@nebula.js/cli 6.8.0 → 7.0.1

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.
@@ -25,4 +25,4 @@ function checkNodeVersion(pkg) {
25
25
  }
26
26
  }
27
27
 
28
- module.exports = checkNodeVersion;
28
+ export default checkNodeVersion;
package/lib/index.js CHANGED
@@ -1,26 +1,44 @@
1
1
  #!/usr/bin/env node
2
- /* eslint-disable no-console */
3
- const yargs = require('yargs');
4
- const importCwd = require('import-cwd');
5
- const checkNodeVersion = require('./checkNodeVersion');
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.usage('nebula <command> [options]');
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 = require(`${m}/command`); // eslint-disable-line
28
+ cmd = await getCommand(`${m}/command.js`);
17
29
  } catch (e) {
18
30
  error = e;
19
- cmd = importCwd.silent(`${m}/command`);
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
- yargs.command(cmd);
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
- yargs.command({
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
- ['@nebula.js/cli-create', '@nebula.js/cli-build', '@nebula.js/cli-serve', '@nebula.js/cli-sense'].forEach(
43
- tryAddCommand
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
- yargs.demandCommand().alias('h', 'help').wrap(Math.min(80, yargs.terminalWidth())).argv;
71
+ run();
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@nebula.js/cli",
3
- "version": "6.8.0",
3
+ "version": "7.0.1",
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": ">=18.10.0"
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 - 6",
29
- "@nebula.js/cli-sense": "5.0.0 - 6",
30
- "@nebula.js/cli-serve": "5.0.0 - 6"
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": "^6.8.0",
34
+ "@nebula.js/cli-create": "^7.0.1",
34
35
  "import-cwd": "3.0.0",
35
- "yargs": "17.7.2"
36
+ "yargs": "18.0.0"
36
37
  },
37
- "gitHead": "5da9c702c8dc6c9570ea50ef458d2328385eef2b"
38
+ "gitHead": "d04cf92d3bc24efb02fc8c578abb6629781e4766"
38
39
  }