@tangelo/tangelo-configuration-toolkit 1.14.0 → 1.14.2
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/package.json
CHANGED
|
@@ -3,16 +3,19 @@ const path = require('path');
|
|
|
3
3
|
|
|
4
4
|
module.exports = function getTdiBranch(toBranchName) {
|
|
5
5
|
const tdiBranch = {};
|
|
6
|
+
// Fetch all
|
|
7
|
+
_info(`Fetch TDI submodule`);
|
|
8
|
+
const cmdFetch = execGitCommand('fetch -pf --all', path.join(_paths.repo, _paths.tdi));
|
|
9
|
+
if (cmdFetch.error) _warn(`Fetch failed\n${cmdFetch.error}`);
|
|
10
|
+
|
|
6
11
|
let toBranch;
|
|
7
12
|
if (toBranchName) {
|
|
8
13
|
// Check if specified branch exists; we will update to this branch
|
|
9
|
-
toBranch = String(toBranchName).replace(/(?:release\/)?(\d+(?:\.[\
|
|
14
|
+
toBranch = String(toBranchName).replace(/(?:release\/)?(\d+(?:\.[\dxt]+)*)/, `release/$1`);
|
|
10
15
|
const branchExists = execGitCommand(`branch --remote`, path.join(_paths.repo, _paths.tdi)).match(`origin/${toBranch}`);
|
|
11
16
|
if (!branchExists) _error(`TDI branch "${toBranch}" does not exist. Note that TCT can only update to a release branch.`);
|
|
12
17
|
}
|
|
13
18
|
|
|
14
|
-
// Get the current TDI branch:
|
|
15
|
-
|
|
16
19
|
// Get remote release branches containing TDI HEAD commit
|
|
17
20
|
const releaseBranches = execGitCommand(`branch --all --contains ${_git.commitTdi.local().hash}`, path.join(_paths.repo, _paths.tdi)).match(/remotes\/origin\/release\/[^\s]+/gsm);
|
|
18
21
|
if (!releaseBranches || releaseBranches.error) _error(`Could not retrieve TDI release branches`);
|
|
@@ -9,7 +9,7 @@ const createSymlink = (t, p) => {
|
|
|
9
9
|
fs.symlink(path.join(up, _paths.tdi, t), p, 'dir', err => {
|
|
10
10
|
if (err) {
|
|
11
11
|
if (err.code=='EEXIST') _write(`Symlink already exists: ${p}`);
|
|
12
|
-
else _error((err.code
|
|
12
|
+
else _error((err.code!=='EPERM' ? err : `Can't create symlinks, restart your console as admin, or fix it permanently:\n 1. Open 'Local Security Policy' (secpol.msc)\n 2. Go to 'Security Settings > Local Policies > User Rights Assignment > Create symbolic links'\n 3. Add your own account\n 4. Restart Windows`));
|
|
13
13
|
}
|
|
14
14
|
else _write(`Symlink created: ${p}`);
|
|
15
15
|
});
|
|
@@ -112,5 +112,5 @@ module.exports = function build (argv) {
|
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
if (argv.oxygen) oxygen();
|
|
115
|
+
if (argv.oxygen) oxygen(argv.oxygen);
|
|
116
116
|
};
|
|
@@ -11,18 +11,25 @@ const siteStylesheetsPath = 'config/txp/site-stylesheets/';
|
|
|
11
11
|
const masterFiles = new Set;
|
|
12
12
|
const transformationScenarios = [];
|
|
13
13
|
|
|
14
|
-
const convertToValidFilename = (string) => string.replace(/[
|
|
14
|
+
const convertToValidFilename = (string) => string.replace(/[/|\\:*?"<>]/g, ' ');
|
|
15
15
|
|
|
16
|
-
const createProjectFile = (config) => {
|
|
16
|
+
const createProjectFile = (config, filename) => {
|
|
17
17
|
_info('Initializing xpr file(s):');
|
|
18
|
-
const xprFiles = globby.sync(`*.xpr`);
|
|
18
|
+
const xprFiles = [...globby.sync(`*.xpr`)];
|
|
19
|
+
const newXprFile = (typeof filename === 'string') ? convertToValidFilename(filename) + '.xpr' : null;
|
|
20
|
+
// Add newXprFile at the start of xprFiles if it does not already exists:
|
|
21
|
+
if (xprFiles.indexOf(newXprFile)===-1) xprFiles.unshift(newXprFile);
|
|
19
22
|
|
|
20
23
|
// Copy xpr file from TDI if it does not exists yet;
|
|
21
|
-
if (xprFiles[0]) _write(`Found: ${xprFiles.join(', ')}`);
|
|
24
|
+
if (xprFiles[0] && !newXprFile) _write(`Found: ${xprFiles.join(', ')}`);
|
|
22
25
|
else {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
if (!newXprFile) {
|
|
27
|
+
// Set xpr filename to customer name (assumes correct upsert scripts structure)
|
|
28
|
+
const customers = new Set;
|
|
29
|
+
_repoconfig.forEach(p => customers.add(p.customer_name));
|
|
30
|
+
xprFiles.push(convertToValidFilename([...customers].join(' - ')) + '.xpr');
|
|
31
|
+
}
|
|
32
|
+
// Copy new xpr file
|
|
26
33
|
fs.copySync(path.join(_paths.repo, 'tangelo-default-implementation/src/[customer].xpr'), path.join(_paths.repo, xprFiles[0]));
|
|
27
34
|
_write(`Created: '${xprFiles[0]}'`);
|
|
28
35
|
}
|
|
@@ -60,7 +67,7 @@ const getTransformations = (config) => {
|
|
|
60
67
|
const fileString = fs.readFileSync(f).toString();
|
|
61
68
|
const baseStrings = fileString.match(RegExp(config.extracts.base, 'gm'));
|
|
62
69
|
|
|
63
|
-
if (fileString.replace(/\s|^prompt\s.*$/gm,'')!=='') {
|
|
70
|
+
if (fileString.replace(/\s|^prompt\s.*$/gm, '')!=='') {
|
|
64
71
|
if (baseStrings) {
|
|
65
72
|
baseStrings.forEach(s => {
|
|
66
73
|
// extract type, name, files info from baseString
|
|
@@ -97,7 +104,7 @@ const getMasterfiles = (config) => {
|
|
|
97
104
|
.forEach(cf => {
|
|
98
105
|
// Check if masterfile should be extracted from file
|
|
99
106
|
const fileString = fs.readFileSync(cf).toString();
|
|
100
|
-
if (fileString.replace(/\s|^prompt\s.*$/gm,'')!=='') {
|
|
107
|
+
if (fileString.replace(/\s|^prompt\s.*$/gm, '')!=='') {
|
|
101
108
|
if (config.extracts) {
|
|
102
109
|
// extract baseStrings from file
|
|
103
110
|
const baseStrings = fileString.match(RegExp(config.extracts.base, 'gm'));
|
|
@@ -155,7 +162,7 @@ const transformXprFile = (xprFiles) => {
|
|
|
155
162
|
};
|
|
156
163
|
|
|
157
164
|
|
|
158
|
-
module.exports = function oxygen () {
|
|
165
|
+
module.exports = function oxygen (filename) {
|
|
159
166
|
// Set projects transformation scenarios and masterfiles in oXygen project file
|
|
160
167
|
// - Will try to preserve manually added entries in the transformation scenarios and masterfiles
|
|
161
168
|
// - Will remove non existing masterfiles or masterfiles that start with a '_'
|
|
@@ -164,5 +171,5 @@ module.exports = function oxygen () {
|
|
|
164
171
|
_error(`Cannot find required files in TDI submodule. Try updating TDI submodule.`);
|
|
165
172
|
}
|
|
166
173
|
|
|
167
|
-
createProjectFile(require(spConfigPath));
|
|
174
|
+
createProjectFile(require(spConfigPath), filename);
|
|
168
175
|
};
|
package/src/modules/git/index.js
CHANGED
|
@@ -67,13 +67,13 @@ module.exports = function git (argv) {
|
|
|
67
67
|
_write();
|
|
68
68
|
cmdExec([
|
|
69
69
|
['git init', 'Initialize repo:'],
|
|
70
|
-
[`git remote add origin
|
|
70
|
+
[`git remote add origin ${_paths.gitremote.replace(/\//, ':')}/${path.basename(process.cwd()).replace(/\W/, '-')}.git`],
|
|
71
71
|
[`git submodule add -b ${a.branch} ${remoteTdiUrl}`, 'Add TDI submodule:'],
|
|
72
72
|
['git commit -m "added tdi submodule"', 'Commit:']
|
|
73
73
|
])
|
|
74
74
|
.then(() => {
|
|
75
75
|
_info(`Next steps:
|
|
76
|
-
1. Go to https://bitbucket.org/repo/create?workspace=tangelosoftware and create a repository named "${path.basename(process.cwd())}", with options for including README/.gitignore disabled.
|
|
76
|
+
1. Go to https://bitbucket.org/repo/create?workspace=tangelosoftware and create a repository named "${path.basename(process.cwd()).replace(/\W/, '-')}", with options for including README/.gitignore disabled.
|
|
77
77
|
2. Open this folder in Sourcetree (ctrl+O), and push master branch to origin.
|
|
78
78
|
`.replace(/^\s{8}/gm, ''));
|
|
79
79
|
});
|
|
@@ -104,6 +104,8 @@ module.exports = function git (argv) {
|
|
|
104
104
|
['git submodule update --init', 'Fetch submodules such as TDI'],
|
|
105
105
|
// Create symlinks for TDI
|
|
106
106
|
['tct b -s', 'Create TDI symlinks'],
|
|
107
|
+
// Create Oxygen project file and set name equal to repo name
|
|
108
|
+
[`tct b -x ${argv.clone}`, 'Create Oxygen project file'],
|
|
107
109
|
]);
|
|
108
110
|
}).catch((e) => {
|
|
109
111
|
// Show warnings for missing, expected, system environment variables
|
|
@@ -124,8 +126,9 @@ module.exports = function git (argv) {
|
|
|
124
126
|
if (update === `tdi`) {
|
|
125
127
|
|
|
126
128
|
const tdiBranch = getTdiBranch(argv.branch);
|
|
129
|
+
const tdiBranchUpgrade = tdiBranch.from ? (tdiBranch.from.name < tdiBranch.name) : false;
|
|
127
130
|
|
|
128
|
-
if (
|
|
131
|
+
if (tdiBranchUpgrade) _info(`Current branch '${tdiBranch.from.name}' will be updated to '${tdiBranch.name}'\nCommon ancestor will be used in selecting TDI commits requiring migration: ${_formatDate(tdiBranch.commonAncestor.date)}`);
|
|
129
132
|
_info(`Branch ${tdiBranch.name} is ${tdiBranch.commitsBehind} commits behind.`);
|
|
130
133
|
|
|
131
134
|
// Set branch in .gitmodules file; This ensures submodule update will follow this branch to the latest commit
|
|
@@ -150,7 +153,7 @@ module.exports = function git (argv) {
|
|
|
150
153
|
const migrationsFiltered = migrations
|
|
151
154
|
.filter((m) => m.releases.find((r) => {
|
|
152
155
|
const time = new Date(r.date).getTime();
|
|
153
|
-
return ((
|
|
156
|
+
return ((tdiBranchUpgrade)
|
|
154
157
|
? `release/${r.release}` == tdiBranch.name || (tdiBranch.from.name <= `release/${r.release}` && `release/${r.release}` < tdiBranch.name && (fromTdiDate.getTime() < time && time < toTdiDate.getTime()))
|
|
155
158
|
: `release/${r.release}` == tdiBranch.name && (fromTdiDate.getTime() < time && time < toTdiDate.getTime())
|
|
156
159
|
);
|
|
@@ -52,9 +52,11 @@ module.exports = function steps (step, dry, filter) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
let filesModCount = 0;
|
|
55
|
-
|
|
55
|
+
let maxRepeat = 20;
|
|
56
|
+
for (let i=0; i<maxRepeat && r.files[0]; i++) { // execute repeatedly for modified files only (with safety limit of 20)
|
|
56
57
|
r.files = rif.sync(r).filter(f => f.hasChanged).map(f => f.file);
|
|
57
58
|
if (i===0) filesModCount = r.files.length; // save count only after first run (after this only subsets are processed)
|
|
59
|
+
if (i===maxRepeat-1 && r.files[0]) _warn(`Repeated replacement stopped by safety limit - check file changes for too many content occurrences`);
|
|
58
60
|
if (dry) break;
|
|
59
61
|
}
|
|
60
62
|
|