@tangelo/tangelo-configuration-toolkit 1.14.3 → 1.14.4
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/.pre-commit-config.yaml +9 -10
- package/.vscode/settings.json +6 -0
- package/README.md +67 -67
- package/bin/index.js +2 -2
- package/bitbucket-pipelines.yml +7 -7
- package/index.js +8 -8
- package/package.json +6 -6
- package/src/lib/get-repoconfig.js +3 -3
- package/src/lib/get-tdi-branch.js +43 -43
- package/src/lib/gulp-batch-replace-with-filter.js +19 -19
- package/src/lib/gulp-simple-rename.js +11 -11
- package/src/lib/style-string-getters.js +2 -0
- package/src/modules/build/oxygen.js +174 -174
- package/src/modules/fonto/commands.js +4 -4
- package/src/modules/fonto/index.js +8 -8
- package/src/modules/git/index.js +1 -1
- package/src/modules/info/index.js +201 -201
|
@@ -1,201 +1,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 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 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
|
+
};
|