@ruan-cat/vercel-deploy-tool 0.5.9 → 0.6.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/package.json +2 -2
- package/src/index.ts +36 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruan-cat/vercel-deploy-tool",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.2",
|
|
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.
|
|
54
|
+
"@ruan-cat/utils": "^1.5.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/gulp": "^4.0.17",
|
package/src/index.ts
CHANGED
|
@@ -168,15 +168,45 @@ function getTargetCWDCommandArgument(deployTarget: DeployTarget) {
|
|
|
168
168
|
* 封装 spawnSync 函数
|
|
169
169
|
* @version 2
|
|
170
170
|
*/
|
|
171
|
-
function generateExeca(execaSimpleParams: {
|
|
172
|
-
|
|
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;
|
|
173
182
|
|
|
174
183
|
if (config?.isShowCommand) {
|
|
175
184
|
const coloredCommand = gradient(["rgb(0, 153, 247)", "rgb(241, 23, 18)"])(`${command} ${parameters.join(" ")}`);
|
|
176
185
|
consola.info(` 当前运行的命令为: ${coloredCommand} \n`);
|
|
177
186
|
}
|
|
178
187
|
|
|
179
|
-
return generateSimpleAsyncTask(() =>
|
|
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;
|
|
209
|
+
});
|
|
180
210
|
}
|
|
181
211
|
|
|
182
212
|
/**
|
|
@@ -377,6 +407,8 @@ function generateDeployTask(deployTarget: DeployTarget) {
|
|
|
377
407
|
getTargetCWDCommandArgument(deployTarget),
|
|
378
408
|
getVercelTokenCommandArgument(),
|
|
379
409
|
),
|
|
410
|
+
// 部署任务不需要流式输出
|
|
411
|
+
isFlow: false,
|
|
380
412
|
});
|
|
381
413
|
}
|
|
382
414
|
|
|
@@ -481,12 +513,8 @@ async function main() {
|
|
|
481
513
|
parameters: [],
|
|
482
514
|
});
|
|
483
515
|
consola.start(` 开始用户命令任务 `);
|
|
484
|
-
|
|
485
|
-
process.stdout.write(child.stdout);
|
|
486
|
-
process.stderr.write(child.stderr);
|
|
487
|
-
// consola.success(` 完成用户命令任务 ${code} `);
|
|
516
|
+
await userCommand();
|
|
488
517
|
consola.success(` 完成用户命令任务 `);
|
|
489
|
-
// consola.box(stdout);
|
|
490
518
|
});
|
|
491
519
|
}),
|
|
492
520
|
},
|
|
@@ -525,7 +553,6 @@ async function main() {
|
|
|
525
553
|
if (error) {
|
|
526
554
|
consola.error(" 部署失败了 \n");
|
|
527
555
|
consola.error(error);
|
|
528
|
-
process.stderr.write(stderr);
|
|
529
556
|
return;
|
|
530
557
|
}
|
|
531
558
|
|
|
@@ -534,7 +561,6 @@ async function main() {
|
|
|
534
561
|
consola.box(vercelUrl);
|
|
535
562
|
|
|
536
563
|
consola.success(` 部署任务输出如下: \n`);
|
|
537
|
-
process.stdout.write(stdout);
|
|
538
564
|
console.log(`\n`);
|
|
539
565
|
|
|
540
566
|
return vercelUrl;
|