newspack-scripts 5.5.1-alpha.3 → 5.5.2

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/README.md CHANGED
@@ -6,12 +6,11 @@ Scripts for Newspack, heavily inspired by [`react-scripts`](https://github.com/f
6
6
 
7
7
  ## Available scripts
8
8
 
9
- ### test
9
+ Repos consuming the `newspack-scripts` package can use the following NPM scripts. Prefix each at the command line with `npm run` (or [`bun run`](https://bun.sh/)) to execute.
10
10
 
11
- Will run `jest` tests. Useful flags:
11
+ ### start
12
12
 
13
- - `--watch` to run in file watch mode,
14
- - `--coverage` to collect test coverage
13
+ Execute with `npm start`. This is the only script you run without the `run` prefix. This will install Composer and NPM dependencies, then run the `watch` command to start a development build. Best used when cloning a repo for the first time, or when you need to restore a locally cloned repo to a fresh state.
15
14
 
16
15
  ### build
17
16
 
@@ -21,6 +20,33 @@ Will run `wp-scripts build` to create optimised production builds.
21
20
 
22
21
  Will run `wp-scripts start` to start a development build in devserver/watch mode.
23
22
 
23
+ ### lint:js, lint:scss, lint
24
+
25
+ Will run `wp-scripts lint-js`, `wp-scripts lint-style`, or both. See the [`@wordpress/scripts` handbook](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/) for implementation details and additional options.
26
+
27
+ ### fix:js
28
+
29
+ Will run `wp-scripts lint-js --fix`, allowing ESLint to correct any autofixable code quality errors it finds. Note that code quality errors are separate from formatting, which is handled by `format:js` (see below).
30
+
31
+ ### format:js
32
+
33
+ Will run `wp-scripts format-js` to reformat JS files according to [Prettier](https://prettier.io/) rules. Note that formatting is separate from code quality errors, which are handled by `fix:js` (see above).
34
+
35
+ ### format:scss
36
+
37
+ Will run `wp-scripts lint-style --fix` to reformat SCSS files according to [Stylelint](https://stylelint.io/) rules.
38
+
39
+ ### test
40
+
41
+ Will run `jest` tests. Useful flags:
42
+
43
+ - `--watch` to run in file watch mode,
44
+ - `--coverage` to collect test coverage
45
+
46
+ ### lint:php, fix:php
47
+
48
+ Will run `phpcs` or `phpcbf` to lint or autofix PHP files, respectively. Note that you must install these PHP packages via `composer install` or `npm start` before you can use these locally.
49
+
24
50
  ### commit
25
51
 
26
52
  Uses [`commitizen`](https://www.npmjs.com/package/commitizen) to create a structured commit message.
@@ -39,23 +65,18 @@ Will validate TypeScript code in the project. This requires a `tsconfig.json` fi
39
65
 
40
66
  ```json
41
67
  {
42
- "extends": "newspack-scripts/config/tsconfig.json",
43
- "compilerOptions": {
44
- "rootDir": "src"
45
- },
46
- "include": ["src"]
68
+ "extends": "newspack-scripts/config/tsconfig.json",
69
+ "compilerOptions": {
70
+ "rootDir": "src",
71
+ "jsx": "react-jsx"
72
+ },
73
+ "include": [
74
+ "src",
75
+ "src/**/*.json"
76
+ ]
47
77
  }
48
78
  ```
49
79
 
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
80
  ---
60
81
 
61
82
  ## Semantic Release
@@ -124,12 +145,11 @@ The `webpack.config.js` file should use this package's config-extending function
124
145
  const getBaseWebpackConfig = require("newspack-scripts/config/getWebpackConfig");
125
146
 
126
147
  const webpackConfig = getBaseWebpackConfig(
127
- { WP: true },
128
- {
129
- entry: {
130
- "some-script": "./src/some-script.js",
131
- },
132
- }
148
+ {
149
+ entry: {
150
+ 'output-file': './src/entrypoint-file.js',
151
+ },
152
+ }
133
153
  );
134
154
 
135
155
  module.exports = webpackConfig;
@@ -140,36 +160,69 @@ module.exports = webpackConfig;
140
160
  A basic `babel.config.js`:
141
161
 
142
162
  ```js
143
- module.exports = (api) => {
144
- api.cache(true);
145
- return {
146
- extends: "newspack-scripts/config/babel.config.js",
147
- };
163
+ module.exports = api => {
164
+ api.cache( true );
165
+ return {
166
+ extends: 'newspack-scripts/config/babel.config.js',
167
+ };
168
+ };
169
+ ```
170
+
171
+ ### ESLint
172
+
173
+ `@wordpress/scripts` uses ESLint under the hood for JS code quality linting. Note that this is separate from code formatting, which is handled by Prettier (see below).
174
+
175
+ Because of ESLint's [issue](https://github.com/eslint/eslint/issues/3458) with resolving dependencies of extended configurations, a patch has to be used to use this config in a stand-alone fashion: install `@rushstack/eslint-patch` and set up the `.eslintrc.js` like so:
176
+
177
+ ```js
178
+ require( '@rushstack/eslint-patch/modern-module-resolution' );
179
+
180
+ module.exports = {
181
+ extends: [ './node_modules/newspack-scripts/config/eslintrc.js' ],
182
+ // Additional options…
148
183
  };
149
184
  ```
150
185
 
151
- ### eslint
186
+ ### Prettier
187
+
188
+ `@wordpress/scripts` uses [Prettier](https://prettier.io/) under the hood for JS formatting. Note that this is separate from code quality, which is handled by ESLint (see above).
152
189
 
153
- Because of eslint's [issue](https://github.com/eslint/eslint/issues/3458) with resolving dependencies of extended configurations, a patch has to be used to use this config in a stand-alone fashion: install `@rushstack/eslint-patch` and set up the `.eslintrc.js` like so:
190
+ To configure Prettier rules, extend this repo's config by creating a `.prettierrc.js` file like so:
154
191
 
155
192
  ```js
156
- require("@rushstack/eslint-patch/modern-module-resolution");
193
+ const baseConfig = require( './node_modules/newspack-scripts/config/prettier.config.js' );
157
194
 
158
195
  module.exports = {
159
- extends: ["./node_modules/newspack-scripts/config/eslintrc.js"],
160
- // Additional options…
196
+ ...baseConfig,
197
+ // Additional options…
161
198
  };
162
199
  ```
163
200
 
201
+ You should also include a [`.prettierignore` file](https://prettier.io/docs/en/ignore.html) to tell Prettier which files and directories it should ignore, using [gitignore syntax](https://git-scm.com/docs/gitignore#_pattern_format):
202
+
203
+ ```
204
+ dist
205
+ node_modules
206
+ release
207
+ vendor
208
+ ```
209
+
164
210
  ### stylelint
165
211
 
166
- Use this package's stylelint executable and config file when running it, e.g.:
212
+ `@wordpress/scripts` uses [Stylelint](https://stylelint.io/) under the hood for SCSS linting and formatting.
167
213
 
168
214
  ```shell
169
- newspack-scripts proxy stylelint '**/*.scss' --customSyntax postcss-scss --config=./node_modules/newspack-scripts/config/stylelint.config.js
215
+ newspack-scripts wp-scripts lint-style '**/*.scss' --customSyntax postcss-scss
170
216
  ```
171
217
 
172
- _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._
218
+ Extend this repo's config with a `.stylelintrc.js` file like so:
219
+
220
+ ```js
221
+ module.exports = {
222
+ extends: [ './node_modules/newspack-scripts/config/stylelint.config.js' ],
223
+ // Additional options…
224
+ };
225
+ ```
173
226
 
174
227
  ### TypeScript
175
228
 
@@ -216,4 +269,4 @@ Note that before the first time updating you'll need to set the API key for Circ
216
269
 
217
270
  ### `@wordpress/*` packages
218
271
 
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.
272
+ This project lists [`@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.
@@ -8,15 +8,12 @@ const [ scriptName, ...nodeArgs ] = process.argv.slice( 2 );
8
8
  if (
9
9
  [
10
10
  'test',
11
- 'build',
12
- 'watch',
13
11
  'commit',
14
12
  'commitlint',
15
- 'eslint',
16
- 'proxy',
17
- 'stylelint',
18
13
  'release',
14
+ 'semantic-release',
19
15
  'typescript-check',
16
+ 'wp-scripts',
20
17
  ].includes( scriptName )
21
18
  ) {
22
19
  const result = spawn.sync(
@@ -1,14 +1,19 @@
1
1
  const wpRecommended = require.resolve( '@wordpress/eslint-plugin/configs/recommended' );
2
2
  const reactRecommended = require.resolve( '@wordpress/eslint-plugin/configs/react' );
3
3
 
4
- // Assume `@wordpress/*` packages are available. This is because `@wordpress/scripts` is using
5
- // Dependency Extraction Webpack Plugin to use core WP packages instead of those from
6
- // node_modules. The packages should still be part of the project (they are listed in this
7
- // project's package.json) so that they are available in testing environment.
8
- // More on this:
9
- // - https://www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin
10
- // - https://github.com/WordPress/gutenberg/issues/35630
11
- const GLOBALLY_AVAILABLE_PACKAGES = [ '@wordpress/.*' ];
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' ];
12
17
 
13
18
  module.exports = {
14
19
  extends: [
@@ -16,8 +21,8 @@ module.exports = {
16
21
  'plugin:import/warnings',
17
22
  'plugin:@typescript-eslint/eslint-recommended',
18
23
  'plugin:@typescript-eslint/recommended',
19
- wpRecommended,
20
24
  reactRecommended,
25
+ wpRecommended,
21
26
  ],
22
27
  env: {
23
28
  browser: true,
@@ -32,14 +37,13 @@ module.exports = {
32
37
  },
33
38
  },
34
39
  },
35
- ignorePatterns: [ 'dist/', 'node_modules/', 'scripts/' ],
36
- parser: '@typescript-eslint/parser',
40
+ ignorePatterns: [ 'dist/', 'node_modules/', 'release/', 'scripts/', '/vendor' ],
37
41
  rules: {
38
42
  'arrow-parens': 'off',
39
43
  camelcase: 'off',
40
- 'no-console': 'off',
44
+ // Disallow logging.
45
+ 'no-console': 'error',
41
46
  'no-mixed-operators': 'off',
42
- 'space-before-function-paren': 'off',
43
47
  'wrap-iife': 'off',
44
48
  // Some dependencies are injected by WP, and should not be declared in package.json (won't be used anyway).
45
49
  // See https://github.com/WordPress/gutenberg/blob/e035f71/packages/dependency-extraction-webpack-plugin/README.md#behavior-with-scripts
@@ -62,13 +66,12 @@ module.exports = {
62
66
  '@typescript-eslint/no-empty-function': 'off',
63
67
  // Fail on unused vars.
64
68
  '@typescript-eslint/no-unused-vars': 'error',
65
- // Disallow logging.
66
- 'no-console': 'error',
67
69
  // Handle the issue where no-shadow is a false positive when declaring TS enums.
68
70
  // See https://github.com/typescript-eslint/typescript-eslint/issues/2483
69
71
  'no-shadow': 'off',
70
72
  '@typescript-eslint/no-shadow': 'error',
71
73
  '@typescript-eslint/ban-ts-comment': 'warn',
72
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.
73
76
  },
74
77
  };
@@ -0,0 +1,6 @@
1
+ const wpConfig = require( '@wordpress/prettier-config' );
2
+
3
+ module.exports = {
4
+ ...wpConfig,
5
+ arrowParens: 'avoid',
6
+ };
@@ -1,5 +1,7 @@
1
1
  module.exports = {
2
- extends: [ 'stylelint-config-standard' ],
2
+ extends: [
3
+ '@wordpress/stylelint-config',
4
+ ],
3
5
  rules: {
4
6
  'rule-empty-line-before': null,
5
7
  'at-rule-empty-line-before': null,
@@ -26,7 +28,7 @@ module.exports = {
26
28
  ignoreAnnotations: [ '/default/' ],
27
29
  },
28
30
  ],
29
- 'media-query-no-invalid': null,
30
31
  'media-feature-range-notation': null,
32
+ 'max-line-length': null,
31
33
  },
32
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newspack-scripts",
3
- "version": "5.5.1-alpha.3",
3
+ "version": "5.5.2",
4
4
  "description": "",
5
5
  "bin": {
6
6
  "newspack-scripts": "./bin/newspack-scripts.js"
@@ -36,9 +36,10 @@
36
36
  "@wordpress/icons": "^10.0.0",
37
37
  "@wordpress/keycodes": "^4.0.0",
38
38
  "@wordpress/plugins": "^7.0.0",
39
- "@wordpress/scripts": "^28.0.0",
39
+ "@wordpress/prettier-config": "^4.1.0",
40
+ "@wordpress/scripts": "^28.1.0",
41
+ "@wordpress/stylelint-config": "^22.1.0",
40
42
  "@wordpress/url": "^4.0.0",
41
- "ajv": "^8.16.0",
42
43
  "autoprefixer": "^10.4.19",
43
44
  "commitizen": "^4.3.0",
44
45
  "cross-spawn": "^7.0.3",
@@ -52,21 +53,14 @@
52
53
  "postcss": "^8.4.38",
53
54
  "postcss-focus-within": "^5.0.4",
54
55
  "postcss-scss": "^4.0.9",
55
- "prettier": "^3.3.2",
56
+ "prettier": "npm:wp-prettier@^3.0.3",
56
57
  "semantic-release": "^19.0.5",
57
58
  "semantic-release-version-bump": "^1.4.1",
58
- "stylelint": "^16.6.1",
59
- "stylelint-config-standard": "^36.0.0",
59
+ "stylelint": "^14.2.0",
60
60
  "typescript": "^5.4.5",
61
61
  "yargs": "^17.7.2"
62
62
  },
63
63
  "overrides": {
64
- "@eslint/eslintrc": {
65
- "ajv": "^6.0.0"
66
- },
67
- "terser-webpack-plugin": {
68
- "ajv": "^6.0.0"
69
- },
70
64
  "history": "4.9.0",
71
65
  "path-to-regexp": "1.7.0"
72
66
  },
@@ -88,5 +82,6 @@
88
82
  },
89
83
  "browserslist": [
90
84
  "extends @wordpress/browserslist-config"
91
- ]
85
+ ],
86
+ "prettier": "@wordpress/prettier-config"
92
87
  }
@@ -2,9 +2,10 @@
2
2
 
3
3
  const spawn = require( 'cross-spawn' );
4
4
  const path = require( 'path' );
5
+ const commitlint = require.resolve( '@commitlint/cli/cli' );
5
6
 
6
7
  const result = spawn.sync(
7
- `${ process.cwd() }/node_modules/.bin/commitlint`,
8
+ commitlint,
8
9
  [ '--config', path.resolve( __dirname, '../config/commitlint.config.js' ) ],
9
10
  {
10
11
  stdio: 'inherit',
@@ -18,8 +18,22 @@ if ( shouldPublishOnNPM ) {
18
18
  utils.log( `Will publish on npm` );
19
19
  }
20
20
 
21
- const getConfig = ( { gitBranchName } ) => {
22
- const branchType = gitBranchName.split( '/' )[ 0 ];
21
+ const getConfig = ({ gitBranchName }) => {
22
+ const branchType = gitBranchName.split("/")[0];
23
+ const githubConfig = {
24
+ assets: [
25
+ {
26
+ path: `./release/${process.env.CIRCLE_PROJECT_REPONAME}.zip`,
27
+ label: `${process.env.CIRCLE_PROJECT_REPONAME}.zip`,
28
+ },
29
+ ],
30
+ };
31
+
32
+ // Only post GH PR comments for alpha, hotfix/*, and release branches.
33
+ if ( ! ["alpha", "hotfix", "release"].includes(branchType) ) {
34
+ githubConfig.successComment = false;
35
+ githubConfig.failComment = false;
36
+ }
23
37
 
24
38
  const config = {
25
39
  dryRun: otherArgs.dryRun,
@@ -28,52 +42,43 @@ const getConfig = ( { gitBranchName } ) => {
28
42
 
29
43
  branches: [
30
44
  // `release` branch is published on the main distribution channel (a new version on GH).
31
- 'release',
45
+ "release",
32
46
  // `alpha` branch – for regular pre-releases.
33
47
  {
34
- name: 'alpha',
48
+ name: "alpha",
35
49
  prerelease: true,
36
50
  },
37
51
  // `hotfix/*` branches – for releases outside of the release schedule.
38
52
  {
39
- name: 'hotfix/*',
53
+ name: "hotfix/*",
40
54
  // With `prerelease: true`, the `name` would be used for the pre-release tag. A name with a `/`
41
55
  // is not valid, though. See https://semver.org/#spec-item-9.
42
56
  prerelease: '${name.replace(/\\//g, "-")}',
43
57
  },
44
58
  // `epic/*` branches – for beta testing/QA pre-release builds.
45
59
  {
46
- name: 'epic/*',
60
+ name: "epic/*",
47
61
  // With `prerelease: true`, the `name` would be used for the pre-release tag. A name with a `/`
48
62
  // is not valid, though. See https://semver.org/#spec-item-9.
49
63
  prerelease: '${name.replace(/\\//g, "-")}',
50
64
  },
51
65
  ],
52
- prepare: [ '@semantic-release/changelog', '@semantic-release/npm' ],
66
+ prepare: ["@semantic-release/changelog", "@semantic-release/npm"],
53
67
  plugins: [
54
- '@semantic-release/commit-analyzer',
55
- '@semantic-release/release-notes-generator',
68
+ "@semantic-release/commit-analyzer",
69
+ "@semantic-release/release-notes-generator",
56
70
  [
57
71
  // Whether to publish on npm.
58
- '@semantic-release/npm',
72
+ "@semantic-release/npm",
59
73
  {
60
74
  npmPublish: shouldPublishOnNPM,
61
75
  },
62
76
  ],
63
- 'semantic-release-version-bump',
77
+ "semantic-release-version-bump",
64
78
  // Add the built ZIP archive to GH release.
65
79
  [
66
- '@semantic-release/github',
67
- {
68
- assets: [
69
- {
70
- path: `./release/${ process.env.CIRCLE_PROJECT_REPONAME }.zip`,
71
- label: `${ process.env.CIRCLE_PROJECT_REPONAME }.zip`,
72
- },
73
- ],
74
- // Only post GH PR comments for alpha, hotfix/*, and release branches.
75
- successComment: [ 'alpha', 'hotfix', 'release' ].includes( branchType ),
76
- },
80
+ "@semantic-release/github",
81
+ githubConfig,
77
82
  ],
78
83
  ],
79
84
  };
@@ -109,7 +114,7 @@ const getConfig = ( { gitBranchName } ) => {
109
114
  path: '@semantic-release/git',
110
115
  assets,
111
116
  message:
112
- 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
117
+ 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
113
118
  } );
114
119
  } else {
115
120
  utils.log(
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A proxy for the semantic-release executable.
3
+ * Note: most Newspack repos use the `release` script.
4
+ * Only newspack-theme currently uses this script.
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ const spawn = require( 'cross-spawn' );
10
+ const utils = require( './utils/index.js' );
11
+ const sr = require.resolve( 'semantic-release/bin/semantic-release' );
12
+
13
+ utils.log( 'Starting TypeScript check…' );
14
+
15
+ const args = process.argv.slice( 2 ) || [];
16
+
17
+ const result = spawn.sync( sr, args, {
18
+ stdio: 'inherit',
19
+ } );
20
+
21
+ if ( result.status === 0 ) {
22
+ utils.log( 'All good!' );
23
+ }
24
+
25
+ process.exit( result.status );
@@ -1,13 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const spawn = require( 'cross-spawn' );
4
- const path = require( 'path' );
5
- const modules = require( './utils/modules' );
6
4
  const utils = require( './utils/index.js' );
5
+ const tsc = require.resolve( 'typescript/bin/tsc' );
7
6
 
8
7
  utils.log( 'Starting TypeScript check…' );
9
8
 
10
- const result = spawn.sync( `${ process.cwd() }/node_modules/.bin/tsc`, [], {
9
+ const result = spawn.sync( tsc, [], {
11
10
  stdio: 'inherit',
12
11
  } );
13
12
 
@@ -4,18 +4,22 @@ const rootDirectory = fs.realpathSync( process.cwd() );
4
4
 
5
5
  module.exports = {
6
6
  rootDirectory,
7
- args: ( cmd, opts = [] ) => {
7
+ // Get webpack bundle args for `build` and `start` commands.
8
+ buildArgs: ( cmd, args = [] ) => {
9
+ if ( 'build' !== cmd && 'start' !== cmd ) {
10
+ return [ cmd, ...args ];
11
+ }
12
+
8
13
  const defaults = [
9
- cmd,
10
14
  '--config',
11
15
  'webpack.config.js',
12
16
  ];
13
17
 
14
18
  // Default build path: ./dist
15
- if ( ! opts.includes( '--output-path' ) ) {
19
+ if ( ! args.includes( '--output-path' ) ) {
16
20
  defaults.push( '--output-path', 'dist' );
17
21
  }
18
22
 
19
- return [ ...defaults, ...opts ];
23
+ return [ cmd, ...defaults, ...args ];
20
24
  },
21
25
  };
@@ -5,18 +5,19 @@ const modules = require( './utils/modules' );
5
5
  const utils = require( './utils/index.js' );
6
6
  const wpScripts = require.resolve( '@wordpress/scripts/bin/wp-scripts' );
7
7
 
8
- utils.log( 'Starting to build…' );
9
-
10
8
  const args = process.argv.slice( 2 );
9
+ const cmd = args.shift();
10
+
11
+ utils.log( `Running ${ cmd }...` );
11
12
 
12
- const buildResult = spawn.sync( wpScripts, modules.args( 'build', args ), {
13
+ const result = spawn.sync( wpScripts, modules.buildArgs( cmd, args ), {
13
14
  cwd: modules.rootDirectory,
14
15
  stdio: 'inherit',
15
- env: { ...process.env, NODE_ENV: 'production' },
16
+ env: { ...process.env, NODE_ENV: 'build' === cmd ? 'production' : 'development' },
16
17
  } );
17
18
 
18
- if ( buildResult.status === 0 ) {
19
- utils.log( 'Build succeeded!' );
19
+ if ( result.status === 0 ) {
20
+ utils.log( `${ cmd } complete!` );
20
21
  }
21
22
 
22
- process.exit( buildResult.status );
23
+ process.exit( result.status );
@@ -1,5 +1,5 @@
1
1
  description: >
2
- Lint the JS & SCSS files.
2
+ Lint the JS & SCSS (temporarily skipped) files.
3
3
 
4
4
  executor: default
5
5
 
@@ -8,4 +8,4 @@ steps:
8
8
  - set_node_version
9
9
  - run:
10
10
  name: Run Linter
11
- command: npm run lint
11
+ command: npm run lint:js # Temporarily skip linting SCSS due to stylelint config updates. Remove :js when ready to re-enable linting of SCSS.
package/scripts/proxy.js DELETED
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Run a command via newspack-script's dependencies.
5
- * Usage: newspack-scripts proxy <command> [args]
6
- */
7
-
8
- const path = require( 'path' );
9
- const spawn = require( 'cross-spawn' );
10
- const modules = require( './utils/modules' );
11
- const utils = require( './utils/index.js' );
12
-
13
- const args = process.argv.slice( 2 );
14
- const dependency = args.shift();
15
- const cmd = path.resolve( __dirname, `../node_modules/.bin/${ dependency }` );
16
-
17
- utils.log( `Running command: ${ dependency } ${ args.join( ' ' ) }` );
18
-
19
- const result = spawn.sync(
20
- cmd,
21
- args,
22
- {
23
- cwd: modules.rootDirectory,
24
- stdio: 'inherit',
25
- env: { ...process.env, NODE_ENV: 'semantic-release' === cmd ? 'production' : 'development' },
26
- }
27
- );
28
-
29
- process.exit( result.status );
package/scripts/watch.js DELETED
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- const spawn = require( 'cross-spawn' );
4
- const modules = require( './utils/modules' );
5
- const utils = require( './utils/index.js' );
6
- const wpScripts = require.resolve( '@wordpress/scripts/bin/wp-scripts' );
7
-
8
- utils.log( 'Starting to watch…' );
9
-
10
- const args = process.argv.slice( 2 );
11
-
12
- spawn.sync( wpScripts, modules.args( 'start', args ), {
13
- cwd: modules.rootDirectory,
14
- stdio: 'inherit',
15
- env: { ...process.env, NODE_ENV: 'development' },
16
- } );