newspack-scripts 1.5.0 → 1.6.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/bin/newspack-scripts.js +5 -1
- package/config/eslintrc.js +4 -0
- package/package.json +7 -2
- package/scripts/commitlint.js +1 -2
- package/scripts/release.js +106 -0
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],
|
package/config/eslintrc.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// Technically not required, but issues were encountered with module resolution
|
|
2
|
+
// done by an editor plugin (prettier-atom) when ran on a codebase using newspack-scripts.
|
|
3
|
+
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
4
|
+
|
|
1
5
|
module.exports = {
|
|
2
6
|
extends: [
|
|
3
7
|
"plugin:@wordpress/eslint-plugin/recommended",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newspack-scripts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"newspack-scripts": "./bin/newspack-scripts.js"
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
"@babel/preset-env": "^7.16.4",
|
|
14
14
|
"@commitlint/cli": "^15.0.0",
|
|
15
15
|
"@commitlint/config-conventional": "^15.0.0",
|
|
16
|
+
"@semantic-release/changelog": "^6.0.1",
|
|
17
|
+
"@semantic-release/git": "^10.0.1",
|
|
16
18
|
"@testing-library/jest-dom": "^5.15.1",
|
|
17
19
|
"@testing-library/react": "^12.1.2",
|
|
18
20
|
"@wordpress/eslint-plugin": "^9.3.0",
|
|
@@ -32,6 +34,8 @@
|
|
|
32
34
|
"postcss": "^8.4.4",
|
|
33
35
|
"postcss-focus-within": "^5.0.1",
|
|
34
36
|
"prettier": "npm:wp-prettier@2.2.1-beta-1",
|
|
37
|
+
"semantic-release": "^18.0.1",
|
|
38
|
+
"semantic-release-version-bump": "^1.4.1",
|
|
35
39
|
"stylelint": "^14.1.0",
|
|
36
40
|
"stylelint-config-prettier": "^9.0.3",
|
|
37
41
|
"stylelint-prettier": "^2.0.0",
|
|
@@ -45,6 +49,7 @@
|
|
|
45
49
|
"url": "https://github.com/Automattic/newspack-scripts.git"
|
|
46
50
|
},
|
|
47
51
|
"devDependencies": {
|
|
48
|
-
"
|
|
52
|
+
"@rushstack/eslint-patch": "^1.1.0",
|
|
53
|
+
"yargs": "^17.3.0"
|
|
49
54
|
}
|
|
50
55
|
}
|
package/scripts/commitlint.js
CHANGED
|
@@ -4,10 +4,9 @@ const spawn = require("cross-spawn");
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
|
|
6
6
|
const result = spawn.sync(
|
|
7
|
-
|
|
7
|
+
`${process.cwd()}/node_modules/.bin/commitlint`,
|
|
8
8
|
["--config", path.resolve(__dirname, "../config/commitlint.config.js")],
|
|
9
9
|
{
|
|
10
|
-
cwd: path.resolve(__dirname, ".."),
|
|
11
10
|
stdio: "inherit",
|
|
12
11
|
}
|
|
13
12
|
);
|
|
@@ -0,0 +1,106 @@
|
|
|
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 { files, ...semanticReleaseArgs } = require("yargs/yargs")(
|
|
9
|
+
process.argv.slice(2)
|
|
10
|
+
).parse();
|
|
11
|
+
|
|
12
|
+
const filesList = files.split(",");
|
|
13
|
+
|
|
14
|
+
console.log(`Releasing ${process.env.CIRCLE_PROJECT_REPONAME}…`);
|
|
15
|
+
|
|
16
|
+
const config = {
|
|
17
|
+
dryRun: semanticReleaseArgs.dryRun,
|
|
18
|
+
ci: semanticReleaseArgs.ci,
|
|
19
|
+
debug: semanticReleaseArgs.debug,
|
|
20
|
+
|
|
21
|
+
branches: [
|
|
22
|
+
"release",
|
|
23
|
+
{
|
|
24
|
+
name: "alpha",
|
|
25
|
+
prerelease: "alpha",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
prepare: [
|
|
29
|
+
"@semantic-release/changelog",
|
|
30
|
+
"@semantic-release/npm",
|
|
31
|
+
[
|
|
32
|
+
// Increment the version in additional files, and the create the release archive.
|
|
33
|
+
"semantic-release-version-bump",
|
|
34
|
+
{
|
|
35
|
+
files: filesList,
|
|
36
|
+
callback: "npm run release:archive",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
{
|
|
40
|
+
path: "@semantic-release/git",
|
|
41
|
+
// These assets should be added to source control after a release.
|
|
42
|
+
assets: [
|
|
43
|
+
...filesList,
|
|
44
|
+
"package.json",
|
|
45
|
+
"package-lock.json",
|
|
46
|
+
"CHANGELOG.md",
|
|
47
|
+
],
|
|
48
|
+
message:
|
|
49
|
+
"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
plugins: [
|
|
53
|
+
"@semantic-release/commit-analyzer",
|
|
54
|
+
"@semantic-release/release-notes-generator",
|
|
55
|
+
[
|
|
56
|
+
// Do not publish on npm.
|
|
57
|
+
"@semantic-release/npm",
|
|
58
|
+
{
|
|
59
|
+
npmPublish: false,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
"semantic-release-version-bump",
|
|
63
|
+
// Add the built ZIP archive to GH release.
|
|
64
|
+
[
|
|
65
|
+
"@semantic-release/github",
|
|
66
|
+
{
|
|
67
|
+
assets: [
|
|
68
|
+
{
|
|
69
|
+
path: `./release/${process.env.CIRCLE_PROJECT_REPONAME}.zip`,
|
|
70
|
+
label: `${process.env.CIRCLE_PROJECT_REPONAME}.zip`,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const run = async () => {
|
|
79
|
+
try {
|
|
80
|
+
const result = await semanticRelease(config);
|
|
81
|
+
|
|
82
|
+
if (result) {
|
|
83
|
+
const { lastRelease, commits, nextRelease, releases } = result;
|
|
84
|
+
|
|
85
|
+
console.log(
|
|
86
|
+
`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
if (lastRelease.version) {
|
|
90
|
+
console.log(`The last release was "${lastRelease.version}".`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (const release of releases) {
|
|
94
|
+
console.log(
|
|
95
|
+
`The release was published with plugin "${release.pluginName}".`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
console.log("No release published.");
|
|
100
|
+
}
|
|
101
|
+
} catch (err) {
|
|
102
|
+
console.error("The automated release failed with %O", err);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
run();
|