@tangelo/tangelo-configuration-toolkit 1.14.3 → 1.15.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.
@@ -1,201 +1,200 @@
1
- const fs = require('fs-extra');
2
- const globby = require('globby');
3
- const path = require('path');
4
- const {Table} = require('console-table-printer');
5
-
6
- const execGitCommand = require('../../lib/exec-git-command');
7
- const getTdiBranch = require('../../lib/get-tdi-branch');
8
- const c = require('../deploy/config');
9
- const {remote} = require('../deploy/execute');
10
-
11
-
12
- const getGitInfo = () => {
13
- // Version info TDI submodule
14
- const gitSubmoduleInfo = new Table({
15
- columns: [
16
- {name: 'property', title: 'TDI - submodule', alignment: 'left'},
17
- {name: 'value', alignment: 'left'}
18
- ],
19
- });
20
-
21
- // Fetch all
22
- const cmdFetch = execGitCommand('fetch -pf --all', path.join(_paths.repo, _paths.tdi));
23
- if (cmdFetch.error) _warn(`Fetch failed\n${cmdFetch.error}`);
24
-
25
- // Set branch name of firstBranch without 'remotes/origin/'
26
- const tdiBranch = getTdiBranch();
27
-
28
- // Get number of commits behind
29
- tdiBranch.commitsBehind = execGitCommand(`rev-list HEAD...origin/${tdiBranch.name} --count`, path.join(_paths.repo, _paths.tdi));
30
-
31
- // Create table rows for TDI submodule info
32
- gitSubmoduleInfo.addRow({
33
- property: 'Commit date',
34
- value: _formatDate(_git.commitTdi.local().date)
35
- });
36
- if (tdiBranch) {
37
- gitSubmoduleInfo.addRow({
38
- property: 'Branch',
39
- value: tdiBranch.name
40
- });
41
- gitSubmoduleInfo.addRow({
42
- property: 'Commits behind',
43
- value: tdiBranch.commitsBehind
44
- });
45
- } else {
46
- gitSubmoduleInfo.addRow({
47
- property: 'Branch could not be determined',
48
- value: ''
49
- });
50
- }
51
-
52
- // Print TDI submodule info
53
- gitSubmoduleInfo.printTable();
54
- };
55
-
56
- const getFileExtractInfo = (sorting) => {
57
- // version info miscellaneous
58
- const projects = new Set;
59
- const types = new Set;
60
- const versionInfoConfigPath = path.join(_paths.repo, _paths.tdi, 'tct/version/versionInfo.js');
61
- const versionInfo = new Table({
62
- columns: [
63
- {name: 'path', alignment: 'left'},
64
- {name: 'type', alignment: 'left'},
65
- {name: 'version', alignment: 'left'},
66
- {name: 'sort'}
67
- ],
68
- disabledColumns: ['sort'],
69
- sort: (a, b) => a.sort.toLowerCase() > b.sort.toLowerCase() ? 1 : -1
70
- });
71
-
72
- if (fs.existsSync(versionInfoConfigPath)) {
73
- const config = require(versionInfoConfigPath);
74
-
75
- config.forEach(v => {
76
- const location = path.join(_paths.repo, v.glob);
77
-
78
- globby
79
- .sync(location)
80
- .forEach(f => {
81
- const filePathExtract = f.match(/.*(?<path>(cmscustom|site-stylesheets)\/(?<customer>[^/]*)\/(?<project>[^/]*)\/.*)/);
82
- const path = filePathExtract.groups.path || '';
83
- const project = filePathExtract.groups.project || '';
84
-
85
- const fileContent = fs.readFileSync(f).toString();
86
- v.extracts.forEach(e => {
87
- const extract = fileContent.match(e.regex);
88
- if (extract) {
89
- projects.add(project); // Store the projects where versioninfo is found
90
- types.add(e.type); // Store the types for which versioninfo is found
91
- versionInfo.addRow({ // Create row with version information to output
92
- path,
93
- sort: `${sorting=='project' ? project : e.type}_2${sorting=='project' ? e.type : extract.groups.version}`, // Output is sorted on project or type: '_2' ensures it is rendered after the empty row and the row with the project name
94
- type: e.type,
95
- version: extract.groups.version
96
- });
97
- }
98
- });
99
- });
100
- });
101
-
102
- if (sorting=='project') {
103
- // For projects containing version information
104
- projects.forEach(p => {
105
- versionInfo.addRow({ // Add empty row after project
106
- path: '',
107
- sort: `${p}_3`,
108
- type: '',
109
- version: ''
110
- });
111
- versionInfo.addRow({ // Add row with project name
112
- path: `-- ${p}:`,
113
- sort: `${p}_1`,
114
- type: '',
115
- version: ''
116
- }, {
117
- color: 'yellow'
118
- });
119
- });
120
- }
121
- else if (sorting=='type') {
122
- types.forEach(t => {
123
- versionInfo.addRow({ // Add empty row after type
124
- path: '',
125
- sort: `${t}_3`,
126
- type: '',
127
- version: ''
128
- });
129
- });
130
- }
131
- versionInfo.printTable();
132
- }
133
- else {
134
- _warn('Version info of miscellaneous items cannot be extracted:\nCannot find required files in TDI submodule. Try updating TDI submodule.');
135
- }
136
- };
137
-
138
- const getServerInfo = (server) => {
139
- // Remote server info
140
- // common setup
141
- _write();
142
- c.setServer(server);
143
-
144
- if (!c.envDev) {
145
- _info(`Remote version info for '${c.server.ftpConfig.host}':\n`);
146
- remote.add('sudo ~root/scripts/version.sh', '').process();
147
- }
148
- else {
149
- _info('For development environments no server version information is available. Check rancher / database for this information.\nAdd the --server option with a non-dev environment to see version information for that server.');
150
- }
151
- };
152
-
153
-
154
- module.exports = function info (argv) {
155
-
156
- if (argv.doctypes) {
157
- _info('Document type information for this git repository\n');
158
-
159
- const doctypesInfo = new Table({
160
- columns: [
161
- {name: 'id', alignment: 'right'},
162
- {name: 'name', alignment: 'left'},
163
- {name: 'paths', alignment: 'left'}
164
- ],
165
- });
166
-
167
- globby
168
- .sync(_paths.repo + '/database/config/**/txd_document_types.sql')
169
- .forEach((p, i, a) => {
170
- fs.readFileSync(p).toString().match(/select([\s\S]+?)from\s+dual/gmi)
171
- .forEach((dtRow, i, a) => {
172
- const ntSqlInsert = fs.readFileSync(p.replace('txd_document_types', 'txd_node_types')).toString().match(/select(.*?)from\s+dual/s)[1];
173
- const id = dtRow.match(/(\d+) id/)?.[1];
174
- const name = dtRow.match(/'([^']+)' display_name/)?.[1];
175
- const dbPath = p.match(/(database\/config\/(:?.*)\/)txd_document_types.sql/i)?.[1];
176
- const prPath = ntSqlInsert.match(/'([^']+)' xsl_prep_inc/)[1].replace('prepare_xincludes.xsl', '');
177
-
178
- doctypesInfo.addRows([
179
- {id, name, paths: 'config/cmscustom/'+ prPath},
180
- {paths: dbPath}
181
- ]);
182
-
183
- if (i!==a.length-1) doctypesInfo.addRow({});
184
- });
185
-
186
- if (i!==a.length-1) doctypesInfo.addRow({});
187
- });
188
-
189
-
190
- doctypesInfo.printTable();
191
- }
192
-
193
- if (argv.versions) {
194
- _info('Version information for this git repository\n');
195
-
196
- getGitInfo();
197
- getFileExtractInfo(argv.versions);
198
- getServerInfo(argv.server);
199
- }
200
-
201
- };
1
+ const fs = require('fs-extra');
2
+ const globby = require('globby');
3
+ const path = require('path');
4
+ const {Table} = require('console-table-printer');
5
+
6
+ const execGitCommand = require('../../lib/exec-git-command');
7
+ const getTdiBranch = require('../../lib/get-tdi-branch');
8
+ const c = require('../deploy/config');
9
+ const {remote} = require('../deploy/execute');
10
+
11
+
12
+ const getGitInfo = () => {
13
+ // Version info TDI submodule
14
+ const gitSubmoduleInfo = new Table({
15
+ columns: [
16
+ {name: 'property', title: 'TDI - submodule', alignment: 'left'},
17
+ {name: 'value', alignment: 'left'}
18
+ ],
19
+ });
20
+
21
+ // Fetch all
22
+ const cmdFetch = execGitCommand('fetch -pf --all', path.join(_paths.repo, _paths.tdi));
23
+ if (cmdFetch.error) _warn(`Fetch failed\n${cmdFetch.error}`);
24
+
25
+ // Set branch name of firstBranch without 'remotes/origin/'
26
+ const tdiBranch = getTdiBranch();
27
+
28
+ // Get number of commits behind
29
+ tdiBranch.commitsBehind = execGitCommand(`rev-list HEAD...origin/${tdiBranch.name} --count`, path.join(_paths.repo, _paths.tdi));
30
+
31
+ // Create table rows for TDI submodule info
32
+ gitSubmoduleInfo.addRow({
33
+ property: 'Commit date',
34
+ value: _formatDate(_git.commitTdi.local().date)
35
+ });
36
+ if (tdiBranch) {
37
+ gitSubmoduleInfo.addRow({
38
+ property: 'Branch',
39
+ value: tdiBranch.name
40
+ });
41
+ gitSubmoduleInfo.addRow({
42
+ property: 'Commits behind',
43
+ value: tdiBranch.commitsBehind
44
+ });
45
+ } else {
46
+ gitSubmoduleInfo.addRow({
47
+ property: 'Branch could not be determined',
48
+ value: ''
49
+ });
50
+ }
51
+
52
+ // Print TDI submodule info
53
+ gitSubmoduleInfo.printTable();
54
+ };
55
+
56
+ const getFileExtractInfo = (sorting) => {
57
+ // version info miscellaneous
58
+ const projects = new Set;
59
+ const types = new Set;
60
+ const versionInfo = new Table({
61
+ columns: [
62
+ {name: 'path', alignment: 'left'},
63
+ {name: 'type', alignment: 'left'},
64
+ {name: 'version', alignment: 'left'},
65
+ {name: 'sort'}
66
+ ],
67
+ disabledColumns: ['sort'],
68
+ sort: (a, b) => a.sort.toLowerCase() > b.sort.toLowerCase() ? 1 : -1
69
+ });
70
+
71
+ const versionInfoConfig = _modulesTdi.require('version/versionInfo.js');
72
+ if (versionInfoConfig) {
73
+
74
+ versionInfoConfig.forEach(v => {
75
+ const location = path.join(_paths.repo, v.glob);
76
+
77
+ globby
78
+ .sync(location)
79
+ .forEach(f => {
80
+ const filePathExtract = f.match(/.*(?<path>(cmscustom|site-stylesheets)\/(?<customer>[^/]*)\/(?<project>[^/]*)\/.*)/);
81
+ const path = filePathExtract.groups.path || '';
82
+ const project = filePathExtract.groups.project || '';
83
+
84
+ const fileContent = fs.readFileSync(f).toString();
85
+ v.extracts.forEach(e => {
86
+ const extract = fileContent.match(e.regex);
87
+ if (extract) {
88
+ projects.add(project); // Store the projects where versioninfo is found
89
+ types.add(e.type); // Store the types for which versioninfo is found
90
+ versionInfo.addRow({ // Create row with version information to output
91
+ path,
92
+ sort: `${sorting=='project' ? project : e.type}_2${sorting=='project' ? e.type : extract.groups.version}`, // Output is sorted on project or type: '_2' ensures it is rendered after the empty row and the row with the project name
93
+ type: e.type,
94
+ version: extract.groups.version
95
+ });
96
+ }
97
+ });
98
+ });
99
+ });
100
+
101
+ if (sorting=='project') {
102
+ // For projects containing version information
103
+ projects.forEach(p => {
104
+ versionInfo.addRow({ // Add empty row after project
105
+ path: '',
106
+ sort: `${p}_3`,
107
+ type: '',
108
+ version: ''
109
+ });
110
+ versionInfo.addRow({ // Add row with project name
111
+ path: `-- ${p}:`,
112
+ sort: `${p}_1`,
113
+ type: '',
114
+ version: ''
115
+ }, {
116
+ color: 'yellow'
117
+ });
118
+ });
119
+ }
120
+ else if (sorting=='type') {
121
+ types.forEach(t => {
122
+ versionInfo.addRow({ // Add empty row after type
123
+ path: '',
124
+ sort: `${t}_3`,
125
+ type: '',
126
+ version: ''
127
+ });
128
+ });
129
+ }
130
+ versionInfo.printTable();
131
+ }
132
+ else {
133
+ _warn('Version info of miscellaneous items cannot be extracted:\nCannot find required files in TDI submodule. Try updating TDI submodule.');
134
+ }
135
+ };
136
+
137
+ const getServerInfo = (server) => {
138
+ // Remote server info
139
+ // common setup
140
+ _write();
141
+ c.setServer(server);
142
+
143
+ if (!c.envDev) {
144
+ _info(`Remote version info for '${c.server.ftpConfig.host}':\n`);
145
+ remote.add('sudo ~root/scripts/version.sh', '').process();
146
+ }
147
+ else {
148
+ _info('For development environments no server version information is available. Check rancher / database for this information.\nAdd the --server option with a non-dev environment to see version information for that server.');
149
+ }
150
+ };
151
+
152
+
153
+ module.exports = function info (argv) {
154
+
155
+ if (argv.doctypes) {
156
+ _info('Document type information for this git repository\n');
157
+
158
+ const doctypesInfo = new Table({
159
+ columns: [
160
+ {name: 'id', alignment: 'right'},
161
+ {name: 'name', alignment: 'left'},
162
+ {name: 'paths', alignment: 'left'}
163
+ ],
164
+ });
165
+
166
+ globby
167
+ .sync(_paths.repo + '/database/config/**/txd_document_types.sql')
168
+ .forEach((p, i, a) => {
169
+ fs.readFileSync(p).toString().match(/select([\s\S]+?)from\s+dual/gmi)
170
+ .forEach((dtRow, i, a) => {
171
+ const ntSqlInsert = fs.readFileSync(p.replace('txd_document_types', 'txd_node_types')).toString().match(/select(.*?)from\s+dual/s)[1];
172
+ const id = dtRow.match(/(\d+) id/)?.[1];
173
+ const name = dtRow.match(/'([^']+)' display_name/)?.[1];
174
+ const dbPath = p.match(/(database\/config\/(:?.*)\/)txd_document_types.sql/i)?.[1];
175
+ const prPath = ntSqlInsert.match(/'([^']+)' xsl_prep_inc/)[1].replace('prepare_xincludes.xsl', '');
176
+
177
+ doctypesInfo.addRows([
178
+ {id, name, paths: 'config/cmscustom/'+ prPath},
179
+ {paths: dbPath}
180
+ ]);
181
+
182
+ if (i!==a.length-1) doctypesInfo.addRow({});
183
+ });
184
+
185
+ if (i!==a.length-1) doctypesInfo.addRow({});
186
+ });
187
+
188
+
189
+ doctypesInfo.printTable();
190
+ }
191
+
192
+ if (argv.versions) {
193
+ _info('Version information for this git repository\n');
194
+
195
+ getGitInfo();
196
+ getFileExtractInfo(argv.versions);
197
+ getServerInfo(argv.server);
198
+ }
199
+
200
+ };
@@ -4,7 +4,7 @@ const path = require('path');
4
4
 
5
5
 
6
6
  module.exports = function migrate (argv) {
7
- if (_isPre51) _error('This command only works when using branch release/5.1 and up.');
7
+ if (_isPre51()) _error('This command only works when using branch release/5.1 and up.');
8
8
 
9
9
  let filter = path.join(_paths.apply, argv.filter).toFws(); // Default set filter with filter added to the command argument -f
10
10
 
@@ -76,8 +76,8 @@ module.exports = function migrate (argv) {
76
76
  _write();
77
77
  const startTime = new Date();
78
78
 
79
- const scriptPath = path.join(_paths.repo, _paths.tdi, 'tct/migrate', a.script);
80
- require(scriptPath).forEach(step => require('./steps')(step, argv.dry, filter));
79
+ const scriptPath = path.join('migrate', a.script);
80
+ _modulesTdi.require(scriptPath).forEach(step => require('./steps')(step, argv.dry, filter));
81
81
 
82
82
  _perf(startTime);
83
83
  });
@@ -43,7 +43,7 @@ module.exports = function sql (argv) {
43
43
 
44
44
  if (argv.install) {
45
45
  // tdi
46
- const dir = `${_paths.tdi}/${_isPre51 ? 'sources' : 'src'}/database/tdi/${_isPre42 ? 'install/' : ''}`;
46
+ const dir = `${_paths.tdi}/${_isPre51() ? 'sources' : 'src'}/database/tdi/${_isPre42() ? 'install/' : ''}`;
47
47
  runSqlScript(dir + 'install.sql');
48
48
  checkLog(dir + 'tdi-install.log', false);
49
49
  // custom
@@ -96,7 +96,7 @@ module.exports = function sql (argv) {
96
96
  }
97
97
 
98
98
  if (argv.generate) {
99
- const dir = _paths.tdi + (_isPre51 ? '/util/db-config-generator/' : '/tct/sql/generate/');
99
+ const dir = _paths.tdi + (_isPre51() ? '/util/db-config-generator/' : '/tct/sql/generate/');
100
100
  fs.ensureSymlinkSync(_paths.apply, dir + 'dist', 'junction');
101
101
  runSqlScript(dir + 'start.sql');
102
102
  fs.removeSync(dir + 'dist');
@@ -104,7 +104,7 @@ module.exports = function sql (argv) {
104
104
  }
105
105
 
106
106
  if (argv.remove) {
107
- const dir = _paths.tdi + (_isPre51 ? '/util/db-config-remover/' : '/tct/sql/remove/');
107
+ const dir = _paths.tdi + (_isPre51() ? '/util/db-config-remover/' : '/tct/sql/remove/');
108
108
  runSqlScript(dir + 'start.sql');
109
109
  checkLog(dir + 'remove-config.log');
110
110
  }
package/.eslintrc.js DELETED
@@ -1,47 +0,0 @@
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
- '_formatDate': 'writable',
18
- '_error': 'writable',
19
- '_perf': 'writable',
20
- '_paths': 'writable',
21
- '_appdata': 'writable',
22
- '_packages': 'writable',
23
- '_appconfig': 'writable',
24
- '_git': 'writable',
25
- '_repoconfig': 'writable',
26
- '_tdiSubmoduleExists': 'writable',
27
- '_isPre42': 'writable',
28
- '_isPre51': 'writable'
29
- },
30
- 'rules': {
31
- 'no-var': ['error'],
32
- 'indent': ['error', 2],
33
- 'quotes': [
34
- 'error',
35
- 'single',
36
- {'avoidEscape': true, 'allowTemplateLiterals': true}
37
- ],
38
- 'semi': ['error', 'always'],
39
- 'comma-style': ['error', 'last'],
40
- 'array-bracket-spacing': ['error', 'never'],
41
- 'object-curly-spacing': ['error', 'never'],
42
- 'key-spacing': ['error'],
43
- 'comma-spacing': ['error'],
44
- 'rest-spread-spacing': ['error', 'never'],
45
- 'spaced-comment': ['error', 'always'],
46
- }
47
- };
@@ -1,36 +0,0 @@
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]
@@ -1,32 +0,0 @@
1
- image: atlassian/default-image:4
2
-
3
- clone:
4
- depth: full # SonarCloud scanner needs the full history to assign issues properly
5
-
6
- definitions:
7
- caches:
8
- sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
9
- services:
10
- docker:
11
- memory: 2048 # For large file line code
12
- steps:
13
- - step: &build-test-sonarcloud
14
- name: Build, test and analyze on SonarCloud
15
- caches:
16
- - sonar
17
- script:
18
- - pipe: sonarsource/sonarcloud-scan:1.4.0
19
- - step: &check-quality-gate-sonarcloud
20
- name: Check the Quality Gate on SonarCloud
21
- script:
22
- - pipe: sonarsource/sonarcloud-quality-gate:0.1.6
23
-
24
- pipelines:
25
- branches:
26
- master:
27
- - step: *build-test-sonarcloud
28
- - step: *check-quality-gate-sonarcloud
29
- pull-requests:
30
- '**':
31
- - step: *build-test-sonarcloud
32
- - step: *check-quality-gate-sonarcloud