Skip to content

Commit

Permalink
✨ feat(vercel-deploy-tool): 增加 isShowCommand 命令。控制是否显示出目前正在运行的命令。
Browse files Browse the repository at this point in the history
  • Loading branch information
ruan-cat committed Dec 3, 2024
1 parent 358691f commit 5c3d803
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions .config/vercel-deploy-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default <Config>{
vercelOrgId: "",
vercelProjectId: "",

isShowCommand: true,
// afterBuildTasks: ["pnpm turbo build:docs"],

// FIXME: execa运行的turbo命令,不会使用cache缓存,导致了重复构建。
Expand Down
7 changes: 7 additions & 0 deletions packages/vercel-deploy-tool/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @ruan-cat/vercel-deploy-tool

## 0.5.0

### Minor Changes

- 增加 isShowCommand 命令。控制是否显示出目前正在运行的命令。
- 显示的命令为渐变彩色。使用和 turborepo 相同的渐变色。rgb(0, 153, 247) 到 rgb(241, 23, 18)。

## 0.4.2

### Patch Changes
Expand Down
3 changes: 2 additions & 1 deletion packages/vercel-deploy-tool/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ruan-cat/vercel-deploy-tool",
"version": "0.4.2",
"version": "0.5.0",
"description": "阮喵喵自用的vercel部署工具,用于实现复杂项目的部署。",
"type": "module",
"main": "./src/index.ts",
Expand Down Expand Up @@ -52,6 +52,7 @@
"c12": "^1.11.2",
"commander": "^12.0.0",
"consola": "^3.2.3",
"gradient-string": "^3.0.0",
"lodash-es": "catalog:",
"pathe": "^1.1.2",
"rimraf": "^6.0.1",
Expand Down
7 changes: 7 additions & 0 deletions packages/vercel-deploy-tool/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ export interface Config {
*/
vercelJsonPath?: string;

/**
* 是否显示运行命令?
* @description
* 默认不显示运行命令。
*/
isShowCommand?: boolean;

/** 在build命令阶段后 执行的用户命令 */
afterBuildTasks?: string[];

Expand Down
7 changes: 7 additions & 0 deletions packages/vercel-deploy-tool/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import fs, {

import { concat, isEmpty, isUndefined } from "lodash-es";
import { consola } from "consola";
import gradient from "gradient-string";

import {
isConditionsEvery,
Expand Down Expand Up @@ -169,6 +170,12 @@ function getTargetCWDCommandArgument(deployTarget: DeployTarget) {
*/
function generateExeca(execaSimpleParams: { command: string; parameters: string[] }) {
const { command, parameters } = execaSimpleParams;

if (config?.isShowCommand) {
const coloredCommand = gradient(["rgb(0, 153, 247)", "rgb(241, 23, 18)"])(`${command} ${parameters.join(" ")}`);
consola.info(` 当前运行的命令为: ${coloredCommand} \n`);
}

return generateSimpleAsyncTask(() => spawnSync(command, parameters, { shell: true }));
}

Expand Down

0 comments on commit 5c3d803

Please sign in to comment.