@deot/dev-releaser 1.1.1 → 2.0.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/dist/index.cjs.js CHANGED
@@ -1,603 +1,617 @@
1
1
  'use strict';
2
2
 
3
- var chalk = require('chalk');
4
- var devShared = require('@deot/dev-shared');
5
- var path = require('node:path');
6
- var fs = require('fs-extra');
7
- var node_module = require('node:module');
8
- var parser = require('conventional-commits-parser');
9
- var semver = require('semver');
10
- var inquirer = require('inquirer');
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const chalk = require('chalk');
6
+ const devShared = require('@deot/dev-shared');
7
+ const path = require('node:path');
8
+ const fs = require('fs-extra');
9
+ const node_module = require('node:module');
10
+ const parser = require('conventional-commits-parser');
11
+ const semver = require('semver');
12
+ const inquirer = require('inquirer');
11
13
 
12
14
  function _interopNamespaceDefault(e) {
13
- var n = Object.create(null);
14
- if (e) {
15
- Object.keys(e).forEach(function (k) {
16
- if (k !== 'default') {
17
- var d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: function () { return e[k]; }
21
- });
22
- }
23
- });
24
- }
25
- n.default = e;
26
- return Object.freeze(n);
15
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
16
+ if (e) {
17
+ for (const k in e) {
18
+ if (k !== 'default') {
19
+ const d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: () => e[k]
23
+ });
24
+ }
25
+ }
26
+ }
27
+ n.default = e;
28
+ return Object.freeze(n);
27
29
  }
28
30
 
29
- var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
31
+ const path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
30
32
 
31
33
  const cwd = process.cwd();
32
34
  const require$ = node_module.createRequire(cwd);
33
35
  const { prompt } = inquirer;
34
- const HASH = '-hash-';
35
- const SUFFIX = '🐒💨🙊';
36
+ const HASH = "-hash-";
37
+ const SUFFIX = "🐒💨🙊";
36
38
  const parserOptions = {
37
- noteKeywords: ['BREAKING CHANGE', 'Breaking Change']
39
+ noteKeywords: ["BREAKING CHANGE", "Breaking Change"]
38
40
  };
39
- const reBreaking = new RegExp(`(${parserOptions.noteKeywords.join(')|(')})`);
41
+ const reBreaking = new RegExp(`(${parserOptions.noteKeywords.join(")|(")})`);
40
42
  class Release {
41
- packageDir;
42
- packageName;
43
- packageFolderName;
44
- packageOptions;
45
- packageRelation;
46
- config;
47
- changeLog;
48
- version;
49
- commits;
50
- commandOptions;
51
- constructor(config, commandOptions) {
52
- const { packageDir, packageRelation } = devShared.Locals.impl();
53
- if (typeof config === 'string') {
54
- let packageFolderName = config;
55
- let packageDir$ = path__namespace.resolve(packageDir, packageFolderName);
56
- config = {
57
- dir: packageDir$,
58
- name: packageFolderName
59
- };
60
- }
61
- this.packageDir = config.dir;
62
- this.packageName = devShared.Locals.getPackageName(config.name);
63
- this.packageFolderName = config.name;
64
- this.packageOptions = require$(`${this.packageDir}/package.json`);
65
- this.packageRelation = packageRelation[this.packageName] || [];
66
- this.config = config;
67
- this.commits = [];
68
- this.changeLog = '';
69
- this.version = '';
70
- this.commandOptions = commandOptions;
43
+ packageDir;
44
+ packageName;
45
+ packageFolderName;
46
+ packageOptions;
47
+ packageRelation;
48
+ config;
49
+ changeLog;
50
+ version;
51
+ commits;
52
+ commandOptions;
53
+ constructor(config, commandOptions) {
54
+ const { packageDir, packageRelation } = devShared.Locals.impl();
55
+ if (typeof config === "string") {
56
+ let packageFolderName = config;
57
+ let packageDir$ = path__namespace.resolve(packageDir, packageFolderName);
58
+ config = {
59
+ dir: packageDir$,
60
+ name: packageFolderName
61
+ };
71
62
  }
72
- async parseCommits() {
73
- const { workspace } = devShared.Locals.impl();
74
- const { packageFolderName, commandOptions } = this;
75
- const [latestTag] = await this.getTags();
76
- devShared.Logger.log(chalk.yellow(`Last Release Tag`) + `: ${latestTag || '<none>'}`);
77
- let params = ['--no-pager', 'log', `${latestTag}..HEAD`, `--format=%B%n${HASH}%n%H${SUFFIX}`];
78
- let { stdout } = await devShared.Shell.exec('git', params);
79
- let skipGetLog = false;
80
- if (latestTag) {
81
- const log1 = await devShared.Shell.exec('git', ['rev-parse', latestTag]);
82
- const log2 = await devShared.Shell.exec('git', ['--no-pager', 'log', '-1', '--format=%H']);
83
- if (log1.stdout === log2.stdout) {
84
- skipGetLog = true;
85
- }
86
- }
87
- if (!skipGetLog && !stdout) {
88
- if (latestTag) {
89
- params.splice(2, 1, `${latestTag}`);
90
- }
91
- else {
92
- params.splice(2, 1, 'HEAD');
93
- }
94
- ({ stdout } = await devShared.Shell.exec('git', params));
95
- }
96
- const allowTypes = ['feat', `fix`, `break change`, `style`, `perf`, `types`, `refactor`, `chore`];
97
- const rePlugin = new RegExp(`^(${allowTypes.join('|')})${workspace ? `\\(${packageFolderName}\\)` : '(\\(.+\\))?'}: .*`, 'i');
98
- const allCommits = stdout.split(SUFFIX);
99
- const commits = allCommits
100
- .filter((commit) => {
101
- const chunk = commit.trim();
102
- return chunk && rePlugin.test(chunk);
103
- })
104
- .map((commit) => {
105
- const node = parser.sync(commit);
106
- const body = (node.body || node.footer);
107
- if (!node.type)
108
- node.type = parser.sync(node.header?.replace(/\(.+\)!?:/, ':') || '').type;
109
- if (!node.hash)
110
- node.hash = commit.split(HASH).pop()?.trim();
111
- node.breaking = reBreaking.test(body) || /!:/.test(node.header);
112
- node.effect = false;
113
- node.custom = false;
114
- return node;
115
- });
116
- if (!commits.length) {
117
- devShared.Logger.log(chalk.red(`No Commits Found.`));
118
- }
119
- else {
120
- devShared.Logger.log(chalk.yellow(`Found `)
121
- + chalk.bold(`${allCommits.length}`)
122
- + ` Commits, `
123
- + chalk.bold(`${commits.length}`)
124
- + ' Commits Valid');
125
- }
126
- const { skipUpdatePackage } = commandOptions;
127
- if (commits.length && skipUpdatePackage) {
128
- let skip = false;
129
- if (typeof skipUpdatePackage === 'boolean' && skipUpdatePackage) {
130
- let result = await prompt([
131
- {
132
- type: 'confirm',
133
- name: 'skip',
134
- message: `Skip Update(${this.packageName}@${this.packageOptions.version}):`,
135
- default: true
136
- }
137
- ]);
138
- skip = result.skip;
139
- }
140
- else if (typeof skipUpdatePackage === 'string'
141
- && (skipUpdatePackage === '*'
142
- || skipUpdatePackage.split(',').includes(this.packageName))) {
143
- skip = true;
144
- }
145
- if (skip) {
146
- devShared.Logger.log(chalk.red(`Skipping Update\n`));
147
- return;
148
- }
149
- }
150
- await this.updateVersion();
151
- await this.updateCommits(commits);
152
- const { forceUpdatePackage } = commandOptions;
153
- if (!commits.length && forceUpdatePackage) {
154
- let force = false;
155
- if (typeof forceUpdatePackage === 'boolean' && forceUpdatePackage) {
156
- let result = await prompt([
157
- {
158
- type: 'confirm',
159
- name: 'force',
160
- message: `Force Update(${this.packageName}@${this.packageOptions.version}):`,
161
- default: true
162
- }
163
- ]);
164
- force = result.force;
165
- }
166
- else if (typeof forceUpdatePackage === 'string'
167
- && (forceUpdatePackage === '*'
168
- || forceUpdatePackage.split(',').includes(this.packageName))) {
169
- force = true;
170
- }
171
- if (force) {
172
- const oldVersion = this.packageOptions.version;
173
- const versionChanged = `\`${oldVersion}\` -> \`${this.version}\``;
174
- this.commits = [
175
- {
176
- type: 'chore',
177
- header: `chore(${this.packageFolderName || 'release'}): force-publish ${versionChanged}`,
178
- hash: '',
179
- effect: false,
180
- breaking: false,
181
- custom: true
182
- }
183
- ];
184
- this.changeLog = `### Force Update Package\n\n- ${versionChanged}`.trim();
185
- }
186
- }
63
+ this.packageDir = config.dir;
64
+ this.packageName = devShared.Locals.getPackageName(config.name);
65
+ this.packageFolderName = config.name;
66
+ this.packageOptions = require$(`${this.packageDir}/package.json`);
67
+ this.packageRelation = packageRelation[this.packageName] || [];
68
+ this.config = config;
69
+ this.commits = [];
70
+ this.changeLog = "";
71
+ this.version = "";
72
+ this.commandOptions = commandOptions;
73
+ }
74
+ async parseCommits() {
75
+ const { workspace } = devShared.Locals.impl();
76
+ const { packageFolderName, commandOptions } = this;
77
+ const [latestTag] = await this.getTags();
78
+ devShared.Logger.log(chalk.yellow(`Last Release Tag`) + `: ${latestTag || "<none>"}`);
79
+ let params = ["--no-pager", "log", `${latestTag}..HEAD`, `--format=%B%n${HASH}%n%H${SUFFIX}`];
80
+ let {
81
+ stdout
82
+ } = await devShared.Shell.exec("git", params);
83
+ let skipGetLog = false;
84
+ if (latestTag) {
85
+ const log1 = await devShared.Shell.exec("git", ["rev-parse", latestTag]);
86
+ const log2 = await devShared.Shell.exec("git", ["--no-pager", "log", "-1", "--format=%H"]);
87
+ if (log1.stdout === log2.stdout) {
88
+ skipGetLog = true;
89
+ }
187
90
  }
188
- async getTags() {
189
- const { packageName } = this;
190
- const params = ['tag', '--list', `'${packageName}@*'`, '--sort', '-v:refname'];
191
- const { stdout } = await devShared.Shell.exec('git', params);
192
- return stdout.split('\n');
91
+ if (!skipGetLog && !stdout) {
92
+ if (latestTag) {
93
+ params.splice(2, 1, `${latestTag}`);
94
+ } else {
95
+ params.splice(2, 1, "HEAD");
96
+ }
97
+ ({ stdout } = await devShared.Shell.exec("git", params));
193
98
  }
194
- rebuildChangeLog(commits) {
195
- const { packageDir } = this;
196
- const { homepage, workspace } = devShared.Locals.impl();
197
- const logPath = path__namespace.resolve(packageDir, './CHANGELOG.md');
198
- const logFile = fs.existsSync(logPath) ? fs.readFileSync(logPath, 'utf-8') : '';
199
- const notes = {
200
- breaking: [],
201
- features: [],
202
- fixes: [],
203
- updates: []
204
- };
205
- const closeRegxp = /\(?(closes? )\(?#((\d+))\)/ig;
206
- const pullRegxp = /(?<!closes? )\((#(\d+))\)/ig;
207
- for (const commit of commits) {
208
- const { effect, breaking, hash, header, type } = commit;
209
- const ref = !hash || pullRegxp.test(header)
210
- ? ''
211
- : ` ([${hash?.substring(0, 7)}](${homepage}/commit/${hash}))`;
212
- let message = header?.trim();
213
- if (workspace && !effect) {
214
- message = message.replace(/\(.+\)!?:/, ':');
215
- }
216
- message = message
217
- .replace(pullRegxp, `[$1](${homepage}/pull/$2)`)
218
- .replace(closeRegxp, `[$1$2](${homepage}/issues/$2)`) + ref;
219
- if (breaking) {
220
- notes.breaking.push(message);
221
- }
222
- else if (type === 'fix') {
223
- notes.fixes.push(message);
224
- }
225
- else if (type === 'feat') {
226
- notes.features.push(message);
227
- }
228
- else {
229
- notes.updates.push(message);
230
- }
231
- }
232
- Object.keys(notes).forEach(i => {
233
- notes[i] = notes[i].filter((j) => {
234
- return !logFile.includes(j);
235
- });
236
- });
237
- const parts = [
238
- notes.breaking.length ? `### Breaking Changes\n\n- ${notes.breaking.join('\n- ')}`.trim() : '',
239
- notes.fixes.length ? `### Bugfixes\n\n- ${notes.fixes.join('\n- ')}`.trim() : '',
240
- notes.features.length ? `### Features\n\n- ${notes.features.join('\n- ')}`.trim() : '',
241
- notes.updates.length ? `### Updates\n\n- ${notes.updates.join('\n- ')}`.trim() : ''
242
- ].filter(Boolean);
243
- const newLog = parts.join('\n\n');
244
- return !parts.length || logFile.includes(newLog)
245
- ? ''
246
- : newLog;
99
+ const allowTypes = ["feat", `fix`, `break change`, `style`, `perf`, `types`, `refactor`, `chore`];
100
+ const rePlugin = new RegExp(`^(${allowTypes.join("|")})${workspace ? `\\(${packageFolderName}\\)` : "(\\(.+\\))?"}: .*`, "i");
101
+ const allCommits = stdout.split(SUFFIX);
102
+ const commits = allCommits.filter((commit) => {
103
+ const chunk = commit.trim();
104
+ return chunk && rePlugin.test(chunk);
105
+ }).map((commit) => {
106
+ const node = parser.sync(commit);
107
+ const body = node.body || node.footer;
108
+ if (!node.type)
109
+ node.type = parser.sync(node.header?.replace(/\(.+\)!?:/, ":") || "").type;
110
+ if (!node.hash)
111
+ node.hash = commit.split(HASH).pop()?.trim();
112
+ node.breaking = reBreaking.test(body) || /!:/.test(node.header);
113
+ node.effect = false;
114
+ node.custom = false;
115
+ return node;
116
+ });
117
+ if (!commits.length) {
118
+ devShared.Logger.log(chalk.red(`No Commits Found.`));
119
+ } else {
120
+ devShared.Logger.log(
121
+ chalk.yellow(`Found `) + chalk.bold(`${allCommits.length}`) + ` Commits, ` + chalk.bold(`${commits.length}`) + " Commits Valid"
122
+ );
247
123
  }
248
- async updateVersion() {
249
- const { packageOptions, commits, commandOptions } = this;
250
- const { version } = packageOptions;
251
- let newVersion = '';
252
- if (commandOptions.customVersion) {
253
- newVersion = commandOptions.customVersion;
254
- if (!(/\d+.\d+.\d+/.test(newVersion)) || version === newVersion) {
255
- let result = await prompt([
256
- {
257
- type: 'input',
258
- name: 'version',
259
- message: `Custom Update Version(${this.packageName}@${version}):`,
260
- default: '',
261
- validate: (answer) => {
262
- if (!(/\d+.\d+.\d+/.test(answer))) {
263
- return 'Version Should Be Like x.x.x';
264
- }
265
- if (answer === version) {
266
- return 'Version Should Be Diff Than Before';
267
- }
268
- return true;
269
- }
270
- }
271
- ]);
272
- newVersion = result.version;
273
- }
274
- }
275
- else {
276
- const intersection = [
277
- commandOptions.major && 'major',
278
- commandOptions.minor && 'minor',
279
- commandOptions.patch && 'patch'
280
- ].filter(i => !!i);
281
- if (intersection.length) {
282
- newVersion = semver.inc(version, intersection[0]) || '';
283
- }
284
- else {
285
- const types = new Set(commits.map(({ type }) => type));
286
- const breaking = commits.some((commit) => !!commit.breaking);
287
- const level = breaking
288
- ? 'major'
289
- : types.has('feat')
290
- ? 'minor'
291
- : 'patch';
292
- newVersion = semver.inc(version, level) || '';
293
- }
294
- }
295
- this.version = newVersion;
124
+ const { skipUpdatePackage } = commandOptions;
125
+ if (commits.length && skipUpdatePackage) {
126
+ let skip = false;
127
+ if (typeof skipUpdatePackage === "boolean" && skipUpdatePackage) {
128
+ let result = await prompt([
129
+ {
130
+ type: "confirm",
131
+ name: "skip",
132
+ message: `Skip Update(${this.packageName}@${this.packageOptions.version}):`,
133
+ default: true
134
+ }
135
+ ]);
136
+ skip = result.skip;
137
+ } else if (typeof skipUpdatePackage === "string" && (skipUpdatePackage === "*" || skipUpdatePackage.split(",").includes(this.packageName))) {
138
+ skip = true;
139
+ }
140
+ if (skip) {
141
+ devShared.Logger.log(chalk.red(`Skipping Update
142
+ `));
143
+ return;
144
+ }
296
145
  }
297
- isChanged() {
298
- return !!this.commits.length;
146
+ await this.updateVersion();
147
+ await this.updateCommits(commits);
148
+ const { forceUpdatePackage } = commandOptions;
149
+ if (!commits.length && forceUpdatePackage) {
150
+ let force = false;
151
+ if (typeof forceUpdatePackage === "boolean" && forceUpdatePackage) {
152
+ let result = await prompt([
153
+ {
154
+ type: "confirm",
155
+ name: "force",
156
+ message: `Force Update(${this.packageName}@${this.packageOptions.version}):`,
157
+ default: true
158
+ }
159
+ ]);
160
+ force = result.force;
161
+ } else if (typeof forceUpdatePackage === "string" && (forceUpdatePackage === "*" || forceUpdatePackage.split(",").includes(this.packageName))) {
162
+ force = true;
163
+ }
164
+ if (force) {
165
+ const oldVersion = this.packageOptions.version;
166
+ const versionChanged = `\`${oldVersion}\` -> \`${this.version}\``;
167
+ this.commits = [
168
+ {
169
+ type: "chore",
170
+ header: `chore(${this.packageFolderName || "release"}): force-publish ${versionChanged}`,
171
+ hash: "",
172
+ effect: false,
173
+ breaking: false,
174
+ custom: true
175
+ }
176
+ ];
177
+ this.changeLog = `### Force Update Package
178
+
179
+ - ${versionChanged}`.trim();
180
+ }
299
181
  }
300
- async updateCommits(commits, source) {
301
- if (!commits.length)
302
- return;
303
- const { packageName } = this;
304
- const olds = this.commits.map(i => JSON.stringify({ ...i, effect: false }));
305
- const newCommits = commits
306
- .filter(i => {
307
- return !olds.includes(JSON.stringify({ ...i, effect: false }));
308
- })
309
- .map(j => {
310
- return {
311
- ...j,
312
- effect: !!source
313
- };
314
- });
315
- if (newCommits.length && this.commits.length) {
316
- this.commits = this.commits.filter(i => !i.custom);
317
- }
318
- const commits$ = this.commits.concat(newCommits);
319
- if (source) {
320
- devShared.Logger.log(chalk.magenta(`MERGE COMMITS: `)
321
- + chalk.bold(`${commits.length}`) + ` Commits. `
322
- + 'merge ' + chalk.yellow(source) + ' into ' + chalk.green(packageName));
323
- }
324
- else {
325
- devShared.Logger.log(``);
326
- }
327
- const changeLog = this.rebuildChangeLog(commits$);
328
- if (changeLog) {
329
- this.commits = commits$;
330
- this.changeLog = changeLog;
331
- }
332
- else if (commits.length) {
333
- devShared.Logger.log(chalk.red(`${commits.length} Commits Already Exists.`));
334
- }
182
+ }
183
+ async getTags() {
184
+ const { packageName } = this;
185
+ const params = ["tag", "--list", `'${packageName}@*'`, "--sort", "-v:refname"];
186
+ const { stdout } = await devShared.Shell.exec("git", params);
187
+ return stdout.split("\n");
188
+ }
189
+ rebuildChangeLog(commits) {
190
+ const { packageDir } = this;
191
+ const { homepage, workspace } = devShared.Locals.impl();
192
+ const logPath = path__namespace.resolve(packageDir, "./CHANGELOG.md");
193
+ const logFile = fs.existsSync(logPath) ? fs.readFileSync(logPath, "utf-8") : "";
194
+ const notes = {
195
+ breaking: [],
196
+ features: [],
197
+ fixes: [],
198
+ updates: []
199
+ };
200
+ const closeRegxp = /\(?(closes? )\(?#((\d+))\)/ig;
201
+ const pullRegxp = /(?<!closes? )\((#(\d+))\)/ig;
202
+ for (const commit of commits) {
203
+ const { effect, breaking, hash, header, type } = commit;
204
+ const ref = !hash || pullRegxp.test(header) ? "" : ` ([${hash?.substring(0, 7)}](${homepage}/commit/${hash}))`;
205
+ let message = header?.trim();
206
+ if (workspace && !effect) {
207
+ message = message.replace(/\(.+\)!?:/, ":");
208
+ }
209
+ message = message.replace(pullRegxp, `[$1](${homepage}/pull/$2)`).replace(closeRegxp, `[$1$2](${homepage}/issues/$2)`) + ref;
210
+ if (breaking) {
211
+ notes.breaking.push(message);
212
+ } else if (type === "fix") {
213
+ notes.fixes.push(message);
214
+ } else if (type === "feat") {
215
+ notes.features.push(message);
216
+ } else {
217
+ notes.updates.push(message);
218
+ }
335
219
  }
336
- async updatePackageOptions(relationVerisons = {}) {
337
- if (!this.isChanged())
338
- return;
339
- const { packageDir, packageOptions, commandOptions } = this;
340
- const { dependencies, devDependencies } = packageOptions;
341
- const newVersion = this.version;
342
- devShared.Logger.log(chalk.yellow(`New Version: `) + `${newVersion}`);
343
- packageOptions.version = newVersion;
344
- if (Object.keys(this.packageRelation).length) {
345
- for (let packageName$ in relationVerisons) {
346
- let newVersion$ = relationVerisons[packageName$];
347
- if (dependencies?.[packageName$]) {
348
- dependencies[packageName$] = newVersion$;
349
- }
350
- if (devDependencies?.[packageName$]) {
351
- devDependencies[packageName$] = newVersion$;
352
- }
220
+ Object.keys(notes).forEach((i) => {
221
+ notes[i] = notes[i].filter((j) => {
222
+ return !logFile.includes(j);
223
+ });
224
+ });
225
+ const parts = [
226
+ notes.breaking.length ? `### Breaking Changes
227
+
228
+ - ${notes.breaking.join("\n- ")}`.trim() : "",
229
+ notes.fixes.length ? `### Bugfixes
230
+
231
+ - ${notes.fixes.join("\n- ")}`.trim() : "",
232
+ notes.features.length ? `### Features
233
+
234
+ - ${notes.features.join("\n- ")}`.trim() : "",
235
+ notes.updates.length ? `### Updates
236
+
237
+ - ${notes.updates.join("\n- ")}`.trim() : ""
238
+ ].filter(Boolean);
239
+ const newLog = parts.join("\n\n");
240
+ return !parts.length || logFile.includes(newLog) ? "" : newLog;
241
+ }
242
+ async updateVersion() {
243
+ const { packageOptions, commits, commandOptions } = this;
244
+ const { version } = packageOptions;
245
+ let newVersion = "";
246
+ if (commandOptions.customVersion) {
247
+ newVersion = commandOptions.customVersion;
248
+ if (!/\d+.\d+.\d+/.test(newVersion) || version === newVersion) {
249
+ let result = await prompt([
250
+ {
251
+ type: "input",
252
+ name: "version",
253
+ message: `Custom Update Version(${this.packageName}@${version}):`,
254
+ default: "",
255
+ validate: (answer) => {
256
+ if (!/\d+.\d+.\d+/.test(answer)) {
257
+ return "Version Should Be Like x.x.x";
258
+ }
259
+ if (answer === version) {
260
+ return "Version Should Be Diff Than Before";
261
+ }
262
+ return true;
353
263
  }
354
- }
355
- if (commandOptions.dryRun) {
356
- devShared.Logger.log(chalk.yellow(`Skipping package.json Update`));
357
- return;
358
- }
359
- devShared.Logger.log(chalk.yellow(`Updating `) + 'package.json');
360
- fs.outputFileSync(`${packageDir}/package.json`, JSON.stringify(packageOptions, null, 2));
264
+ }
265
+ ]);
266
+ newVersion = result.version;
267
+ }
268
+ } else {
269
+ const intersection = [
270
+ commandOptions.major && "major",
271
+ commandOptions.minor && "minor",
272
+ commandOptions.patch && "patch"
273
+ ].filter((i) => !!i);
274
+ if (intersection.length) {
275
+ newVersion = semver.inc(version, intersection[0]) || "";
276
+ } else {
277
+ const types = new Set(commits.map(({
278
+ type
279
+ }) => type));
280
+ const breaking = commits.some((commit) => !!commit.breaking);
281
+ const level = breaking ? "major" : types.has("feat") ? "minor" : "patch";
282
+ newVersion = semver.inc(version, level) || "";
283
+ }
361
284
  }
362
- async updateChangelog() {
363
- if (!this.isChanged())
364
- return;
365
- const { packageName, packageDir, packageOptions, commandOptions } = this;
366
- const title = `# ${packageName} ChangeLog`;
367
- const [date] = new Date().toISOString().split('T');
368
- const logPath = path__namespace.resolve(packageDir, './CHANGELOG.md');
369
- const logFile = fs.existsSync(logPath) ? fs.readFileSync(logPath, 'utf-8') : '';
370
- const oldNotes = logFile.startsWith(title) ? logFile.slice(title.length).trim() : logFile;
371
- const parts = [
372
- `## v${packageOptions.version}`,
373
- `_${date}_`,
374
- this.changeLog
375
- ].filter(Boolean);
376
- const newLog = parts.join('\n\n');
377
- if (commandOptions.dryRun) {
378
- devShared.Logger.log(chalk.yellow(`New ChangeLog:`) + `\n${newLog}`);
379
- return;
380
- }
381
- devShared.Logger.log(chalk.yellow(`Updating `) + `CHANGELOG.md`);
382
- let content = [title, newLog, oldNotes].filter(Boolean).join('\n\n');
383
- if (!content.endsWith('\n'))
384
- content += '\n';
385
- fs.writeFileSync(logPath, content, 'utf-8');
285
+ this.version = newVersion;
286
+ }
287
+ isChanged() {
288
+ return !!this.commits.length;
289
+ }
290
+ async updateCommits(commits, source) {
291
+ if (!commits.length)
292
+ return;
293
+ const { packageName } = this;
294
+ const olds = this.commits.map((i) => JSON.stringify({ ...i, effect: false }));
295
+ const newCommits = commits.filter((i) => {
296
+ return !olds.includes(JSON.stringify({ ...i, effect: false }));
297
+ }).map((j) => {
298
+ return {
299
+ ...j,
300
+ effect: !!source
301
+ };
302
+ });
303
+ if (newCommits.length && this.commits.length) {
304
+ this.commits = this.commits.filter((i) => !i.custom);
386
305
  }
387
- async test() {
388
- if (!this.isChanged())
389
- return;
390
- const { commandOptions } = this;
391
- if (commandOptions.dryRun) {
392
- devShared.Logger.log(chalk.yellow('Skipping Test'));
393
- return;
394
- }
395
- else {
396
- devShared.Logger.log(chalk.yellow('Test...'));
397
- }
398
- await devShared.Shell.exec(`npm run test -- --package-name ${this.packageName}`);
306
+ const commits$ = this.commits.concat(newCommits);
307
+ if (source) {
308
+ devShared.Logger.log(
309
+ chalk.magenta(`MERGE COMMITS: `) + chalk.bold(`${commits.length}`) + ` Commits. merge ` + chalk.yellow(source) + " into " + chalk.green(packageName)
310
+ );
311
+ } else {
312
+ devShared.Logger.log(``);
313
+ }
314
+ const changeLog = this.rebuildChangeLog(commits$);
315
+ if (changeLog) {
316
+ this.commits = commits$;
317
+ this.changeLog = changeLog;
318
+ } else if (commits.length) {
319
+ devShared.Logger.log(chalk.red(`${commits.length} Commits Already Exists.`));
399
320
  }
400
- async build() {
401
- if (!this.isChanged())
402
- return;
403
- const { commandOptions } = this;
404
- if (commandOptions.dryRun) {
405
- devShared.Logger.log(chalk.yellow('Skipping Build'));
406
- return;
321
+ }
322
+ async updatePackageOptions(relationVerisons = {}) {
323
+ if (!this.isChanged())
324
+ return;
325
+ const { packageDir, packageOptions, commandOptions } = this;
326
+ const { dependencies, devDependencies } = packageOptions;
327
+ const newVersion = this.version;
328
+ devShared.Logger.log(chalk.yellow(`New Version: `) + `${newVersion}`);
329
+ packageOptions.version = newVersion;
330
+ if (Object.keys(this.packageRelation).length) {
331
+ for (let packageName$ in relationVerisons) {
332
+ let newVersion$ = relationVerisons[packageName$];
333
+ if (dependencies?.[packageName$]) {
334
+ dependencies[packageName$] = newVersion$;
407
335
  }
408
- else {
409
- devShared.Logger.log(chalk.yellow('Build...'));
336
+ if (devDependencies?.[packageName$]) {
337
+ devDependencies[packageName$] = newVersion$;
410
338
  }
411
- await devShared.Shell.exec(`npm run build -- --package-name ${this.packageName}`);
339
+ }
412
340
  }
413
- async publish() {
414
- const { commandOptions } = this;
415
- if (!this.isChanged() || !commandOptions.publish)
416
- return;
417
- const { packageDir, packageName } = this;
418
- devShared.Logger.log(chalk.magenta(`PUBLISH: `) + packageName);
419
- if (commandOptions.dryRun) {
420
- devShared.Logger.log(chalk.yellow(`Skipping Publish`));
421
- return;
422
- }
423
- devShared.Logger.log(chalk.cyan(`\n Publishing to NPM`));
424
- await devShared.Shell.spawn('npm', ['publish', '--no-git-checks', '--access', 'public'], {
425
- cwd: packageDir
426
- });
341
+ if (commandOptions.dryRun) {
342
+ devShared.Logger.log(chalk.yellow(`Skipping package.json Update`));
343
+ return;
427
344
  }
428
- async tag() {
429
- const { commandOptions } = this;
430
- if (!this.isChanged() || !commandOptions.tag)
431
- return;
432
- const { packageDir, packageName, packageOptions } = this;
433
- devShared.Logger.log(chalk.magenta(`TAG: `) + packageName);
434
- if (commandOptions.dryRun) {
435
- devShared.Logger.log(chalk.yellow(`Skipping Git Tag`));
436
- return;
437
- }
438
- const tagName = `${packageName}@${packageOptions.version}`;
439
- devShared.Logger.log(chalk.blue(`\n Tagging`) + chalk.grey(`${tagName}`));
440
- await devShared.Shell.spawn('git', ['tag', tagName], {
441
- cwd: packageDir
442
- });
345
+ devShared.Logger.log(chalk.yellow(`Updating `) + "package.json");
346
+ fs.outputFileSync(`${packageDir}/package.json`, JSON.stringify(packageOptions, null, 2));
347
+ }
348
+ async updateChangelog() {
349
+ if (!this.isChanged())
350
+ return;
351
+ const { packageName, packageDir, packageOptions, commandOptions } = this;
352
+ const title = `# ${packageName} ChangeLog`;
353
+ const [date] = (/* @__PURE__ */ new Date()).toISOString().split("T");
354
+ const logPath = path__namespace.resolve(packageDir, "./CHANGELOG.md");
355
+ const logFile = fs.existsSync(logPath) ? fs.readFileSync(logPath, "utf-8") : "";
356
+ const oldNotes = logFile.startsWith(title) ? logFile.slice(title.length).trim() : logFile;
357
+ const parts = [
358
+ `## v${packageOptions.version}`,
359
+ `_${date}_`,
360
+ this.changeLog
361
+ ].filter(Boolean);
362
+ const newLog = parts.join("\n\n");
363
+ if (commandOptions.dryRun) {
364
+ devShared.Logger.log(chalk.yellow(`New ChangeLog:`) + `
365
+ ${newLog}`);
366
+ return;
443
367
  }
444
- async clean() {
445
- await this.cleanTagsAndKeepLastTag();
368
+ devShared.Logger.log(chalk.yellow(`Updating `) + `CHANGELOG.md`);
369
+ let content = [title, newLog, oldNotes].filter(Boolean).join("\n\n");
370
+ if (!content.endsWith("\n"))
371
+ content += "\n";
372
+ fs.writeFileSync(logPath, content, "utf-8");
373
+ }
374
+ async test() {
375
+ if (!this.isChanged())
376
+ return;
377
+ const { commandOptions } = this;
378
+ if (commandOptions.dryRun) {
379
+ devShared.Logger.log(chalk.yellow("Skipping Test"));
380
+ return;
381
+ } else {
382
+ devShared.Logger.log(chalk.yellow("Test..."));
446
383
  }
447
- async cleanTagsAndKeepLastTag() {
448
- const { commandOptions } = this;
449
- if (!commandOptions.keepLastTag)
450
- return;
451
- let tags = await this.getTags();
452
- tags = tags.slice(1).filter(i => !!i).reverse();
453
- if (!tags.length)
454
- return;
455
- const { packageName } = this;
456
- devShared.Logger.log(chalk.magenta(`CLEAN TAGS: `) + packageName);
457
- if (commandOptions.dryRun) {
458
- devShared.Logger.log(chalk.yellow(`Skipping Tags Clean`));
459
- return;
460
- }
461
- await tags
462
- .reduce((preProcess, tag) => {
463
- preProcess = preProcess
464
- .then(() => devShared.Shell.spawn('git', ['push', 'origin', '--delete', tag]))
465
- .then(() => devShared.Shell.spawn('git', ['tag', '--delete', tag]));
466
- return preProcess;
467
- }, Promise.resolve());
384
+ await devShared.Shell.exec(`npm run test -- --package-name ${this.packageName}`);
385
+ }
386
+ async build() {
387
+ if (!this.isChanged())
388
+ return;
389
+ const { commandOptions } = this;
390
+ if (commandOptions.dryRun) {
391
+ devShared.Logger.log(chalk.yellow("Skipping Build"));
392
+ return;
393
+ } else {
394
+ devShared.Logger.log(chalk.yellow("Build..."));
468
395
  }
469
- async process() {
470
- const { workspace } = devShared.Locals.impl();
471
- const { packageName, packageDir, packageFolderName } = this;
472
- if (!packageDir || !fs.pathExists(packageDir)) {
473
- throw new RangeError(`Could not find directory for package: ${packageFolderName}`);
474
- }
475
- devShared.Logger.log(chalk.cyan(`Releasing ${packageName}`) + ' from ' + chalk.grey(`${workspace}/${packageFolderName}`));
476
- await this.parseCommits();
477
- return this;
396
+ await devShared.Shell.exec(`npm run build -- --package-name ${this.packageName}`);
397
+ }
398
+ async publish() {
399
+ const { commandOptions } = this;
400
+ if (!this.isChanged() || !commandOptions.publish)
401
+ return;
402
+ const { packageDir, packageName } = this;
403
+ devShared.Logger.log(chalk.magenta(`PUBLISH: `) + packageName);
404
+ if (commandOptions.dryRun) {
405
+ devShared.Logger.log(chalk.yellow(`Skipping Publish`));
406
+ return;
407
+ }
408
+ devShared.Logger.log(chalk.cyan(`
409
+ Publishing to NPM`));
410
+ await devShared.Shell.spawn(
411
+ "npm",
412
+ ["publish", "--no-git-checks", "--access", "public"],
413
+ {
414
+ cwd: packageDir
415
+ }
416
+ );
417
+ }
418
+ async tag() {
419
+ const { commandOptions } = this;
420
+ if (!this.isChanged() || !commandOptions.tag)
421
+ return;
422
+ const { packageDir, packageName, packageOptions } = this;
423
+ devShared.Logger.log(chalk.magenta(`TAG: `) + packageName);
424
+ if (commandOptions.dryRun) {
425
+ devShared.Logger.log(chalk.yellow(`Skipping Git Tag`));
426
+ return;
427
+ }
428
+ const tagName = `${packageName}@${packageOptions.version}`;
429
+ devShared.Logger.log(chalk.blue(`
430
+ Tagging`) + chalk.grey(`${tagName}`));
431
+ await devShared.Shell.spawn(
432
+ "git",
433
+ ["tag", tagName],
434
+ {
435
+ cwd: packageDir
436
+ }
437
+ );
438
+ }
439
+ /**
440
+ * 清理tags,仅保留最后一个tag. 相当于tags仅用于记录commit开始的位置
441
+ * git push以后执行。即时删除失败了,也不会产生不必要的影响
442
+ */
443
+ async cleanTagsAndKeepLastTag() {
444
+ const { commandOptions } = this;
445
+ if (!commandOptions.keepLastTag)
446
+ return;
447
+ let tags = await this.getTags();
448
+ tags = tags.slice(1).filter((i) => !!i).reverse();
449
+ if (!tags.length)
450
+ return;
451
+ const { packageName } = this;
452
+ devShared.Logger.log(chalk.magenta(`CLEAN TAGS: `) + packageName);
453
+ if (commandOptions.dryRun) {
454
+ devShared.Logger.log(chalk.yellow(`Skipping Tags Clean`));
455
+ return;
478
456
  }
457
+ await tags.reduce(
458
+ (preProcess, tag) => {
459
+ preProcess = preProcess.then(() => devShared.Shell.spawn("git", ["push", "origin", "--delete", tag])).then(() => devShared.Shell.spawn("git", ["tag", "--delete", tag]));
460
+ return preProcess;
461
+ },
462
+ Promise.resolve()
463
+ );
464
+ }
465
+ async process() {
466
+ const { workspace } = devShared.Locals.impl();
467
+ const { packageName, packageDir, packageFolderName } = this;
468
+ if (!packageDir || !fs.pathExists(packageDir)) {
469
+ throw new RangeError(`Could not find directory for package: ${packageFolderName}`);
470
+ }
471
+ devShared.Logger.log(chalk.cyan(`Releasing ${packageName}`) + " from " + chalk.grey(`${workspace}/${packageFolderName}`));
472
+ await this.parseCommits();
473
+ return this;
474
+ }
479
475
  }
480
476
  const release = (options, commandOptions) => {
481
- return new Release(options, commandOptions);
477
+ return new Release(options, commandOptions);
482
478
  };
483
479
 
484
480
  const run = (options) => devShared.Utils.autoCatch(async () => {
485
- options = {
486
- dryRun: true,
487
- tag: true,
488
- publish: true,
489
- commit: true,
490
- push: true,
491
- keepLastTag: false,
492
- ...options
493
- };
494
- const locals = devShared.Locals.impl();
495
- if (options.dryRun) {
496
- devShared.Logger.log(chalk.magenta(`DRY RUN: `)
497
- + 'No files will be modified.');
498
- }
499
- let inputs = [];
500
- if (locals.workspace) {
501
- inputs = locals.normalizePackageFolderNames;
502
- }
503
- else {
504
- inputs = [''];
505
- }
506
- const instances = {};
507
- await inputs
508
- .reduce((preProcess, packageFolderName) => {
509
- preProcess = preProcess
510
- .then(() => release(packageFolderName, options).process())
511
- .then((instance) => {
512
- instances[packageFolderName] = instance;
513
- });
514
- return preProcess;
515
- }, Promise.resolve());
516
- devShared.Logger.log(chalk.blue(`---------------------\n`));
517
- let message = `chore(release): publish\n\n`;
518
- let relationVerisons = {};
519
- await inputs.reduce((preProcess, packageFolderName) => {
520
- const instance = instances[packageFolderName];
521
- instance.packageRelation.forEach(i => {
522
- let packageFolderName$ = devShared.Locals.getPackageFolderName(i);
523
- let instance$ = instances[packageFolderName$];
524
- if (instance$.commits.length > 0) {
525
- instance.updateCommits(instance$.commits, instance$.packageName);
526
- }
527
- });
528
- if (instance.commits.length) {
529
- preProcess = preProcess
530
- .then(() => devShared.Logger.log(chalk.magenta(`CHANGED: `) + instance.packageName))
531
- .then(() => instance.test())
532
- .then(() => instance.build())
533
- .then(() => instance.updatePackageOptions(relationVerisons))
534
- .then(() => instance.updateChangelog())
535
- .then(() => {
536
- message += `- ${instance.packageName}@${instance.packageOptions.version}\n`;
537
- relationVerisons[instance.packageName] = `^${instance.packageOptions.version}`;
538
- });
481
+ options = {
482
+ dryRun: true,
483
+ tag: true,
484
+ publish: true,
485
+ commit: true,
486
+ push: true,
487
+ keepLastTag: false,
488
+ ...options
489
+ };
490
+ const locals = devShared.Locals.impl();
491
+ if (options.dryRun) {
492
+ devShared.Logger.log(
493
+ chalk.magenta(`DRY RUN: `) + "No files will be modified."
494
+ );
495
+ }
496
+ let inputs = [];
497
+ if (locals.workspace) {
498
+ inputs = locals.normalizePackageFolderNames;
499
+ } else {
500
+ inputs = [""];
501
+ }
502
+ const instances = {};
503
+ await inputs.reduce(
504
+ (preProcess, packageFolderName) => {
505
+ preProcess = preProcess.then(() => release(packageFolderName, options).process()).then((instance) => {
506
+ instances[packageFolderName] = instance;
507
+ });
508
+ return preProcess;
509
+ },
510
+ Promise.resolve()
511
+ );
512
+ devShared.Logger.log(chalk.blue(`---------------------
513
+ `));
514
+ let message = `chore(release): publish
515
+
516
+ `;
517
+ let relationVerisons = {};
518
+ await inputs.reduce(
519
+ (preProcess, packageFolderName) => {
520
+ const instance = instances[packageFolderName];
521
+ instance.packageRelation.forEach((i) => {
522
+ let packageFolderName$ = devShared.Locals.getPackageFolderName(i);
523
+ let instance$ = instances[packageFolderName$];
524
+ if (instance$.commits.length > 0) {
525
+ instance.updateCommits(instance$.commits, instance$.packageName);
539
526
  }
540
- return preProcess;
541
- }, Promise.resolve());
542
- devShared.Logger.log(chalk.blue(`\n---------------------\n`));
543
- const isChanged = Object.keys(relationVerisons).length;
544
- if (!isChanged) {
545
- devShared.Logger.log(chalk.magenta(`COMMIT: `) + 'Nothing Chanaged Found.');
546
- }
547
- else if (!options.commit) {
548
- devShared.Logger.log(chalk.magenta(`COMMIT: `) + 'Disabled.');
549
- }
550
- else if (options.dryRun) {
551
- devShared.Logger.log(chalk.magenta(`COMMIT: `) + chalk.yellow(`Skipping Git Commit`) + `\n${message}`);
552
- }
553
- else {
554
- devShared.Logger.log(chalk.magenta(`CHANGED: `) + `pnpm-lock.yaml`);
555
- await devShared.Shell.spawn('npx', ['pnpm', 'install', '--lockfile-only']);
556
- devShared.Logger.log(chalk.magenta(`COMMIT: `) + `CHANGELOG.md, package.json, pnpm-lock.yaml`);
557
- await devShared.Shell.spawn('git', ['add', process.cwd()]);
558
- await devShared.Shell.spawn('git', ['commit', '--m', `'${message}'`]);
559
- }
560
- if ((options.keepLastTag || options.push) && !options.dryRun) {
561
- devShared.Logger.log(chalk.yellow('Git Fetch...'));
562
- await devShared.Shell.spawn('git', ['fetch', '--prune', '--prune-tags']);
563
- }
564
- await inputs
565
- .reduce((preProcess, packageFolderName) => {
566
- const instance = instances[packageFolderName];
567
- preProcess = preProcess
568
- .then(() => instance.publish())
569
- .then(() => instance.tag())
570
- .then(() => instance.clean());
571
- return preProcess;
572
- }, Promise.resolve());
573
- devShared.Logger.log(chalk.blue(`\n---------------------\n`));
574
- if (!isChanged) {
575
- devShared.Logger.log(chalk.magenta(`FINISH: `) + 'Nothing Chanaged.');
576
- }
577
- else if (!options.push) {
578
- devShared.Logger.log(chalk.magenta(`FINISH: `) + 'Push Disabled.');
579
- }
580
- else if (options.dryRun) {
581
- devShared.Logger.log(chalk.magenta(`FINISH: `) + 'Skipping Git Push');
582
- }
583
- else {
584
- await devShared.Shell.spawn('git', ['push']);
585
- await devShared.Shell.spawn('git', ['push', '--tags']);
586
- }
587
- if (options.dryRun) {
588
- devShared.Logger.log(chalk.green('NO DRY RUN WAY: ')
589
- + chalk.grey(`npm run release -- --no-dry-run\n`));
590
- }
527
+ });
528
+ if (instance.commits.length) {
529
+ preProcess = preProcess.then(() => devShared.Logger.log(chalk.magenta(`CHANGED: `) + instance.packageName)).then(() => instance.test()).then(() => instance.build()).then(() => instance.updatePackageOptions(relationVerisons)).then(() => instance.updateChangelog()).then(() => {
530
+ message += `- ${instance.packageName}@${instance.packageOptions.version}
531
+ `;
532
+ relationVerisons[instance.packageName] = `^${instance.packageOptions.version}`;
533
+ });
534
+ }
535
+ return preProcess;
536
+ },
537
+ Promise.resolve()
538
+ );
539
+ devShared.Logger.log(chalk.blue(`
540
+ ---------------------
541
+ `));
542
+ const isChanged = Object.keys(relationVerisons).length;
543
+ if (!isChanged) {
544
+ devShared.Logger.log(chalk.magenta(`COMMIT: `) + "Nothing Chanaged Found.");
545
+ } else if (!options.commit) {
546
+ devShared.Logger.log(chalk.magenta(`COMMIT: `) + "Disabled.");
547
+ } else if (options.dryRun) {
548
+ devShared.Logger.log(chalk.magenta(`COMMIT: `) + chalk.yellow(`Skipping Git Commit`) + `
549
+ ${message}`);
550
+ } else {
551
+ devShared.Logger.log(chalk.magenta(`CHANGED: `) + `pnpm-lock.yaml`);
552
+ await devShared.Shell.spawn("npx", ["pnpm", "install", "--lockfile-only"]);
553
+ devShared.Logger.log(chalk.magenta(`COMMIT: `) + `CHANGELOG.md, package.json, pnpm-lock.yaml`);
554
+ await devShared.Shell.spawn("git", ["add", process.cwd()]);
555
+ await devShared.Shell.spawn("git", ["commit", "--m", `'${message}'`]);
556
+ }
557
+ if ((options.keepLastTag || options.push) && !options.dryRun) {
558
+ devShared.Logger.log(chalk.yellow("Git Fetch..."));
559
+ await devShared.Shell.spawn("git", ["fetch", "--prune", "--prune-tags"]);
560
+ }
561
+ devShared.Logger.log(chalk.blue(`
562
+ ---------------------
563
+ `));
564
+ await inputs.reduce(
565
+ (preProcess, packageFolderName) => {
566
+ const instance = instances[packageFolderName];
567
+ preProcess = preProcess.then(() => instance.publish()).then(() => instance.tag());
568
+ return preProcess;
569
+ },
570
+ Promise.resolve()
571
+ );
572
+ devShared.Logger.log(chalk.blue(`
573
+ ---------------------
574
+ `));
575
+ if (!isChanged) {
576
+ devShared.Logger.log(chalk.magenta(`PUSH: `) + "Nothing Chanaged.");
577
+ } else if (!options.push) {
578
+ devShared.Logger.log(chalk.magenta(`PUSH: `) + "Push Disabled.");
579
+ } else if (options.dryRun) {
580
+ devShared.Logger.log(chalk.magenta(`PUSH: `) + "Skipping Git Push");
581
+ } else {
582
+ devShared.Logger.log(chalk.yellow("Git Pull/Push..."));
583
+ await devShared.Shell.spawn("git", ["pull", "--rebase"]);
584
+ await devShared.Shell.spawn("git", ["push"]);
585
+ await devShared.Shell.spawn("git", ["push", "--tags"]);
586
+ }
587
+ devShared.Logger.log(chalk.blue(`
588
+ ---------------------
589
+ `));
590
+ await inputs.reduce(
591
+ (preProcess, packageFolderName) => {
592
+ const instance = instances[packageFolderName];
593
+ preProcess = preProcess.then(() => instance.cleanTagsAndKeepLastTag());
594
+ return preProcess;
595
+ },
596
+ Promise.resolve()
597
+ );
598
+ devShared.Logger.log(chalk.magenta(`FINISH: `) + chalk.green(`Release Successed.`));
599
+ if (options.dryRun) {
600
+ devShared.Logger.log(
601
+ chalk.green("NO DRY RUN WAY: ") + chalk.grey(`npm run release -- --no-dry-run
602
+ `)
603
+ );
604
+ }
591
605
  }, {
592
- onError: (e) => {
593
- if (typeof e === 'number' && e === 1) {
594
- devShared.Logger.error('发布失败');
595
- }
596
- else {
597
- devShared.Logger.error(e);
598
- }
599
- process.exit(1);
606
+ onError: (e) => {
607
+ if (typeof e === "number" && e === 1) {
608
+ devShared.Logger.error("发布失败");
609
+ } else {
610
+ devShared.Logger.error(e);
600
611
  }
612
+ devShared.Logger.log(chalk.magenta(`FINISH: `) + chalk.red(`Release Failed.`));
613
+ process.exit(1);
614
+ }
601
615
  });
602
616
 
603
617
  exports.run = run;