newspack-scripts 4.4.0 → 4.5.0-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/package.json +2 -1
- package/scripts/release.js +69 -54
- package/scripts/utils/index.js +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newspack-scripts",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"newspack-scripts": "./bin/newspack-scripts.js"
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"prettier": "npm:wp-prettier@^2.6.2-beta-1",
|
|
59
59
|
"semantic-release": "^19.0.5",
|
|
60
60
|
"semantic-release-version-bump": "^1.4.1",
|
|
61
|
+
"slugg": "^1.2.1",
|
|
61
62
|
"stylelint": "^14.1.0",
|
|
62
63
|
"stylelint-config-prettier": "^9.0.3",
|
|
63
64
|
"stylelint-prettier": "^2.0.0",
|
package/scripts/release.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const spawn = require("cross-spawn");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const utils = require("./utils/index.js");
|
|
6
|
+
const slugg = require("slugg");
|
|
6
7
|
|
|
7
8
|
const semanticRelease = require("semantic-release");
|
|
8
9
|
|
|
@@ -20,39 +21,67 @@ if (shouldPublishOnNPM) {
|
|
|
20
21
|
utils.log(`Will publish on npm`);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"@semantic-release/changelog",
|
|
46
|
-
|
|
47
|
-
|
|
24
|
+
const getConfig = ({ gitBranchName }) => {
|
|
25
|
+
const config = {
|
|
26
|
+
dryRun: otherArgs.dryRun,
|
|
27
|
+
ci: otherArgs.ci,
|
|
28
|
+
debug: otherArgs.debug,
|
|
29
|
+
|
|
30
|
+
branches: [
|
|
31
|
+
// `release` branch is published on the main distribution channel (a new version on GH).
|
|
32
|
+
"release",
|
|
33
|
+
// `alpha` branch – for regular pre-releases.
|
|
34
|
+
{
|
|
35
|
+
name: "alpha",
|
|
36
|
+
prerelease: true,
|
|
37
|
+
},
|
|
38
|
+
// `hotfix/*` branches – for releases outside of the release schedule.
|
|
39
|
+
{
|
|
40
|
+
name: "hotfix/*",
|
|
41
|
+
// With `prerelease: true`, the `name` would be used for the pre-release tag. A name with a `/`
|
|
42
|
+
// is not valid, though. See https://semver.org/#spec-item-9.
|
|
43
|
+
prerelease: slugg(gitBranchName),
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
prepare: ["@semantic-release/changelog", "@semantic-release/npm"],
|
|
47
|
+
plugins: [
|
|
48
|
+
"@semantic-release/commit-analyzer",
|
|
49
|
+
"@semantic-release/release-notes-generator",
|
|
50
|
+
[
|
|
51
|
+
// Whether to publish on npm.
|
|
52
|
+
"@semantic-release/npm",
|
|
53
|
+
{
|
|
54
|
+
npmPublish: shouldPublishOnNPM,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
"semantic-release-version-bump",
|
|
58
|
+
// Add the built ZIP archive to GH release.
|
|
59
|
+
[
|
|
60
|
+
"@semantic-release/github",
|
|
61
|
+
{
|
|
62
|
+
assets: [
|
|
63
|
+
{
|
|
64
|
+
path: `./release/${process.env.CIRCLE_PROJECT_REPONAME}.zip`,
|
|
65
|
+
label: `${process.env.CIRCLE_PROJECT_REPONAME}.zip`,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Unless on a hotfix branch, add a commit that updates the files.
|
|
74
|
+
if (gitBranchName.indexOf("hotfix/") !== 0) {
|
|
75
|
+
utils.log(`Plugin files and the changelog will be updated.`);
|
|
76
|
+
config.prepare.push([
|
|
48
77
|
// Increment the version in additional files, and the create the release archive.
|
|
49
78
|
"semantic-release-version-bump",
|
|
50
79
|
{
|
|
51
80
|
files: filesList,
|
|
52
81
|
callback: "npm run release:archive",
|
|
53
82
|
},
|
|
54
|
-
]
|
|
55
|
-
{
|
|
83
|
+
]);
|
|
84
|
+
config.prepare.push({
|
|
56
85
|
path: "@semantic-release/git",
|
|
57
86
|
// These assets should be added to source control after a release.
|
|
58
87
|
assets: [
|
|
@@ -63,37 +92,23 @@ const config = {
|
|
|
63
92
|
],
|
|
64
93
|
message:
|
|
65
94
|
"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
npmPublish: shouldPublishOnNPM,
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
"semantic-release-version-bump",
|
|
79
|
-
// Add the built ZIP archive to GH release.
|
|
80
|
-
[
|
|
81
|
-
"@semantic-release/github",
|
|
82
|
-
{
|
|
83
|
-
assets: [
|
|
84
|
-
{
|
|
85
|
-
path: `./release/${process.env.CIRCLE_PROJECT_REPONAME}.zip`,
|
|
86
|
-
label: `${process.env.CIRCLE_PROJECT_REPONAME}.zip`,
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
],
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
utils.log(
|
|
98
|
+
`This is a hotfix branch, plugin files and the changelog will *not* be updated.`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return config;
|
|
92
103
|
};
|
|
93
104
|
|
|
94
105
|
const run = async () => {
|
|
95
106
|
try {
|
|
96
|
-
const
|
|
107
|
+
const gitBranch = await utils.getGitBranch();
|
|
108
|
+
|
|
109
|
+
const result = await semanticRelease(
|
|
110
|
+
getConfig({ gitBranchName: gitBranch })
|
|
111
|
+
);
|
|
97
112
|
|
|
98
113
|
if (result) {
|
|
99
114
|
const { lastRelease, commits, nextRelease, releases } = result;
|
package/scripts/utils/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const { exec } = require("child_process");
|
|
2
|
+
|
|
1
3
|
const { version } = require("../../package.json");
|
|
2
4
|
|
|
3
5
|
const log = (content, type) => {
|
|
@@ -6,6 +8,18 @@ const log = (content, type) => {
|
|
|
6
8
|
);
|
|
7
9
|
};
|
|
8
10
|
|
|
11
|
+
const getGitBranch = () =>
|
|
12
|
+
new Promise((resolve, reject) => {
|
|
13
|
+
return exec("git rev-parse --abbrev-ref HEAD", (err, stdout) => {
|
|
14
|
+
if (err) {
|
|
15
|
+
reject(`getGitBranch Error: ${err}`);
|
|
16
|
+
} else if (typeof stdout === "string") {
|
|
17
|
+
resolve(stdout.trim());
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
9
22
|
module.exports = {
|
|
10
23
|
log,
|
|
24
|
+
getGitBranch,
|
|
11
25
|
};
|