@ruan-cat/vercel-deploy-tool 0.7.5 → 0.8.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruan-cat/vercel-deploy-tool",
3
- "version": "0.7.5",
3
+ "version": "0.8.1",
4
4
  "description": "阮喵喵自用的vercel部署工具,用于实现复杂项目的部署。",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -50,7 +50,7 @@
50
50
  "pathe": "^1.1.2",
51
51
  "rimraf": "^6.0.1",
52
52
  "shx": "^0.3.4",
53
- "vercel": "39.3.0",
53
+ "vercel": "^41.2.0",
54
54
  "@ruan-cat/utils": "^3.0.0"
55
55
  },
56
56
  "devDependencies": {
package/src/config.ts CHANGED
@@ -2,7 +2,7 @@ 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 } from "lodash-es";
5
+ import { merge, isEmpty } from "lodash-es";
6
6
  import { program } from "commander";
7
7
 
8
8
  /**
@@ -226,17 +226,21 @@ export async function initVercelConfig() {
226
226
  const vercelProjectId = currentDotenvConfig!.VERCEL_PROJECT_ID ?? process.env.VERCEL_PROJECT_ID;
227
227
  const vercelToken = currentDotenvConfig!.VERCEL_TOKEN ?? process.env.VERCEL_TOKEN;
228
228
 
229
- const res: Config = merge(userConfig, {
230
- vercelOrgId,
231
- vercelProjectId,
232
- vercelToken,
233
- } satisfies Partial<Config>);
229
+ if (!isEmpty(vercelOrgId)) {
230
+ userConfig.vercelOrgId = vercelOrgId;
231
+ }
232
+ if (!isEmpty(vercelProjectId)) {
233
+ userConfig.vercelProjectId = vercelProjectId;
234
+ }
235
+ if (!isEmpty(vercelToken)) {
236
+ userConfig.vercelToken = vercelToken;
237
+ }
234
238
 
235
239
  consola.success(" 完成初始化项目配置 ");
236
240
  // 显示效果没有那么好看
237
- consola.box(res);
241
+ consola.box(userConfig);
238
242
 
239
- return res;
243
+ return userConfig;
240
244
  }
241
245
 
242
246
  /** 项目内的vercel配置 */
package/src/index.ts CHANGED
@@ -140,6 +140,18 @@ function getVercelProjetNameCommandArgument() {
140
140
  return <const>[`--project=${config.vercelProjetName}`];
141
141
  }
142
142
 
143
+ /**
144
+ * 以命令参数数组的形式,获得范围名称
145
+ * @see https://vercel.com/docs/cli/global-options#scope
146
+ *
147
+ * 为什么传递组织id?
148
+ * 此篇讨论内 使用了组织id
149
+ * @see https://vercel.community/t/deployment-via-gitlab-ci-to-dev-domain/523/3
150
+ */
151
+ function getVercelScopeCommandArgument() {
152
+ return <const>[`--scope=${config.vercelOrgId}`];
153
+ }
154
+
143
155
  /** 以命令参数数组的形式,获得项目token */
144
156
  function getVercelTokenCommandArgument() {
145
157
  return <const>[`--token=${config.vercelToken}`];
@@ -352,11 +364,15 @@ function generateCopyDistTasks(deployTarget: WithUserCommands) {
352
364
  * 旨在于封装类似于这样的命令:
353
365
  *
354
366
  * vc alias set "$url1" ${{env.p1-url}} -t ${{env.vct}}
367
+ *
368
+ * 封装出类似的命令:
369
+ * vercel alias set $DEPLOYMENT_URL domain2.com --token=$VERCEL_TOKEN --scope=$VERCEL_ORG_ID
370
+ * @see https://vercel.community/t/deployment-via-gitlab-ci-to-dev-domain/523/3
355
371
  */
356
372
  function generateAliasTask(vercelUrl: string, userUrl: string) {
357
373
  return generateSpawnSync({
358
374
  command: `vc alias set ${vercelUrl} ${userUrl}`,
359
- parameters: concat(getVercelTokenCommandArgument()),
375
+ parameters: concat(getVercelTokenCommandArgument(), getVercelScopeCommandArgument()),
360
376
  });
361
377
  }
362
378