@tangelo/tangelo-configuration-toolkit 1.13.0 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -0
- package/LICENSE.md +1 -1
- package/README.md +67 -67
- package/bin/index.js +2 -2
- package/bitbucket-pipelines.yml +32 -0
- package/index.js +4 -1
- package/package.json +4 -1
- package/src/cli.js +10 -5
- package/src/lib/exec-git-command.js +4 -3
- package/src/lib/get-repoconfig.js +1 -1
- package/src/lib/get-tdi-branch.js +46 -0
- package/src/lib/gulp-batch-replace-with-filter.js +19 -19
- package/src/lib/gulp-resolve-includes.js +3 -2
- package/src/lib/gulp-simple-rename.js +11 -11
- package/src/lib/package-update-check.js +15 -14
- package/src/lib/style-string-getters.js +1 -1
- package/src/modules/build/index.js +1 -1
- package/src/modules/build/oxygen.js +167 -167
- package/src/modules/deploy/config.js +1 -1
- package/src/modules/deploy/execute.js +5 -5
- package/src/modules/deploy/index.js +1 -1
- package/src/modules/fonto/commands.js +41 -41
- package/src/modules/fonto/index.js +22 -22
- package/src/modules/git/index.js +96 -1
- package/src/modules/info/index.js +201 -202
- package/src/modules/migrate/index.js +1 -1
- package/src/modules/migrate/steps.js +4 -2
- package/src/modules/sql/index.js +2 -2
|
@@ -1,168 +1,168 @@
|
|
|
1
|
-
const fs = require('fs-extra');
|
|
2
|
-
const globby = require('globby');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const SaxonJS = require('saxon-js');
|
|
5
|
-
|
|
6
|
-
const spConfigPath = path.join(_paths.repo, _paths.tdi, 'tct/build/oxygen/stylesheetPaths.json');
|
|
7
|
-
const sefFilePath = path.join(_paths.repo, _paths.tdi, 'tct/build/oxygen/createProjectFile.sef.json');
|
|
8
|
-
const cmscustomPath = 'config/cmscustom/';
|
|
9
|
-
const siteStylesheetsPath = 'config/txp/site-stylesheets/';
|
|
10
|
-
|
|
11
|
-
const masterFiles = new Set;
|
|
12
|
-
const transformationScenarios = [];
|
|
13
|
-
|
|
14
|
-
const convertToValidFilename = (string) => string.replace(/[\/|\\:*?"<>]/g, " ");
|
|
15
|
-
|
|
16
|
-
const createProjectFile = (config) => {
|
|
17
|
-
_info('Initializing xpr file(s):');
|
|
18
|
-
const xprFiles = globby.sync(`*.xpr`);
|
|
19
|
-
|
|
20
|
-
// Copy xpr file from TDI if it does not exists yet;
|
|
21
|
-
if (xprFiles[0]) _write(`Found: ${xprFiles.join(', ')}`);
|
|
22
|
-
else {
|
|
23
|
-
const customers = new Set;
|
|
24
|
-
_repoconfig.forEach(p => customers.add(p.customer_name));
|
|
25
|
-
xprFiles.push(convertToValidFilename([...customers].join(' - ')) + '.xpr');
|
|
26
|
-
fs.copySync(path.join(_paths.repo, 'tangelo-default-implementation/src/[customer].xpr'), path.join(_paths.repo, xprFiles[0]));
|
|
27
|
-
_write(`Created: '${xprFiles[0]}'`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Search for transformationScenarios/masterfiles based on TDI submodule oxygenProjectFile config
|
|
31
|
-
_info('\nSearching for transformationScenarios/masterfiles');
|
|
32
|
-
config.oxygenProjectFile.forEach(
|
|
33
|
-
pf => {
|
|
34
|
-
// Collect transformation scenarios and add them to the transformationScenarios array; add individual stylesheets to the masterFiles set.
|
|
35
|
-
if (pf.transformation) getTransformations(pf.transformation);
|
|
36
|
-
// Add files to the masterfiles set.
|
|
37
|
-
else if (pf.masterfile) getMasterfiles(pf.masterfile);
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
// update all .xpr files with collected transformation scenarios and masterfiles.
|
|
42
|
-
transformXprFile(xprFiles);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const getTransformations = (config) => {
|
|
46
|
-
_repoconfig.forEach(rc => {
|
|
47
|
-
// get pathname of customer/project
|
|
48
|
-
const [customerPath, projectPath] = config.location == 'database' ? rc.path_dbconfig : rc.path_cmscustom;
|
|
49
|
-
|
|
50
|
-
// set pathname of customer/project in location glob-expression
|
|
51
|
-
const location = path.join(
|
|
52
|
-
_paths.repo,
|
|
53
|
-
config.files.replace(/\[customer\]/, customerPath).replace(/\[project\]/, projectPath)
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
globby
|
|
57
|
-
.sync(`${location}`)
|
|
58
|
-
.forEach(f => {
|
|
59
|
-
// extract baseStrings from file
|
|
60
|
-
const fileString = fs.readFileSync(f).toString();
|
|
61
|
-
const baseStrings = fileString.match(RegExp(config.extracts.base, 'gm'));
|
|
62
|
-
|
|
63
|
-
if (fileString.replace(/\s|^prompt\s.*$/gm,'')!=='') {
|
|
64
|
-
if (baseStrings) {
|
|
65
|
-
baseStrings.forEach(s => {
|
|
66
|
-
// extract type, name, files info from baseString
|
|
67
|
-
const type = config.extracts.type ? s.match(RegExp(config.extracts.type))[1] : config.values.type;
|
|
68
|
-
const name = config.extracts.name ? s.match(RegExp(config.extracts.name))[1] : config.values.name;
|
|
69
|
-
const files = s.match(RegExp(config.extracts.files))[1];
|
|
70
|
-
|
|
71
|
-
// Add transformation scenario to the transformationScenario array
|
|
72
|
-
transformationScenarios.push({
|
|
73
|
-
name: `${type}: ${name} (${rc.customer_name}, ${rc.project_name})`, // note that in createProjectFile.xsl a regex is added that matches scenarios based on this name. This to preserve manually added scenarios.
|
|
74
|
-
transformationScenario: files,
|
|
75
|
-
location: config.location == 'txp' ? siteStylesheetsPath : cmscustomPath
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Add each non-tdi stylesheet in transformation scenario to the masterFiles set
|
|
79
|
-
files.split(',').forEach(f => {
|
|
80
|
-
const filePath = `${config.location == 'txp' ? siteStylesheetsPath : cmscustomPath}${f}`;
|
|
81
|
-
if (!f.startsWith('tdi')) masterFiles.add(filePath);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
} else {
|
|
85
|
-
_write(`No transformation scenarios found in ${f} for '${config.extracts.base}'`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const getMasterfiles = (config) => {
|
|
95
|
-
globby
|
|
96
|
-
.sync(`${path.join(_paths.repo, config.files)}`)
|
|
97
|
-
.forEach(cf => {
|
|
98
|
-
// Check if masterfile should be extracted from file
|
|
99
|
-
const fileString = fs.readFileSync(cf).toString();
|
|
100
|
-
if (fileString.replace(/\s|^prompt\s.*$/gm,'')!=='') {
|
|
101
|
-
if (config.extracts) {
|
|
102
|
-
// extract baseStrings from file
|
|
103
|
-
const baseStrings = fileString.match(RegExp(config.extracts.base, 'gm'));
|
|
104
|
-
|
|
105
|
-
if (baseStrings) {
|
|
106
|
-
baseStrings.forEach(s => {
|
|
107
|
-
// extract (comma-separated) list of masterfiles
|
|
108
|
-
const filesString = s.match(RegExp(config.extracts.files))[1];
|
|
109
|
-
if (!filesString) _error(`No masterfiles found in '${s}' for '${config.extracts.files}'`);
|
|
110
|
-
|
|
111
|
-
// Add each non-tdi masterfile to the masterFiles set
|
|
112
|
-
filesString.split(',').forEach(f => {
|
|
113
|
-
if (!f.startsWith('tdi')){
|
|
114
|
-
const filePath = `${config.location == 'txp' ? siteStylesheetsPath : cmscustomPath}${f}`;
|
|
115
|
-
masterFiles.add(filePath);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
} else {
|
|
120
|
-
_write(`No masterfiles found in ${cf} for '${config.extracts.base}'`);
|
|
121
|
-
}
|
|
122
|
-
} else { // Add synced file to masterfiles; strip path from c:/... hence it starts with config/cmscustom or config/txp/site-stylesheets
|
|
123
|
-
const filePath = config.location == 'txp' ? `${siteStylesheetsPath}${cf.split(siteStylesheetsPath)[1]}` : `${cmscustomPath}${cf.split(cmscustomPath)[1]}`;
|
|
124
|
-
masterFiles.add(filePath);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const transformXprFile = (xprFiles) => {
|
|
132
|
-
_info('\nUpdating xpr file(s):');
|
|
133
|
-
// create with: xslt3 -t -xsl:createProjectFile.xsl -export:createProjectFile.sef.json v -nogo'
|
|
134
|
-
|
|
135
|
-
xprFiles
|
|
136
|
-
.forEach(xprFile => {
|
|
137
|
-
// Transform xpr; add masterfiles and transformationScenarios as parameters of the stylesheet
|
|
138
|
-
_write(`${xprFile}\n`);
|
|
139
|
-
SaxonJS.transform({
|
|
140
|
-
stylesheetText: fs.readFileSync(sefFilePath),
|
|
141
|
-
stylesheetBaseURI: 'createProjectFile.sef.json',
|
|
142
|
-
sourceFileName: path.join(_paths.repo, xprFile),
|
|
143
|
-
destination: 'serialized',
|
|
144
|
-
stylesheetParams: {
|
|
145
|
-
'masterfiles': [...masterFiles],
|
|
146
|
-
'Q{}transformationScenarios': transformationScenarios
|
|
147
|
-
}
|
|
148
|
-
}, 'async')
|
|
149
|
-
.then(output => {
|
|
150
|
-
// Write result of transformation to xpr file
|
|
151
|
-
fs.writeFileSync(path.join(_paths.repo, xprFile), output.principalResult);
|
|
152
|
-
})
|
|
153
|
-
.catch(e => _warn(`Failed to update: ${xprFile}\n ${e}`));
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
module.exports = function oxygen () {
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
|
|
163
|
-
if (!fs.existsSync(spConfigPath) || !fs.existsSync(sefFilePath)) {
|
|
164
|
-
_error(`Cannot find required files in TDI submodule. Try updating TDI submodule.`);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
createProjectFile(require(spConfigPath));
|
|
1
|
+
const fs = require('fs-extra');
|
|
2
|
+
const globby = require('globby');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const SaxonJS = require('saxon-js');
|
|
5
|
+
|
|
6
|
+
const spConfigPath = path.join(_paths.repo, _paths.tdi, 'tct/build/oxygen/stylesheetPaths.json');
|
|
7
|
+
const sefFilePath = path.join(_paths.repo, _paths.tdi, 'tct/build/oxygen/createProjectFile.sef.json');
|
|
8
|
+
const cmscustomPath = 'config/cmscustom/';
|
|
9
|
+
const siteStylesheetsPath = 'config/txp/site-stylesheets/';
|
|
10
|
+
|
|
11
|
+
const masterFiles = new Set;
|
|
12
|
+
const transformationScenarios = [];
|
|
13
|
+
|
|
14
|
+
const convertToValidFilename = (string) => string.replace(/[\/|\\:*?"<>]/g, " ");
|
|
15
|
+
|
|
16
|
+
const createProjectFile = (config) => {
|
|
17
|
+
_info('Initializing xpr file(s):');
|
|
18
|
+
const xprFiles = globby.sync(`*.xpr`);
|
|
19
|
+
|
|
20
|
+
// Copy xpr file from TDI if it does not exists yet;
|
|
21
|
+
if (xprFiles[0]) _write(`Found: ${xprFiles.join(', ')}`);
|
|
22
|
+
else {
|
|
23
|
+
const customers = new Set;
|
|
24
|
+
_repoconfig.forEach(p => customers.add(p.customer_name));
|
|
25
|
+
xprFiles.push(convertToValidFilename([...customers].join(' - ')) + '.xpr');
|
|
26
|
+
fs.copySync(path.join(_paths.repo, 'tangelo-default-implementation/src/[customer].xpr'), path.join(_paths.repo, xprFiles[0]));
|
|
27
|
+
_write(`Created: '${xprFiles[0]}'`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Search for transformationScenarios/masterfiles based on TDI submodule oxygenProjectFile config
|
|
31
|
+
_info('\nSearching for transformationScenarios/masterfiles');
|
|
32
|
+
config.oxygenProjectFile.forEach(
|
|
33
|
+
pf => {
|
|
34
|
+
// Collect transformation scenarios and add them to the transformationScenarios array; add individual stylesheets to the masterFiles set.
|
|
35
|
+
if (pf.transformation) getTransformations(pf.transformation);
|
|
36
|
+
// Add files to the masterfiles set.
|
|
37
|
+
else if (pf.masterfile) getMasterfiles(pf.masterfile);
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// update all .xpr files with collected transformation scenarios and masterfiles.
|
|
42
|
+
transformXprFile(xprFiles);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getTransformations = (config) => {
|
|
46
|
+
_repoconfig.forEach(rc => {
|
|
47
|
+
// get pathname of customer/project
|
|
48
|
+
const [customerPath, projectPath] = config.location == 'database' ? rc.path_dbconfig : rc.path_cmscustom;
|
|
49
|
+
|
|
50
|
+
// set pathname of customer/project in location glob-expression
|
|
51
|
+
const location = path.join(
|
|
52
|
+
_paths.repo,
|
|
53
|
+
config.files.replace(/\[customer\]/, customerPath).replace(/\[project\]/, projectPath)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
globby
|
|
57
|
+
.sync(`${location}`)
|
|
58
|
+
.forEach(f => {
|
|
59
|
+
// extract baseStrings from file
|
|
60
|
+
const fileString = fs.readFileSync(f).toString();
|
|
61
|
+
const baseStrings = fileString.match(RegExp(config.extracts.base, 'gm'));
|
|
62
|
+
|
|
63
|
+
if (fileString.replace(/\s|^prompt\s.*$/gm,'')!=='') {
|
|
64
|
+
if (baseStrings) {
|
|
65
|
+
baseStrings.forEach(s => {
|
|
66
|
+
// extract type, name, files info from baseString
|
|
67
|
+
const type = config.extracts.type ? s.match(RegExp(config.extracts.type))[1] : config.values.type;
|
|
68
|
+
const name = config.extracts.name ? s.match(RegExp(config.extracts.name))[1] : config.values.name;
|
|
69
|
+
const files = s.match(RegExp(config.extracts.files))[1];
|
|
70
|
+
|
|
71
|
+
// Add transformation scenario to the transformationScenario array
|
|
72
|
+
transformationScenarios.push({
|
|
73
|
+
name: `${type}: ${name} (${rc.customer_name}, ${rc.project_name})`, // note that in createProjectFile.xsl a regex is added that matches scenarios based on this name. This to preserve manually added scenarios.
|
|
74
|
+
transformationScenario: files,
|
|
75
|
+
location: config.location == 'txp' ? siteStylesheetsPath : cmscustomPath
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Add each non-tdi stylesheet in transformation scenario to the masterFiles set
|
|
79
|
+
files.split(',').forEach(f => {
|
|
80
|
+
const filePath = `${config.location == 'txp' ? siteStylesheetsPath : cmscustomPath}${f}`;
|
|
81
|
+
if (!f.startsWith('tdi')) masterFiles.add(filePath);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
_write(`No transformation scenarios found in ${f} for '${config.extracts.base}'`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
const getMasterfiles = (config) => {
|
|
95
|
+
globby
|
|
96
|
+
.sync(`${path.join(_paths.repo, config.files)}`)
|
|
97
|
+
.forEach(cf => {
|
|
98
|
+
// Check if masterfile should be extracted from file
|
|
99
|
+
const fileString = fs.readFileSync(cf).toString();
|
|
100
|
+
if (fileString.replace(/\s|^prompt\s.*$/gm,'')!=='') {
|
|
101
|
+
if (config.extracts) {
|
|
102
|
+
// extract baseStrings from file
|
|
103
|
+
const baseStrings = fileString.match(RegExp(config.extracts.base, 'gm'));
|
|
104
|
+
|
|
105
|
+
if (baseStrings) {
|
|
106
|
+
baseStrings.forEach(s => {
|
|
107
|
+
// extract (comma-separated) list of masterfiles
|
|
108
|
+
const filesString = s.match(RegExp(config.extracts.files))[1];
|
|
109
|
+
if (!filesString) _error(`No masterfiles found in '${s}' for '${config.extracts.files}'`);
|
|
110
|
+
|
|
111
|
+
// Add each non-tdi masterfile to the masterFiles set
|
|
112
|
+
filesString.split(',').forEach(f => {
|
|
113
|
+
if (!f.startsWith('tdi')){
|
|
114
|
+
const filePath = `${config.location == 'txp' ? siteStylesheetsPath : cmscustomPath}${f}`;
|
|
115
|
+
masterFiles.add(filePath);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
_write(`No masterfiles found in ${cf} for '${config.extracts.base}'`);
|
|
121
|
+
}
|
|
122
|
+
} else { // Add synced file to masterfiles; strip path from c:/... hence it starts with config/cmscustom or config/txp/site-stylesheets
|
|
123
|
+
const filePath = config.location == 'txp' ? `${siteStylesheetsPath}${cf.split(siteStylesheetsPath)[1]}` : `${cmscustomPath}${cf.split(cmscustomPath)[1]}`;
|
|
124
|
+
masterFiles.add(filePath);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const transformXprFile = (xprFiles) => {
|
|
132
|
+
_info('\nUpdating xpr file(s):');
|
|
133
|
+
// create with: xslt3 -t -xsl:createProjectFile.xsl -export:createProjectFile.sef.json v -nogo'
|
|
134
|
+
|
|
135
|
+
xprFiles
|
|
136
|
+
.forEach(xprFile => {
|
|
137
|
+
// Transform xpr; add masterfiles and transformationScenarios as parameters of the stylesheet
|
|
138
|
+
_write(`${xprFile}\n`);
|
|
139
|
+
SaxonJS.transform({
|
|
140
|
+
stylesheetText: fs.readFileSync(sefFilePath),
|
|
141
|
+
stylesheetBaseURI: 'createProjectFile.sef.json',
|
|
142
|
+
sourceFileName: path.join(_paths.repo, xprFile),
|
|
143
|
+
destination: 'serialized',
|
|
144
|
+
stylesheetParams: {
|
|
145
|
+
'masterfiles': [...masterFiles],
|
|
146
|
+
'Q{}transformationScenarios': transformationScenarios
|
|
147
|
+
}
|
|
148
|
+
}, 'async')
|
|
149
|
+
.then(output => {
|
|
150
|
+
// Write result of transformation to xpr file
|
|
151
|
+
fs.writeFileSync(path.join(_paths.repo, xprFile), output.principalResult);
|
|
152
|
+
})
|
|
153
|
+
.catch(e => _warn(`Failed to update: ${xprFile}\n ${e}`));
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
module.exports = function oxygen () {
|
|
159
|
+
// Set projects transformation scenarios and masterfiles in oXygen project file
|
|
160
|
+
// - Will try to preserve manually added entries in the transformation scenarios and masterfiles
|
|
161
|
+
// - Will remove non existing masterfiles or masterfiles that start with a '_'
|
|
162
|
+
|
|
163
|
+
if (!fs.existsSync(spConfigPath) || !fs.existsSync(sefFilePath)) {
|
|
164
|
+
_error(`Cannot find required files in TDI submodule. Try updating TDI submodule.`);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
createProjectFile(require(spConfigPath));
|
|
168
168
|
};
|
|
@@ -91,7 +91,7 @@ module.exports = {
|
|
|
91
91
|
let transferPattern = path.join(_paths.apply, filter).toFws();
|
|
92
92
|
|
|
93
93
|
// test if 'cmscustom/tdi' would be included, then add specifically, because following symlinks doesnt work with glob stars
|
|
94
|
-
const tdiIncRegex = /^(config\/)?(({\w*,?)?cmscustom(,?\w
|
|
94
|
+
const tdiIncRegex = /^(config\/)?((\{\w*,?)?cmscustom(,?\w*\})?\/|\*\/)?\*\*/;
|
|
95
95
|
const tdiPattern = tdiIncRegex.test(transferPattern) ? transferPattern.replace(tdiIncRegex, `${this.deliveryPack ? 'config/' : ''}cmscustom/tdi/**`) : 'nomatch';
|
|
96
96
|
|
|
97
97
|
if (!transferPattern)
|
|
@@ -32,7 +32,7 @@ const remote = {
|
|
|
32
32
|
do(sshI) {
|
|
33
33
|
let executing = Math.min(this.queue.length, c.server.ftpConfig.parallel);
|
|
34
34
|
|
|
35
|
-
if (executing
|
|
35
|
+
if (executing===0) { // close connection and return callback after last exec command
|
|
36
36
|
sshI.dispose();
|
|
37
37
|
_write();
|
|
38
38
|
}
|
|
@@ -48,14 +48,14 @@ const remote = {
|
|
|
48
48
|
else _info(command[1] || command[0], true);
|
|
49
49
|
|
|
50
50
|
executing--;
|
|
51
|
-
if (executing
|
|
51
|
+
if (executing===0) this.do(sshI);
|
|
52
52
|
})
|
|
53
|
-
.catch(
|
|
53
|
+
.catch(() => {
|
|
54
54
|
_warn(`Server aborted connection. Retrying.`);
|
|
55
55
|
this.queue.unshift(command);
|
|
56
56
|
|
|
57
57
|
executing--;
|
|
58
|
-
if (executing
|
|
58
|
+
if (executing===0) this.do(sshI);
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
},
|
|
@@ -189,7 +189,7 @@ const transfer = (paths, lrServer) => {
|
|
|
189
189
|
remote.process();
|
|
190
190
|
|
|
191
191
|
if (lrServer) { // reload specific resources if files are all image or css, else reload page
|
|
192
|
-
const reloadPage = !files.every(f => /.(css|jpe?g|png|gif)$/i.test(f));
|
|
192
|
+
const reloadPage = !files.every(f => /.(?:css|jpe?g|png|gif)$/i.test(f));
|
|
193
193
|
lrServer.changed({params: {files: reloadPage ? ['page'] : files}});
|
|
194
194
|
_info(`${reloadPage ? 'Page' : 'Resources'} reloaded\n`);
|
|
195
195
|
}
|
|
@@ -90,7 +90,7 @@ module.exports = function deploy (argv) {
|
|
|
90
90
|
if (!path.parse(filepath).base.match(/\.scss/)) {
|
|
91
91
|
const rp = c.getRemotePath(filepath);
|
|
92
92
|
const msg = 'Removed: ' + rp.replace(c.server.remotedir, '').white;
|
|
93
|
-
if (c.localTransfer) del([rp], {force: true}).then(
|
|
93
|
+
if (c.localTransfer) del([rp], {force: true}).then(() => _info(msg, true));
|
|
94
94
|
else remote.add(`rm -rf "${rp}"`, msg).process();
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -38,7 +38,7 @@ const cmdExec = command => new Promise((resolve) => {
|
|
|
38
38
|
});
|
|
39
39
|
cp.stderr.setEncoding('utf8');
|
|
40
40
|
cp.stderr.on('data', data => log(data.replace(/Browserslist: caniuse-lite .*/s, '')));
|
|
41
|
-
cp.on('close',
|
|
41
|
+
cp.on('close', () => {
|
|
42
42
|
_write();
|
|
43
43
|
resolve();
|
|
44
44
|
});
|
|
@@ -49,15 +49,15 @@ module.exports = {
|
|
|
49
49
|
|
|
50
50
|
init ([fdt, fontoVersion]) {
|
|
51
51
|
return new Promise((resolve, reject) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
_info('Ensure symlink exists:');
|
|
53
|
+
fs.symlink(path.join('../../../tdi/fonto/packages-shared'), 'packages-shared', 'dir', err => {
|
|
54
|
+
if (err && err.code!='EEXIST') reject(err.code=='EPERM' ? 'Start your console as admin for symlink creation!' : err);
|
|
55
|
+
else _write('Done.\n');
|
|
56
|
+
resolve();
|
|
57
|
+
});
|
|
58
|
+
})
|
|
59
|
+
.then(() => cmdExec(`${fdt} editor upgrade --version ${fontoVersion} --non-interactive`))
|
|
60
|
+
.then(() => [fdt])
|
|
61
61
|
;
|
|
62
62
|
},
|
|
63
63
|
|
|
@@ -77,7 +77,7 @@ module.exports = {
|
|
|
77
77
|
|
|
78
78
|
// add dependency for sx-module to each package fonto-manifest.json
|
|
79
79
|
// add schema packages in fonto.json to config/fonto-manifest.json
|
|
80
|
-
Object.entries(rootSchemas).forEach(([
|
|
80
|
+
Object.entries(rootSchemas).forEach(([, obj]) => {
|
|
81
81
|
const pckPath = 'packages/' + obj.packageName;
|
|
82
82
|
const pckFontoManifest = fs.readJsonSync(pckPath + '/fonto-manifest.json', {throws: false}) || {dependencies: {}};
|
|
83
83
|
pckFontoManifest.dependencies['sx-module'] = 'packages/sx-module';
|
|
@@ -100,8 +100,8 @@ module.exports = {
|
|
|
100
100
|
_info('Copying schema json files to build folders:');
|
|
101
101
|
// deploy-watch copies schema's to server directly, so update local builds to keep integrity
|
|
102
102
|
jsonPaths.forEach(jsonPath => {
|
|
103
|
-
fs.copySync(jsonPath, 'dev/assets/schemas/' + jsonPath.match(/[
|
|
104
|
-
fs.copySync(jsonPath, 'dist/assets/schemas/' + jsonPath.match(/[
|
|
103
|
+
fs.copySync(jsonPath, 'dev/assets/schemas/' + jsonPath.match(/[^/]*$/)[0]);
|
|
104
|
+
fs.copySync(jsonPath, 'dist/assets/schemas/' + jsonPath.match(/[^/]*$/)[0]);
|
|
105
105
|
});
|
|
106
106
|
_write('Done.\n');
|
|
107
107
|
})
|
|
@@ -125,7 +125,7 @@ module.exports = {
|
|
|
125
125
|
|
|
126
126
|
// execute "fdt elements" for each schema package, ignore default elements, and combine results
|
|
127
127
|
const schemasPerElement = {};
|
|
128
|
-
Object.entries(rootSchemas).forEach(([
|
|
128
|
+
Object.entries(rootSchemas).forEach(([, obj]) => {
|
|
129
129
|
const data = execSync(`${fdt} elements --schema packages/${obj.packageName}/src/assets/schemas/${obj.packageName}.json -C name`, {encoding: 'UTF-8'});
|
|
130
130
|
const elements = data.replace(/(^.*?Name\*)|(Printed name\*.*$)/gs, '').split(/\s+/);
|
|
131
131
|
const customElements = [...new Set(elements)].filter(e => e && !ignoreElements.includes(e));
|
|
@@ -142,19 +142,19 @@ module.exports = {
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
return wws(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
145
|
+
'searching',
|
|
146
|
+
findElements,
|
|
147
|
+
{
|
|
148
|
+
fdt,
|
|
149
|
+
rootSchemas: fs.readJsonSync('../schema/fonto.json').rootSchemas,
|
|
150
|
+
tdiXsdPath: path.join(_paths.repo, _paths.tdi, 'src/config/cmscustom/[customer]/[project]/schema/xsd/')
|
|
151
|
+
},
|
|
152
|
+
result => {
|
|
153
|
+
if (Array.isArray(result)) result.forEach(([e, s]) => _write(e, s, '\n'));
|
|
154
|
+
else _write(result, '\n');
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
.then(() => [fdt])
|
|
158
158
|
;
|
|
159
159
|
},
|
|
160
160
|
|
|
@@ -174,7 +174,7 @@ module.exports = {
|
|
|
174
174
|
|
|
175
175
|
// execute "fdt attributes" for each schema package, ignore default attributes, and combine results
|
|
176
176
|
const schemasPerAttribute = {};
|
|
177
|
-
Object.entries(rootSchemas).forEach(([
|
|
177
|
+
Object.entries(rootSchemas).forEach(([, obj]) => {
|
|
178
178
|
const data = execSync(`${fdt} attributes --schema packages/${obj.packageName}/src/assets/schemas/${obj.packageName}.json`, {encoding: 'UTF-8'});
|
|
179
179
|
const attributes = data.replace(/(^.*?Default value\s+)|(\s+Printed name\*.*$)/gs, '').split(/\n\s+/).map(a => a.split(/\s+/)).map(a =>
|
|
180
180
|
a[0] + (a[2]=='required' ? ' (required)' : '') + (a[3]=='-' ? ' (no default)' : '')
|
|
@@ -193,19 +193,19 @@ module.exports = {
|
|
|
193
193
|
};
|
|
194
194
|
|
|
195
195
|
return wws(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
196
|
+
'searching',
|
|
197
|
+
findAttributes,
|
|
198
|
+
{
|
|
199
|
+
fdt,
|
|
200
|
+
rootSchemas: fs.readJsonSync('../schema/fonto.json').rootSchemas,
|
|
201
|
+
tdiXsdPath: path.join(_paths.repo, _paths.tdi, 'src/config/cmscustom/[customer]/[project]/schema/xsd/')
|
|
202
|
+
},
|
|
203
|
+
result => {
|
|
204
|
+
if (Array.isArray(result)) result.forEach(([e, s]) => _write(e, s, '\n'));
|
|
205
|
+
else _write(result, '\n');
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
.then(() => [fdt])
|
|
209
209
|
;
|
|
210
210
|
},
|
|
211
211
|
|
|
@@ -33,7 +33,7 @@ module.exports = function fonto (argv) {
|
|
|
33
33
|
.map(p => ([p.replace('manifest.json', ''), fs.readJsonSync(p).sdkVersion.replace(/Nightlies.*/, 'nightly')])
|
|
34
34
|
);
|
|
35
35
|
|
|
36
|
-
if (fontoPaths.length
|
|
36
|
+
if (fontoPaths.length===0) _error('No Fonto instance found.');
|
|
37
37
|
|
|
38
38
|
let promiseChain = Promise.resolve(); // for sequentially executing commands for each fonto instance
|
|
39
39
|
|
|
@@ -47,27 +47,27 @@ module.exports = function fonto (argv) {
|
|
|
47
47
|
|
|
48
48
|
// execute commands sequentially and in correct order
|
|
49
49
|
return new Promise((resolve) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
50
|
+
_info('Determining Fonto version:');
|
|
51
|
+
let fontoVersionNew = typeof argv.init == 'string' ? argv.init : fontoVersionCurrent;
|
|
52
|
+
|
|
53
|
+
if (fontoVersionNew == 'latest') {
|
|
54
|
+
const data = execSync(`${fdtCommand(fontoVersionCurrent)} editor versions`, {encoding: 'UTF-8'});
|
|
55
|
+
fontoVersionNew = data.match(/\d+\.\d+\.\d+/g).filter(v => allowedFontoVersionRegex.test(v))[0];
|
|
56
|
+
}
|
|
57
|
+
else if (!allowedFontoVersionRegex.test(fontoVersionNew)) {
|
|
58
|
+
_error(`Fonto version ${fontoVersionNew} is not compatible with the current TDI submodule commit!\nExecute: tct fonto --init latest`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_write(fontoVersionNew+'\n');
|
|
62
|
+
return resolve([fdtCommand(fontoVersionNew), fontoVersionNew]);
|
|
63
|
+
})
|
|
64
|
+
.then(argv.init && commands.init)
|
|
65
|
+
.then(argv.schema && commands.schema)
|
|
66
|
+
.then(argv.elements && commands.elements)
|
|
67
|
+
.then(argv.attributes && commands.attributes)
|
|
68
|
+
.then(argv.localize && commands.localize)
|
|
69
|
+
.then(argv.build && commands.build)
|
|
70
|
+
.then(argv.run && commands.run)
|
|
71
71
|
;
|
|
72
72
|
});
|
|
73
73
|
});
|