newspack-scripts 1.4.4 → 1.6.0
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 +9 -1
- package/bin/newspack-scripts.js +5 -1
- package/config/commitlint.config.js +1 -0
- package/package.json +12 -9
- package/scripts/commit.js +12 -0
- package/scripts/commitlint.js +14 -0
- package/scripts/release.js +108 -0
- package/scripts/utils/modules.js +1 -2
package/README.md
CHANGED
|
@@ -19,6 +19,14 @@ Will run `calypso-build`, creating optimised production builds.
|
|
|
19
19
|
|
|
20
20
|
Will run `calypso-build` in watch mode.
|
|
21
21
|
|
|
22
|
+
### commit
|
|
23
|
+
|
|
24
|
+
Uses [`commitizen`](https://www.npmjs.com/package/commitizen) to create a structured commit message.
|
|
25
|
+
|
|
26
|
+
### commitlint
|
|
27
|
+
|
|
28
|
+
Lints to commit message, to be used in a git `commit-msg` hook.
|
|
29
|
+
|
|
22
30
|
## Available configs
|
|
23
31
|
|
|
24
32
|
This package exposes a couple of configuration files.
|
|
@@ -76,4 +84,4 @@ Install `stylelint` via npm and reference this package's config file when runnin
|
|
|
76
84
|
stylelint '**/*.scss' --syntax scss --config=./node_modules/newspack-scripts/config/stylelint.config.js
|
|
77
85
|
```
|
|
78
86
|
|
|
79
|
-
_Note:
|
|
87
|
+
_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._
|
package/bin/newspack-scripts.js
CHANGED
|
@@ -4,7 +4,11 @@ const spawn = require("cross-spawn");
|
|
|
4
4
|
|
|
5
5
|
const [scriptName, ...nodeArgs] = process.argv.slice(2);
|
|
6
6
|
|
|
7
|
-
if (
|
|
7
|
+
if (
|
|
8
|
+
["test", "build", "start", "commit", "commitlint", "release"].includes(
|
|
9
|
+
scriptName
|
|
10
|
+
)
|
|
11
|
+
) {
|
|
8
12
|
const result = spawn.sync(
|
|
9
13
|
process.execPath,
|
|
10
14
|
[require.resolve("../scripts/" + scriptName), ...nodeArgs],
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = { extends: ["@commitlint/config-conventional"] };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newspack-scripts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"newspack-scripts": "./bin/newspack-scripts.js"
|
|
@@ -11,13 +11,19 @@
|
|
|
11
11
|
"@automattic/calypso-build": "^10.0.0",
|
|
12
12
|
"@babel/eslint-parser": "^7.16.3",
|
|
13
13
|
"@babel/preset-env": "^7.16.4",
|
|
14
|
+
"@commitlint/cli": "^15.0.0",
|
|
15
|
+
"@commitlint/config-conventional": "^15.0.0",
|
|
16
|
+
"@semantic-release/changelog": "^6.0.1",
|
|
17
|
+
"@semantic-release/git": "^10.0.1",
|
|
14
18
|
"@testing-library/jest-dom": "^5.15.1",
|
|
15
19
|
"@testing-library/react": "^12.1.2",
|
|
16
20
|
"@wordpress/eslint-plugin": "^9.3.0",
|
|
17
21
|
"@wordpress/stylelint-config": "^19.1.0",
|
|
18
22
|
"autoprefixer": "^10.4.0",
|
|
19
23
|
"babel-jest": "^27.4.2",
|
|
24
|
+
"commitizen": "^4.2.4",
|
|
20
25
|
"cross-spawn": "^7.0.3",
|
|
26
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
21
27
|
"eslint": "^7.32.0",
|
|
22
28
|
"eslint-config-prettier": "^8.3.0",
|
|
23
29
|
"eslint-plugin-import": "^2.25.3",
|
|
@@ -28,16 +34,13 @@
|
|
|
28
34
|
"postcss": "^8.4.4",
|
|
29
35
|
"postcss-focus-within": "^5.0.1",
|
|
30
36
|
"prettier": "npm:wp-prettier@2.2.1-beta-1",
|
|
31
|
-
"
|
|
37
|
+
"semantic-release": "^18.0.1",
|
|
38
|
+
"semantic-release-version-bump": "^1.4.1",
|
|
39
|
+
"stylelint": "^14.1.0",
|
|
32
40
|
"stylelint-config-prettier": "^9.0.3",
|
|
33
|
-
"stylelint-prettier": "^
|
|
41
|
+
"stylelint-prettier": "^2.0.0",
|
|
34
42
|
"webpack": "^5.65.0"
|
|
35
43
|
},
|
|
36
|
-
"overrides": {
|
|
37
|
-
"stylelint-prettier": {
|
|
38
|
-
"prettier": "npm:wp-prettier@2.2.1-beta-1"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
44
|
"scripts": {
|
|
42
45
|
"semantic-release": "semantic-release"
|
|
43
46
|
},
|
|
@@ -46,6 +49,6 @@
|
|
|
46
49
|
"url": "https://github.com/Automattic/newspack-scripts.git"
|
|
47
50
|
},
|
|
48
51
|
"devDependencies": {
|
|
49
|
-
"
|
|
52
|
+
"yargs": "^17.3.0"
|
|
50
53
|
}
|
|
51
54
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const bootstrap = require("commitizen/dist/cli/git-cz").bootstrap;
|
|
5
|
+
const cliPath = path.resolve(require.resolve("commitizen"), "../..");
|
|
6
|
+
|
|
7
|
+
bootstrap({
|
|
8
|
+
cliPath,
|
|
9
|
+
config: {
|
|
10
|
+
path: "cz-conventional-changelog",
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const spawn = require("cross-spawn");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const result = spawn.sync(
|
|
7
|
+
`${process.cwd()}/node_modules/.bin/commitlint`,
|
|
8
|
+
["--config", path.resolve(__dirname, "../config/commitlint.config.js")],
|
|
9
|
+
{
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
process.exit(result.status);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const spawn = require("cross-spawn");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const semanticRelease = require("semantic-release");
|
|
7
|
+
|
|
8
|
+
const PROJECT_NAME = path.basename(process.cwd());
|
|
9
|
+
|
|
10
|
+
const { files, ...semanticReleaseArgs } = require("yargs/yargs")(
|
|
11
|
+
process.argv.slice(2)
|
|
12
|
+
).parse();
|
|
13
|
+
|
|
14
|
+
const filesList = files.split(",");
|
|
15
|
+
|
|
16
|
+
console.log(`Releasing ${PROJECT_NAME}…`);
|
|
17
|
+
|
|
18
|
+
const config = {
|
|
19
|
+
dryRun: semanticReleaseArgs.dryRun,
|
|
20
|
+
ci: semanticReleaseArgs.ci,
|
|
21
|
+
debug: semanticReleaseArgs.debug,
|
|
22
|
+
|
|
23
|
+
branches: [
|
|
24
|
+
"release",
|
|
25
|
+
{
|
|
26
|
+
name: "alpha",
|
|
27
|
+
prerelease: "alpha",
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
prepare: [
|
|
31
|
+
"@semantic-release/changelog",
|
|
32
|
+
"@semantic-release/npm",
|
|
33
|
+
[
|
|
34
|
+
// Increment the version in additional files, and the create the release archive.
|
|
35
|
+
"semantic-release-version-bump",
|
|
36
|
+
{
|
|
37
|
+
files: filesList,
|
|
38
|
+
callback: "npm run release:archive",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
{
|
|
42
|
+
path: "@semantic-release/git",
|
|
43
|
+
// These assets should be added to source control after a release.
|
|
44
|
+
assets: [
|
|
45
|
+
...filesList,
|
|
46
|
+
"package.json",
|
|
47
|
+
"package-lock.json",
|
|
48
|
+
"CHANGELOG.md",
|
|
49
|
+
],
|
|
50
|
+
message:
|
|
51
|
+
"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
plugins: [
|
|
55
|
+
"@semantic-release/commit-analyzer",
|
|
56
|
+
"@semantic-release/release-notes-generator",
|
|
57
|
+
[
|
|
58
|
+
// Do not publish on npm.
|
|
59
|
+
"@semantic-release/npm",
|
|
60
|
+
{
|
|
61
|
+
npmPublish: false,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
"semantic-release-version-bump",
|
|
65
|
+
// Add the built ZIP archive to GH release.
|
|
66
|
+
[
|
|
67
|
+
"@semantic-release/github",
|
|
68
|
+
{
|
|
69
|
+
assets: [
|
|
70
|
+
{
|
|
71
|
+
path: `./release/${PROJECT_NAME}.zip`,
|
|
72
|
+
label: `${PROJECT_NAME}.zip`,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const run = async () => {
|
|
81
|
+
try {
|
|
82
|
+
const result = await semanticRelease(config);
|
|
83
|
+
|
|
84
|
+
if (result) {
|
|
85
|
+
const { lastRelease, commits, nextRelease, releases } = result;
|
|
86
|
+
|
|
87
|
+
console.log(
|
|
88
|
+
`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
if (lastRelease.version) {
|
|
92
|
+
console.log(`The last release was "${lastRelease.version}".`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
for (const release of releases) {
|
|
96
|
+
console.log(
|
|
97
|
+
`The release was published with plugin "${release.pluginName}".`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
console.log("No release published.");
|
|
102
|
+
}
|
|
103
|
+
} catch (err) {
|
|
104
|
+
console.error("The automated release failed with %O", err);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
run();
|
package/scripts/utils/modules.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
2
|
|
|
4
3
|
module.exports = {
|
|
5
4
|
rootDirectory: fs.realpathSync(process.cwd()),
|
|
6
|
-
calypsoBuild: require.resolve("@automattic/calypso-build/bin/calypso-build")
|
|
5
|
+
calypsoBuild: require.resolve("@automattic/calypso-build/bin/calypso-build"),
|
|
7
6
|
};
|