cross-release-cli 0.2.2 → 0.4.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/README.md CHANGED
@@ -13,7 +13,8 @@ pnpm i -D cross-release
13
13
  ```json
14
14
  {
15
15
  "scripts": {
16
- "release": "cross-release"
16
+ "release": "cross-release -ax 'pnpm changelog' && pnpm build && pnpm -r publish",
17
+ "changelog": "conventional-changelog -si CHANGELOG.md",
17
18
  }
18
19
  }
19
20
  ```
@@ -26,23 +27,34 @@ pnpm run release
26
27
 
27
28
  ## Command line
28
29
 
29
- | short | long | description | default |
30
- | ----- | ---------------------- | --------------------------------------------------- | ----------------------------------------------- |
31
- | -V | --version | output the version number | false |
32
- | -a | --all | Add all changed files to staged | false |
33
- | -c | --config [file] | Config file | auto detect |
34
- | -D | --dry | Dry run | false |
35
- | -d | --debug | Enable debug mode | false |
36
- | -e | --exclude [dir] | Folders to exclude from search | ["node_modules",".git","target","build","dist"] |
37
- | -m | --main | Base project language [e.g. java, rust, javascript] | "javascript" |
38
- | -r | --recursive | Run the command for each project in the workspace | false |
39
- | -x | --execute [command...] | Execute the command | [] |
40
- | -y | --yes | Answer yes to all prompts | false |
41
- | | --cwd [dir] | Set working directory | process.cwd() |
42
- | -c | --no-commit | Skip committing changes | false |
43
- | -p | --no-push | Skip pushing | false |
44
- | -t | --no-tag | Skip tagging | false |
45
- | -h | --help | Display this message | false |
30
+ ```
31
+ Usage:
32
+ $ cross-release [version] [options]
33
+
34
+ Options:
35
+ -v, --version Display version number
36
+ -a, --all shortcut for --commit.stageAll
37
+ -c, --config [file] Config file (auto detect by default)
38
+ -D, --dry Dry run
39
+ -d, --debug Enable debug mode
40
+ -e, --exclude [dir...] Folders to exclude from search
41
+ -m, --main [lang] Base project language [e.g. java, rust, javascript]
42
+ -r, --recursive Run the command for each project in the workspace
43
+ -x, --execute [command...] Execute the command
44
+ -y, --yes Answer yes to all prompts
45
+ --cwd [dir] Set working directory
46
+ --commit Committing changes
47
+ --commit.signoff Commit with signoff
48
+ --commit.stageAll Stage all changes before commit
49
+ --commit.template <template> Template for commit message
50
+ --commit.verify Verify commit message
51
+ --push Pushing Commit to remote
52
+ --push.followTags Pushing with follow tags
53
+ --push.branch <branch> Branch name to push
54
+ --tag Tagging for release
55
+ --tag.template <template> Template for tag message
56
+ -h, --help Display this message
57
+ ```
46
58
 
47
59
  ## Configuration
48
60
 
@@ -65,6 +77,7 @@ export default {
65
77
  "cross-release": {
66
78
  // "commit": false,
67
79
  commit: {
80
+ signoff: true,
68
81
  // Whether to stage all un-staged files or stage only changed files
69
82
  stageAll: false,
70
83
  // the symbol '%s' will be replace to the version number that you specified
@@ -76,6 +89,8 @@ export default {
76
89
  dry: false,
77
90
  // Your config will be append within default exclude folders
78
91
  excludes: ["path/to/exclude"],
92
+ // use for read current version number
93
+ main: "javascript",
79
94
  // "push": false,
80
95
  push: {
81
96
  branch: false,
package/dist/app.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReleaseOptions } from "./types-D4PQyQEq.js";
1
+ import { ReleaseOptions } from "./types-Bmp7nnWP.js";
2
2
  import { ProjectFile } from "cross-bump";
3
3
 
4
4
  //#region src/app.d.ts
@@ -13,6 +13,7 @@ declare class App {
13
13
  private _taskStatus;
14
14
  constructor(argv?: string[]);
15
15
  checkGitClean(): void;
16
+ checkGitRemote(): void;
16
17
  confirmReleaseOptions(): Promise<void>;
17
18
  executeTasks(): Promise<void>;
18
19
  resolveExecutes(): void;
@@ -24,5 +25,6 @@ declare class App {
24
25
  get nextVersion(): string;
25
26
  get options(): ReleaseOptions;
26
27
  get projectFiles(): ProjectFile[];
27
- } //#endregion
28
+ }
29
+ //#endregion
28
30
  export { App as default };
package/dist/app.js CHANGED
@@ -72,6 +72,7 @@ let ExitCode = /* @__PURE__ */ function(ExitCode$1) {
72
72
  ExitCode$1[ExitCode$1["Canceled"] = 2] = "Canceled";
73
73
  ExitCode$1[ExitCode$1["FatalError"] = 1] = "FatalError";
74
74
  ExitCode$1[ExitCode$1["GitDirty"] = 3] = "GitDirty";
75
+ ExitCode$1[ExitCode$1["GitUnreachable"] = 4] = "GitUnreachable";
75
76
  ExitCode$1[ExitCode$1["InvalidArgument"] = 9] = "InvalidArgument";
76
77
  ExitCode$1[ExitCode$1["Success"] = 0] = "Success";
77
78
  return ExitCode$1;
@@ -150,19 +151,19 @@ const cliOptions = z.object({
150
151
 
151
152
  //#endregion
152
153
  //#region package.json
153
- var version = "0.2.1";
154
+ var version = "0.3.0";
154
155
 
155
156
  //#endregion
156
157
  //#region src/cli.ts
157
158
  const debug$3 = createDebug("cli");
158
159
  function createCliProgram(argv) {
159
- const cli = cac("cross-release").usage("A release tool that support multi programming language").version(version).usage("[version] [options]").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", "Pushing Commit with signoff").option("--commit.stageAll", "Stage all changes before pushing").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("--push.followTags", "pushing with follow tags").option("--tag", "Tagging for release").option("--tag.template <template>", "Template for tag message").help();
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();
160
161
  return cli.parse(argv);
161
162
  }
162
163
  function argvToReleaseOptions(cli) {
163
164
  const { args, options } = cli;
164
165
  const opts = {
165
- commit: options.commit,
166
+ commit: merge({ stageAll: options.all }, options.commit),
166
167
  config: options.config,
167
168
  cwd: options.cwd,
168
169
  debug: options.debug,
@@ -225,6 +226,27 @@ const execa = execaSync({
225
226
  all: true,
226
227
  reject: false
227
228
  });
229
+ function gitLsRemote(options) {
230
+ const { cwd = process.cwd(), dry = false, mode = "branches", pattern, remote, repository = "origin" } = options;
231
+ const s = spinner();
232
+ s.start("listing remote...");
233
+ const args = [];
234
+ if (remote) args.push(remote);
235
+ if (mode) args.push(`--${mode}`);
236
+ args.push(repository);
237
+ if (pattern) args.push(pattern);
238
+ debug$2(`command: git ls-remote ${args.join(" ")}`);
239
+ if (!dry) {
240
+ const { all, exitCode, failed, shortMessage } = execa("git", ["ls-remote", ...args], { cwd });
241
+ debug$2("git ls-remote stdout:", all);
242
+ if (failed) {
243
+ s.stop(color.red(shortMessage), exitCode);
244
+ return false;
245
+ }
246
+ }
247
+ s.stop(`listed remote`);
248
+ return true;
249
+ }
228
250
  function gitTag(options) {
229
251
  const { cwd = process.cwd(), del = false, dry = false, force = false, message: message$1, tagName: name } = options ?? {};
230
252
  const s = spinner();
@@ -232,15 +254,7 @@ function gitTag(options) {
232
254
  const args = [];
233
255
  if (del) args.push("--delete");
234
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");
235
- else args.push(
236
- // Create an annotated tag, which is recommended for releases.
237
- // See https://git-scm.com/docs/git-tag
238
- "--annotate",
239
- // Use the same commit message for the tag
240
- "--message",
241
- // formatMessageString(template, nextVersion),
242
- message$1
243
- );
257
+ else args.push("--annotate", "--message", message$1);
244
258
  if (force) args.push("--force");
245
259
  args.push(name);
246
260
  debug$2(`command: git tag ${args.join(" ")}`);
@@ -491,11 +505,23 @@ var App = class {
491
505
  const commit = resolveAltOptions(this._options, "commit");
492
506
  const isClean = isGitClean({ cwd });
493
507
  if (!isClean && !commit.stageAll) {
494
- log.warn("git is not clean, please commit or stash your changes before release");
508
+ log.warn("git is not clean, please commit or stash your changes");
495
509
  this.#done();
496
510
  process.exit(ExitCode.GitDirty);
497
511
  }
498
512
  }
513
+ checkGitRemote() {
514
+ const { cwd, debug: debug$5, dry } = this._options;
515
+ const hasRemote = gitLsRemote({
516
+ cwd,
517
+ dry: dry || debug$5
518
+ });
519
+ if (!hasRemote) {
520
+ log.warn("git remote not found, please add remote or check your network");
521
+ this.#done();
522
+ process.exit(ExitCode.GitUnreachable);
523
+ }
524
+ }
499
525
  async confirmReleaseOptions() {
500
526
  const { cwd, dry, yes } = this._options;
501
527
  const confirmTask = async (name, message$1, exec) => {
@@ -643,6 +669,7 @@ var App = class {
643
669
  async run() {
644
670
  this.#start();
645
671
  this.checkGitClean();
672
+ this.checkGitRemote();
646
673
  this.resolveProjectFiles();
647
674
  await this.resolveNextVersion();
648
675
  this.resolveProjects();
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { DefineConfigOptions } from "./types-D4PQyQEq.js";
1
+ import { DefineConfigOptions } from "./types-Bmp7nnWP.js";
2
2
 
3
3
  //#region src/index.d.ts
4
4
  declare function defineConfig(config: DefineConfigOptions): DefineConfigOptions;
5
-
6
5
  //#endregion
7
6
  export { defineConfig };
@@ -0,0 +1,114 @@
1
+ import { ProjectCategory } from "cross-bump";
2
+ import "cac";
3
+
4
+ //#region src/types.d.ts
5
+
6
+ type DefineConfigOptions = Partial<Omit<ReleaseOptions, "config">>;
7
+ type ReleaseOptions = {
8
+ /**
9
+ * Indicates whether to commit the changes.
10
+ */
11
+ commit: boolean | CommitOptions;
12
+ /**
13
+ * Specifies the path to the configuration file.
14
+ */
15
+ config: string;
16
+ /**
17
+ * The directory path where the operation will be performed.
18
+ * @default process.cwd()
19
+ */
20
+ cwd: string;
21
+ /**
22
+ * Enable debug log
23
+ */
24
+ debug: boolean;
25
+ /**
26
+ * Whether the operation is being run in a dry-run mode (simulated execution).
27
+ */
28
+ dry: boolean;
29
+ /**
30
+ * The list of directories to exclude from the search.
31
+ * @default ["node_modules", ".git", "target", "build", "dist"]
32
+ */
33
+ exclude: string[];
34
+ /**
35
+ * The command to execute before pushing.
36
+ */
37
+ execute: string[];
38
+ /**
39
+ * Specifies the main project category.
40
+ */
41
+ main: ProjectCategory;
42
+ /**
43
+ * Whether push changes to remote and push options
44
+ * @default false
45
+ */
46
+ push: boolean | PushOptions;
47
+ /**
48
+ * Specifies whether the operation should be performed recursively.
49
+ * @default false
50
+ */
51
+ recursive: boolean;
52
+ /**
53
+ * Indicates whether to create a tag for a release.
54
+ * @default false
55
+ */
56
+ tag: boolean | TagOptions;
57
+ /**
58
+ * The version string associated with the command or operation.
59
+ */
60
+ version: string;
61
+ /**
62
+ * Whether all prompts requiring user input will be answered with "yes".
63
+ * @default false
64
+ */
65
+ yes: boolean;
66
+ };
67
+ type CommitOptions = {
68
+ /**
69
+ * Whether to sign the commit.
70
+ * @default true
71
+ */
72
+ signoff?: true;
73
+ /**
74
+ * Whether to stage all files or only modified files.
75
+ * @default false
76
+ */
77
+ stageAll?: boolean;
78
+ /**
79
+ * The template string for the commit message. if the template contains any "%s" placeholders,
80
+ * then they are replaced with the version number;
81
+ * @default "chore: release v%s"
82
+ */
83
+ template?: string;
84
+ /**
85
+ * Whether to enable git pre-commit and commit-msg hook.
86
+ * @default true
87
+ */
88
+ verify?: boolean;
89
+ };
90
+ type PushOptions = {
91
+ /**
92
+ * The branch name, Use the same branch name as the local if not specified.
93
+ */
94
+ branch?: string;
95
+ /**
96
+ * Whether to follow tags
97
+ * @default true
98
+ */
99
+ followTags?: boolean;
100
+ /**
101
+ * The remote name, defaults to the upstream defined in the Git repository if not specified.
102
+ */
103
+ remote?: string;
104
+ };
105
+ type TagOptions = {
106
+ /**
107
+ * The template for tag name, same as @type {CommitOptions.template}
108
+ * if the template contains any "%s" placeholders,
109
+ * then they are replaced with the version number;
110
+ */
111
+ template?: string;
112
+ };
113
+ //#endregion
114
+ export { DefineConfigOptions, ReleaseOptions };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cross-release-cli",
3
3
  "type": "module",
4
- "version": "0.2.2",
4
+ "version": "0.4.0",
5
5
  "description": "command line app for cross language bump utility",
6
6
  "author": {
7
7
  "name": "rainbowatcher",
@@ -18,6 +18,7 @@
18
18
  "url": "https://github.com/rainbowatcher/cross-release/issues"
19
19
  },
20
20
  "main": "dist/index.js",
21
+ "types": "./dist/index.d.ts",
21
22
  "bin": {
22
23
  "cross-release": "./bin/cross-release.js"
23
24
  },
@@ -26,19 +27,19 @@
26
27
  "dist"
27
28
  ],
28
29
  "dependencies": {
29
- "@clack/prompts": "^0.10.1",
30
+ "@clack/prompts": "^0.11.0",
30
31
  "@rainbowatcher/common": "^0.7.0",
31
32
  "@rainbowatcher/fs-extra": "^0.7.0",
32
33
  "@rainbowatcher/path-extra": "^0.7.0",
33
34
  "cac": "^6.7.14",
34
35
  "debug": "^4.4.1",
35
36
  "defu": "^6.1.4",
36
- "execa": "^9.5.3",
37
+ "execa": "^9.6.0",
37
38
  "is-unicode-supported": "^2.1.0",
38
39
  "picocolors": "^1.1.1",
39
40
  "unconfig": "^7.3.2",
40
- "zod": "^3.24.4",
41
- "cross-bump": "0.2.2"
41
+ "zod": "^4.0.17",
42
+ "cross-bump": "0.4.0"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@rainbowatcher/maybe": "^0.7.0"
@@ -1,112 +0,0 @@
1
- import { ProjectCategory } from "cross-bump";
2
-
3
- //#region src/types.d.ts
4
-
5
- type DefineConfigOptions = Partial<Omit<ReleaseOptions, "config">>;
6
- type ReleaseOptions = {
7
- /**
8
- * Indicates whether to commit the changes.
9
- */
10
- commit: boolean | CommitOptions;
11
- /**
12
- * Specifies the path to the configuration file.
13
- */
14
- config: string;
15
- /**
16
- * The directory path where the operation will be performed.
17
- * @default process.cwd()
18
- */
19
- cwd: string;
20
- /**
21
- * Enable debug log
22
- */
23
- debug: boolean;
24
- /**
25
- * Whether the operation is being run in a dry-run mode (simulated execution).
26
- */
27
- dry: boolean;
28
- /**
29
- * The list of directories to exclude from the search.
30
- * @default ["node_modules", ".git", "target", "build", "dist"]
31
- */
32
- exclude: string[];
33
- /**
34
- * The command to execute before pushing.
35
- */
36
- execute: string[];
37
- /**
38
- * Specifies the main project category.
39
- */
40
- main: ProjectCategory;
41
- /**
42
- * Whether push changes to remote and push options
43
- * @default false
44
- */
45
- push: boolean | PushOptions;
46
- /**
47
- * Specifies whether the operation should be performed recursively.
48
- * @default false
49
- */
50
- recursive: boolean;
51
- /**
52
- * Indicates whether to create a tag for a release.
53
- * @default false
54
- */
55
- tag: boolean | TagOptions;
56
- /**
57
- * The version string associated with the command or operation.
58
- */
59
- version: string;
60
- /**
61
- * Whether all prompts requiring user input will be answered with "yes".
62
- * @default false
63
- */
64
- yes: boolean;
65
- };
66
- type CommitOptions = {
67
- /**
68
- * Whether to sign the commit.
69
- * @default true
70
- */
71
- signoff?: true;
72
- /**
73
- * Whether to stage all files or only modified files.
74
- * @default false
75
- */
76
- stageAll?: boolean;
77
- /**
78
- * The template string for the commit message. if the template contains any "%s" placeholders,
79
- * then they are replaced with the version number;
80
- * @default "chore: release v%s"
81
- */
82
- template?: string;
83
- /**
84
- * Whether to enable git pre-commit and commit-msg hook.
85
- * @default true
86
- */
87
- verify?: boolean;
88
- };
89
- type PushOptions = {
90
- /**
91
- * The branch name, Use the same branch name as the local if not specified.
92
- */
93
- branch?: string;
94
- /**
95
- * Whether to follow tags
96
- * @default true
97
- */
98
- followTags?: boolean;
99
- /**
100
- * The remote name, defaults to the upstream defined in the Git repository if not specified.
101
- */
102
- remote?: string;
103
- };
104
- type TagOptions = {
105
- /**
106
- * The template for tag name, same as @type {CommitOptions.template}
107
- * if the template contains any "%s" placeholders,
108
- * then they are replaced with the version number;
109
- */
110
- template?: string;
111
- }; //#endregion
112
- export { DefineConfigOptions, ReleaseOptions };