@tangelo/tangelo-configuration-toolkit 1.14.3 → 1.14.4
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/.pre-commit-config.yaml +9 -10
- package/.vscode/settings.json +6 -0
- package/README.md +67 -67
- package/bin/index.js +2 -2
- package/bitbucket-pipelines.yml +7 -7
- package/index.js +8 -8
- package/package.json +6 -6
- package/src/lib/get-repoconfig.js +3 -3
- package/src/lib/get-tdi-branch.js +43 -43
- package/src/lib/gulp-batch-replace-with-filter.js +19 -19
- package/src/lib/gulp-simple-rename.js +11 -11
- package/src/lib/style-string-getters.js +2 -0
- package/src/modules/build/oxygen.js +174 -174
- package/src/modules/fonto/commands.js +4 -4
- package/src/modules/fonto/index.js +8 -8
- package/src/modules/git/index.js +1 -1
- package/src/modules/info/index.js +201 -201
|
@@ -1,175 +1,175 @@
|
|
|
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 =
|
|
15
|
-
|
|
16
|
-
const createProjectFile = (config,
|
|
17
|
-
_info('Initializing xpr file(s):');
|
|
18
|
-
const xprFiles = [...globby.sync(`*.xpr`)];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
'
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
//
|
|
167
|
-
// - Will
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
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, newXprFile) => {
|
|
17
|
+
_info('Initializing xpr file(s):');
|
|
18
|
+
const xprFiles = [...globby.sync(`*.xpr`)];
|
|
19
|
+
// Add newXprFile at the start of xprFiles if it does not already exists:
|
|
20
|
+
if (newXprFile && xprFiles.indexOf(newXprFile)===-1) xprFiles.unshift(newXprFile);
|
|
21
|
+
|
|
22
|
+
// Copy xpr file from TDI if it does not exists yet;
|
|
23
|
+
if (xprFiles[0] && !newXprFile) _write(`Found: ${xprFiles.join(', ')}`);
|
|
24
|
+
else {
|
|
25
|
+
if (!newXprFile) {
|
|
26
|
+
// Set xpr filename to customer name (assumes correct upsert scripts structure)
|
|
27
|
+
const customers = new Set;
|
|
28
|
+
_repoconfig.forEach(p => customers.add(p.customer_name));
|
|
29
|
+
xprFiles.push(convertToValidFilename([...customers].join(' - ')) + '.xpr');
|
|
30
|
+
}
|
|
31
|
+
// Copy new xpr file
|
|
32
|
+
fs.copySync(path.join(_paths.repo, 'tangelo-default-implementation/src/[customer].xpr'), path.join(_paths.repo, xprFiles[0]));
|
|
33
|
+
_write(`Created: '${xprFiles[0]}'`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Search for transformationScenarios/masterfiles based on TDI submodule oxygenProjectFile config
|
|
37
|
+
_info('\nSearching for transformationScenarios/masterfiles');
|
|
38
|
+
config.oxygenProjectFile.forEach(
|
|
39
|
+
pf => {
|
|
40
|
+
// Collect transformation scenarios and add them to the transformationScenarios array; add individual stylesheets to the masterFiles set.
|
|
41
|
+
if (pf.transformation) getTransformations(pf.transformation);
|
|
42
|
+
// Add files to the masterfiles set.
|
|
43
|
+
else if (pf.masterfile) getMasterfiles(pf.masterfile);
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
// update all .xpr files with collected transformation scenarios and masterfiles.
|
|
48
|
+
transformXprFile(xprFiles);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const getTransformations = config => {
|
|
52
|
+
_repoconfig.forEach(rc => {
|
|
53
|
+
// get pathname of customer/project
|
|
54
|
+
const [customerPath, projectPath] = config.location === 'database' ? rc.path_dbconfig : rc.path_cmscustom;
|
|
55
|
+
|
|
56
|
+
// set pathname of customer/project in location glob-expression
|
|
57
|
+
const location = path.join(
|
|
58
|
+
_paths.repo,
|
|
59
|
+
config.files.replace(/\[customer\]/, customerPath).replace(/\[project\]/, projectPath)
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
globby
|
|
63
|
+
.sync(`${location}`)
|
|
64
|
+
.forEach(f => {
|
|
65
|
+
// extract baseStrings from file
|
|
66
|
+
const fileString = fs.readFileSync(f).toString();
|
|
67
|
+
const baseStrings = fileString.match(RegExp(config.extracts.base, 'gm'));
|
|
68
|
+
|
|
69
|
+
if (fileString.replace(/\s|^prompt\s.*$/gm, '') !== '') {
|
|
70
|
+
if (baseStrings) {
|
|
71
|
+
baseStrings.forEach(s => {
|
|
72
|
+
// extract type, name, files info from baseString
|
|
73
|
+
const type = config.extracts.type ? s.match(RegExp(config.extracts.type))[1] : config.values.type;
|
|
74
|
+
const name = config.extracts.name ? s.match(RegExp(config.extracts.name))[1] : config.values.name;
|
|
75
|
+
const files = s.match(RegExp(config.extracts.files))[1];
|
|
76
|
+
|
|
77
|
+
// Add transformation scenario to the transformationScenario array
|
|
78
|
+
transformationScenarios.push({
|
|
79
|
+
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.
|
|
80
|
+
transformationScenario: files,
|
|
81
|
+
location: config.location === 'txp' ? siteStylesheetsPath : cmscustomPath
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Add each non-tdi stylesheet in transformation scenario to the masterFiles set
|
|
85
|
+
files.split(',').forEach(f => {
|
|
86
|
+
const filePath = `${config.location === 'txp' ? siteStylesheetsPath : cmscustomPath}${f}`;
|
|
87
|
+
if (!f.startsWith('tdi')) masterFiles.add(filePath);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
_write(`No transformation scenarios found in ${f} for '${config.extracts.base}'`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
const getMasterfiles = config => {
|
|
101
|
+
globby
|
|
102
|
+
.sync(`${path.join(_paths.repo, config.files)}`)
|
|
103
|
+
.forEach(cf => {
|
|
104
|
+
// Check if masterfile should be extracted from file
|
|
105
|
+
const fileString = fs.readFileSync(cf).toString();
|
|
106
|
+
if (fileString.replace(/\s|^prompt\s.*$/gm, '')!=='') {
|
|
107
|
+
if (config.extracts) {
|
|
108
|
+
// extract baseStrings from file
|
|
109
|
+
const baseStrings = fileString.match(RegExp(config.extracts.base, 'gm'));
|
|
110
|
+
|
|
111
|
+
if (baseStrings) {
|
|
112
|
+
baseStrings.forEach(s => {
|
|
113
|
+
// extract (comma-separated) list of masterfiles
|
|
114
|
+
const filesString = s.match(RegExp(config.extracts.files))[1];
|
|
115
|
+
if (!filesString) _error(`No masterfiles found in '${s}' for '${config.extracts.files}'`);
|
|
116
|
+
|
|
117
|
+
// Add each non-tdi masterfile to the masterFiles set
|
|
118
|
+
filesString.split(',').forEach(f => {
|
|
119
|
+
if (!f.startsWith('tdi')){
|
|
120
|
+
const filePath = `${config.location === 'txp' ? siteStylesheetsPath : cmscustomPath}${f}`;
|
|
121
|
+
masterFiles.add(filePath);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
_write(`No masterfiles found in ${cf} for '${config.extracts.base}'`);
|
|
127
|
+
}
|
|
128
|
+
} else { // Add synced file to masterfiles; strip path from c:/... hence it starts with config/cmscustom or config/txp/site-stylesheets
|
|
129
|
+
const filePath = config.location === 'txp' ? `${siteStylesheetsPath}${cf.split(siteStylesheetsPath)[1]}` : `${cmscustomPath}${cf.split(cmscustomPath)[1]}`;
|
|
130
|
+
masterFiles.add(filePath);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const transformXprFile = xprFiles => {
|
|
138
|
+
_info('\nUpdating xpr file(s):');
|
|
139
|
+
// create with: xslt3 -t -xsl:createProjectFile.xsl -export:createProjectFile.sef.json v -nogo'
|
|
140
|
+
|
|
141
|
+
xprFiles
|
|
142
|
+
.forEach(xprFile => {
|
|
143
|
+
// Transform xpr; add masterfiles and transformationScenarios as parameters of the stylesheet
|
|
144
|
+
_write(`${xprFile}\n`);
|
|
145
|
+
SaxonJS.transform({
|
|
146
|
+
stylesheetText: fs.readFileSync(sefFilePath),
|
|
147
|
+
stylesheetBaseURI: 'createProjectFile.sef.json',
|
|
148
|
+
sourceFileName: path.join(_paths.repo, xprFile),
|
|
149
|
+
destination: 'serialized',
|
|
150
|
+
stylesheetParams: {
|
|
151
|
+
'masterfiles': [...masterFiles],
|
|
152
|
+
'Q{}transformationScenarios': transformationScenarios
|
|
153
|
+
}
|
|
154
|
+
}, 'async')
|
|
155
|
+
.then(output => {
|
|
156
|
+
// Write result of transformation to xpr file
|
|
157
|
+
fs.writeFileSync(path.join(_paths.repo, xprFile), output.principalResult);
|
|
158
|
+
})
|
|
159
|
+
.catch(e => _warn(`Failed to update: ${xprFile}\n ${e}`));
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
module.exports = function oxygen (arg) {
|
|
165
|
+
// Set projects transformation scenarios and masterfiles in oXygen project file
|
|
166
|
+
// - Will try to preserve manually added entries in the transformation scenarios and masterfiles
|
|
167
|
+
// - Will remove non existing masterfiles or masterfiles that start with a '_'
|
|
168
|
+
|
|
169
|
+
if (!fs.existsSync(spConfigPath) || !fs.existsSync(sefFilePath)) {
|
|
170
|
+
_error(`Cannot find required files in TDI submodule. Try updating TDI submodule.`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const newXprFile = (typeof arg === 'string') ? convertToValidFilename(arg) + '.xpr' : null;
|
|
174
|
+
createProjectFile(require(spConfigPath), newXprFile);
|
|
175
175
|
};
|
|
@@ -56,8 +56,8 @@ module.exports = {
|
|
|
56
56
|
resolve();
|
|
57
57
|
});
|
|
58
58
|
})
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
.then(() => cmdExec(`${fdt} editor upgrade --version ${fontoVersion} --non-interactive`))
|
|
60
|
+
.then(() => [fdt])
|
|
61
61
|
;
|
|
62
62
|
},
|
|
63
63
|
|
|
@@ -154,7 +154,7 @@ module.exports = {
|
|
|
154
154
|
else _write(result, '\n');
|
|
155
155
|
}
|
|
156
156
|
)
|
|
157
|
-
|
|
157
|
+
.then(() => [fdt])
|
|
158
158
|
;
|
|
159
159
|
},
|
|
160
160
|
|
|
@@ -205,7 +205,7 @@ module.exports = {
|
|
|
205
205
|
else _write(result, '\n');
|
|
206
206
|
}
|
|
207
207
|
)
|
|
208
|
-
|
|
208
|
+
.then(() => [fdt])
|
|
209
209
|
;
|
|
210
210
|
},
|
|
211
211
|
|
|
@@ -31,7 +31,7 @@ module.exports = function fonto (argv) {
|
|
|
31
31
|
// find fonto instances by searching for fonto/manifest.json files
|
|
32
32
|
const fontoPaths = globby.sync(['**/fonto/manifest.json', 'manifest.json', `!${_paths.tdi}/**`])
|
|
33
33
|
.map(p => ([p.replace('manifest.json', ''), fs.readJsonSync(p).sdkVersion.replace(/Nightlies.*/, 'nightly')])
|
|
34
|
-
|
|
34
|
+
);
|
|
35
35
|
|
|
36
36
|
if (fontoPaths.length===0) _error('No Fonto instance found.');
|
|
37
37
|
|
|
@@ -61,13 +61,13 @@ module.exports = function fonto (argv) {
|
|
|
61
61
|
_write(fontoVersionNew+'\n');
|
|
62
62
|
return resolve([fdtCommand(fontoVersionNew), fontoVersionNew]);
|
|
63
63
|
})
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
});
|
package/src/modules/git/index.js
CHANGED
|
@@ -146,7 +146,7 @@ module.exports = function git (argv) {
|
|
|
146
146
|
if (fs.existsSync(tdiMigrationFilePath)) {
|
|
147
147
|
const migrations = require(tdiMigrationFilePath);
|
|
148
148
|
const fromTdiDate = tdiFromDateCustom ? new Date(tdiFromDateCustom) : (tdiBranch.commonAncestor) ? tdiBranch.commonAncestor.date: _git.commitTdi.local().date;
|
|
149
|
-
const toTdiDate = tdiToDateCustom ? new Date(tdiToDateCustom) : new Date(
|
|
149
|
+
const toTdiDate = tdiToDateCustom ? new Date(tdiToDateCustom) : new Date();
|
|
150
150
|
|
|
151
151
|
_info(`TDI commits requiring migration between ${_formatDate(fromTdiDate)} and ${_formatDate(toTdiDate)}`);
|
|
152
152
|
// Filter the migrations that should be applied/considered; Also display older releases migrations
|