@ruan-cat/vercel-deploy-tool 0.6.2 → 0.7.4
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/config.ts +0 -7
- package/src/index.ts +18 -48
- package/tsconfig.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruan-cat/vercel-deploy-tool",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.4",
|
|
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": "^
|
|
54
|
+
"@ruan-cat/utils": "^2.0.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/gulp": "^4.0.17",
|
package/src/config.ts
CHANGED
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-cjs";
|
|
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
|
-
*
|
|
167
|
+
* 二次封装函数,在此仅仅负责为打印内容增加颜色。
|
|
167
168
|
*
|
|
168
|
-
*
|
|
169
|
-
* @version 2
|
|
169
|
+
* @version 3
|
|
170
170
|
*/
|
|
171
|
-
function
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
481
|
+
const userCommand = generateSpawnSync({
|
|
512
482
|
command,
|
|
513
483
|
parameters: [],
|
|
514
484
|
});
|