@ruan-cat/vercel-deploy-tool 0.6.1 → 0.7.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruan-cat/vercel-deploy-tool",
3
- "version": "0.6.1",
3
+ "version": "0.7.1",
4
4
  "description": "阮喵喵自用的vercel部署工具,用于实现复杂项目的部署。",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -51,7 +51,7 @@
51
51
  "rimraf": "^6.0.1",
52
52
  "shx": "^0.3.4",
53
53
  "vercel": "39.3.0",
54
- "@ruan-cat/utils": "^1.5.0"
54
+ "@ruan-cat/utils": "^1.7.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/gulp": "^4.0.17",
package/src/config.ts CHANGED
@@ -109,13 +109,6 @@ export interface Config {
109
109
  */
110
110
  vercelJsonPath?: string;
111
111
 
112
- /**
113
- * 是否显示运行命令?
114
- * @description
115
- * 默认不显示运行命令。
116
- */
117
- isShowCommand?: boolean;
118
-
119
112
  /** 在build命令阶段后 执行的用户命令 */
120
113
  afterBuildTasks?: string[];
121
114
 
package/src/index.ts CHANGED
@@ -26,6 +26,7 @@ import {
26
26
  executePromiseTasks,
27
27
  } from "@ruan-cat/utils";
28
28
  import type { Task } from "@ruan-cat/utils";
29
+ import { generateSpawnSync as generateSpawnSyncUtils, type SpawnSyncSimpleParams } from "@ruan-cat/utils/node";
29
30
 
30
31
  import { config, getConfig } from "./config";
31
32
  import type { Config, Base, DeployTarget, WithUserCommands } from "./config";
@@ -163,25 +164,18 @@ function getTargetCWDCommandArgument(deployTarget: DeployTarget) {
163
164
  /**
164
165
  * 生成简单的执行命令函数
165
166
  * @description
166
- * 对 execa 做简单的包装
167
+ * 二次封装函数,在此仅仅负责为打印内容增加颜色。
167
168
  *
168
- * 封装 spawnSync 函数
169
- * @version 2
169
+ * @version 3
170
170
  */
171
- function generateExeca(execaSimpleParams: { command: string; parameters: string[] }) {
172
- const { command, parameters } = execaSimpleParams;
173
-
174
- if (config?.isShowCommand) {
175
- const coloredCommand = gradient(["rgb(0, 153, 247)", "rgb(241, 23, 18)"])(`${command} ${parameters.join(" ")}`);
176
- consola.info(` 当前运行的命令为: ${coloredCommand} \n`);
177
- }
178
-
179
- return generateSimpleAsyncTask(() => {
180
- const result = spawnSync(command, parameters, { stdio: "inherit", shell: true });
181
- if (result.error) {
182
- throw result.error;
183
- }
184
- return result;
171
+ function generateSpawnSync(spawnSyncSimpleParams: SpawnSyncSimpleParams) {
172
+ return generateSpawnSyncUtils({
173
+ ...spawnSyncSimpleParams,
174
+ printCurrentCommand(params) {
175
+ const { command, parameters } = params;
176
+ const coloredCommand = gradient(["rgb(0, 153, 247)", "rgb(241, 23, 18)"])(`${command} ${parameters.join(" ")}`);
177
+ consola.info(` 当前运行的命令为: ${coloredCommand} \n`);
178
+ },
185
179
  });
186
180
  }
187
181
 
@@ -193,7 +187,7 @@ function generateExeca(execaSimpleParams: { command: string; parameters: string[
193
187
  * vc link --yes --cwd=${{env.p1}} --project=${{env.pjn}} -t ${{env.vct}}
194
188
  */
195
189
  function generateLinkTask(deployTarget: DeployTarget) {
196
- return generateExeca({
190
+ return generateSpawnSync({
197
191
  command: "vc link",
198
192
  parameters: concat(
199
193
  getYesCommandArgument(),
@@ -212,7 +206,7 @@ function generateLinkTask(deployTarget: DeployTarget) {
212
206
  * vc build --yes --prod --cwd=${{env.p1}} -A ./vercel.null.json -t ${{env.vct}}
213
207
  */
214
208
  function generateBuildTask(deployTarget: DeployTarget) {
215
- return generateExeca({
209
+ return generateSpawnSync({
216
210
  command: "vc build",
217
211
  parameters: concat(
218
212
  getYesCommandArgument(),
@@ -283,7 +277,7 @@ function generateCopyDistTasks_v1(deployTarget: WithUserCommands) {
283
277
 
284
278
  const copyDistTasks = (<const>[delCmd, createCmd, copyFileCmd, printFileCmd]).map((command) => {
285
279
  return generateSimpleAsyncTask(async function () {
286
- const commandFunction = generateExeca({
280
+ const commandFunction = generateSpawnSync({
287
281
  command,
288
282
  parameters: [],
289
283
  });
@@ -360,7 +354,7 @@ function generateCopyDistTasks(deployTarget: WithUserCommands) {
360
354
  * vc alias set "$url1" ${{env.p1-url}} -t ${{env.vct}}
361
355
  */
362
356
  function generateAliasTask(vercelUrl: string, userUrl: string) {
363
- return generateExeca({
357
+ return generateSpawnSync({
364
358
  command: `vc alias set ${vercelUrl} ${userUrl}`,
365
359
  parameters: concat(getVercelTokenCommandArgument()),
366
360
  });
@@ -374,7 +368,7 @@ function generateAliasTask(vercelUrl: string, userUrl: string) {
374
368
  * vc deploy --yes --prebuilt --prod --cwd=${{env.p1}} -t ${{env.vct}}
375
369
  */
376
370
  function generateDeployTask(deployTarget: DeployTarget) {
377
- return generateExeca({
371
+ return generateSpawnSync({
378
372
  command: "vc deploy",
379
373
  parameters: concat(
380
374
  getYesCommandArgument(),
@@ -383,6 +377,8 @@ function generateDeployTask(deployTarget: DeployTarget) {
383
377
  getTargetCWDCommandArgument(deployTarget),
384
378
  getVercelTokenCommandArgument(),
385
379
  ),
380
+ // 部署任务不需要流式输出
381
+ isFlow: false,
386
382
  });
387
383
  }
388
384
 
@@ -404,7 +400,7 @@ function generateAfterBuildTasksConfig(config: Config): Task {
404
400
  type: "queue",
405
401
  tasks: afterBuildTasks!.map((command) => {
406
402
  return generateSimpleAsyncTask(async () => {
407
- const userCommand = generateExeca({
403
+ const userCommand = generateSpawnSync({
408
404
  command,
409
405
  parameters: [],
410
406
  });
@@ -482,17 +478,13 @@ async function main() {
482
478
  type: "queue",
483
479
  tasks: deployTarget.userCommands.map((command) => {
484
480
  return generateSimpleAsyncTask(async () => {
485
- const userCommand = generateExeca({
481
+ const userCommand = generateSpawnSync({
486
482
  command,
487
483
  parameters: [],
488
484
  });
489
485
  consola.start(` 开始用户命令任务 `);
490
- const child = await userCommand();
491
- process.stdout.write(child.stdout);
492
- process.stderr.write(child.stderr);
493
- // consola.success(` 完成用户命令任务 ${code} `);
486
+ await userCommand();
494
487
  consola.success(` 完成用户命令任务 `);
495
- // consola.box(stdout);
496
488
  });
497
489
  }),
498
490
  },
@@ -531,7 +523,6 @@ async function main() {
531
523
  if (error) {
532
524
  consola.error(" 部署失败了 \n");
533
525
  consola.error(error);
534
- process.stderr.write(stderr);
535
526
  return;
536
527
  }
537
528
 
@@ -540,7 +531,6 @@ async function main() {
540
531
  consola.box(vercelUrl);
541
532
 
542
533
  consola.success(` 部署任务输出如下: \n`);
543
- process.stdout.write(stdout);
544
534
  console.log(`\n`);
545
535
 
546
536
  return vercelUrl;
package/tsconfig.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "strict": true,
13
13
  "esModuleInterop": true,
14
14
  "resolveJsonModule": true,
15
- "moduleResolution": "node",
15
+ "moduleResolution": "bundler",
16
16
  // "rootDir": "./",
17
17
  // 不能这样配置 导致路径识别错乱
18
18
  // "rootDirs": [