@wjwjq/release-helper 0.2.1 → 0.2.2

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/publish.js CHANGED
@@ -8,13 +8,13 @@ import { setTimeout } from 'node:timers/promises';
8
8
  import { Gitlab } from '@gitbeaker/rest';
9
9
  import { releaseConf, __releaseDir } from './prepare.js';
10
10
  import { logger } from './logger.js';
11
- import { $ } from 'execa';
11
+ import { execa, $ } from 'execa';
12
12
  import 'yaml';
13
13
  import 'picocolors';
14
14
 
15
15
  async function isGitFlowRepo() {
16
16
  try {
17
- let { stdout } = await $("git config", ["--get-regexp", `^gitflow.`]);
17
+ let { stdout } = await execa("git config", ["--get-regexp", `^gitflow.`]);
18
18
  return stdout.toString().length > 0;
19
19
  } catch (error) {
20
20
  console.error("\u{1F680} ~ doGitFlowRelease ~ error:", error);
package/dist/release.js CHANGED
@@ -4,7 +4,7 @@ import pc from 'picocolors';
4
4
  import { pack } from './pack.js';
5
5
  import { getGitTags, selectLatestTag, publish, isGitFlowRepo } from './publish.js';
6
6
  import { checkEnvInfo, releaseConf } from './prepare.js';
7
- import { $ } from 'execa';
7
+ import { $, execa } from 'execa';
8
8
  import { logger } from './logger.js';
9
9
  import 'node:fs';
10
10
  import 'node:path';
@@ -96,7 +96,7 @@ async function doGitFlowRelease(version) {
96
96
  let { stdout: currentBranch } = await $(`git branch --show-current`);
97
97
  const releaseBranch = `release/${version}`;
98
98
  if (currentBranch !== "develop" && currentBranch !== releaseBranch) {
99
- const { stdout } = await $("git branch -a");
99
+ const { stdout } = await $`git branch -a`;
100
100
  const branches = stdout.split("\n").map((branch) => branch.trim().replace(/^\* /, ""));
101
101
  const preReleaseBranch = branches.includes(releaseBranch) ? releaseBranch : "develop";
102
102
  await execGitCheckout(preReleaseBranch);
@@ -120,7 +120,7 @@ async function doGitFlowRelease(version) {
120
120
  }
121
121
  }
122
122
  try {
123
- const npmVersionRes = await $(`npm version ${version} --no-git-tag-version`);
123
+ const npmVersionRes = await $`npm version ${version} --no-git-tag-version`;
124
124
  if (npmVersionRes.stderr) {
125
125
  logger.error("\u6DFB\u52A0\u7248\u672C\u4FE1\u606F\u5230package.json\u5931\u8D25");
126
126
  process.exit(1);
@@ -134,16 +134,16 @@ async function doGitFlowRelease(version) {
134
134
  }
135
135
  const hasUncommitted = await hasUncommittedChanges(true);
136
136
  if (hasUncommitted) {
137
- await $(`git add -A`);
138
- await $("git commit", ["-m", `Release version: ${version}`, "--no-verify"]);
137
+ await $`git add -A`;
138
+ await execa("git commit", ["-m", `Release version: ${version}`, "--no-verify"]);
139
139
  }
140
140
  await execWithPipe(`git flow release finish`, [version, "-m", `Release version: ${version}`]);
141
- await $(`git push --all`);
142
- await $(`git push --tags`);
141
+ await $`git push --all`;
142
+ await $`git push --tags`;
143
143
  return "master";
144
144
  }
145
145
  async function doCustomSpecifyBranchRelease() {
146
- const { stdout } = await $("git branch -r");
146
+ const { stdout } = await $`git branch -r`;
147
147
  const branches = stdout.split("\n").map((branch) => branch.trim()).filter((item) => !item.startsWith("origin/HEAD")).map((branch) => ({ value: branch.replace("origin/", "") }));
148
148
  const selectedBranch = await inquirer.select({
149
149
  message: "\u8BF7\u9009\u62E9\u76EE\u6807\u5206\u652F, \u5206\u652F\u672A\u627E\u5230\uFF0C\u8BF7\u5148\u5C06\u672C\u5730\u5206\u652F\u63A8\u5230\u8FDC\u7AEF\uFF0C\u518D\u6267\u884C\u6B64\u547D\u4EE4",
@@ -164,7 +164,7 @@ async function hasUncommittedChanges(boolReturned = false) {
164
164
  }
165
165
  async function execGitPullOrigin(remoteTargetBranch) {
166
166
  logger.tip(`${remoteTargetBranch} syncing...`);
167
- const syncReleaseBranchRes = $("git", ["pull", "origin", remoteTargetBranch]);
167
+ const syncReleaseBranchRes = execa("git", ["pull", "origin", remoteTargetBranch]);
168
168
  syncReleaseBranchRes.stdout.pipe(process.stdout);
169
169
  syncReleaseBranchRes.stderr.pipe(process.stderr);
170
170
  const res = await syncReleaseBranchRes;
@@ -174,7 +174,7 @@ async function execGitPullOrigin(remoteTargetBranch) {
174
174
  }
175
175
  }
176
176
  async function execWithPipe(...args) {
177
- const execRes = $(...args);
177
+ const execRes = execa(...args);
178
178
  execRes.stdout.pipe(process.stdout);
179
179
  execRes.stderr.pipe(process.stderr);
180
180
  const result = await execRes;
@@ -182,13 +182,13 @@ async function execWithPipe(...args) {
182
182
  }
183
183
  async function execGitCheckout(remoteTargetBranch) {
184
184
  await hasUncommittedChanges();
185
- const { stdout: prevCurrentBranch } = await $(`git branch --show-current`);
185
+ const { stdout: prevCurrentBranch } = await $`git branch --show-current`;
186
186
  if (prevCurrentBranch !== remoteTargetBranch) {
187
- const execRes = $(`git checkout ${remoteTargetBranch}`);
187
+ const execRes = execa(`git checkout ${remoteTargetBranch}`);
188
188
  execRes.stdout.pipe(process.stdout);
189
189
  execRes.stderr.pipe(process.stderr);
190
190
  const result = await execRes;
191
- const { stdout: currentBranch } = await $(`git branch --show-current`);
191
+ const { stdout: currentBranch } = await $`git branch --show-current`;
192
192
  if (currentBranch !== remoteTargetBranch) {
193
193
  logger.error(`\u76EE\u6807\u53D1\u5E03\u5206\u652F[${remoteTargetBranch}] checkout \u5931\u8D25`);
194
194
  return Promise.reject(result);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wjwjq/release-helper",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "generate deployment package for frontend, include nginx...",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",