newspack-scripts 5.5.1-alpha.1 → 5.5.1-alpha.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 +14 -5
- package/bin/newspack-scripts.js +2 -0
- package/config/eslintrc.js +2 -4
- package/config/getWebpackConfig.js +1 -1
- package/config/stylelint.config.js +2 -0
- package/package.json +28 -26
- package/scripts/build.js +3 -1
- package/scripts/proxy.js +29 -0
- package/scripts/utils/modules.js +11 -7
- package/scripts/watch.js +3 -1
- package/scripts/eslint.js +0 -25
package/README.md
CHANGED
|
@@ -15,11 +15,11 @@ Will run `jest` tests. Useful flags:
|
|
|
15
15
|
|
|
16
16
|
### build
|
|
17
17
|
|
|
18
|
-
Will run `
|
|
18
|
+
Will run `wp-scripts build` to create optimised production builds.
|
|
19
19
|
|
|
20
20
|
### watch
|
|
21
21
|
|
|
22
|
-
Will run `
|
|
22
|
+
Will run `wp-scripts start` to start a development build in devserver/watch mode.
|
|
23
23
|
|
|
24
24
|
### commit
|
|
25
25
|
|
|
@@ -47,6 +47,15 @@ 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
|
+
|
|
50
59
|
---
|
|
51
60
|
|
|
52
61
|
## Semantic Release
|
|
@@ -154,10 +163,10 @@ module.exports = {
|
|
|
154
163
|
|
|
155
164
|
### stylelint
|
|
156
165
|
|
|
157
|
-
|
|
166
|
+
Use this package's stylelint executable and config file when running it, e.g.:
|
|
158
167
|
|
|
159
168
|
```shell
|
|
160
|
-
stylelint '**/*.scss' --
|
|
169
|
+
newspack-scripts proxy stylelint '**/*.scss' --customSyntax postcss-scss --config=./node_modules/newspack-scripts/config/stylelint.config.js
|
|
161
170
|
```
|
|
162
171
|
|
|
163
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._
|
|
@@ -207,4 +216,4 @@ Note that before the first time updating you'll need to set the API key for Circ
|
|
|
207
216
|
|
|
208
217
|
### `@wordpress/*` packages
|
|
209
218
|
|
|
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 `
|
|
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.
|
package/bin/newspack-scripts.js
CHANGED
package/config/eslintrc.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
const wpRecommended = require.resolve( '@wordpress/eslint-plugin/configs/recommended' );
|
|
2
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
3
|
|
|
6
|
-
// Assume `@wordpress/*` packages are available. This is because `
|
|
4
|
+
// Assume `@wordpress/*` packages are available. This is because `@wordpress/scripts` is using
|
|
7
5
|
// Dependency Extraction Webpack Plugin to use core WP packages instead of those from
|
|
8
6
|
// node_modules. The packages should still be part of the project (they are listed in this
|
|
9
7
|
// project's package.json) so that they are available in testing environment.
|
|
@@ -34,7 +32,7 @@ module.exports = {
|
|
|
34
32
|
},
|
|
35
33
|
},
|
|
36
34
|
},
|
|
37
|
-
ignorePatterns: [ 'dist/', 'node_modules/' ],
|
|
35
|
+
ignorePatterns: [ 'dist/', 'node_modules/', 'scripts/' ],
|
|
38
36
|
parser: '@typescript-eslint/parser',
|
|
39
37
|
rules: {
|
|
40
38
|
'arrow-parens': 'off',
|
|
@@ -12,7 +12,7 @@ module.exports = ( ...args ) => {
|
|
|
12
12
|
|
|
13
13
|
// Ensure that webpack resolves modules from the Newspack Scripts node_modules as well as the root repo's node_modules.
|
|
14
14
|
config.resolve.modules = [
|
|
15
|
-
path.resolve( 'node_modules
|
|
15
|
+
path.resolve( __dirname, '../node_modules' ),
|
|
16
16
|
'node_modules',
|
|
17
17
|
];
|
|
18
18
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newspack-scripts",
|
|
3
|
-
"version": "5.5.1-alpha.
|
|
3
|
+
"version": "5.5.1-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"newspack-scripts": "./bin/newspack-scripts.js"
|
|
7
7
|
},
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "ISC",
|
|
10
|
-
"
|
|
10
|
+
"dependencies": {
|
|
11
11
|
"@commitlint/cli": "^17.8.1",
|
|
12
12
|
"@commitlint/config-conventional": "^17.8.1",
|
|
13
13
|
"@rushstack/eslint-patch": "^1.10.3",
|
|
@@ -16,8 +16,28 @@
|
|
|
16
16
|
"@testing-library/jest-dom": "^5.17.0",
|
|
17
17
|
"@testing-library/react": "^13.4.0",
|
|
18
18
|
"@typescript-eslint/parser": "^7.13.0",
|
|
19
|
+
"@wordpress/a11y": "^4.0.0",
|
|
20
|
+
"@wordpress/api-fetch": "^7.0.0",
|
|
19
21
|
"@wordpress/base-styles": "^5.0.0",
|
|
22
|
+
"@wordpress/block-editor": "^13.0.0",
|
|
23
|
+
"@wordpress/blocks": "^13.0.0",
|
|
24
|
+
"@wordpress/components": "^28.0.0",
|
|
25
|
+
"@wordpress/compose": "^7.0.0",
|
|
26
|
+
"@wordpress/data": "^10.0.0",
|
|
27
|
+
"@wordpress/date": "^5.0.0",
|
|
28
|
+
"@wordpress/dom-ready": "^4.0.0",
|
|
29
|
+
"@wordpress/edit-post": "^8.0.0",
|
|
30
|
+
"@wordpress/element": "^6.0.0",
|
|
31
|
+
"@wordpress/escape-html": "^3.0.0",
|
|
32
|
+
"@wordpress/eslint-plugin": "^19.0.0",
|
|
33
|
+
"@wordpress/hooks": "^4.0.0",
|
|
34
|
+
"@wordpress/html-entities": "^4.0.0",
|
|
35
|
+
"@wordpress/i18n": "^5.0.0",
|
|
36
|
+
"@wordpress/icons": "^10.0.0",
|
|
37
|
+
"@wordpress/keycodes": "^4.0.0",
|
|
38
|
+
"@wordpress/plugins": "^7.0.0",
|
|
20
39
|
"@wordpress/scripts": "^28.0.0",
|
|
40
|
+
"@wordpress/url": "^4.0.0",
|
|
21
41
|
"autoprefixer": "^10.4.19",
|
|
22
42
|
"commitizen": "^4.3.0",
|
|
23
43
|
"cross-spawn": "^7.0.3",
|
|
@@ -32,34 +52,16 @@
|
|
|
32
52
|
"postcss-focus-within": "^5.0.4",
|
|
33
53
|
"postcss-scss": "^4.0.9",
|
|
34
54
|
"prettier": "^3.3.2",
|
|
35
|
-
"semantic-release": "^
|
|
55
|
+
"semantic-release": "^19.0.5",
|
|
36
56
|
"semantic-release-version-bump": "^1.4.1",
|
|
37
|
-
"stylelint": "^
|
|
38
|
-
"stylelint-config-standard": "^
|
|
57
|
+
"stylelint": "^16.6.1",
|
|
58
|
+
"stylelint-config-standard": "^36.0.0",
|
|
39
59
|
"typescript": "^5.4.5",
|
|
40
60
|
"yargs": "^17.7.2"
|
|
41
61
|
},
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
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"
|
|
62
|
+
"overrides": {
|
|
63
|
+
"history": "4.9.0",
|
|
64
|
+
"path-to-regexp": "1.7.0"
|
|
63
65
|
},
|
|
64
66
|
"scripts": {
|
|
65
67
|
"semantic-release": "semantic-release"
|
package/scripts/build.js
CHANGED
|
@@ -7,7 +7,9 @@ const wpScripts = require.resolve( '@wordpress/scripts/bin/wp-scripts' );
|
|
|
7
7
|
|
|
8
8
|
utils.log( 'Starting to build…' );
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const args = process.argv.slice( 2 );
|
|
11
|
+
|
|
12
|
+
const buildResult = spawn.sync( wpScripts, modules.args( 'build', args ), {
|
|
11
13
|
cwd: modules.rootDirectory,
|
|
12
14
|
stdio: 'inherit',
|
|
13
15
|
env: { ...process.env, NODE_ENV: 'production' },
|
package/scripts/proxy.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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/utils/modules.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
const fs = require( 'fs' );
|
|
2
|
-
const path = require( 'path' );
|
|
3
2
|
|
|
4
3
|
const rootDirectory = fs.realpathSync( process.cwd() );
|
|
5
4
|
|
|
6
5
|
module.exports = {
|
|
7
6
|
rootDirectory,
|
|
8
|
-
args: cmd =>
|
|
9
|
-
[
|
|
7
|
+
args: ( cmd, opts = [] ) => {
|
|
8
|
+
const defaults = [
|
|
10
9
|
cmd,
|
|
11
10
|
'--config',
|
|
12
11
|
'webpack.config.js',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
// Default build path: ./dist
|
|
15
|
+
if ( ! opts.includes( '--output-path' ) ) {
|
|
16
|
+
defaults.push( '--output-path', 'dist' );
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return [ ...defaults, ...opts ];
|
|
20
|
+
},
|
|
17
21
|
};
|
package/scripts/watch.js
CHANGED
|
@@ -7,7 +7,9 @@ const wpScripts = require.resolve( '@wordpress/scripts/bin/wp-scripts' );
|
|
|
7
7
|
|
|
8
8
|
utils.log( 'Starting to watch…' );
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const args = process.argv.slice( 2 );
|
|
11
|
+
|
|
12
|
+
spawn.sync( wpScripts, modules.args( 'start', args ), {
|
|
11
13
|
cwd: modules.rootDirectory,
|
|
12
14
|
stdio: 'inherit',
|
|
13
15
|
env: { ...process.env, NODE_ENV: 'development' },
|
package/scripts/eslint.js
DELETED
|
@@ -1,25 +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( 'Linting JS…' );
|
|
9
|
-
|
|
10
|
-
const args = process.argv.slice( 2 );
|
|
11
|
-
|
|
12
|
-
const result = spawn.sync(
|
|
13
|
-
wpScripts,
|
|
14
|
-
[
|
|
15
|
-
'lint-js',
|
|
16
|
-
...args,
|
|
17
|
-
],
|
|
18
|
-
{
|
|
19
|
-
cwd: modules.rootDirectory,
|
|
20
|
-
stdio: 'inherit',
|
|
21
|
-
env: { ...process.env, NODE_ENV: 'development' },
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
process.exit( result.status );
|