@ruan-cat/vercel-deploy-tool 0.6.2 → 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.2",
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,49 +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: {
172
- command: string;
173
- parameters: string[];
174
- /**
175
- * 是否流式输出内容
176
- * @description 默认输出的命令数据全部以流式的方式输出
177
- * @default true
178
- */
179
- isFlow?: boolean;
180
- }) {
181
- const { command, parameters, isFlow = true } = execaSimpleParams;
182
-
183
- if (config?.isShowCommand) {
184
- const coloredCommand = gradient(["rgb(0, 153, 247)", "rgb(241, 23, 18)"])(`${command} ${parameters.join(" ")}`);
185
- consola.info(` 当前运行的命令为: ${coloredCommand} \n`);
186
- }
187
-
188
- return generateSimpleAsyncTask(() => {
189
- const result = spawnSync(command, parameters, {
190
- /**
191
- * 是否流式输出?
192
- * 是流式输出就是继承父进程的流式输出
193
- * 否则就使用默认值
194
- * @see https://nodejs.org/api/child_process.html#optionsstdio
195
- */
196
- stdio: isFlow ? "inherit" : "pipe",
197
- shell: true,
198
- });
199
-
200
- // 如果不是流式输出 就直接返回返回值即可
201
- if (!isFlow) {
202
- return result;
203
- }
204
-
205
- if (result.error) {
206
- throw result.error;
207
- }
208
- 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
+ },
209
179
  });
210
180
  }
211
181
 
@@ -217,7 +187,7 @@ function generateExeca(execaSimpleParams: {
217
187
  * vc link --yes --cwd=${{env.p1}} --project=${{env.pjn}} -t ${{env.vct}}
218
188
  */
219
189
  function generateLinkTask(deployTarget: DeployTarget) {
220
- return generateExeca({
190
+ return generateSpawnSync({
221
191
  command: "vc link",
222
192
  parameters: concat(
223
193
  getYesCommandArgument(),
@@ -236,7 +206,7 @@ function generateLinkTask(deployTarget: DeployTarget) {
236
206
  * vc build --yes --prod --cwd=${{env.p1}} -A ./vercel.null.json -t ${{env.vct}}
237
207
  */
238
208
  function generateBuildTask(deployTarget: DeployTarget) {
239
- return generateExeca({
209
+ return generateSpawnSync({
240
210
  command: "vc build",
241
211
  parameters: concat(
242
212
  getYesCommandArgument(),
@@ -307,7 +277,7 @@ function generateCopyDistTasks_v1(deployTarget: WithUserCommands) {
307
277
 
308
278
  const copyDistTasks = (<const>[delCmd, createCmd, copyFileCmd, printFileCmd]).map((command) => {
309
279
  return generateSimpleAsyncTask(async function () {
310
- const commandFunction = generateExeca({
280
+ const commandFunction = generateSpawnSync({
311
281
  command,
312
282
  parameters: [],
313
283
  });
@@ -384,7 +354,7 @@ function generateCopyDistTasks(deployTarget: WithUserCommands) {
384
354
  * vc alias set "$url1" ${{env.p1-url}} -t ${{env.vct}}
385
355
  */
386
356
  function generateAliasTask(vercelUrl: string, userUrl: string) {
387
- return generateExeca({
357
+ return generateSpawnSync({
388
358
  command: `vc alias set ${vercelUrl} ${userUrl}`,
389
359
  parameters: concat(getVercelTokenCommandArgument()),
390
360
  });
@@ -398,7 +368,7 @@ function generateAliasTask(vercelUrl: string, userUrl: string) {
398
368
  * vc deploy --yes --prebuilt --prod --cwd=${{env.p1}} -t ${{env.vct}}
399
369
  */
400
370
  function generateDeployTask(deployTarget: DeployTarget) {
401
- return generateExeca({
371
+ return generateSpawnSync({
402
372
  command: "vc deploy",
403
373
  parameters: concat(
404
374
  getYesCommandArgument(),
@@ -430,7 +400,7 @@ function generateAfterBuildTasksConfig(config: Config): Task {
430
400
  type: "queue",
431
401
  tasks: afterBuildTasks!.map((command) => {
432
402
  return generateSimpleAsyncTask(async () => {
433
- const userCommand = generateExeca({
403
+ const userCommand = generateSpawnSync({
434
404
  command,
435
405
  parameters: [],
436
406
  });
@@ -508,7 +478,7 @@ async function main() {
508
478
  type: "queue",
509
479
  tasks: deployTarget.userCommands.map((command) => {
510
480
  return generateSimpleAsyncTask(async () => {
511
- const userCommand = generateExeca({
481
+ const userCommand = generateSpawnSync({
512
482
  command,
513
483
  parameters: [],
514
484
  });
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": [