newspack-scripts 5.6.0-alpha.7 → 6.0.0-beta.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.
@@ -24,7 +24,7 @@ jobs:
24
24
  command: node --version
25
25
  - run:
26
26
  name: install
27
- command: npm install --legacy-peer-deps
27
+ command: npm install
28
28
  - run:
29
29
  name: release
30
30
  command: npm run semantic-release || true
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- lts/*
1
+ 16.11.1
package/README.md CHANGED
@@ -15,11 +15,11 @@ Will run `jest` tests. Useful flags:
15
15
 
16
16
  ### build
17
17
 
18
- Will run `wp-scripts build` to create optimised production builds.
18
+ Will run `calypso-build`, creating optimised production builds.
19
19
 
20
20
  ### watch
21
21
 
22
- Will run `wp-scripts start` to start a development build in devserver/watch mode.
22
+ Will run `calypso-build` in watch mode.
23
23
 
24
24
  ### commit
25
25
 
@@ -47,15 +47,6 @@ Will validate TypeScript code in the project. This requires a `tsconfig.json` fi
47
47
  }
48
48
  ```
49
49
 
50
- ### proxy
51
-
52
- Allows you to proxy NPM CLI commands through this repository's dependencies, so if a repository consumes the `newspack-scripts` NPM package, it can access any executables installed as a dependency in [package.json](https://github.com/Automattic/newspack-scripts/blob/trunk/package.json). e.g. `newspack-scripts proxy semantic-release --dry-run` will run `semantic-release --dry-run` but using the executable from `newspack-scripts` instead of whatever repository you're running the command from. This allows for more flexible use of NPM commands where the prefab configs and scripts this repo provides are too opinionated or aren't sufficient.
53
-
54
- Other examples:
55
-
56
- - `newspack-scripts proxy eslint 'src/**/*.{js,jsx,ts,tsx}'` will lint all JS/JSX/TS/TSX files inside the `./src` directory.
57
- - `newspack-scripts proxy stylelint 'src/**/*.scss'` will lint all SCSS files inside the `./src` directory.
58
-
59
50
  ---
60
51
 
61
52
  ## Semantic Release
@@ -163,10 +154,10 @@ module.exports = {
163
154
 
164
155
  ### stylelint
165
156
 
166
- Use this package's stylelint executable and config file when running it, e.g.:
157
+ Install `stylelint` via npm and reference this package's config file when running it, e.g.:
167
158
 
168
159
  ```shell
169
- newspack-scripts proxy stylelint '**/*.scss' --customSyntax postcss-scss --config=./node_modules/newspack-scripts/config/stylelint.config.js
160
+ stylelint '**/*.scss' --syntax scss --config=./node_modules/newspack-scripts/config/stylelint.config.js
170
161
  ```
171
162
 
172
163
  _Note: Due to issue with dependency resolving, you might end up a different version of `prettier` in project's `node_modules` and `node_modules/newspack-scripts/node_modules`. See https://github.com/Automattic/newspack-scripts/issues/1 for more information._
@@ -216,4 +207,4 @@ Note that before the first time updating you'll need to set the API key for Circ
216
207
 
217
208
  ### `@wordpress/*` packages
218
209
 
219
- This project list [`@wordpress/*` packages](https://github.com/WordPress/gutenberg/tree/trunk/packages) as dependencies in order to provide them to consumers. In a project using `@wordpress/scripts` (e.g. a consumer of `newspack-scripts`), the `@wordpress/*` packages are sourced from WP Core, not `node_modules`. The packages should be included in `node_modules`, though, to be available in other environments – notably when running tests. See [Dependency Extraction Webpack Plugin](https://www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin) for more information.
210
+ This project list [`@wordpress/*` packages](https://github.com/WordPress/gutenberg/tree/trunk/packages) as dependencies in order to provide them to consumers. In a project using `calypso-build` (e.g. a consumer of `newspack-scripts`), the `@wordpress/*` packages are sourced from WP Core, not `node_modules`. The packages should be included in `node_modules`, though, to be available in other environments – notably when running tests. See [Dependency Extraction Webpack Plugin](https://www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin) for more information.
@@ -1,43 +1,43 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const spawn = require( 'cross-spawn' );
4
- const utils = require( '../scripts/utils/index.js' );
3
+ const spawn = require("cross-spawn");
4
+ const utils = require("../scripts/utils/index.js");
5
5
 
6
- const [ scriptName, ...nodeArgs ] = process.argv.slice( 2 );
6
+ const [scriptName, ...nodeArgs] = process.argv.slice(2);
7
7
 
8
8
  if (
9
- [
10
- 'test',
11
- 'commit',
12
- 'commitlint',
13
- 'release',
14
- 'semantic-release',
15
- 'typescript-check',
16
- 'wp-scripts',
17
- ].includes( scriptName )
9
+ [
10
+ "test",
11
+ "build",
12
+ "watch",
13
+ "commit",
14
+ "commitlint",
15
+ "release",
16
+ "typescript-check",
17
+ ].includes(scriptName)
18
18
  ) {
19
- const result = spawn.sync(
20
- process.execPath,
21
- [ require.resolve( '../scripts/' + scriptName ), ...nodeArgs ],
22
- { stdio: 'inherit' }
23
- );
24
- if ( result.signal ) {
25
- if ( result.signal === 'SIGKILL' ) {
26
- utils.log(
27
- 'The build failed because the process exited too early. ' +
28
- 'This probably means the system ran out of memory or someone called ' +
29
- '`kill -9` on the process.'
30
- );
31
- } else if ( result.signal === 'SIGTERM' ) {
32
- utils.log(
33
- 'The build failed because the process exited too early. ' +
34
- 'Someone might have called `kill` or `killall`, or the system could ' +
35
- 'be shutting down.'
36
- );
37
- }
38
- process.exit( 1 );
39
- }
40
- process.exit( result.status );
19
+ const result = spawn.sync(
20
+ process.execPath,
21
+ [require.resolve("../scripts/" + scriptName), ...nodeArgs],
22
+ { stdio: "inherit" }
23
+ );
24
+ if (result.signal) {
25
+ if (result.signal === "SIGKILL") {
26
+ utils.log(
27
+ "The build failed because the process exited too early. " +
28
+ "This probably means the system ran out of memory or someone called " +
29
+ "`kill -9` on the process."
30
+ );
31
+ } else if (result.signal === "SIGTERM") {
32
+ utils.log(
33
+ "The build failed because the process exited too early. " +
34
+ "Someone might have called `kill` or `killall`, or the system could " +
35
+ "be shutting down."
36
+ );
37
+ }
38
+ process.exit(1);
39
+ }
40
+ process.exit(result.status);
41
41
  } else {
42
- utils.log( `Unknown script "${ scriptName }".` );
42
+ utils.log(`Unknown script "${scriptName}".`);
43
43
  }
@@ -1,8 +1,6 @@
1
- module.exports = api => {
2
- api.cache( true );
3
- return {
4
- presets: [
5
- '@wordpress/babel-preset-default',
6
- ],
7
- };
1
+ module.exports = (api) => {
2
+ api.cache(true);
3
+ return {
4
+ presets: ["@wordpress/babel-preset-default"],
5
+ };
8
6
  };
@@ -1 +1 @@
1
- module.exports = { extends: [ '@commitlint/config-conventional' ] };
1
+ module.exports = { extends: ["@commitlint/config-conventional"] };
@@ -1,77 +1,65 @@
1
- const wpRecommended = require.resolve( '@wordpress/eslint-plugin/configs/recommended' );
2
- const reactRecommended = require.resolve( '@wordpress/eslint-plugin/configs/react' );
3
-
4
- /**
5
- * Assume `@wordpress/*` packages are available. This is because `@wordpress/scripts` is using
6
- * Dependency Extraction Webpack Plugin to use core WP packages instead of those from
7
- * node_modules. The packages should still be part of the project (they are listed in this
8
- * project's package.json) so that they are available in testing environment.
9
- *
10
- * More on this:
11
- * - https: *www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin
12
- * - https: *github.com/WordPress/gutenberg/issues/35630
13
- *
14
- * React is also included here as it's a peer dependency of @wordpress/scripts.
15
- */
16
- const GLOBALLY_AVAILABLE_PACKAGES = [ '@wordpress/.*', 'react' ];
1
+ // Assume `@wordpress/*` packages are available. This is because `calypso-build` is using
2
+ // Dependency Extraction Webpack Plugin to use core WP packages instead of those from
3
+ // node_modules. The packages should still be part of the project (they are listed in this
4
+ // project's package.json) so that they are available in testing environment.
5
+ // More on this:
6
+ // - https://www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin
7
+ // - https://github.com/WordPress/gutenberg/issues/35630
8
+ const GLOBALLY_AVAILABLE_PACKAGES = ["@wordpress/.*"];
17
9
 
18
10
  module.exports = {
19
- extends: [
20
- 'plugin:import/errors',
21
- 'plugin:import/warnings',
22
- 'plugin:@typescript-eslint/eslint-recommended',
23
- 'plugin:@typescript-eslint/recommended',
24
- reactRecommended,
25
- wpRecommended,
26
- ],
27
- env: {
28
- browser: true,
29
- jest: true,
30
- },
31
- parser: '@typescript-eslint/parser',
32
- plugins: [ '@typescript-eslint' ],
33
- settings: {
34
- 'import/resolver': {
35
- node: {
36
- extensions: [ '.js', '.jsx', '.ts', '.tsx' ],
37
- },
38
- },
39
- },
40
- ignorePatterns: [ 'dist/', 'node_modules/', 'release/', 'scripts/', '/vendor' ],
41
- rules: {
42
- 'arrow-parens': 'off',
43
- camelcase: 'off',
44
- // Disallow logging.
45
- 'no-console': 'error',
46
- 'no-mixed-operators': 'off',
47
- 'wrap-iife': 'off',
48
- // Some dependencies are injected by WP, and should not be declared in package.json (won't be used anyway).
49
- // See https://github.com/WordPress/gutenberg/blob/e035f71/packages/dependency-extraction-webpack-plugin/README.md#behavior-with-scripts
50
- // Unfortunately there's no "ignore" option for this rule, so it's disabled altogether.
51
- 'import/no-extraneous-dependencies': 'off',
52
- 'import/no-unresolved': [ 'error', { ignore: GLOBALLY_AVAILABLE_PACKAGES } ],
53
- 'import/namespace': 'off',
54
- // There's a conflict with prettier here:
55
- 'react/jsx-curly-spacing': 'off',
56
- // Skip prop types validation for now
57
- 'react/prop-types': 'off',
58
- 'react/react-in-jsx-scope': 'off',
59
- 'react/self-closing-comp': 'error',
60
- 'react-hooks/exhaustive-deps': 'off',
61
- // JSDoc rules overrides
62
- 'jsdoc/require-returns': 'off',
63
- 'jsdoc/require-param': 'off',
64
- // Deprecated rules
65
- 'jsx-a11y/no-onchange': 'off',
66
- '@typescript-eslint/no-empty-function': 'off',
67
- // Fail on unused vars.
68
- '@typescript-eslint/no-unused-vars': 'error',
69
- // Handle the issue where no-shadow is a false positive when declaring TS enums.
70
- // See https://github.com/typescript-eslint/typescript-eslint/issues/2483
71
- 'no-shadow': 'off',
72
- '@typescript-eslint/no-shadow': 'error',
73
- '@typescript-eslint/ban-ts-comment': 'warn',
74
- '@typescript-eslint/no-explicit-any': 'warn',
75
- 'prettier/prettier': 'off', // We're mainly concerned about code quality rules, not formatting. npm run format:js can be used to reformat JS if desired.
76
- },
11
+ extends: [
12
+ "plugin:@wordpress/eslint-plugin/recommended",
13
+ "plugin:react/recommended",
14
+ "plugin:import/errors",
15
+ "plugin:import/warnings",
16
+ "plugin:@typescript-eslint/eslint-recommended",
17
+ "plugin:@typescript-eslint/recommended",
18
+ ],
19
+ env: {
20
+ browser: true,
21
+ jest: true,
22
+ },
23
+ parser: "@typescript-eslint/parser",
24
+ plugins: ["@typescript-eslint"],
25
+ settings: {
26
+ "import/resolver": {
27
+ node: {
28
+ extensions: [".js", ".jsx", ".ts", ".tsx"],
29
+ },
30
+ },
31
+ },
32
+ ignorePatterns: ["dist/", "node_modules/"],
33
+ parser: "@typescript-eslint/parser",
34
+ rules: {
35
+ "no-console": "off",
36
+ camelcase: "off",
37
+ // Some dependencies are injected by WP, and should not be declared in package.json (won't be used anyway).
38
+ // See https://github.com/WordPress/gutenberg/blob/e035f71/packages/dependency-extraction-webpack-plugin/README.md#behavior-with-scripts
39
+ // Unfortunately there's no "ignore" option for this rule, so it's disabled altogether.
40
+ "import/no-extraneous-dependencies": "off",
41
+ "import/no-unresolved": ["error", { ignore: GLOBALLY_AVAILABLE_PACKAGES }],
42
+ // There's a conflict with prettier here:
43
+ "react/jsx-curly-spacing": "off",
44
+ // Skip prop types validation for now
45
+ "react/prop-types": "off",
46
+ "react/react-in-jsx-scope": "off",
47
+ "react/self-closing-comp": "error",
48
+ // JSDoc rules overrides
49
+ "jsdoc/require-returns": "off",
50
+ "jsdoc/require-param": "off",
51
+ // Deprecated rules
52
+ "jsx-a11y/no-onchange": "off",
53
+ // For TypeScript type declarations.
54
+ camelcase: "off",
55
+ "@typescript-eslint/no-empty-function": "off",
56
+ // Fail on unused vars.
57
+ "@typescript-eslint/no-unused-vars": "error",
58
+ // Disallow logging.
59
+ "no-console": "error",
60
+ // Handle the issue where no-shadow is a false positive when declaring TS enums.
61
+ // See https://github.com/typescript-eslint/typescript-eslint/issues/2483
62
+ "no-shadow": "off",
63
+ "@typescript-eslint/no-shadow": "error",
64
+ },
77
65
  };
@@ -1,25 +1,24 @@
1
- const path = require( 'path' );
2
- require( '@wordpress/browserslist-config' );
3
- const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
1
+ const path = require("path");
2
+ const defaultConfig = require("@wordpress/scripts/config/webpack.config");
4
3
 
5
- module.exports = ( ...args ) => {
6
- let config = { ...defaultConfig };
4
+ module.exports = (...args) => {
5
+ let config = { ...defaultConfig };
7
6
 
8
- // Merge config extensions into default config.
9
- args.forEach( extension => {
10
- config = { ...config, ...extension };
11
- } );
7
+ // Merge config extensions into default config.
8
+ args.forEach((extension) => {
9
+ config = { ...config, ...extension };
10
+ });
12
11
 
13
- // Ensure that webpack resolves modules from the Newspack Scripts node_modules as well as the root repo's node_modules.
14
- config.resolve.modules = [
15
- path.resolve( __dirname, '../node_modules' ),
16
- 'node_modules',
17
- ];
12
+ // Ensure that webpack resolves modules from the Newspack Scripts node_modules as well as the root repo's node_modules.
13
+ config.resolve.modules = [
14
+ path.resolve(__dirname, "../node_modules"),
15
+ "node_modules",
16
+ ];
18
17
 
19
- // Clear cacheGroups so that CSS files don't get the `style-` prefix.
20
- if ( config?.optimization?.splitChunks?.cacheGroups?.style ) {
21
- delete config.optimization.splitChunks.cacheGroups.style;
22
- }
18
+ // Clear cacheGroups so that CSS files don't get the `style-` prefix.
19
+ if (config?.optimization?.splitChunks?.cacheGroups?.style) {
20
+ delete config.optimization.splitChunks.cacheGroups.style;
21
+ }
23
22
 
24
- return config;
23
+ return config;
25
24
  };
@@ -1,6 +1,6 @@
1
- const postcssFocusWithin = require( 'postcss-focus-within' );
2
- const autoprefixer = require( 'autoprefixer' );
1
+ const postcssFocusWithin = require("postcss-focus-within");
2
+ const autoprefixer = require("autoprefixer");
3
3
 
4
4
  module.exports = {
5
- plugins: [ autoprefixer(), postcssFocusWithin() ],
5
+ plugins: [autoprefixer(), postcssFocusWithin()]
6
6
  };
@@ -1,34 +1,30 @@
1
1
  module.exports = {
2
- extends: [
3
- '@wordpress/stylelint-config',
4
- ],
5
- rules: {
6
- 'rule-empty-line-before': null,
7
- 'at-rule-empty-line-before': null,
8
- 'comment-empty-line-before': null,
9
- 'no-descending-specificity': null,
10
- 'function-url-quotes': null,
11
- 'font-weight-notation': null,
12
- 'color-named': null,
13
- 'selector-class-pattern': null,
14
- 'custom-property-pattern': null,
15
- 'at-rule-no-unknown': null,
16
- 'alpha-value-notation': null,
17
- 'color-function-notation': null,
18
- 'selector-not-notation': null,
19
- 'function-no-unknown': [
20
- true,
21
- {
22
- ignoreFunctions: [ '/color/' ],
23
- },
24
- ],
25
- 'annotation-no-unknown': [
26
- true,
27
- {
28
- ignoreAnnotations: [ '/default/' ],
29
- },
30
- ],
31
- 'media-feature-range-notation': null,
32
- 'max-line-length': null,
33
- },
2
+ extends: ["stylelint-config-standard"],
3
+ rules: {
4
+ "rule-empty-line-before": null,
5
+ "at-rule-empty-line-before": null,
6
+ "comment-empty-line-before": null,
7
+ "no-descending-specificity": null,
8
+ "function-url-quotes": null,
9
+ "font-weight-notation": null,
10
+ "color-named": null,
11
+ "selector-class-pattern": null,
12
+ "custom-property-pattern": null,
13
+ "at-rule-no-unknown": null,
14
+ "alpha-value-notation": null,
15
+ "color-function-notation": null,
16
+ "selector-not-notation": null,
17
+ "function-no-unknown": [
18
+ true,
19
+ {
20
+ ignoreFunctions: ["/color/"],
21
+ },
22
+ ],
23
+ "annotation-no-unknown": [
24
+ true,
25
+ {
26
+ ignoreAnnotations: ["/default/"],
27
+ },
28
+ ],
29
+ },
34
30
  };
@@ -1,25 +1,21 @@
1
1
  {
2
- "$schema": "https://json.schemastore.org/tsconfig",
3
- "compilerOptions": {
4
- "noEmit": true,
5
- "composite": true,
6
- "noEmitHelpers": true,
7
- "skipLibCheck": true,
8
- "lib": [
9
- "ESNext",
10
- "DOM",
11
- "DOM.Iterable"
12
- ],
13
- "target": "es6",
14
- "module": "ESNext",
15
- "esModuleInterop": true,
16
- "jsx": "react-jsx",
17
- "strict": true,
18
- "isolatedModules": true,
19
- "moduleResolution": "node",
20
- "resolveJsonModule": true,
21
- "forceConsistentCasingInFileNames": true,
22
- "allowJs": true,
23
- "checkJs": false
24
- }
25
- }
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "noEmit": true,
5
+ "composite": true,
6
+ "noEmitHelpers": true,
7
+ "skipLibCheck": true,
8
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
9
+ "target": "es6",
10
+ "module": "ESNext",
11
+ "esModuleInterop": true,
12
+ "jsx": "react-jsx",
13
+ "strict": true,
14
+ "isolatedModules": true,
15
+ "moduleResolution": "node",
16
+ "resolveJsonModule": true,
17
+ "forceConsistentCasingInFileNames": true,
18
+ "allowJs": true,
19
+ "checkJs": false
20
+ }
21
+ }