create-disposabl-app 0.13.2 → 0.13.3

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/dist/disposabl.js CHANGED
@@ -5,7 +5,7 @@ import { lock } from "proper-lockfile";
5
5
  // ../cli/package.json
6
6
  var package_default = {
7
7
  name: "@disposabl/cli",
8
- version: "0.13.2",
8
+ version: "0.13.3",
9
9
  type: "module",
10
10
  description: "Command-line access to your Disposabl app",
11
11
  license: "MIT",
package/dist/index.js CHANGED
@@ -3,12 +3,12 @@
3
3
  // index.ts
4
4
  import { execFileSync as execFileSync2, spawnSync as spawnSync3 } from "node:child_process";
5
5
  import { lstatSync, readFileSync } from "node:fs";
6
- import { join as join5, resolve as resolve3 } from "node:path";
6
+ import { join as join6, resolve as resolve3 } from "node:path";
7
7
  import { fileURLToPath as fileURLToPath2 } from "node:url";
8
8
  import { Command, CommanderError } from "commander";
9
9
  import * as p2 from "@clack/prompts";
10
10
  // package.json
11
- var version = "0.13.2";
11
+ var version = "0.13.3";
12
12
 
13
13
  // ../disposabl-kit/platforms.ts
14
14
  var platforms = [
@@ -313,15 +313,76 @@ function projectSetup(name, config) {
313
313
  import {
314
314
  cp,
315
315
  mkdir,
316
- readFile,
316
+ readFile as readFile2,
317
317
  readdir,
318
318
  rename,
319
- rm,
320
- writeFile
319
+ rm as rm2,
320
+ writeFile as writeFile2
321
321
  } from "node:fs/promises";
322
- import { existsSync } from "node:fs";
323
- import { basename, join } from "node:path";
322
+ import { existsSync as existsSync2 } from "node:fs";
323
+ import { basename, join as join2 } from "node:path";
324
324
  import { randomUUID } from "node:crypto";
325
+
326
+ // mobile-payments.ts
327
+ import { existsSync } from "node:fs";
328
+ import { readFile, rm, writeFile } from "node:fs/promises";
329
+ import { join, sep } from "node:path";
330
+ var nativeBillingPath = join("packages", "disposabl-kit", "mobile", "billing") + sep;
331
+ var nativeBillingTest = join("packages", "tests", "native-billing.test.ts");
332
+ var purchasesPackage = "react-native-purchases";
333
+ var dependencyFields = [
334
+ "dependencies",
335
+ "peerDependencies",
336
+ "peerDependenciesMeta"
337
+ ];
338
+ function mergePurchasesManifest(prior, next, current) {
339
+ const before = JSON.parse(prior.toString());
340
+ const after = JSON.parse(next.toString());
341
+ const actual = JSON.parse(current.toString());
342
+ const withoutSdk = (value) => {
343
+ const copy = structuredClone(value);
344
+ for (const field of dependencyFields)
345
+ delete copy[field]?.[purchasesPackage];
346
+ return JSON.stringify(copy);
347
+ };
348
+ if (withoutSdk(before) !== withoutSdk(after))
349
+ return;
350
+ for (const field of dependencyFields) {
351
+ const oldValue = before[field]?.[purchasesPackage];
352
+ const newValue = after[field]?.[purchasesPackage];
353
+ const currentValue = actual[field]?.[purchasesPackage];
354
+ if (JSON.stringify(oldValue) === JSON.stringify(newValue))
355
+ continue;
356
+ if (JSON.stringify(currentValue) !== JSON.stringify(oldValue) && JSON.stringify(currentValue) !== JSON.stringify(newValue))
357
+ throw new Error(`Cannot reconfigure: customized ${purchasesPackage} ${field}. No files were changed.`);
358
+ if (newValue === undefined)
359
+ delete actual[field]?.[purchasesPackage];
360
+ else
361
+ (actual[field] ??= {})[purchasesPackage] = newValue;
362
+ }
363
+ return Buffer.from(JSON.stringify(actual, null, 2) + `
364
+ `);
365
+ }
366
+ async function omitMobilePayments(root) {
367
+ for (const name of ["apps/mobile", "packages/disposabl-kit"]) {
368
+ const path = join(root, name, "package.json");
369
+ if (!existsSync(path))
370
+ continue;
371
+ const manifest = JSON.parse(await readFile(path, "utf8"));
372
+ for (const field of dependencyFields)
373
+ if (manifest[field])
374
+ delete manifest[field][purchasesPackage];
375
+ await writeFile(path, JSON.stringify(manifest, null, 2) + `
376
+ `);
377
+ }
378
+ const path = join(root, "packages/disposabl-kit/mobile/screens/account.tsx");
379
+ const source = await readFile(path, "utf8");
380
+ await writeFile(path, source.replace(/^[ \t]*\/\/ payments:start\r?\n[\s\S]*?^[ \t]*\/\/ payments:end\r?\n/gm, "").replace(/^[ \t]*\{\/\* payments:start \*\/\}\r?\n[\s\S]*?^[ \t]*\{\/\* payments:end \*\/\}\r?\n/gm, ""));
381
+ await rm(join(root, nativeBillingPath), { recursive: true, force: true });
382
+ await rm(join(root, nativeBillingTest), { force: true });
383
+ }
384
+
385
+ // scaffold.ts
325
386
  async function createApp(template, destination, name, config, overwrite = false) {
326
387
  config = {
327
388
  ...config,
@@ -330,47 +391,47 @@ async function createApp(template, destination, name, config, overwrite = false)
330
391
  features: selectFeatures(config.features.join(",") || "none")
331
392
  };
332
393
  const folders = selectedFolders(config);
333
- const skill = join(template, "packages/skill");
334
- if (!existsSync(join(skill, "SKILL.md")))
394
+ const skill = join2(template, "packages/skill");
395
+ if (!existsSync2(join2(skill, "SKILL.md")))
335
396
  throw new Error("The bundled starter is missing the Disposabl skill. Rebuild the CLI.");
336
397
  for (const folder of folders) {
337
- if (!existsSync(join(template, folder, "package.json"))) {
398
+ if (!existsSync2(join2(template, folder, "package.json"))) {
338
399
  throw new Error("The bundled starter is missing " + folder + "/package.json. Rebuild the CLI.");
339
400
  }
340
401
  }
341
402
  if (overwrite)
342
- await rm(destination, { recursive: true, force: true });
403
+ await rm2(destination, { recursive: true, force: true });
343
404
  await mkdir(destination);
344
405
  try {
345
406
  for (const entry of await readdir(template)) {
346
- await cp(join(template, entry), join(destination, entry), {
407
+ await cp(join2(template, entry), join2(destination, entry), {
347
408
  recursive: true,
348
409
  force: false,
349
410
  errorOnExist: true
350
411
  });
351
412
  }
352
413
  for (const agent of [".agents", ".claude"]) {
353
- const skills = join(destination, agent, "skills");
414
+ const skills = join2(destination, agent, "skills");
354
415
  await mkdir(skills, { recursive: true });
355
- await cp(skill, join(skills, "disposabl-app"), { recursive: true });
416
+ await cp(skill, join2(skills, "disposabl-app"), { recursive: true });
356
417
  }
357
- const instructions = join(destination, "AGENTS.md");
358
- await writeFile(instructions, await readFile(instructions, "utf8") + `
418
+ const instructions = join2(destination, "AGENTS.md");
419
+ await writeFile2(instructions, await readFile2(instructions, "utf8") + `
359
420
  ## Disposabl
360
421
 
361
422
  For Disposabl development and delivery, read [.agents/skills/disposabl-app/SKILL.md](.agents/skills/disposabl-app/SKILL.md). Work in this generated app; create another app only when requested.
362
423
  `);
363
- for (const entry of await readdir(join(destination, "apps"))) {
424
+ for (const entry of await readdir(join2(destination, "apps"))) {
364
425
  if (!folders.includes("apps/" + entry))
365
- await rm(join(destination, "apps", entry), {
426
+ await rm2(join2(destination, "apps", entry), {
366
427
  recursive: true,
367
428
  force: true
368
429
  });
369
430
  }
370
- const tests = join(destination, "packages/tests");
431
+ const tests = join2(destination, "packages/tests");
371
432
  for (const entry of await readdir(tests)) {
372
433
  if (!folders.includes("apps/desktop") && /^desktop-.*\.test\.ts$/.test(entry) || !folders.includes("apps/mobile") && /^(mobile-.*|native-billing|ios-ota)\.test\.ts$/.test(entry))
373
- await rm(join(tests, entry));
434
+ await rm2(join2(tests, entry));
374
435
  }
375
436
  if (!config.features.includes("authentication")) {
376
437
  for (const path of [
@@ -380,57 +441,59 @@ For Disposabl development and delivery, read [.agents/skills/disposabl-app/SKILL
380
441
  "apps/web/src/router/_authenticated/dashboard.api-keys.tsx",
381
442
  "apps/mobile/src/app/(auth)"
382
443
  ]) {
383
- await rm(join(destination, path), { recursive: true, force: true });
444
+ await rm2(join2(destination, path), { recursive: true, force: true });
384
445
  }
385
- await writeFile(join(destination, "apps/web/src/router/_authenticated/dashboard.tsx"), `import { createFileRoute } from "@tanstack/react-router";
446
+ await writeFile2(join2(destination, "apps/web/src/router/_authenticated/dashboard.tsx"), `import { createFileRoute } from "@tanstack/react-router";
386
447
 
387
448
  export const Route = createFileRoute("/_providers/_authenticated/dashboard")({
388
449
  component: () => <h1>Dashboard</h1>,
389
450
  });
390
451
  `);
391
452
  if (folders.includes("apps/mobile")) {
392
- await writeFile(join(destination, "apps/mobile/src/app/index.tsx"), `export { PublicHomeScreen as default } from "@disposabl/disposabl-kit/mobile";
453
+ await writeFile2(join2(destination, "apps/mobile/src/app/index.tsx"), `export { PublicHomeScreen as default } from "@disposabl/disposabl-kit/mobile";
393
454
  `);
394
455
  }
395
456
  }
457
+ if (!config.features.includes("payments"))
458
+ await omitMobilePayments(destination);
396
459
  if (!config.features.includes("docs")) {
397
- const webPackage = join(destination, "apps/web/package.json");
398
- const web = JSON.parse(await readFile(webPackage, "utf8"));
460
+ const webPackage = join2(destination, "apps/web/package.json");
461
+ const web = JSON.parse(await readFile2(webPackage, "utf8"));
399
462
  delete web.devDependencies["@disposabl/docs"];
400
- await writeFile(webPackage, JSON.stringify(web, null, 2) + `
463
+ await writeFile2(webPackage, JSON.stringify(web, null, 2) + `
401
464
  `);
402
465
  for (const file of [
403
466
  "apps/web/vite.config.ts",
404
467
  "packages/disposabl-kit/client/lib/prerender.ts",
405
468
  "packages/disposabl-kit/server/http.ts"
406
469
  ]) {
407
- const path = join(destination, file);
408
- const source = await readFile(path, "utf8");
409
- await writeFile(path, source.replace(/^[ \t]*\/\/ docs:start\r?\n[\s\S]*?^[ \t]*\/\/ docs:end\r?\n/gm, ""));
470
+ const path = join2(destination, file);
471
+ const source = await readFile2(path, "utf8");
472
+ await writeFile2(path, source.replace(/^[ \t]*\/\/ docs:start\r?\n[\s\S]*?^[ \t]*\/\/ docs:end\r?\n/gm, ""));
410
473
  }
411
- const turboPath = join(destination, "turbo.json");
412
- const turbo = JSON.parse(await readFile(turboPath, "utf8"));
474
+ const turboPath = join2(destination, "turbo.json");
475
+ const turbo = JSON.parse(await readFile2(turboPath, "utf8"));
413
476
  delete turbo.tasks["@disposabl/docs#build"];
414
477
  delete turbo.tasks["@disposabl/web#build"];
415
- await writeFile(turboPath, JSON.stringify(turbo, null, 2) + `
478
+ await writeFile2(turboPath, JSON.stringify(turbo, null, 2) + `
416
479
  `);
417
- await rm(join(destination, "packages/disposabl-kit/server/lib/docs.ts"));
480
+ await rm2(join2(destination, "packages/disposabl-kit/server/lib/docs.ts"));
418
481
  }
419
482
  for (const kind of ["cli", "sdk"]) {
420
- const folder = join(destination, "packages", kind);
483
+ const folder = join2(destination, "packages", kind);
421
484
  if (!folders.includes(`packages/${kind}`)) {
422
- await rm(folder, { recursive: true, force: true });
485
+ await rm2(folder, { recursive: true, force: true });
423
486
  continue;
424
487
  }
425
- const packagePath = join(folder, "package.json");
426
- const client = JSON.parse(await readFile(packagePath, "utf8"));
488
+ const packagePath = join2(folder, "package.json");
489
+ const client = JSON.parse(await readFile2(packagePath, "utf8"));
427
490
  client.name = `${name}-${kind}`;
428
491
  delete client.repository;
429
492
  if (client.name.length > 214)
430
493
  throw new Error("Project name is too long for generated package names.");
431
494
  if (kind === "cli") {
432
495
  client.bin = { [name]: "dist/index.js" };
433
- await writeFile(join(folder, "index.ts"), `#!/usr/bin/env node
496
+ await writeFile2(join2(folder, "index.ts"), `#!/usr/bin/env node
434
497
  import { readFile } from "node:fs/promises";
435
498
  import { runCli } from "./commands";
436
499
 
@@ -469,52 +532,52 @@ main().catch((error) => {
469
532
  });
470
533
  `);
471
534
  }
472
- await writeFile(packagePath, JSON.stringify(client, null, 2) + `
535
+ await writeFile2(packagePath, JSON.stringify(client, null, 2) + `
473
536
  `);
474
- const readme = join(folder, "README.md");
475
- if (existsSync(readme))
476
- await writeFile(readme, (await readFile(readme, "utf8")).replaceAll(`@disposabl/${kind}`, client.name));
537
+ const readme = join2(folder, "README.md");
538
+ if (existsSync2(readme))
539
+ await writeFile2(readme, (await readFile2(readme, "utf8")).replaceAll(`@disposabl/${kind}`, client.name));
477
540
  }
478
541
  for (const path of await readdir(destination, { recursive: true })) {
479
542
  if (basename(path) === "gitignore") {
480
- await rename(join(destination, path), join(destination, path.replace(/gitignore$/, ".gitignore")));
543
+ await rename(join2(destination, path), join2(destination, path.replace(/gitignore$/, ".gitignore")));
481
544
  }
482
545
  }
483
- const manifestPath = join(destination, "package.json");
484
- const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
546
+ const manifestPath = join2(destination, "package.json");
547
+ const manifest = JSON.parse(await readFile2(manifestPath, "utf8"));
485
548
  manifest.name = name;
486
- await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + `
549
+ await writeFile2(manifestPath, JSON.stringify(manifest, null, 2) + `
487
550
  `);
488
551
  if (folders.includes("apps/desktop")) {
489
- const desktopPath = join(destination, "apps/desktop/package.json");
490
- const desktop = JSON.parse(await readFile(desktopPath, "utf8"));
552
+ const desktopPath = join2(destination, "apps/desktop/package.json");
553
+ const desktop = JSON.parse(await readFile2(desktopPath, "utf8"));
491
554
  if (!/^[a-f0-9]{32}$/.test(config.desktopId))
492
555
  throw new Error("Invalid desktop identity.");
493
556
  desktop.name = `disposabl-desktop-${config.desktopId}`;
494
557
  desktop.disposablDesktopId = config.desktopId;
495
558
  desktop.productName = name;
496
559
  desktop.description = `${name} desktop app`;
497
- await writeFile(desktopPath, JSON.stringify(desktop, null, 2) + `
560
+ await writeFile2(desktopPath, JSON.stringify(desktop, null, 2) + `
498
561
  `);
499
- const lockPath = join(destination, "bun.lock");
500
- let lock = await readFile(lockPath, "utf8");
562
+ const lockPath = join2(destination, "bun.lock");
563
+ let lock = await readFile2(lockPath, "utf8");
501
564
  lock = lock.replace(`"apps/desktop": {
502
565
  "name": "desktop"`, `"apps/desktop": {
503
566
  "name": "${desktop.name}"`).replace('"desktop": ["desktop@workspace:apps/desktop"]', `"${desktop.name}": ["${desktop.name}@workspace:apps/desktop"]`);
504
- await writeFile(lockPath, lock);
567
+ await writeFile2(lockPath, lock);
505
568
  }
506
569
  if (folders.includes("apps/mobile")) {
507
- const appConfigPath = join(destination, "apps/mobile/app.json");
508
- const appConfig = JSON.parse(await readFile(appConfigPath, "utf8"));
570
+ const appConfigPath = join2(destination, "apps/mobile/app.json");
571
+ const appConfig = JSON.parse(await readFile2(appConfigPath, "utf8"));
509
572
  appConfig.expo.name = name;
510
573
  appConfig.expo.slug = name;
511
- await writeFile(appConfigPath, JSON.stringify(appConfig, null, 2) + `
574
+ await writeFile2(appConfigPath, JSON.stringify(appConfig, null, 2) + `
512
575
  `);
513
576
  }
514
- await writeFile(join(destination, "disposabl.json"), JSON.stringify(config, null, 2) + `
577
+ await writeFile2(join2(destination, "disposabl.json"), JSON.stringify(config, null, 2) + `
515
578
  `);
516
579
  } catch (error) {
517
- await rm(destination, { recursive: true, force: true });
580
+ await rm2(destination, { recursive: true, force: true });
518
581
  throw error;
519
582
  }
520
583
  return folders;
@@ -525,20 +588,20 @@ import {
525
588
  lstat,
526
589
  mkdtemp,
527
590
  mkdir as mkdir2,
528
- readFile as readFile2,
591
+ readFile as readFile3,
529
592
  readdir as readdir2,
530
- rm as rm2,
531
- writeFile as writeFile2
593
+ rm as rm3,
594
+ writeFile as writeFile3
532
595
  } from "node:fs/promises";
533
596
  import { tmpdir } from "node:os";
534
597
  import { randomUUID as randomUUID2 } from "node:crypto";
535
- import { dirname, join as join2, resolve, sep } from "node:path";
598
+ import { basename as basename2, dirname, join as join3, resolve, sep as sep2 } from "node:path";
536
599
  async function files(root, path = "") {
537
600
  const result = [];
538
- for (const entry of await readdir2(join2(root, path), {
601
+ for (const entry of await readdir2(join3(root, path), {
539
602
  withFileTypes: true
540
603
  })) {
541
- const relative = join2(path, entry.name);
604
+ const relative = join3(path, entry.name);
542
605
  if (entry.isSymbolicLink())
543
606
  throw new Error(`Symlink in starter: ${relative}`);
544
607
  if (entry.isDirectory())
@@ -555,11 +618,11 @@ async function safeRead(root, path) {
555
618
  if ((await lstat(base)).isSymbolicLink())
556
619
  throw new Error(`Refusing symlink: ${base}`);
557
620
  const target = resolve(base, path);
558
- if (!target.startsWith(base + sep))
621
+ if (!target.startsWith(base + sep2))
559
622
  throw new Error(`Unsafe path: ${path}`);
560
623
  let current = base;
561
- for (const part of path.split(sep)) {
562
- current = join2(current, part);
624
+ for (const part of path.split(sep2)) {
625
+ current = join3(current, part);
563
626
  const stat = await lstat(current).catch((error) => {
564
627
  if (error.code === "ENOENT")
565
628
  return;
@@ -570,7 +633,7 @@ async function safeRead(root, path) {
570
633
  if (stat.isSymbolicLink())
571
634
  throw new Error(`Refusing symlink: ${current}`);
572
635
  }
573
- return readFile2(target);
636
+ return readFile3(target);
574
637
  }
575
638
  async function reconfigureApp(template, directory, version, options) {
576
639
  const configPath = "disposabl.json";
@@ -604,10 +667,10 @@ async function reconfigureApp(template, directory, version, options) {
604
667
  if (typeof name !== "string" || !/^[a-z0-9][a-z0-9._-]*$/.test(name))
605
668
  throw new Error("Invalid app name in package.json.");
606
669
  await files(template);
607
- const temp = await mkdtemp(join2(tmpdir(), "disposabl-reconfigure-"));
670
+ const temp = await mkdtemp(join3(tmpdir(), "disposabl-reconfigure-"));
608
671
  try {
609
- const before = join2(temp, "before");
610
- const after = join2(temp, "after");
672
+ const before = join3(temp, "before");
673
+ const after = join3(temp, "after");
611
674
  await createApp(template, before, name, {
612
675
  ...existing,
613
676
  desktopId: config.desktopId,
@@ -615,13 +678,31 @@ async function reconfigureApp(template, directory, version, options) {
615
678
  features: oldFeatures
616
679
  });
617
680
  await createApp(template, after, name, combined);
681
+ if (oldFeatures.includes("payments") && !config.features.includes("payments"))
682
+ await omitMobilePayments(after);
618
683
  const oldFiles = new Set(await files(before));
684
+ const nextFiles = new Set(await files(after));
619
685
  const changes = [];
620
- for (const path of await files(after)) {
686
+ if (oldFeatures.includes("payments") && !config.features.includes("payments")) {
687
+ const billing = join3(directory, nativeBillingPath);
688
+ const stat = await lstat(billing).catch((error) => {
689
+ if (error.code === "ENOENT")
690
+ return;
691
+ throw error;
692
+ });
693
+ if (stat?.isSymbolicLink())
694
+ throw new Error(`Refusing symlink: ${billing}`);
695
+ if (stat)
696
+ for (const path of await files(billing)) {
697
+ if (!oldFiles.has(nativeBillingPath + path))
698
+ throw new Error(`Cannot disable payments: ${nativeBillingPath + path} is a custom billing file. No files were changed.`);
699
+ }
700
+ }
701
+ for (const path of nextFiles) {
621
702
  if (path === configPath)
622
703
  continue;
623
- const next = await readFile2(join2(after, path));
624
- const prior = oldFiles.has(path) ? await readFile2(join2(before, path)) : undefined;
704
+ const next = await readFile3(join3(after, path));
705
+ const prior = oldFiles.has(path) ? await readFile3(join3(before, path)) : undefined;
625
706
  if (prior?.equals(next))
626
707
  continue;
627
708
  const current = await safeRead(directory, path);
@@ -635,31 +716,49 @@ async function reconfigureApp(template, directory, version, options) {
635
716
  continue;
636
717
  else if (current.equals(prior))
637
718
  changes.push({ path, content: next });
638
- else
639
- throw new Error(`Cannot reconfigure: ${path} conflicts with the starter changes. Reconcile this file and retry; no files were changed.`);
719
+ else {
720
+ const merged = basename2(path) === "package.json" ? mergePurchasesManifest(prior, next, current) : undefined;
721
+ if (merged)
722
+ changes.push({ path, content: merged });
723
+ else
724
+ throw new Error(`Cannot reconfigure: ${path} conflicts with the starter changes. Reconcile this file and retry; no files were changed.`);
725
+ }
726
+ }
727
+ for (const path of oldFiles) {
728
+ if (nextFiles.has(path) || !(path.startsWith(nativeBillingPath) || path === nativeBillingTest))
729
+ continue;
730
+ const current = await safeRead(directory, path);
731
+ if (!current)
732
+ continue;
733
+ if (!current.equals(await readFile3(join3(before, path))))
734
+ throw new Error(`Cannot disable payments: ${path} was customized. No files were changed.`);
735
+ changes.push({ path });
640
736
  }
641
737
  for (const { path } of changes)
642
738
  await safeRead(directory, path);
643
739
  for (const { path, content } of changes) {
644
- await mkdir2(dirname(join2(directory, path)), { recursive: true });
645
- await writeFile2(join2(directory, path), content);
740
+ if (content) {
741
+ await mkdir2(dirname(join3(directory, path)), { recursive: true });
742
+ await writeFile3(join3(directory, path), content);
743
+ } else
744
+ await rm3(join3(directory, path));
646
745
  }
647
- await writeFile2(join2(directory, configPath), JSON.stringify(config, null, 2) + `
746
+ await writeFile3(join3(directory, configPath), JSON.stringify(config, null, 2) + `
648
747
  `);
649
748
  return config;
650
749
  } finally {
651
- await rm2(temp, { recursive: true, force: true });
750
+ await rm3(temp, { recursive: true, force: true });
652
751
  }
653
752
  }
654
753
 
655
754
  // setup.ts
656
755
  import { execFileSync, spawn, spawnSync as spawnSync2 } from "node:child_process";
657
- import { readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
658
- import { basename as basename3, join as join4 } from "node:path";
756
+ import { readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
757
+ import { basename as basename4, join as join5 } from "node:path";
659
758
  import { fileURLToPath } from "node:url";
660
759
 
661
760
  // ../cli/preview.ts
662
- import { basename as basename2, join as join3, resolve as resolve2 } from "node:path";
761
+ import { basename as basename3, join as join4, resolve as resolve2 } from "node:path";
663
762
  import { spawnSync } from "node:child_process";
664
763
  function detectReference(directory = process.cwd()) {
665
764
  const git = (...args) => spawnSync("git", args, { cwd: directory, encoding: "utf8" }).stdout?.trim();
@@ -670,7 +769,7 @@ function detectReference(directory = process.cwd()) {
670
769
  const common = git("rev-parse", "--path-format=absolute", "--git-common-dir");
671
770
  const local = git("rev-parse", "--absolute-git-dir");
672
771
  if (root && common && local && common !== local)
673
- return basename2(root);
772
+ return basename3(root);
674
773
  throw new Error("Cannot detect a branch or worktree. Run inside the app's Git checkout or supply --reference.");
675
774
  }
676
775
 
@@ -714,8 +813,8 @@ var runDisposabl = (args, interactive = false, origin) => new Promise((resolve,
714
813
  });
715
814
  async function setupApp(directory, name, run = runDisposabl) {
716
815
  const reference = detectReference(directory);
717
- const path = join4(directory, "disposabl.json");
718
- const config = JSON.parse(await readFile3(path, "utf8"));
816
+ const path = join5(directory, "disposabl.json");
817
+ const config = JSON.parse(await readFile4(path, "utf8"));
719
818
  const origin = apiUrl(process.env.DISPOSABL_API_ORIGIN || config.serviceOrigin || SERVICE_ORIGIN);
720
819
  if (config.appId && config.serviceOrigin && apiUrl(config.serviceOrigin) !== origin)
721
820
  throw new Error("This app belongs to a different Disposabl service. Use its saved service origin.");
@@ -723,7 +822,7 @@ async function setupApp(directory, name, run = runDisposabl) {
723
822
  if (run === runDisposabl)
724
823
  run = (args, interactive) => runDisposabl(args, interactive, origin);
725
824
  config.features = resolveFeatures(config.features ?? []);
726
- await writeFile3(path, JSON.stringify(config, null, 2) + `
825
+ await writeFile4(path, JSON.stringify(config, null, 2) + `
727
826
  `);
728
827
  const status = await run(["login", "status"]);
729
828
  if (!status.currentUser) {
@@ -742,7 +841,7 @@ async function setupApp(directory, name, run = runDisposabl) {
742
841
  ...config.platforms.some((p) => p === "ios" || p === "android") ? ["--mobile"] : []
743
842
  ]);
744
843
  if (!connections.ready)
745
- throw new Error(`Finish connecting your app's accounts at ${connections.connectionsUrl ?? "https://www.disposabl.dev/dashboard/connections"}, then retry from the parent directory: bun create disposabl-app@latest ` + basename3(directory) + ". Your app files and login are saved.");
844
+ throw new Error(`Finish connecting your app's accounts at ${connections.connectionsUrl ?? "https://www.disposabl.dev/dashboard/connections"}, then retry from the parent directory: bun create disposabl-app@latest ` + basename4(directory) + ". Your app files and login are saved.");
746
845
  if (!config.appId) {
747
846
  const app = await run([
748
847
  "apps",
@@ -755,7 +854,7 @@ async function setupApp(directory, name, run = runDisposabl) {
755
854
  JSON.stringify(config.features)
756
855
  ]);
757
856
  config.appId = app.appId;
758
- await writeFile3(path, JSON.stringify(config, null, 2) + `
857
+ await writeFile4(path, JSON.stringify(config, null, 2) + `
759
858
  `);
760
859
  execFileSync("bun", ["fmt", "disposabl.json"], {
761
860
  cwd: directory,
@@ -912,9 +1011,9 @@ async function main() {
912
1011
  if (options.appId && !/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(options.appId))
913
1012
  throw new Error("--app-id must be a lowercase UUID v4.");
914
1013
  let directory = resolve3(name);
915
- if (pathExists(join5(directory, "disposabl.json"))) {
1014
+ if (pathExists(join6(directory, "disposabl.json"))) {
916
1015
  if (options.appId) {
917
- const existing = JSON.parse(readFileSync(join5(directory, "disposabl.json"), "utf8"));
1016
+ const existing = JSON.parse(readFileSync(join6(directory, "disposabl.json"), "utf8"));
918
1017
  if (existing.appId !== options.appId)
919
1018
  throw new Error("This directory belongs to a different app. Choose a new directory.");
920
1019
  }
@@ -1,6 +1,16 @@
1
1
  const { getDefaultConfig } = require("expo/metro-config");
2
2
  const { withNativewind } = require("nativewind/metro");
3
3
 
4
- module.exports = withNativewind(getDefaultConfig(__dirname), {
4
+ const config = getDefaultConfig(__dirname);
5
+ if (process.env.EXPO_NO_DOTENV === "1") {
6
+ // SDK 58's development env module otherwise reloads .env files after shell values.
7
+ const blocked = config.resolver.blockList ?? [];
8
+ config.resolver.blockList = [
9
+ ...(Array.isArray(blocked) ? blocked : [blocked]),
10
+ /[/\\]\.env(?:\.(?:local|development|production)(?:\.local)?)?$/,
11
+ ];
12
+ }
13
+
14
+ module.exports = withNativewind(config, {
5
15
  inlineVariables: false,
6
16
  });
@@ -281,6 +281,7 @@
281
281
  },
282
282
  },
283
283
  "patchedDependencies": {
284
+ "expo-modules-core@58.0.30": "patches/expo-modules-core@58.0.30.patch",
284
285
  "react-native-css@3.1.0-rc.1": "patches/react-native-css@3.1.0-rc.1.patch",
285
286
  "@convex-dev/static-hosting@0.2.1": "patches/@convex-dev%2Fstatic-hosting@0.2.1.patch",
286
287
  },
@@ -39,7 +39,8 @@
39
39
  },
40
40
  "patchedDependencies": {
41
41
  "@convex-dev/static-hosting@0.2.1": "patches/@convex-dev%2Fstatic-hosting@0.2.1.patch",
42
- "react-native-css@3.1.0-rc.1": "patches/react-native-css@3.1.0-rc.1.patch"
42
+ "react-native-css@3.1.0-rc.1": "patches/react-native-css@3.1.0-rc.1.patch",
43
+ "expo-modules-core@58.0.30": "patches/expo-modules-core@58.0.30.patch"
43
44
  },
44
45
  "overrides": {
45
46
  "lightningcss": "1.30.1"
@@ -10,6 +10,8 @@ The app calls Autumn API 2.6.0 `customers.get_or_create`, `billing.attach`, and
10
10
 
11
11
  ## Native subscriptions and synchronization
12
12
 
13
+ Generated apps include RevenueCat and the native billing example only when payments is selected. Reconfiguring payments adds or removes that SDK and its unchanged example files; unrelated dependencies are preserved. Customized billing files must be reconciled before disabling payments. Run installation after reconfiguration and build a new native binary when the SDK selection changes.
14
+
13
15
  The account screen supports monthly subscriptions and restore through RevenueCat. Use Autumn's managed RevenueCat integration as the sole sync path, with the same authenticated user ID as RevenueCat `appUserID` and Autumn `customer_id`. Request beta access, connect a RevenueCat project and V2 read-only key in Autumn, map store-level subscription products to `credits_monthly`, and configure separate test and live webhooks using Autumn's provided URL and authorization. Block duplicate web/native subscriptions based on the provider customer state. Mobile purchases use RevenueCat, never Autumn attach. Await Autumn webhook synchronization before treating the Autumn balance as available.
14
16
 
15
17
  Set public build-time variables `EXPO_PUBLIC_REVENUECAT_IOS_API_KEY` and `EXPO_PUBLIC_REVENUECAT_ANDROID_API_KEY`, plus `EXPO_PUBLIC_REVENUECAT_IOS_MONTHLY_PRODUCT` and `EXPO_PUBLIC_REVENUECAT_ANDROID_MONTHLY_PRODUCT` to the exact store product identifiers. Configure each as a $5 monthly product with no unverified offers. The app displays the store's localized price. Build a new native binary after adding the SDK; Expo Go is insufficient. Android uses `singleTop` when payments is selected so external bank verification can return to the purchase.
@@ -17,9 +17,11 @@ import {
17
17
  } from "../design/preferences";
18
18
  import { ThemedText } from "../design/themed-text";
19
19
  import { api } from "../lib/convex";
20
- import { authenticationEnabled, paymentsEnabled } from "../../features";
20
+ import * as features from "../../features";
21
+ // payments:start
21
22
  import { AccountBilling } from "../billing/account-billing";
22
23
  import { billingSession } from "../billing/session";
24
+ // payments:end
23
25
 
24
26
  type AccountScreenProps = {
25
27
  accountRows?: ReactNode;
@@ -37,7 +39,7 @@ async function copyEmail(email: string) {
37
39
 
38
40
  /** Preferences are public. Only account content requires an authenticated provider. */
39
41
  export function AccountScreen(props: AccountScreenProps) {
40
- return authenticationEnabled ? (
42
+ return features.authenticationEnabled ? (
41
43
  <SessionSettings {...props} />
42
44
  ) : (
43
45
  <GuestSettings {...props} />
@@ -60,7 +62,7 @@ function GuestSettings({
60
62
  }: AccountScreenProps & { loading?: boolean }) {
61
63
  return (
62
64
  <SettingsPage>
63
- {authenticationEnabled && (
65
+ {features.authenticationEnabled && (
64
66
  <PreferenceSection title="Account">
65
67
  <PreferenceRow
66
68
  icon={{ ios: "person.crop.circle", android: "account_circle" }}
@@ -97,18 +99,24 @@ function SignedInSettings({
97
99
  const { signOut } = useAuthActions();
98
100
  const [pending, setPending] = useState(false);
99
101
  const [error, setError] = useState<string | null>(null);
102
+ // payments:start
100
103
  const [billingEpoch, setBillingEpoch] = useState(0);
104
+ // payments:end
101
105
 
102
106
  async function logOut() {
103
107
  if (pending) return;
108
+ // payments:start
104
109
  billingSession.select(null);
110
+ // payments:end
105
111
  setPending(true);
106
112
  setError(null);
107
113
  try {
108
114
  await signOut();
109
115
  router.dismissTo("/");
110
116
  } catch {
117
+ // payments:start
111
118
  setBillingEpoch((value) => value + 1);
119
+ // payments:end
112
120
  setError("Couldn't clear your session. Please try logging out again.");
113
121
  } finally {
114
122
  setPending(false);
@@ -146,7 +154,8 @@ function SignedInSettings({
146
154
  />
147
155
  </PreferenceSection>
148
156
  )}
149
- {isAuthenticated && user && paymentsEnabled && !pending && (
157
+ {/* payments:start */}
158
+ {isAuthenticated && user && features.paymentsEnabled && !pending && (
150
159
  <PreferenceSection title="Billing">
151
160
  <View style={{ padding: 20 }}>
152
161
  <AccountBilling
@@ -156,6 +165,7 @@ function SignedInSettings({
156
165
  </View>
157
166
  </PreferenceSection>
158
167
  )}
168
+ {/* payments:end */}
159
169
  <View className="mt-7">
160
170
  <PreferenceCard>
161
171
  <PreferenceRow
@@ -48,6 +48,8 @@ The config evaluates `apps/mobile/app.config.js` to use the same bundle IDs and
48
48
 
49
49
  For a development client with several Metro servers running, set `E2E_MOBILE_DEV_URL` to this app's Metro URL and `E2E_MOBILE_DEV_SCHEME` to its unique installed URL scheme. The mobile flows explicitly connect after launch and restart. This prevents accidentally testing another server or backend. Release builds omit both variables.
50
50
 
51
+ When supplying an isolated backend through Metro's shell environment, also set `EXPO_NO_DOTENV=1` and `EXPO_PUBLIC_E2E=true`. The Metro configuration excludes dotenv files in this mode: SDK 58's development environment module otherwise reloads `.env.local` after shell values. Set both `EXPO_PUBLIC_CONVEX_URL` and `EXPO_PUBLIC_CONVEX_SITE_URL` to the test backend, using the emulator's reachable host address. The test runner's `E2E_CONVEX_URL` and `E2E_CONVEX_SITE_URL` must address that same deployment from the host.
52
+
51
53
  ## CI
52
54
 
53
55
  The same commands work in CI without model credentials. On Linux, install Chromium's system dependencies with `bun run --cwd packages/tests setup:browser`. Provision an isolated backend and deploy the current functions before testing. Set its URLs, then run `bun run test --target web,backend` and include `,api` when `disposabl.json` enables it.
@@ -10,8 +10,6 @@ export async function openMobile(
10
10
  }: Pick<TestFixtures, "app" | "screen"> & { device: Device },
11
11
  restart = false,
12
12
  ) {
13
- if (restart) await app.restart();
14
- else await app.open();
15
13
  const origin = process.env.E2E_MOBILE_DEV_URL;
16
14
  if (origin) {
17
15
  const scheme = process.env.E2E_MOBILE_DEV_SCHEME;
@@ -23,8 +21,12 @@ export async function openMobile(
23
21
  url.searchParams.set("url", origin);
24
22
  url.searchParams.set("__expo_disable_fab", "1");
25
23
  url.searchParams.set("__expo_disable_onboarding", "1");
24
+ // Launch the selected project once. Opening the saved project first races
25
+ // native initialization against the development client's redirect/reload.
26
+ await device.closeApp();
26
27
  await device.openLink(url.href);
27
- }
28
+ } else if (restart) await app.restart();
29
+ else await app.open();
28
30
  const settings = screen.getByRole("button", "Settings", { exact: true });
29
31
  await expect(settings).toHaveCount(1, { timeout: 30_000 });
30
32
  await expect(settings).toBeVisible({ timeout: 30_000 });
@@ -0,0 +1,23 @@
1
+ diff --git a/android/src/main/java/expo/modules/kotlin/jni/fabric/NativeStatePropsGetter.kt b/android/src/main/java/expo/modules/kotlin/jni/fabric/NativeStatePropsGetter.kt
2
+ index 1509bddac6ae6ee7e21857b27def28e8454fc33a..ed01ecde2f87404a42ea2899d5ab0016cd3a9df7 100644
3
+ --- a/android/src/main/java/expo/modules/kotlin/jni/fabric/NativeStatePropsGetter.kt
4
+ +++ b/android/src/main/java/expo/modules/kotlin/jni/fabric/NativeStatePropsGetter.kt
5
+ @@ -1,10 +1,18 @@
6
+ package expo.modules.kotlin.jni.fabric
7
+
8
+ import com.facebook.jni.HybridData
9
+ +import com.facebook.soloader.SoLoader
10
+ import com.facebook.yoga.annotations.DoNotStrip
11
+
12
+ @DoNotStrip
13
+ class NativeStatePropsGetter {
14
+ + companion object {
15
+ + init {
16
+ + // Expo UI can be destroyed before the JavaScript runtime installs JNI bindings.
17
+ + SoLoader.loadLibrary("expo-modules-core")
18
+ + }
19
+ + }
20
+ +
21
+ // We can't use StateWrapper directly, as this class is not exposed
22
+ external fun getStateProps(stateWrapper: Any): Map<String, Any?>?
23
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-disposabl-app",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "Create a Disposabl app",
5
5
  "type": "module",
6
6
  "license": "MIT",