@ruan-cat/vercel-deploy-tool 0.2.0 → 0.3.0

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.
Files changed (2) hide show
  1. package/package.json +4 -3
  2. package/src/config.ts +24 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruan-cat/vercel-deploy-tool",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "阮喵喵自用的vercel部署工具,用于实现复杂项目的部署。",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -42,6 +42,7 @@
42
42
  "dependencies": {
43
43
  "@dotenvx/dotenvx": "^1.11.5",
44
44
  "c12": "^1.11.2",
45
+ "commander": "^12.0.0",
45
46
  "consola": "^3.2.3",
46
47
  "cpx": "^1.5.0",
47
48
  "cpy": "^11.1.0",
@@ -66,8 +67,8 @@
66
67
  "scripts": {
67
68
  "—build-not-use-for-now": "tsc",
68
69
  "start": "node ./dist/index.js",
69
- "run": "vite-node ./src/index.ts --files",
70
- "test:config": "vite-node ./tests/config.test.ts --files",
70
+ "run": "node --import=tsx ./src/index.ts --env-path=.env.test",
71
+ "test:config": "node --import=tsx ./tests/config.test.ts --env-path=.env.test",
71
72
  "test:vitest": "vitest --ui --watch",
72
73
  "rm:node_modules": "rimraf node_modules"
73
74
  }
package/src/config.ts CHANGED
@@ -3,6 +3,7 @@ import { loadConfig } from "c12";
3
3
  import { config as dotenvConfig } from "@dotenvx/dotenvx";
4
4
  import { consola } from "consola";
5
5
  import { merge } from "lodash-es";
6
+ import { program } from "commander";
6
7
 
7
8
  /**
8
9
  * @description
@@ -139,12 +140,31 @@ declare module "@dotenvx/dotenvx" {
139
140
  }
140
141
  }
141
142
 
143
+ program
144
+ .name("vercel-deploy-tool")
145
+ // 环境变量的地址
146
+ .option("--env-path <path>", "环境变量的地址")
147
+ .parse();
148
+ const options = program.opts();
149
+
150
+ consola.info(" 查看命令行提供的参数 ", options);
151
+
142
152
  /** 初始化的当前的环境变量 */
143
153
  function initCurrentDotenvConfig() {
144
- const res = dotenvConfig({
145
- // 具体识别的路径,会自动识别根目录下面的env文件,故这里不作处理
146
- // path: "../../../.env"
147
- }).parsed;
154
+ // 如果存在环境变量路径 就使用并读取
155
+ const dotenvConfigParams = options?.envPath
156
+ ? {
157
+ path: options?.envPath,
158
+ }
159
+ : {};
160
+
161
+ const res = dotenvConfig(
162
+ dotenvConfigParams,
163
+ // {
164
+ // // 具体识别的路径,会自动识别根目录下面的env文件,故这里不作处理
165
+ // path: "../../../.env"
166
+ // }
167
+ ).parsed;
148
168
 
149
169
  consola.info(" 查看来自 @dotenvx/dotenvx 获取的环境变量: ");
150
170
  consola.box(res);