@enact/cli 4.1.7 → 5.0.0-alpha.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/.eslintrc.js CHANGED
@@ -2,7 +2,7 @@ module.exports = {
2
2
  env: {
3
3
  node: true
4
4
  },
5
- extends: ['enact', 'plugin:prettier/recommended', 'prettier/babel', 'prettier/react'],
5
+ extends: ['enact', 'plugin:prettier/recommended', 'prettier'],
6
6
  plugins: ['import'],
7
7
  rules: {
8
8
  'import/no-unresolved': ['error', {commonjs: true, caseSensitive: true}],
package/CHANGELOG.md CHANGED
@@ -1,3 +1,39 @@
1
+ ## 5.0.0-alpha.3 (April 22, 2022)
2
+
3
+ ### lint
4
+
5
+ * Fixed `enact lint` is not working on node 16 by moving ESLint plugins to dependencies.
6
+
7
+ ### test
8
+
9
+ * Fixed `--watch` option is not working by fixing the version of `jest-watch-typeahead` to `0.6.5`.
10
+
11
+ ## 5.0.0-alpha.2 (April 15, 2022)
12
+
13
+ ### create, template
14
+
15
+ * Updated `@enact/template-sandstone` dependency.
16
+
17
+ ## 5.0.0-alpha.1 (April 11, 2022)
18
+
19
+ ### pack
20
+
21
+ * Updated all dependencies to the latest including Webpack 5, React 18, and ESLint 8.
22
+ * Replaced `optimize-css-assets-webpack-plugin` to `css-minimizer-webpack-plugin`.
23
+ * Fixed ICSS syntax in stylesheets.
24
+ * Added `source-map-loader` for debugging into original source of node_modules libraries that contain sourcemaps.
25
+ * Added `tailwindcss` support.
26
+ * Added `node-polyfill-webpack-plugin` to fix screenshot build fail.
27
+
28
+ ### serve
29
+
30
+ * Fixed to disable overlay for warnings.
31
+ * Fixed to allow CORS on `webpack-dev-server`.
32
+
33
+ ### test
34
+
35
+ * Updated to Jest 27.
36
+
1
37
  ## 4.1.7 (February 18, 2022)
2
38
 
3
39
  ### pack
package/README.md CHANGED
@@ -112,7 +112,7 @@ npm install -g eslint
112
112
  Then, you will need to uninstall any previous globally-installed Enact linting package (everything but eslint itself):
113
113
 
114
114
  ```sh
115
- npm remove -g eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-babel babel-eslint eslint-plugin-jest eslint-plugin-enact eslint-config-enact
115
+ npm remove -g eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-babel @babel/eslint-parser eslint-plugin-jest eslint-plugin-enact eslint-config-enact
116
116
  ```
117
117
 
118
118
  ## Copyright and License Information
package/bin/enact.js CHANGED
@@ -9,7 +9,13 @@ const semver = require('semver');
9
9
  const pkg = require('../package.json');
10
10
 
11
11
  // Verify the correct version of Node is in use.
12
- if (!semver.satisfies(process.version, pkg.engines.node)) {
12
+ if (
13
+ !semver.satisfies(
14
+ // Coerce strings with metadata (i.e. `15.0.0-nightly`).
15
+ semver.coerce(process.version),
16
+ pkg.engines.node
17
+ )
18
+ ) {
13
19
  console.log(
14
20
  chalk.red(`You are running Node ${process.version}, but @enact/cli requires Node ${pkg.engines.node}.\n`) +
15
21
  chalk.bold.red('Please update your version of Node.')
package/commands/eject.js CHANGED
@@ -267,7 +267,7 @@ function api({bare = false} = {}) {
267
267
  console.log('Ejecting...');
268
268
  console.log();
269
269
  console.log(chalk.cyan(`Copying files into ${process.cwd()}`));
270
- assets.forEach(dir => !fs.existsSync(dir.dest) && fs.mkdirSync(dir.dest));
270
+ assets.forEach(dir => !fs.existsSync(dir.dest) && fs.mkdirSync(dir.dest, {recursive: true}));
271
271
  files.forEach(copySanitizedFile);
272
272
  console.log();
273
273
  console.log(chalk.cyan('Configuring package.json'));
package/commands/lint.js CHANGED
@@ -55,7 +55,7 @@ function eslint({strict = false, local = false, fix = false, eslintArgs = []} =
55
55
  }
56
56
  return new Promise((resolve, reject) => {
57
57
  const opts = {env: process.env, cwd: process.cwd()};
58
- const child = cp.fork(require.resolve('eslint/bin/eslint'), args, opts);
58
+ const child = cp.fork(path.join(require.resolve('eslint'), '..', '..', 'bin', 'eslint'), args, opts);
59
59
  child.on('close', code => {
60
60
  if (code !== 0) {
61
61
  reject();
package/commands/pack.js CHANGED
@@ -19,7 +19,7 @@ const minimist = require('minimist');
19
19
  const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
20
20
  const printBuildError = require('react-dev-utils/printBuildError');
21
21
  const stripAnsi = require('strip-ansi');
22
- const webpack = require('webpack');
22
+ const {ProgressPlugin, webpack} = require('webpack');
23
23
  const {optionParser: app, mixins, configHelper: helper} = require('@enact/dev-utils');
24
24
 
25
25
  function displayHelp() {
@@ -53,13 +53,14 @@ function displayHelp() {
53
53
  console.log();
54
54
  /*
55
55
  Private Options:
56
- --entry Specify an override entrypoint
57
- --no-minify Will skip minification during production build
58
- --framework Builds the @enact/*, react, and react-dom into an external framework
59
- --externals Specify a local directory path to the standalone external framework
60
- --externals-public Remote public path to the external framework for use injecting into HTML
61
- --externals-polyfill Flag whether to use external polyfill (or include in framework build)
62
- --custom-skin To use a custom skin for build
56
+ --entry Specify an override entrypoint
57
+ --no-minify Will skip minification during production build
58
+ --framework Builds the @enact/*, react, and react-dom into an external framework
59
+ --externals Specify a local directory path to the standalone external framework
60
+ --externals-public Remote public path to the external framework for use injecting into HTML
61
+ --externals-polyfill Flag whether to use external polyfill (or include in framework build)
62
+ --custom-skin To use a custom skin for build
63
+ --ilib-additional-path Specify iLib additional resources path
63
64
  */
64
65
  process.exit(0);
65
66
  }
@@ -100,13 +101,17 @@ function details(err, stats, output) {
100
101
  process.env.CI.toLowerCase() !== 'false' &&
101
102
  messages.warnings.length
102
103
  ) {
103
- console.log(
104
- chalk.yellow(
105
- 'Treating warnings as errors because process.env.CI = true. ' +
106
- 'Most CI servers set it automatically.\n'
107
- )
108
- );
109
- return new Error(messages.warnings.join('\n\n'));
104
+ // Ignore sourcemap warnings in CI builds. See #8227 for more info.
105
+ const filteredWarnings = messages.warnings.filter(w => !/Failed to parse source map/.test(w));
106
+ if (filteredWarnings.length) {
107
+ console.log(
108
+ chalk.yellow(
109
+ '\nTreating warnings as errors because process.env.CI = true. \n' +
110
+ 'Most CI servers set it automatically.\n'
111
+ )
112
+ );
113
+ return new Error(filteredWarnings.join('\n\n'));
114
+ }
110
115
  } else {
111
116
  copyPublicFolder(output);
112
117
  if (messages.warnings.length) {
@@ -245,7 +250,7 @@ function api(opts = {}) {
245
250
 
246
251
  // Do this as the first thing so that any code reading it knows the right env.
247
252
  const configFactory = require('../config/webpack.config');
248
- const config = configFactory(opts.production ? 'production' : 'development');
253
+ const config = configFactory(opts.production ? 'production' : 'development', opts['ilib-additional-path']);
249
254
 
250
255
  // Set any entry path override
251
256
  if (opts.entry) helper.replaceMain(config, path.resolve(opts.entry));
@@ -253,6 +258,8 @@ function api(opts = {}) {
253
258
  // Set any output path override
254
259
  if (opts.output) config.output.path = path.resolve(opts.output);
255
260
 
261
+ if (opts.verbose) opts.ProgressPlugin = ProgressPlugin;
262
+
256
263
  mixins.apply(config, opts);
257
264
 
258
265
  // Remove all content but keep the directory so that
@@ -283,7 +290,7 @@ function cli(args) {
283
290
  'watch',
284
291
  'help'
285
292
  ],
286
- string: ['externals', 'externals-public', 'locales', 'entry', 'output', 'meta'],
293
+ string: ['externals', 'externals-public', 'locales', 'entry', 'ilib-additional-path', 'output', 'meta'],
287
294
  default: {minify: true},
288
295
  alias: {
289
296
  o: 'output',
package/commands/serve.js CHANGED
@@ -16,11 +16,11 @@ const path = require('path');
16
16
  const chalk = require('chalk');
17
17
  const minimist = require('minimist');
18
18
  const clearConsole = require('react-dev-utils/clearConsole');
19
- const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
20
19
  const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
21
20
  const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath');
22
21
  const openBrowser = require('react-dev-utils/openBrowser');
23
22
  const redirectServedPathMiddleware = require('react-dev-utils/redirectServedPathMiddleware');
23
+ const ignoredFiles = require('react-dev-utils/ignoredFiles');
24
24
  const {choosePort, createCompiler, prepareProxy, prepareUrls} = require('react-dev-utils/WebpackDevServerUtils');
25
25
  const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
26
26
  const webpack = require('webpack');
@@ -35,6 +35,7 @@ process.on('unhandledRejection', err => {
35
35
  // As react-dev-utils assumes the webpack production packaging command is
36
36
  // "npm run build" with no way to modify it yet, we provide a basic override
37
37
  // to console.log to ensure the correct output is displayed to the user.
38
+ // prettier-ignore
38
39
  console.log = (log => (data, ...rest) =>
39
40
  typeof data === 'undefined'
40
41
  ? log()
@@ -62,8 +63,6 @@ function displayHelp() {
62
63
  }
63
64
 
64
65
  function hotDevServer(config, fastRefresh) {
65
- // This is necessary to emit hot updates
66
- config.plugins.unshift(new webpack.HotModuleReplacementPlugin());
67
66
  // Keep webpack alive when there are any errors, so user can fix and rebuild.
68
67
  config.bail = false;
69
68
  // Ensure the CLI version of Chalk is used for webpackHotDevClient
@@ -85,9 +84,7 @@ function hotDevServer(config, fastRefresh) {
85
84
  // https://github.com/facebook/react/tree/master/packages/react-refresh
86
85
  config.plugins.unshift(
87
86
  new ReactRefreshWebpackPlugin({
88
- overlay: {
89
- entry: require.resolve('react-dev-utils/webpackHotDevClient')
90
- }
87
+ overlay: false
91
88
  })
92
89
  );
93
90
  // Append fast refresh babel plugin
@@ -105,6 +102,7 @@ function devServerConfig(host, protocol, publicPath, proxy, allowedHost) {
105
102
  key: fs.readFileSync(SSL_KEY_FILE)
106
103
  };
107
104
  }
105
+ const disableFirewall = !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true';
108
106
 
109
107
  return {
110
108
  // WebpackDevServer 2.4.3 introduced a security fix that prevents remote
@@ -123,38 +121,64 @@ function devServerConfig(host, protocol, publicPath, proxy, allowedHost) {
123
121
  // So we will disable the host check normally, but enable it if you have
124
122
  // specified the `proxy` setting. Finally, we let you override it if you
125
123
  // really know what you're doing with a special environment variable.
126
- disableHostCheck: !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true',
127
- // Silence WebpackDevServer's own logs since they're generally not useful.
128
- // It will still show compile warnings and errors with this setting.
129
- clientLogLevel: 'none',
130
- // Enable hot reloading server. It will provide /sockjs-node/ endpoint
131
- // for the WebpackDevServer client so it can learn when the files were
132
- // updated. The WebpackDevServer client is included as an entry point
133
- // in the Webpack development configuration. Note that only changes
134
- // to CSS are currently hot reloaded. JS changes will refresh the browser.
135
- hot: true,
136
- // Use 'ws' instead of 'sockjs-node' on server since we're using native
137
- // websockets in `webpackHotDevClient`.
138
- transportMode: 'ws',
139
- // Prevent a WS client from getting injected as we're already including
140
- // `webpackHotDevClient`.
141
- injectClient: false,
142
- // Enable custom sockjs pathname for websocket connection to hot reloading server.
143
- // Enable custom sockjs hostname, pathname and port for websocket connection
144
- // to hot reloading server.
145
- sockHost: process.env.WDS_SOCKET_HOST,
146
- sockPath: process.env.WDS_SOCKET_PATH,
147
- sockPort: process.env.WDS_SOCKET_PORT,
148
- // WebpackDevServer is noisy by default so we emit custom message instead
149
- // by listening to the compiler events with `compiler.plugin` calls above.
150
- quiet: true,
124
+ // Note: ["localhost", ".localhost"] will support subdomains - but we might
125
+ // want to allow setting the allowedHosts manually for more complex setups
126
+ allowedHosts: disableFirewall ? 'all' : [allowedHost],
151
127
  // Enable HTTPS if the HTTPS environment variable is set to 'true'
152
128
  https,
153
129
  host,
154
- overlay: false,
155
130
  // Allow cross-origin HTTP requests
156
131
  headers: {
157
- 'Access-Control-Allow-Origin': '*'
132
+ 'Access-Control-Allow-Origin': '*',
133
+ 'Access-Control-Allow-Methods': '*',
134
+ 'Access-Control-Allow-Headers': '*'
135
+ },
136
+ static: {
137
+ // By default WebpackDevServer serves physical files from current directory
138
+ // in addition to all the virtual build products that it serves from memory.
139
+ // This is confusing because those files won’t automatically be available in
140
+ // production build folder unless we copy them. However, copying the whole
141
+ // project directory is dangerous because we may expose sensitive files.
142
+ // Instead, we establish a convention that only files in `public` directory
143
+ // get served. Our build script will copy `public` into the `build` folder.
144
+ // In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
145
+ // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
146
+ // In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
147
+ // Note that we only recommend to use `public` folder as an escape hatch
148
+ // for files like `favicon.ico`, `manifest.json`, and libraries that are
149
+ // for some reason broken when imported through webpack. If you just want to
150
+ // use an image, put it in `src` and `import` it from JavaScript instead.
151
+ directory: path.resolve(app.context, 'public'),
152
+ publicPath: publicPath,
153
+ // By default files from `contentBase` will not trigger a page reload.
154
+ watch: {
155
+ // Reportedly, this avoids CPU overload on some systems.
156
+ // https://github.com/facebook/create-react-app/issues/293
157
+ // src/node_modules is not ignored to support absolute imports
158
+ // https://github.com/facebook/create-react-app/issues/1065
159
+ ignored: ignoredFiles(path.resolve(app.context, 'src'))
160
+ }
161
+ },
162
+ client: {
163
+ webSocketURL: {
164
+ // Enable custom sockjs pathname for websocket connection to hot reloading server.
165
+ // Enable custom sockjs hostname, pathname and port for websocket connection
166
+ // to hot reloading server.
167
+ hostname: process.env.WDS_SOCKET_HOST,
168
+ pathname: process.env.WDS_SOCKET_PATH,
169
+ port: process.env.WDS_SOCKET_PORT
170
+ },
171
+ overlay: {
172
+ errors: true,
173
+ warnings: false
174
+ }
175
+ },
176
+ devMiddleware: {
177
+ // It is important to tell WebpackDevServer to use the same "publicPath" path as
178
+ // we specified in the webpack config. When homepage is '.', default to serving
179
+ // from the root.
180
+ // remove last slash so user can land on `/test` instead of `/test/`
181
+ publicPath: publicPath.slice(0, -1)
158
182
  },
159
183
  historyApiFallback: {
160
184
  // ensure JSON file requests correctly 404 error when not found.
@@ -164,27 +188,24 @@ function devServerConfig(host, protocol, publicPath, proxy, allowedHost) {
164
188
  disableDotRule: true,
165
189
  index: publicPath
166
190
  },
167
- public: allowedHost,
168
191
  // `proxy` is run between `before` and `after` `webpack-dev-server` hooks
169
192
  proxy,
170
- before(build, server) {
171
- // Keep `evalSourceMapMiddleware` and `errorOverlayMiddleware`
193
+ onBeforeSetupMiddleware(devServer) {
194
+ // Keep `evalSourceMapMiddleware`
172
195
  // middlewares before `redirectServedPath` otherwise will not have any effect
173
196
  // This lets us fetch source contents from webpack for the error overlay
174
- build.use(evalSourceMapMiddleware(server));
175
- // This lets us open files from the runtime error overlay.
176
- build.use(errorOverlayMiddleware());
197
+ devServer.app.use(evalSourceMapMiddleware(devServer));
177
198
 
178
199
  // Optionally register app-side proxy middleware if it exists
179
200
  const proxySetup = path.join(process.cwd(), 'src', 'setupProxy.js');
180
201
  if (fs.existsSync(proxySetup)) {
181
- require(proxySetup)(build);
202
+ require(proxySetup)(devServer.app);
182
203
  }
183
204
  },
184
- after(build) {
205
+ onAfterSetupMiddleware(devServer) {
185
206
  // Redirect to `PUBLIC_URL` or `homepage`/`enact.publicUrl` from `package.json`
186
207
  // if url not match
187
- build.use(redirectServedPathMiddleware(publicPath));
208
+ devServer.app.use(redirectServedPathMiddleware(publicPath));
188
209
  }
189
210
  };
190
211
  }
@@ -200,21 +221,14 @@ function serve(config, host, port, open) {
200
221
  const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
201
222
  const publicPath = getPublicUrlOrPath(true, app.publicUrl, process.env.PUBLIC_URL);
202
223
  const urls = prepareUrls(protocol, host, resolvedPort, publicPath.slice(0, -1));
203
- const devSocket = {
204
- // eslint-disable-next-line no-use-before-define
205
- warnings: warnings => devServer.sockWrite(devServer.sockets, 'warnings', warnings),
206
- // eslint-disable-next-line no-use-before-define
207
- errors: errors => devServer.sockWrite(devServer.sockets, 'errors', errors)
208
- };
224
+
209
225
  // Create a webpack compiler that is configured with custom messages.
210
226
  const compiler = createCompiler({
211
227
  appName: app.name,
212
228
  config,
213
- devSocket,
214
229
  urls,
215
230
  useYarn: false,
216
231
  useTypeScript: fs.existsSync('tsconfig.json'),
217
- tscCompileOnError: process.env.TSC_COMPILE_ON_ERROR === 'true',
218
232
  webpack
219
233
  });
220
234
  // Hook into compiler to remove potentially confusing messages
@@ -238,9 +252,9 @@ function serve(config, host, port, open) {
238
252
  config.devServer,
239
253
  devServerConfig(host, protocol, publicPath, proxyConfig, urls.lanUrlForConfig)
240
254
  );
241
- const devServer = new WebpackDevServer(compiler, serverConfig);
255
+ const devServer = new WebpackDevServer(serverConfig, compiler);
242
256
  // Launch WebpackDevServer.
243
- devServer.listen(resolvedPort, host, err => {
257
+ devServer.startCallback(err => {
244
258
  if (err) return console.log(err);
245
259
  if (process.stdout.isTTY) clearConsole();
246
260
  console.log(chalk.cyan('Starting the development server...\n'));
@@ -86,6 +86,8 @@ module.exports = function (api) {
86
86
  // Stage 3
87
87
  require('@babel/plugin-syntax-dynamic-import').default,
88
88
  [require('@babel/plugin-proposal-class-properties').default, {loose: true}],
89
+ [require('@babel/plugin-proposal-private-methods').default, {loose: true}],
90
+ [require('@babel/plugin-proposal-private-property-in-object').default, {loose: true}],
89
91
  // '@babel/plugin-syntax-import-meta',
90
92
  // '@babel/plugin-proposal-json-strings'
91
93
 
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+ const {createHash} = require('crypto');
3
+
4
+ module.exports = env => {
5
+ const hash = createHash('md5');
6
+ hash.update(JSON.stringify(env));
7
+
8
+ return hash.digest('hex');
9
+ };
@@ -10,7 +10,7 @@
10
10
  */
11
11
 
12
12
  const path = require('path');
13
- const babelJest = require('babel-jest');
13
+ const babelJest = require('babel-jest').default;
14
14
 
15
15
  module.exports = babelJest.createTransformer({
16
16
  extends: path.join(__dirname, '..', 'babel.config.js'),
@@ -73,7 +73,6 @@ module.exports = {
73
73
  testPathIgnorePatterns: ignorePatterns,
74
74
  testEnvironment: 'jsdom',
75
75
  testEnvironmentOptions: {pretendToBeVisual: true},
76
- testRunner: require.resolve('jest-circus/runner'),
77
76
  testURL: 'http://localhost',
78
77
  transform: {
79
78
  '^.+\\.(js|jsx|ts|tsx)$': require.resolve('./babelTransform'),