@tangelo/tangelo-configuration-toolkit 1.8.0-beta.1 → 1.8.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/index.js +10 -5
- package/package.json +6 -4
- package/src/cli.js +38 -39
- package/src/modules/deploy/execute.js +3 -5
- package/src/modules/git/index.js +6 -3
- package/src/modules/migrate/steps.js +2 -3
- package/src/lib/npm-package-update.js +0 -50
package/index.js
CHANGED
|
@@ -5,9 +5,10 @@ String.prototype.toFws = function(){
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
const findUp
|
|
9
|
-
const fs
|
|
10
|
-
const
|
|
8
|
+
const findUp = require('find-up');
|
|
9
|
+
const fs = require('fs-extra');
|
|
10
|
+
const {getPath} = require('global-modules-path');
|
|
11
|
+
const path = require('path');
|
|
11
12
|
|
|
12
13
|
const execGitCommand = require('./src/lib/exec-git-command');
|
|
13
14
|
|
|
@@ -56,8 +57,12 @@ _paths.repoconfig = path.join(_paths.repo, appname+'-repoconfig.json');
|
|
|
56
57
|
_paths.apply = process.cwd().replace(_paths.repo, '').substr(1);
|
|
57
58
|
|
|
58
59
|
|
|
59
|
-
global.
|
|
60
|
-
global.
|
|
60
|
+
global._appdata = fs.readJsonSync(_paths.appdata, {throws: false}) || {};
|
|
61
|
+
global._packages = {
|
|
62
|
+
TCT: {name: '@tangelo/tangelo-configuration-toolkit', version: require('./package.json')?.version},
|
|
63
|
+
FDT: {name: '@fontoxml/fontoxml-development-tools'}
|
|
64
|
+
}
|
|
65
|
+
_packages.FDT.version = require(`${getPath(_packages.FDT.name)}/package.json`)?.version;
|
|
61
66
|
|
|
62
67
|
try { global._appconfig = _paths.appconfig && fs.readJsonSync(_paths.appconfig) || {}; }
|
|
63
68
|
catch({message}) { _error('Error in '+message); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangelo/tangelo-configuration-toolkit",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "Tangelo Configuration Toolkit is a command-line toolkit which offers support for developing a Tangelo configuration.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tct": "bin/index.js",
|
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
"babel-core": "^6.26.3",
|
|
21
21
|
"babel-preset-es2015-without-strict": "0.0.4",
|
|
22
22
|
"cli-spinner": "^0.2.10",
|
|
23
|
+
"compare-versions": "^4.1.1",
|
|
23
24
|
"del": "^6.0.0",
|
|
24
25
|
"event-stream": "^4.0.1",
|
|
25
26
|
"find-up": "^5.0.0",
|
|
26
|
-
"globby": "^6.1.0",
|
|
27
27
|
"fs-extra": "^10.0.0",
|
|
28
|
+
"global-modules-path": "^2.3.1",
|
|
29
|
+
"globby": "^6.1.0",
|
|
28
30
|
"gulp": "^4.0.2",
|
|
29
31
|
"gulp-babel": "^7.0.1",
|
|
30
32
|
"gulp-eol": "^0.2.0",
|
|
@@ -39,8 +41,8 @@
|
|
|
39
41
|
"minimatch": "^3.0.4",
|
|
40
42
|
"node-ssh": "^12.0.2",
|
|
41
43
|
"object-assign-deep": "^0.4.0",
|
|
42
|
-
"replace-in-file": "^
|
|
43
|
-
"sass": "^1.43.
|
|
44
|
+
"replace-in-file": "^3.4.4",
|
|
45
|
+
"sass": "^1.43.5",
|
|
44
46
|
"saxon-js": "^2.3.0",
|
|
45
47
|
"scp2": "^0.5.0",
|
|
46
48
|
"tiny-lr": "^2.0.0",
|
package/src/cli.js
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
|
+
const {compare} = require('compare-versions');
|
|
2
|
+
const exec = require('util').promisify(require('child_process').exec);
|
|
1
3
|
const fs = require('fs-extra');
|
|
2
4
|
const yargs = require('yargs');
|
|
3
|
-
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const updateAppdata = (data) => Object.assign(_appdata, data, {_changed: true});
|
|
8
|
+
|
|
9
|
+
const checkForPackageUpdate = (package) => (
|
|
10
|
+
exec(`npm view -g ${_packages[package].name} version`)
|
|
11
|
+
.then(r => {
|
|
12
|
+
const versionAvailable = r.stdout.match(/([\d/.]+)/)[1];
|
|
13
|
+
if (compare(_packages[package].version, versionAvailable, '<')) {
|
|
14
|
+
updateAppdata({[`updateCheck${package}`]: {executed: new Date(), versionAvailable}});
|
|
15
|
+
return versionAvailable;
|
|
16
|
+
}
|
|
17
|
+
else updateAppdata({[`updateCheck${package}`]: {executed: new Date()}});
|
|
18
|
+
})
|
|
19
|
+
.catch(e => _warn(`Failed checking latest version of ${package}.`))
|
|
20
|
+
);
|
|
21
|
+
|
|
4
22
|
|
|
5
23
|
module.exports = function cli () {
|
|
6
24
|
|
|
7
25
|
_write();
|
|
8
26
|
|
|
9
27
|
const txtTitle = 'Tangelo Configuration Toolkit'.bold.underline.cyan;
|
|
10
|
-
const txtVersion = `v${
|
|
28
|
+
const txtVersion = `v${_packages.TCT.version}`.lblack;
|
|
11
29
|
|
|
12
30
|
const {argv} = yargs
|
|
13
31
|
.scriptName('tct')
|
|
@@ -95,8 +113,6 @@ module.exports = function cli () {
|
|
|
95
113
|
})
|
|
96
114
|
.recommendCommands()
|
|
97
115
|
.option('config', {alias: 'c', desc: 'Show loaded appconfig', global: false})
|
|
98
|
-
.option('update', {alias: 'u', desc: 'Update this package', global: false})
|
|
99
|
-
.option('update-fdt', {alias: 'uf', desc: 'Update the FDT package', global: false})
|
|
100
116
|
.version(false)
|
|
101
117
|
.help(false)
|
|
102
118
|
.example([
|
|
@@ -123,53 +139,36 @@ module.exports = function cli () {
|
|
|
123
139
|
_write(_appconfig);
|
|
124
140
|
}
|
|
125
141
|
|
|
126
|
-
if (argv.updateTct) {
|
|
127
|
-
_info('Updating TCT...');
|
|
128
|
-
getLatestPackageVersion({package: 'TCT', version: _package.version})
|
|
129
|
-
.then(updatePackage)
|
|
130
|
-
;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (argv.updateFdt) {
|
|
134
|
-
_info('Updating FDT...');
|
|
135
|
-
getCurrentPackageVersion({package: 'FDT'})
|
|
136
|
-
.then(getLatestPackageVersion)
|
|
137
|
-
.then(updatePackage)
|
|
138
|
-
;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
|
|
144
145
|
let checkUpdatesDone = false;
|
|
145
146
|
|
|
146
147
|
process.on('beforeExit', () => {
|
|
147
|
-
|
|
148
|
-
if (_appdata._changed) {
|
|
149
|
-
delete _appdata._changed;
|
|
150
|
-
fs.writeJsonSync(_paths.appdata, _appdata, {spaces: 2});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
148
|
_write(); // print empty line before and after update check
|
|
154
149
|
|
|
155
|
-
if (!
|
|
156
|
-
(!_appdata.updateCheckTCT?.versionAvailable || !_appdata.updateCheckFDT?.versionAvailable) && // not if already known that update is available
|
|
157
|
-
( new Date() - new Date(_appdata.updateCheckTCT?.executed || 0) > 1000*3600*24*3 ||
|
|
158
|
-
new Date() - new Date(_appdata.updateCheckFDT?.executed || 0) > 1000*3600*24*3
|
|
159
|
-
) && // check every 3 days
|
|
160
|
-
!checkUpdatesDone // check if updatecheck has ran before because async calls below trigger beforeExit again
|
|
161
|
-
) {
|
|
150
|
+
if (!checkUpdatesDone) { // check if updatecheck has ran before because async calls below trigger beforeExit again
|
|
162
151
|
checkUpdatesDone = true;
|
|
163
|
-
_info('Checking for updates...');
|
|
164
152
|
|
|
165
|
-
|
|
166
|
-
|
|
153
|
+
['TCT', 'FDT'].forEach(p => {
|
|
154
|
+
const updateMsg = (va) => `| Update ${p} to ${va} | ` + `npm i -g ${_packages[p].name}`.white;
|
|
155
|
+
const {versionAvailable} = _appdata[`updateCheck${p}`] || {};
|
|
156
|
+
|
|
157
|
+
if (new Date() - new Date(_appdata[`updateCheck${p}`]?.executed || 0) > 1000*3600*24*7) { // check every week
|
|
158
|
+
checkForPackageUpdate(p).then(r => r && _warn(updateMsg(r)));
|
|
159
|
+
}
|
|
160
|
+
else if (versionAvailable) {
|
|
161
|
+
if (compare(_packages[p].version, versionAvailable, '<')) _warn(updateMsg(versionAvailable));
|
|
162
|
+
else updateAppdata({[`updateCheck${p}`]: {executed: new Date()}});
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
167
166
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
.
|
|
171
|
-
;
|
|
167
|
+
if (_appdata._changed) {
|
|
168
|
+
delete _appdata._changed;
|
|
169
|
+
fs.writeJsonSync(_paths.appdata, _appdata, {spaces: 2});
|
|
172
170
|
}
|
|
171
|
+
|
|
173
172
|
});
|
|
174
173
|
|
|
175
174
|
}
|
|
@@ -2,17 +2,15 @@ const fs = require('fs-extra');
|
|
|
2
2
|
const globby = require('globby');
|
|
3
3
|
const gulp = require('gulp');
|
|
4
4
|
const {NodeSSH} = require('node-ssh');
|
|
5
|
-
const path = require('path');
|
|
6
5
|
const through2 = require('through2');
|
|
7
6
|
const {spawnSync} = require('child_process');
|
|
8
7
|
|
|
9
|
-
const g_babel = require('gulp-babel');
|
|
10
8
|
const g_babel_env = require('babel-preset-es2015-without-strict');
|
|
9
|
+
const g_babel = require('gulp-babel')({presets: [g_babel_env], comments: false, minified: true});
|
|
11
10
|
const g_eol = require('gulp-eol');
|
|
12
11
|
const g_filter = require('gulp-filter');
|
|
13
12
|
const g_plumber = require('gulp-plumber');
|
|
14
13
|
const g_print = require('gulp-print');
|
|
15
|
-
const g_rename = require('gulp-simple-rename');
|
|
16
14
|
const g_replace = require('../../lib/gulp-batch-replace-with-filter');
|
|
17
15
|
const g_resolveIncl = require('../../lib/gulp-resolve-includes');
|
|
18
16
|
const g_sass = require('gulp-sass')(require('sass'));
|
|
@@ -157,7 +155,7 @@ const transfer = (paths, lrServer) => {
|
|
|
157
155
|
.pipe(xpsF.restore)
|
|
158
156
|
.pipe(jsF)
|
|
159
157
|
.pipe(g_sourcemaps.init())
|
|
160
|
-
.pipe(g_babel
|
|
158
|
+
.pipe(g_babel)
|
|
161
159
|
.pipe(g_sourcemaps.write('.'))
|
|
162
160
|
.pipe(jsF.restore)
|
|
163
161
|
.pipe(sassF)
|
|
@@ -170,8 +168,8 @@ const transfer = (paths, lrServer) => {
|
|
|
170
168
|
.pipe(shF.restore)
|
|
171
169
|
.pipe(g_plumber.stop())
|
|
172
170
|
.pipe(g_replace(c.replaceStrings))
|
|
173
|
-
.pipe(g_rename(path => path.replace(/fonto[\\\/]dist/, 'fonto').replace(/(fonto[\\\/]).+(assets[\\\/]schemas)/, '$1$2'))) // change destination path for fonto build and schemas
|
|
174
171
|
.pipe(through2.obj((file, enc, cb) => {
|
|
172
|
+
if (file.path.match(/fonto[\\\/]dist/)) file.path = file.path.replace(/fonto[\\\/]dist/, 'fonto'); // change destination path for fonto build
|
|
175
173
|
if (!file.relative.endsWith('.map')) files.push(file.relative); // collect all file paths in array for livereload
|
|
176
174
|
cb(null, file);
|
|
177
175
|
}))
|
package/src/modules/git/index.js
CHANGED
|
@@ -37,9 +37,12 @@ module.exports = function git (argv) {
|
|
|
37
37
|
|
|
38
38
|
if (argv.hasOwnProperty('init')) {
|
|
39
39
|
const remoteTdiUrl = `${_paths.gitremote}/${_paths.tdi}.git`;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
let branches;
|
|
41
|
+
|
|
42
|
+
try { branches = execSync('git ls-remote --heads ' + remoteTdiUrl, {encoding: 'UTF-8'}) }
|
|
43
|
+
catch (e) { _error(' '); } // execSync already prints an error to the console
|
|
44
|
+
|
|
45
|
+
branches = branches
|
|
43
46
|
.match(/refs\/heads\/\S+/g)
|
|
44
47
|
.map(s => s.replace('refs/heads/', ''))
|
|
45
48
|
.sort((a, b) => {
|
|
@@ -5,7 +5,6 @@ const path = require('path');
|
|
|
5
5
|
const rif = require('replace-in-file');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
const rifSync = (options) => rif.sync(options).filter(result => result.hasChanged).map(result => result.file);
|
|
9
8
|
const getPaths = (search, filter) =>
|
|
10
9
|
globby
|
|
11
10
|
.sync(search, {dot: true, ignore: [_paths.tdi + '/**','**/cmscustom/tdi/**']})
|
|
@@ -48,9 +47,9 @@ module.exports = function steps (step, dry, filter) {
|
|
|
48
47
|
r.to = r.fromtoPairs.map(p => p[1]);
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
r.files =
|
|
50
|
+
r.files = rif.sync(r); // execute first time
|
|
52
51
|
const filesModCount = r.files.length; // save file count
|
|
53
|
-
for (let i=0; i<20 && !dry && r.files[0]; i++) r.files =
|
|
52
|
+
for (let i=0; i<20 && !dry && r.files[0]; i++) r.files = rif.sync(r); // execute repeatedly for modified files only (with safety limit of 20)
|
|
54
53
|
|
|
55
54
|
_write('Files modified:', filesModCount);
|
|
56
55
|
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const util = require('util');
|
|
2
|
-
const exec = util.promisify(require('child_process').exec);
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const packageNames = {
|
|
6
|
-
TCT: '@tangelo/tangelo-configuration-toolkit',
|
|
7
|
-
FDT: '@fontoxml/fontoxml-development-tools'
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const updateAppdata = (data) => Object.assign(_appdata, data, {_changed: true});
|
|
11
|
-
|
|
12
|
-
const getCurrentPackageVersion = ({package}) => (
|
|
13
|
-
exec(`npm list -g ${packageNames[package]}`)
|
|
14
|
-
.then(r => ({package, version: r.stdout.match(/@([\d/.]+)/)[1]}))
|
|
15
|
-
.catch(e => _warn(`Failed checking current version of ${package}.`))
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const getLatestPackageVersion = ({package, version}) => (
|
|
19
|
-
exec(`npm view -g ${packageNames[package]} version`)
|
|
20
|
-
.then(r => {
|
|
21
|
-
const versionAvailable = r.stdout.match(/([\d/.]+)/)[1];
|
|
22
|
-
if (version==versionAvailable) {
|
|
23
|
-
updateAppdata({[`updateCheck${package}`]: {executed: new Date()}});
|
|
24
|
-
_write(`Using latest version of ${package}.`);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
updateAppdata({[`updateCheck${package}`]: {executed: new Date(), versionAvailable}});
|
|
28
|
-
_write(`New version of ${package} available!`);
|
|
29
|
-
}
|
|
30
|
-
return {package, version, versionAvailable};
|
|
31
|
-
})
|
|
32
|
-
.catch(e => _warn(`Failed checking latest version of ${package}.`))
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const updatePackage = ({package, version, versionAvailable}) => (
|
|
36
|
-
version!=versionAvailable &&
|
|
37
|
-
exec(`npm install -g ${packageNames[package]}`)
|
|
38
|
-
.then(r => {
|
|
39
|
-
updateAppdata({[`updateCheck${package}`]: {executed: new Date()}});
|
|
40
|
-
_write(`Updated ${package} to version ${versionAvailable}.`);
|
|
41
|
-
})
|
|
42
|
-
.catch(e => _warn(`Failed updating latest version of ${package}.`))
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
module.exports = {
|
|
47
|
-
getCurrentPackageVersion,
|
|
48
|
-
getLatestPackageVersion,
|
|
49
|
-
updatePackage
|
|
50
|
-
};
|