@enact/cli 6.0.1 → 6.0.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 6.0.3 (October 5, 2023)
2
+
3
+ * Updated `prettier` version to `^3.0.1` and `eslint-plugin-prettier` version to `^5.0.0`.
4
+
5
+ ## 6.0.2 (July 26, 2023)
6
+
7
+ * Updated `chalk` version to `^5.3.0`.
8
+ * Updated `find-cache-dir` version to `^7.1.0`.
9
+
1
10
  ## 6.0.1 (July 4, 2023)
2
11
 
3
12
  * Updated dependencies.
package/bin/enact.js CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  'use strict';
4
4
 
5
- const chalk = require('chalk');
6
5
  const semver = require('semver');
7
6
  const pkg = require('../package.json');
8
7
 
@@ -14,11 +13,13 @@ if (
14
13
  pkg.engines.node
15
14
  )
16
15
  ) {
17
- console.log(
18
- chalk.red(`You are running Node ${process.version}, but @enact/cli requires Node ${pkg.engines.node}.\n`) +
19
- chalk.bold.red('Please update your version of Node.')
20
- );
21
- process.exit(1);
16
+ import('chalk').then(({default: chalk}) => {
17
+ console.log(
18
+ chalk.red(`You are running Node ${process.version}, but @enact/cli requires Node ${pkg.engines.node}.\n`) +
19
+ chalk.bold.red('Please update your version of Node.')
20
+ );
21
+ process.exit(1);
22
+ });
22
23
  }
23
24
 
24
25
  // Uncaught error handler
@@ -29,8 +30,9 @@ if (process.platform === 'win32' && process.title === 'Windows PowerShell ISE')
29
30
 
30
31
  // Handle tasks/arguments
31
32
  if (process.argv.indexOf('-v') >= 0 || process.argv.indexOf('--version') >= 0) {
32
- // Enact-CLI ascii art title
33
- const title = `
33
+ import('chalk').then(({default: chalk}) => {
34
+ // Enact-CLI ascii art title
35
+ const title = `
34
36
  ┌─┐┌┐┌┌─┐┌─┐┌┬┐ ┌─┐┬ ┬ ▐██▄▄ ▄▄██▌
35
37
  │ ││││ ││ │ │ │ │ ▐██▀██████▀▀
36
38
  ├┤ │││├─┤│ │ ──│ │ │ ▐██▄▄ ▀▀ ▄▄
@@ -38,21 +40,24 @@ if (process.argv.indexOf('-v') >= 0 || process.argv.indexOf('--version') >= 0) {
38
40
  └─┘┘└┘┴ ┴└─┘ ┴ └─┘┴─┘┴ ▐██▄▄ ▀▀ ▄▄██▌
39
41
  ──────────────────────── ▀▀██████▀▀
40
42
  ▀▀ `;
41
- // Add colour to the logo
42
- const colourTitle = title
43
- .split(/[\n\r]+/g)
44
- .map(l => {
45
- const half = (l.length - 31) / 2;
46
- return (
47
- l.substring(0, 31) +
48
- chalk.bgBlueBright(chalk.whiteBright(l.substring(31, 31 + half)) + chalk.white(l.substring(31 + half)))
49
- );
50
- })
51
- .join('\n');
52
- console.log();
53
- console.log(colourTitle);
54
- console.log(' Version ' + pkg.version);
55
- console.log();
43
+ // Add colour to the logo
44
+ const colourTitle = title
45
+ .split(/[\n\r]+/g)
46
+ .map(l => {
47
+ const half = (l.length - 31) / 2;
48
+ return (
49
+ l.substring(0, 31) +
50
+ chalk.bgBlueBright(
51
+ chalk.whiteBright(l.substring(31, 31 + half)) + chalk.white(l.substring(31 + half))
52
+ )
53
+ );
54
+ })
55
+ .join('\n');
56
+ console.log();
57
+ console.log(colourTitle);
58
+ console.log(' Version ' + pkg.version);
59
+ console.log();
60
+ });
56
61
  } else {
57
62
  const command = process.argv[2];
58
63
 
@@ -75,25 +80,27 @@ if (process.argv.indexOf('-v') >= 0 || process.argv.indexOf('--version') >= 0) {
75
80
  break;
76
81
  }
77
82
  default: {
78
- console.log(' Usage');
79
- console.log(' enact <command> [...]');
80
- console.log();
81
- console.log(' Commands');
82
- console.log(' create Create a new project');
83
- console.log(' link Link @enact dependencies');
84
- console.log(' bootstrap Install and link dependencies');
85
- console.log(' serve Development server');
86
- console.log(' pack Bundle source code');
87
- console.log(' test Test specs runner');
88
- console.log(' transpile Transpile to ES5');
89
- console.log(' template Manage Enact templates');
90
- console.log(' license Detect all used licenses');
91
- console.log(' lint Lint source code');
92
- console.log(' clean Clean build directory');
93
- console.log(' eject Eject to standalone app');
94
- console.log();
95
- console.log(` Refer to each command's ${chalk.cyan('--help')} for more details.`);
96
- console.log();
83
+ import('chalk').then(({default: chalk}) => {
84
+ console.log(' Usage');
85
+ console.log(' enact <command> [...]');
86
+ console.log();
87
+ console.log(' Commands');
88
+ console.log(' create Create a new project');
89
+ console.log(' link Link @enact dependencies');
90
+ console.log(' bootstrap Install and link dependencies');
91
+ console.log(' serve Development server');
92
+ console.log(' pack Bundle source code');
93
+ console.log(' test Test specs runner');
94
+ console.log(' transpile Transpile to ES5');
95
+ console.log(' template Manage Enact templates');
96
+ console.log(' license Detect all used licenses');
97
+ console.log(' lint Lint source code');
98
+ console.log(' clean Clean build directory');
99
+ console.log(' eject Eject to standalone app');
100
+ console.log();
101
+ console.log(` Refer to each command's ${chalk.cyan('--help')} for more details.`);
102
+ console.log();
103
+ });
97
104
  }
98
105
  }
99
106
  }
@@ -1,12 +1,13 @@
1
1
  // @remove-file-on-eject
2
2
  const path = require('path');
3
- const chalk = require('chalk');
4
3
  const spawn = require('cross-spawn');
5
4
  const fs = require('fs-extra');
6
5
  const minimist = require('minimist');
7
6
  const packageRoot = require('@enact/dev-utils').packageRoot;
8
7
  const doLink = require('./link').api;
9
8
 
9
+ let chalk;
10
+
10
11
  function displayHelp() {
11
12
  let e = 'node ' + path.relative(process.cwd(), __filename);
12
13
  if (require.main !== module) e = 'enact bootstrap';
@@ -175,9 +176,12 @@ function cli(args) {
175
176
 
176
177
  if (opts._[0] && fs.statSync(opts._[0]).isDirectory()) opts.cwd = opts._[0];
177
178
 
178
- api(opts).catch(err => {
179
- console.error(chalk.red('ERROR: ') + err.message);
180
- process.exit(1);
179
+ import('chalk').then(({default: _chalk}) => {
180
+ chalk = _chalk;
181
+ api(opts).catch(err => {
182
+ console.error(chalk.red('ERROR: ') + err.message);
183
+ process.exit(1);
184
+ });
181
185
  });
182
186
  }
183
187
 
package/commands/clean.js CHANGED
@@ -1,10 +1,11 @@
1
1
  /* eslint-env node, es6 */
2
2
  const path = require('path');
3
- const chalk = require('chalk');
4
3
  const fs = require('fs-extra');
5
4
  const minimist = require('minimist');
6
5
  const packageRoot = require('@enact/dev-utils').packageRoot;
7
6
 
7
+ let chalk;
8
+
8
9
  const build = 'build';
9
10
  const dist = 'dist';
10
11
  const node_modules = 'node_modules';
@@ -57,9 +58,12 @@ function cli(args) {
57
58
  if (opts.help) displayHelp();
58
59
 
59
60
  process.chdir(packageRoot().path);
60
- api({paths: opts._, all: opts.all}).catch(err => {
61
- console.error(chalk.red('ERROR: ') + 'Failed to clean project.\n' + err.message);
62
- process.exit(1);
61
+ import('chalk').then(({default: _chalk}) => {
62
+ chalk = _chalk;
63
+ api({paths: opts._, all: opts.all}).catch(err => {
64
+ console.error(chalk.red('ERROR: ') + 'Failed to clean project.\n' + err.message);
65
+ process.exit(1);
66
+ });
63
67
  });
64
68
  }
65
69
 
@@ -11,12 +11,13 @@
11
11
  */
12
12
  const os = require('os');
13
13
  const path = require('path');
14
- const chalk = require('chalk');
15
14
  const spawn = require('cross-spawn');
16
15
  const fs = require('fs-extra');
17
16
  const minimist = require('minimist');
18
17
  const validatePackageName = require('validate-npm-package-name');
19
18
 
19
+ let chalk;
20
+
20
21
  const ENACT_DEV_NPM = '@enact/cli';
21
22
  const INCLUDED = path.dirname(require.resolve('@enact/template-sandstone'));
22
23
  const TEMPLATE_DIR = path.join(process.env.APPDATA || os.homedir(), '.enact');
@@ -283,9 +284,12 @@ function cli(args) {
283
284
  opts.directory = path.resolve(typeof opts._[0] !== 'undefined' ? opts._[0] + '' : process.cwd());
284
285
  opts.name = path.basename(opts.directory).replace(/ /g, '-').toLowerCase();
285
286
 
286
- api(opts).catch(err => {
287
- console.error(chalk.red('ERROR: ') + err.message);
288
- process.exit(1);
287
+ import('chalk').then(({default: _chalk}) => {
288
+ chalk = _chalk;
289
+ api(opts).catch(err => {
290
+ console.error(chalk.red('ERROR: ') + err.message);
291
+ process.exit(1);
292
+ });
289
293
  });
290
294
  }
291
295
 
package/commands/eject.js CHANGED
@@ -12,13 +12,14 @@
12
12
  const cp = require('child_process');
13
13
  const os = require('os');
14
14
  const path = require('path');
15
- const chalk = require('chalk');
16
15
  const fs = require('fs-extra');
17
16
  const prompts = require('prompts');
18
17
  const minimist = require('minimist');
19
18
  const {packageRoot} = require('@enact/dev-utils');
20
19
  const spawn = require('cross-spawn');
21
20
 
21
+ let chalk;
22
+
22
23
  const assets = [
23
24
  {src: path.join(__dirname, '..', 'config'), dest: 'config'},
24
25
  {src: path.join(__dirname, '..', 'config', 'jest'), dest: 'config/jest'},
@@ -303,9 +304,12 @@ function cli(args) {
303
304
 
304
305
  process.chdir(packageRoot().path);
305
306
 
306
- api({bare: opts.bare}).catch(err => {
307
- console.error(chalk.red('ERROR: ') + err.message);
308
- process.exit(1);
307
+ import('chalk').then(({default: _chalk}) => {
308
+ chalk = _chalk;
309
+ api({bare: opts.bare}).catch(err => {
310
+ console.error(chalk.red('ERROR: ') + err.message);
311
+ process.exit(1);
312
+ });
309
313
  });
310
314
  }
311
315
 
package/commands/info.js CHANGED
@@ -1,11 +1,12 @@
1
1
  /* eslint-env node, es6 */
2
2
  const path = require('path');
3
3
  const fs = require('fs');
4
- const chalk = require('chalk');
5
4
  const spawn = require('cross-spawn');
6
5
  const minimist = require('minimist');
7
6
  const resolveSync = require('resolve').sync;
8
7
 
8
+ let chalk;
9
+
9
10
  function displayHelp() {
10
11
  let e = 'node ' + path.relative(process.cwd(), __filename);
11
12
  if (require.main !== module) e = 'enact info';
@@ -120,10 +121,12 @@ function api({cliInfo = false, dev = false} = {}) {
120
121
  } else {
121
122
  const app = require('@enact/dev-utils').optionParser;
122
123
  const meta = require(path.join(app.context, 'package.json'));
123
- const bl = require(resolveSync('browserslist', {
124
- basedir: path.dirname(require.resolve('@enact/dev-utils/package.json')),
125
- preserveSymlinks: false
126
- }));
124
+ const bl = require(
125
+ resolveSync('browserslist', {
126
+ basedir: path.dirname(require.resolve('@enact/dev-utils/package.json')),
127
+ preserveSymlinks: false
128
+ })
129
+ );
127
130
  app.setEnactTargetsAsDefault();
128
131
  console.log(chalk.yellow.bold('==Project Info=='));
129
132
  console.log(`Name: ${app.name}`);
@@ -167,9 +170,12 @@ function cli(args) {
167
170
  });
168
171
  if (opts.help) displayHelp();
169
172
 
170
- api({cliInfo: opts.cli, dev: opts.dev}).catch(err => {
171
- console.error(chalk.red('ERROR: ') + 'Failed to display info.\n' + err.message);
172
- process.exit(1);
173
+ import('chalk').then(({default: _chalk}) => {
174
+ chalk = _chalk;
175
+ api({cliInfo: opts.cli, dev: opts.dev}).catch(err => {
176
+ console.error(chalk.red('ERROR: ') + 'Failed to display info.\n' + err.message);
177
+ process.exit(1);
178
+ });
173
179
  });
174
180
  }
175
181
 
@@ -1,9 +1,10 @@
1
1
  /* eslint-env node, es6 */
2
2
  const path = require('path');
3
- const chalk = require('chalk');
4
3
  const checker = require('license-checker');
5
4
  const minimist = require('minimist');
6
5
 
6
+ let chalk;
7
+
7
8
  // The following modules reside in `@enact/cli` but end up in production builds of apps
8
9
  const pkgPathResolve = m => path.dirname(require.resolve(m + '/package.json'));
9
10
  const enactCLIProdModules = ['@babel/core', 'core-js'].map(pkgPathResolve);
@@ -53,12 +54,15 @@ function cli(args) {
53
54
  });
54
55
  if (opts.help) displayHelp();
55
56
 
56
- api({modules: opts._})
57
- .then(licenses => console.log(JSON.stringify(licenses, null, 2)))
58
- .catch(err => {
59
- console.error(chalk.red('ERROR: ') + err.message);
60
- process.exit(1);
61
- });
57
+ import('chalk').then(({default: _chalk}) => {
58
+ chalk = _chalk;
59
+ api({modules: opts._})
60
+ .then(licenses => console.log(JSON.stringify(licenses, null, 2)))
61
+ .catch(err => {
62
+ console.error(chalk.red('ERROR: ') + err.message);
63
+ process.exit(1);
64
+ });
65
+ });
62
66
  }
63
67
 
64
68
  module.exports = {api, cli};
package/commands/link.js CHANGED
@@ -1,11 +1,12 @@
1
1
  // @remove-file-on-eject
2
2
  const path = require('path');
3
- const chalk = require('chalk');
4
3
  const spawn = require('cross-spawn');
5
4
  const fs = require('fs-extra');
6
5
  const minimist = require('minimist');
7
6
  const packageRoot = require('@enact/dev-utils').packageRoot;
8
7
 
8
+ let chalk;
9
+
9
10
  function displayHelp() {
10
11
  let e = 'node ' + path.relative(process.cwd(), __filename);
11
12
  if (require.main !== module) e = 'enact link';
@@ -94,9 +95,12 @@ function cli(args) {
94
95
 
95
96
  if (opts._[0]) opts.cwd = opts._[0];
96
97
 
97
- api(opts).catch(err => {
98
- console.error(chalk.red('ERROR: ') + err.message);
99
- process.exit(1);
98
+ import('chalk').then(({default: _chalk}) => {
99
+ chalk = _chalk;
100
+ api(opts).catch(err => {
101
+ console.error(chalk.red('ERROR: ') + err.message);
102
+ process.exit(1);
103
+ });
100
104
  });
101
105
  }
102
106
 
package/commands/pack.js CHANGED
@@ -12,16 +12,17 @@
12
12
  */
13
13
  // @remove-on-eject-end
14
14
  const path = require('path');
15
- const chalk = require('chalk');
16
15
  const {filesize} = require('filesize');
17
16
  const fs = require('fs-extra');
18
17
  const minimist = require('minimist');
19
18
  const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
20
19
  const printBuildError = require('react-dev-utils/printBuildError');
21
- const stripAnsi = require('strip-ansi');
22
20
  const webpack = require('webpack');
23
21
  const {optionParser: app, mixins, configHelper: helper} = require('@enact/dev-utils');
24
22
 
23
+ let chalk;
24
+ let stripAnsi;
25
+
25
26
  function displayHelp() {
26
27
  let e = 'node ' + path.relative(process.cwd(), __filename);
27
28
  if (require.main !== module) e = 'enact pack';
@@ -315,9 +316,15 @@ function cli(args) {
315
316
  if (opts.help) displayHelp();
316
317
 
317
318
  process.chdir(app.context);
318
- api(opts).catch(err => {
319
- printErrorDetails(err, () => {
320
- process.exit(1);
319
+ import('chalk').then(({default: _chalk}) => {
320
+ chalk = _chalk;
321
+ import('strip-ansi').then(({default: _stripAnsi}) => {
322
+ stripAnsi = _stripAnsi;
323
+ api(opts).catch(err => {
324
+ printErrorDetails(err, () => {
325
+ process.exit(1);
326
+ });
327
+ });
321
328
  });
322
329
  });
323
330
  }
package/commands/serve.js CHANGED
@@ -13,7 +13,6 @@
13
13
  // @remove-on-eject-end
14
14
  const fs = require('fs');
15
15
  const path = require('path');
16
- const chalk = require('chalk');
17
16
  const minimist = require('minimist');
18
17
  const clearConsole = require('react-dev-utils/clearConsole');
19
18
  const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
@@ -27,6 +26,8 @@ const webpack = require('webpack');
27
26
  const WebpackDevServer = require('webpack-dev-server');
28
27
  const {optionParser: app} = require('@enact/dev-utils');
29
28
 
29
+ let chalk;
30
+
30
31
  // Any unhandled promise rejections should be treated like errors.
31
32
  process.on('unhandledRejection', err => {
32
33
  throw err;
@@ -355,10 +356,13 @@ function cli(args) {
355
356
 
356
357
  process.chdir(app.context);
357
358
 
358
- api(opts).catch(err => {
359
- //console.error(chalk.red('ERROR: ') + (err.message || err));
360
- console.log(err);
361
- process.exit(1);
359
+ import('chalk').then(({default: _chalk}) => {
360
+ chalk = _chalk;
361
+ api(opts).catch(err => {
362
+ //console.error(chalk.red('ERROR: ') + (err.message || err));
363
+ console.log(err);
364
+ process.exit(1);
365
+ });
362
366
  });
363
367
  }
364
368
 
@@ -2,13 +2,14 @@
2
2
  const os = require('os');
3
3
  const path = require('path');
4
4
  const url = require('url');
5
- const chalk = require('chalk');
6
5
  const spawn = require('cross-spawn');
7
6
  const fs = require('fs-extra');
8
7
  const minimist = require('minimist');
9
8
  const prompts = require('prompts');
10
9
  const tar = require('tar');
11
10
 
11
+ let chalk;
12
+
12
13
  const TEMPLATE_DIR = path.join(process.env.APPDATA || os.homedir(), '.enact');
13
14
  const INCLUDED = path.dirname(require.resolve('@enact/template-sandstone'));
14
15
  const DEFAULT_LINK = path.join(TEMPLATE_DIR, 'default');
@@ -300,11 +301,14 @@ function cli(args) {
300
301
  const name = ['install', 'link'].includes(action) ? opts._[2] : opts._[1];
301
302
  if (!action) displayHelp();
302
303
 
303
- api({action, name, target}).catch(err => {
304
- console.error('Template action failed.');
305
- console.error();
306
- console.error(chalk.red('ERROR: ') + err.message);
307
- process.exit(1);
304
+ import('chalk').then(({default: _chalk}) => {
305
+ chalk = _chalk;
306
+ api({action, name, target}).catch(err => {
307
+ console.error('Template action failed.');
308
+ console.error();
309
+ console.error(chalk.red('ERROR: ') + err.message);
310
+ process.exit(1);
311
+ });
308
312
  });
309
313
  }
310
314
 
package/commands/test.js CHANGED
@@ -14,10 +14,11 @@
14
14
  const path = require('path');
15
15
  const {execSync} = require('child_process');
16
16
  const {packageRoot} = require('@enact/dev-utils');
17
- const chalk = require('chalk');
18
17
  const jest = require('jest');
19
18
  const resolve = require('resolve');
20
19
 
20
+ let chalk;
21
+
21
22
  // Makes the script crash on unhandled rejections instead of silently
22
23
  // ignoring them. In the future, promise rejections that are not handled will
23
24
  // terminate the Node.js process with a non-zero exit code.
@@ -171,8 +172,11 @@ function api(args = []) {
171
172
  }
172
173
 
173
174
  function cli(args) {
174
- api(args).catch(() => {
175
- process.exit(1);
175
+ import('chalk').then(({default: _chalk}) => {
176
+ chalk = _chalk;
177
+ api(args).catch(() => {
178
+ process.exit(1);
179
+ });
176
180
  });
177
181
  }
178
182
 
@@ -1,7 +1,6 @@
1
1
  // @remove-file-on-eject
2
2
  const path = require('path');
3
3
  const babel = require('@babel/core');
4
- const chalk = require('chalk');
5
4
  const fs = require('fs-extra');
6
5
  const less = require('less');
7
6
  const LessPluginResolve = require('less-plugin-npm-import');
@@ -9,6 +8,8 @@ const minimist = require('minimist');
9
8
  const LessPluginRi = require('resolution-independence');
10
9
  const {optionParser: app} = require('@enact/dev-utils');
11
10
 
11
+ let chalk;
12
+
12
13
  const blacklist = ['node_modules', 'build', 'dist', 'docs', '.git', '.gitignore', 'samples', 'tests'];
13
14
  const babelConfig = path.join(__dirname, '..', 'config', 'babel.config.js');
14
15
  const babelRename = {original: '^(\\.(?!.*\\bstyles\\b.*).*)\\.less$', replacement: '$1.css'};
@@ -103,8 +104,11 @@ function cli(args) {
103
104
  process.chdir(app.context);
104
105
  console.log('Transpiling via Babel to ' + path.resolve(opts.output));
105
106
 
106
- api({source: '.', output: opts.output, commonjs: opts.commonjs, ignore}).catch(err => {
107
- console.error(chalk.red('ERROR: ') + err.message);
107
+ import('chalk').then(({default: _chalk}) => {
108
+ chalk = _chalk;
109
+ api({source: '.', output: opts.output, commonjs: opts.commonjs, ignore}).catch(err => {
110
+ console.error(chalk.red('ERROR: ') + err.message);
111
+ });
108
112
  });
109
113
  }
110
114