newspack-scripts 5.4.0 → 5.5.1-alpha.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
27
+ command: npm install --legacy-peer-deps
28
28
  - run:
29
29
  name: release
30
30
  command: npm run semantic-release || true
package/.eslintrc.js ADDED
@@ -0,0 +1,9 @@
1
+ require( '@rushstack/eslint-patch/modern-module-resolution' );
2
+
3
+ module.exports = {
4
+ extends: [ './config/eslintrc.js' ],
5
+ ignorePatterns: [ 'node_modules' ],
6
+ rules: {
7
+ '@typescript-eslint/no-var-requires': 'off',
8
+ },
9
+ };
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- 16.11.1
1
+ lts/*
@@ -1,43 +1,44 @@
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
- "build",
12
- "watch",
13
- "commit",
14
- "commitlint",
15
- "release",
16
- "typescript-check",
17
- ].includes(scriptName)
9
+ [
10
+ 'test',
11
+ 'build',
12
+ 'watch',
13
+ 'commit',
14
+ 'commitlint',
15
+ 'eslint',
16
+ 'release',
17
+ 'typescript-check',
18
+ ].includes( scriptName )
18
19
  ) {
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);
20
+ const result = spawn.sync(
21
+ process.execPath,
22
+ [ require.resolve( '../scripts/' + scriptName ), ...nodeArgs ],
23
+ { stdio: 'inherit' }
24
+ );
25
+ if ( result.signal ) {
26
+ if ( result.signal === 'SIGKILL' ) {
27
+ utils.log(
28
+ 'The build failed because the process exited too early. ' +
29
+ 'This probably means the system ran out of memory or someone called ' +
30
+ '`kill -9` on the process.'
31
+ );
32
+ } else if ( result.signal === 'SIGTERM' ) {
33
+ utils.log(
34
+ 'The build failed because the process exited too early. ' +
35
+ 'Someone might have called `kill` or `killall`, or the system could ' +
36
+ 'be shutting down.'
37
+ );
38
+ }
39
+ process.exit( 1 );
40
+ }
41
+ process.exit( result.status );
41
42
  } else {
42
- utils.log(`Unknown script "${scriptName}".`);
43
+ utils.log( `Unknown script "${ scriptName }".` );
43
44
  }
@@ -1,9 +1,8 @@
1
1
  module.exports = api => {
2
- api.cache(true);
3
- return {
4
- presets: [
5
- "@automattic/calypso-build/babel/default",
6
- "@automattic/calypso-build/babel/wordpress-element"
7
- ]
8
- };
2
+ api.cache( true );
3
+ return {
4
+ presets: [
5
+ '@wordpress/babel-preset-default',
6
+ ],
7
+ };
9
8
  };
@@ -1 +1 @@
1
- module.exports = { extends: ["@commitlint/config-conventional"] };
1
+ module.exports = { extends: [ '@commitlint/config-conventional' ] };
@@ -1,3 +1,8 @@
1
+ const wpRecommended = require.resolve( '@wordpress/eslint-plugin/configs/recommended' );
2
+ const reactRecommended = require.resolve( '@wordpress/eslint-plugin/configs/react' );
3
+ // const tsRecommended = require.resolve( '@typescript-eslint/eslint-plugin/dist/configs/recommended' );
4
+ // const tsESLintRecommended = require.resolve( '@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended' );
5
+
1
6
  // Assume `@wordpress/*` packages are available. This is because `calypso-build` is using
2
7
  // Dependency Extraction Webpack Plugin to use core WP packages instead of those from
3
8
  // node_modules. The packages should still be part of the project (they are listed in this
@@ -5,61 +10,67 @@
5
10
  // More on this:
6
11
  // - https://www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin
7
12
  // - https://github.com/WordPress/gutenberg/issues/35630
8
- const GLOBALLY_AVAILABLE_PACKAGES = ["@wordpress/.*"];
13
+ const GLOBALLY_AVAILABLE_PACKAGES = [ '@wordpress/.*' ];
9
14
 
10
15
  module.exports = {
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
- },
16
+ extends: [
17
+ 'plugin:import/errors',
18
+ 'plugin:import/warnings',
19
+ 'plugin:@typescript-eslint/eslint-recommended',
20
+ 'plugin:@typescript-eslint/recommended',
21
+ wpRecommended,
22
+ reactRecommended,
23
+ ],
24
+ env: {
25
+ browser: true,
26
+ jest: true,
27
+ },
28
+ parser: '@typescript-eslint/parser',
29
+ plugins: [ '@typescript-eslint' ],
30
+ settings: {
31
+ 'import/resolver': {
32
+ node: {
33
+ extensions: [ '.js', '.jsx', '.ts', '.tsx' ],
34
+ },
35
+ },
36
+ },
37
+ ignorePatterns: [ 'dist/', 'node_modules/' ],
38
+ parser: '@typescript-eslint/parser',
39
+ rules: {
40
+ 'arrow-parens': 'off',
41
+ camelcase: 'off',
42
+ 'no-console': 'off',
43
+ 'no-mixed-operators': 'off',
44
+ 'space-before-function-paren': 'off',
45
+ 'wrap-iife': 'off',
46
+ // Some dependencies are injected by WP, and should not be declared in package.json (won't be used anyway).
47
+ // See https://github.com/WordPress/gutenberg/blob/e035f71/packages/dependency-extraction-webpack-plugin/README.md#behavior-with-scripts
48
+ // Unfortunately there's no "ignore" option for this rule, so it's disabled altogether.
49
+ 'import/no-extraneous-dependencies': 'off',
50
+ 'import/no-unresolved': [ 'error', { ignore: GLOBALLY_AVAILABLE_PACKAGES } ],
51
+ 'import/namespace': 'off',
52
+ // There's a conflict with prettier here:
53
+ 'react/jsx-curly-spacing': 'off',
54
+ // Skip prop types validation for now
55
+ 'react/prop-types': 'off',
56
+ 'react/react-in-jsx-scope': 'off',
57
+ 'react/self-closing-comp': 'error',
58
+ 'react-hooks/exhaustive-deps': 'off',
59
+ // JSDoc rules overrides
60
+ 'jsdoc/require-returns': 'off',
61
+ 'jsdoc/require-param': 'off',
62
+ // Deprecated rules
63
+ 'jsx-a11y/no-onchange': 'off',
64
+ '@typescript-eslint/no-empty-function': 'off',
65
+ // Fail on unused vars.
66
+ '@typescript-eslint/no-unused-vars': 'error',
67
+ // Disallow logging.
68
+ 'no-console': '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
+ },
65
76
  };
@@ -1,27 +1,25 @@
1
- const path = require("path");
1
+ const path = require( 'path' );
2
+ require( '@wordpress/browserslist-config' );
3
+ const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
2
4
 
3
- const getWebpackConfig = require("@automattic/calypso-build/webpack.config.js");
5
+ module.exports = ( ...args ) => {
6
+ let config = { ...defaultConfig };
4
7
 
5
- module.exports = (...args) => {
6
- const config = getWebpackConfig(...args);
8
+ // Merge config extensions into default config.
9
+ args.forEach( extension => {
10
+ config = { ...config, ...extension };
11
+ } );
7
12
 
8
- const scssRuleIndex = config.module.rules.findIndex(rule =>
9
- rule.test.toString().match(/\(sc\|sa\|c\)ss/)
10
- );
11
- if (scssRuleIndex !== -1) {
12
- const scssRule = config.module.rules[scssRuleIndex];
13
- const postCssLoaderIndex = scssRule.use.findIndex(
14
- loader => loader.loader && loader.loader.indexOf("postcss") > 0
15
- );
16
- if (postCssLoaderIndex !== -1) {
17
- const postCssLoader = scssRule.use[postCssLoaderIndex];
18
- const postCssConfigPath = path.resolve(__dirname, "postcss.config.js");
19
- // Replace calypso-build's PostCSS config with this project's one.
20
- postCssLoader.options.postcssOptions.config = postCssConfigPath;
21
- config.module.rules[scssRuleIndex].use[
22
- postCssLoaderIndex
23
- ] = postCssLoader;
24
- }
25
- }
26
- return config;
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( 'node_modules/newspack-scripts/node_modules' ),
16
+ 'node_modules',
17
+ ];
18
+
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
+ }
23
+
24
+ return config;
27
25
  };
@@ -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,30 +1,30 @@
1
1
  module.exports = {
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
- },
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
+ },
30
30
  };
@@ -1,21 +1,25 @@
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": ["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
- }
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
+ }
package/package.json CHANGED
@@ -1,84 +1,83 @@
1
1
  {
2
- "name": "newspack-scripts",
3
- "version": "5.4.0",
4
- "description": "",
5
- "bin": {
6
- "newspack-scripts": "./bin/newspack-scripts.js"
7
- },
8
- "author": "",
9
- "license": "ISC",
10
- "dependencies": {
11
- "@automattic/calypso-build": "^10.0.0",
12
- "@babel/preset-env": "^7.16.4",
13
- "@babel/preset-typescript": "^7.18.6",
14
- "@commitlint/cli": "^17.1.2",
15
- "@commitlint/config-conventional": "^17.1.0",
16
- "@semantic-release/changelog": "^6.0.1",
17
- "@semantic-release/git": "^10.0.1",
18
- "@testing-library/jest-dom": "^5.15.1",
19
- "@testing-library/react": "^13.4.0",
20
- "@types/wordpress__data": "^4.6.10",
21
- "@typescript-eslint/parser": "^5.26.0",
22
- "@wordpress/a11y": "^3.2.4",
23
- "@wordpress/api-fetch": "^6.17.0",
24
- "@wordpress/base-styles": "^4.0.4",
25
- "@wordpress/block-editor": "^8.0.11",
26
- "@wordpress/blocks": "^11.1.4",
27
- "@wordpress/components": "^21.3.0",
28
- "@wordpress/compose": "^5.0.6",
29
- "@wordpress/data": "^6.1.4",
30
- "@wordpress/date": "^4.2.3",
31
- "@wordpress/dom-ready": "^3.2.3",
32
- "@wordpress/edit-post": "^6.17.0",
33
- "@wordpress/element": "^4.0.4",
34
- "@wordpress/escape-html": "^2.2.3",
35
- "@wordpress/eslint-plugin": "^10.0.0",
36
- "@wordpress/hooks": "^3.2.2",
37
- "@wordpress/html-entities": "^3.2.3",
38
- "@wordpress/i18n": "^4.2.4",
39
- "@wordpress/icons": "^6.1.1",
40
- "@wordpress/keycodes": "^3.2.4",
41
- "@wordpress/plugins": "^4.0.6",
42
- "@wordpress/url": "^3.3.1",
43
- "autoprefixer": "^10.4.0",
44
- "babel-jest": "^29.2.2",
45
- "commitizen": "^4.2.4",
46
- "cross-spawn": "^7.0.3",
47
- "cz-conventional-changelog": "^3.3.0",
48
- "eslint": "^8.8.0",
49
- "eslint-config-prettier": "^8.3.0",
50
- "eslint-plugin-import": "^2.25.4",
51
- "eslint-plugin-jest": "^27.1.3",
52
- "eslint-plugin-react": "^7.28.0",
53
- "jest": "^27.4.3",
54
- "jest-environment-jsdom": "^27.4.3",
55
- "postcss": "^8.4.4",
56
- "postcss-focus-within": "^5.0.1",
57
- "prettier": "npm:wp-prettier@^2.6.2-beta-1",
58
- "semantic-release": "^19.0.5",
59
- "semantic-release-version-bump": "^1.4.1",
60
- "stylelint": "^14.1.0",
61
- "stylelint-config-standard": "^30.0.1",
62
- "typescript": "^4.5.5",
63
- "webpack": "^5.65.0"
64
- },
65
- "scripts": {
66
- "semantic-release": "semantic-release"
67
- },
68
- "release": {
69
- "branches": [
70
- "trunk",
71
- {
72
- "name": "alpha",
73
- "prerelease": true
74
- }
75
- ]
76
- },
77
- "repository": {
78
- "type": "git",
79
- "url": "https://github.com/Automattic/newspack-scripts.git"
80
- },
81
- "devDependencies": {
82
- "yargs": "^17.3.0"
83
- }
2
+ "name": "newspack-scripts",
3
+ "version": "5.5.1-alpha.1",
4
+ "description": "",
5
+ "bin": {
6
+ "newspack-scripts": "./bin/newspack-scripts.js"
7
+ },
8
+ "author": "",
9
+ "license": "ISC",
10
+ "devDependencies": {
11
+ "@commitlint/cli": "^17.8.1",
12
+ "@commitlint/config-conventional": "^17.8.1",
13
+ "@rushstack/eslint-patch": "^1.10.3",
14
+ "@semantic-release/changelog": "^6.0.3",
15
+ "@semantic-release/git": "^10.0.1",
16
+ "@testing-library/jest-dom": "^5.17.0",
17
+ "@testing-library/react": "^13.4.0",
18
+ "@typescript-eslint/parser": "^7.13.0",
19
+ "@wordpress/base-styles": "^5.0.0",
20
+ "@wordpress/scripts": "^28.0.0",
21
+ "autoprefixer": "^10.4.19",
22
+ "commitizen": "^4.3.0",
23
+ "cross-spawn": "^7.0.3",
24
+ "cz-conventional-changelog": "^3.3.0",
25
+ "eslint": "^8.57.0",
26
+ "eslint-config-prettier": "^8.10.0",
27
+ "eslint-plugin-import": "^2.29.1",
28
+ "eslint-plugin-jest": "^27.9.0",
29
+ "eslint-plugin-react": "^7.34.2",
30
+ "lodash": "^4.17.21",
31
+ "postcss": "^8.4.38",
32
+ "postcss-focus-within": "^5.0.4",
33
+ "postcss-scss": "^4.0.9",
34
+ "prettier": "^3.3.2",
35
+ "semantic-release": "^24.0.0",
36
+ "semantic-release-version-bump": "^1.4.1",
37
+ "stylelint": "^14.16.1",
38
+ "stylelint-config-standard": "^30.0.1",
39
+ "typescript": "^5.4.5",
40
+ "yargs": "^17.7.2"
41
+ },
42
+ "dependencies": {
43
+ "@wordpress/a11y": "^4.0.0",
44
+ "@wordpress/api-fetch": "^7.0.0",
45
+ "@wordpress/block-editor": "^13.0.0",
46
+ "@wordpress/blocks": "^13.0.0",
47
+ "@wordpress/components": "^28.0.0",
48
+ "@wordpress/compose": "^7.0.0",
49
+ "@wordpress/data": "^10.0.0",
50
+ "@wordpress/date": "^5.0.0",
51
+ "@wordpress/dom-ready": "^4.0.0",
52
+ "@wordpress/edit-post": "^8.0.0",
53
+ "@wordpress/element": "^6.0.0",
54
+ "@wordpress/escape-html": "^3.0.0",
55
+ "@wordpress/eslint-plugin": "^19.0.0",
56
+ "@wordpress/hooks": "^4.0.0",
57
+ "@wordpress/html-entities": "^4.0.0",
58
+ "@wordpress/i18n": "^5.0.0",
59
+ "@wordpress/icons": "^10.0.0",
60
+ "@wordpress/keycodes": "^4.0.0",
61
+ "@wordpress/plugins": "^7.0.0",
62
+ "@wordpress/url": "^4.0.0"
63
+ },
64
+ "scripts": {
65
+ "semantic-release": "semantic-release"
66
+ },
67
+ "release": {
68
+ "branches": [
69
+ "trunk",
70
+ {
71
+ "name": "alpha",
72
+ "prerelease": true
73
+ }
74
+ ]
75
+ },
76
+ "repository": {
77
+ "type": "git",
78
+ "url": "https://github.com/Automattic/newspack-scripts.git"
79
+ },
80
+ "browserslist": [
81
+ "extends @wordpress/browserslist-config"
82
+ ]
84
83
  }