newspack-scripts 5.6.0-alpha.1 → 5.6.0-alpha.3
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/bin/newspack-scripts.js +2 -5
- package/config/eslintrc.js +2 -3
- package/config/prettier.config.js +6 -0
- package/config/stylelint.config.js +3 -2
- package/package.json +6 -5
- package/scripts/commitlint.js +2 -1
- package/scripts/semantic-release.js +25 -0
- package/scripts/typescript-check.js +2 -3
- package/scripts/utils/modules.js +8 -4
- package/scripts/{build.js → wp-scripts.js} +8 -7
- package/scripts/proxy.js +0 -29
- package/scripts/watch.js +0 -16
package/bin/newspack-scripts.js
CHANGED
|
@@ -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(
|
package/config/eslintrc.js
CHANGED
|
@@ -32,14 +32,12 @@ module.exports = {
|
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
|
-
ignorePatterns: [ 'dist/', 'node_modules/', 'scripts/' ],
|
|
36
|
-
parser: '@typescript-eslint/parser',
|
|
35
|
+
ignorePatterns: [ 'dist/', 'node_modules/', 'release/', 'scripts/', '/vendor' ],
|
|
37
36
|
rules: {
|
|
38
37
|
'arrow-parens': 'off',
|
|
39
38
|
camelcase: 'off',
|
|
40
39
|
'no-console': 'off',
|
|
41
40
|
'no-mixed-operators': 'off',
|
|
42
|
-
'space-before-function-paren': 'off',
|
|
43
41
|
'wrap-iife': 'off',
|
|
44
42
|
// Some dependencies are injected by WP, and should not be declared in package.json (won't be used anyway).
|
|
45
43
|
// See https://github.com/WordPress/gutenberg/blob/e035f71/packages/dependency-extraction-webpack-plugin/README.md#behavior-with-scripts
|
|
@@ -70,5 +68,6 @@ module.exports = {
|
|
|
70
68
|
'@typescript-eslint/no-shadow': 'error',
|
|
71
69
|
'@typescript-eslint/ban-ts-comment': 'warn',
|
|
72
70
|
'@typescript-eslint/no-explicit-any': 'warn',
|
|
71
|
+
'prettier/prettier': 'off',
|
|
73
72
|
},
|
|
74
73
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
extends: [
|
|
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,6 @@ module.exports = {
|
|
|
26
28
|
ignoreAnnotations: [ '/default/' ],
|
|
27
29
|
},
|
|
28
30
|
],
|
|
29
|
-
'media-query-no-invalid': null,
|
|
30
31
|
'media-feature-range-notation': null,
|
|
31
32
|
},
|
|
32
33
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newspack-scripts",
|
|
3
|
-
"version": "5.6.0-alpha.
|
|
3
|
+
"version": "5.6.0-alpha.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"newspack-scripts": "./bin/newspack-scripts.js"
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
"@wordpress/icons": "^10.0.0",
|
|
37
37
|
"@wordpress/keycodes": "^4.0.0",
|
|
38
38
|
"@wordpress/plugins": "^7.0.0",
|
|
39
|
-
"@wordpress/
|
|
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
43
|
"autoprefixer": "^10.4.19",
|
|
42
44
|
"commitizen": "^4.3.0",
|
|
@@ -54,8 +56,6 @@
|
|
|
54
56
|
"prettier": "^3.3.2",
|
|
55
57
|
"semantic-release": "^19.0.5",
|
|
56
58
|
"semantic-release-version-bump": "^1.4.1",
|
|
57
|
-
"stylelint": "^16.6.1",
|
|
58
|
-
"stylelint-config-standard": "^36.0.0",
|
|
59
59
|
"typescript": "^5.4.5",
|
|
60
60
|
"yargs": "^17.7.2"
|
|
61
61
|
},
|
|
@@ -81,5 +81,6 @@
|
|
|
81
81
|
},
|
|
82
82
|
"browserslist": [
|
|
83
83
|
"extends @wordpress/browserslist-config"
|
|
84
|
-
]
|
|
84
|
+
],
|
|
85
|
+
"prettier": "@wordpress/prettier-config"
|
|
85
86
|
}
|
package/scripts/commitlint.js
CHANGED
|
@@ -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
|
-
|
|
8
|
+
commitlint,
|
|
8
9
|
[ '--config', path.resolve( __dirname, '../config/commitlint.config.js' ) ],
|
|
9
10
|
{
|
|
10
11
|
stdio: 'inherit',
|
|
@@ -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(
|
|
9
|
+
const result = spawn.sync( tsc, [], {
|
|
11
10
|
stdio: 'inherit',
|
|
12
11
|
} );
|
|
13
12
|
|
package/scripts/utils/modules.js
CHANGED
|
@@ -4,18 +4,22 @@ const rootDirectory = fs.realpathSync( process.cwd() );
|
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
rootDirectory,
|
|
7
|
-
|
|
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 ( !
|
|
19
|
+
if ( ! args.includes( '--output-path' ) ) {
|
|
16
20
|
defaults.push( '--output-path', 'dist' );
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
return [ ...defaults, ...
|
|
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
|
|
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 (
|
|
19
|
-
utils.log(
|
|
19
|
+
if ( result.status === 0 ) {
|
|
20
|
+
utils.log( `${ cmd } complete!` );
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
process.exit(
|
|
23
|
+
process.exit( result.status );
|
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
|
-
} );
|