sku 12.3.3 → 12.4.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +7 -3
  3. package/bin/sku.js +1 -1
  4. package/config/eslint/importOrderConfig.js +1 -1
  5. package/config/jest/cssModulesTransform.js +1 -1
  6. package/config/lintStaged/lintStagedConfig.js +5 -2
  7. package/config/storybook/index.js +75 -0
  8. package/config/storybook/storybookWebpackConfig.js +10 -10
  9. package/config/webpack/plugins/metrics-plugin/index.js +1 -1
  10. package/config/webpack/plugins/sku-webpack-plugin/index.js +3 -5
  11. package/config/webpack/resolveModules.js +1 -1
  12. package/config/webpack/utils/resolvePackage.js +2 -2
  13. package/config/webpack/utils/resolvePackage.test.js +3 -1
  14. package/config/webpack/webpack.config.js +9 -26
  15. package/config/webpack/webpack.config.ssr.js +8 -25
  16. package/context/defaultCompilePackages.js +3 -5
  17. package/context/defaultSkuConfig.js +1 -1
  18. package/context/index.js +9 -4
  19. package/entry/csp.js +2 -2
  20. package/entry/server/index.js +3 -3
  21. package/entry/server/server.js +1 -1
  22. package/lib/buildFileUtils.js +2 -2
  23. package/lib/certificate.js +8 -2
  24. package/lib/configure.js +11 -5
  25. package/lib/copyDirContents.js +2 -2
  26. package/lib/createServer.js +2 -2
  27. package/lib/cwd.js +1 -1
  28. package/lib/env.js +31 -0
  29. package/lib/exists.js +1 -1
  30. package/lib/gracefulSpawn.js +1 -1
  31. package/lib/hosts.js +2 -2
  32. package/lib/install.js +8 -23
  33. package/lib/managedConfigBanner.js +1 -0
  34. package/lib/openBrowser/index.js +1 -1
  35. package/lib/packageManager.js +152 -0
  36. package/lib/parseArgs.js +4 -0
  37. package/lib/runBin.js +1 -1
  38. package/lib/runESLint.js +5 -1
  39. package/lib/runPrettier.js +3 -3
  40. package/lib/serverManager.js +1 -1
  41. package/lib/storybook.js +23 -58
  42. package/lib/suggestScript.js +17 -22
  43. package/lib/toPosixPath.js +1 -1
  44. package/lib/validateLessFiles.js +2 -2
  45. package/lib/validatePeerDeps.js +6 -7
  46. package/package.json +10 -11
  47. package/scripts/build-ssr.js +1 -1
  48. package/scripts/build-storybook.js +4 -7
  49. package/scripts/build.js +1 -1
  50. package/scripts/init.js +43 -36
  51. package/scripts/postinstall.js +1 -1
  52. package/scripts/serve.js +2 -3
  53. package/scripts/start-ssr.js +15 -2
  54. package/scripts/storybook.js +4 -7
  55. package/scripts/test.js +1 -1
  56. package/sku-types.d.ts +8 -8
  57. package/telemetry/index.js +1 -1
  58. package/telemetry/provider.js +7 -1
  59. package/tsconfig.json +4 -0
  60. package/config/storybook/build/main.js +0 -1
  61. package/config/storybook/build/webpack.config.js +0 -4
  62. package/config/storybook/config.js +0 -45
  63. package/config/storybook/start/main.js +0 -1
  64. package/config/storybook/start/middleware.js +0 -10
  65. package/config/storybook/start/webpack.config.js +0 -4
  66. package/lib/detectYarn.js +0 -10
  67. package/lib/isYarn.js +0 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,74 @@
1
1
  # sku
2
2
 
3
+ ## 12.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Update eslint-config-seek to version 12, which includes the major bump to ESLint 7 and typescript-eslint 6. ([#892](https://github.com/seek-oss/sku/pull/892))
8
+ You can view the specific changes over in [eslint-config-seek].
9
+
10
+ The majority of changes should automatically fix when running `sku format`.
11
+
12
+ [eslint-config-seek]: https://github.com/seek-oss/eslint-config-seek/blob/master/CHANGELOG.md#1200
13
+
14
+ ## 12.4.0
15
+
16
+ ### Minor Changes
17
+
18
+ - Enable caching for ESLint and Prettier ([#881](https://github.com/seek-oss/sku/pull/881))
19
+
20
+ - Add `--packageManager` flag ([#884](https://github.com/seek-oss/sku/pull/884))
21
+
22
+ Sku detects package managers in the following order: `yarn` -> `pnpm` -> `npm`.
23
+ The `--packageManager` flag can be used to override the package manager used for the `sku init` script.
24
+ This affects what package manager is used to install dependencies, as well as the scripts present in the initialized app template.
25
+
26
+ ```sh
27
+ $ pnpm dlx sku init --packageManager pnpm my-app
28
+ ```
29
+
30
+ - Adds support for Storybook configuration via the `.storybook` directory ([#878](https://github.com/seek-oss/sku/pull/878))
31
+
32
+ sku now supports the standard `.storybook` configuration directory, as documented in [Storybook's configuration documentation].
33
+ Please read [sku's storybook documentation][sku storybook docs] for more info.
34
+
35
+ [Storybook's configuration documentation]: https://storybook.js.org/docs/react/configure/overview
36
+ [sku storybook docs]: https://seek-oss.github.io/sku/#/./docs/storybook
37
+
38
+ - Drop support for running `devServerMiddleware` alongside `sku storybook` ([#878](https://github.com/seek-oss/sku/pull/878))
39
+
40
+ Now that sku supports Storybook configuration via the `.storybook` directory, this feature is unnecessary.
41
+ Storybook middleware can be configured by creating a `middleware.js` file in the `.storybook` directory.
42
+ See [the sku docs][sku storybook middleware] for more info.
43
+
44
+ **NOTE**: While this is technically a breaking change, it does not affect app builds, therefore it has been downgraded to a `minor` release.
45
+
46
+ [sku storybook middleware]: https://seek-oss.github.io/sku/#/./docs/storybook?id=devserver-middleware
47
+
48
+ - Update TypeScript to 5.2 ([#886](https://github.com/seek-oss/sku/pull/886))
49
+
50
+ This release includes breaking changes. See the [TypeScript 5.2 announcement][ts52] for more information.
51
+
52
+ [ts52]: https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/
53
+
54
+ ### Patch Changes
55
+
56
+ - Fixes a bug where sku would fail to suggest existing `package.json` scripts before suggesting its own commands ([#876](https://github.com/seek-oss/sku/pull/876))
57
+
58
+ - Remove `lodash` dependency ([#883](https://github.com/seek-oss/sku/pull/883))
59
+
60
+ - Propagate `--config` argument to Storybook process ([#879](https://github.com/seek-oss/sku/pull/879))
61
+
62
+ Fixes a bug where `sku storybook` and `sku build-storybook` would not honour a custom sku config specified via the `--config` flag
63
+
64
+ - Fixes a bug where `pnpm` was not detected correctly when detecting [compile packages](https://seek-oss.github.io/sku/#/./docs/extra-features?id=compile-packages) ([#876](https://github.com/seek-oss/sku/pull/876))
65
+
66
+ - Bump `@pmmmwh/react-refresh-webpack-plugin` and `webpack-dev-server` dependencies. Remove unused dependencies. ([#885](https://github.com/seek-oss/sku/pull/885))
67
+
68
+ - Adds support for `pnpm` when suggesting commands ([#876](https://github.com/seek-oss/sku/pull/876))
69
+
70
+ - Disable Storybook telemetry ([#878](https://github.com/seek-oss/sku/pull/878))
71
+
3
72
  ## 12.3.3
4
73
 
5
74
  ### Patch Changes
package/README.md CHANGED
@@ -23,13 +23,17 @@ Create a new project and start a local development environment:
23
23
  ```bash
24
24
  $ npx sku init my-app
25
25
  $ cd my-app
26
- $ npm start
26
+ $ yarn start
27
27
  ```
28
28
 
29
- Don't have [npx](https://www.npmjs.com/package/npx)?
29
+ By default, a new project's dependencies will be installed with the first supported package manager detected on your system.
30
+ Package managers are detected in the following order: `yarn` -> `pnpm` -> `npm`.
31
+ This can be overridden via the `--packageManager` flag:
30
32
 
31
33
  ```bash
32
- $ npm install -g npx
34
+ $ pnpm dlx sku init --packageManager pnpm my-app
35
+ $ cd my-app
36
+ $ pnpm start
33
37
  ```
34
38
 
35
39
  ## [Documentation](https://seek-oss.github.io/sku)
package/bin/sku.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const fs = require('fs');
2
+ const fs = require('node:fs');
3
3
  const debug = require('debug');
4
4
  const args = require('../config/args');
5
5
  const _validatePeerDeps = require('../lib/validatePeerDeps');
@@ -1,4 +1,4 @@
1
- const path = require('path');
1
+ const path = require('node:path');
2
2
  const { paths, rootResolution } = require('../../context');
3
3
 
4
4
  const internalRegex = `^(${paths.src
@@ -1,4 +1,4 @@
1
- const path = require('path');
1
+ const path = require('node:path');
2
2
  const getClassNames = require('./getClassNames');
3
3
 
4
4
  module.exports = {
@@ -1,11 +1,14 @@
1
- const isYarn = require('../../lib/isYarn');
1
+ const { isYarn } = require('../../lib/packageManager');
2
2
  const { lintExtensions } = require('../../lib/lint');
3
+ const { getCommand } = require('@antfu/ni');
3
4
 
4
5
  const steps = {};
5
6
 
6
7
  // Yarn lock integrity check
7
8
  if (isYarn) {
8
- steps['+(package.json|yarn.lock)'] = [() => 'yarn install --check-files'];
9
+ steps['+(package.json|yarn.lock)'] = [
10
+ () => getCommand('yarn', 'install', ['--check-files']),
11
+ ];
9
12
  }
10
13
 
11
14
  // Format & lint
@@ -0,0 +1,75 @@
1
+ /**
2
+ * This file and all its dependencies must be CJS
3
+ * https://github.com/storybookjs/storybook/pull/23018
4
+ */
5
+
6
+ const fs = require('node:fs');
7
+ const path = require('node:path');
8
+ const {
9
+ paths,
10
+ storybookAddons,
11
+ storybookStoryStore,
12
+ } = require('../../context');
13
+
14
+ const makeStorybookWebpackConfig = require('./storybookWebpackConfig');
15
+
16
+ /** @type {import("@storybook/react-webpack5").StorybookConfig} */
17
+ module.exports = {
18
+ stories: paths.src
19
+ .filter((srcPath) => fs.statSync(srcPath).isDirectory())
20
+ .map((srcPath) => path.join(srcPath, '**/*.stories.@(js|ts|tsx)')),
21
+ addons: storybookAddons,
22
+ framework: {
23
+ // Storybook looks for a `/preset` entrypoint on the framework package,
24
+ // so we give it the dirname of the resolved path to package.json
25
+ // https://github.com/storybookjs/storybook/blob/aecfa1791f982bef6a06b51d20df3e31dd82b5b4/code/lib/core-common/src/utils/validate-config.ts#L34
26
+ name: path.dirname(
27
+ require.resolve('@storybook/react-webpack5/package.json'),
28
+ ),
29
+ options: {},
30
+ },
31
+ core: {
32
+ builder: {
33
+ name: require.resolve('@storybook/builder-webpack5'),
34
+ options: {
35
+ fsCache: true,
36
+ },
37
+ },
38
+ disableTelemetry: true,
39
+ },
40
+ features: {
41
+ storyStoreV7: storybookStoryStore,
42
+ },
43
+ // sku storybook -> configType === 'DEVELOPMENT'
44
+ // sku build-storybook -> configType === 'PRODUCTION'
45
+ webpackFinal: (config, { configType }) =>
46
+ makeStorybookWebpackConfig(config, {
47
+ isDevServer: configType === 'DEVELOPMENT',
48
+ }),
49
+ babel: (config) => ({
50
+ ...config,
51
+ presets: [
52
+ // Includes `@babel/preset-react`
53
+ ...config.presets,
54
+
55
+ // Storybook as of 7.0 no longer handles babel stuff for you (other than react)
56
+ // We need to configure TypeScript support ourselves, if we want it
57
+ // https://github.com/storybookjs/storybook/issues/22357#issuecomment-1532548058
58
+ [
59
+ require.resolve('@babel/preset-env'),
60
+ {
61
+ targets: {
62
+ chrome: 100,
63
+ },
64
+ },
65
+ ],
66
+ [
67
+ require.resolve('@babel/preset-typescript'),
68
+ {
69
+ allExtensions: true,
70
+ isTSX: true,
71
+ },
72
+ ],
73
+ ],
74
+ }),
75
+ };
@@ -1,20 +1,20 @@
1
1
  const { paths } = require('../../context');
2
- const find = require('lodash/find');
3
2
  const { merge: webpackMerge } = require('webpack-merge');
4
3
  const makeWebpackConfig = require('../webpack/webpack.config');
5
4
  const { resolvePackage } = require('../webpack/utils/resolvePackage');
6
5
 
7
6
  const hot = process.env.SKU_HOT !== 'false';
8
7
 
9
- module.exports = ({ config }, { isDevServer }) => {
10
- const clientWebpackConfig = find(
11
- makeWebpackConfig({
12
- isIntegration: true,
13
- isDevServer,
14
- hot: isDevServer && hot,
15
- }),
16
- ({ name }) => name === 'client',
17
- );
8
+ /**
9
+ * @param {import("webpack").Configuration} config
10
+ * @param {{isDevServer: boolean}}
11
+ */
12
+ module.exports = (config, { isDevServer }) => {
13
+ const clientWebpackConfig = makeWebpackConfig({
14
+ isIntegration: true,
15
+ isDevServer,
16
+ hot: isDevServer && hot,
17
+ }).find(({ name }) => name === 'client');
18
18
 
19
19
  // Ensure Storybook's webpack loaders ignore our code :(
20
20
  if (config && config.module && Array.isArray(config.module.rules)) {
@@ -1,4 +1,4 @@
1
- const { performance } = require('perf_hooks');
1
+ const { performance } = require('node:perf_hooks');
2
2
  const prettyMilliseconds = require('pretty-ms');
3
3
  const debug = require('debug')('sku:metrics');
4
4
  const track = require('../../../../telemetry');
@@ -1,5 +1,4 @@
1
1
  const webpack = require('webpack');
2
- const uniq = require('lodash/uniq');
3
2
  const defaultSupportedBrowsers = require('browserslist-config-seek');
4
3
  const { VanillaExtractPlugin } = require('@vanilla-extract/webpack-plugin');
5
4
  const {
@@ -32,10 +31,9 @@ class SkuWebpackPlugin {
32
31
  rootResolution: false,
33
32
  ...options,
34
33
  };
35
- this.compilePackages = uniq([
36
- ...defaultCompilePackages,
37
- ...this.options.compilePackages,
38
- ]);
34
+ this.compilePackages = [
35
+ ...new Set([...defaultCompilePackages, ...this.options.compilePackages]),
36
+ ];
39
37
  this.include = [
40
38
  ...this.options.include,
41
39
  ...this.compilePackages.map(resolvePackage),
@@ -1,4 +1,4 @@
1
- const path = require('path');
1
+ const path = require('node:path');
2
2
 
3
3
  const modules = ['node_modules'];
4
4
 
@@ -1,4 +1,4 @@
1
- const path = require('path');
1
+ const path = require('node:path');
2
2
  const memoize = require('memoizee');
3
3
  const debug = require('debug')('sku:resolvePackage');
4
4
  const { cwd } = require('../../../lib/cwd');
@@ -75,6 +75,6 @@ const createPackageResolver = (fs, resolve) => {
75
75
  };
76
76
 
77
77
  module.exports = {
78
- resolvePackage: createPackageResolver(require('fs'), require.resolve),
78
+ resolvePackage: createPackageResolver(require('node:fs'), require.resolve),
79
79
  createPackageResolver,
80
80
  };
@@ -3,7 +3,9 @@ const { cwd } = require('../../../lib/cwd');
3
3
 
4
4
  describe('webpack utils', () => {
5
5
  describe('resolvePackage()', () => {
6
- let resolvePackage, fs, resolve;
6
+ let resolvePackage;
7
+ let fs;
8
+ let resolve;
7
9
 
8
10
  beforeEach(() => {
9
11
  fs = {
@@ -1,8 +1,7 @@
1
1
  const webpack = require('webpack');
2
2
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
3
3
  const nodeExternals = require('webpack-node-externals');
4
- const lodash = require('lodash');
5
- const path = require('path');
4
+ const path = require('node:path');
6
5
  const LoadablePlugin = require('@loadable/webpack-plugin');
7
6
  const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
8
7
  const TerserPlugin = require('terser-webpack-plugin');
@@ -16,6 +15,7 @@ const { VocabWebpackPlugin } = require('@vocab/webpack');
16
15
 
17
16
  const utils = require('./utils');
18
17
  const { cwd } = require('../../lib/cwd');
18
+ const { stringifyEnvarValues } = require('../../lib/env');
19
19
 
20
20
  const renderEntry = require.resolve('../../entry/render');
21
21
  const libraryRenderEntry = require.resolve('../../entry/libraryRender');
@@ -58,28 +58,11 @@ const makeWebpackConfig = ({
58
58
 
59
59
  const vocabOptions = getVocabConfig();
60
60
 
61
- const envVars = lodash
62
- .chain(env)
63
- .mapValues((value, key) => {
64
- if (typeof value !== 'object') {
65
- return JSON.stringify(value);
66
- }
67
-
68
- const valueForEnv = value[args.env];
69
-
70
- if (typeof valueForEnv === 'undefined') {
71
- console.log(
72
- `WARNING: Environment variable "${key}" is missing a value for the "${args.env}" environment`,
73
- );
74
- process.exit(1);
75
- }
76
-
77
- return JSON.stringify(valueForEnv);
78
- })
79
- .set('SKU_ENV', JSON.stringify(args.env))
80
- .set('PORT', JSON.stringify(port))
81
- .mapKeys((value, key) => `process.env.${key}`)
82
- .value();
61
+ const envars = stringifyEnvarValues({
62
+ ...env,
63
+ SKU_ENV: args.env,
64
+ PORT: port,
65
+ });
83
66
 
84
67
  const resolvedPolyfills = polyfills.map((polyfill) => {
85
68
  return require.resolve(polyfill, { paths: [cwd()] });
@@ -220,7 +203,7 @@ const makeWebpackConfig = ({
220
203
  ...(isDevServer || isIntegration
221
204
  ? []
222
205
  : [bundleAnalyzerPlugin({ name: 'client' })]),
223
- new webpack.DefinePlugin(envVars),
206
+ new webpack.DefinePlugin(envars),
224
207
  new webpack.DefinePlugin({
225
208
  __SKU_CLIENT_PATH__: JSON.stringify(
226
209
  path.relative(cwd(), paths.clientEntry),
@@ -309,7 +292,7 @@ const makeWebpackConfig = ({
309
292
  },
310
293
  plugins: [
311
294
  ...(htmlRenderPlugin ? [htmlRenderPlugin.rendererPlugin] : []),
312
- new webpack.DefinePlugin(envVars),
295
+ new webpack.DefinePlugin(envars),
313
296
  new webpack.DefinePlugin({
314
297
  __SKU_LIBRARY_NAME__: JSON.stringify(libraryName),
315
298
  __SKU_LIBRARY_FILE__: JSON.stringify(libraryFile),
@@ -1,7 +1,6 @@
1
- const path = require('path');
1
+ const path = require('node:path');
2
2
  const webpack = require('webpack');
3
3
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4
- const lodash = require('lodash');
5
4
  const nodeExternals = require('webpack-node-externals');
6
5
  const findUp = require('find-up');
7
6
  const LoadablePlugin = require('@loadable/webpack-plugin');
@@ -16,6 +15,7 @@ const args = require('../args');
16
15
  const { bundleAnalyzerPlugin } = require('./plugins/bundleAnalyzer');
17
16
  const utils = require('./utils');
18
17
  const { cwd } = require('../../lib/cwd');
18
+ const { stringifyEnvarValues } = require('../../lib/env');
19
19
  const {
20
20
  paths,
21
21
  env,
@@ -48,27 +48,10 @@ const makeWebpackConfig = ({
48
48
 
49
49
  const vocabOptions = getVocabConfig();
50
50
 
51
- const envVars = lodash
52
- .chain(env)
53
- .mapValues((value, key) => {
54
- if (typeof value !== 'object') {
55
- return JSON.stringify(value);
56
- }
57
-
58
- const valueForEnv = value[args.env];
59
-
60
- if (typeof valueForEnv === 'undefined') {
61
- console.log(
62
- `WARNING: Environment variable "${key}" is missing a value for the "${args.env}" environment`,
63
- );
64
- process.exit(1);
65
- }
66
-
67
- return JSON.stringify(valueForEnv);
68
- })
69
- .set('SKU_ENV', JSON.stringify(args.env))
70
- .mapKeys((value, key) => `process.env.${key}`)
71
- .value();
51
+ const envars = stringifyEnvarValues({
52
+ ...env,
53
+ SKU_ENV: args.env,
54
+ });
72
55
 
73
56
  const internalInclude = [path.join(__dirname, '../../entry'), ...paths.src];
74
57
 
@@ -173,7 +156,7 @@ const makeWebpackConfig = ({
173
156
  ],
174
157
  },
175
158
  plugins: [
176
- new webpack.DefinePlugin(envVars),
159
+ new webpack.DefinePlugin(envars),
177
160
  new LoadablePlugin({
178
161
  filename: webpackStatsFilename,
179
162
  writeToDisk: true,
@@ -268,7 +251,7 @@ const makeWebpackConfig = ({
268
251
  rules: [{ test: /\.mjs$/, type: 'javascript/auto' }],
269
252
  },
270
253
  plugins: [
271
- new webpack.DefinePlugin(envVars),
254
+ new webpack.DefinePlugin(envars),
272
255
  new webpack.DefinePlugin({
273
256
  __SKU_DEFAULT_SERVER_PORT__: JSON.stringify(serverPort),
274
257
  __SKU_PUBLIC_PATH__: JSON.stringify(publicPath),
@@ -1,11 +1,11 @@
1
- const { posix: path } = require('path');
1
+ const { posix: path } = require('node:path');
2
2
  const chalk = require('chalk');
3
3
  const glob = require('fast-glob');
4
4
 
5
5
  const { cwd: skuCwd } = require('../lib/cwd');
6
6
  const toPosixPath = require('../lib/toPosixPath');
7
7
 
8
- const { findRootSync } = require('@manypkg/find-root');
8
+ const { rootDir, isPnpm } = require('../lib/packageManager');
9
9
 
10
10
  /** @type {string[]} */
11
11
  let detectedCompilePackages = [];
@@ -14,9 +14,7 @@ try {
14
14
  const globs = ['node_modules/@seek/*/package.json'];
15
15
  const cwd = skuCwd();
16
16
 
17
- const { rootDir, tool } = findRootSync(cwd);
18
-
19
- if (tool === 'pnpm') {
17
+ if (isPnpm && rootDir) {
20
18
  const pnpmVirtualStorePath = path.join(
21
19
  toPosixPath(rootDir),
22
20
  'node_modules/.pnpm',
@@ -1,5 +1,5 @@
1
1
  const supportedBrowsers = require('browserslist-config-seek');
2
- const path = require('path');
2
+ const path = require('node:path');
3
3
  const isCompilePackage = require('../lib/isCompilePackage');
4
4
 
5
5
  const defaultDecorator = (a) => a;
package/context/index.js CHANGED
@@ -1,5 +1,5 @@
1
- const fs = require('fs');
2
- const path = require('path');
1
+ const fs = require('node:fs');
2
+ const path = require('node:path');
3
3
  const chalk = require('chalk');
4
4
  const { register } = require('esbuild-register/dist/node');
5
5
  const { getPathFromCwd } = require('../lib/cwd');
@@ -19,8 +19,10 @@ const getSkuConfig = () => {
19
19
  const tsPath = getPathFromCwd('sku.config.ts');
20
20
  const jsPath = getPathFromCwd('sku.config.js');
21
21
 
22
- if (args.config) {
23
- appSkuConfigPath = getPathFromCwd(args.config);
22
+ const customSkuConfig = args.config || process.env.SKU_CONFIG;
23
+
24
+ if (customSkuConfig) {
25
+ appSkuConfigPath = getPathFromCwd(customSkuConfig);
24
26
  } else if (fs.existsSync(tsPath)) {
25
27
  appSkuConfigPath = tsPath;
26
28
  } else if (fs.existsSync(jsPath)) {
@@ -65,6 +67,9 @@ if (isCompilePackage && skuConfig.rootResolution) {
65
67
  process.exit(1);
66
68
  }
67
69
 
70
+ /**
71
+ * @type {Record<string, unknown>}
72
+ */
68
73
  const env = {
69
74
  ...skuConfig.env,
70
75
  SKU_TENANT: args.tenant,
package/entry/csp.js CHANGED
@@ -1,6 +1,6 @@
1
- import { createHash } from 'crypto';
1
+ import { createHash } from 'node:crypto';
2
2
  import { parse, valid } from 'node-html-parser';
3
- import { URL } from 'url';
3
+ import { URL } from 'node:url';
4
4
 
5
5
  const scriptTypeIgnoreList = ['application/json', 'application/ld+json'];
6
6
 
@@ -1,6 +1,6 @@
1
- import fs from 'fs';
2
- import http from 'http';
3
- import https from 'https';
1
+ import fs from 'node:fs';
2
+ import http from 'node:http';
3
+ import https from 'node:https';
4
4
  import commandLineArgs from 'command-line-args';
5
5
  import { app, onStart } from './server';
6
6
 
@@ -1,5 +1,5 @@
1
1
  import { getChunkName } from '@vocab/webpack/chunk-name';
2
- import path from 'path';
2
+ import path from 'node:path';
3
3
  import express from 'express';
4
4
  import makeExtractor from '../makeExtractor';
5
5
  import createCSPHandler from '../csp';
@@ -1,5 +1,5 @@
1
- const path = require('path');
2
- const fs = require('fs/promises');
1
+ const path = require('node:path');
2
+ const fs = require('node:fs/promises');
3
3
  const { rimraf } = require('rimraf');
4
4
 
5
5
  const { paths } = require('../context');
@@ -1,11 +1,17 @@
1
1
  const selfsigned = require('selfsigned');
2
2
  const { blue } = require('chalk');
3
3
  const exists = require('./exists');
4
- const { mkdir, unlink, writeFile, stat, readFile } = require('fs/promises');
4
+ const {
5
+ mkdir,
6
+ unlink,
7
+ writeFile,
8
+ stat,
9
+ readFile,
10
+ } = require('node:fs/promises');
5
11
 
6
12
  const { getPathFromCwd } = require('../lib/cwd');
7
13
  const { hosts } = require('../context');
8
- const { performance } = require('perf_hooks');
14
+ const { performance } = require('node:perf_hooks');
9
15
  const track = require('../telemetry');
10
16
 
11
17
  const certificateTtl = 1000 * 60 * 60 * 24;
package/lib/configure.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
- const { writeFile, rm } = require('fs/promises');
3
- const path = require('path');
2
+
3
+ const { writeFile, rm } = require('node:fs/promises');
4
+ const path = require('node:path');
4
5
 
5
6
  const ensureGitignore = require('ensure-gitignore');
6
7
  const { cwd, getPathFromCwd } = require('./cwd');
@@ -13,12 +14,14 @@ const prettierConfig = require('../config/prettier/prettierConfig');
13
14
  const eslintConfig = require('../config/eslint/eslintConfig');
14
15
  const createTSConfig = require('../config/typescript/tsconfig.js');
15
16
  const getCertificate = require('./certificate');
17
+ const { storybookMainConfigPath } = require('./storybook');
18
+ const managedConfigBanner = require('./managedConfigBanner.js');
19
+
16
20
  const coverageFolder = 'coverage';
17
21
 
18
22
  const convertToForwardSlashPaths = (pathStr) => pathStr.replace(/\\/g, '/');
19
23
  const addSep = (p) => `${p}${path.sep}`;
20
- const prependBanner = (str) =>
21
- `/** THIS FILE IS GENERATED BY SKU, MANUAL CHANGES WILL BE DISCARDED **/\n${str}`;
24
+ const prependBanner = (str) => `${managedConfigBanner}\n${str}`;
22
25
 
23
26
  const writeFileToCWD = async (fileName, content, { banner = true } = {}) => {
24
27
  const outPath = getPathFromCwd(fileName);
@@ -33,11 +36,13 @@ module.exports = async () => {
33
36
  const gitIgnorePatterns = [
34
37
  addSep(bundleReportFolder),
35
38
  addSep(coverageFolder),
39
+ storybookMainConfigPath,
36
40
  ];
37
41
  const lintIgnorePatterns = [
38
42
  addSep(bundleReportFolder),
39
43
  addSep(coverageFolder),
40
44
  '*.less.d.ts',
45
+ storybookMainConfigPath,
41
46
  ];
42
47
 
43
48
  // Ignore webpack target directories
@@ -51,8 +56,9 @@ module.exports = async () => {
51
56
 
52
57
  // Generate ESLint configuration
53
58
  const eslintConfigFilename = '.eslintrc';
59
+ const eslintCacheFilename = '.eslintcache';
54
60
  await writeFileToCWD(eslintConfigFilename, eslintConfig);
55
- gitIgnorePatterns.push(eslintConfigFilename);
61
+ gitIgnorePatterns.push(eslintConfigFilename, eslintCacheFilename);
56
62
 
57
63
  // Generate Prettier configuration
58
64
  // NOTE: We are not generating a banner as prettier does not support the `JSON
@@ -1,5 +1,5 @@
1
- const path = require('path');
2
- const fs = require('fs/promises');
1
+ const path = require('node:path');
2
+ const fs = require('node:fs/promises');
3
3
  const exists = require('./exists');
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- const http = require('http');
2
- const https = require('https');
1
+ const http = require('node:http');
2
+ const https = require('node:https');
3
3
 
4
4
  const { httpsDevServer } = require('../context');
5
5
  const getCertificate = require('./certificate');
package/lib/cwd.js CHANGED
@@ -1,4 +1,4 @@
1
- const path = require('path');
1
+ const path = require('node:path');
2
2
 
3
3
  let currentCwd = process.cwd();
4
4