@donotdev/cli 0.3.6 → 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.
@@ -8775,20 +8775,6 @@ var init_package_paths = __esm({
8775
8775
  });
8776
8776
 
8777
8777
  // packages/tooling/src/utils/typed-file-operations.ts
8778
- function readFirebaserc(filePath) {
8779
- if (!pathExists(filePath)) {
8780
- return { projects: {} };
8781
- }
8782
- const content = readSync(filePath, { format: "json" });
8783
- if (!content || typeof content !== "object") {
8784
- throw new DoNotDevError(
8785
- `Invalid .firebaserc: ${filePath}`,
8786
- DO_NOT_DEV_ERROR_CODES.CONFIG_INVALID,
8787
- { context: { filePath } }
8788
- );
8789
- }
8790
- return content;
8791
- }
8792
8778
  function readPackageJson(filePath) {
8793
8779
  if (!pathExists(filePath)) {
8794
8780
  throw new DoNotDevError(
@@ -9133,7 +9119,11 @@ var init_command_registry = __esm({
9133
9119
  appCommand: true,
9134
9120
  actionPattern: "app",
9135
9121
  options: [
9136
- { flags: "-c, --concurrency <n>", description: "set concurrency" }
9122
+ { flags: "-c, --concurrency <n>", description: "set concurrency" },
9123
+ {
9124
+ flags: "--uat",
9125
+ description: "Run locally against the UAT backend (apps/<app>/.env.uat; refuses production values)"
9126
+ }
9137
9127
  ],
9138
9128
  loader: "../apps/dev.ts",
9139
9129
  exportName: "dev"
@@ -9435,7 +9425,7 @@ var init_command_registry = __esm({
9435
9425
  options: [
9436
9426
  {
9437
9427
  flags: "-y, --yes",
9438
- description: "Accept every default answer: packages and docs, no major updates, then bun install"
9428
+ description: "Accept every default answer: packages, docs, AI harness and the demo/dndev apps already present, no major updates, then bun install"
9439
9429
  }
9440
9430
  ],
9441
9431
  loader: "../maintenance/bump.ts",
@@ -9453,7 +9443,7 @@ var init_command_registry = __esm({
9453
9443
  // ---------------------------------------------------------------------------
9454
9444
  {
9455
9445
  name: "deploy [app]",
9456
- description: "Deploy app",
9446
+ description: "Deploy app to production (UAT: uat <app>)",
9457
9447
  category: "deployment",
9458
9448
  public: true,
9459
9449
  appCommand: true,
@@ -9471,10 +9461,6 @@ var init_command_registry = __esm({
9471
9461
  flags: "--force",
9472
9462
  description: "Delete deployed Firebase functions missing from the local source (default: off; the deploy aborts and names them)"
9473
9463
  },
9474
- {
9475
- flags: "--staging",
9476
- description: "Deploy to staging (uses .env.staging and staging credentials)"
9477
- },
9478
9464
  {
9479
9465
  flags: "--scope <scope>",
9480
9466
  description: "What to deploy: frontend, functions, rules, both or all. Implies --yes"
@@ -9492,43 +9478,31 @@ var init_command_registry = __esm({
9492
9478
  exportName: "deploy"
9493
9479
  },
9494
9480
  {
9495
- name: "staging [app]",
9496
- description: "Deploy to staging/UAT (shorthand for deploy --staging)",
9497
- alias: "uat",
9481
+ name: "uat [app]",
9482
+ description: "Ship the code on this machine to UAT (Supabase + Vercel apps): apps/<app>/.env.uat, .dndev.uat.secrets; never production values; history-aware migrations, noindex",
9498
9483
  category: "deployment",
9499
9484
  public: true,
9500
9485
  appCommand: true,
9501
9486
  options: [
9502
- {
9503
- flags: "-p, --project <project>",
9504
- description: "Project ID (overrides default)"
9505
- },
9506
9487
  {
9507
9488
  flags: "--skip-build",
9508
9489
  description: "Reuse existing builds (dist/, out/, .vercel/output, functions, edge .build/). Default: build"
9509
9490
  },
9510
- {
9511
- flags: "--from-git",
9512
- description: "Next.js on Vercel: let Vercel build from linked Git (default: local vercel build + upload)"
9513
- },
9514
- {
9515
- flags: "--force",
9516
- description: "Delete deployed Firebase functions missing from the local source (default: off; the deploy aborts and names them)"
9517
- },
9518
9491
  {
9519
9492
  flags: "--scope <scope>",
9520
- description: "What to deploy: frontend, functions, rules, both or all. Implies --yes"
9493
+ description: "What to deploy: frontend, functions, both or all. Implies --yes"
9521
9494
  },
9522
9495
  {
9523
9496
  flags: "-y, --yes",
9524
9497
  description: "Non-interactive: never prompt; a missing required value fails, naming its flag (also when stdin is not a TTY)"
9525
9498
  },
9526
9499
  {
9527
- flags: "--no-sync-secrets",
9528
- description: "Skip pushing the secrets functions.yaml binds to Firebase Secret Manager (default: push changed values)"
9500
+ flags: "--refresh-data",
9501
+ description: "Copy production data into UAT (anonymized; storage incremental), then deploy; overwrites UAT data; asks for confirmation unless --yes"
9529
9502
  }
9530
9503
  ],
9531
- loader: "../apps/deploy.ts"
9504
+ loader: "../apps/uat.ts",
9505
+ exportName: "uat"
9532
9506
  },
9533
9507
  {
9534
9508
  name: "sync-secrets",
@@ -9598,10 +9572,15 @@ var init_command_registry = __esm({
9598
9572
  },
9599
9573
  {
9600
9574
  name: "setup [provider]",
9601
- description: "Set up infrastructure providers (firebase, supabase, vercel)",
9575
+ description: "Set up infrastructure providers (firebase, supabase, vercel) or the UAT environment (uat)",
9602
9576
  category: "deployment",
9603
9577
  public: true,
9604
- options: [],
9578
+ options: [
9579
+ {
9580
+ flags: "-y, --yes",
9581
+ description: "dn setup uat: create missing UAT resources without prompting"
9582
+ }
9583
+ ],
9605
9584
  loader: "../cli/setup/setup.ts",
9606
9585
  exportName: "setup"
9607
9586
  },
@@ -9615,10 +9594,6 @@ var init_command_registry = __esm({
9615
9594
  {
9616
9595
  flags: "--app <app>",
9617
9596
  description: "App name (auto-detected if single app)"
9618
- },
9619
- {
9620
- flags: "--staging",
9621
- description: "Include staging workflow generation"
9622
9597
  }
9623
9598
  ],
9624
9599
  loader: "../scaffolding/setup-cicd.ts",
@@ -9790,11 +9765,19 @@ var init_command_registry = __esm({
9790
9765
  },
9791
9766
  {
9792
9767
  flags: "--output-dir <dir>",
9793
- description: "output directory for migrations (default: supabase/migrations)"
9768
+ 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)"
9794
9769
  },
9795
9770
  {
9796
9771
  flags: "--no-single-file",
9797
9772
  description: "emit one migration file per entity"
9773
+ },
9774
+ {
9775
+ flags: "--only <collections...>",
9776
+ 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)"
9777
+ },
9778
+ {
9779
+ flags: "--app-dir <dir>",
9780
+ 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)"
9798
9781
  }
9799
9782
  ],
9800
9783
  loader: "../generators/sql-generator.ts"
@@ -10185,32 +10168,12 @@ function detectAvailableApps() {
10185
10168
  return pathExists(firebaseJsonPath) || pathExists(supabaseDir) || pathExists(vercelJsonPath) || isVercelFunctionsDir(joinPath(appDir, "functions"));
10186
10169
  }).sort();
10187
10170
  }
10188
- function readStagingProject(startDir) {
10189
- let current = startDir;
10190
- for (let i2 = 0; i2 < 10; i2++) {
10191
- const firebasercPath = joinPath(current, ".firebaserc");
10192
- if (pathExists(firebasercPath)) {
10193
- try {
10194
- const firebaserc = readFirebaserc(firebasercPath);
10195
- if (firebaserc?.projects?.staging) {
10196
- return firebaserc.projects.staging;
10197
- }
10198
- } catch (error2) {
10199
- }
10200
- }
10201
- const parent = joinPath(current, "..");
10202
- if (parent === current) break;
10203
- current = parent;
10204
- }
10205
- return null;
10206
- }
10207
10171
  var init_deploy_utils = __esm({
10208
10172
  "packages/tooling/src/apps/deploy-utils.ts"() {
10209
10173
  "use strict";
10210
10174
  init_utils2();
10211
10175
  init_app_detection();
10212
10176
  init_pathResolver();
10213
- init_typed_file_operations();
10214
10177
  }
10215
10178
  });
10216
10179
 
@@ -10345,12 +10308,12 @@ function describeTokenSource(resolved, projectRoot, appDir) {
10345
10308
  }
10346
10309
  return joinPath(appDir, resolved.legacyPath);
10347
10310
  }
10348
- function resolveVercelCredentials(appDir, projectRoot) {
10311
+ function resolveVercelCredentials(appDir, projectRoot, project) {
10349
10312
  const root = projectRoot ?? getRepoRoot();
10350
10313
  const resolvedToken = resolveSecret("VERCEL_TOKEN", root, { appDir });
10351
10314
  const token = resolvedToken?.value ?? null;
10352
- const orgId = resolvePerAppVar(appDir, "VERCEL_ORG_ID");
10353
- const projectId = resolvePerAppVar(appDir, "VERCEL_PROJECT_ID");
10315
+ const orgId = project ? project.orgId ?? null : resolvePerAppVar(appDir, "VERCEL_ORG_ID");
10316
+ const projectId = project ? project.projectId : resolvePerAppVar(appDir, "VERCEL_PROJECT_ID");
10354
10317
  const missing = [];
10355
10318
  if (!token) missing.push("VERCEL_TOKEN");
10356
10319
  if (!projectId) missing.push("VERCEL_PROJECT_ID");
@@ -10446,9 +10409,9 @@ ${errorOutput}`
10446
10409
  );
10447
10410
  }
10448
10411
  }
10449
- function uploadServiceAccountToGitHub(appDir, repo, dryRun = false, staging = false) {
10450
- const fileName = staging ? "service-account-key.staging.json" : "service-account-key.json";
10451
- const secretName = staging ? "FIREBASE_SERVICE_ACCOUNT_STAGING" : "FIREBASE_SERVICE_ACCOUNT";
10412
+ function uploadServiceAccountToGitHub(appDir, repo, dryRun = false) {
10413
+ const fileName = "service-account-key.json";
10414
+ const secretName = "FIREBASE_SERVICE_ACCOUNT";
10452
10415
  const filePath = joinPath(appDir, fileName);
10453
10416
  if (!pathExists(filePath)) {
10454
10417
  log2.debug(`No ${fileName} found in ${appDir}, skipping GitHub upload`);
@@ -10505,19 +10468,9 @@ function isGhAuthenticated() {
10505
10468
  return false;
10506
10469
  }
10507
10470
  }
10508
- function detectStagingSupport(appDir) {
10509
- const stagingProjectId = readStagingProject(appDir) ?? void 0;
10510
- const hasStagingKey = pathExists(
10511
- joinPath(appDir, "service-account-key.staging.json")
10512
- );
10513
- return {
10514
- hasStaging: !!stagingProjectId || hasStagingKey,
10515
- stagingProjectId
10516
- };
10517
- }
10518
10471
  function collectSecrets(config) {
10519
10472
  const secrets = [];
10520
- const { appDir, projectRoot, providers, hasStaging } = config;
10473
+ const { appDir, projectRoot, providers } = config;
10521
10474
  const saPath = joinPath(appDir, "service-account-key.json");
10522
10475
  if (usesFirebase(providers) && pathExists(saPath)) {
10523
10476
  secrets.push({
@@ -10527,14 +10480,6 @@ function collectSecrets(config) {
10527
10480
  source: "service-account-key.json (base64)"
10528
10481
  });
10529
10482
  }
10530
- const saStagingPath = joinPath(appDir, "service-account-key.staging.json");
10531
- if (hasStaging && pathExists(saStagingPath)) {
10532
- secrets.push({
10533
- name: "FIREBASE_SERVICE_ACCOUNT_STAGING",
10534
- value: "__SERVICE_ACCOUNT_STAGING__",
10535
- source: "service-account-key.staging.json (base64)"
10536
- });
10537
- }
10538
10483
  if (usesVercel(providers)) {
10539
10484
  const vercelResult = resolveVercelCredentials(appDir, projectRoot);
10540
10485
  if (vercelResult.credentials) {
@@ -10755,93 +10700,6 @@ jobs:
10755
10700
  ${steps}
10756
10701
  `;
10757
10702
  }
10758
- function generateStagingWorkflow(providers, envSecretNames) {
10759
- const appName = providers.name;
10760
- const envBlock = envSecretNames.filter((n3) => n3.startsWith("VITE_") || n3.startsWith("NEXT_PUBLIC_")).map((n3) => ` ${n3}: \${{ secrets.${n3} }}`).join("\n");
10761
- let steps = ` - name: Checkout repository
10762
- uses: actions/checkout@v4
10763
-
10764
- - name: Checkout dndev
10765
- uses: actions/checkout@v4
10766
- with:
10767
- repository: \${{ github.repository_owner }}/dndev
10768
- token: \${{ secrets.GH_PAT }}
10769
- path: dndev
10770
-
10771
- - name: Setup Node.js
10772
- uses: actions/setup-node@v4
10773
- with:
10774
- node-version: '${getNodePolicy().ci}'
10775
-
10776
- - name: Install Bun
10777
- uses: oven-sh/setup-bun@v2
10778
- with:
10779
- bun-version: latest
10780
-
10781
- - name: Install dependencies
10782
- run: bun install
10783
-
10784
- - name: Build (staging)
10785
- run: bun run build -- --mode staging${envBlock ? "\n env:\n" + envBlock : ""}`;
10786
- if (usesFirebase(providers)) {
10787
- const fbConfig = providers.firebaseConfig;
10788
- if (fbConfig?.hasFunctions) {
10789
- steps += `
10790
-
10791
- - name: Deploy Firebase Functions (staging)
10792
- run: npx firebase deploy --only functions --project $FIREBASE_PROJECT_ID_STAGING
10793
- env:
10794
- GOOGLE_APPLICATION_CREDENTIALS_JSON: \${{ secrets.FIREBASE_SERVICE_ACCOUNT_STAGING }}
10795
- working-directory: apps/${appName}`;
10796
- }
10797
- if (fbConfig?.hasFirestoreRules || fbConfig?.hasStorageRules) {
10798
- const targets = [];
10799
- if (fbConfig?.hasFirestoreRules) targets.push("firestore:rules");
10800
- if (fbConfig?.hasStorageRules) targets.push("storage");
10801
- steps += `
10802
-
10803
- - name: Deploy Firebase Rules (staging)
10804
- run: npx firebase deploy --only ${targets.join(",")} --project $FIREBASE_PROJECT_ID_STAGING
10805
- env:
10806
- GOOGLE_APPLICATION_CREDENTIALS_JSON: \${{ secrets.FIREBASE_SERVICE_ACCOUNT_STAGING }}
10807
- working-directory: apps/${appName}`;
10808
- }
10809
- if (fbConfig?.hasHosting && !usesVercel(providers)) {
10810
- steps += `
10811
-
10812
- - name: Deploy to Firebase Hosting (staging)
10813
- uses: FirebaseExtended/action-hosting-deploy@v0
10814
- with:
10815
- repoToken: \${{ secrets.GITHUB_TOKEN }}
10816
- firebaseServiceAccount: \${{ secrets.FIREBASE_SERVICE_ACCOUNT_STAGING }}
10817
- channelId: live
10818
- entryPoint: apps/${appName}`;
10819
- }
10820
- }
10821
- if (usesVercel(providers)) {
10822
- steps += `
10823
-
10824
- - name: Deploy to Vercel (staging)
10825
- run: npx vercel deploy --token $VERCEL_TOKEN
10826
- env:
10827
- VERCEL_TOKEN: \${{ secrets.VERCEL_TOKEN }}
10828
- VERCEL_ORG_ID: \${{ secrets.VERCEL_ORG_ID }}
10829
- VERCEL_PROJECT_ID: \${{ secrets.VERCEL_PROJECT_ID }}
10830
- working-directory: apps/${appName}`;
10831
- }
10832
- return `name: Deploy Staging
10833
-
10834
- on:
10835
- push:
10836
- branches: [staging, develop]
10837
-
10838
- jobs:
10839
- deploy-staging:
10840
- runs-on: ubuntu-latest
10841
- steps:
10842
- ${steps}
10843
- `;
10844
- }
10845
10703
  async function main(options = {}) {
10846
10704
  const dryRun = options.dryRun ?? false;
10847
10705
  intro("CI/CD Setup");
@@ -10891,24 +10749,20 @@ async function main(options = {}) {
10891
10749
  return 1;
10892
10750
  }
10893
10751
  const providers = detectProvider(appDir);
10894
- const staging = detectStagingSupport(appDir);
10895
10752
  const config = {
10896
10753
  appName,
10897
10754
  appDir,
10898
10755
  projectRoot,
10899
- providers,
10900
- hasStaging: staging.hasStaging,
10901
- stagingProjectId: staging.stagingProjectId
10756
+ providers
10902
10757
  };
10903
10758
  const secrets = collectSecrets(config);
10904
10759
  const missingSecrets = secrets.filter(
10905
10760
  (s2) => s2.value === "" || s2.source === "MISSING"
10906
10761
  );
10907
- const workflows = ["ci.yml (quality gate)"];
10908
- workflows.push("deploy.yml (production)");
10909
- if (config.hasStaging) {
10910
- workflows.push("deploy-staging.yml (staging)");
10911
- }
10762
+ const workflows = [
10763
+ "ci.yml (quality gate)",
10764
+ "deploy.yml (production)"
10765
+ ];
10912
10766
  const providerLabels = [];
10913
10767
  if (usesFirebase(providers)) providerLabels.push("Firebase");
10914
10768
  if (usesVercel(providers)) providerLabels.push("Vercel");
@@ -10917,7 +10771,6 @@ async function main(options = {}) {
10917
10771
  `App: ${appName}`,
10918
10772
  `Repo: ${repo}`,
10919
10773
  `Providers: ${providerLabels.join(" + ") || "none detected"}`,
10920
- `Staging: ${config.hasStaging ? "yes" : "no"}`,
10921
10774
  "",
10922
10775
  `Workflows to generate:`,
10923
10776
  ...workflows.map((w) => ` - ${w}`),
@@ -10962,17 +10815,10 @@ These will be skipped. Add them to .dndev.secrets or .env and re-run.`
10962
10815
  }
10963
10816
  if (usesFirebase(providers)) {
10964
10817
  try {
10965
- uploadServiceAccountToGitHub(appDir, repo, dryRun, false);
10818
+ uploadServiceAccountToGitHub(appDir, repo, dryRun);
10966
10819
  successCount++;
10967
10820
  } catch {
10968
10821
  }
10969
- if (config.hasStaging) {
10970
- try {
10971
- uploadServiceAccountToGitHub(appDir, repo, dryRun, true);
10972
- successCount++;
10973
- } catch {
10974
- }
10975
- }
10976
10822
  }
10977
10823
  if (failCount > 0) {
10978
10824
  s.stop(`Secrets: ${successCount} uploaded, ${failCount} failed`);
@@ -10984,29 +10830,17 @@ These will be skipped. Add them to .dndev.secrets or .env and re-run.`
10984
10830
  const secretNames = secrets.map((s2) => s2.name);
10985
10831
  const ciYaml = generateCIWorkflow(appName);
10986
10832
  const deployYaml = generateDeployWorkflow(providers, secretNames);
10987
- let stagingYaml;
10988
- if (config.hasStaging) {
10989
- stagingYaml = generateStagingWorkflow(providers, secretNames);
10990
- }
10991
10833
  if (dryRun) {
10992
10834
  log2.info("\n--- ci.yml ---");
10993
10835
  log2.info(ciYaml);
10994
10836
  log2.info("\n--- deploy.yml ---");
10995
10837
  log2.info(deployYaml);
10996
- if (stagingYaml) {
10997
- log2.info("\n--- deploy-staging.yml ---");
10998
- log2.info(stagingYaml);
10999
- }
11000
10838
  } else {
11001
10839
  ensureDir(workflowDir);
11002
10840
  write(joinPath(workflowDir, "ci.yml"), ciYaml);
11003
10841
  log2.success("Generated .github/workflows/ci.yml");
11004
10842
  write(joinPath(workflowDir, "deploy.yml"), deployYaml);
11005
10843
  log2.success("Generated .github/workflows/deploy.yml");
11006
- if (stagingYaml) {
11007
- write(joinPath(workflowDir, "deploy-staging.yml"), stagingYaml);
11008
- log2.success("Generated .github/workflows/deploy-staging.yml");
11009
- }
11010
10844
  }
11011
10845
  const nextSteps = [
11012
10846
  "Review generated workflow files in .github/workflows/",