@donotdev/cli 0.3.7 → 0.3.8

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.
@@ -9017,11 +9017,19 @@ var init_command_registry = __esm({
9017
9017
  },
9018
9018
  {
9019
9019
  flags: "--output-dir <dir>",
9020
- description: "output directory for migrations (default: supabase/migrations)"
9020
+ description: "output directory for migrations (default: supabase/migrations of the app the command runs for: the nearest folder up with supabase/config.toml, or the only app with one under apps/; fails when none)"
9021
9021
  },
9022
9022
  {
9023
9023
  flags: "--no-single-file",
9024
9024
  description: "emit one migration file per entity"
9025
+ },
9026
+ {
9027
+ flags: "--only <collections...>",
9028
+ description: "emit only these collections into ONE new migration <version>_<first>[_and_more].sql (version: now, or the latest existing + 1 so it sorts last); never touches *_entity_tables.sql (for a live app adding a feature's entities; feature-owned collections accepted)"
9029
+ },
9030
+ {
9031
+ flags: "--app-dir <dir>",
9032
+ description: "app folder whose src/config/app.ts turns framework features on (their entities are included when installed; default: the app of the output dir)"
9025
9033
  }
9026
9034
  ],
9027
9035
  loader: "../generators/sql-generator.ts"
@@ -9879,11 +9879,19 @@ var init_command_registry = __esm({
9879
9879
  },
9880
9880
  {
9881
9881
  flags: "--output-dir <dir>",
9882
- description: "output directory for migrations (default: supabase/migrations)"
9882
+ description: "output directory for migrations (default: supabase/migrations of the app the command runs for: the nearest folder up with supabase/config.toml, or the only app with one under apps/; fails when none)"
9883
9883
  },
9884
9884
  {
9885
9885
  flags: "--no-single-file",
9886
9886
  description: "emit one migration file per entity"
9887
+ },
9888
+ {
9889
+ flags: "--only <collections...>",
9890
+ description: "emit only these collections into ONE new migration <version>_<first>[_and_more].sql (version: now, or the latest existing + 1 so it sorts last); never touches *_entity_tables.sql (for a live app adding a feature's entities; feature-owned collections accepted)"
9891
+ },
9892
+ {
9893
+ flags: "--app-dir <dir>",
9894
+ description: "app folder whose src/config/app.ts turns framework features on (their entities are included when installed; default: the app of the output dir)"
9887
9895
  }
9888
9896
  ],
9889
9897
  loader: "../generators/sql-generator.ts"
@@ -22762,7 +22770,7 @@ var init_supabase_function_secrets = __esm({
22762
22770
 
22763
22771
  // packages/tooling/src/quality/uat/live-dump.ts
22764
22772
  import { spawn as spawn2, spawnSync as spawnSync8 } from "node:child_process";
22765
- import { existsSync as existsSync3, mkdirSync as mkdirSync3, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync3 } from "node:fs";
22773
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, rmSync as rmSync3, statSync as statSync3, writeFileSync as writeFileSync4 } from "node:fs";
22766
22774
  import { dirname as dirname6, join as join5, relative as relative4 } from "node:path";
22767
22775
  var LIVE_ACCESS_TOKEN_KEY, LIVE_DB_PASSWORD_KEY;
22768
22776
  var init_live_dump = __esm({
@@ -24331,7 +24339,8 @@ init_secrets_resolver();
24331
24339
  init_type_guards();
24332
24340
  import { execFileSync } from "node:child_process";
24333
24341
  import { createHash as createHash2 } from "node:crypto";
24334
- import { readlinkSync } from "node:fs";
24342
+ import { mkdtempSync, readlinkSync, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
24343
+ import { tmpdir } from "node:os";
24335
24344
  var UPLOAD_BATCH_SIZE = 10;
24336
24345
  var POLL_INTERVAL_MS = 3e3;
24337
24346
  var POLL_MAX_ATTEMPTS = 100;
@@ -24492,7 +24501,11 @@ Add VERCEL_TOKEN to .dndev.secrets and VERCEL_PROJECT_ID to the app .env`
24492
24501
  "Vercel CLI not found on PATH (needed by vercel build). Install it, or deploy with --from-git."
24493
24502
  );
24494
24503
  }
24495
- logDryRunCommand("vercel", ["build", "--yes"], appDir);
24504
+ logDryRunCommand(
24505
+ "vercel",
24506
+ ["build", "--yes", "--local-config", '<app vercel.json + installCommand "">'],
24507
+ appDir
24508
+ );
24496
24509
  return;
24497
24510
  }
24498
24511
  const { token, orgId, projectId } = result.credentials;
@@ -24500,46 +24513,71 @@ Add VERCEL_TOKEN to .dndev.secrets and VERCEL_PROJECT_ID to the app .env`
24500
24513
  CLI_TOOLS.VERCEL,
24501
24514
  "Install the Vercel CLI: bun install -g vercel (or brew install vercel)"
24502
24515
  );
24503
- execFileSync("vercel", ["build", "--yes"], {
24504
- cwd: appDir,
24505
- stdio: "inherit",
24506
- env: {
24507
- ...process.env,
24508
- // UAT: process env wins over the app .env files in Next.js, so the UAT values are built in
24509
- ...uat?.publicEnv,
24510
- // A deploy build: published URLs must be public (core isDeployBuild)
24511
- DNDEV_DEPLOY: "1",
24512
- VERCEL_TOKEN: token,
24513
- VERCEL_PROJECT_ID: projectId,
24514
- ...orgId ? { VERCEL_ORG_ID: orgId } : {}
24515
- }
24516
- });
24516
+ const configDir = mkdtempSync(joinPath(tmpdir(), "dndev-vercel-build-"));
24517
+ const localConfig = joinPath(configDir, "vercel.json");
24518
+ writeFileSync3(localConfig, JSON.stringify(localBuildConfig(appDir), null, 2));
24519
+ try {
24520
+ execFileSync("vercel", ["build", "--yes", "--local-config", localConfig], {
24521
+ cwd: appDir,
24522
+ stdio: "inherit",
24523
+ env: {
24524
+ ...process.env,
24525
+ // UAT: process env wins over the app .env files in Next.js, so the UAT values are built in
24526
+ ...uat?.publicEnv,
24527
+ // A deploy build: published URLs must be public (core isDeployBuild)
24528
+ DNDEV_DEPLOY: "1",
24529
+ VERCEL_TOKEN: token,
24530
+ VERCEL_PROJECT_ID: projectId,
24531
+ ...orgId ? { VERCEL_ORG_ID: orgId } : {}
24532
+ }
24533
+ });
24534
+ } finally {
24535
+ rmSync2(configDir, { recursive: true, force: true });
24536
+ }
24537
+ }
24538
+ function localBuildConfig(appDir) {
24539
+ const appConfigPath = joinPath(appDir, "vercel.json");
24540
+ const appConfig = pathExists(appConfigPath) ? readSync(appConfigPath) : {};
24541
+ if (typeof appConfig !== "object" || appConfig === null || Array.isArray(appConfig)) {
24542
+ throw new Error(`${appConfigPath} must be a JSON object`);
24543
+ }
24544
+ return { ...appConfig, installCommand: "" };
24517
24545
  }
24518
24546
  async function uploadFiles(files, token, orgId) {
24519
- const q = teamQuery(orgId);
24520
24547
  for (let i2 = 0; i2 < files.length; i2 += UPLOAD_BATCH_SIZE) {
24521
24548
  const batch = files.slice(i2, i2 + UPLOAD_BATCH_SIZE);
24522
- await Promise.all(
24523
- batch.map(async (file) => {
24524
- const res = await fetch(`${VERCEL_API}/v2/files${q}`, {
24525
- method: "POST",
24526
- headers: apiHeaders(token, {
24527
- "Content-Type": "application/octet-stream",
24528
- "x-vercel-digest": file.sha,
24529
- "Content-Length": String(file.size)
24530
- }),
24531
- body: new Uint8Array(file.content)
24532
- });
24533
- if (!res.ok) {
24534
- const body = await res.text();
24535
- throw formatVercelError(
24536
- res.status,
24537
- body,
24538
- `upload file ${file.relativePath}`
24539
- );
24540
- }
24541
- })
24542
- );
24549
+ await Promise.all(batch.map((file) => uploadFile(file, token, orgId)));
24550
+ }
24551
+ }
24552
+ var UPLOAD_TIMEOUT_MS = 6e4;
24553
+ var UPLOAD_ATTEMPTS = 3;
24554
+ async function uploadFile(file, token, orgId, fetchImpl = fetch) {
24555
+ const q = teamQuery(orgId);
24556
+ for (let attempt = 1; ; attempt++) {
24557
+ let failure;
24558
+ let res;
24559
+ try {
24560
+ res = await fetchImpl(`${VERCEL_API}/v2/files${q}`, {
24561
+ method: "POST",
24562
+ headers: apiHeaders(token, {
24563
+ "Content-Type": "application/octet-stream",
24564
+ "x-vercel-digest": file.sha,
24565
+ "Content-Length": String(file.size)
24566
+ }),
24567
+ body: new Uint8Array(file.content),
24568
+ signal: AbortSignal.timeout(UPLOAD_TIMEOUT_MS)
24569
+ });
24570
+ } catch (error2) {
24571
+ failure = error2;
24572
+ }
24573
+ if (res) {
24574
+ if (res.ok) return;
24575
+ failure = formatVercelError(res.status, await res.text(), `upload file ${file.relativePath}`);
24576
+ if (res.status !== 429 && res.status < 500) throw failure;
24577
+ }
24578
+ if (attempt >= UPLOAD_ATTEMPTS) throw failure;
24579
+ log2.warn(`Upload of ${file.relativePath} failed (attempt ${attempt}/${UPLOAD_ATTEMPTS}), retrying...`);
24580
+ await new Promise((resolve5) => setTimeout(resolve5, 1e3 * attempt));
24543
24581
  }
24544
24582
  }
24545
24583
  function sourceToRegex(source) {
@@ -24746,9 +24784,9 @@ async function waitForReady(deploymentId, token, orgId) {
24746
24784
  }
24747
24785
  throw new Error("Deployment timed out (5+ minutes)");
24748
24786
  }
24749
- async function logDeploymentPlan(outputDir, countFiles, orgId) {
24787
+ async function logDeploymentPlan(outputDir, countFiles, rebuilt, orgId) {
24750
24788
  const q = teamQuery(orgId);
24751
- const files = pathExists(outputDir) ? `${await countFiles()} files currently in ${outputDir}` : `the files of ${outputDir}, produced by the build step`;
24789
+ const files = !rebuilt && pathExists(outputDir) ? `${await countFiles()} files currently in ${outputDir}` : `the files of ${outputDir}, produced by the build step`;
24752
24790
  logDryRunRequest(
24753
24791
  "POST",
24754
24792
  `${VERCEL_API}/v13/deployments${q}`,
@@ -24860,6 +24898,7 @@ async function deployVercelFrontend(appDir, repoRoot, config, framework = "unkno
24860
24898
  const { output, sources } = await collectVercelOutputFiles(appDir, repoRoot);
24861
24899
  return output.length + sources.length + await countFunctionFiles(functionsOutputDir);
24862
24900
  },
24901
+ !config.skipBuild,
24863
24902
  orgId
24864
24903
  );
24865
24904
  } else if (framework === "nextjs" && !isNextStatic) {
@@ -24888,6 +24927,7 @@ async function deployVercelFrontend(appDir, repoRoot, config, framework = "unkno
24888
24927
  await logDeploymentPlan(
24889
24928
  distDir,
24890
24929
  async () => (await collectDistFiles(distDir)).length + 1 + await countFunctionFiles(functionsOutputDir),
24930
+ !config.skipBuild,
24891
24931
  orgId
24892
24932
  );
24893
24933
  }
@@ -24982,6 +25022,7 @@ async function deployVercelFunctions(appDir, config, functionsOutputDir) {
24982
25022
  await logDeploymentPlan(
24983
25023
  joinPath(functionsOutputDir, "functions"),
24984
25024
  async () => await countFunctionFiles(functionsOutputDir) + 1,
25025
+ !config.skipBuild,
24985
25026
  target.orgId
24986
25027
  );
24987
25028
  return;
@@ -25621,8 +25662,8 @@ init_deploy_utils();
25621
25662
  // packages/tooling/src/apps/uat-refresh-data.ts
25622
25663
  init_utils2();
25623
25664
  init_deploy_utils();
25624
- import { mkdtempSync, readFileSync as readFileSync4, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "node:fs";
25625
- import { tmpdir } from "node:os";
25665
+ import { mkdtempSync as mkdtempSync2, readFileSync as readFileSync4, rmSync as rmSync4, writeFileSync as writeFileSync5 } from "node:fs";
25666
+ import { tmpdir as tmpdir2 } from "node:os";
25626
25667
  import { join as join7 } from "node:path";
25627
25668
 
25628
25669
  // packages/tooling/src/apps/uat-anonymize.ts
@@ -26129,7 +26170,7 @@ async function confirmOverwrite(inputs, yes) {
26129
26170
  function printPlan(inputs, pgDumpMajor) {
26130
26171
  const prod = placeholderTarget("production", inputs.prodRef, inputs.prodDbPassword);
26131
26172
  const uat = placeholderTarget("UAT", inputs.uatRef, inputs.uatDbPassword);
26132
- const dir = join7(tmpdir(), "dn-uat-refresh-<random>");
26173
+ const dir = join7(tmpdir2(), "dn-uat-refresh-<random>");
26133
26174
  const dumpFile = join7(dir, "prod-data.sql");
26134
26175
  const anonymizeFile = join7(dir, "anonymize.sql");
26135
26176
  const pendingCopyFile = join7(dir, "pending-copy.sql");
@@ -26173,7 +26214,7 @@ async function refreshUatData(options) {
26173
26214
  assertDumpVersion(client.pgDump, serverVersion);
26174
26215
  assertUatHistoryNotAhead(readMigrationHistory(prod), readMigrationHistory(uat), { production: prod.ref, uat: uat.ref });
26175
26216
  const uatObjects = parseStorageSnapshot(runPg("psql", buildReadArgs(uat, STORAGE_SNAPSHOT_SQL), uat, "UAT storage read").stdout);
26176
- const dir = mkdtempSync(join7(tmpdir(), "dn-uat-refresh-"));
26217
+ const dir = mkdtempSync2(join7(tmpdir2(), "dn-uat-refresh-"));
26177
26218
  try {
26178
26219
  const dumpFile = join7(dir, "prod-data.sql");
26179
26220
  const anonymizeFile = join7(dir, "anonymize.sql");
@@ -26186,8 +26227,8 @@ async function refreshUatData(options) {
26186
26227
  const diff = diffStorage(storageObjectsFromRows(copyRows(blocks, "storage.objects")), uatObjects);
26187
26228
  log2.info(`Dump: ${tables.length} tables. Storage: ${diff.copy.length} to copy, ${diff.remove.length} to delete, ${diff.unchanged} unchanged.`);
26188
26229
  const deleted = await deleteStorageObjects(inputs.uatStorage, inputs.prodStorage, diff.remove);
26189
- writeFileSync4(anonymizeFile, inputs.anonymizeSql, { encoding: "utf8", mode: 384 });
26190
- writeFileSync4(pendingCopyFile, buildPendingCopySql(diff.copy), { encoding: "utf8", mode: 384 });
26230
+ writeFileSync5(anonymizeFile, inputs.anonymizeSql, { encoding: "utf8", mode: 384 });
26231
+ writeFileSync5(pendingCopyFile, buildPendingCopySql(diff.copy), { encoding: "utf8", mode: 384 });
26191
26232
  assertNotProductionDb(uat, prod);
26192
26233
  log2.info(`Restoring into UAT and anonymizing (one transaction, ${tables.length} tables truncated)\u2026`);
26193
26234
  runPg("psql", buildRestoreArgs(uat, tables, dumpFile, anonymizeFile, pendingCopyFile), uat, "UAT restore");
@@ -26206,7 +26247,7 @@ ${formatCountTable(counts)}`);
26206
26247
  log2.success(`UAT data refreshed: ${tables.length} tables, storage ${copied} copied, ${deleted} deleted, ${diff.unchanged} unchanged.`);
26207
26248
  return { dryRun, counts, storage: { copied, deleted, unchanged: diff.unchanged } };
26208
26249
  } finally {
26209
- rmSync3(dir, { recursive: true, force: true });
26250
+ rmSync4(dir, { recursive: true, force: true });
26210
26251
  }
26211
26252
  }
26212
26253
 
package/dist/bin/dndev.js CHANGED
@@ -1286,11 +1286,19 @@ var init_command_registry = __esm({
1286
1286
  },
1287
1287
  {
1288
1288
  flags: "--output-dir <dir>",
1289
- description: "output directory for migrations (default: supabase/migrations)"
1289
+ description: "output directory for migrations (default: supabase/migrations of the app the command runs for: the nearest folder up with supabase/config.toml, or the only app with one under apps/; fails when none)"
1290
1290
  },
1291
1291
  {
1292
1292
  flags: "--no-single-file",
1293
1293
  description: "emit one migration file per entity"
1294
+ },
1295
+ {
1296
+ flags: "--only <collections...>",
1297
+ description: "emit only these collections into ONE new migration <version>_<first>[_and_more].sql (version: now, or the latest existing + 1 so it sorts last); never touches *_entity_tables.sql (for a live app adding a feature's entities; feature-owned collections accepted)"
1298
+ },
1299
+ {
1300
+ flags: "--app-dir <dir>",
1301
+ description: "app folder whose src/config/app.ts turns framework features on (their entities are included when installed; default: the app of the output dir)"
1294
1302
  }
1295
1303
  ],
1296
1304
  loader: "../generators/sql-generator.ts"
@@ -1501,7 +1509,7 @@ function registerCommand(program2, def, action) {
1501
1509
  }
1502
1510
 
1503
1511
  // packages/cli/src/bin/dndev.mjs
1504
- var CLI_VERSION = true ? "0.3.7" : "0.0.0";
1512
+ var CLI_VERSION = true ? "0.3.8" : "0.0.0";
1505
1513
  var args = process.argv.slice(2);
1506
1514
  if (args.length === 1 && (args[0] === "--version" || args[0] === "-v")) {
1507
1515
  console.log(CLI_VERSION);
package/dist/index.js CHANGED
@@ -10537,11 +10537,19 @@ var init_command_registry = __esm({
10537
10537
  },
10538
10538
  {
10539
10539
  flags: "--output-dir <dir>",
10540
- description: "output directory for migrations (default: supabase/migrations)"
10540
+ description: "output directory for migrations (default: supabase/migrations of the app the command runs for: the nearest folder up with supabase/config.toml, or the only app with one under apps/; fails when none)"
10541
10541
  },
10542
10542
  {
10543
10543
  flags: "--no-single-file",
10544
10544
  description: "emit one migration file per entity"
10545
+ },
10546
+ {
10547
+ flags: "--only <collections...>",
10548
+ description: "emit only these collections into ONE new migration <version>_<first>[_and_more].sql (version: now, or the latest existing + 1 so it sorts last); never touches *_entity_tables.sql (for a live app adding a feature's entities; feature-owned collections accepted)"
10549
+ },
10550
+ {
10551
+ flags: "--app-dir <dir>",
10552
+ description: "app folder whose src/config/app.ts turns framework features on (their entities are included when installed; default: the app of the output dir)"
10545
10553
  }
10546
10554
  ],
10547
10555
  loader: "../generators/sql-generator.ts"
@@ -24034,7 +24042,7 @@ var init_supabase_function_secrets = __esm({
24034
24042
 
24035
24043
  // packages/tooling/src/quality/uat/live-dump.ts
24036
24044
  import { spawn as spawn3, spawnSync as spawnSync11 } from "node:child_process";
24037
- import { existsSync as existsSync3, mkdirSync as mkdirSync3, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync3 } from "node:fs";
24045
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, rmSync as rmSync3, statSync as statSync3, writeFileSync as writeFileSync4 } from "node:fs";
24038
24046
  import { dirname as dirname6, join as join5, relative as relative4 } from "node:path";
24039
24047
  var LIVE_ACCESS_TOKEN_KEY, LIVE_DB_PASSWORD_KEY;
24040
24048
  var init_live_dump = __esm({
@@ -26810,7 +26818,8 @@ init_secrets_resolver();
26810
26818
  init_type_guards();
26811
26819
  import { execFileSync as execFileSync4 } from "node:child_process";
26812
26820
  import { createHash as createHash2 } from "node:crypto";
26813
- import { readlinkSync } from "node:fs";
26821
+ import { mkdtempSync, readlinkSync, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
26822
+ import { tmpdir } from "node:os";
26814
26823
  var UPLOAD_BATCH_SIZE = 10;
26815
26824
  var POLL_INTERVAL_MS = 3e3;
26816
26825
  var POLL_MAX_ATTEMPTS = 100;
@@ -26971,7 +26980,11 @@ Add VERCEL_TOKEN to .dndev.secrets and VERCEL_PROJECT_ID to the app .env`
26971
26980
  "Vercel CLI not found on PATH (needed by vercel build). Install it, or deploy with --from-git."
26972
26981
  );
26973
26982
  }
26974
- logDryRunCommand("vercel", ["build", "--yes"], appDir);
26983
+ logDryRunCommand(
26984
+ "vercel",
26985
+ ["build", "--yes", "--local-config", '<app vercel.json + installCommand "">'],
26986
+ appDir
26987
+ );
26975
26988
  return;
26976
26989
  }
26977
26990
  const { token, orgId, projectId } = result.credentials;
@@ -26979,46 +26992,71 @@ Add VERCEL_TOKEN to .dndev.secrets and VERCEL_PROJECT_ID to the app .env`
26979
26992
  CLI_TOOLS.VERCEL,
26980
26993
  "Install the Vercel CLI: bun install -g vercel (or brew install vercel)"
26981
26994
  );
26982
- execFileSync4("vercel", ["build", "--yes"], {
26983
- cwd: appDir,
26984
- stdio: "inherit",
26985
- env: {
26986
- ...process.env,
26987
- // UAT: process env wins over the app .env files in Next.js, so the UAT values are built in
26988
- ...uat?.publicEnv,
26989
- // A deploy build: published URLs must be public (core isDeployBuild)
26990
- DNDEV_DEPLOY: "1",
26991
- VERCEL_TOKEN: token,
26992
- VERCEL_PROJECT_ID: projectId,
26993
- ...orgId ? { VERCEL_ORG_ID: orgId } : {}
26994
- }
26995
- });
26995
+ const configDir = mkdtempSync(joinPath(tmpdir(), "dndev-vercel-build-"));
26996
+ const localConfig = joinPath(configDir, "vercel.json");
26997
+ writeFileSync3(localConfig, JSON.stringify(localBuildConfig(appDir), null, 2));
26998
+ try {
26999
+ execFileSync4("vercel", ["build", "--yes", "--local-config", localConfig], {
27000
+ cwd: appDir,
27001
+ stdio: "inherit",
27002
+ env: {
27003
+ ...process.env,
27004
+ // UAT: process env wins over the app .env files in Next.js, so the UAT values are built in
27005
+ ...uat?.publicEnv,
27006
+ // A deploy build: published URLs must be public (core isDeployBuild)
27007
+ DNDEV_DEPLOY: "1",
27008
+ VERCEL_TOKEN: token,
27009
+ VERCEL_PROJECT_ID: projectId,
27010
+ ...orgId ? { VERCEL_ORG_ID: orgId } : {}
27011
+ }
27012
+ });
27013
+ } finally {
27014
+ rmSync2(configDir, { recursive: true, force: true });
27015
+ }
27016
+ }
27017
+ function localBuildConfig(appDir) {
27018
+ const appConfigPath = joinPath(appDir, "vercel.json");
27019
+ const appConfig = pathExists(appConfigPath) ? readSync(appConfigPath) : {};
27020
+ if (typeof appConfig !== "object" || appConfig === null || Array.isArray(appConfig)) {
27021
+ throw new Error(`${appConfigPath} must be a JSON object`);
27022
+ }
27023
+ return { ...appConfig, installCommand: "" };
26996
27024
  }
26997
27025
  async function uploadFiles(files, token, orgId) {
26998
- const q = teamQuery(orgId);
26999
27026
  for (let i2 = 0; i2 < files.length; i2 += UPLOAD_BATCH_SIZE) {
27000
27027
  const batch = files.slice(i2, i2 + UPLOAD_BATCH_SIZE);
27001
- await Promise.all(
27002
- batch.map(async (file) => {
27003
- const res = await fetch(`${VERCEL_API}/v2/files${q}`, {
27004
- method: "POST",
27005
- headers: apiHeaders(token, {
27006
- "Content-Type": "application/octet-stream",
27007
- "x-vercel-digest": file.sha,
27008
- "Content-Length": String(file.size)
27009
- }),
27010
- body: new Uint8Array(file.content)
27011
- });
27012
- if (!res.ok) {
27013
- const body = await res.text();
27014
- throw formatVercelError(
27015
- res.status,
27016
- body,
27017
- `upload file ${file.relativePath}`
27018
- );
27019
- }
27020
- })
27021
- );
27028
+ await Promise.all(batch.map((file) => uploadFile(file, token, orgId)));
27029
+ }
27030
+ }
27031
+ var UPLOAD_TIMEOUT_MS = 6e4;
27032
+ var UPLOAD_ATTEMPTS = 3;
27033
+ async function uploadFile(file, token, orgId, fetchImpl = fetch) {
27034
+ const q = teamQuery(orgId);
27035
+ for (let attempt = 1; ; attempt++) {
27036
+ let failure;
27037
+ let res;
27038
+ try {
27039
+ res = await fetchImpl(`${VERCEL_API}/v2/files${q}`, {
27040
+ method: "POST",
27041
+ headers: apiHeaders(token, {
27042
+ "Content-Type": "application/octet-stream",
27043
+ "x-vercel-digest": file.sha,
27044
+ "Content-Length": String(file.size)
27045
+ }),
27046
+ body: new Uint8Array(file.content),
27047
+ signal: AbortSignal.timeout(UPLOAD_TIMEOUT_MS)
27048
+ });
27049
+ } catch (error2) {
27050
+ failure = error2;
27051
+ }
27052
+ if (res) {
27053
+ if (res.ok) return;
27054
+ failure = formatVercelError(res.status, await res.text(), `upload file ${file.relativePath}`);
27055
+ if (res.status !== 429 && res.status < 500) throw failure;
27056
+ }
27057
+ if (attempt >= UPLOAD_ATTEMPTS) throw failure;
27058
+ log2.warn(`Upload of ${file.relativePath} failed (attempt ${attempt}/${UPLOAD_ATTEMPTS}), retrying...`);
27059
+ await new Promise((resolve5) => setTimeout(resolve5, 1e3 * attempt));
27022
27060
  }
27023
27061
  }
27024
27062
  function sourceToRegex(source) {
@@ -27225,9 +27263,9 @@ async function waitForReady(deploymentId, token, orgId) {
27225
27263
  }
27226
27264
  throw new Error("Deployment timed out (5+ minutes)");
27227
27265
  }
27228
- async function logDeploymentPlan(outputDir, countFiles, orgId) {
27266
+ async function logDeploymentPlan(outputDir, countFiles, rebuilt, orgId) {
27229
27267
  const q = teamQuery(orgId);
27230
- const files = pathExists(outputDir) ? `${await countFiles()} files currently in ${outputDir}` : `the files of ${outputDir}, produced by the build step`;
27268
+ const files = !rebuilt && pathExists(outputDir) ? `${await countFiles()} files currently in ${outputDir}` : `the files of ${outputDir}, produced by the build step`;
27231
27269
  logDryRunRequest(
27232
27270
  "POST",
27233
27271
  `${VERCEL_API}/v13/deployments${q}`,
@@ -27339,6 +27377,7 @@ async function deployVercelFrontend(appDir, repoRoot, config, framework = "unkno
27339
27377
  const { output, sources } = await collectVercelOutputFiles(appDir, repoRoot);
27340
27378
  return output.length + sources.length + await countFunctionFiles(functionsOutputDir);
27341
27379
  },
27380
+ !config.skipBuild,
27342
27381
  orgId
27343
27382
  );
27344
27383
  } else if (framework === "nextjs" && !isNextStatic) {
@@ -27367,6 +27406,7 @@ async function deployVercelFrontend(appDir, repoRoot, config, framework = "unkno
27367
27406
  await logDeploymentPlan(
27368
27407
  distDir,
27369
27408
  async () => (await collectDistFiles(distDir)).length + 1 + await countFunctionFiles(functionsOutputDir),
27409
+ !config.skipBuild,
27370
27410
  orgId
27371
27411
  );
27372
27412
  }
@@ -27461,6 +27501,7 @@ async function deployVercelFunctions(appDir, config, functionsOutputDir) {
27461
27501
  await logDeploymentPlan(
27462
27502
  joinPath(functionsOutputDir, "functions"),
27463
27503
  async () => await countFunctionFiles(functionsOutputDir) + 1,
27504
+ !config.skipBuild,
27464
27505
  target.orgId
27465
27506
  );
27466
27507
  return;
@@ -28100,8 +28141,8 @@ init_deploy_utils();
28100
28141
  // packages/tooling/src/apps/uat-refresh-data.ts
28101
28142
  init_utils2();
28102
28143
  init_deploy_utils();
28103
- import { mkdtempSync, readFileSync as readFileSync4, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "node:fs";
28104
- import { tmpdir } from "node:os";
28144
+ import { mkdtempSync as mkdtempSync2, readFileSync as readFileSync4, rmSync as rmSync4, writeFileSync as writeFileSync5 } from "node:fs";
28145
+ import { tmpdir as tmpdir2 } from "node:os";
28105
28146
  import { join as join7 } from "node:path";
28106
28147
 
28107
28148
  // packages/tooling/src/apps/uat-anonymize.ts
@@ -28608,7 +28649,7 @@ async function confirmOverwrite(inputs, yes) {
28608
28649
  function printPlan(inputs, pgDumpMajor) {
28609
28650
  const prod = placeholderTarget("production", inputs.prodRef, inputs.prodDbPassword);
28610
28651
  const uat = placeholderTarget("UAT", inputs.uatRef, inputs.uatDbPassword);
28611
- const dir = join7(tmpdir(), "dn-uat-refresh-<random>");
28652
+ const dir = join7(tmpdir2(), "dn-uat-refresh-<random>");
28612
28653
  const dumpFile = join7(dir, "prod-data.sql");
28613
28654
  const anonymizeFile = join7(dir, "anonymize.sql");
28614
28655
  const pendingCopyFile = join7(dir, "pending-copy.sql");
@@ -28652,7 +28693,7 @@ async function refreshUatData(options) {
28652
28693
  assertDumpVersion(client.pgDump, serverVersion);
28653
28694
  assertUatHistoryNotAhead(readMigrationHistory(prod), readMigrationHistory(uat), { production: prod.ref, uat: uat.ref });
28654
28695
  const uatObjects = parseStorageSnapshot(runPg("psql", buildReadArgs(uat, STORAGE_SNAPSHOT_SQL), uat, "UAT storage read").stdout);
28655
- const dir = mkdtempSync(join7(tmpdir(), "dn-uat-refresh-"));
28696
+ const dir = mkdtempSync2(join7(tmpdir2(), "dn-uat-refresh-"));
28656
28697
  try {
28657
28698
  const dumpFile = join7(dir, "prod-data.sql");
28658
28699
  const anonymizeFile = join7(dir, "anonymize.sql");
@@ -28665,8 +28706,8 @@ async function refreshUatData(options) {
28665
28706
  const diff = diffStorage(storageObjectsFromRows(copyRows(blocks, "storage.objects")), uatObjects);
28666
28707
  log2.info(`Dump: ${tables.length} tables. Storage: ${diff.copy.length} to copy, ${diff.remove.length} to delete, ${diff.unchanged} unchanged.`);
28667
28708
  const deleted = await deleteStorageObjects(inputs.uatStorage, inputs.prodStorage, diff.remove);
28668
- writeFileSync4(anonymizeFile, inputs.anonymizeSql, { encoding: "utf8", mode: 384 });
28669
- writeFileSync4(pendingCopyFile, buildPendingCopySql(diff.copy), { encoding: "utf8", mode: 384 });
28709
+ writeFileSync5(anonymizeFile, inputs.anonymizeSql, { encoding: "utf8", mode: 384 });
28710
+ writeFileSync5(pendingCopyFile, buildPendingCopySql(diff.copy), { encoding: "utf8", mode: 384 });
28670
28711
  assertNotProductionDb(uat, prod);
28671
28712
  log2.info(`Restoring into UAT and anonymizing (one transaction, ${tables.length} tables truncated)\u2026`);
28672
28713
  runPg("psql", buildRestoreArgs(uat, tables, dumpFile, anonymizeFile, pendingCopyFile), uat, "UAT restore");
@@ -28685,7 +28726,7 @@ ${formatCountTable(counts)}`);
28685
28726
  log2.success(`UAT data refreshed: ${tables.length} tables, storage ${copied} copied, ${deleted} deleted, ${diff.unchanged} unchanged.`);
28686
28727
  return { dryRun, counts, storage: { copied, deleted, unchanged: diff.unchanged } };
28687
28728
  } finally {
28688
- rmSync3(dir, { recursive: true, force: true });
28729
+ rmSync4(dir, { recursive: true, force: true });
28689
28730
  }
28690
28731
  }
28691
28732
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/cli",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "Command-line interface for DoNotDev Framework",
5
5
  "type": "module",
6
6
  "private": false,