@tangelo/tangelo-configuration-toolkit 1.14.1 → 1.14.3
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,21 +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
|
-
// Fetch all
|
|
17
|
-
_info(`Fetch TDI submodule`);
|
|
18
|
-
const cmdFetch = execGitCommand('fetch -pf --all', path.join(_paths.repo, _paths.tdi));
|
|
19
|
-
if (cmdFetch.error) _warn(`Fetch failed\n${cmdFetch.error}`);
|
|
20
|
-
|
|
21
19
|
// Get remote release branches containing TDI HEAD commit
|
|
22
20
|
const releaseBranches = execGitCommand(`branch --all --contains ${_git.commitTdi.local().hash}`, path.join(_paths.repo, _paths.tdi)).match(/remotes\/origin\/release\/[^\s]+/gsm);
|
|
23
21
|
if (!releaseBranches || releaseBranches.error) _error(`Could not retrieve TDI release branches`);
|
|
@@ -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 (newXprFile && 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
|
|
@@ -52,7 +52,7 @@ module.exports = function steps (step, dry, filter) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
let filesModCount = 0;
|
|
55
|
-
let maxRepeat =
|
|
55
|
+
let maxRepeat = 15;
|
|
56
56
|
for (let i=0; i<maxRepeat && r.files[0]; i++) { // execute repeatedly for modified files only (with safety limit of 20)
|
|
57
57
|
r.files = rif.sync(r).filter(f => f.hasChanged).map(f => f.file);
|
|
58
58
|
if (i===0) filesModCount = r.files.length; // save count only after first run (after this only subsets are processed)
|