cross-release-cli 0.4.0 → 0.5.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.
@@ -2,6 +2,6 @@
2
2
 
3
3
  "use strict"
4
4
 
5
- const App = await import("../dist/app.js")
5
+ const App = await import("../dist/app.mjs")
6
6
  const app = new App.default()
7
7
  void app.run()
@@ -1,4 +1,4 @@
1
- import { ReleaseOptions } from "./types-Bmp7nnWP.js";
1
+ import { n as ReleaseOptions } from "./types-CSTfUwO2.mjs";
2
2
  import { ProjectFile } from "cross-bump";
3
3
 
4
4
  //#region src/app.d.ts
@@ -45,8 +45,8 @@ function loadDefaultConfigFile(cwd = process.cwd()) {
45
45
  sources: [{ files: "cross-release.config" }, {
46
46
  extensions: ["json"],
47
47
  files: "package",
48
- rewrite(config$1) {
49
- return config$1["cross-release"];
48
+ rewrite(config) {
49
+ return config["cross-release"];
50
50
  }
51
51
  }]
52
52
  }) ?? {};
@@ -68,14 +68,14 @@ function loadUserConfig(opts) {
68
68
  *
69
69
  * @see https://nodejs.org/api/process.html#process_exit_codes
70
70
  */
71
- let ExitCode = /* @__PURE__ */ function(ExitCode$1) {
72
- ExitCode$1[ExitCode$1["Canceled"] = 2] = "Canceled";
73
- ExitCode$1[ExitCode$1["FatalError"] = 1] = "FatalError";
74
- ExitCode$1[ExitCode$1["GitDirty"] = 3] = "GitDirty";
75
- ExitCode$1[ExitCode$1["GitUnreachable"] = 4] = "GitUnreachable";
76
- ExitCode$1[ExitCode$1["InvalidArgument"] = 9] = "InvalidArgument";
77
- ExitCode$1[ExitCode$1["Success"] = 0] = "Success";
78
- return ExitCode$1;
71
+ let ExitCode = /* @__PURE__ */ function(ExitCode) {
72
+ ExitCode[ExitCode["Canceled"] = 2] = "Canceled";
73
+ ExitCode[ExitCode["FatalError"] = 1] = "FatalError";
74
+ ExitCode[ExitCode["GitDirty"] = 3] = "GitDirty";
75
+ ExitCode[ExitCode["GitUnreachable"] = 4] = "GitUnreachable";
76
+ ExitCode[ExitCode["InvalidArgument"] = 9] = "InvalidArgument";
77
+ ExitCode[ExitCode["Success"] = 0] = "Success";
78
+ return ExitCode;
79
79
  }({});
80
80
  const CONFIG_DEFAULT = {
81
81
  commit: {
@@ -151,14 +151,13 @@ const cliOptions = z.object({
151
151
 
152
152
  //#endregion
153
153
  //#region package.json
154
- var version = "0.3.0";
154
+ var version = "0.4.0";
155
155
 
156
156
  //#endregion
157
157
  //#region src/cli.ts
158
158
  const debug$3 = createDebug("cli");
159
159
  function createCliProgram(argv) {
160
- const cli = cac("cross-release").usage("A release tool that support multi programming language").version(version).usage("[version] [options]").option("-a, --all", "shortcut for --commit.stageAll").option("-c, --config [file]", "Config file (auto detect by default)").option("-D, --dry", "Dry run").option("-d, --debug", "Enable debug mode").option("-e, --exclude [dir...]", "Folders to exclude from search").option("-m, --main [lang]", "Base project language [e.g. java, rust, javascript]").option("-r, --recursive", "Run the command for each project in the workspace").option("-x, --execute [command...]", "Execute the command").option("-y, --yes", "Answer yes to all prompts").option("--cwd [dir]", "Set working directory").option("--commit", "Committing changes").option("--commit.signoff", "Commit with signoff").option("--commit.stageAll", "Stage all changes before commit").option("--commit.template <template>", "Template for commit message").option("--commit.verify", "Verify commit message").option("--push", "Pushing Commit to remote").option("--push.followTags", "Pushing with follow tags").option("--push.branch <branch>", "Branch name to push").option("--tag", "Tagging for release").option("--tag.template <template>", "Template for tag message").help();
161
- return cli.parse(argv);
160
+ return cac("cross-release").usage("A release tool that support multi programming language").version(version).usage("[version] [options]").option("-a, --all", "shortcut for --commit.stageAll").option("-c, --config [file]", "Config file (auto detect by default)").option("-D, --dry", "Dry run").option("-d, --debug", "Enable debug mode").option("-e, --exclude [dir...]", "Folders to exclude from search").option("-m, --main [lang]", "Base project language [e.g. java, rust, javascript]").option("-r, --recursive", "Run the command for each project in the workspace").option("-x, --execute [command...]", "Execute the command").option("-y, --yes", "Answer yes to all prompts").option("--cwd [dir]", "Set working directory").option("--commit", "Committing changes").option("--commit.signoff", "Commit with signoff").option("--commit.stageAll", "Stage all changes before commit").option("--commit.template <template>", "Template for commit message").option("--commit.verify", "Verify commit message").option("--push", "Pushing Commit to remote").option("--push.followTags", "Pushing with follow tags").option("--push.branch <branch>", "Branch name to push").option("--tag", "Tagging for release").option("--tag.template <template>", "Template for tag message").help().parse(argv);
162
161
  }
163
162
  function argvToReleaseOptions(cli) {
164
163
  const { args, options } = cli;
@@ -182,8 +181,7 @@ function argvToReleaseOptions(cli) {
182
181
  return opts;
183
182
  }
184
183
  function pathToAbs(opts) {
185
- const shouldBeAbsolute = ["cwd", "config"];
186
- for (const key of shouldBeAbsolute) {
184
+ for (const key of ["cwd", "config"]) {
187
185
  if (!opts[key]) continue;
188
186
  if (key === "cwd") opts.cwd = toAbsolute(opts.cwd);
189
187
  opts[key] = path.resolve(opts.cwd, opts[key]);
@@ -209,8 +207,7 @@ function validateOptions(cli) {
209
207
  }
210
208
  function resolveAppOptions(cli) {
211
209
  const opts = argvToReleaseOptions(cli);
212
- const userConfig = loadUserConfig(opts);
213
- const crOptions = merge(CONFIG_DEFAULT, userConfig, opts);
210
+ const crOptions = merge(CONFIG_DEFAULT, loadUserConfig(opts), opts);
214
211
  validateOptions(crOptions);
215
212
  setupDebug(crOptions);
216
213
  resolveGitIgnore(crOptions);
@@ -237,10 +234,10 @@ function gitLsRemote(options) {
237
234
  if (pattern) args.push(pattern);
238
235
  debug$2(`command: git ls-remote ${args.join(" ")}`);
239
236
  if (!dry) {
240
- const { all, exitCode, failed, shortMessage } = execa("git", ["ls-remote", ...args], { cwd });
237
+ const { all, failed, shortMessage } = execa("git", ["ls-remote", ...args], { cwd });
241
238
  debug$2("git ls-remote stdout:", all);
242
239
  if (failed) {
243
- s.stop(color.red(shortMessage), exitCode);
240
+ s.error(shortMessage);
244
241
  return false;
245
242
  }
246
243
  }
@@ -248,21 +245,21 @@ function gitLsRemote(options) {
248
245
  return true;
249
246
  }
250
247
  function gitTag(options) {
251
- const { cwd = process.cwd(), del = false, dry = false, force = false, message: message$1, tagName: name } = options ?? {};
248
+ const { cwd = process.cwd(), del = false, dry = false, force = false, message, tagName: name } = options ?? {};
252
249
  const s = spinner();
253
250
  s.start("creating tag...");
254
251
  const args = [];
255
252
  if (del) args.push("--delete");
256
- else if (!message$1 || message$1?.length === 0) log.warn("no message provided, is recommended to provide a message for create an annotated tag");
257
- else args.push("--annotate", "--message", message$1);
253
+ else if (!message || message?.length === 0) log.warn("no message provided, is recommended to provide a message for create an annotated tag");
254
+ else args.push("--annotate", "--message", message);
258
255
  if (force) args.push("--force");
259
256
  args.push(name);
260
257
  debug$2(`command: git tag ${args.join(" ")}`);
261
258
  if (!dry) {
262
- const { all, exitCode, failed, shortMessage } = execa("git", ["tag", ...args], { cwd });
259
+ const { all, failed, shortMessage } = execa("git", ["tag", ...args], { cwd });
263
260
  debug$2("git tag stdout:", all);
264
261
  if (failed) {
265
- s.stop(color.red(shortMessage), exitCode);
262
+ s.error(shortMessage);
266
263
  return false;
267
264
  }
268
265
  }
@@ -270,25 +267,25 @@ function gitTag(options) {
270
267
  return true;
271
268
  }
272
269
  function gitCommit(options) {
273
- const { cwd = process.cwd(), dry = false, message: message$1, modifiedFiles = [], signoff, stageAll, verify } = options ?? {};
270
+ const { cwd = process.cwd(), dry = false, message, modifiedFiles = [], signoff, stageAll, verify } = options ?? {};
274
271
  const s = spinner();
275
272
  s.start("committing...");
276
273
  const args = [];
277
- args.push("--message", message$1);
274
+ args.push("--message", message);
278
275
  !verify && args.push("--no-verify");
279
276
  if (!stageAll && modifiedFiles.length > 0) args.push("--", ...modifiedFiles);
280
277
  else args.push("--all");
281
278
  if (signoff) args.push("--signoff");
282
279
  debug$2(`command: git commit ${args.join(" ")}`);
283
280
  if (!dry) {
284
- const { all, exitCode, failed, shortMessage } = execa("git", ["commit", ...args], { cwd });
281
+ const { all, failed, shortMessage } = execa("git", ["commit", ...args], { cwd });
285
282
  debug$2("git commit stdout: %s", all);
286
283
  if (failed) {
287
- s.stop(color.red(shortMessage), exitCode);
284
+ s.error(shortMessage);
288
285
  return false;
289
286
  }
290
287
  }
291
- s.stop(`commit message: ${color.green(message$1)}`);
288
+ s.stop(`commit message: ${color.green(message)}`);
292
289
  return true;
293
290
  }
294
291
  function gitPush(options = {}) {
@@ -303,10 +300,10 @@ function gitPush(options = {}) {
303
300
  followTags && args.push("--follow-tags");
304
301
  debug$2(`command: git push ${args.join(" ")}`);
305
302
  if (!dry) {
306
- const { all, exitCode, failed, shortMessage } = execa("git", ["push", ...args], { cwd });
303
+ const { all, failed, shortMessage } = execa("git", ["push", ...args], { cwd });
307
304
  debug$2("git push stdout: %s", all);
308
305
  if (failed) {
309
- s.stop(color.red(shortMessage), exitCode);
306
+ s.error(shortMessage);
310
307
  return false;
311
308
  }
312
309
  }
@@ -315,12 +312,11 @@ function gitPush(options = {}) {
315
312
  return true;
316
313
  }
317
314
  function gitOriginUrl() {
318
- const command = execa("git", [
315
+ return execa("git", [
319
316
  "remote",
320
317
  "get-url",
321
318
  "origin"
322
- ]);
323
- return command.stdout.trim();
319
+ ]).stdout.trim();
324
320
  }
325
321
  function gitAdd(options = {}) {
326
322
  const { all = false, cwd = process.cwd(), dry = false, files = [] } = options;
@@ -329,16 +325,15 @@ function gitAdd(options = {}) {
329
325
  else if (files.length > 0) args.push("--", ...files);
330
326
  debug$2("command: git add", args.join(" "));
331
327
  if (!dry) {
332
- const { all: all$1, failed } = execa("git", ["add", ...args], { cwd });
333
- debug$2("git add stdout:", all$1);
328
+ const { all, failed } = execa("git", ["add", ...args], { cwd });
329
+ debug$2("git add stdout:", all);
334
330
  if (failed) return false;
335
331
  }
336
332
  return true;
337
333
  }
338
334
  function isGitClean(options = {}) {
339
335
  const { cwd = process.cwd() } = options;
340
- const args = ["status", "--porcelain"];
341
- const { all, failed } = execa("git", args, { cwd });
336
+ const { all, failed } = execa("git", ["status", "--porcelain"], { cwd });
342
337
  if (all) return false;
343
338
  return !failed;
344
339
  }
@@ -371,8 +366,7 @@ function getStagedFiles(opts = {}) {
371
366
  * @return The chosen version.
372
367
  */
373
368
  async function chooseVersion(currentVersion) {
374
- const versionObj = parseVersion(currentVersion);
375
- const { nextMajor, nextMinor, nextPatch, nextPreMajor, nextPreMinor, nextPrePatch, nextRelease } = getNextVersions(versionObj ?? void 0);
369
+ const { nextMajor, nextMinor, nextPatch, nextPreMajor, nextPreMinor, nextPrePatch, nextRelease } = getNextVersions(parseVersion(currentVersion) ?? void 0);
376
370
  const C_CUSTOM = "custom";
377
371
  const versions = [
378
372
  {
@@ -466,8 +460,7 @@ var App = class {
466
460
  constructor(argv = process.argv) {
467
461
  const cli = createCliProgram(argv);
468
462
  if (cli.options.help) process.exit(ExitCode.Success);
469
- const opts = resolveAppOptions(cli);
470
- this._options = opts;
463
+ this._options = resolveAppOptions(cli);
471
464
  }
472
465
  #addTask(task, idx) {
473
466
  const expect = this._taskQueue.length + 1;
@@ -503,20 +496,18 @@ var App = class {
503
496
  checkGitClean() {
504
497
  const { cwd } = this._options;
505
498
  const commit = resolveAltOptions(this._options, "commit");
506
- const isClean = isGitClean({ cwd });
507
- if (!isClean && !commit.stageAll) {
499
+ if (!isGitClean({ cwd }) && !commit.stageAll) {
508
500
  log.warn("git is not clean, please commit or stash your changes");
509
501
  this.#done();
510
502
  process.exit(ExitCode.GitDirty);
511
503
  }
512
504
  }
513
505
  checkGitRemote() {
514
- const { cwd, debug: debug$5, dry } = this._options;
515
- const hasRemote = gitLsRemote({
506
+ const { cwd, debug, dry } = this._options;
507
+ if (!gitLsRemote({
516
508
  cwd,
517
- dry: dry || debug$5
518
- });
519
- if (!hasRemote) {
509
+ dry: dry || debug
510
+ })) {
520
511
  log.warn("git remote not found, please add remote or check your network");
521
512
  this.#done();
522
513
  process.exit(ExitCode.GitUnreachable);
@@ -524,12 +515,12 @@ var App = class {
524
515
  }
525
516
  async confirmReleaseOptions() {
526
517
  const { cwd, dry, yes } = this._options;
527
- const confirmTask = async (name, message$1, exec) => {
518
+ const confirmTask = async (name, message, exec) => {
528
519
  if (yes) {
529
520
  if (!this._options[name]) return;
530
521
  this._options[name] = true;
531
522
  } else if (this._options[name]) {
532
- const confirmation = await confirm({ message: message$1 });
523
+ const confirmation = await confirm({ message });
533
524
  this._options[name] = handleUserCancel(confirmation);
534
525
  }
535
526
  if (this._options[name]) this.#addTask({
@@ -624,18 +615,14 @@ var App = class {
624
615
  }
625
616
  }
626
617
  async resolveNextVersion() {
627
- const { main, version: version$1 } = this._options;
618
+ const { main, version } = this._options;
628
619
  const mainProjectFile = this._projectFiles.find((file) => file.category === main);
629
620
  if (!mainProjectFile) throw new Error(`can't found ${main} project file in the project root`);
630
- const projectVersion = await getProjectVersion(mainProjectFile);
631
- this._currentVersion = projectVersion ?? "";
632
- if (isVersionValid(version$1)) {
633
- this._nextVersion = version$1;
621
+ this._currentVersion = await getProjectVersion(mainProjectFile) ?? "";
622
+ if (isVersionValid(version)) {
623
+ this._nextVersion = version;
634
624
  log.info(`current version: ${this._currentVersion}, next version: ${color.blue(this._nextVersion)}`);
635
- } else {
636
- const nextVersion = await chooseVersion(this._currentVersion);
637
- this._nextVersion = handleUserCancel(nextVersion);
638
- }
625
+ } else this._nextVersion = handleUserCancel(await chooseVersion(this._currentVersion));
639
626
  }
640
627
  resolveProjectFiles() {
641
628
  const { cwd, exclude, recursive } = this._options;
@@ -691,7 +678,6 @@ var App = class {
691
678
  return this._projectFiles;
692
679
  }
693
680
  };
694
- var app_default = App;
695
681
 
696
682
  //#endregion
697
- export { app_default as default };
683
+ export { App as default };
@@ -1,4 +1,4 @@
1
- import { DefineConfigOptions } from "./types-Bmp7nnWP.js";
1
+ import { t as DefineConfigOptions } from "./types-CSTfUwO2.mjs";
2
2
 
3
3
  //#region src/index.d.ts
4
4
  declare function defineConfig(config: DefineConfigOptions): DefineConfigOptions;
@@ -2,7 +2,6 @@ import { ProjectCategory } from "cross-bump";
2
2
  import "cac";
3
3
 
4
4
  //#region src/types.d.ts
5
-
6
5
  type DefineConfigOptions = Partial<Omit<ReleaseOptions, "config">>;
7
6
  type ReleaseOptions = {
8
7
  /**
@@ -111,4 +110,4 @@ type TagOptions = {
111
110
  template?: string;
112
111
  };
113
112
  //#endregion
114
- export { DefineConfigOptions, ReleaseOptions };
113
+ export { ReleaseOptions as n, DefineConfigOptions as t };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cross-release-cli",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.5.0",
5
5
  "description": "command line app for cross language bump utility",
6
6
  "author": {
7
7
  "name": "rainbowatcher",
@@ -17,8 +17,8 @@
17
17
  "bugs": {
18
18
  "url": "https://github.com/rainbowatcher/cross-release/issues"
19
19
  },
20
- "main": "dist/index.js",
21
- "types": "./dist/index.d.ts",
20
+ "main": "dist/index.mjs",
21
+ "types": "./dist/index.d.mts",
22
22
  "bin": {
23
23
  "cross-release": "./bin/cross-release.js"
24
24
  },
@@ -27,19 +27,19 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "@clack/prompts": "^0.11.0",
30
+ "@clack/prompts": "^1.0.0",
31
31
  "@rainbowatcher/common": "^0.7.0",
32
32
  "@rainbowatcher/fs-extra": "^0.7.0",
33
33
  "@rainbowatcher/path-extra": "^0.7.0",
34
34
  "cac": "^6.7.14",
35
- "debug": "^4.4.1",
35
+ "debug": "^4.4.3",
36
36
  "defu": "^6.1.4",
37
- "execa": "^9.6.0",
37
+ "execa": "^9.6.1",
38
38
  "is-unicode-supported": "^2.1.0",
39
39
  "picocolors": "^1.1.1",
40
- "unconfig": "^7.3.2",
41
- "zod": "^4.0.17",
42
- "cross-bump": "0.4.0"
40
+ "unconfig": "^7.4.2",
41
+ "zod": "^4.3.6",
42
+ "cross-bump": "0.5.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@rainbowatcher/maybe": "^0.7.0"
File without changes