@hahnpro/flow-cli 2.15.3 → 2.16.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/lib/cli.mjs +92 -82
- package/package.json +11 -11
package/lib/cli.mjs
CHANGED
|
@@ -58,15 +58,16 @@ program
|
|
|
58
58
|
.on('--help', () => {});
|
|
59
59
|
|
|
60
60
|
program
|
|
61
|
-
.command('build [
|
|
62
|
-
.description('
|
|
63
|
-
.action(async (
|
|
61
|
+
.command('build [moduleNames]')
|
|
62
|
+
.description('Build specified Module(s)')
|
|
63
|
+
.action(async (moduleNames) => {
|
|
64
64
|
try {
|
|
65
|
-
|
|
66
|
-
const project
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
const projects = await selectProjects(moduleNames);
|
|
66
|
+
for (const project of projects) {
|
|
67
|
+
await exec(CMD.INSTALL, project);
|
|
68
|
+
await exec(CMD.BUILD, project);
|
|
69
|
+
await copyProjectFiles(project);
|
|
70
|
+
}
|
|
70
71
|
} catch (error) {
|
|
71
72
|
if (error) logger.log(error);
|
|
72
73
|
process.exit(1);
|
|
@@ -74,17 +75,12 @@ program
|
|
|
74
75
|
});
|
|
75
76
|
|
|
76
77
|
program
|
|
77
|
-
.command('install [
|
|
78
|
-
.description('
|
|
79
|
-
.action(async (
|
|
78
|
+
.command('install [moduleNames]')
|
|
79
|
+
.description('Install the dependencies of the specified Module(s)')
|
|
80
|
+
.action(async (moduleNames) => {
|
|
80
81
|
try {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
for (const project of projects) {
|
|
84
|
-
await exec(CMD.INSTALL, project);
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
const project = await findProject(projectName);
|
|
82
|
+
const projects = await selectProjects(moduleNames);
|
|
83
|
+
for (const project of projects) {
|
|
88
84
|
await exec(CMD.INSTALL, project);
|
|
89
85
|
}
|
|
90
86
|
} catch (error) {
|
|
@@ -94,17 +90,12 @@ program
|
|
|
94
90
|
});
|
|
95
91
|
|
|
96
92
|
program
|
|
97
|
-
.command('audit [
|
|
98
|
-
.description('Audit dependencies')
|
|
99
|
-
.action(async (
|
|
93
|
+
.command('audit [moduleNames]')
|
|
94
|
+
.description('Audit dependencies for the specified Module(s)')
|
|
95
|
+
.action(async (moduleNames) => {
|
|
100
96
|
try {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
for (const project of projects) {
|
|
104
|
-
await exec(CMD.AUDIT, project);
|
|
105
|
-
}
|
|
106
|
-
} else {
|
|
107
|
-
const project = await findProject(projectName);
|
|
97
|
+
const projects = await selectProjects(moduleNames);
|
|
98
|
+
for (const project of projects) {
|
|
108
99
|
await exec(CMD.AUDIT, project);
|
|
109
100
|
}
|
|
110
101
|
} catch (error) {
|
|
@@ -114,12 +105,14 @@ program
|
|
|
114
105
|
});
|
|
115
106
|
|
|
116
107
|
program
|
|
117
|
-
.command('lint [
|
|
118
|
-
.description('Lint
|
|
119
|
-
.action(async (
|
|
108
|
+
.command('lint [moduleNames]')
|
|
109
|
+
.description('Lint source files for the specified Module(s)')
|
|
110
|
+
.action(async (moduleNames) => {
|
|
120
111
|
try {
|
|
121
|
-
const
|
|
122
|
-
|
|
112
|
+
const projects = await selectProjects(moduleNames);
|
|
113
|
+
for (const project of projects) {
|
|
114
|
+
await exec(CMD.LINT, project);
|
|
115
|
+
}
|
|
123
116
|
} catch (error) {
|
|
124
117
|
if (error) logger.log(error);
|
|
125
118
|
process.exit(1);
|
|
@@ -158,7 +151,7 @@ program
|
|
|
158
151
|
|
|
159
152
|
program
|
|
160
153
|
.command('format')
|
|
161
|
-
.description('
|
|
154
|
+
.description('Format all typescript files according to prettier configuration')
|
|
162
155
|
.action(async () => {
|
|
163
156
|
try {
|
|
164
157
|
await exec(CMD.FORMAT, { name: 'all' });
|
|
@@ -169,18 +162,19 @@ program
|
|
|
169
162
|
});
|
|
170
163
|
|
|
171
164
|
program
|
|
172
|
-
.command('package [
|
|
173
|
-
.description('
|
|
174
|
-
.action(async (
|
|
165
|
+
.command('package [moduleNames]')
|
|
166
|
+
.description('Build specified Module(s) and package as .zip file for manual upload to the platform')
|
|
167
|
+
.action(async (moduleNames) => {
|
|
175
168
|
try {
|
|
176
|
-
|
|
177
|
-
const project = await findProject(projectName);
|
|
169
|
+
const projects = await selectProjects(moduleNames);
|
|
178
170
|
await clean(BUILD_DIR);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
171
|
+
for (const project of projects) {
|
|
172
|
+
await exec(CMD.INSTALL, project);
|
|
173
|
+
await exec(CMD.BUILD, project);
|
|
174
|
+
await copyProjectFiles(project);
|
|
175
|
+
await validateModule(project);
|
|
176
|
+
await packageModule(project);
|
|
177
|
+
}
|
|
184
178
|
} catch (error) {
|
|
185
179
|
if (error) logger.log(error);
|
|
186
180
|
process.exit(1);
|
|
@@ -188,28 +182,21 @@ program
|
|
|
188
182
|
});
|
|
189
183
|
|
|
190
184
|
program
|
|
191
|
-
.command('publish-module [
|
|
185
|
+
.command('publish-module [moduleNames]')
|
|
192
186
|
.requiredOption('--url <url>', 'URL of target platform', process.env.BASE_URL)
|
|
193
187
|
.requiredOption('-r, --realm <realm>', 'Auth realm of target platform', process.env.REALM)
|
|
194
188
|
.option('-f, --functions', 'publish flow functions')
|
|
195
189
|
.option('-u, --update', 'update existing flow functions')
|
|
196
190
|
.option('-s, --skip', 'skip modules that already exists with the current version')
|
|
197
|
-
.description('
|
|
198
|
-
.action(async (
|
|
191
|
+
.description('Publish specified Module(s) to Cloud Platform')
|
|
192
|
+
.action(async (moduleNames, options) => {
|
|
199
193
|
try {
|
|
200
|
-
const projects =
|
|
201
|
-
if (projectName === 'all') {
|
|
202
|
-
for (const project of await findProjects()) {
|
|
203
|
-
projects.push(project);
|
|
204
|
-
}
|
|
205
|
-
} else {
|
|
206
|
-
projects.push(await findProject(projectName));
|
|
207
|
-
}
|
|
194
|
+
const projects = await selectProjects(moduleNames);
|
|
208
195
|
|
|
209
196
|
apiToken = await getAccessToken(options.url, options.realm);
|
|
210
197
|
logger.ok('Got Access Token');
|
|
198
|
+
await clean(BUILD_DIR);
|
|
211
199
|
for (const project of projects) {
|
|
212
|
-
await clean(BUILD_DIR);
|
|
213
200
|
await exec(CMD.INSTALL, project);
|
|
214
201
|
await exec(CMD.BUILD, project);
|
|
215
202
|
await copyProjectFiles(project);
|
|
@@ -242,21 +229,14 @@ program
|
|
|
242
229
|
});
|
|
243
230
|
|
|
244
231
|
program
|
|
245
|
-
.command('publish-functions [
|
|
232
|
+
.command('publish-functions [moduleNames]')
|
|
246
233
|
.requiredOption('--url <url>', 'URL of target platform', process.env.BASE_URL)
|
|
247
234
|
.requiredOption('-r, --realm <realm>', 'Auth realm of target platform', process.env.REALM)
|
|
248
235
|
.option('-u, --update', 'update existing flow functions')
|
|
249
|
-
.description('
|
|
250
|
-
.action(async (
|
|
236
|
+
.description('Publish all Flow Functions inside specified Module(s) to Cloud Platform')
|
|
237
|
+
.action(async (moduleNames, options) => {
|
|
251
238
|
try {
|
|
252
|
-
const projects =
|
|
253
|
-
if (projectName === 'all') {
|
|
254
|
-
for (const project of await findProjects()) {
|
|
255
|
-
projects.push(project);
|
|
256
|
-
}
|
|
257
|
-
} else {
|
|
258
|
-
projects.push(await findProject(projectName));
|
|
259
|
-
}
|
|
239
|
+
const projects = await selectProjects(moduleNames);
|
|
260
240
|
|
|
261
241
|
apiToken = await getAccessToken(options.url, options.realm);
|
|
262
242
|
logger.ok('Got Access Token');
|
|
@@ -301,19 +281,18 @@ program
|
|
|
301
281
|
});
|
|
302
282
|
|
|
303
283
|
program
|
|
304
|
-
.command('test [
|
|
305
|
-
.description('Runs tests for
|
|
306
|
-
.action(async (
|
|
284
|
+
.command('test [moduleNames]')
|
|
285
|
+
.description('Runs tests for specified Module(s)')
|
|
286
|
+
.action(async (moduleNames) => {
|
|
307
287
|
try {
|
|
308
|
-
// check if it is running in
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const project = await findProject(projectName);
|
|
288
|
+
// check if it is running in CI environment
|
|
289
|
+
let projects = await selectProjects(moduleNames);
|
|
290
|
+
if (process.env.CI) {
|
|
291
|
+
// only run tests that can be run in CI
|
|
292
|
+
projects = projects.filter((project) => !project['excludeTestsInCI']);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
for (const project of projects) {
|
|
317
296
|
await exec(CMD.TEST, project);
|
|
318
297
|
}
|
|
319
298
|
} catch (error) {
|
|
@@ -443,10 +422,10 @@ async function findProjects() {
|
|
|
443
422
|
const isProject = (directory) =>
|
|
444
423
|
new Promise((resolve) => {
|
|
445
424
|
fs.access(path.join(directory, 'package.json'), (error) => {
|
|
446
|
-
if (
|
|
447
|
-
resolve(true);
|
|
448
|
-
} else {
|
|
425
|
+
if (error) {
|
|
449
426
|
resolve(false);
|
|
427
|
+
} else {
|
|
428
|
+
resolve(true);
|
|
450
429
|
}
|
|
451
430
|
});
|
|
452
431
|
});
|
|
@@ -509,6 +488,37 @@ function findProject(projectName) {
|
|
|
509
488
|
});
|
|
510
489
|
}
|
|
511
490
|
|
|
491
|
+
function selectProjects(value) {
|
|
492
|
+
return new Promise(async (resolve, reject) => {
|
|
493
|
+
if (!value) {
|
|
494
|
+
logger.error('No Module specified');
|
|
495
|
+
return reject();
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
const projectNames = value.split(',').map((v) => v.trim());
|
|
499
|
+
const allProjects = await findProjects();
|
|
500
|
+
if (value === 'all') {
|
|
501
|
+
return resolve(allProjects);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
const projects = [];
|
|
505
|
+
for (const project of allProjects) {
|
|
506
|
+
const location = path.parse(project.location);
|
|
507
|
+
const directoryName = location.name + location.ext;
|
|
508
|
+
if (projectNames.includes(project.name) || projectNames.includes(directoryName)) {
|
|
509
|
+
projects.push(project);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if (projects.length === 0) {
|
|
514
|
+
logger.error(`Cloud not find any Modules for ${JSON.stringify(projectNames)}.`);
|
|
515
|
+
reject();
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
return resolve(projects);
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
|
|
512
522
|
async function packageModule(project) {
|
|
513
523
|
const { dist, ...package_ } = project;
|
|
514
524
|
const file = path.posix.join(dist, '..', `${project.name}.zip`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/flow-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "CLI for managing Flow Modules",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"archiver": "^5.3.1",
|
|
30
30
|
"axios": "~1.1.3",
|
|
31
|
-
"chalk": "^5.
|
|
31
|
+
"chalk": "^5.2.0",
|
|
32
32
|
"class-transformer": "0.5.1",
|
|
33
|
-
"class-validator": "~0.
|
|
33
|
+
"class-validator": "~0.14.0",
|
|
34
34
|
"class-validator-jsonschema": "^3.1.1",
|
|
35
35
|
"commander": "^9.4.1",
|
|
36
36
|
"copyfiles": "^2.4.1",
|
|
@@ -44,21 +44,21 @@
|
|
|
44
44
|
"https-proxy-agent": "^5.0.1",
|
|
45
45
|
"nconf": "^0.12.0",
|
|
46
46
|
"open": "^8.4.0",
|
|
47
|
-
"openid-client": "^5.3.
|
|
47
|
+
"openid-client": "^5.3.1",
|
|
48
48
|
"ora": "^6.1.2",
|
|
49
49
|
"reflect-metadata": "^0.1.13",
|
|
50
50
|
"ts-node": "^10.9.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/express": "^4.17.
|
|
54
|
-
"@types/jest": "^29.2.
|
|
53
|
+
"@types/express": "^4.17.15",
|
|
54
|
+
"@types/jest": "^29.2.4",
|
|
55
55
|
"@types/nconf": "^0.10.3",
|
|
56
|
-
"@types/node": "^18.11.
|
|
57
|
-
"eslint": "^8.
|
|
58
|
-
"eslint-plugin-unicorn": "^
|
|
56
|
+
"@types/node": "^18.11.15",
|
|
57
|
+
"eslint": "^8.29.0",
|
|
58
|
+
"eslint-plugin-unicorn": "^45.0.2",
|
|
59
59
|
"jest": "^29.3.1",
|
|
60
|
-
"prettier": "^2.8.
|
|
61
|
-
"typescript": "^4.9.
|
|
60
|
+
"prettier": "^2.8.1",
|
|
61
|
+
"typescript": "^4.9.4"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": "^14.13.1 || >=16.0.0"
|