@tangelo/tangelo-configuration-toolkit 1.12.1 → 1.13.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/package.json +1 -1
- package/src/cli.js +8 -6
- package/src/modules/{version → info}/index.js +65 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangelo/tangelo-configuration-toolkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.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
|
@@ -92,15 +92,17 @@ module.exports = function cli () {
|
|
|
92
92
|
remove: {alias: 'r', desc: 'Remove project configuration', conflicts: ['i', 'c', 'g']}
|
|
93
93
|
},
|
|
94
94
|
handler: require('./modules/sql')
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
})
|
|
96
|
+
.command({
|
|
97
|
+
command: 'info',
|
|
98
|
+
aliases: ['i'],
|
|
99
|
+
desc: 'Show project information',
|
|
99
100
|
builder: {
|
|
100
|
-
|
|
101
|
+
doctypes: {alias: 'd', desc: `List document-types information`},
|
|
102
|
+
versions: {alias: 'v', desc: `Find all version information, sorted by project or type`, choices: ['project', 'type'], conflicts: ['d']},
|
|
101
103
|
server: {alias: 's', desc: 'Pass server name (set in config file)', default: _appconfig.defaultServer}
|
|
102
104
|
},
|
|
103
|
-
handler: require('./modules/
|
|
105
|
+
handler: require('./modules/info')
|
|
104
106
|
})
|
|
105
107
|
.recommendCommands()
|
|
106
108
|
.option('config', {alias: 'c', desc: 'Show loaded appconfig', global: false})
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
const fs
|
|
2
|
-
const globby
|
|
3
|
-
const path
|
|
4
|
-
const {Table}
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
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 c = require('../deploy/config');
|
|
8
|
+
const {remote} = require('../deploy/execute');
|
|
9
|
+
|
|
8
10
|
|
|
9
11
|
const getGitInfo = () => {
|
|
10
12
|
// Version info TDI submodule
|
|
@@ -52,9 +54,8 @@ const getGitInfo = () => {
|
|
|
52
54
|
gitSubmoduleInfo.printTable();
|
|
53
55
|
};
|
|
54
56
|
|
|
55
|
-
const getFileExtractInfo = (
|
|
57
|
+
const getFileExtractInfo = (sorting) => {
|
|
56
58
|
// version info miscellaneous
|
|
57
|
-
const sorting = argv.find.toString().includes('sort-type') ? 'type' : 'project';
|
|
58
59
|
const projects = new Set;
|
|
59
60
|
const types = new Set;
|
|
60
61
|
const versionInfoConfigPath = path.join(_paths.repo, _paths.tdi, 'tct/version/versionInfo.js');
|
|
@@ -117,8 +118,8 @@ const getFileExtractInfo = (argv) => {
|
|
|
117
118
|
color: 'yellow'
|
|
118
119
|
});
|
|
119
120
|
});
|
|
120
|
-
}
|
|
121
|
-
if (sorting=='type') {
|
|
121
|
+
}
|
|
122
|
+
else if (sorting=='type') {
|
|
122
123
|
types.forEach(t => {
|
|
123
124
|
versionInfo.addRow({ // Add empty row after type
|
|
124
125
|
path: '',
|
|
@@ -129,30 +130,73 @@ const getFileExtractInfo = (argv) => {
|
|
|
129
130
|
});
|
|
130
131
|
}
|
|
131
132
|
versionInfo.printTable();
|
|
132
|
-
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
133
135
|
_warn('Version info of miscellaneous items cannot be extracted:\nCannot find required files in TDI submodule. Try updating TDI submodule.');
|
|
134
136
|
}
|
|
135
137
|
};
|
|
136
138
|
|
|
137
|
-
const getServerInfo = (
|
|
139
|
+
const getServerInfo = (server) => {
|
|
138
140
|
// Remote server info
|
|
139
141
|
// common setup
|
|
140
142
|
_write();
|
|
141
|
-
c.setServer(
|
|
143
|
+
c.setServer(server);
|
|
142
144
|
|
|
143
145
|
if (!c.envDev) {
|
|
144
146
|
_info(`Remote version info for '${c.server.ftpConfig.host}':\n`);
|
|
145
147
|
remote.add('sudo ~root/scripts/version.sh', '').process();
|
|
146
|
-
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
147
150
|
_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.');
|
|
148
151
|
}
|
|
149
152
|
};
|
|
150
153
|
|
|
151
|
-
module.exports = function version (argv) {
|
|
152
|
-
_info('Version information of this git repository\n');
|
|
153
154
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
module.exports = function info (argv) {
|
|
156
|
+
|
|
157
|
+
if (argv.doctypes) {
|
|
158
|
+
_info('Document type information for this git repository\n');
|
|
157
159
|
|
|
158
|
-
|
|
160
|
+
const doctypesInfo = new Table({
|
|
161
|
+
columns: [
|
|
162
|
+
{name: 'id', alignment: 'right'},
|
|
163
|
+
{name: 'name', alignment: 'left'},
|
|
164
|
+
{name: 'paths', alignment: 'left'}
|
|
165
|
+
],
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
globby
|
|
169
|
+
.sync(_paths.repo + '/database/config/**/txd_document_types.sql')
|
|
170
|
+
.forEach((p, i, a) => {
|
|
171
|
+
fs.readFileSync(p).toString().match(/select([\s\S]+?)from\s+dual/gmi)
|
|
172
|
+
.forEach((dtRow, i, a) => {
|
|
173
|
+
const ntSqlInsert = fs.readFileSync(p.replace('txd_document_types', 'txd_node_types')).toString().match(/select(.*?)from\s+dual/s)[1];
|
|
174
|
+
const id = dtRow.match(/(\d+) id/)?.[1];
|
|
175
|
+
const name = dtRow.match(/'([^']+)' display_name/)?.[1];
|
|
176
|
+
const dbPath = p.match(/(database\/config\/(:?.*)\/)txd_document_types.sql/i)?.[1];
|
|
177
|
+
const prPath = ntSqlInsert.match(/'([^']+)' xsl_prep_inc/)[1].replace('prepare_xincludes.xsl','');
|
|
178
|
+
|
|
179
|
+
doctypesInfo.addRows([
|
|
180
|
+
{id, name, paths: 'config/cmscustom/'+ prPath},
|
|
181
|
+
{paths: dbPath}
|
|
182
|
+
]);
|
|
183
|
+
|
|
184
|
+
if (i!==a.length-1) doctypesInfo.addRow({});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
if (i!==a.length-1) doctypesInfo.addRow({});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
doctypesInfo.printTable();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (argv.versions) {
|
|
195
|
+
_info('Version information for this git repository\n');
|
|
196
|
+
|
|
197
|
+
getGitInfo();
|
|
198
|
+
getFileExtractInfo(argv.versions);
|
|
199
|
+
getServerInfo(argv.server);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
};
|