cross-release-cli 0.1.0-alpha.3 → 0.1.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
@@ -5,20 +5,10 @@
5
5
  1. install through package manager
6
6
 
7
7
  ```shell
8
- # pnpm
9
- pnpm i cross-release -g
8
+ pnpm i -D cross-release
10
9
  ```
11
10
 
12
- otherwise you can use you favorite package manager instead
13
-
14
- ```shell
15
- # npm
16
- npm i cross-release -g
17
- # yarn
18
- yarn add cross-release --global
19
- ```
20
-
21
- 2. add to your package.json
11
+ 2. add a release script in your package.json
22
12
 
23
13
  ```json
24
14
  {
@@ -36,51 +26,83 @@ pnpm run release
36
26
 
37
27
  ## Command line
38
28
 
39
- | short | long | description | default |
40
- | ----- | --------------- | --------------------------------------------------- | -------------------------- |
41
- | -m | --main | Main project language e.g. java / javascript / rust | `false` |
42
- | -r | --recursive | Run the command for each project in the workspace | `false` |
43
- | -d | --dry | Dry run | `false` |
44
- | -D | --dir [dir] | Set working directory | `project root` |
45
- | -c | --commit | Commit current changes | `false` |
46
- | -p | --push | Push the project to remote | `false` |
47
- | -t | --tag | Create a tag for current version | `false` |
48
- | -e | --exclude [dir] | Folders to exclude from search | `["node_modules", ".git"]` |
49
- | -y | --yes | Answer yes to all prompts | `false` |
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 |
50
46
 
51
47
  ## Configuration
52
48
 
53
- You can specify various runtime settings by using the "package.json" file. Here are some examples that cover all the parameters:
49
+ supportted file name:
54
50
 
55
- ```json
56
- {
57
- "...": "...",
51
+ - `cross-release.config.js`
52
+ - `cross-release.config.cjs`
53
+ - `cross-release.config.mjs`
54
+ - `cross-release.config.ts`
55
+ - `cross-release.config.cts`
56
+ - `cross-release.config.mts`
57
+ - `cross-release.config.json`
58
+ - `package.json`
59
+
60
+ Here are some examples that cover all the parameters:
61
+
62
+ ```ts
63
+ export default {
64
+ // ...
58
65
  "cross-release": {
59
- // show the help message
60
- "showHelp": false,
61
- // show the version about cross-release
62
- "showVersion": false,
63
- "version": "",
64
- "isAllYes": false,
65
- "isDry": false,
66
- "isRecursive": false,
67
- "shouldCommit": false,
68
- "shouldPush": false,
69
- "shouldTag": false,
70
- // default exclude folders are `["node_modules", ".git"]`, your config will be append within it
71
- "excludes": ["path/to/exclude"],
72
- "dir": "/path/to/run",
73
- "commit": {
74
- // Whether to invoke git pre-commit and commit-msg hook
75
- "shouldVerify": true,
66
+ // "commit": false,
67
+ commit: {
76
68
  // Whether to stage all un-staged files or stage only changed files
77
- "shouldStageAll": false,
69
+ stageAll: false,
78
70
  // the symbol '%s' will be replace to the version number that you specified
79
- "template": "chore: release v%s"
71
+ template: "chore: release v%s",
72
+ // Whether to invoke git pre-commit and commit-msg hook
73
+ verify: true,
74
+ },
75
+ cwd: "/path/to/run",
76
+ dry: false,
77
+ // Your config will be append within default exclude folders
78
+ excludes: ["path/to/exclude"],
79
+ // "push": false,
80
+ push: {
81
+ branch: false,
82
+ followTags: false,
83
+ },
84
+ recursive: false,
85
+ // tag: false,
86
+ tag: {
87
+ template: "v%s",
88
+ },
89
+ version: "",
90
+ yes: false,
91
+ },
92
+ }
93
+ ```
94
+
95
+ example for config in `package.json`
96
+
97
+ ```jsonc
98
+ {
99
+ // ...
100
+ "cross-release": {
101
+ "yes": true,
102
+ "commit": true,
103
+ "tag": {
104
+ "template": "v%s",
80
105
  },
81
- "push": {
82
- "shouldFollowTags": false
83
- }
84
106
  }
85
107
  }
86
108
  ```
package/dist/app.js CHANGED
@@ -22,14 +22,15 @@ import color2 from "picocolors";
22
22
  import path from "node:path";
23
23
  import { toAbsolute as toAbsolute2 } from "@rainbowatcher/path-extra";
24
24
  import { Command } from "commander";
25
- import { getGitignores } from "cross-bump";
25
+ import { DEFAULT_IGNORED_GLOBS as DEFAULT_IGNORED_GLOBS2, getGitignores } from "cross-bump";
26
26
  import { defu as defu2 } from "defu";
27
27
 
28
28
  // package.json
29
- var version = "0.1.0-alpha.2";
29
+ var version = "0.1.0-alpha.4";
30
30
 
31
31
  // src/constants.ts
32
32
  import process from "node:process";
33
+ import { DEFAULT_IGNORED_GLOBS } from "cross-bump";
33
34
  var CONFIG_DEFAULT = {
34
35
  all: false,
35
36
  commit: {
@@ -40,7 +41,7 @@ var CONFIG_DEFAULT = {
40
41
  cwd: process.cwd(),
41
42
  debug: false,
42
43
  dry: false,
43
- exclude: ["node_modules", ".git"],
44
+ exclude: DEFAULT_IGNORED_GLOBS,
44
45
  execute: [],
45
46
  main: "javascript",
46
47
  push: {
@@ -117,7 +118,7 @@ function createCliProgram() {
117
118
  cli.configureHelp({
118
119
  subcommandTerm: (cmd) => `${cmd.name()} ${cmd.usage()}`
119
120
  });
120
- cli.name("cross-release").version(version).description("A release tool that support multi programming language").usage("[version] [options]").option("-a, --all", "Add all changed files to staged", CONFIG_DEFAULT.commit.stageAll).option("-c, --config [file]", "Config file (auto detect by default)").option("-D, --dry", "Dry run", CONFIG_DEFAULT.dry).option("-d, --debug", "Enable debug mode", CONFIG_DEFAULT.debug).option("-e, --exclude [dir]", "Folders to exclude from search", CONFIG_DEFAULT.exclude).option("-m, --main", "Base project language [e.g. java, rust, javascript]", CONFIG_DEFAULT.main).option("-r, --recursive", "Run the command for each project in the workspace", CONFIG_DEFAULT.recursive).option("-x, --execute [command...]", "Execute the command", CONFIG_DEFAULT.execute).option("-y, --yes", "Answer yes to all prompts", CONFIG_DEFAULT.yes).option("--cwd [dir]", "Set working directory", CONFIG_DEFAULT.cwd).option("--no-commit", "Skip committing changes").option("--no-push", "Skip pushing").option("--no-tag", "Skip tagging").option("-h, --help", "Display this message");
121
+ cli.name("cross-release").version(version).description("A release tool that support multi programming language").usage("[version] [options]").option("-a, --all", "Add all changed files to staged", CONFIG_DEFAULT.commit.stageAll).option("-c, --config [file]", "Config file (auto detect by default)").option("-D, --dry", "Dry run", CONFIG_DEFAULT.dry).option("-d, --debug", "Enable debug mode", CONFIG_DEFAULT.debug).option("-e, --exclude [dir...]", "Folders to exclude from search", CONFIG_DEFAULT.exclude).option("-m, --main", "Base project language [e.g. java, rust, javascript]", CONFIG_DEFAULT.main).option("-r, --recursive", "Run the command for each project in the workspace", CONFIG_DEFAULT.recursive).option("-x, --execute [command...]", "Execute the command", CONFIG_DEFAULT.execute).option("-y, --yes", "Answer yes to all prompts", CONFIG_DEFAULT.yes).option("--cwd [dir]", "Set working directory", CONFIG_DEFAULT.cwd).option("--no-commit", "Skip committing changes").option("--no-push", "Skip pushing").option("--no-tag", "Skip tagging").option("-h, --help", "Display this message");
121
122
  return cli;
122
123
  }
123
124
  function toCliReleaseOptions(cli) {
@@ -128,6 +129,8 @@ function toCliReleaseOptions(cli) {
128
129
  }
129
130
  return {
130
131
  ...options,
132
+ // combine user cli exclude option with default
133
+ exclude: options.exclude?.length ? [...DEFAULT_IGNORED_GLOBS2, ...options.exclude] : DEFAULT_IGNORED_GLOBS2,
131
134
  ...args.length > 0 ? { version: args[0] } : {}
132
135
  };
133
136
  }
@@ -137,7 +140,7 @@ async function resolveOptions(cli) {
137
140
  if (cliOptions.config) {
138
141
  userConfig = await loadUserSpecifiedConfigFile(cliOptions.config, cliOptions);
139
142
  } else {
140
- userConfig = await loadUserConfig();
143
+ userConfig = await loadUserConfig(cliOptions.cwd);
141
144
  }
142
145
  const parsedArgs = defu2(cliOptions, userConfig);
143
146
  isDebugEnable(parsedArgs);
@@ -197,8 +200,8 @@ function gitTag(options) {
197
200
  args.push(name);
198
201
  debug4(`command: git tag ${args.join(" ")}`);
199
202
  if (!dry) {
200
- const { exitCode, failed, shortMessage, stderr, stdout } = execa("git", ["tag", ...args], { cwd });
201
- debug4("git tag stdout:", stdout, stderr);
203
+ const { all, exitCode, failed, shortMessage } = execa("git", ["tag", ...args], { cwd });
204
+ debug4("git tag stdout:", all);
202
205
  if (failed) {
203
206
  s.stop(color.red(shortMessage), exitCode);
204
207
  return false;
@@ -228,8 +231,8 @@ function gitCommit(options) {
228
231
  }
229
232
  debug4(`command: git commit ${args.join(" ")}`);
230
233
  if (!dry) {
231
- const { exitCode, failed, shortMessage, stderr, stdout } = execa("git", ["commit", ...args], { cwd });
232
- debug4("git commit stdout:", stdout, stderr);
234
+ const { all, exitCode, failed, shortMessage } = execa("git", ["commit", ...args], { cwd });
235
+ debug4("git commit stdout: %s", all);
233
236
  if (failed) {
234
237
  s.stop(color.red(shortMessage), exitCode);
235
238
  return false;
@@ -258,8 +261,8 @@ function gitPush(options = {}) {
258
261
  followTags && args.push("--follow-tags");
259
262
  debug4(`command: git push ${args.join(" ")}`);
260
263
  if (!dry) {
261
- const { exitCode, failed, shortMessage, stderr, stdout } = execa("git", ["push", ...args], { cwd });
262
- debug4("git push stdout:", stdout, stderr);
264
+ const { all, exitCode, failed, shortMessage } = execa("git", ["push", ...args], { cwd });
265
+ debug4("git push stdout: %s", all);
263
266
  if (failed) {
264
267
  s.stop(color.red(shortMessage), exitCode);
265
268
  return false;
@@ -282,19 +285,18 @@ function gitAdd(options = {}) {
282
285
  } = options;
283
286
  const args = [];
284
287
  if (all) {
285
- args.push("-A");
288
+ args.push("--all");
286
289
  } else if (files.length > 0) {
287
290
  args.push("--", ...files);
288
291
  }
289
292
  debug4("command: git add", args.join(" "));
290
293
  if (!dry) {
291
- const { failed, stderr, stdout } = execa("git", ["add", ...args], { cwd });
292
- debug4("git add stdout:", stdout, stderr);
294
+ const { all: all2, failed } = execa("git", ["add", ...args], { cwd });
295
+ debug4("git add stdout:", all2);
293
296
  if (failed) {
294
297
  return false;
295
298
  }
296
299
  }
297
- debug4("add files:", files);
298
300
  return true;
299
301
  }
300
302
  function isGitClean(options = {}) {
@@ -468,10 +470,11 @@ var App = class _App {
468
470
  ...CONFIG_DEFAULT.commit,
469
471
  stageAll: all
470
472
  });
473
+ const _all = stageAll ?? all;
471
474
  this.#addTask({
472
475
  exec: () => {
473
476
  return gitAdd({
474
- all: stageAll === false ? all : stageAll,
477
+ all: _all,
475
478
  cwd,
476
479
  dry,
477
480
  files: this._modifiedFiles
@@ -486,8 +489,8 @@ var App = class _App {
486
489
  cwd,
487
490
  dry,
488
491
  message: commitMessage,
489
- modifiedFiles: this._modifiedFiles,
490
- // stageAll,
492
+ modifiedFiles: _all ? void 0 : this._modifiedFiles,
493
+ stageAll: _all,
491
494
  verify
492
495
  });
493
496
  });
package/dist/types.d.ts CHANGED
@@ -49,7 +49,7 @@ type ReleaseOptions = {
49
49
  dry: boolean;
50
50
  /**
51
51
  * The list of directories to exclude from the search.
52
- * @default ["node_modules", ".git"]
52
+ * @default ["node_modules", ".git", "target", "build", "dist"]
53
53
  */
54
54
  exclude: string[];
55
55
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cross-release-cli",
3
3
  "type": "module",
4
- "version": "0.1.0-alpha.3",
4
+ "version": "0.1.0",
5
5
  "description": "command line app for cross language bump utility",
6
6
  "author": {
7
7
  "name": "rainbowatcher",
@@ -30,13 +30,13 @@
30
30
  "@rainbowatcher/fs-extra": "^0.2.3",
31
31
  "@rainbowatcher/path-extra": "^0.2.3",
32
32
  "commander": "^12.1.0",
33
- "debug": "^4.3.6",
33
+ "debug": "^4.3.7",
34
34
  "defu": "^6.1.4",
35
35
  "execa": "^9.3.1",
36
- "is-unicode-supported": "^2.0.0",
36
+ "is-unicode-supported": "^2.1.0",
37
37
  "picocolors": "^1.1.0",
38
38
  "unconfig": "^0.5.5",
39
- "cross-bump": "0.1.0-alpha.3"
39
+ "cross-bump": "0.1.0"
40
40
  },
41
41
  "scripts": {
42
42
  "clean": "rimraf dist/*",