@tangelo/tangelo-configuration-toolkit 1.11.1 → 1.12.0
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/.eslintrc.js +46 -0
- package/.pre-commit-config.yaml +36 -0
- package/README.md +66 -66
- package/bin/index.js +2 -2
- package/index.js +26 -13
- package/package.json +1 -1
- package/src/cli.js +111 -111
- package/src/lib/exec-git-command.js +5 -5
- package/src/lib/get-repoconfig.js +23 -23
- package/src/lib/gulp-batch-replace-with-filter.js +19 -19
- package/src/lib/gulp-resolve-includes.js +14 -14
- package/src/lib/gulp-sftp.js +25 -25
- package/src/lib/gulp-simple-rename.js +11 -11
- package/src/lib/package-update-check.js +12 -12
- package/src/lib/style-string-getters.js +2 -2
- package/src/lib/worker-with-spinner.js +3 -3
- package/src/modules/build/index.js +56 -56
- package/src/modules/build/oxygen.js +165 -159
- package/src/modules/deploy/config.js +13 -13
- package/src/modules/deploy/execute.js +74 -74
- package/src/modules/deploy/index.js +23 -23
- package/src/modules/deploy/srcset.js +16 -16
- package/src/modules/fonto/commands.js +125 -150
- package/src/modules/fonto/index.js +61 -28
- package/src/modules/git/index.js +39 -37
- package/src/modules/migrate/index.js +61 -61
- package/src/modules/migrate/steps.js +9 -5
- package/src/modules/sql/index.js +39 -39
- package/src/modules/version/index.js +164 -173
- package/tct-workspace.code-workspace +0 -7
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
'env': {
|
|
3
|
+
'browser': true,
|
|
4
|
+
'commonjs': true,
|
|
5
|
+
'es2021': true
|
|
6
|
+
},
|
|
7
|
+
'extends': 'eslint:recommended',
|
|
8
|
+
'overrides': [],
|
|
9
|
+
'parserOptions': {'ecmaVersion': 'latest'},
|
|
10
|
+
'globals': {
|
|
11
|
+
'process': 'readonly',
|
|
12
|
+
'Buffer': 'readonly',
|
|
13
|
+
'__dirname': 'readonly',
|
|
14
|
+
'_write': 'writable',
|
|
15
|
+
'_info': 'writable',
|
|
16
|
+
'_warn': 'writable',
|
|
17
|
+
'_error': 'writable',
|
|
18
|
+
'_perf': 'writable',
|
|
19
|
+
'_paths': 'writable',
|
|
20
|
+
'_appdata': 'writable',
|
|
21
|
+
'_packages': 'writable',
|
|
22
|
+
'_appconfig': 'writable',
|
|
23
|
+
'_git': 'writable',
|
|
24
|
+
'_repoconfig': 'writable',
|
|
25
|
+
'_tdiSubmoduleExists': 'writable',
|
|
26
|
+
'_isPre42': 'writable',
|
|
27
|
+
'_isPre51': 'writable'
|
|
28
|
+
},
|
|
29
|
+
'rules': {
|
|
30
|
+
'no-var': ['error'],
|
|
31
|
+
'indent': ['error', 2],
|
|
32
|
+
'quotes': [
|
|
33
|
+
'error',
|
|
34
|
+
'single',
|
|
35
|
+
{'avoidEscape': true, 'allowTemplateLiterals': true}
|
|
36
|
+
],
|
|
37
|
+
'semi': ['error', 'always'],
|
|
38
|
+
'comma-style': ['error', 'last'],
|
|
39
|
+
'array-bracket-spacing': ['error', 'never'],
|
|
40
|
+
'object-curly-spacing': ['error', 'never'],
|
|
41
|
+
'key-spacing': ['error'],
|
|
42
|
+
'comma-spacing': ['error'],
|
|
43
|
+
'rest-spread-spacing': ['error', 'never'],
|
|
44
|
+
'spaced-comment': ['error', 'always'],
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# See https://pre-commit.com for more information
|
|
2
|
+
# See https://pre-commit.com/hooks.html for more hooks
|
|
3
|
+
|
|
4
|
+
repos:
|
|
5
|
+
|
|
6
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
7
|
+
rev: v3.2.0
|
|
8
|
+
hooks:
|
|
9
|
+
- id: trailing-whitespace
|
|
10
|
+
- id: check-json
|
|
11
|
+
- id: check-xml
|
|
12
|
+
- id: check-merge-conflict # checks for files that contain merge conflict strings
|
|
13
|
+
- id: check-added-large-files
|
|
14
|
+
args: [--maxkb=100]
|
|
15
|
+
|
|
16
|
+
- repo: https://github.com/pre-commit/pygrep-hooks
|
|
17
|
+
rev: v1.9.0
|
|
18
|
+
hooks:
|
|
19
|
+
- id: text-unicode-replacement-char # forbid files which have a UTF-8 Unicode replacement character
|
|
20
|
+
|
|
21
|
+
- repo: https://github.com/crate-ci/typos
|
|
22
|
+
rev: v1.12.14
|
|
23
|
+
hooks:
|
|
24
|
+
- id: typos # spell checker
|
|
25
|
+
|
|
26
|
+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
|
|
27
|
+
rev: v2.4.0
|
|
28
|
+
hooks:
|
|
29
|
+
- id: pretty-format-yaml
|
|
30
|
+
args: [--autofix, --indent, '2']
|
|
31
|
+
|
|
32
|
+
- repo: https://github.com/pre-commit/mirrors-eslint
|
|
33
|
+
rev: v8.28.0
|
|
34
|
+
hooks:
|
|
35
|
+
- id: eslint # javascript linter and formatter
|
|
36
|
+
args: [--fix]
|
package/README.md
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
# tangelo-configuration-toolkit
|
|
2
|
-
|
|
3
|
-
Tangelo Configuration Toolkit is a command-line toolkit which offers support for developing a Tangelo configuration.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
The toolkit requires [NPM](https://www.npmjs.com/get-npm) on [Node.js®](https://nodejs.org/) (at least version 14.x). An active or maintenance LTS release is recommended. After installing Node.js, you can install the latest version of the Tangelo Configuration Toolkit globally on your system using the following command:
|
|
8
|
-
|
|
9
|
-
npm i -g @tangelo/tangelo-configuration-toolkit
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
Get help for the available commands and see version:
|
|
14
|
-
|
|
15
|
-
tangelo-configuration-toolkit
|
|
16
|
-
|
|
17
|
-
Get help for a specific command, detailing all its arguments:
|
|
18
|
-
|
|
19
|
-
tangelo-configuration-toolkit <command>
|
|
20
|
-
|
|
21
|
-
Use the `tct` shorthand instead of `tangelo-configuration-toolkit`:
|
|
22
|
-
|
|
23
|
-
tct <command>
|
|
24
|
-
|
|
25
|
-
## Config
|
|
26
|
-
|
|
27
|
-
### Global
|
|
28
|
-
|
|
29
|
-
The `deploy` command requires server connection information. So you'll have to create a configuration file named `tangelo-configuration-toolkit-appconfig.json` in which such information can be stored. This file will be searched for in an ancestor directory of the current working directory.
|
|
30
|
-
|
|
31
|
-
The contents looks like this (all properties are optional):
|
|
32
|
-
|
|
33
|
-
{
|
|
34
|
-
"sharedConfigPath": "absolute/or/relative/path/to/folder/containing/shared/config",
|
|
35
|
-
"servers": [{
|
|
36
|
-
"config": {
|
|
37
|
-
"port": 22,
|
|
38
|
-
"parallel": 4,
|
|
39
|
-
"username": "username",
|
|
40
|
-
"remotedir": "/absolute/path/to/tangelo/config/folder/on/server"
|
|
41
|
-
},
|
|
42
|
-
"domains": ["domain.name.com"],
|
|
43
|
-
"name": "name-for-local-deploy"
|
|
44
|
-
}],
|
|
45
|
-
"serverDefaults": {
|
|
46
|
-
"config": {
|
|
47
|
-
...
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
"defaultServer": "can be set to the name of e.g. your favorite dev server",
|
|
51
|
-
"defaultDatabase": "can be set to the tnsname of e.g. your favorite dev server"
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
When passing a server name, `tct` will look for a full match with a name or a partial match (the start) with a domain.
|
|
55
|
-
|
|
56
|
-
### Repo
|
|
57
|
-
|
|
58
|
-
The `build` and `sql` commands make use of a configuration file in the repository named `tangelo-configuration-toolkit-repoconfig.json`. This contains information about the customer projects.
|
|
59
|
-
|
|
60
|
-
For a new repository, using `tct build --init` also creates the repoconfig-file. For existing projects not having the repoconfig-file, you can use `tct build --config` to generate it.
|
|
61
|
-
|
|
62
|
-
### oXygen
|
|
63
|
-
|
|
64
|
-
The `build -x` commands set projects transformation scenarios and masterfiles in the oXygen project file with the following functionality:
|
|
65
|
-
- Will try to preserve manually added entries in the transformation scenarios and masterfiles
|
|
66
|
-
- Will remove non existing masterfiles or masterfiles that start with a '_'
|
|
1
|
+
# tangelo-configuration-toolkit
|
|
2
|
+
|
|
3
|
+
Tangelo Configuration Toolkit is a command-line toolkit which offers support for developing a Tangelo configuration.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
The toolkit requires [NPM](https://www.npmjs.com/get-npm) on [Node.js®](https://nodejs.org/) (at least version 14.x). An active or maintenance LTS release is recommended. After installing Node.js, you can install the latest version of the Tangelo Configuration Toolkit globally on your system using the following command:
|
|
8
|
+
|
|
9
|
+
npm i -g @tangelo/tangelo-configuration-toolkit
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Get help for the available commands and see version:
|
|
14
|
+
|
|
15
|
+
tangelo-configuration-toolkit
|
|
16
|
+
|
|
17
|
+
Get help for a specific command, detailing all its arguments:
|
|
18
|
+
|
|
19
|
+
tangelo-configuration-toolkit <command>
|
|
20
|
+
|
|
21
|
+
Use the `tct` shorthand instead of `tangelo-configuration-toolkit`:
|
|
22
|
+
|
|
23
|
+
tct <command>
|
|
24
|
+
|
|
25
|
+
## Config
|
|
26
|
+
|
|
27
|
+
### Global
|
|
28
|
+
|
|
29
|
+
The `deploy` command requires server connection information. So you'll have to create a configuration file named `tangelo-configuration-toolkit-appconfig.json` in which such information can be stored. This file will be searched for in an ancestor directory of the current working directory.
|
|
30
|
+
|
|
31
|
+
The contents looks like this (all properties are optional):
|
|
32
|
+
|
|
33
|
+
{
|
|
34
|
+
"sharedConfigPath": "absolute/or/relative/path/to/folder/containing/shared/config",
|
|
35
|
+
"servers": [{
|
|
36
|
+
"config": {
|
|
37
|
+
"port": 22,
|
|
38
|
+
"parallel": 4,
|
|
39
|
+
"username": "username",
|
|
40
|
+
"remotedir": "/absolute/path/to/tangelo/config/folder/on/server"
|
|
41
|
+
},
|
|
42
|
+
"domains": ["domain.name.com"],
|
|
43
|
+
"name": "name-for-local-deploy"
|
|
44
|
+
}],
|
|
45
|
+
"serverDefaults": {
|
|
46
|
+
"config": {
|
|
47
|
+
...
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
"defaultServer": "can be set to the name of e.g. your favorite dev server",
|
|
51
|
+
"defaultDatabase": "can be set to the tnsname of e.g. your favorite dev server"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
When passing a server name, `tct` will look for a full match with a name or a partial match (the start) with a domain.
|
|
55
|
+
|
|
56
|
+
### Repo
|
|
57
|
+
|
|
58
|
+
The `build` and `sql` commands make use of a configuration file in the repository named `tangelo-configuration-toolkit-repoconfig.json`. This contains information about the customer projects.
|
|
59
|
+
|
|
60
|
+
For a new repository, using `tct build --init` also creates the repoconfig-file. For existing projects not having the repoconfig-file, you can use `tct build --config` to generate it.
|
|
61
|
+
|
|
62
|
+
### oXygen
|
|
63
|
+
|
|
64
|
+
The `build -x` commands set projects transformation scenarios and masterfiles in the oXygen project file with the following functionality:
|
|
65
|
+
- Will try to preserve manually added entries in the transformation scenarios and masterfiles
|
|
66
|
+
- Will remove non existing masterfiles or masterfiles that start with a '_'
|
|
67
67
|
- No masterfiles / scenarios will be added if their path match with oXygens hidden directory patterns
|
package/bin/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
3
|
require('..');
|
package/index.js
CHANGED
|
@@ -21,7 +21,7 @@ global._write = (...msg) => {
|
|
|
21
21
|
console.log(msg.join(' ').replace(/^/gm, ' ')); // indent each line
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
global._info
|
|
24
|
+
global._info = (msg, time = false) => {
|
|
25
25
|
if (time) {
|
|
26
26
|
const tzDiff = new Date().getTimezoneOffset() * 60000;
|
|
27
27
|
const time = new Date(Date.now() - tzDiff).toISOString().replace(/.*T(.*)\..*/g, '$1');
|
|
@@ -66,8 +66,7 @@ if (!_appdata.npmPath) {
|
|
|
66
66
|
global._packages = {
|
|
67
67
|
TCT: {name: '@tangelo/tangelo-configuration-toolkit', version: require('./package.json')?.version},
|
|
68
68
|
FDT: {name: '@fontoxml/fontoxml-development-tools'}
|
|
69
|
-
}
|
|
70
|
-
_packages.FDT.version = fs.readJsonSync(path.join(_appdata.npmPath, 'node_modules', _packages.FDT.name, 'package.json'), {throws: false})?.version;
|
|
69
|
+
};
|
|
71
70
|
|
|
72
71
|
try { global._appconfig = _paths.appconfig && fs.readJsonSync(_paths.appconfig) || {}; }
|
|
73
72
|
catch({message}) { _error('Error in '+message); }
|
|
@@ -77,12 +76,27 @@ _appconfig.shared = fs.readJsonSync(_appconfig.sharedConfigPath, {thro
|
|
|
77
76
|
|
|
78
77
|
|
|
79
78
|
global._git = {
|
|
80
|
-
user
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
user () {
|
|
80
|
+
if (!_appdata.gitUser) _appdata._update({gitUser: execGitCommand(`config --get user.email`, _paths.repo)});
|
|
81
|
+
return _appdata.gitUser;
|
|
82
|
+
},
|
|
83
|
+
commitLocal () {
|
|
84
|
+
return this.cache = this.cache ||
|
|
85
|
+
execGitCommand(`log -1 --format=%D;%H;%cd --date=iso-strict`, _paths.repo, ['branch', 'hash', 'date']);
|
|
86
|
+
},
|
|
87
|
+
commitRemote () {
|
|
88
|
+
return this.cache = this.cache ||
|
|
89
|
+
execGitCommand('log -1 --format=%cd --date=iso-strict origin/'+_git.commitLocal().branch, _paths.repo, ['date']);
|
|
90
|
+
},
|
|
91
|
+
commitTdi: {
|
|
92
|
+
local () {
|
|
93
|
+
return this.cache = this.cache ||
|
|
94
|
+
execGitCommand(`log -1 --format=%D;%H;%cd --date=iso-strict`, path.join(_paths.repo, _paths.tdi), ['tags', 'hash', 'date']);
|
|
95
|
+
},
|
|
84
96
|
after (commitHash) {
|
|
85
|
-
|
|
97
|
+
if (this['cache-'+commitHash] != undefined) return this['cache-'+commitHash];
|
|
98
|
+
return this['cache-'+commitHash] =
|
|
99
|
+
execGitCommand(`merge-base --is-ancestor ${commitHash} ${_git.commitTdi.local().hash}`, path.join(_paths.repo, _paths.tdi), null, 0);
|
|
86
100
|
},
|
|
87
101
|
fontoVersions: [ // latest commits first
|
|
88
102
|
{commitHash: 'e599766', regex: /^7\.1[45]\./},
|
|
@@ -93,17 +107,16 @@ global._git = {
|
|
|
93
107
|
stopUsingRepoconfigFile: '1f12bff' // release/5.1 10-05-2021
|
|
94
108
|
}
|
|
95
109
|
};
|
|
96
|
-
_git.commitRemote = execGitCommand('log -1 --format=%cd --date=iso-strict origin/'+_git.commitLocal.branch, _paths.repo, ['date']);
|
|
97
110
|
|
|
98
111
|
|
|
99
|
-
if (_git.
|
|
112
|
+
if (_git.commitTdi.after(_git.commitTdi.stopUsingRepoconfigFile)) {
|
|
100
113
|
global._repoconfig = require('./src/lib/get-repoconfig')();
|
|
101
114
|
}
|
|
102
115
|
else {
|
|
103
116
|
try { global._repoconfig = fs.existsSync(_paths.repoconfig) && fs.readJsonSync(_paths.repoconfig) || {}; }
|
|
104
|
-
catch({message}) { _error('Error in '+message); }
|
|
105
|
-
_repoconfig.update = obj => {
|
|
106
|
-
_repoconfig = Object.assign(_repoconfig, obj);
|
|
117
|
+
catch ({message}) { _error('Error in '+message); }
|
|
118
|
+
global._repoconfig.update = obj => {
|
|
119
|
+
global._repoconfig = Object.assign(_repoconfig, obj);
|
|
107
120
|
fs.writeJsonSync(_paths.repoconfig, _repoconfig, {spaces: 2});
|
|
108
121
|
};
|
|
109
122
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangelo/tangelo-configuration-toolkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
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",
|
package/src/cli.js
CHANGED
|
@@ -9,116 +9,116 @@ module.exports = function cli () {
|
|
|
9
9
|
const txtVersion = `v${_packages.TCT.version}`.lblack;
|
|
10
10
|
|
|
11
11
|
const {argv} = yargs
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
12
|
+
.scriptName('tct')
|
|
13
|
+
.usage(`${txtTitle} ${txtVersion}\n\nUsage: $0 <command> [options]`)
|
|
14
|
+
.middleware(argv => { // executes before command handlers
|
|
15
|
+
if (!(['git', 'g'].includes(argv._[0]) && (argv.init || argv.clone))) {
|
|
16
|
+
if (!_paths.repo) _error('This command can only be used inside a customer git repo!');
|
|
17
|
+
process.chdir(_paths.repo);
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
.command({
|
|
21
|
+
command: 'build',
|
|
22
|
+
aliases: ['b'],
|
|
23
|
+
desc: 'Build the customer repository',
|
|
24
|
+
builder: {
|
|
25
|
+
init: {alias: 'i', desc: 'Create repository content structure', conflicts: ['p', 's', 'c']},
|
|
26
|
+
project: {alias: 'p', desc: 'Create project configuration', conflicts: ['i', 's', 'c']},
|
|
27
|
+
symlinks: {alias: 's', desc: 'Recreate symlinks to TDI', conflicts: ['p', 'i', 'c']},
|
|
28
|
+
config: {alias: 'c', desc: 'Create repo-config file', conflicts: ['p', 'i', 's'], hidden: _git.commitTdi.after(_git.commitTdi.stopUsingRepoconfigFile)},
|
|
29
|
+
oxygen: {alias: 'x', desc: 'Create or update oXygen project file (.xpr)', conflicts: ['p', 'i', 'c']}
|
|
30
|
+
},
|
|
31
|
+
handler: require('./modules/build')
|
|
32
|
+
})
|
|
33
|
+
.command({
|
|
34
|
+
command: 'deploy',
|
|
35
|
+
aliases: ['d'],
|
|
36
|
+
desc: 'Copy configuration to server',
|
|
37
|
+
builder: {
|
|
38
|
+
test: {alias: 't', desc: 'Test what files qualify for copy', conflicts: ['c', 'w', 'l']},
|
|
39
|
+
copy: {alias: 'c', desc: 'Copy files', conflicts: ['t', 'w', 'l']},
|
|
40
|
+
watch: {alias: 'w', desc: 'Watch files for copy on change', conflicts: ['t', 'c', 'l']},
|
|
41
|
+
live: {alias: 'l', desc: 'Watch files for copy on change, and reload webpage', conflicts: ['t', 'c', 'w']},
|
|
42
|
+
server: {alias: 's', desc: 'Pass server name (set in config file)', default: _appconfig.defaultServer},
|
|
43
|
+
filter: {alias: 'f', desc: 'Pass glob filter', default: '**'}
|
|
44
|
+
},
|
|
45
|
+
handler: require('./modules/deploy')
|
|
46
|
+
})
|
|
47
|
+
.command({
|
|
48
|
+
command: 'fonto',
|
|
49
|
+
aliases: ['f'],
|
|
50
|
+
desc: 'Setting up the Fonto editor',
|
|
51
|
+
builder: {
|
|
52
|
+
init: {alias: 'i', desc: `Initialize editor (optionally pass version number or 'latest')`},
|
|
53
|
+
schema: {alias: 's', desc: 'Compile schemas to json'},
|
|
54
|
+
elements: {alias: 'e', desc: 'List schema elements not having a default configuration'},
|
|
55
|
+
attributes: {alias: 'a', desc: 'List schema attributes not having a default configuration'},
|
|
56
|
+
localize: {alias: 'l', desc: 'Update localization file'},
|
|
57
|
+
build: {alias: 'b', desc: 'Build the editor instance'},
|
|
58
|
+
run: {alias: 'r', desc: 'Start editor instance on localhost and watch changes'}
|
|
59
|
+
},
|
|
60
|
+
handler: require('./modules/fonto')
|
|
61
|
+
})
|
|
62
|
+
.command({
|
|
63
|
+
command: 'git',
|
|
64
|
+
aliases: ['g'],
|
|
65
|
+
desc: 'Git repo actions (requires global git installation)',
|
|
66
|
+
builder: {
|
|
67
|
+
init: {alias: 'i', desc: 'Initialize repository and add submodule', conflicts: ['r']},
|
|
68
|
+
reset: {alias: 'r', desc: 'Reset repository to last commit', conflicts: ['i']},
|
|
69
|
+
clone: {alias: 'c', desc: 'Clone a client repository and do basic setup'},
|
|
70
|
+
},
|
|
71
|
+
handler: require('./modules/git')
|
|
72
|
+
})
|
|
73
|
+
.command({
|
|
74
|
+
command: 'migrate',
|
|
75
|
+
aliases: ['m'],
|
|
76
|
+
desc: 'Execute migration scripts on configuration files',
|
|
77
|
+
builder: {
|
|
78
|
+
execute: {alias: 'e', desc: 'Execute migration'},
|
|
79
|
+
dry: {alias: 'd', desc: 'Dry run (does not persist changes)'},
|
|
80
|
+
filter: {alias: 'f', desc: 'Pass glob filter (only used for applicable steps)', default: '**'}
|
|
81
|
+
},
|
|
82
|
+
handler: require('./modules/migrate')
|
|
83
|
+
})
|
|
84
|
+
.command({
|
|
85
|
+
command: 'sql',
|
|
86
|
+
aliases: ['s'],
|
|
87
|
+
desc: 'Execute sql scripts',
|
|
88
|
+
builder: {
|
|
89
|
+
install: {alias: 'i', desc: 'Install TDI schema and custom schema'},
|
|
90
|
+
configure: {alias: 'c', desc: 'Load configuration for projects'},
|
|
91
|
+
generate: {alias: 'g', desc: 'Generate configuration scripts for a project', conflicts: ['i', 'c', 'r']},
|
|
92
|
+
remove: {alias: 'r', desc: 'Remove project configuration', conflicts: ['i', 'c', 'g']}
|
|
93
|
+
},
|
|
94
|
+
handler: require('./modules/sql')
|
|
95
|
+
}).command({
|
|
96
|
+
command: 'versions',
|
|
97
|
+
aliases: ['v'],
|
|
98
|
+
desc: 'Show version information',
|
|
99
|
+
builder: {
|
|
100
|
+
find: {alias: 'f', desc: `Find all version information [choices: "sort-project"(default),"sort-type"]`},
|
|
101
|
+
server: {alias: 's', desc: 'Pass server name (set in config file)', default: _appconfig.defaultServer}
|
|
102
|
+
},
|
|
103
|
+
handler: require('./modules/version')
|
|
104
|
+
})
|
|
105
|
+
.recommendCommands()
|
|
106
|
+
.option('config', {alias: 'c', desc: 'Show loaded appconfig', global: false})
|
|
107
|
+
.version(false)
|
|
108
|
+
.help(false)
|
|
109
|
+
.example([
|
|
110
|
+
['$0 deploy --copy --server demo', 'Copy files to server "demo"'],
|
|
111
|
+
['$0 d -c -s demo', 'Same as above'],
|
|
112
|
+
['$0 f -sb && $0 d -c', 'Compile schema and build Fonto, then deploy to default server']
|
|
113
|
+
])
|
|
114
|
+
.check((argv, options) => {
|
|
115
|
+
const passedOpts = Object.keys(argv).filter(k => !['_', '$0', 'server', 's', 'filter', 'f'].includes(k)); // also filter options with defaults
|
|
116
|
+
const hasOpts = Object.keys(options)[0];
|
|
117
|
+
if (hasOpts && !passedOpts[0]) yargs.showHelp();
|
|
118
|
+
return true;
|
|
119
|
+
})
|
|
120
|
+
.strict()
|
|
121
|
+
.wrap(100)
|
|
122
122
|
;
|
|
123
123
|
|
|
124
124
|
|
|
@@ -132,4 +132,4 @@ module.exports = function cli () {
|
|
|
132
132
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
}
|
|
135
|
+
};
|
|
@@ -9,17 +9,17 @@ module.exports = function execGitCommand(args, path, returnProperties = [], expe
|
|
|
9
9
|
|
|
10
10
|
let retObj = (cmd.stdout||'').toString().trim().split(';');
|
|
11
11
|
if (returnProperties[0]) {
|
|
12
|
+
const o = {};
|
|
12
13
|
retObj = (
|
|
13
|
-
|
|
14
|
-
retObj.forEach((v,i) => {
|
|
14
|
+
retObj.forEach((v, i) => {
|
|
15
15
|
o[returnProperties[i]] =
|
|
16
16
|
returnProperties[i] == 'date' ? new Date(v) :
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
returnProperties[i] == 'branch' ? v.replace(/HEAD -> ([^,]+).*/, '$1') :
|
|
18
|
+
v
|
|
19
19
|
;
|
|
20
20
|
}),
|
|
21
21
|
o
|
|
22
|
-
)
|
|
22
|
+
);
|
|
23
23
|
}
|
|
24
24
|
return retObj.length==1 ? retObj[0] : retObj;
|
|
25
25
|
|
|
@@ -7,30 +7,30 @@ module.exports = function getRepoconfig() {
|
|
|
7
7
|
const repoconfig = [];
|
|
8
8
|
|
|
9
9
|
globby
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
.sync('database/config/**/txd_document_types.sql')
|
|
11
|
+
.forEach(p => {
|
|
12
|
+
const dtSqlInsert = fs.readFileSync(p).toString().match(/select(.*?)from/s)[1];
|
|
13
|
+
const ntSqlInsert = fs.readFileSync(p.replace('txd_document_types', 'txd_node_types')).toString().match(/select(.*?)from/s)[1];
|
|
14
|
+
|
|
15
|
+
const dtDisplayName = dtSqlInsert.match(/'([^']+)' display_name/)[1];
|
|
16
|
+
const ntName = ntSqlInsert.match(/'([^']+)' name/)[1];
|
|
17
|
+
const xpiDir = ntSqlInsert.match(/'([^']+)' xsl_prep_inc/)[1];
|
|
18
|
+
|
|
19
|
+
const path_cmscustom = xpiDir.replace(/\/[^/]+$/, '').split(/[/]/);
|
|
20
|
+
const path_dbconfig = p.replace(/database\/config\/(.*)\/[^/]+/, '$1').split(/[/\\]/);
|
|
21
|
+
const dnRegex = [path_cmscustom[0].replace(/[_'"]/g, '.'), path_dbconfig[0].replace(/[_'"]/g, '.')].sort((a, b) => b.length - a.length).join('|');
|
|
22
|
+
const customer_name = (dtDisplayName.match(RegExp(dnRegex, 'i')) || dtDisplayName.split(/ (.+)/))[0];
|
|
23
|
+
|
|
24
|
+
repoconfig.push({
|
|
25
|
+
customer_name,
|
|
26
|
+
customer_abbr: ntName.split('_')[0],
|
|
27
|
+
project_name: dtDisplayName.split(RegExp(customer_name.replace(/(\W)/g, '\\$1')))[1].trim() || '',
|
|
28
|
+
project_abbr: ntName.split('_')[1],
|
|
29
|
+
path_cmscustom,
|
|
30
|
+
path_dbconfig,
|
|
31
|
+
id_range: dtSqlInsert.match(/(\d+)\d{3} id/)[1]
|
|
32
|
+
});
|
|
32
33
|
});
|
|
33
|
-
});
|
|
34
34
|
|
|
35
35
|
return repoconfig;
|
|
36
36
|
|