@enact/cli 7.1.0 → 7.2.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.
@@ -1,4 +1,5 @@
1
1
  // @remove-file-on-eject
2
+ /* eslint no-console: off, no-undef: off */
2
3
  const os = require('os');
3
4
  const path = require('path');
4
5
  const url = require('url');
@@ -14,7 +15,7 @@ const TEMPLATE_DIR = path.join(process.env.APPDATA || os.homedir(), '.enact');
14
15
  const INCLUDED = path.dirname(require.resolve('@enact/template-sandstone'));
15
16
  const DEFAULT_LINK = path.join(TEMPLATE_DIR, 'default');
16
17
 
17
- function displayHelp() {
18
+ function displayHelp () {
18
19
  let e = 'node ' + path.relative(process.cwd(), __filename);
19
20
  if (require.main !== module) e = 'enact template';
20
21
 
@@ -56,7 +57,7 @@ function displayHelp() {
56
57
  process.exit(0);
57
58
  }
58
59
 
59
- function initTemplateArea() {
60
+ function initTemplateArea () {
60
61
  if (!fs.existsSync(TEMPLATE_DIR)) {
61
62
  fs.mkdirSync(TEMPLATE_DIR);
62
63
  } else {
@@ -76,7 +77,7 @@ function initTemplateArea() {
76
77
  return init.then(() => !fs.existsSync(DEFAULT_LINK) && doLink(sandstoneLink, 'default'));
77
78
  }
78
79
 
79
- function doInstall(target, name) {
80
+ function doInstall (target, name) {
80
81
  const github = target.match(/^([a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38})\/([-_.\w]+)((?:#|@)?[-_.\w]+)?$/);
81
82
  if (github) {
82
83
  // If target is GitHub shorthand, resolve to full HTTPS URI
@@ -114,12 +115,12 @@ function doInstall(target, name) {
114
115
  });
115
116
  }
116
117
 
117
- function normalizeName(name) {
118
+ function normalizeName (name) {
118
119
  return name.replace(/(?:^enact-template-|^template-)/g, '');
119
120
  }
120
121
 
121
122
  // Clone Git repository using specific branch if desired
122
- function installFromGit(target, name = normalizeName(path.basename(url.parse(target).pathname, '.git'))) {
123
+ function installFromGit (target, name = normalizeName(path.basename(url.parse(target).pathname, '.git'))) {
123
124
  const git = target.match(/^(?:(^.*)#([\w\d-_.]+)?|(^.*))$/);
124
125
  const args = ['clone', git[1] || git[3], name, '-c', 'advice.detachedHead=false'];
125
126
  if (git[2]) args.splice(2, 0, '-b', git[2]);
@@ -137,7 +138,7 @@ function installFromGit(target, name = normalizeName(path.basename(url.parse(tar
137
138
  }
138
139
 
139
140
  // Copy directory files
140
- function installFromLocal(target, name = normalizeName(path.basename(target))) {
141
+ function installFromLocal (target, name = normalizeName(path.basename(target))) {
141
142
  const output = path.join(TEMPLATE_DIR, name);
142
143
  fs.removeSync(output);
143
144
  fs.ensureDirSync(output);
@@ -150,7 +151,7 @@ function installFromLocal(target, name = normalizeName(path.basename(target))) {
150
151
  }
151
152
 
152
153
  // Download and extract NPM package
153
- function installFromNPM(target, name = normalizeName(path.basename(target).replace(/@.*$/g, ''))) {
154
+ function installFromNPM (target, name = normalizeName(path.basename(target).replace(/@.*$/g, ''))) {
154
155
  const tempDir = path.join(os.tmpdir(), 'enact');
155
156
  fs.removeSync(tempDir);
156
157
  fs.ensureDirSync(tempDir);
@@ -182,7 +183,7 @@ function installFromNPM(target, name = normalizeName(path.basename(target).repla
182
183
  });
183
184
  }
184
185
 
185
- function doLink(target, name = normalizeName(path.basename(path.resolve(target)))) {
186
+ function doLink (target, name = normalizeName(path.basename(path.resolve(target)))) {
186
187
  const directory = path.resolve(target);
187
188
  const prevCWD = process.cwd();
188
189
  process.chdir(TEMPLATE_DIR);
@@ -199,7 +200,7 @@ function doLink(target, name = normalizeName(path.basename(path.resolve(target))
199
200
  });
200
201
  }
201
202
 
202
- function doRemove(name) {
203
+ function doRemove (name) {
203
204
  const output = path.join(TEMPLATE_DIR, name);
204
205
  const isDefault = fs.existsSync(DEFAULT_LINK) && fs.realpathSync(output) === fs.realpathSync(DEFAULT_LINK);
205
206
  if (!fs.existsSync(output)) return Promise.reject(new Error(`Unable to remove. Template "${name}" not found.`));
@@ -212,7 +213,7 @@ function doRemove(name) {
212
213
  });
213
214
  }
214
215
 
215
- function doDefault(name) {
216
+ function doDefault (name) {
216
217
  const all = fs.readdirSync(TEMPLATE_DIR).filter(t => t !== 'default');
217
218
  let choice;
218
219
  if (name && all.includes(name)) {
@@ -232,7 +233,7 @@ function doDefault(name) {
232
233
  return choice.then(response => doLink(path.join(TEMPLATE_DIR, response.template), 'default'));
233
234
  }
234
235
 
235
- function doList() {
236
+ function doList () {
236
237
  const realDefault = fs.realpathSync(DEFAULT_LINK);
237
238
  const all = fs.readdirSync(TEMPLATE_DIR).filter(t => t !== 'default');
238
239
  console.log(chalk.bold('Available Templates'));
@@ -250,12 +251,13 @@ function doList() {
250
251
  });
251
252
  }
252
253
 
253
- function api({action, target, name} = {}) {
254
+ function api ({action, target, name} = {}) {
254
255
  return initTemplateArea().then(() => {
255
256
  let actionPromise;
256
257
 
257
- if (['install', 'link', 'remove'].includes(action) && name === 'default')
258
+ if (['install', 'link', 'remove'].includes(action) && name === 'default') {
258
259
  throw new Error('Template "default" name is reserved. ' + 'Use "enact template default" to modify it.');
260
+ }
259
261
 
260
262
  switch (action) {
261
263
  case 'install':
@@ -289,7 +291,7 @@ function api({action, target, name} = {}) {
289
291
  });
290
292
  }
291
293
 
292
- function cli(args) {
294
+ function cli (args) {
293
295
  import('chalk').then(({default: _chalk}) => {
294
296
  chalk = _chalk;
295
297
  const opts = minimist(args, {
package/commands/test.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint no-console: off, no-undef: off */
1
2
  /* eslint-env node, es6 */
2
3
  // @remove-on-eject-begin
3
4
  /**
@@ -26,7 +27,7 @@ process.on('unhandledRejection', err => {
26
27
  throw err;
27
28
  });
28
29
 
29
- function isInGitRepository() {
30
+ function isInGitRepository () {
30
31
  try {
31
32
  execSync('git rev-parse --is-inside-work-tree', {stdio: 'ignore'});
32
33
  return true;
@@ -35,7 +36,7 @@ function isInGitRepository() {
35
36
  }
36
37
  }
37
38
 
38
- function isInMercurialRepository() {
39
+ function isInMercurialRepository () {
39
40
  try {
40
41
  execSync('hg --cwd . root', {stdio: 'ignore'});
41
42
  return true;
@@ -46,14 +47,14 @@ function isInMercurialRepository() {
46
47
 
47
48
  // This is a very dirty workaround for https://github.com/facebook/jest/issues/5913.
48
49
  // We're trying to resolve the environment ourselves because Jest does it incorrectly.
49
- function resolveJestDefaultEnvironment(name) {
50
+ function resolveJestDefaultEnvironment (name) {
50
51
  const jestDir = path.dirname(resolve.sync('jest', {basedir: __dirname}));
51
52
  const jestCLIDir = path.dirname(resolve.sync('jest-cli', {basedir: jestDir}));
52
53
  const jestConfigDir = path.dirname(resolve.sync('jest-config', {basedir: jestCLIDir}));
53
54
  return resolve.sync(name, {basedir: jestConfigDir});
54
55
  }
55
56
 
56
- function testEnvironment(args) {
57
+ function testEnvironment (args) {
57
58
  const env = (
58
59
  args.reverse().find((curr, i, a) => curr.startsWith('--env=') || a[i + 1] === '--env') || 'jsdom'
59
60
  ).replace(/^--env=/, '');
@@ -74,7 +75,7 @@ function testEnvironment(args) {
74
75
  return resolvedEnv || env;
75
76
  }
76
77
 
77
- function assignOverrides(config) {
78
+ function assignOverrides (config) {
78
79
  const {meta} = packageRoot();
79
80
  const overrides = Object.assign({}, meta.jest);
80
81
  const supportedKeys = [
@@ -149,7 +150,7 @@ function assignOverrides(config) {
149
150
  }
150
151
  }
151
152
 
152
- function api(args = []) {
153
+ function api (args = []) {
153
154
  const config = require('../config/jest/jest.config');
154
155
 
155
156
  // @TODO: readd dotenv parse support
@@ -171,7 +172,7 @@ function api(args = []) {
171
172
  return jest.run(args);
172
173
  }
173
174
 
174
- function cli(args) {
175
+ function cli (args) {
175
176
  import('chalk').then(({default: _chalk}) => {
176
177
  chalk = _chalk;
177
178
  api(args).catch(() => {
@@ -1,4 +1,5 @@
1
1
  // @remove-file-on-eject
2
+ /* eslint no-console: off, no-undef: off */
2
3
  const path = require('path');
3
4
  const babel = require('@babel/core');
4
5
  const fs = require('fs-extra');
@@ -15,7 +16,7 @@ const babelConfig = path.join(__dirname, '..', 'config', 'babel.config.js');
15
16
  const babelRename = {original: '^(\\.(?!.*\\bstyles\\b.*).*)\\.less$', replacement: '$1.css'};
16
17
  const lessPlugins = [new LessPluginResolve({prefix: '~'}), new LessPluginRi(app.ri)];
17
18
 
18
- function displayHelp() {
19
+ function displayHelp () {
19
20
  let e = 'node ' + path.relative(process.cwd(), __filename);
20
21
  if (require.main !== module) e = 'enact transpile';
21
22
 
@@ -33,7 +34,7 @@ function displayHelp() {
33
34
  process.exit(0);
34
35
  }
35
36
 
36
- function transpile(src, dest, plugins) {
37
+ function transpile (src, dest, plugins) {
37
38
  return new Promise((resolve, reject) => {
38
39
  babel.transformFile(src, {extends: babelConfig, plugins}, (err, result) => {
39
40
  if (err) {
@@ -45,7 +46,7 @@ function transpile(src, dest, plugins) {
45
46
  }).then(result => fs.writeFile(dest, result.code, {encoding: 'utf8'}));
46
47
  }
47
48
 
48
- function lessc(src, dest) {
49
+ function lessc (src, dest) {
49
50
  return less
50
51
  .render(fs.readFileSync(src, {encoding: 'utf8'}), {
51
52
  rewriteUrls: 'local',
@@ -56,7 +57,7 @@ function lessc(src, dest) {
56
57
  .then(result => fs.writeFileSync(dest.replace(/\.less$/, '.css'), result.css, {encoding: 'utf8'}));
57
58
  }
58
59
 
59
- function api({source = '.', output = './build', commonjs = true, ignore} = {}) {
60
+ function api ({source = '.', output = './build', commonjs = true, ignore} = {}) {
60
61
  process.env.ES5 = 'true';
61
62
  const babelPlugins = [
62
63
  commonjs && require.resolve('@babel/plugin-transform-modules-commonjs'),
@@ -91,7 +92,7 @@ function api({source = '.', output = './build', commonjs = true, ignore} = {}) {
91
92
  });
92
93
  }
93
94
 
94
- function cli(args) {
95
+ function cli (args) {
95
96
  const opts = minimist(args, {
96
97
  string: ['output', 'ignore'],
97
98
  boolean: ['commonjs', 'help'],
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-undef */
1
2
  /**
2
3
  * Portions of this source code file are from create-react-app, used under the
3
4
  * following MIT license:
@@ -16,12 +16,12 @@
16
16
  // http://facebook.github.io/jest/docs/en/webpack.html
17
17
 
18
18
  module.exports = {
19
- process() {
19
+ process () {
20
20
  return {
21
21
  code: 'module.exports = {};'
22
22
  };
23
23
  },
24
- getCacheKey() {
24
+ getCacheKey () {
25
25
  // The output is always the same.
26
26
  return 'cssTransform';
27
27
  }
@@ -18,7 +18,7 @@ const path = require('path');
18
18
  // http://facebook.github.io/jest/docs/en/webpack.html
19
19
 
20
20
  module.exports = {
21
- process(src, filename) {
21
+ process (src, filename) {
22
22
  const assetFilename = JSON.stringify(path.basename(filename));
23
23
  return {
24
24
  code: `module.exports = ${assetFilename};`
@@ -1,3 +1,4 @@
1
+ /* eslint no-console: off, no-undef: off */
1
2
  /* eslint-env jest */
2
3
  const fs = require('fs');
3
4
  const path = require('path');
@@ -56,7 +57,7 @@ const ilibPaths = Object.keys(global).filter(k => /ILIB_[^_]+_PATH/.test(k));
56
57
  const pkg = packageRoot();
57
58
  const XHR = global.XMLHttpRequest;
58
59
  class ILibXHR extends XHR {
59
- open(method, url) {
60
+ open (method, url) {
60
61
  if (ilibPaths.some(p => url.startsWith(global[p]))) {
61
62
  this.send = () => {
62
63
  try {
@@ -75,13 +76,13 @@ class ILibXHR extends XHR {
75
76
  return super.open(...arguments);
76
77
  }
77
78
  }
78
- get readyState() {
79
+ get readyState () {
79
80
  return typeof this.fileStatus !== 'undefined' ? XHR.DONE : super.readyState;
80
81
  }
81
- get status() {
82
+ get status () {
82
83
  return typeof this.fileStatus !== 'undefined' ? this.fileStatus : super.status;
83
84
  }
84
- get responseText() {
85
+ get responseText () {
85
86
  return typeof this.fileText !== 'undefined' ? this.fileText : super.responseText;
86
87
  }
87
88
  }
@@ -1,4 +1,4 @@
1
- /* eslint no-var: off, no-extend-native: off */
1
+ /* eslint no-var: off, no-extend-native: off, vars-on-top: off */
2
2
  /*
3
3
  * polyfills.js
4
4
  *
@@ -1,3 +1,4 @@
1
+ /* eslint no-console: off, no-undef: off */
1
2
  /* eslint-env node, es6 */
2
3
  // @remove-on-eject-begin
3
4
  /**
@@ -17,9 +18,9 @@ const path = require('path');
17
18
  const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
18
19
  const ESLintPlugin = require('eslint-webpack-plugin');
19
20
  const ForkTsCheckerWebpackPlugin =
20
- process.env.TSC_COMPILE_ON_ERROR === 'true'
21
- ? require('react-dev-utils/ForkTsCheckerWarningWebpackPlugin')
22
- : require('react-dev-utils/ForkTsCheckerWebpackPlugin');
21
+ process.env.TSC_COMPILE_ON_ERROR === 'true' ?
22
+ require('react-dev-utils/ForkTsCheckerWarningWebpackPlugin') :
23
+ require('react-dev-utils/ForkTsCheckerWebpackPlugin');
23
24
  const HtmlWebpackPlugin = require('html-webpack-plugin');
24
25
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
25
26
  const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
@@ -41,12 +42,13 @@ const createEnvironmentHash = require('./createEnvironmentHash');
41
42
  // This is the production and development configuration.
42
43
  // It is focused on developer experience, fast rebuilds, and a minimal bundle.
43
44
  module.exports = function (
44
- env,
45
- contentHash = false,
46
- isomorphic = false,
47
- noAnimation = false,
48
- noSplitCSS = false,
49
- ilibAdditionalResourcesPath
45
+ env,
46
+ noLinting = false,
47
+ contentHash = false,
48
+ isomorphic = false,
49
+ noAnimation = false,
50
+ noSplitCSS = false,
51
+ ilibAdditionalResourcesPath
50
52
  ) {
51
53
  process.chdir(app.context);
52
54
 
@@ -150,7 +152,7 @@ module.exports = function (
150
152
  // Support importing JSON files with ~ alias - custom plugin (must run first)
151
153
  {
152
154
  postcssPlugin: 'postcss-import-json-tilde',
153
- Once(root) {
155
+ Once (root) {
154
156
  // Process all @import-json rules with ~ prefix first, before other plugins
155
157
  root.walkAtRules('import-json', atRule => {
156
158
  let src = atRule.params.slice(1, -1); // Remove quotes
@@ -278,8 +280,8 @@ module.exports = function (
278
280
  mode: isEnvProduction ? 'production' : 'development',
279
281
  // Don't attempt to continue if there are any errors.
280
282
  bail: true,
281
- // Webpack noise constrained to errors and warnings
282
- stats: 'errors-warnings',
283
+ // Webpack noise constrained to errors only
284
+ stats: 'errors-only',
283
285
  // Use source maps during development builds or when specified by GENERATE_SOURCEMAP
284
286
  devtool: shouldUseSourceMap && (isEnvProduction ? 'source-map' : 'cheap-module-source-map'),
285
287
  // These are the "entry points" to our application.
@@ -306,9 +308,9 @@ module.exports = function (
306
308
  publicPath,
307
309
  // Improved sourcemap path name mapping for system filepaths
308
310
  devtoolModuleFilenameTemplate: info => {
309
- let file = isEnvProduction
310
- ? path.relative(app.context, info.absoluteResourcePath)
311
- : path.resolve(info.absoluteResourcePath);
311
+ let file = isEnvProduction ?
312
+ path.relative(app.context, info.absoluteResourcePath) :
313
+ path.resolve(info.absoluteResourcePath);
312
314
  file = file.replace(/\\/g, '/').replace(/\.\./g, '_');
313
315
  const loader = info.allLoaders.match(/[^\\/]+-loader/);
314
316
  if (info.resource.includes('.less') && loader) {
@@ -329,6 +331,7 @@ module.exports = function (
329
331
  store: 'pack',
330
332
  buildDependencies: {
331
333
  defaultWebpack: ['webpack/lib/'],
334
+ // eslint-disable-next-line no-undef
332
335
  config: [__filename],
333
336
  tsconfig: useTypeScript ? ['tsconfig.json'] : []
334
337
  }
@@ -358,9 +361,9 @@ module.exports = function (
358
361
  symlinks: false,
359
362
  // Backward compatibility for apps using new ilib references with old Enact
360
363
  // and old apps referencing old iLib location with new Enact
361
- alias: fs.existsSync(path.join(app.context, 'node_modules', '@enact', 'i18n', 'ilib'))
362
- ? Object.assign({ilib: '@enact/i18n/ilib'}, app.alias)
363
- : Object.assign({'@enact/i18n/ilib': 'ilib'}, app.alias),
364
+ alias: fs.existsSync(path.join(app.context, 'node_modules', '@enact', 'i18n', 'ilib')) ?
365
+ Object.assign({ilib: '@enact/i18n/ilib'}, app.alias) :
366
+ Object.assign({'@enact/i18n/ilib': 'ilib'}, app.alias),
364
367
  // Optional configuration for redirecting module requests.
365
368
  fallback: app.resolveFallback
366
369
  },
@@ -532,6 +535,7 @@ module.exports = function (
532
535
  comments: false,
533
536
  // Turned on because emoji and regex is not minified properly using default
534
537
  // https://github.com/facebook/create-react-app/issues/2488
538
+ // eslint-disable-next-line camelcase
535
539
  ascii_only: true
536
540
  }
537
541
  },
@@ -659,17 +663,18 @@ module.exports = function (
659
663
  infrastructure: 'silent'
660
664
  }
661
665
  }),
662
- new ESLintPlugin({
663
- // Plugin options
664
- configType: 'flat',
665
- extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
666
- formatter: require.resolve('react-dev-utils/eslintFormatter'),
667
- eslintPath: require.resolve('eslint'),
668
- // @remove-on-eject-begin
669
- overrideConfigFile: require.resolve('./eslintWebpackPluginConfig'),
670
- // @remove-on-eject-end
671
- cache: true
672
- })
666
+ !noLinting &&
667
+ new ESLintPlugin({
668
+ // Plugin options
669
+ configType: 'flat',
670
+ extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
671
+ formatter: require.resolve('react-dev-utils/eslintFormatter'),
672
+ eslintPath: require.resolve('eslint'),
673
+ // @remove-on-eject-begin
674
+ overrideConfigFile: require.resolve('./eslintWebpackPluginConfig'),
675
+ // @remove-on-eject-end
676
+ cache: true
677
+ })
673
678
  ].filter(Boolean)
674
679
  };
675
680
  };
@@ -26,6 +26,7 @@ order: 4
26
26
  (requires V8_MKSNAPSHOT set)
27
27
  -m, --meta JSON to override package.json enact metadata
28
28
  -c, --custom-skin Build with a custom skin
29
+ --no-linting Build without code linting
29
30
  --no-animation Build without effects such as animation and shadow
30
31
  --stats Output bundle analysis file
31
32
  --verbose Verbose log build details
@@ -10,7 +10,12 @@ order: 6
10
10
  Options
11
11
  -b, --browser Automatically open browser
12
12
  -i, --host Server host IP address
13
+ -f, --fast Enables experimental frast refresh
13
14
  -p, --port Server port number
15
+ -m, --meta JSON to override package.json enact metadata
16
+ --no-linting Build without code linting
17
+ -v, --version Display version information
18
+ -h, --help Display help information
14
19
  ```
15
20
  The `enact serve` command (aliased as `npm run serve`) will build and host your project on **http://localhost:8080/**. The options allow you to customize the host IP and host port, which can also be overriden via `HOST` and `PORT` environment variable. While the `enact serve` is active, any changes to source code will trigger a rebuild and update any loaded browser windows.
16
21