@deot/dev-releaser 2.8.0 → 2.9.1

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 CHANGED
@@ -7,9 +7,9 @@ const devShared = require('@deot/dev-shared');
7
7
  const path = require('node:path');
8
8
  const node_module = require('node:module');
9
9
  const fs = require('fs-extra');
10
- const parser = require('conventional-commits-parser');
10
+ const conventionalCommitsParser = require('conventional-commits-parser');
11
11
  const semver = require('semver');
12
- const inquirer = require('inquirer');
12
+ const prompts = require('@inquirer/prompts');
13
13
 
14
14
  function _interopNamespaceDefault(e) {
15
15
  const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
@@ -32,13 +32,13 @@ const path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
32
32
 
33
33
  const cwd = process.cwd();
34
34
  const require$ = node_module.createRequire(cwd);
35
- const { prompt } = inquirer;
36
35
  const HASH = "-hash-";
37
36
  const SUFFIX = "🐒💨🙊";
38
37
  const parserOptions = {
39
38
  noteKeywords: ["BREAKING CHANGE", "Breaking Change"]
40
39
  };
41
40
  const reBreaking = new RegExp(`(${parserOptions.noteKeywords.join(")|(")})`);
41
+ const commitParser = new conventionalCommitsParser.CommitParser();
42
42
  class Release {
43
43
  packageDir;
44
44
  packageName;
@@ -104,12 +104,10 @@ class Release {
104
104
  const chunk = commit.trim();
105
105
  return chunk && (rePlugin.test(chunk) || reAll && reAll.test(chunk));
106
106
  }).map((commit) => {
107
- const node = parser.sync(commit);
107
+ const node = commitParser.parse(commit);
108
108
  const body = node.body || node.footer;
109
- if (!node.type)
110
- node.type = parser.sync(node.header?.replace(/\(.+\)!?:/, ":") || "").type;
111
- if (!node.hash)
112
- node.hash = commit.split(HASH).pop()?.trim();
109
+ if (!node.type) node.type = commitParser.parse(node.header?.replace(/\(.+\)!?:/, ":") || "").type;
110
+ if (!node.hash) node.hash = commit.split(HASH).pop()?.trim();
113
111
  node.breaking = reBreaking.test(body) || /!:/.test(node.header);
114
112
  node.effect = false;
115
113
  node.custom = false;
@@ -126,15 +124,10 @@ class Release {
126
124
  if (commits.length && skipUpdatePackage) {
127
125
  let skip = false;
128
126
  if (typeof skipUpdatePackage === "boolean" && skipUpdatePackage) {
129
- const result = await prompt([
130
- {
131
- type: "confirm",
132
- name: "skip",
133
- message: `Skip Update(${this.packageName}@${this.packageOptions.version}):`,
134
- default: true
135
- }
136
- ]);
137
- skip = result.skip;
127
+ skip = await prompts.confirm({
128
+ message: `Skip Update(${this.packageName}@${this.packageOptions.version}):`,
129
+ default: true
130
+ });
138
131
  } else if (typeof skipUpdatePackage === "string" && (skipUpdatePackage === "*" || skipUpdatePackage.split(",").includes(this.packageName))) {
139
132
  skip = true;
140
133
  }
@@ -150,15 +143,10 @@ class Release {
150
143
  if (!commits.length && forceUpdatePackage) {
151
144
  let force = false;
152
145
  if (typeof forceUpdatePackage === "boolean" && forceUpdatePackage) {
153
- const result = await prompt([
154
- {
155
- type: "confirm",
156
- name: "force",
157
- message: `Force Update(${this.packageName}@${this.packageOptions.version}):`,
158
- default: true
159
- }
160
- ]);
161
- force = result.force;
146
+ force = await prompts.confirm({
147
+ message: `Force Update(${this.packageName}@${this.packageOptions.version}):`,
148
+ default: true
149
+ });
162
150
  } else if (typeof forceUpdatePackage === "string" && (forceUpdatePackage === "*" || forceUpdatePackage.split(",").includes(this.packageName))) {
163
151
  force = true;
164
152
  }
@@ -247,10 +235,8 @@ class Release {
247
235
  if (commandOptions.customVersion) {
248
236
  newVersion = commandOptions.customVersion;
249
237
  if (!/\d+.\d+.\d+/.test(newVersion) || version === newVersion) {
250
- const result = await prompt([
238
+ newVersion = await prompts.input(
251
239
  {
252
- type: "input",
253
- name: "version",
254
240
  message: `Custom Update Version(${this.packageName}@${version}):`,
255
241
  default: "",
256
242
  validate: (answer) => {
@@ -263,8 +249,7 @@ class Release {
263
249
  return true;
264
250
  }
265
251
  }
266
- ]);
267
- newVersion = result.version;
252
+ );
268
253
  }
269
254
  } else {
270
255
  const intersection = [
@@ -289,8 +274,7 @@ class Release {
289
274
  return !!this.commits.length;
290
275
  }
291
276
  async updateCommits(commits, source) {
292
- if (!commits.length)
293
- return;
277
+ if (!commits.length) return;
294
278
  const { packageName } = this;
295
279
  const olds = this.commits.map((i) => JSON.stringify({ ...i, effect: false }));
296
280
  const newCommits = commits.filter((i) => {
@@ -321,8 +305,7 @@ class Release {
321
305
  }
322
306
  }
323
307
  async updatePackageOptions(relationVerisons = {}) {
324
- if (!this.isChanged())
325
- return;
308
+ if (!this.isChanged()) return;
326
309
  const { packageDir, packageOptions, commandOptions } = this;
327
310
  const { dependencies, devDependencies } = packageOptions;
328
311
  const newVersion = this.version;
@@ -347,8 +330,7 @@ class Release {
347
330
  fs.outputFileSync(`${packageDir}/package.json`, JSON.stringify(packageOptions, null, 2));
348
331
  }
349
332
  async updateChangelog() {
350
- if (!this.isChanged())
351
- return;
333
+ if (!this.isChanged()) return;
352
334
  const { packageName, packageDir, packageOptions, commandOptions } = this;
353
335
  const title = `# ${packageName} ChangeLog`;
354
336
  const [date] = (/* @__PURE__ */ new Date()).toISOString().split("T");
@@ -368,13 +350,11 @@ ${newLog}`);
368
350
  }
369
351
  devShared.Logger.log(chalk.yellow(`Updating `) + `CHANGELOG.md`);
370
352
  let content = [title, newLog, oldNotes].filter(Boolean).join("\n\n");
371
- if (!content.endsWith("\n"))
372
- content += "\n";
353
+ if (!content.endsWith("\n")) content += "\n";
373
354
  fs.writeFileSync(logPath, content, "utf-8");
374
355
  }
375
356
  async test() {
376
- if (!this.isChanged())
377
- return;
357
+ if (!this.isChanged()) return;
378
358
  const { commandOptions } = this;
379
359
  if (commandOptions.dryRun) {
380
360
  devShared.Logger.log(chalk.yellow("Skipping Test"));
@@ -385,8 +365,7 @@ ${newLog}`);
385
365
  await devShared.Shell.exec(`npm run test -- --package-name ${this.packageName}`);
386
366
  }
387
367
  async build() {
388
- if (!this.isChanged())
389
- return;
368
+ if (!this.isChanged()) return;
390
369
  const { commandOptions } = this;
391
370
  if (commandOptions.dryRun) {
392
371
  devShared.Logger.log(chalk.yellow("Skipping Build"));
@@ -398,8 +377,7 @@ ${newLog}`);
398
377
  }
399
378
  async publish() {
400
379
  const { commandOptions } = this;
401
- if (!this.isChanged() || !commandOptions.publish)
402
- return;
380
+ if (!this.isChanged() || !commandOptions.publish) return;
403
381
  const { packageDir, packageName } = this;
404
382
  devShared.Logger.log(chalk.magenta(`PUBLISH: `) + packageName);
405
383
  if (commandOptions.dryRun) {
@@ -418,8 +396,7 @@ ${newLog}`);
418
396
  }
419
397
  async tag() {
420
398
  const { commandOptions } = this;
421
- if (!this.isChanged() || !commandOptions.tag)
422
- return;
399
+ if (!this.isChanged() || !commandOptions.tag) return;
423
400
  const { packageDir, packageName, packageOptions } = this;
424
401
  devShared.Logger.log(chalk.magenta(`TAG: `) + packageName);
425
402
  if (commandOptions.dryRun) {
@@ -443,12 +420,10 @@ ${newLog}`);
443
420
  */
444
421
  async cleanTagsAndKeepLastTag() {
445
422
  const { commandOptions } = this;
446
- if (!commandOptions.keepLastTag)
447
- return;
423
+ if (!commandOptions.keepLastTag) return;
448
424
  let tags = await this.getTags();
449
425
  tags = tags.slice(1).filter((i) => !!i).reverse();
450
- if (!tags.length)
451
- return;
426
+ if (!tags.length) return;
452
427
  const { packageName } = this;
453
428
  devShared.Logger.log(chalk.magenta(`CLEAN TAGS: `) + packageName);
454
429
  if (commandOptions.dryRun) {
package/dist/index.js CHANGED
@@ -3,19 +3,19 @@ import { Locals, Logger, Shell, Utils } from '@deot/dev-shared';
3
3
  import * as path from 'node:path';
4
4
  import { createRequire } from 'node:module';
5
5
  import fs from 'fs-extra';
6
- import parser from 'conventional-commits-parser';
6
+ import { CommitParser } from 'conventional-commits-parser';
7
7
  import semver from 'semver';
8
- import inquirer from 'inquirer';
8
+ import { confirm, input } from '@inquirer/prompts';
9
9
 
10
10
  const cwd = process.cwd();
11
11
  const require$ = createRequire(cwd);
12
- const { prompt } = inquirer;
13
12
  const HASH = "-hash-";
14
13
  const SUFFIX = "🐒💨🙊";
15
14
  const parserOptions = {
16
15
  noteKeywords: ["BREAKING CHANGE", "Breaking Change"]
17
16
  };
18
17
  const reBreaking = new RegExp(`(${parserOptions.noteKeywords.join(")|(")})`);
18
+ const commitParser = new CommitParser();
19
19
  class Release {
20
20
  packageDir;
21
21
  packageName;
@@ -81,12 +81,10 @@ class Release {
81
81
  const chunk = commit.trim();
82
82
  return chunk && (rePlugin.test(chunk) || reAll && reAll.test(chunk));
83
83
  }).map((commit) => {
84
- const node = parser.sync(commit);
84
+ const node = commitParser.parse(commit);
85
85
  const body = node.body || node.footer;
86
- if (!node.type)
87
- node.type = parser.sync(node.header?.replace(/\(.+\)!?:/, ":") || "").type;
88
- if (!node.hash)
89
- node.hash = commit.split(HASH).pop()?.trim();
86
+ if (!node.type) node.type = commitParser.parse(node.header?.replace(/\(.+\)!?:/, ":") || "").type;
87
+ if (!node.hash) node.hash = commit.split(HASH).pop()?.trim();
90
88
  node.breaking = reBreaking.test(body) || /!:/.test(node.header);
91
89
  node.effect = false;
92
90
  node.custom = false;
@@ -103,15 +101,10 @@ class Release {
103
101
  if (commits.length && skipUpdatePackage) {
104
102
  let skip = false;
105
103
  if (typeof skipUpdatePackage === "boolean" && skipUpdatePackage) {
106
- const result = await prompt([
107
- {
108
- type: "confirm",
109
- name: "skip",
110
- message: `Skip Update(${this.packageName}@${this.packageOptions.version}):`,
111
- default: true
112
- }
113
- ]);
114
- skip = result.skip;
104
+ skip = await confirm({
105
+ message: `Skip Update(${this.packageName}@${this.packageOptions.version}):`,
106
+ default: true
107
+ });
115
108
  } else if (typeof skipUpdatePackage === "string" && (skipUpdatePackage === "*" || skipUpdatePackage.split(",").includes(this.packageName))) {
116
109
  skip = true;
117
110
  }
@@ -127,15 +120,10 @@ class Release {
127
120
  if (!commits.length && forceUpdatePackage) {
128
121
  let force = false;
129
122
  if (typeof forceUpdatePackage === "boolean" && forceUpdatePackage) {
130
- const result = await prompt([
131
- {
132
- type: "confirm",
133
- name: "force",
134
- message: `Force Update(${this.packageName}@${this.packageOptions.version}):`,
135
- default: true
136
- }
137
- ]);
138
- force = result.force;
123
+ force = await confirm({
124
+ message: `Force Update(${this.packageName}@${this.packageOptions.version}):`,
125
+ default: true
126
+ });
139
127
  } else if (typeof forceUpdatePackage === "string" && (forceUpdatePackage === "*" || forceUpdatePackage.split(",").includes(this.packageName))) {
140
128
  force = true;
141
129
  }
@@ -224,10 +212,8 @@ class Release {
224
212
  if (commandOptions.customVersion) {
225
213
  newVersion = commandOptions.customVersion;
226
214
  if (!/\d+.\d+.\d+/.test(newVersion) || version === newVersion) {
227
- const result = await prompt([
215
+ newVersion = await input(
228
216
  {
229
- type: "input",
230
- name: "version",
231
217
  message: `Custom Update Version(${this.packageName}@${version}):`,
232
218
  default: "",
233
219
  validate: (answer) => {
@@ -240,8 +226,7 @@ class Release {
240
226
  return true;
241
227
  }
242
228
  }
243
- ]);
244
- newVersion = result.version;
229
+ );
245
230
  }
246
231
  } else {
247
232
  const intersection = [
@@ -266,8 +251,7 @@ class Release {
266
251
  return !!this.commits.length;
267
252
  }
268
253
  async updateCommits(commits, source) {
269
- if (!commits.length)
270
- return;
254
+ if (!commits.length) return;
271
255
  const { packageName } = this;
272
256
  const olds = this.commits.map((i) => JSON.stringify({ ...i, effect: false }));
273
257
  const newCommits = commits.filter((i) => {
@@ -298,8 +282,7 @@ class Release {
298
282
  }
299
283
  }
300
284
  async updatePackageOptions(relationVerisons = {}) {
301
- if (!this.isChanged())
302
- return;
285
+ if (!this.isChanged()) return;
303
286
  const { packageDir, packageOptions, commandOptions } = this;
304
287
  const { dependencies, devDependencies } = packageOptions;
305
288
  const newVersion = this.version;
@@ -324,8 +307,7 @@ class Release {
324
307
  fs.outputFileSync(`${packageDir}/package.json`, JSON.stringify(packageOptions, null, 2));
325
308
  }
326
309
  async updateChangelog() {
327
- if (!this.isChanged())
328
- return;
310
+ if (!this.isChanged()) return;
329
311
  const { packageName, packageDir, packageOptions, commandOptions } = this;
330
312
  const title = `# ${packageName} ChangeLog`;
331
313
  const [date] = (/* @__PURE__ */ new Date()).toISOString().split("T");
@@ -345,13 +327,11 @@ ${newLog}`);
345
327
  }
346
328
  Logger.log(chalk.yellow(`Updating `) + `CHANGELOG.md`);
347
329
  let content = [title, newLog, oldNotes].filter(Boolean).join("\n\n");
348
- if (!content.endsWith("\n"))
349
- content += "\n";
330
+ if (!content.endsWith("\n")) content += "\n";
350
331
  fs.writeFileSync(logPath, content, "utf-8");
351
332
  }
352
333
  async test() {
353
- if (!this.isChanged())
354
- return;
334
+ if (!this.isChanged()) return;
355
335
  const { commandOptions } = this;
356
336
  if (commandOptions.dryRun) {
357
337
  Logger.log(chalk.yellow("Skipping Test"));
@@ -362,8 +342,7 @@ ${newLog}`);
362
342
  await Shell.exec(`npm run test -- --package-name ${this.packageName}`);
363
343
  }
364
344
  async build() {
365
- if (!this.isChanged())
366
- return;
345
+ if (!this.isChanged()) return;
367
346
  const { commandOptions } = this;
368
347
  if (commandOptions.dryRun) {
369
348
  Logger.log(chalk.yellow("Skipping Build"));
@@ -375,8 +354,7 @@ ${newLog}`);
375
354
  }
376
355
  async publish() {
377
356
  const { commandOptions } = this;
378
- if (!this.isChanged() || !commandOptions.publish)
379
- return;
357
+ if (!this.isChanged() || !commandOptions.publish) return;
380
358
  const { packageDir, packageName } = this;
381
359
  Logger.log(chalk.magenta(`PUBLISH: `) + packageName);
382
360
  if (commandOptions.dryRun) {
@@ -395,8 +373,7 @@ ${newLog}`);
395
373
  }
396
374
  async tag() {
397
375
  const { commandOptions } = this;
398
- if (!this.isChanged() || !commandOptions.tag)
399
- return;
376
+ if (!this.isChanged() || !commandOptions.tag) return;
400
377
  const { packageDir, packageName, packageOptions } = this;
401
378
  Logger.log(chalk.magenta(`TAG: `) + packageName);
402
379
  if (commandOptions.dryRun) {
@@ -420,12 +397,10 @@ ${newLog}`);
420
397
  */
421
398
  async cleanTagsAndKeepLastTag() {
422
399
  const { commandOptions } = this;
423
- if (!commandOptions.keepLastTag)
424
- return;
400
+ if (!commandOptions.keepLastTag) return;
425
401
  let tags = await this.getTags();
426
402
  tags = tags.slice(1).filter((i) => !!i).reverse();
427
- if (!tags.length)
428
- return;
403
+ if (!tags.length) return;
429
404
  const { packageName } = this;
430
405
  Logger.log(chalk.magenta(`CLEAN TAGS: `) + packageName);
431
406
  if (commandOptions.dryRun) {
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@deot/dev-releaser",
3
- "version": "2.8.0",
3
+ "version": "2.9.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
+ "types": "./dist/index.d.ts",
9
10
  "import": "./dist/index.js",
10
- "require": "./dist/index.cjs",
11
- "types": "./dist/index.d.ts"
11
+ "require": "./dist/index.cjs"
12
12
  }
13
13
  },
14
14
  "files": [
@@ -19,13 +19,12 @@
19
19
  "access": "public"
20
20
  },
21
21
  "dependencies": {
22
- "@deot/dev-shared": "^2.8.0",
23
- "conventional-commits-parser": "^5.0.0",
24
- "chalk": "^5.3.0",
25
- "fs-extra": "^11.2.0",
26
- "inquirer": "^9.2.12",
27
- "inquirer-autocomplete-prompt": "^3.0.1",
28
- "semver": "^7.5.4"
22
+ "@deot/dev-shared": "^2.9.1",
23
+ "conventional-commits-parser": "^6.1.0",
24
+ "chalk": "^5.4.1",
25
+ "fs-extra": "^11.3.0",
26
+ "inquirer": "^12.5.2",
27
+ "semver": "^7.7.1"
29
28
  },
30
29
  "devDependencies": {
31
30
  "cross-env": "^7.0.3"