@tangelo/tangelo-configuration-toolkit 1.16.0 → 1.17.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangelo/tangelo-configuration-toolkit",
3
- "version": "1.16.0",
3
+ "version": "1.17.1",
4
4
  "engines": {
5
5
  "node": ">=14.0.0"
6
6
  },
package/src/cli.js CHANGED
@@ -88,7 +88,7 @@ module.exports = function cli () {
88
88
  builder: {
89
89
  execute: {alias: 'e', desc: 'Execute migration'},
90
90
  dry: {alias: 'd', desc: 'Dry run (does not persist changes)'},
91
- filter: {alias: 'f', desc: 'Pass glob filter (only used for applicable steps)', default: '**'}
91
+ filter: {alias: 'f', desc: 'Pass glob filter (only used for applicable steps)'}
92
92
  },
93
93
  handler: require('./modules/migrate')
94
94
  })
@@ -28,7 +28,7 @@ module.exports = function packageUpdateCheck () {
28
28
  const updateMsg = (va) => `| Update ${pkg} to ${va} | ` + `npm i -g ${_packages[pkg].name}`.white;
29
29
  const {versionAvailable} = _appdata[`updateCheck${pkg}`] || {};
30
30
 
31
- if (new Date() - new Date(_appdata[`updateCheck${pkg}`]?.executed || 0) > 1000*3600*24*7) { // check every week
31
+ if (new Date() - new Date(_appdata[`updateCheck${pkg}`]?.executed || 0) > 1000*3600*24*1) { // check every day
32
32
  doUpdateCheck(pkg).then(r => r && _warn(updateMsg(r)));
33
33
  }
34
34
  else if (versionAvailable) {
@@ -1,5 +1,7 @@
1
+ const del = require('del');
1
2
  const {exec} = require('child_process');
2
3
  const fs = require('fs-extra');
4
+ const globby = require('globby');
3
5
  const gulp = require('gulp');
4
6
  const g_print = require('gulp-print');
5
7
  const path = require('path');
@@ -219,15 +221,34 @@ module.exports = {
219
221
  ;
220
222
 
221
223
  _info(`Ensure ${messagesFile} exists:`);
222
- if (!fs.existsSync(messagesFile)) fs.outputJsonSync(messagesFile, [], {spaces: 2});
224
+ if (!fs.existsSync(messagesFile)) fs.outputJsonSync(messagesFile, []);
225
+ _write('Done.\n');
226
+
227
+ _info('Make temporary copies of json files:');
228
+ const attrCfgTmpFiles = globby.sync('packages/*/src/!(messages.|operations-)*.json');
229
+ attrCfgTmpFiles.forEach((p, i, a) => {
230
+ _write(p);
231
+ a[i] = path.join(path.dirname(p), 'operations-' + path.basename(p));
232
+ fs.copyFileSync(p, a[i]);
233
+ });
234
+ _write();
223
235
 
224
236
  return cmdExec(`${fdt} localization extract ${templateFile} --paths ` + packagesDirs)
225
237
  .then(() => cmdExec(`${fdt} localization update ${messagesFile} ${templateFile}`))
238
+ .then(() => fs.readJson(messagesFile))
239
+ .then(data => // compress meta object into string array "refs" and remove "operations-" prefix from paths
240
+ data.map(msg => {
241
+ msg.refs = msg.meta.map(r => Object.values(r).join(':').replace(/src\/operations-_/, 'src/_'));
242
+ delete msg.meta;
243
+ return msg;
244
+ })
245
+ )
246
+ .then(data => fs.outputJson(messagesFile, data, {spaces: 2}))
226
247
  .then(() => {
227
- _info('Remove template file:');
228
- fs.unlinkSync(templateFile);
229
- _write('Done.\n');
248
+ _info('Cleanup temp files:');
249
+ return del([templateFile, ...attrCfgTmpFiles]);
230
250
  })
251
+ .then(() => _write('Done.\n'))
231
252
  .then(() => [fdt])
232
253
  ;
233
254
  },
@@ -130,6 +130,7 @@ module.exports = function git (argv) {
130
130
  const updateSubmoduleMsg = execGitCommand(`submodule update --remote`, _paths.repo);
131
131
  if (updateSubmoduleMsg.error && !tdiFromDateCustom) _error(`Update submodule failed\n${updateSubmoduleMsg.error}`);
132
132
 
133
+ const tdiDateBeforeUpdate = _git.commitTdi.local().date;
133
134
  // update local TDI commit data
134
135
  _git.commitTdi.local(true);
135
136
 
@@ -138,7 +139,7 @@ module.exports = function git (argv) {
138
139
  // tdiMigrationFilePath should exist in latest commits of releases 5.3+; As we updated to the latest version this should work
139
140
  const migrations = _modulesTdi.require('git/tdiCommitsRequiringMigration.js');
140
141
  if (migrations) {
141
- const fromTdiDate = tdiFromDateCustom ? new Date(tdiFromDateCustom) : (tdiBranch.commonAncestor) ? tdiBranch.commonAncestor.date: _git.commitTdi.local().date;
142
+ const fromTdiDate = tdiFromDateCustom ? new Date(tdiFromDateCustom) : (tdiBranch.commonAncestor) ? tdiBranch.commonAncestor.date: tdiDateBeforeUpdate;
142
143
  const toTdiDate = tdiToDateCustom ? new Date(tdiToDateCustom) : new Date();
143
144
 
144
145
  _info(`TDI commits requiring migration between ${_formatDate(fromTdiDate)} and ${_formatDate(toTdiDate)}`);
@@ -6,8 +6,6 @@ const path = require('path');
6
6
  module.exports = function migrate (argv) {
7
7
  if (_isPre51()) _error('This command only works when using branch release/5.1 and up.');
8
8
 
9
- let filter = path.join(_paths.apply, argv.filter).toFws(); // Default set filter with filter added to the command argument -f
10
-
11
9
  const scripts =
12
10
  globby
13
11
  .sync(_paths.tdi + '/tct/migrate/*.js')
@@ -37,12 +35,12 @@ module.exports = function migrate (argv) {
37
35
  when: !(cmdlScript) // Only show choice for migration when no script is set in commandline
38
36
  }, {
39
37
  message: 'Choose filter: ', name: 'filter', type: 'list', pageSize: 5, loop: false,
40
- choices: [{name: `- All`, value: argv.filter}, {name: '- Choose active projects', value: 'projects'}],
41
- when: argv.filter === '**' // Only show this message if no custom filter was added to the command argument -f
38
+ choices: [{name: `- All`, value: '**'}, {name: '- Choose active projects', value: 'projects'}],
39
+ when: !argv.filter // Only show this message if no custom filter was added to the command argument -f
42
40
  }, {
43
41
  message: 'Choose active projects: ', name: 'projects', type: 'checkbox', validate: v => !!v[0],
44
42
  choices: _repoconfig.map(p => ({name: `${p.customer_name} ${p.project_name}`, value: p})),
45
- when: (a) => a.filter === 'projects' // Only show this message if 'Choose active projects' was chosen previously
43
+ when: a => a.filter === 'projects' // Only show this message if 'Choose active projects' was chosen previously
46
44
  }])
47
45
  .then(a => {
48
46
  _write();
@@ -53,6 +51,8 @@ module.exports = function migrate (argv) {
53
51
  a.script = cmdlScript.value;
54
52
  }
55
53
 
54
+ let filter = path.join(_paths.apply, argv.filter??'**').toFws(); // Default set filter with filter added to the command argument -f
55
+
56
56
  if (a.filter === 'projects' && _repoconfig.length > a.projects.length) {
57
57
  // push paths of chosen active documents to projectFolders (only if not all projects are chosen)
58
58
  const projectFolders = [];