@varlet/release 0.2.11 → 0.3.1-alpha.1730553381783

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/LICENCE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2022 varlet
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 varlet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/bin/index.js CHANGED
@@ -1,9 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import { release, publish, changelog, commitLint } from '../dist/index.js'
3
3
  import { Command } from 'commander'
4
+ import { fileURLToPath } from 'url'
5
+ import fse from 'fs-extra'
4
6
 
5
7
  const program = new Command()
6
8
 
9
+ const packageJson = fse.readJSONSync(fileURLToPath(new URL('../package.json', import.meta.url)))
10
+
11
+ program.version(packageJson.version)
12
+
7
13
  program
8
14
  .command('release')
9
15
  .option('-r --remote <remote>', 'Remote name')
package/dist/index.cjs CHANGED
@@ -67,8 +67,8 @@ var logger_default = {
67
67
 
68
68
  // src/release.ts
69
69
  var import_semver = __toESM(require("semver"), 1);
70
- var import_inquirer = __toESM(require("inquirer"), 1);
71
- var import_execa = require("execa");
70
+ var import_prompts = require("@inquirer/prompts");
71
+ var import_tinyexec = require("tinyexec");
72
72
  var import_nanospinner2 = require("nanospinner");
73
73
  var import_glob = require("glob");
74
74
  var import_path2 = require("path");
@@ -95,11 +95,10 @@ function changelog({ releaseCount = 0, file = "CHANGELOG.md" } = {}) {
95
95
  // src/release.ts
96
96
  var cwd = process.cwd();
97
97
  var { writeFileSync, readJSONSync } = import_fs_extra2.default;
98
- var { prompt } = import_inquirer.default;
99
- var releaseTypes = ["premajor", "preminor", "prepatch", "major", "minor", "patch"];
98
+ var releaseTypes = ["patch", "minor", "major", "prepatch", "preminor", "premajor"];
100
99
  var BACK_HINT = "Back to previous step";
101
100
  async function isWorktreeEmpty() {
102
- const ret = await (0, import_execa.execa)("git", ["status", "--porcelain"]);
101
+ const ret = await (0, import_tinyexec.x)("git", ["status", "--porcelain"]);
103
102
  return !ret.stdout;
104
103
  }
105
104
  async function isSameVersion(version) {
@@ -109,7 +108,9 @@ async function isSameVersion(version) {
109
108
  if (packageJson) {
110
109
  const { config } = packageJson;
111
110
  try {
112
- await (0, import_execa.execa)("npm", ["view", `${config.name}@${version ?? config.version}`, "version"]);
111
+ await (0, import_tinyexec.x)("npm", ["view", `${config.name}@${version ?? config.version}`, "version"], {
112
+ throwOnError: true
113
+ });
113
114
  s.warn({
114
115
  text: `The npm package has a same remote version ${config.version}.`
115
116
  });
@@ -132,7 +133,7 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
132
133
  } else if (npmTag) {
133
134
  args.push("--tag", npmTag);
134
135
  }
135
- const ret = await (0, import_execa.execa)("pnpm", args);
136
+ const ret = await (0, import_tinyexec.x)("pnpm", args);
136
137
  if (ret.stderr && ret.stderr.includes("npm ERR!")) {
137
138
  throw new Error("\n" + ret.stderr);
138
139
  } else {
@@ -142,13 +143,23 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
142
143
  }
143
144
  async function pushGit(version, remote = "origin", skipGitTag = false) {
144
145
  const s = (0, import_nanospinner2.createSpinner)("Pushing to remote git repository").start();
145
- await (0, import_execa.execa)("git", ["add", "."]);
146
- await (0, import_execa.execa)("git", ["commit", "-m", `v${version}`]);
146
+ await (0, import_tinyexec.x)("git", ["add", "."], {
147
+ throwOnError: true
148
+ });
149
+ await (0, import_tinyexec.x)("git", ["commit", "-m", `v${version}`], {
150
+ throwOnError: true
151
+ });
147
152
  if (!skipGitTag) {
148
- await (0, import_execa.execa)("git", ["tag", `v${version}`]);
149
- await (0, import_execa.execa)("git", ["push", remote, `v${version}`]);
153
+ await (0, import_tinyexec.x)("git", ["tag", `v${version}`], {
154
+ throwOnError: true
155
+ });
156
+ await (0, import_tinyexec.x)("git", ["push", remote, `v${version}`], {
157
+ throwOnError: true
158
+ });
150
159
  }
151
- const ret = await (0, import_execa.execa)("git", ["push"]);
160
+ const ret = await (0, import_tinyexec.x)("git", ["push"], {
161
+ throwOnError: true
162
+ });
152
163
  s.success({ text: "Push remote repository successfully" });
153
164
  ret.stdout && logger_default.info(ret.stdout);
154
165
  }
@@ -170,53 +181,38 @@ function updateVersion(version) {
170
181
  });
171
182
  }
172
183
  async function confirmRegistry() {
173
- const registry = (await (0, import_execa.execa)("npm", ["config", "get", "registry"])).stdout;
174
- const name = "Registry confirm";
175
- const ret = await prompt([
176
- {
177
- name,
178
- type: "confirm",
179
- message: `Current registry is: ${registry}`
180
- }
181
- ]);
182
- return ret[name];
184
+ const registry = (await (0, import_tinyexec.x)("npm", ["config", "get", "registry"])).stdout;
185
+ const ret = await (0, import_prompts.confirm)({
186
+ message: `Current registry is: ${registry}`
187
+ });
188
+ return ret;
183
189
  }
184
190
  async function confirmVersion(currentVersion, expectVersion) {
185
- const name = "Version confirm";
186
- const ret = await prompt([
187
- {
188
- name,
189
- type: "list",
190
- choices: [`All packages version ${currentVersion} -> ${expectVersion}`, BACK_HINT]
191
- }
192
- ]);
193
- return ret[name];
191
+ const ret = await (0, import_prompts.select)({
192
+ message: "Version confirm",
193
+ choices: [`All packages version ${currentVersion} -> ${expectVersion}`, BACK_HINT].map((value) => ({
194
+ name: value,
195
+ value
196
+ }))
197
+ });
198
+ return ret;
194
199
  }
195
200
  async function confirmRefs(remote = "origin") {
196
- const { stdout } = await (0, import_execa.execa)("git", ["remote", "-v"]);
201
+ const { stdout } = await (0, import_tinyexec.x)("git", ["remote", "-v"]);
197
202
  const reg = new RegExp(`${remote} (.*) \\(push`);
198
203
  const repo = stdout.match(reg)?.[1];
199
- const { stdout: branch } = await (0, import_execa.execa)("git", ["branch", "--show-current"]);
200
- const name = "Refs confirm";
201
- const ret = await prompt([
202
- {
203
- name,
204
- type: "confirm",
205
- message: `Current refs ${repo}:refs/for/${branch}`
206
- }
207
- ]);
208
- return ret[name];
204
+ const { stdout: branch } = await (0, import_tinyexec.x)("git", ["branch", "--show-current"]);
205
+ const ret = await (0, import_prompts.confirm)({
206
+ message: `Current refs ${repo}:refs/for/${branch}`
207
+ });
208
+ return ret;
209
209
  }
210
210
  async function getReleaseType() {
211
- const name = "Please select release type";
212
- const ret = await prompt([
213
- {
214
- name,
215
- type: "list",
216
- choices: releaseTypes
217
- }
218
- ]);
219
- return ret[name];
211
+ const releaseType = await (0, import_prompts.select)({
212
+ message: "Please select release type",
213
+ choices: releaseTypes.map((type) => ({ name: type, value: type }))
214
+ });
215
+ return releaseType;
220
216
  }
221
217
  async function getReleaseVersion(currentVersion) {
222
218
  let isPreRelease = false;
@@ -269,11 +265,15 @@ async function release(options) {
269
265
  logger_default.success(`Release version ${expectVersion} successfully!`);
270
266
  if (isPreRelease) {
271
267
  try {
272
- await (0, import_execa.execa)("git", ["restore", "**/package.json"]);
268
+ await (0, import_tinyexec.x)("git", ["restore", "**/package.json"], {
269
+ throwOnError: true
270
+ });
273
271
  } catch {
274
272
  }
275
273
  try {
276
- await (0, import_execa.execa)("git", ["restore", "package.json"]);
274
+ await (0, import_tinyexec.x)("git", ["restore", "package.json"], {
275
+ throwOnError: true
276
+ });
277
277
  } catch {
278
278
  }
279
279
  }
package/dist/index.js CHANGED
@@ -23,8 +23,8 @@ var logger_default = {
23
23
 
24
24
  // src/release.ts
25
25
  import semver from "semver";
26
- import inquirer from "inquirer";
27
- import { execa } from "execa";
26
+ import { confirm, select } from "@inquirer/prompts";
27
+ import { x as exec } from "tinyexec";
28
28
  import { createSpinner as createSpinner2 } from "nanospinner";
29
29
  import { glob } from "glob";
30
30
  import { resolve } from "path";
@@ -51,11 +51,10 @@ function changelog({ releaseCount = 0, file = "CHANGELOG.md" } = {}) {
51
51
  // src/release.ts
52
52
  var cwd = process.cwd();
53
53
  var { writeFileSync, readJSONSync } = fse2;
54
- var { prompt } = inquirer;
55
- var releaseTypes = ["premajor", "preminor", "prepatch", "major", "minor", "patch"];
54
+ var releaseTypes = ["patch", "minor", "major", "prepatch", "preminor", "premajor"];
56
55
  var BACK_HINT = "Back to previous step";
57
56
  async function isWorktreeEmpty() {
58
- const ret = await execa("git", ["status", "--porcelain"]);
57
+ const ret = await exec("git", ["status", "--porcelain"]);
59
58
  return !ret.stdout;
60
59
  }
61
60
  async function isSameVersion(version) {
@@ -65,7 +64,9 @@ async function isSameVersion(version) {
65
64
  if (packageJson) {
66
65
  const { config } = packageJson;
67
66
  try {
68
- await execa("npm", ["view", `${config.name}@${version ?? config.version}`, "version"]);
67
+ await exec("npm", ["view", `${config.name}@${version ?? config.version}`, "version"], {
68
+ throwOnError: true
69
+ });
69
70
  s.warn({
70
71
  text: `The npm package has a same remote version ${config.version}.`
71
72
  });
@@ -88,7 +89,7 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
88
89
  } else if (npmTag) {
89
90
  args.push("--tag", npmTag);
90
91
  }
91
- const ret = await execa("pnpm", args);
92
+ const ret = await exec("pnpm", args);
92
93
  if (ret.stderr && ret.stderr.includes("npm ERR!")) {
93
94
  throw new Error("\n" + ret.stderr);
94
95
  } else {
@@ -98,13 +99,23 @@ async function publish({ preRelease, checkRemoteVersion, npmTag }) {
98
99
  }
99
100
  async function pushGit(version, remote = "origin", skipGitTag = false) {
100
101
  const s = createSpinner2("Pushing to remote git repository").start();
101
- await execa("git", ["add", "."]);
102
- await execa("git", ["commit", "-m", `v${version}`]);
102
+ await exec("git", ["add", "."], {
103
+ throwOnError: true
104
+ });
105
+ await exec("git", ["commit", "-m", `v${version}`], {
106
+ throwOnError: true
107
+ });
103
108
  if (!skipGitTag) {
104
- await execa("git", ["tag", `v${version}`]);
105
- await execa("git", ["push", remote, `v${version}`]);
109
+ await exec("git", ["tag", `v${version}`], {
110
+ throwOnError: true
111
+ });
112
+ await exec("git", ["push", remote, `v${version}`], {
113
+ throwOnError: true
114
+ });
106
115
  }
107
- const ret = await execa("git", ["push"]);
116
+ const ret = await exec("git", ["push"], {
117
+ throwOnError: true
118
+ });
108
119
  s.success({ text: "Push remote repository successfully" });
109
120
  ret.stdout && logger_default.info(ret.stdout);
110
121
  }
@@ -126,53 +137,38 @@ function updateVersion(version) {
126
137
  });
127
138
  }
128
139
  async function confirmRegistry() {
129
- const registry = (await execa("npm", ["config", "get", "registry"])).stdout;
130
- const name = "Registry confirm";
131
- const ret = await prompt([
132
- {
133
- name,
134
- type: "confirm",
135
- message: `Current registry is: ${registry}`
136
- }
137
- ]);
138
- return ret[name];
140
+ const registry = (await exec("npm", ["config", "get", "registry"])).stdout;
141
+ const ret = await confirm({
142
+ message: `Current registry is: ${registry}`
143
+ });
144
+ return ret;
139
145
  }
140
146
  async function confirmVersion(currentVersion, expectVersion) {
141
- const name = "Version confirm";
142
- const ret = await prompt([
143
- {
144
- name,
145
- type: "list",
146
- choices: [`All packages version ${currentVersion} -> ${expectVersion}`, BACK_HINT]
147
- }
148
- ]);
149
- return ret[name];
147
+ const ret = await select({
148
+ message: "Version confirm",
149
+ choices: [`All packages version ${currentVersion} -> ${expectVersion}`, BACK_HINT].map((value) => ({
150
+ name: value,
151
+ value
152
+ }))
153
+ });
154
+ return ret;
150
155
  }
151
156
  async function confirmRefs(remote = "origin") {
152
- const { stdout } = await execa("git", ["remote", "-v"]);
157
+ const { stdout } = await exec("git", ["remote", "-v"]);
153
158
  const reg = new RegExp(`${remote} (.*) \\(push`);
154
159
  const repo = stdout.match(reg)?.[1];
155
- const { stdout: branch } = await execa("git", ["branch", "--show-current"]);
156
- const name = "Refs confirm";
157
- const ret = await prompt([
158
- {
159
- name,
160
- type: "confirm",
161
- message: `Current refs ${repo}:refs/for/${branch}`
162
- }
163
- ]);
164
- return ret[name];
160
+ const { stdout: branch } = await exec("git", ["branch", "--show-current"]);
161
+ const ret = await confirm({
162
+ message: `Current refs ${repo}:refs/for/${branch}`
163
+ });
164
+ return ret;
165
165
  }
166
166
  async function getReleaseType() {
167
- const name = "Please select release type";
168
- const ret = await prompt([
169
- {
170
- name,
171
- type: "list",
172
- choices: releaseTypes
173
- }
174
- ]);
175
- return ret[name];
167
+ const releaseType = await select({
168
+ message: "Please select release type",
169
+ choices: releaseTypes.map((type) => ({ name: type, value: type }))
170
+ });
171
+ return releaseType;
176
172
  }
177
173
  async function getReleaseVersion(currentVersion) {
178
174
  let isPreRelease = false;
@@ -225,11 +221,15 @@ async function release(options) {
225
221
  logger_default.success(`Release version ${expectVersion} successfully!`);
226
222
  if (isPreRelease) {
227
223
  try {
228
- await execa("git", ["restore", "**/package.json"]);
224
+ await exec("git", ["restore", "**/package.json"], {
225
+ throwOnError: true
226
+ });
229
227
  } catch {
230
228
  }
231
229
  try {
232
- await execa("git", ["restore", "package.json"]);
230
+ await exec("git", ["restore", "package.json"], {
231
+ throwOnError: true
232
+ });
233
233
  } catch {
234
234
  }
235
235
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@varlet/release",
3
3
  "type": "module",
4
- "version": "0.2.11",
4
+ "version": "0.3.1-alpha.1730553381783",
5
5
  "description": "release all packages and generate changelogs",
6
6
  "keywords": [
7
7
  "varlet",
@@ -15,7 +15,7 @@
15
15
  "url": "git+https://github.com/varletjs/release"
16
16
  },
17
17
  "bugs": "https://github.com/varletjs/release/issues",
18
- "main": "./dist/index.js",
18
+ "main": "./dist/index.cjs",
19
19
  "module": "./dist/index.js",
20
20
  "types": "./dist/index.d.ts",
21
21
  "exports": {
@@ -36,8 +36,10 @@
36
36
  "commit-msg": "pnpm run commit-lint -p $1"
37
37
  },
38
38
  "lint-staged": {
39
- "*.{ts,tsx,js,vue,less}": "prettier --write",
40
- "*.{ts,tsx,js,vue}": "eslint --fix"
39
+ "*.{ts,js}": [
40
+ "prettier --write",
41
+ "eslint --fix"
42
+ ]
41
43
  },
42
44
  "engines": {
43
45
  "node": ">=16.0.0",
@@ -46,7 +48,6 @@
46
48
  "devDependencies": {
47
49
  "@types/conventional-changelog": "^3.1.5",
48
50
  "@types/fs-extra": "^11.0.4",
49
- "@types/inquirer": "^9.0.7",
50
51
  "@types/node": "^20.9.0",
51
52
  "@types/semver": "^7.5.5",
52
53
  "@varlet/eslint-config": "^2.18.4",
@@ -54,25 +55,26 @@
54
55
  "lint-staged": "^15.2.0",
55
56
  "prettier": "^3.1.0",
56
57
  "simple-git-hooks": "^2.9.0",
57
- "tsup": "^8.0.1",
58
+ "tsup": "^8.3.0",
58
59
  "typescript": "^5.2.2"
59
60
  },
60
61
  "dependencies": {
62
+ "@inquirer/prompts": "^6.0.1",
61
63
  "commander": "^11.1.0",
62
64
  "conventional-changelog": "^5.1.0",
63
- "execa": "^8.0.1",
64
65
  "fs-extra": "^11.1.1",
65
66
  "glob": "^10.3.10",
66
- "inquirer": "^9.2.12",
67
67
  "nanospinner": "^1.1.0",
68
68
  "picocolors": "^1.0.0",
69
- "semver": "^7.5.4"
69
+ "semver": "^7.5.4",
70
+ "tinyexec": "^0.3.0"
70
71
  },
71
72
  "scripts": {
72
73
  "dev": "tsup --watch",
73
74
  "build": "tsup",
74
75
  "release": "pnpm build && node bin/index.js release -c",
75
- "lint": "eslint --ext .ts,.js",
76
+ "lint": "eslint . --ext .ts,.js",
77
+ "format": "prettier --write .",
76
78
  "commit-lint": "node bin/index.js commit-lint"
77
79
  }
78
80
  }