create-disposabl-app 0.13.2 → 0.13.4
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 +1 -1
- package/dist/index.js +189 -90
- package/dist/templates/default/.github/scripts/android-runner.sh +26 -0
- package/dist/templates/default/.github/scripts/mobile.sh +1 -0
- package/dist/templates/default/.github/scripts/platforms.sh +1 -1
- package/dist/templates/default/.github/workflows/pipeline.yml +2 -0
- package/dist/templates/default/apps/mobile/metro.config.js +11 -1
- package/dist/templates/default/bun.lock +1 -0
- package/dist/templates/default/package.json +2 -1
- package/dist/templates/default/packages/disposabl-kit/PAYMENTS.md +5 -3
- package/dist/templates/default/packages/disposabl-kit/client/routes/pricing.tsx +8 -5
- package/dist/templates/default/packages/disposabl-kit/mobile/billing/account-billing.tsx +4 -1
- package/dist/templates/default/packages/disposabl-kit/mobile/screens/account.tsx +14 -4
- package/dist/templates/default/packages/disposabl-kit/payments/autumn.config.example +31 -6
- package/dist/templates/default/packages/disposabl-kit/payments/config.ts +32 -0
- package/dist/templates/default/packages/disposabl-kit/server/billing.ts +16 -11
- package/dist/templates/default/packages/tests/README.md +2 -0
- package/dist/templates/default/packages/tests/android-runner.test.ts +78 -0
- package/dist/templates/default/packages/tests/billing.test.ts +69 -5
- package/dist/templates/default/packages/tests/ci-platform-selection.test.ts +12 -0
- package/dist/templates/default/packages/tests/helpers/mobile.ts +5 -3
- package/dist/templates/default/packages/tests/native-billing.test.ts +6 -3
- package/dist/templates/default/patches/expo-modules-core@58.0.30.patch +23 -0
- package/package.json +1 -1
package/dist/disposabl.js
CHANGED
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
|
|
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.
|
|
11
|
+
var version = "0.13.4";
|
|
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 =
|
|
334
|
-
if (!
|
|
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 (!
|
|
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
|
|
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(
|
|
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 =
|
|
414
|
+
const skills = join2(destination, agent, "skills");
|
|
354
415
|
await mkdir(skills, { recursive: true });
|
|
355
|
-
await cp(skill,
|
|
416
|
+
await cp(skill, join2(skills, "disposabl-app"), { recursive: true });
|
|
356
417
|
}
|
|
357
|
-
const instructions =
|
|
358
|
-
await
|
|
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(
|
|
424
|
+
for (const entry of await readdir(join2(destination, "apps"))) {
|
|
364
425
|
if (!folders.includes("apps/" + entry))
|
|
365
|
-
await
|
|
426
|
+
await rm2(join2(destination, "apps", entry), {
|
|
366
427
|
recursive: true,
|
|
367
428
|
force: true
|
|
368
429
|
});
|
|
369
430
|
}
|
|
370
|
-
const 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
|
|
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
|
|
444
|
+
await rm2(join2(destination, path), { recursive: true, force: true });
|
|
384
445
|
}
|
|
385
|
-
await
|
|
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
|
|
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 =
|
|
398
|
-
const web = JSON.parse(await
|
|
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
|
|
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 =
|
|
408
|
-
const source = await
|
|
409
|
-
await
|
|
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 =
|
|
412
|
-
const turbo = JSON.parse(await
|
|
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
|
|
478
|
+
await writeFile2(turboPath, JSON.stringify(turbo, null, 2) + `
|
|
416
479
|
`);
|
|
417
|
-
await
|
|
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 =
|
|
483
|
+
const folder = join2(destination, "packages", kind);
|
|
421
484
|
if (!folders.includes(`packages/${kind}`)) {
|
|
422
|
-
await
|
|
485
|
+
await rm2(folder, { recursive: true, force: true });
|
|
423
486
|
continue;
|
|
424
487
|
}
|
|
425
|
-
const packagePath =
|
|
426
|
-
const client = JSON.parse(await
|
|
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
|
|
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
|
|
535
|
+
await writeFile2(packagePath, JSON.stringify(client, null, 2) + `
|
|
473
536
|
`);
|
|
474
|
-
const readme =
|
|
475
|
-
if (
|
|
476
|
-
await
|
|
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(
|
|
543
|
+
await rename(join2(destination, path), join2(destination, path.replace(/gitignore$/, ".gitignore")));
|
|
481
544
|
}
|
|
482
545
|
}
|
|
483
|
-
const manifestPath =
|
|
484
|
-
const manifest = JSON.parse(await
|
|
546
|
+
const manifestPath = join2(destination, "package.json");
|
|
547
|
+
const manifest = JSON.parse(await readFile2(manifestPath, "utf8"));
|
|
485
548
|
manifest.name = name;
|
|
486
|
-
await
|
|
549
|
+
await writeFile2(manifestPath, JSON.stringify(manifest, null, 2) + `
|
|
487
550
|
`);
|
|
488
551
|
if (folders.includes("apps/desktop")) {
|
|
489
|
-
const desktopPath =
|
|
490
|
-
const desktop = JSON.parse(await
|
|
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
|
|
560
|
+
await writeFile2(desktopPath, JSON.stringify(desktop, null, 2) + `
|
|
498
561
|
`);
|
|
499
|
-
const lockPath =
|
|
500
|
-
let lock = await
|
|
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
|
|
567
|
+
await writeFile2(lockPath, lock);
|
|
505
568
|
}
|
|
506
569
|
if (folders.includes("apps/mobile")) {
|
|
507
|
-
const appConfigPath =
|
|
508
|
-
const appConfig = JSON.parse(await
|
|
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
|
|
574
|
+
await writeFile2(appConfigPath, JSON.stringify(appConfig, null, 2) + `
|
|
512
575
|
`);
|
|
513
576
|
}
|
|
514
|
-
await
|
|
577
|
+
await writeFile2(join2(destination, "disposabl.json"), JSON.stringify(config, null, 2) + `
|
|
515
578
|
`);
|
|
516
579
|
} catch (error) {
|
|
517
|
-
await
|
|
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
|
|
591
|
+
readFile as readFile3,
|
|
529
592
|
readdir as readdir2,
|
|
530
|
-
rm as
|
|
531
|
-
writeFile as
|
|
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
|
|
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(
|
|
601
|
+
for (const entry of await readdir2(join3(root, path), {
|
|
539
602
|
withFileTypes: true
|
|
540
603
|
})) {
|
|
541
|
-
const relative =
|
|
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 +
|
|
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(
|
|
562
|
-
current =
|
|
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
|
|
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(
|
|
670
|
+
const temp = await mkdtemp(join3(tmpdir(), "disposabl-reconfigure-"));
|
|
608
671
|
try {
|
|
609
|
-
const before =
|
|
610
|
-
const 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
|
-
|
|
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
|
|
624
|
-
const prior = oldFiles.has(path) ? await
|
|
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
|
-
|
|
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
|
-
|
|
645
|
-
|
|
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
|
|
746
|
+
await writeFile3(join3(directory, configPath), JSON.stringify(config, null, 2) + `
|
|
648
747
|
`);
|
|
649
748
|
return config;
|
|
650
749
|
} finally {
|
|
651
|
-
await
|
|
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
|
|
658
|
-
import { basename as
|
|
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
|
|
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
|
|
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 =
|
|
718
|
-
const config = JSON.parse(await
|
|
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
|
|
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 ` +
|
|
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
|
|
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(
|
|
1014
|
+
if (pathExists(join6(directory, "disposabl.json"))) {
|
|
916
1015
|
if (options.appId) {
|
|
917
|
-
const existing = JSON.parse(readFileSync(
|
|
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
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
case "${1:?operation required}" in
|
|
5
|
+
prepare)
|
|
6
|
+
df -h .
|
|
7
|
+
# Only disposable GitHub-hosted Linux runners. Keep Android, Java, Node,
|
|
8
|
+
# the checkout and dependency caches intact; these toolchains are unused.
|
|
9
|
+
if [[ "${GITHUB_ACTIONS:-}" == true && "${RUNNER_ENVIRONMENT:-}" == github-hosted && "${RUNNER_OS:-}" == Linux ]]; then
|
|
10
|
+
unused=(/usr/share/dotnet /usr/local/.ghcup /opt/ghc /opt/hostedtoolcache/CodeQL
|
|
11
|
+
/usr/share/swift /usr/share/miniconda /opt/microsoft/powershell /usr/local/share/powershell)
|
|
12
|
+
du -sh -- "${unused[@]}" 2>/dev/null || true
|
|
13
|
+
sudo rm -rf -- "${unused[@]}"
|
|
14
|
+
fi
|
|
15
|
+
df -h .
|
|
16
|
+
;;
|
|
17
|
+
check)
|
|
18
|
+
df -h .
|
|
19
|
+
available=$(df -Pk . | awk 'END {print $4}')
|
|
20
|
+
if [[ ! "$available" =~ ^[0-9]+$ ]] || (( available < 25 * 1024 * 1024 )); then
|
|
21
|
+
echo '::error::Android native builds require at least 25 GiB free before prebuild. Use a runner with more disk capacity.' >&2
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
;;
|
|
25
|
+
*) echo "Unknown operation: $1" >&2; exit 1 ;;
|
|
26
|
+
esac
|
|
@@ -105,6 +105,7 @@ bun x "$EAS_CLI" update --platform android --channel "$CHANNEL" --environment "$
|
|
|
105
105
|
jq --arg sha "$SHA" '. + {sha256: $sha, action: "update"}' <<< "$MANIFEST" > ../../dist/release/android.json
|
|
106
106
|
;;
|
|
107
107
|
android-build)
|
|
108
|
+
bash ../../.github/scripts/android-runner.sh check
|
|
108
109
|
MANIFEST=$(manifest)
|
|
109
110
|
test "$(gh api "repos/$GH_REPO/$SOURCE_PATH" --jq 'if has("head") then (if .state == "open" then .head.sha else "closed" end) else .object.sha end')" = "$SOURCE"
|
|
110
111
|
if [[ "$CHANNEL" == production ]]; then
|
|
@@ -38,7 +38,7 @@ node --input-type=module -e '
|
|
|
38
38
|
};
|
|
39
39
|
const shared = p => /^(bun.lock$|package.json$|disposabl.json$|turbo.json$|bunfig.toml$|patches\/|vendor\/|\.github\/(workflows\/pipeline.yml$|scripts\/(platforms.sh|disposabl.mjs|release.sh)$))/.test(p);
|
|
40
40
|
const affected = (platform, dependency) => enabled.includes(platform) && changes(platform).some(p => shared(p) || dependency.test(p));
|
|
41
|
-
const mobile = /^(apps\/mobile\/|packages\/disposabl-kit\/|\.github\/scripts\/(mobile|apple)\.sh$)/;
|
|
41
|
+
const mobile = /^(apps\/mobile\/|packages\/disposabl-kit\/|\.github\/scripts\/(mobile|apple|android-runner)\.sh$)/;
|
|
42
42
|
for (const platform of ["android", "ios"]) console.log(`${platform}=${(platform === "ios" ? process.env.IOS_BUILDS_ENABLED !== "false" : process.env.EXPO_CONNECTED === "true") && affected(platform, mobile)}`);
|
|
43
43
|
const production = process.env.GITHUB_EVENT_NAME === "push" && process.env.GITHUB_REF === "refs/heads/main";
|
|
44
44
|
const desktop = (production ? ["linux", "windows", "macos"] : []).filter(platform => affected(platform, /^apps\/desktop\//))
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
const { getDefaultConfig } = require("expo/metro-config");
|
|
2
2
|
const { withNativewind } = require("nativewind/metro");
|
|
3
3
|
|
|
4
|
-
|
|
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"
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Payments is optional and includes authentication. Select `payments` in `disposabl.json`; the server checks this selection before reading credentials or calling Autumn. With it off, the pricing page blocks purchases and no billing credentials are needed. The authenticated Convex Auth user ID is the Autumn customer ID. Never use a client-supplied customer ID or price.
|
|
4
4
|
|
|
5
|
-
Set the Autumn environment default currency to USD and verify both prices in the provider preview. For a separate Autumn test environment, configure `AUTUMN_SECRET_KEY` and `BILLING_RETURN_URL` on that app's Convex deployment. The latter must be the absolute HTTPS URL of its `/pricing` page (HTTP localhost is allowed for development), without query or fragment. Do not store the secret in the frontend or `disposabl.json`. Set the corresponding live values separately only when ready to launch.
|
|
5
|
+
Set the Autumn environment default currency to match `payments/config.ts` (USD by default) and verify both prices in the provider preview. For a separate Autumn test environment, configure `AUTUMN_SECRET_KEY` and `BILLING_RETURN_URL` on that app's Convex deployment. The latter must be the absolute HTTPS URL of its `/pricing` page (HTTP localhost is allowed for development), without query or fragment. Do not store the secret in the frontend or `disposabl.json`. Set the corresponding live values separately only when ready to launch.
|
|
6
6
|
|
|
7
|
-
`payments/autumn.config.example` defines the `credits` consumable feature, $5 monthly plan with 500 credits per cycle, and $5 one-off prepaid top-up for 500 credits.
|
|
7
|
+
`payments/autumn.config.example` defines the `credits` consumable feature, $5 monthly plan with 500 credits per cycle, and $5 one-off prepaid top-up for 500 credits. The editable defaults live in `payments/config.ts`; checkout quantities, the web pricing page, mobile allowance text, and the Autumn example use this same configuration. Copy both files into a separate configuration project with `atmn@2.0.218` installed, naming the example `autumn.config.ts` and keeping `config.ts` alongside it. After editing prices or credits, apply the matching Autumn and store configuration before deploying the app. Changing the local file alone does not update provider prices. Preview with `atmn push` before applying to a dedicated Autumn environment. Its lists are complete: a push can delete unlisted plans and features. Review the diff and test repeated top-ups, renewals and cancellation in sandbox before taking payment. The one-off prepaid credits are documented to last forever; subscription credits reset each cycle. Autumn's docs do not establish that subscription credits survive cancellation. Do not promise that they do. The provider balance is authoritative; a redirect alone does not grant credits. This foundation does not implement usage charging.
|
|
8
8
|
|
|
9
|
-
The app calls Autumn API 2.6.0 `customers.get_or_create`, `billing.attach`, and `billing.open_customer_portal` server-side. Checkout uses
|
|
9
|
+
The app calls Autumn API 2.6.0 `customers.get_or_create`, `billing.attach`, and `billing.open_customer_portal` server-side. Checkout uses server-owned plan IDs and the top-up quantity from `payments/config.ts`. Return to pricing may precede provider synchronization; use Refresh to read Autumn again. Setup and test Stripe checkout and portal in Autumn before enabling live use.
|
|
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.
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { useAuthToken } from "@convex-dev/auth/react";
|
|
12
12
|
import { sessionId } from "../../lib/auth-session";
|
|
13
13
|
import { paymentsEnabled } from "../../features";
|
|
14
|
+
import { pricing, creditQuantity, formatPrice } from "../../payments/config";
|
|
14
15
|
|
|
15
16
|
export const Route = createFileRoute("/_providers/pricing")({
|
|
16
17
|
component: Pricing,
|
|
@@ -154,7 +155,9 @@ function PurchasePage({ session }: { session: string | null }) {
|
|
|
154
155
|
<main className="mx-auto max-w-5xl space-y-8 p-8">
|
|
155
156
|
<div>
|
|
156
157
|
<h1 className="text-3xl font-semibold">Pricing</h1>
|
|
157
|
-
<p>
|
|
158
|
+
<p>
|
|
159
|
+
{pricing.creditsPerDollar} credits per {formatPrice(1)}.
|
|
160
|
+
</p>
|
|
158
161
|
</div>
|
|
159
162
|
{isLoading ? (
|
|
160
163
|
<p>Checking your account...</p>
|
|
@@ -190,8 +193,8 @@ function PurchasePage({ session }: { session: string | null }) {
|
|
|
190
193
|
<div className="grid gap-5 md:grid-cols-2">
|
|
191
194
|
<section className="rounded-lg border p-6">
|
|
192
195
|
<h2 className="text-xl font-semibold">Monthly</h2>
|
|
193
|
-
<p
|
|
194
|
-
<p>
|
|
196
|
+
<p>{formatPrice(pricing.monthly.price)} / month</p>
|
|
197
|
+
<p>{creditQuantity("monthly")} credits each billing cycle.</p>
|
|
195
198
|
<button
|
|
196
199
|
className="mt-4 rounded bg-black px-4 py-2 text-white disabled:opacity-50"
|
|
197
200
|
disabled={!session || busy || hasMonthlyPlan !== false}
|
|
@@ -204,8 +207,8 @@ function PurchasePage({ session }: { session: string | null }) {
|
|
|
204
207
|
</section>
|
|
205
208
|
<section className="rounded-lg border p-6">
|
|
206
209
|
<h2 className="text-xl font-semibold">Top-up</h2>
|
|
207
|
-
<p
|
|
208
|
-
<p>
|
|
210
|
+
<p>{formatPrice(pricing.topup.price)} once</p>
|
|
211
|
+
<p>{creditQuantity("topup")} credits that do not expire.</p>
|
|
209
212
|
<button
|
|
210
213
|
className="mt-4 rounded bg-black px-4 py-2 text-white disabled:opacity-50"
|
|
211
214
|
disabled={!session || busy}
|
|
@@ -5,6 +5,7 @@ import { AppState, Linking, Platform, Text, View } from "react-native";
|
|
|
5
5
|
import type { PurchasesPackage } from "react-native-purchases";
|
|
6
6
|
import { AuthButton, styles } from "../components/auth-ui";
|
|
7
7
|
import { billingSession } from "./session";
|
|
8
|
+
import { creditQuantity } from "../../payments/config";
|
|
8
9
|
|
|
9
10
|
type Snapshot = {
|
|
10
11
|
balance: number | null;
|
|
@@ -148,7 +149,9 @@ export function AccountBilling({ customerId }: { customerId: string }) {
|
|
|
148
149
|
<Text style={styles.body}>
|
|
149
150
|
Available: {data?.balance ?? "unavailable"}
|
|
150
151
|
</Text>
|
|
151
|
-
<Text style={styles.body}>
|
|
152
|
+
<Text style={styles.body}>
|
|
153
|
+
{creditQuantity("monthly")} credits each monthly billing cycle.
|
|
154
|
+
</Text>
|
|
152
155
|
{data?.hasMonthlyPlan && (
|
|
153
156
|
<Text style={styles.body}>
|
|
154
157
|
Your monthly plan is active or scheduled.
|
|
@@ -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
|
|
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
|
-
{
|
|
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
|
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
import { atmn, feature, plan } from "atmn";
|
|
2
|
+
import { pricing, creditQuantity } from "./config";
|
|
2
3
|
|
|
3
|
-
export const credits = feature({
|
|
4
|
+
export const credits = feature({
|
|
5
|
+
featureId: pricing.featureId,
|
|
6
|
+
name: "Credits",
|
|
7
|
+
type: "metered",
|
|
8
|
+
consumable: true,
|
|
9
|
+
});
|
|
4
10
|
export const monthly = plan({
|
|
5
|
-
planId:
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
planId: pricing.monthly.planId,
|
|
12
|
+
versionSlug: "v1",
|
|
13
|
+
active: true,
|
|
14
|
+
name: "Monthly credits",
|
|
15
|
+
price: { amount: pricing.monthly.price, interval: "month" },
|
|
16
|
+
items: [{
|
|
17
|
+
featureId: credits.featureId,
|
|
18
|
+
included: creditQuantity("monthly"),
|
|
19
|
+
reset: { interval: "month" },
|
|
20
|
+
}],
|
|
8
21
|
});
|
|
9
22
|
export const topup = plan({
|
|
10
|
-
planId:
|
|
11
|
-
|
|
23
|
+
planId: pricing.topup.planId,
|
|
24
|
+
versionSlug: "v1",
|
|
25
|
+
active: true,
|
|
26
|
+
name: "Credits top-up",
|
|
27
|
+
addOn: true,
|
|
28
|
+
items: [{
|
|
29
|
+
featureId: credits.featureId,
|
|
30
|
+
price: {
|
|
31
|
+
amount: pricing.topup.price,
|
|
32
|
+
billingUnits: creditQuantity("topup"),
|
|
33
|
+
interval: "one_off",
|
|
34
|
+
billingMethod: "prepaid",
|
|
35
|
+
},
|
|
36
|
+
}],
|
|
12
37
|
});
|
|
13
38
|
export default atmn({ features: [credits], plans: [monthly, topup] });
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type Pricing = {
|
|
2
|
+
currency: string;
|
|
3
|
+
creditsPerDollar: number;
|
|
4
|
+
featureId: string;
|
|
5
|
+
monthly: { planId: string; price: number };
|
|
6
|
+
topup: { planId: string; price: number };
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/** Editable starter example. Apply matching changes to Autumn before accepting purchases. */
|
|
10
|
+
export const pricing: Pricing = {
|
|
11
|
+
currency: "USD",
|
|
12
|
+
creditsPerDollar: 100,
|
|
13
|
+
featureId: "credits",
|
|
14
|
+
monthly: { planId: "credits_monthly", price: 5 },
|
|
15
|
+
topup: { planId: "credits_topup", price: 5 },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type Purchase = "monthly" | "topup";
|
|
19
|
+
|
|
20
|
+
export function creditQuantity(purchase: Purchase, config: Pricing = pricing) {
|
|
21
|
+
// Credits are whole units; decimal prices must not leak floating-point noise.
|
|
22
|
+
return Math.round(config[purchase].price * config.creditsPerDollar);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function formatPrice(amount: number, config: Pricing = pricing) {
|
|
26
|
+
return new Intl.NumberFormat("en-US", {
|
|
27
|
+
style: "currency",
|
|
28
|
+
currency: config.currency,
|
|
29
|
+
minimumFractionDigits: 0,
|
|
30
|
+
maximumFractionDigits: 2,
|
|
31
|
+
}).format(amount);
|
|
32
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} as const;
|
|
5
|
-
export type Purchase = keyof typeof billingPlans;
|
|
1
|
+
import { pricing, creditQuantity, type Pricing } from "../payments/config";
|
|
2
|
+
|
|
3
|
+
export type { Purchase } from "../payments/config";
|
|
6
4
|
|
|
7
5
|
export function billingConfig(
|
|
8
6
|
enabled: boolean,
|
|
@@ -57,18 +55,23 @@ export async function billingRequest(
|
|
|
57
55
|
|
|
58
56
|
export function purchaseRequest(
|
|
59
57
|
customerId: string,
|
|
60
|
-
purchase:
|
|
58
|
+
purchase: string,
|
|
61
59
|
returnUrl: string,
|
|
60
|
+
config: Pricing = pricing,
|
|
62
61
|
) {
|
|
63
|
-
if (
|
|
62
|
+
if (purchase !== "monthly" && purchase !== "topup")
|
|
64
63
|
throw new Error("Invalid purchase.");
|
|
65
64
|
return {
|
|
66
65
|
customer_id: customerId,
|
|
67
|
-
plan_id:
|
|
66
|
+
plan_id: config[purchase].planId,
|
|
68
67
|
...(purchase === "topup"
|
|
69
68
|
? {
|
|
70
69
|
feature_quantities: [
|
|
71
|
-
{
|
|
70
|
+
{
|
|
71
|
+
feature_id: config.featureId,
|
|
72
|
+
quantity: creditQuantity(purchase, config),
|
|
73
|
+
adjustable: false,
|
|
74
|
+
},
|
|
72
75
|
],
|
|
73
76
|
}
|
|
74
77
|
: {}),
|
|
@@ -79,10 +82,11 @@ export function purchaseRequest(
|
|
|
79
82
|
|
|
80
83
|
export function balanceFromCustomer(
|
|
81
84
|
customer: Record<string, unknown>,
|
|
85
|
+
config: Pricing = pricing,
|
|
82
86
|
): number | null {
|
|
83
87
|
const balances = customer.balances as
|
|
84
88
|
Record<string, { remaining?: unknown }> | undefined;
|
|
85
|
-
const remaining = balances?.
|
|
89
|
+
const remaining = balances?.[config.featureId]?.remaining;
|
|
86
90
|
return typeof remaining === "number" && Number.isFinite(remaining)
|
|
87
91
|
? remaining
|
|
88
92
|
: null;
|
|
@@ -91,6 +95,7 @@ export function balanceFromCustomer(
|
|
|
91
95
|
/** Missing or unfamiliar provider data must not authorize another subscription. */
|
|
92
96
|
export function monthlyPlanFromCustomer(
|
|
93
97
|
customer: Record<string, unknown>,
|
|
98
|
+
config: Pricing = pricing,
|
|
94
99
|
): boolean | null {
|
|
95
100
|
if (!Array.isArray(customer.subscriptions)) return null;
|
|
96
101
|
let present = false;
|
|
@@ -101,7 +106,7 @@ export function monthlyPlanFromCustomer(
|
|
|
101
106
|
!["active", "scheduled"].includes(subscription.status)
|
|
102
107
|
)
|
|
103
108
|
return null;
|
|
104
|
-
if (subscription.plan_id ===
|
|
109
|
+
if (subscription.plan_id === config.monthly.planId) present = true;
|
|
105
110
|
}
|
|
106
111
|
return present;
|
|
107
112
|
}
|
|
@@ -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.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { mkdtempSync, writeFileSync, readFileSync, rmSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join, resolve } from "node:path";
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
|
|
8
|
+
test("Android disk preparation only removes unused hosted-runner toolchains", () => {
|
|
9
|
+
const dir = mkdtempSync(join(tmpdir(), "android-runner-"));
|
|
10
|
+
try {
|
|
11
|
+
writeFileSync(
|
|
12
|
+
join(dir, "sudo"),
|
|
13
|
+
'#!/bin/sh\nprintf "%s\\n" "$*" >> "$CALLS"\n',
|
|
14
|
+
{ mode: 0o755 },
|
|
15
|
+
);
|
|
16
|
+
writeFileSync(join(dir, "du"), "#!/bin/sh\nexit 0\n", { mode: 0o755 });
|
|
17
|
+
writeFileSync(
|
|
18
|
+
join(dir, "df"),
|
|
19
|
+
'#!/bin/sh\nprintf "Filesystem 1024-blocks Used Available Capacity Mounted\\n/dev/test 99999999 1 %s 1%% /\\n" "$AVAILABLE"\n',
|
|
20
|
+
{ mode: 0o755 },
|
|
21
|
+
);
|
|
22
|
+
const calls = join(dir, "calls");
|
|
23
|
+
writeFileSync(calls, "");
|
|
24
|
+
const run = (operation: string, overrides: Record<string, string> = {}) =>
|
|
25
|
+
spawnSync(
|
|
26
|
+
"bash",
|
|
27
|
+
[
|
|
28
|
+
resolve(
|
|
29
|
+
import.meta.dirname,
|
|
30
|
+
"../../.github/scripts/android-runner.sh",
|
|
31
|
+
),
|
|
32
|
+
operation,
|
|
33
|
+
],
|
|
34
|
+
{
|
|
35
|
+
encoding: "utf8",
|
|
36
|
+
env: {
|
|
37
|
+
...process.env,
|
|
38
|
+
PATH: `${dir}:${process.env.PATH}`,
|
|
39
|
+
CALLS: calls,
|
|
40
|
+
AVAILABLE: "31457280",
|
|
41
|
+
GITHUB_ACTIONS: "true",
|
|
42
|
+
RUNNER_ENVIRONMENT: "github-hosted",
|
|
43
|
+
RUNNER_OS: "Linux",
|
|
44
|
+
...overrides,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
const otherRunners: Record<string, string>[] = [
|
|
49
|
+
{ RUNNER_ENVIRONMENT: "self-hosted" },
|
|
50
|
+
{ GITHUB_ACTIONS: "false" },
|
|
51
|
+
{ RUNNER_OS: "macOS" },
|
|
52
|
+
{ RUNNER_ENVIRONMENT: "" },
|
|
53
|
+
{ GITHUB_ACTIONS: "" },
|
|
54
|
+
{ RUNNER_OS: "" },
|
|
55
|
+
];
|
|
56
|
+
for (const overrides of otherRunners) {
|
|
57
|
+
assert.equal(run("prepare", overrides).status, 0);
|
|
58
|
+
assert.equal(readFileSync(calls, "utf8"), "");
|
|
59
|
+
}
|
|
60
|
+
assert.equal(run("prepare").status, 0);
|
|
61
|
+
assert.equal(
|
|
62
|
+
readFileSync(calls, "utf8"),
|
|
63
|
+
"rm -rf -- /usr/share/dotnet /usr/local/.ghcup /opt/ghc /opt/hostedtoolcache/CodeQL /usr/share/swift /usr/share/miniconda /opt/microsoft/powershell /usr/local/share/powershell\n",
|
|
64
|
+
);
|
|
65
|
+
assert.equal(run("check").status, 0);
|
|
66
|
+
assert.equal(run("check", { AVAILABLE: "26214400" }).status, 0);
|
|
67
|
+
assert.equal(run("check", { AVAILABLE: "26214399" }).status, 1);
|
|
68
|
+
const low = run("check", { AVAILABLE: "1024" });
|
|
69
|
+
assert.equal(low.status, 1);
|
|
70
|
+
assert.match(low.stderr, /25 GiB free/);
|
|
71
|
+
assert.equal(run("check", { AVAILABLE: "invalid" }).status, 1);
|
|
72
|
+
assert.equal(run("unsupported").status, 1);
|
|
73
|
+
writeFileSync(join(dir, "sudo"), "#!/bin/sh\nexit 42\n", { mode: 0o755 });
|
|
74
|
+
assert.equal(run("prepare").status, 42);
|
|
75
|
+
} finally {
|
|
76
|
+
rmSync(dir, { recursive: true, force: true });
|
|
77
|
+
}
|
|
78
|
+
});
|
|
@@ -4,13 +4,71 @@ import {
|
|
|
4
4
|
balanceFromCustomer,
|
|
5
5
|
billingConfig,
|
|
6
6
|
billingContext,
|
|
7
|
-
billingPlans,
|
|
8
7
|
billingRequest,
|
|
9
8
|
purchaseRequest,
|
|
9
|
+
monthlyPlanFromCustomer,
|
|
10
10
|
} from "../disposabl-kit/server/billing";
|
|
11
|
+
import {
|
|
12
|
+
pricing,
|
|
13
|
+
creditQuantity,
|
|
14
|
+
formatPrice,
|
|
15
|
+
type Pricing,
|
|
16
|
+
} from "../disposabl-kit/payments/config";
|
|
11
17
|
import { resolveFeatures } from "../disposabl-kit/feature-options";
|
|
12
18
|
|
|
13
19
|
describe("billing boundary", () => {
|
|
20
|
+
test("editable starter prices drive server quantities and displayed allowances", () => {
|
|
21
|
+
const example: Pricing = {
|
|
22
|
+
currency: "USD",
|
|
23
|
+
creditsPerDollar: 100,
|
|
24
|
+
featureId: "credits",
|
|
25
|
+
monthly: { planId: "credits_monthly", price: 5 },
|
|
26
|
+
topup: { planId: "credits_topup", price: 5 },
|
|
27
|
+
};
|
|
28
|
+
assert.equal(formatPrice(example.monthly.price, example), "$5");
|
|
29
|
+
assert.equal(creditQuantity("monthly", example), 500);
|
|
30
|
+
assert.equal(creditQuantity("topup", example), 500);
|
|
31
|
+
assert.equal(
|
|
32
|
+
creditQuantity("topup", {
|
|
33
|
+
...example,
|
|
34
|
+
topup: { ...example.topup, price: 1.1 },
|
|
35
|
+
}),
|
|
36
|
+
110,
|
|
37
|
+
);
|
|
38
|
+
const custom: Pricing = {
|
|
39
|
+
...example,
|
|
40
|
+
featureId: "workspace_credits",
|
|
41
|
+
creditsPerDollar: 80,
|
|
42
|
+
monthly: { planId: "workspace_monthly", price: 12 },
|
|
43
|
+
topup: { planId: "workspace_topup", price: 3 },
|
|
44
|
+
};
|
|
45
|
+
const request = purchaseRequest(
|
|
46
|
+
"owner",
|
|
47
|
+
"topup",
|
|
48
|
+
"https://example.com/pricing",
|
|
49
|
+
custom,
|
|
50
|
+
);
|
|
51
|
+
assert.equal(request.plan_id, "workspace_topup");
|
|
52
|
+
assert.deepEqual(request.feature_quantities, [
|
|
53
|
+
{ feature_id: "workspace_credits", quantity: 240, adjustable: false },
|
|
54
|
+
]);
|
|
55
|
+
assert.equal(creditQuantity("monthly", custom), 960);
|
|
56
|
+
assert.equal(formatPrice(custom.monthly.price, custom), "$12");
|
|
57
|
+
assert.equal(
|
|
58
|
+
balanceFromCustomer(
|
|
59
|
+
{ balances: { workspace_credits: { remaining: 37 } } },
|
|
60
|
+
custom,
|
|
61
|
+
),
|
|
62
|
+
37,
|
|
63
|
+
);
|
|
64
|
+
assert.equal(
|
|
65
|
+
monthlyPlanFromCustomer(
|
|
66
|
+
{ subscriptions: [{ plan_id: "workspace_monthly", status: "active" }] },
|
|
67
|
+
custom,
|
|
68
|
+
),
|
|
69
|
+
true,
|
|
70
|
+
);
|
|
71
|
+
});
|
|
14
72
|
test("payments requires authentication and disabled ignores credentials", () => {
|
|
15
73
|
assert.deepEqual(resolveFeatures(["payments"]), [
|
|
16
74
|
"authentication",
|
|
@@ -45,15 +103,19 @@ describe("billing boundary", () => {
|
|
|
45
103
|
"https://app.example/pricing",
|
|
46
104
|
);
|
|
47
105
|
assert.equal(monthly.customer_id, "user");
|
|
48
|
-
assert.equal(monthly.plan_id,
|
|
106
|
+
assert.equal(monthly.plan_id, pricing.monthly.planId);
|
|
49
107
|
const topup = purchaseRequest(
|
|
50
108
|
"user",
|
|
51
109
|
"topup",
|
|
52
110
|
"https://app.example/pricing",
|
|
53
111
|
);
|
|
54
|
-
assert.equal(topup.plan_id,
|
|
112
|
+
assert.equal(topup.plan_id, pricing.topup.planId);
|
|
55
113
|
assert.deepEqual(topup.feature_quantities, [
|
|
56
|
-
{
|
|
114
|
+
{
|
|
115
|
+
feature_id: pricing.featureId,
|
|
116
|
+
quantity: creditQuantity("topup"),
|
|
117
|
+
adjustable: false,
|
|
118
|
+
},
|
|
57
119
|
]);
|
|
58
120
|
assert.throws(() =>
|
|
59
121
|
purchaseRequest("user", "other" as never, "https://app.example/pricing"),
|
|
@@ -61,7 +123,9 @@ describe("billing boundary", () => {
|
|
|
61
123
|
});
|
|
62
124
|
test("reads provider balances and hides provider errors", async () => {
|
|
63
125
|
assert.equal(
|
|
64
|
-
balanceFromCustomer({
|
|
126
|
+
balanceFromCustomer({
|
|
127
|
+
balances: { [pricing.featureId]: { remaining: 750 } },
|
|
128
|
+
}),
|
|
65
129
|
750,
|
|
66
130
|
);
|
|
67
131
|
assert.equal(balanceFromCustomer({}), null);
|
|
@@ -47,6 +47,18 @@ test("iOS builds can be paused independently of Android", () => {
|
|
|
47
47
|
{ cwd: dir, env: { ...env, IOS_BUILDS_ENABLED: "true" } },
|
|
48
48
|
);
|
|
49
49
|
assert.match(readFileSync(out, "utf8"), /^ios=true$/m);
|
|
50
|
+
writeFileSync(
|
|
51
|
+
join(dir, "bin/gh"),
|
|
52
|
+
'#!/bin/sh\ncase "$*" in *pulls/1/files*) echo .github/scripts/android-runner.sh;; *) exit 1;; esac\n',
|
|
53
|
+
{ mode: 0o755 },
|
|
54
|
+
);
|
|
55
|
+
writeFileSync(out, "");
|
|
56
|
+
execFileSync(
|
|
57
|
+
"bash",
|
|
58
|
+
[resolve(import.meta.dirname, "../../.github/scripts/platforms.sh")],
|
|
59
|
+
{ cwd: dir, env },
|
|
60
|
+
);
|
|
61
|
+
assert.match(readFileSync(out, "utf8"), /^android=true$/m);
|
|
50
62
|
} finally {
|
|
51
63
|
rmSync(dir, { recursive: true, force: true });
|
|
52
64
|
}
|
|
@@ -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 });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { test } from "node:test";
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
3
|
import { BillingSession } from "../disposabl-kit/mobile/billing/session";
|
|
4
|
+
import { pricing } from "../disposabl-kit/payments/config";
|
|
4
5
|
import { monthlyPlanFromCustomer } from "../disposabl-kit/server/billing";
|
|
5
6
|
|
|
6
7
|
function deferred() {
|
|
@@ -18,18 +19,20 @@ test("monthly state includes scheduled plans and fails closed for unknown respon
|
|
|
18
19
|
for (const status of ["active", "scheduled"])
|
|
19
20
|
assert.equal(
|
|
20
21
|
monthlyPlanFromCustomer({
|
|
21
|
-
subscriptions: [{ plan_id:
|
|
22
|
+
subscriptions: [{ plan_id: pricing.monthly.planId, status }],
|
|
22
23
|
}),
|
|
23
24
|
true,
|
|
24
25
|
);
|
|
25
26
|
assert.equal(monthlyPlanFromCustomer({}), null);
|
|
26
27
|
assert.equal(
|
|
27
|
-
monthlyPlanFromCustomer({
|
|
28
|
+
monthlyPlanFromCustomer({
|
|
29
|
+
subscriptions: [{ planId: pricing.monthly.planId }],
|
|
30
|
+
}),
|
|
28
31
|
null,
|
|
29
32
|
);
|
|
30
33
|
assert.equal(
|
|
31
34
|
monthlyPlanFromCustomer({
|
|
32
|
-
subscriptions: [{ plan_id:
|
|
35
|
+
subscriptions: [{ plan_id: pricing.monthly.planId, status: "unknown" }],
|
|
33
36
|
}),
|
|
34
37
|
null,
|
|
35
38
|
);
|
|
@@ -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
|
+
|