newspack-scripts 3.1.1 → 3.3.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.
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const spawn = require("cross-spawn");
4
+ const utils = require("../scripts/utils/index.js");
4
5
 
5
6
  const [scriptName, ...nodeArgs] = process.argv.slice(2);
6
7
 
@@ -22,13 +23,13 @@ if (
22
23
  );
23
24
  if (result.signal) {
24
25
  if (result.signal === "SIGKILL") {
25
- console.log(
26
+ utils.log(
26
27
  "The build failed because the process exited too early. " +
27
28
  "This probably means the system ran out of memory or someone called " +
28
29
  "`kill -9` on the process."
29
30
  );
30
31
  } else if (result.signal === "SIGTERM") {
31
- console.log(
32
+ utils.log(
32
33
  "The build failed because the process exited too early. " +
33
34
  "Someone might have called `kill` or `killall`, or the system could " +
34
35
  "be shutting down."
@@ -38,5 +39,5 @@ if (
38
39
  }
39
40
  process.exit(result.status);
40
41
  } else {
41
- console.log(`Unknown script "${scriptName}".`);
42
+ utils.log(`Unknown script "${scriptName}".`);
42
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newspack-scripts",
3
- "version": "3.1.1",
3
+ "version": "3.3.0-alpha.2",
4
4
  "description": "",
5
5
  "bin": {
6
6
  "newspack-scripts": "./bin/newspack-scripts.js"
@@ -2,21 +2,35 @@
2
2
 
3
3
  const spawn = require("cross-spawn");
4
4
  const path = require("path");
5
+ const utils = require("./utils/index.js");
5
6
 
6
7
  const semanticRelease = require("semantic-release");
7
8
 
8
- const { files, ...semanticReleaseArgs } = require("yargs/yargs")(
9
+ const { files, npmPackageName, ...otherArgs } = require("yargs/yargs")(
9
10
  process.argv.slice(2)
10
11
  ).parse();
11
12
 
12
13
  const filesList = files.split(",");
13
14
 
14
- console.log(`Releasing ${process.env.CIRCLE_PROJECT_REPONAME}…`);
15
+ utils.log(`Releasing ${process.env.CIRCLE_PROJECT_REPONAME}…`);
16
+
17
+ const shouldPublishOnNPM = npmPackageName && process.env.NPM_TOKEN;
18
+
19
+ if (npmPackageName) {
20
+ if (process.env.NPM_TOKEN) {
21
+ utils.log(`Will publish on npm as ${npmPackageName}`);
22
+ } else {
23
+ utils.log(
24
+ `npm package name specified, but no NPM_TOKEN environment variable set – npm package will not be released.`,
25
+ "warning"
26
+ );
27
+ }
28
+ }
15
29
 
16
30
  const config = {
17
- dryRun: semanticReleaseArgs.dryRun,
18
- ci: semanticReleaseArgs.ci,
19
- debug: semanticReleaseArgs.debug,
31
+ dryRun: otherArgs.dryRun,
32
+ ci: otherArgs.ci,
33
+ debug: otherArgs.debug,
20
34
 
21
35
  branches: [
22
36
  // `release` branch is published on the main distribution channel (a new version on GH).
@@ -60,10 +74,10 @@ const config = {
60
74
  "@semantic-release/commit-analyzer",
61
75
  "@semantic-release/release-notes-generator",
62
76
  [
63
- // Do not publish on npm.
77
+ // Whether to publish on npm.
64
78
  "@semantic-release/npm",
65
79
  {
66
- npmPublish: false,
80
+ npmPublish: shouldPublishOnNPM,
67
81
  },
68
82
  ],
69
83
  "semantic-release-version-bump",
@@ -89,21 +103,21 @@ const run = async () => {
89
103
  if (result) {
90
104
  const { lastRelease, commits, nextRelease, releases } = result;
91
105
 
92
- console.log(
106
+ utils.log(
93
107
  `Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`
94
108
  );
95
109
 
96
110
  if (lastRelease.version) {
97
- console.log(`The last release was "${lastRelease.version}".`);
111
+ utils.log(`The last release was "${lastRelease.version}".`);
98
112
  }
99
113
 
100
114
  for (const release of releases) {
101
- console.log(
115
+ utils.log(
102
116
  `The release was published with plugin "${release.pluginName}".`
103
117
  );
104
118
  }
105
119
  } else {
106
- console.log("No release published.");
120
+ utils.log("No release published.");
107
121
  }
108
122
  } catch (err) {
109
123
  console.error("The automated release failed with %O", err);
@@ -3,13 +3,14 @@
3
3
  const spawn = require("cross-spawn");
4
4
  const path = require("path");
5
5
  const modules = require("./utils/modules");
6
+ const utils = require("./utils/index.js");
6
7
 
7
8
  const result = spawn.sync(`${process.cwd()}/node_modules/.bin/tsc`, [], {
8
9
  stdio: "inherit",
9
10
  });
10
11
 
11
12
  if (result.status === 0) {
12
- console.log("All good!");
13
+ utils.log("All good!");
13
14
  }
14
15
 
15
16
  process.exit(result.status);
@@ -0,0 +1,11 @@
1
+ const { version } = require("../../package.json");
2
+
3
+ const log = (content, type) => {
4
+ console.log(
5
+ `[newspack-scripts@${version}]${type ? `[${type}]` : ""} ${content}`
6
+ );
7
+ };
8
+
9
+ module.exports = {
10
+ log,
11
+ };