test-bdk-cli 0.1.4 → 0.1.5
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/dist/commands/create.js +33 -2
- package/package.json +2 -2
package/dist/commands/create.js
CHANGED
|
@@ -26,10 +26,41 @@ function registerCreate(program) {
|
|
|
26
26
|
.option('--api-url <url>', 'BoldDesk API base URL (env BOLD_API_URL)')
|
|
27
27
|
.option('--token <token>', 'BoldDesk API token (env BOLD_API_TOKEN)')
|
|
28
28
|
.action(async (...args) => {
|
|
29
|
-
|
|
29
|
+
// normalize action arguments: support both (appDirectories..., opts) and (opts) shapes
|
|
30
|
+
let opts = {};
|
|
31
|
+
let appDirectories = ['.'];
|
|
32
|
+
if (args.length === 0) {
|
|
33
|
+
opts = {};
|
|
34
|
+
appDirectories = ['.'];
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// pick the last plain object (non-array) as options if present
|
|
38
|
+
for (let i = args.length - 1; i >= 0; i--) {
|
|
39
|
+
const a = args[i];
|
|
40
|
+
if (typeof a === 'object' && !Array.isArray(a)) {
|
|
41
|
+
opts = a;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// collect directory arguments: strings or arrays of strings
|
|
46
|
+
const collected = [];
|
|
47
|
+
for (const a of args) {
|
|
48
|
+
if (typeof a === 'string')
|
|
49
|
+
collected.push(a);
|
|
50
|
+
else if (Array.isArray(a)) {
|
|
51
|
+
for (const s of a)
|
|
52
|
+
if (typeof s === 'string')
|
|
53
|
+
collected.push(s);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
appDirectories = collected.length ? collected : ['.'];
|
|
57
|
+
}
|
|
30
58
|
const template = opts.template || 'react';
|
|
31
59
|
const basePath = path_1.default.resolve(opts.path || '.');
|
|
32
|
-
|
|
60
|
+
// flatten nested array if commander wrapped variadic into single array
|
|
61
|
+
if (Array.isArray(appDirectories) && appDirectories.length === 1 && Array.isArray(appDirectories[0])) {
|
|
62
|
+
appDirectories = appDirectories[0];
|
|
63
|
+
}
|
|
33
64
|
const templatesDir = path_1.default.resolve(__dirname, '../../templates', template);
|
|
34
65
|
if (!fs_1.default.existsSync(templatesDir)) {
|
|
35
66
|
console.error(`Template not found: ${templatesDir}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "test-bdk-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "test CLI",
|
|
5
5
|
"author": "@raisulaslam",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"ajv": "^8.12.0",
|
|
19
19
|
"archiver": "^5.3.1",
|
|
20
|
-
"
|
|
20
|
+
"test-bdk-cli": "^0.1.5",
|
|
21
21
|
"chokidar": "^3.5.3",
|
|
22
22
|
"commander": "^10.0.0",
|
|
23
23
|
"form-data": "^4.0.0",
|