@ruan-cat/vercel-deploy-tool 0.9.4 → 0.10.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 (3) hide show
  1. package/README.md +1 -2
  2. package/package.json +7 -7
  3. package/src/config.ts +37 -24
package/README.md CHANGED
@@ -114,7 +114,7 @@ import "@ruan-cat/vercel-deploy-tool/src/index.ts";
114
114
  "pnpm": ">=9"
115
115
  },
116
116
  "scripts": {
117
- "deploy-vercel": "node --import=tsx ./bin/vercel-deploy-tool.ts"
117
+ "deploy-vercel": "tsx ./bin/vercel-deploy-tool.ts"
118
118
  }
119
119
  }
120
120
  ```
@@ -134,4 +134,3 @@ pnpm i -D tsx
134
134
  - [x] github action 运行产物。
135
135
  - [x] github action 全局安装新开发的包,实现纯工作流的部署。
136
136
  - [x] 去其他项目,自主完成配置与部署。
137
- - [ ] 封装 node 的 bin 命令,发包。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruan-cat/vercel-deploy-tool",
3
- "version": "0.9.4",
3
+ "version": "0.10.0",
4
4
  "description": "阮喵喵自用的vercel部署工具,用于实现复杂项目的部署。",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -41,7 +41,7 @@
41
41
  "tsconfig.json"
42
42
  ],
43
43
  "dependencies": {
44
- "@dotenvx/dotenvx": "^1.47.6",
44
+ "@dotenvx/dotenvx": "^1.48.3",
45
45
  "c12": "^3.1.0",
46
46
  "commander": "^13.1.0",
47
47
  "consola": "^3.4.2",
@@ -50,22 +50,22 @@
50
50
  "pathe": "^2.0.3",
51
51
  "rimraf": "^6.0.1",
52
52
  "vercel": "^41.7.8",
53
- "@ruan-cat/utils": "^4.9.0"
53
+ "@ruan-cat/utils": "^4.9.1"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/gulp": "^4.0.17",
57
57
  "@types/lodash-es": "^4.17.12",
58
- "@types/node": "^22.16.4",
58
+ "@types/node": "^22.16.5",
59
59
  "execa": "^9.6.0",
60
60
  "vitepress": "^1.6.3",
61
- "@ruan-cat/vitepress-preset-config": "^0.16.0"
61
+ "@ruan-cat/vitepress-preset-config": "^0.16.1"
62
62
  },
63
63
  "scripts": {
64
64
  "docs:dev": "vitepress dev docs --port 8080",
65
65
  "build:docs": "vitepress build docs",
66
66
  "—build-not-use-for-now": "tsc",
67
67
  "start": "node ./dist/index.js",
68
- "run": "node --import=tsx ./src/index.ts --env-path=.env.test",
69
- "test:config": "node --import=tsx ./tests/config.test.ts --env-path=.env.test"
68
+ "run": "tsx ./src/index.ts --env-path=.env.test",
69
+ "test:config": "dotenvx run -f .env.test -f .env.test-2 -- tsx ./tests/config.test.ts"
70
70
  }
71
71
  }
package/src/config.ts CHANGED
@@ -2,8 +2,9 @@ import { resolve } from "pathe";
2
2
  import { loadConfig } from "c12";
3
3
  import { config as dotenvConfig } from "@dotenvx/dotenvx";
4
4
  import { consola } from "consola";
5
- import { merge, isEmpty } from "lodash-es";
5
+ import { isUndefined } from "lodash-es";
6
6
  import { program } from "commander";
7
+ import { printFormat } from "@ruan-cat/utils";
7
8
 
8
9
  /**
9
10
  * @description
@@ -162,9 +163,21 @@ program
162
163
  .parse();
163
164
  const options = program.opts();
164
165
 
166
+ const envPath = options?.envPath;
167
+
168
+ if (!isUndefined(envPath)) {
169
+ consola.warn(` 警告 :envPath 参数已被弃用,请使用 dotenvx 命令行工具来注入环境变量 `);
170
+ }
171
+
165
172
  consola.info(" 查看命令行提供的参数 ", options);
166
173
 
167
- /** 初始化的当前的环境变量 */
174
+ /**
175
+ * 初始化的当前的环境变量
176
+ * @deprecated
177
+ * 设计变更
178
+ *
179
+ * 本函数目前不会再继续用 dotenvConfig 来获取环境变量了
180
+ */
168
181
  function initCurrentDotenvConfig() {
169
182
  // 如果存在环境变量路径 就使用并读取
170
183
  const dotenvConfigParams = options?.envPath
@@ -173,17 +186,15 @@ function initCurrentDotenvConfig() {
173
186
  }
174
187
  : {};
175
188
 
176
- const res = dotenvConfig(
177
- dotenvConfigParams,
178
- // {
179
- // // 具体识别的路径,会自动识别根目录下面的env文件,故这里不作处理
180
- // path: "../../../.env"
181
- // }
182
- ).parsed;
183
-
184
- consola.info(" 查看来自 @dotenvx/dotenvx 获取的环境变量: ");
185
- consola.box(res);
186
-
189
+ const res = dotenvConfig().parsed;
190
+ // dotenvConfigParams,
191
+ // {
192
+ // // 具体识别的路径,会自动识别根目录下面的env文件,故这里不作处理
193
+ // path: "../../../.env"
194
+ // }
195
+ // consola.info(" 查看来自 @dotenvx/dotenvx 获取的环境变量: ");
196
+ // consola.box(process.env);
197
+ // consola.success(" process.env ", process.env);
187
198
  return res;
188
199
  }
189
200
 
@@ -213,7 +224,7 @@ async function loadUserConfig() {
213
224
  });
214
225
 
215
226
  consola.success(" 完成加载用户配置 ");
216
- consola.box(config);
227
+ consola.box(printFormat(config));
217
228
 
218
229
  return config;
219
230
  }
@@ -224,29 +235,31 @@ async function loadUserConfig() {
224
235
  * 初始化环境变量
225
236
  */
226
237
  export async function initVercelConfig() {
227
- /** 当前的环境变量 */
238
+ /**
239
+ * 当前的环境变量
240
+ * @deprecated
241
+ */
228
242
  const currentDotenvConfig = initCurrentDotenvConfig();
229
243
 
230
244
  /** 用户配置 */
231
245
  const userConfig = await loadUserConfig();
232
246
 
233
- const vercelOrgId = currentDotenvConfig!.VERCEL_ORG_ID ?? process.env.VERCEL_ORG_ID;
234
- const vercelProjectId = currentDotenvConfig!.VERCEL_PROJECT_ID ?? process.env.VERCEL_PROJECT_ID;
235
- const vercelToken = currentDotenvConfig!.VERCEL_TOKEN ?? process.env.VERCEL_TOKEN;
247
+ const vercelOrgId = process.env.VERCEL_ORG_ID;
248
+ const vercelProjectId = process.env.VERCEL_PROJECT_ID;
249
+ const vercelToken = process.env.VERCEL_TOKEN;
236
250
 
237
- if (!isEmpty(vercelOrgId)) {
251
+ if (!isUndefined(vercelOrgId)) {
238
252
  userConfig.vercelOrgId = vercelOrgId;
239
253
  }
240
- if (!isEmpty(vercelProjectId)) {
254
+ if (!isUndefined(vercelProjectId)) {
241
255
  userConfig.vercelProjectId = vercelProjectId;
242
256
  }
243
- if (!isEmpty(vercelToken)) {
257
+ if (!isUndefined(vercelToken)) {
244
258
  userConfig.vercelToken = vercelToken;
245
259
  }
246
260
 
247
- consola.success(" 完成初始化项目配置 ");
248
- // 显示效果没有那么好看
249
- consola.box(userConfig);
261
+ consola.success(` 完成初始化项目配置 `);
262
+ consola.box(printFormat(userConfig));
250
263
 
251
264
  return userConfig;
252
265
  }