@nebula.js/cli 6.8.0 → 7.0.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/checkNodeVersion.js +1 -1
- package/lib/index.js +39 -14
- package/package.json +9 -8
package/lib/checkNodeVersion.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,26 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/* eslint-disable no-console */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/* eslint-disable no-console, import/extensions */
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
import { pathToFileURL } from 'url';
|
|
6
|
+
import yargs from 'yargs';
|
|
7
|
+
|
|
8
|
+
import checkNodeVersion from './checkNodeVersion.js';
|
|
9
|
+
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
6
11
|
const pkg = require('../package.json');
|
|
7
12
|
|
|
8
13
|
checkNodeVersion(pkg);
|
|
9
14
|
|
|
10
|
-
yargs.
|
|
15
|
+
const cli = yargs(process.argv.slice(2));
|
|
16
|
+
|
|
17
|
+
cli.usage('nebula <command> [options]');
|
|
18
|
+
|
|
19
|
+
const getCommand = async (specifier) => {
|
|
20
|
+
const mod = await import(specifier);
|
|
21
|
+
return mod.default || mod;
|
|
22
|
+
};
|
|
11
23
|
|
|
12
|
-
const tryAddCommand = (m) => {
|
|
24
|
+
const tryAddCommand = async (m) => {
|
|
13
25
|
let cmd;
|
|
14
26
|
let error;
|
|
15
27
|
try {
|
|
16
|
-
cmd =
|
|
28
|
+
cmd = await getCommand(`${m}/command.js`);
|
|
17
29
|
} catch (e) {
|
|
18
30
|
error = e;
|
|
19
|
-
|
|
31
|
+
try {
|
|
32
|
+
const cwdRequire = createRequire(path.join(process.cwd(), 'package.json'));
|
|
33
|
+
const resolved = cwdRequire.resolve(`${m}/command`);
|
|
34
|
+
cmd = await getCommand(pathToFileURL(resolved).href);
|
|
35
|
+
} catch (ee) {
|
|
36
|
+
error = ee;
|
|
37
|
+
}
|
|
20
38
|
}
|
|
21
39
|
|
|
22
40
|
if (cmd) {
|
|
23
|
-
|
|
41
|
+
cli.command(cmd);
|
|
24
42
|
} else {
|
|
25
43
|
// Print the error
|
|
26
44
|
if (error) {
|
|
@@ -28,7 +46,7 @@ const tryAddCommand = (m) => {
|
|
|
28
46
|
}
|
|
29
47
|
// add dummy command in order to instruct user how to install missing package
|
|
30
48
|
const comm = m.split('-')[1];
|
|
31
|
-
|
|
49
|
+
cli.command({
|
|
32
50
|
command: comm,
|
|
33
51
|
handler() {
|
|
34
52
|
throw new Error(
|
|
@@ -39,8 +57,15 @@ const tryAddCommand = (m) => {
|
|
|
39
57
|
}
|
|
40
58
|
};
|
|
41
59
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
60
|
+
const run = async () => {
|
|
61
|
+
await ['@nebula.js/cli-create', '@nebula.js/cli-build', '@nebula.js/cli-serve', '@nebula.js/cli-sense'].reduce(
|
|
62
|
+
(chain, commandPackage) =>
|
|
63
|
+
// Preserve deterministic command registration order.
|
|
64
|
+
chain.then(() => tryAddCommand(commandPackage)),
|
|
65
|
+
Promise.resolve()
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
cli.demandCommand().alias('h', 'help').wrap(Math.min(80, cli.terminalWidth())).argv;
|
|
69
|
+
};
|
|
45
70
|
|
|
46
|
-
|
|
71
|
+
run();
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebula.js/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"author": "QlikTech International AB",
|
|
7
8
|
"keywords": [],
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
"lib"
|
|
17
18
|
],
|
|
18
19
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
20
|
+
"node": ">=24.0.0"
|
|
20
21
|
},
|
|
21
22
|
"bin": {
|
|
22
23
|
"nebula": "lib/index.js"
|
|
@@ -25,14 +26,14 @@
|
|
|
25
26
|
"lint": "eslint src"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
|
-
"@nebula.js/cli-build": "5.0.0 -
|
|
29
|
-
"@nebula.js/cli-sense": "5.0.0 -
|
|
30
|
-
"@nebula.js/cli-serve": "5.0.0 -
|
|
29
|
+
"@nebula.js/cli-build": "5.0.0 - 7",
|
|
30
|
+
"@nebula.js/cli-sense": "5.0.0 - 7",
|
|
31
|
+
"@nebula.js/cli-serve": "5.0.0 - 7"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@nebula.js/cli-create": "^
|
|
34
|
+
"@nebula.js/cli-create": "^7.0.0",
|
|
34
35
|
"import-cwd": "3.0.0",
|
|
35
|
-
"yargs": "
|
|
36
|
+
"yargs": "18.0.0"
|
|
36
37
|
},
|
|
37
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "93100660bf15d108c07c96c46e93858c449c483c"
|
|
38
39
|
}
|