create-disposabl-app 0.11.0 → 0.13.0

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.
Files changed (42) hide show
  1. package/dist/disposabl.js +14 -10
  2. package/dist/index.js +40 -2
  3. package/dist/templates/default/.github/scripts/disposabl.mjs +15 -1
  4. package/dist/templates/default/.github/scripts/platforms.sh +1 -1
  5. package/dist/templates/default/.github/scripts/release.sh +1 -1
  6. package/dist/templates/default/.github/workflows/pipeline.yml +30 -2
  7. package/dist/templates/default/apps/desktop/README.md +16 -4
  8. package/dist/templates/default/apps/desktop/build-ci.mjs +7 -0
  9. package/dist/templates/default/apps/desktop/forge.config.mts +8 -4
  10. package/dist/templates/default/apps/desktop/package.json +3 -2
  11. package/dist/templates/default/apps/desktop/publish-update.mjs +93 -0
  12. package/dist/templates/default/apps/desktop/src/declarations.d.ts +4 -0
  13. package/dist/templates/default/apps/desktop/src/main.ts +86 -1
  14. package/dist/templates/default/apps/desktop/src/updates.ts +123 -0
  15. package/dist/templates/default/apps/desktop/stage-update.mjs +70 -0
  16. package/dist/templates/default/apps/desktop/vite.main.config.mts +10 -0
  17. package/dist/templates/default/apps/web/src/routeTree.gen.ts +31 -0
  18. package/dist/templates/default/apps/web/src/router/mobile-login.tsx +84 -0
  19. package/dist/templates/default/bun.lock +7 -2
  20. package/dist/templates/default/package.json +1 -1
  21. package/dist/templates/default/packages/backend/convex/authSetup.ts +9 -1
  22. package/dist/templates/default/packages/backend/convex/desktopUpdates/validator.ts +62 -0
  23. package/dist/templates/default/packages/backend/convex/desktopUpdates.ts +216 -0
  24. package/dist/templates/default/packages/backend/convex/http.ts +6 -0
  25. package/dist/templates/default/packages/backend/convex/schema.ts +2 -0
  26. package/dist/templates/default/packages/cli/auth.ts +1 -20
  27. package/dist/templates/default/packages/cli/origin.ts +22 -0
  28. package/dist/templates/default/packages/disposabl-kit/lib/indexing.ts +1 -0
  29. package/dist/templates/default/packages/disposabl-kit/server/files-functions.ts +1 -1
  30. package/dist/templates/default/packages/disposabl-kit/server/lib/static.ts +7 -0
  31. package/dist/templates/default/packages/disposabl-kit/server/lib/telemetry.ts +62 -12
  32. package/dist/templates/default/packages/tests/README.md +2 -0
  33. package/dist/templates/default/packages/tests/ci-platform-selection.test.ts +53 -0
  34. package/dist/templates/default/packages/tests/desktop-publication.test.ts +251 -0
  35. package/dist/templates/default/packages/tests/desktop-updates.test.ts +200 -0
  36. package/dist/templates/default/packages/tests/flows/desktop-updates.e2e.ts +102 -0
  37. package/dist/templates/default/packages/tests/flows/files.e2e.ts +48 -0
  38. package/dist/templates/default/packages/tests/telemetry.test.ts +170 -0
  39. package/dist/templates/default/vendor/README.md +7 -4
  40. package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.3.tgz +0 -0
  41. package/package.json +1 -1
  42. package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.1.tgz +0 -0
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.11.0",
8
+ version: "0.13.0",
9
9
  type: "module",
10
10
  description: "Command-line access to your Disposabl app",
11
11
  license: "MIT",
@@ -36,6 +36,19 @@ import {
36
36
  import { homedir } from "node:os";
37
37
  import { join } from "node:path";
38
38
  import { spawn } from "node:child_process";
39
+
40
+ // ../cli/origin.ts
41
+ var SERVICE_ORIGIN = "https://www.disposabl.dev";
42
+ function apiUrl(value) {
43
+ const url = new URL(value);
44
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && ["127.0.0.1", "localhost", "[::1]"].includes(url.hostname)))
45
+ throw new Error("Use HTTPS, or HTTP on loopback for local development.");
46
+ if (url.username || url.password || url.search || url.hash || url.pathname !== "/")
47
+ throw new Error("Use the API origin without a path or credentials.");
48
+ return url.origin;
49
+ }
50
+
51
+ // ../cli/auth.ts
39
52
  function openUrl(url) {
40
53
  const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "rundll32" : "xdg-open";
41
54
  const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
@@ -48,14 +61,6 @@ class NotAuthenticated extends Error {
48
61
  }
49
62
  var directory = () => process.env.DISPOSABL_CONFIG_DIR || join(homedir(), ".config", "disposabl");
50
63
  var sessionPath = (url) => join(directory(), `${createHash("sha256").update(url).digest("hex")}.json`);
51
- function apiUrl(value) {
52
- const url = new URL(value);
53
- if (url.protocol !== "https:" && !(url.protocol === "http:" && ["127.0.0.1", "localhost", "[::1]"].includes(url.hostname)))
54
- throw new Error("Use HTTPS, or HTTP on loopback for local development.");
55
- if (url.username || url.password || url.search || url.hash || url.pathname !== "/")
56
- throw new Error("Use the API origin without a path or credentials.");
57
- return url.origin;
58
- }
59
64
  var fetchFor = (origin) => Object.assign(async (input, init) => {
60
65
  const url = new URL(input instanceof Request ? input.url : input);
61
66
  if (url.origin !== origin)
@@ -568,7 +573,6 @@ function formatPreview(preview) {
568
573
  }
569
574
 
570
575
  // ../cli/commands.ts
571
- var SERVICE_ORIGIN = "https://www.disposabl.dev";
572
576
  async function runCli(argv = process.argv, serviceOrigin = process.env.DISPOSABL_API_ORIGIN || SERVICE_ORIGIN) {
573
577
  const program = createProgram(serviceOrigin);
574
578
  const origin = () => apiUrl(serviceOrigin);
package/dist/index.js CHANGED
@@ -8,7 +8,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.11.0";
11
+ var version = "0.13.0";
12
12
 
13
13
  // ../disposabl-kit/platforms.ts
14
14
  var platforms = [
@@ -321,9 +321,11 @@ import {
321
321
  } from "node:fs/promises";
322
322
  import { existsSync } from "node:fs";
323
323
  import { basename, join } from "node:path";
324
+ import { randomUUID } from "node:crypto";
324
325
  async function createApp(template, destination, name, config, overwrite = false) {
325
326
  config = {
326
327
  ...config,
328
+ desktopId: config.desktopId ?? randomUUID().replaceAll("-", ""),
327
329
  platforms: selectPlatforms(config.platforms.join(",")),
328
330
  features: selectFeatures(config.features.join(",") || "none")
329
331
  };
@@ -480,10 +482,20 @@ main().catch((error) => {
480
482
  if (folders.includes("apps/desktop")) {
481
483
  const desktopPath = join(destination, "apps/desktop/package.json");
482
484
  const desktop = JSON.parse(await readFile(desktopPath, "utf8"));
485
+ if (!/^[a-f0-9]{32}$/.test(config.desktopId))
486
+ throw new Error("Invalid desktop identity.");
487
+ desktop.name = `disposabl-desktop-${config.desktopId}`;
488
+ desktop.disposablDesktopId = config.desktopId;
483
489
  desktop.productName = name;
484
490
  desktop.description = `${name} desktop app`;
485
491
  await writeFile(desktopPath, JSON.stringify(desktop, null, 2) + `
486
492
  `);
493
+ const lockPath = join(destination, "bun.lock");
494
+ let lock = await readFile(lockPath, "utf8");
495
+ lock = lock.replace(`"apps/desktop": {
496
+ "name": "desktop"`, `"apps/desktop": {
497
+ "name": "${desktop.name}"`).replace('"desktop": ["desktop@workspace:apps/desktop"]', `"${desktop.name}": ["${desktop.name}@workspace:apps/desktop"]`);
498
+ await writeFile(lockPath, lock);
487
499
  }
488
500
  if (folders.includes("apps/mobile")) {
489
501
  const appConfigPath = join(destination, "apps/mobile/app.json");
@@ -513,6 +525,7 @@ import {
513
525
  writeFile as writeFile2
514
526
  } from "node:fs/promises";
515
527
  import { tmpdir } from "node:os";
528
+ import { randomUUID as randomUUID2 } from "node:crypto";
516
529
  import { dirname, join as join2, resolve, sep } from "node:path";
517
530
  async function files(root, path = "") {
518
531
  const result = [];
@@ -564,9 +577,12 @@ async function reconfigureApp(template, directory, version, options) {
564
577
  if (!Array.isArray(existing.platforms) || !Array.isArray(existing.features))
565
578
  throw new Error("Invalid selections in disposabl.json.");
566
579
  const oldPlatforms = selectPlatforms(existing.platforms.join(","));
580
+ if (!existing.desktopId && oldPlatforms.some((p) => ["macos", "windows", "linux"].includes(p)))
581
+ throw new Error("This desktop project has no native identity. Create a fresh starter before its first installation.");
567
582
  const oldFeatures = selectFeatures(existing.features.join(",") || "none");
568
583
  const config = {
569
584
  ...existing,
585
+ desktopId: existing.desktopId ?? randomUUID2().replaceAll("-", ""),
570
586
  platforms: options.platforms === undefined ? oldPlatforms : selectPlatforms(options.platforms),
571
587
  features: options.features === undefined ? oldFeatures : selectFeatures(options.features)
572
588
  };
@@ -588,6 +604,7 @@ async function reconfigureApp(template, directory, version, options) {
588
604
  const after = join2(temp, "after");
589
605
  await createApp(template, before, name, {
590
606
  ...existing,
607
+ desktopId: config.desktopId,
591
608
  platforms: oldPlatforms,
592
609
  features: oldFeatures
593
610
  });
@@ -651,9 +668,24 @@ function detectReference(directory = process.cwd()) {
651
668
  throw new Error("Cannot detect a branch or worktree. Run inside the app's Git checkout or supply --reference.");
652
669
  }
653
670
 
671
+ // ../cli/origin.ts
672
+ var SERVICE_ORIGIN = "https://www.disposabl.dev";
673
+ function apiUrl(value) {
674
+ const url = new URL(value);
675
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && ["127.0.0.1", "localhost", "[::1]"].includes(url.hostname)))
676
+ throw new Error("Use HTTPS, or HTTP on loopback for local development.");
677
+ if (url.username || url.password || url.search || url.hash || url.pathname !== "/")
678
+ throw new Error("Use the API origin without a path or credentials.");
679
+ return url.origin;
680
+ }
681
+
654
682
  // setup.ts
655
- var runDisposabl = (args, interactive = false) => new Promise((resolve, reject) => {
683
+ var runDisposabl = (args, interactive = false, origin) => new Promise((resolve, reject) => {
656
684
  const child = spawn(process.execPath, [fileURLToPath(new URL("./disposabl.js", import.meta.url)), ...args], {
685
+ env: {
686
+ ...process.env,
687
+ ...origin ? { DISPOSABL_API_ORIGIN: origin } : {}
688
+ },
657
689
  stdio: interactive ? ["inherit", "inherit", "inherit"] : ["ignore", "pipe", "pipe"]
658
690
  });
659
691
  let output = "";
@@ -678,6 +710,12 @@ async function setupApp(directory, name, run = runDisposabl) {
678
710
  const reference = detectReference(directory);
679
711
  const path = join4(directory, "disposabl.json");
680
712
  const config = JSON.parse(await readFile3(path, "utf8"));
713
+ const origin = apiUrl(process.env.DISPOSABL_API_ORIGIN || config.serviceOrigin || SERVICE_ORIGIN);
714
+ if (config.appId && config.serviceOrigin && apiUrl(config.serviceOrigin) !== origin)
715
+ throw new Error("This app belongs to a different Disposabl service. Use its saved service origin.");
716
+ config.serviceOrigin = origin;
717
+ if (run === runDisposabl)
718
+ run = (args, interactive) => runDisposabl(args, interactive, origin);
681
719
  config.features = resolveFeatures(config.features ?? []);
682
720
  await writeFile3(path, JSON.stringify(config, null, 2) + `
683
721
  `);
@@ -1,11 +1,25 @@
1
1
  import { appendFile, readFile } from "node:fs/promises";
2
2
 
3
- const origin = "https://www.disposabl.dev";
4
3
  const config = JSON.parse(
5
4
  await readFile(new URL("../../disposabl.json", import.meta.url), "utf8"),
6
5
  );
7
6
  const [command, platform, status, detail] = process.argv.slice(2);
8
7
  if (config.appId) {
8
+ if (!config.serviceOrigin)
9
+ throw new Error("Run Disposabl setup to save this app's service origin.");
10
+ const service = new URL(config.serviceOrigin);
11
+ if (
12
+ service.protocol !== "https:" ||
13
+ service.username ||
14
+ service.password ||
15
+ service.pathname !== "/" ||
16
+ service.search ||
17
+ service.hash
18
+ )
19
+ throw new Error(
20
+ "Workflow reporting requires an HTTPS Disposabl service origin.",
21
+ );
22
+ const origin = service.origin;
9
23
  const audience = new URL(process.env.ACTIONS_ID_TOKEN_REQUEST_URL);
10
24
  // The audience is an identity identifier, independent of the HTTP hostname.
11
25
  audience.searchParams.set("audience", "https://disposabl.dev");
@@ -39,7 +39,7 @@ node --input-type=module -e '
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
41
  const mobile = /^(apps\/mobile\/|packages\/disposabl-kit\/|\.github\/scripts\/(mobile|apple)\.sh$)/;
42
- for (const platform of ["android", "ios"]) console.log(`${platform}=${(platform === "ios" || process.env.EXPO_CONNECTED === "true") && affected(platform, mobile)}`);
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\//))
45
45
  .map(platform => ({platform, runner: runners[platform]}));
@@ -82,7 +82,7 @@ case "$PLATFORM" in
82
82
  ios) test -s dist/release/ios.ipa; test -s dist/release/ios.json ;;
83
83
  linux) compgen -G 'dist/release/*.deb' > /dev/null; compgen -G 'dist/release/*.rpm' > /dev/null ;;
84
84
  windows) compgen -G 'dist/release/*.exe' > /dev/null; compgen -G 'dist/release/*.nupkg' > /dev/null; test -s dist/release/RELEASES ;;
85
- macos) compgen -G 'dist/release/*.dmg' > /dev/null ;;
85
+ macos) compgen -G 'dist/release/*.dmg' > /dev/null; compgen -G 'dist/release/*.zip' > /dev/null ;;
86
86
  *) exit 1 ;;
87
87
  esac
88
88
  ;;
@@ -59,6 +59,7 @@ jobs:
59
59
  env:
60
60
  PR: ${{ github.event.number }}
61
61
  EXPO_CONNECTED: ${{ secrets.EXPO_TOKEN != '' }}
62
+ IOS_BUILDS_ENABLED: ${{ vars.IOS_BUILDS_ENABLED != 'false' }}
62
63
  run: bash "$GITHUB_WORKSPACE/.github/scripts/platforms.sh"
63
64
  web:
64
65
  name: Web
@@ -103,7 +104,7 @@ jobs:
103
104
  key: bun-${{ github.job == 'desktop' && 'desktop-' || '' }}${{ runner.os }}-${{ runner.arch }}-${{ env.BUN_VERSION }}-${{ hashFiles('bun.lock') }}
104
105
  restore-keys: bun-${{ github.job == 'desktop' && 'desktop-' || '' }}${{ runner.os }}-${{ runner.arch }}-${{ env.BUN_VERSION }}-
105
106
  - &install
106
- run: bun install --frozen-lockfile ${{ github.job == 'desktop' && '--filter desktop' || (github.job == 'android' || startsWith(github.job, 'ios-')) && '--filter @disposabl/mobile' || '' }}
107
+ run: bun install --frozen-lockfile ${{ github.job == 'desktop' && '--filter "*desktop*" --filter @disposabl/backend' || (github.job == 'android' || startsWith(github.job, 'ios-')) && '--filter @disposabl/mobile' || '' }}
107
108
  - name: Report build start
108
109
  run: |
109
110
  node .github/scripts/disposabl.mjs report web,api,mcp building
@@ -357,7 +358,9 @@ jobs:
357
358
  timeout-minutes: 30
358
359
  env:
359
360
  PLATFORM: ${{ matrix.platform }}
361
+ DISPOSABL_RELEASE_VERSION: 1.${{ github.run_number }}.${{ github.run_attempt }}
360
362
  DISPOSABL_DESKTOP_PLATFORM: ${{ matrix.platform }}
363
+ DISPOSABL_DESKTOP_UPDATE_CHANNEL: ${{ env.CHANNEL }}
361
364
  CONVEX_SITE_URL: ${{ needs.web.outputs.convex_site_url }}
362
365
  electron_config_cache: ${{ github.workspace }}/.cache/electron
363
366
  steps:
@@ -376,9 +379,24 @@ jobs:
376
379
  - name: Packages
377
380
  if: matrix.platform == 'linux'
378
381
  run: command -v fakeroot && command -v rpmbuild && command -v dpkg-deb || { sudo apt-get update && sudo apt-get install -y fakeroot dpkg rpm; }
382
+ - name: Configure desktop update identity
383
+ shell: bash
384
+ run: |
385
+ id=$(node -p "require('./disposabl.json').desktopId || ''")
386
+ if [[ ! "$id" =~ ^[a-f0-9]{32}$ ]]; then echo 'Desktop identity missing; regenerate this app before its first installation.' >&2; exit 1; fi
387
+ echo "DISPOSABL_DESKTOP_ID=$id" >> "$GITHUB_ENV"
388
+ echo "DISPOSABL_DESKTOP_UPDATE_URL=${CONVEX_SITE_URL}/desktop/updates/$id" >> "$GITHUB_ENV"
379
389
  - name: Build
380
390
  run: bun run --cwd apps/desktop preview
381
391
  - *publish
392
+ - name: Publish desktop update feed
393
+ if: matrix.platform == 'windows' || (matrix.platform == 'macos' && env.MACOS_NOTARIZE == 'true')
394
+ shell: bash
395
+ env:
396
+ CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }}
397
+ run: |
398
+ test "$(gh api "repos/$GH_REPO/git/ref/heads/main" --jq .object.sha)" = "$SOURCE"
399
+ node apps/desktop/publish-update.mjs
382
400
  - name: Upload desktop release artifacts
383
401
  if: matrix.platform != 'macos'
384
402
  uses: actions/upload-artifact@v4
@@ -388,12 +406,22 @@ jobs:
388
406
  retention-days: 3
389
407
  compression-level: 0
390
408
  if-no-files-found: error
409
+ - name: Upload staged update feed
410
+ if: matrix.platform != 'linux' && env.DISPOSABL_DESKTOP_UPDATE_URL != '' && (matrix.platform != 'macos' || env.MACOS_NOTARIZE == 'true')
411
+ uses: actions/upload-artifact@v4
412
+ with:
413
+ name: desktop-update-${{ env.PLATFORM }}
414
+ path: dist/update/
415
+ retention-days: 3
416
+ if-no-files-found: error
391
417
  - name: Upload unsigned macOS artifact
392
418
  if: matrix.platform == 'macos'
393
419
  uses: actions/upload-artifact@v4
394
420
  with:
395
421
  name: macos-unsigned
396
- path: dist/release/*.dmg
422
+ path: |
423
+ dist/release/*.dmg
424
+ dist/release/*.zip
397
425
  retention-days: 3
398
426
  compression-level: 0
399
427
  if-no-files-found: error
@@ -17,7 +17,7 @@ bun run --cwd apps/desktop make
17
17
  `dev` opens the app with Vite hot reload. `build` packages the application into
18
18
  `apps/desktop/out/`. `make` also creates distributables for the current platform.
19
19
  The desktop app participates in the root Turbo tasks, so
20
- `bun run dev --filter=desktop` also starts it.
20
+ `bun run --cwd apps/desktop dev` also starts it.
21
21
 
22
22
  Use the root `bun.lock`; do not generate a separate npm lockfile or run npm install
23
23
  inside this workspace. Forge 8 still probes npm's version during its CLI system
@@ -41,10 +41,22 @@ on macOS. Linux builders need `fakeroot`, `dpkg`, and `rpm` installed.
41
41
 
42
42
  Desktop builds run only after a push or merge to `main`, when desktop files or shared build inputs change. Pull requests do not build desktop installers or create desktop prereleases.
43
43
 
44
- The root [pipeline](../../.github/workflows/pipeline.yml) selects enabled targets from `disposabl.json`. After web/backend deployment succeeds, Windows x64, Linux x64, and macOS arm64 build in parallel. Bun installs only the desktop workspace, and dependency downloads and Electron binaries are cached.
44
+ The root [pipeline](../../.github/workflows/pipeline.yml) selects enabled targets from `disposabl.json`. After web/backend deployment succeeds, Windows x64, Linux x64, and macOS arm64 build in parallel. Bun installs the desktop and backend workspaces, and dependency downloads and Electron binaries are cached.
45
45
 
46
- The build helper temporarily sets version `1.0.<workflow run number>`, creates the installers, restores `package.json`, and collects outputs in `dist/release`. Build jobs upload artifacts; the separate publisher checks the source commit and publishes Windows/Linux releases from trusted `main` scripts. Main release tags include the platform and workflow run. Forge itself does not publish.
46
+ The build helper temporarily sets version `1.<workflow run number>.<run attempt>`, creates the installers, restores `package.json`, and collects outputs in `dist/release`. Build jobs upload artifacts; the separate publisher checks the source commit and publishes Windows/Linux releases from trusted `main` scripts. Main release tags include the platform and workflow run. Forge itself does not publish.
47
47
 
48
- Windows and Linux installers are unsigned. macOS uses ad hoc signing and provides a DMG as a workflow artifact retained for three days. The pipeline does not currently configure Developer ID signing, notarization, or macOS GitHub releases. In-app updates are not configured.
48
+ Windows and Linux installers are unsigned. macOS uses ad hoc signing and provides a DMG as a workflow artifact retained for three days. The pipeline does not currently configure Developer ID signing, notarization, or macOS GitHub releases. The signed macOS update lane still requires separate configuration described below.
49
49
 
50
50
  The desktop window uses `http://localhost:3000` during development and the deployed `CONVEX_SITE_URL` in packaged builds. It shares the website and authentication flow; if the site is unavailable, it shows the bundled starter page.
51
+
52
+ ## Native updates
53
+
54
+ The website is loaded from `CONVEX_SITE_URL`; refreshing it receives deployed web changes independently of a native update. The app menu's **Check for updates** checks the installed native binary on macOS and Windows, downloads an available update, and asks before restarting. A downloaded update may also install at the next launch. Development builds and builds without a feed report that updates are not configured. Linux uses the system package manager; the menu explains this and does not claim to check for an update. The existing DEB/RPM artifacts do not configure an apt or RPM repository, so operators must provide one for package-manager updates.
55
+
56
+ Each scaffolded app receives a random persistent `desktopId` in `disposabl.json`. It determines the native package and bundle identifiers and the update path; retain it when regenerating the app. The first CI build embeds its production Convex site URL and identity. Existing installations built before this updater or with a different identity require a new installation. Channels and platform/architecture paths are separate. Feed access is unauthenticated, so update packages are publicly downloadable even when the GitHub repository is private. Do not put private material or credentials in them. Windows packages are currently unsigned and lack publisher signature verification.
57
+
58
+ After building and verifying Windows artifacts, CI uses the same production `CONVEX_DEPLOY_KEY` already used for backend deployment to upload the full package to Convex file storage and atomically publish its feed record. The website's static-hosting component is not modified. Each release has an immutable versioned filename; existing packages remain in storage so in-flight clients can finish. Feed records are scoped to the app identity, channel, platform and architecture, and reject older workflow runs and attempts. Feed metadata is served without caching; package requests redirect to Convex storage, avoiding the HTTP action response limit. Failed or stale publications leave the previous feed in place. The publisher discards its uploaded blob only if no published feed references it; a lost cleanup response may still require manual storage reconciliation. Storage and egress are billable and retained versions require an explicit future retention policy. Convex upload URLs have a two-minute timeout; a slow or failed upload leaves the prior release available.
59
+
60
+ macOS also produces a ZIP for Squirrel.Mac. A properly Developer ID signed and notarized build with `MACOS_NOTARIZE=true`, Apple API credentials and a matching signing identity can use the same upload path. Successive releases must retain the same signing identity and bundle identifier. The current CI lane has no signing credentials and creates only ad-hoc signed workflow artifacts, so it deliberately does not publish a macOS update feed. Signature verification remains enabled. Configure signing and notarization before expecting installed macOS updates to work. The existing Linux DEB/RPM artifacts do not configure an apt or RPM repository, so Linux native updates are unavailable until such a repository is provided.
61
+
62
+ Verify delivery using two installed versions on each supported OS, checking no-update, download, restart, signature rejection and recovery from a failed feed. Building or staging an artifact alone does not prove update delivery. See [Electron's updater documentation](https://www.electronjs.org/docs/latest/api/auto-updater) and [static feed format](https://www.electronjs.org/docs/latest/tutorial/updates).
@@ -25,6 +25,7 @@ const original = await readFile(packagePath, 'utf8');
25
25
  try {
26
26
  await rm(join(root, 'out'), { recursive: true, force: true });
27
27
  await rm(join(root, '../../dist/release'), { recursive: true, force: true });
28
+ await rm(join(root, '../../dist/update'), { recursive: true, force: true });
28
29
  await writeFile(
29
30
  packagePath,
30
31
  JSON.stringify({ ...JSON.parse(original), version }, null, 2) + '\n',
@@ -51,6 +52,12 @@ try {
51
52
  await collect(join(root, 'out', 'make'));
52
53
  if (!(await readdir(destination)).length)
53
54
  throw new Error('Forge produced no artifacts');
55
+ const staged = spawnSync('node', ['stage-update.mjs'], {
56
+ cwd: root,
57
+ stdio: 'inherit',
58
+ });
59
+ if (staged.status !== 0)
60
+ throw new Error(`Update staging failed: ${staged.error ?? staged.status}`);
54
61
  } finally {
55
62
  await writeFile(packagePath, original);
56
63
  }
@@ -2,6 +2,7 @@ import { resolve } from 'node:path';
2
2
  import manifest from './package.json' with { type: 'json' };
3
3
  import type { ForgeConfig } from '@electron-forge/shared-types';
4
4
  import { MakerSquirrel } from '@electron-forge/maker-squirrel';
5
+ import { MakerZIP } from '@electron-forge/maker-zip';
5
6
  import { MakerDMG } from '@electron-forge/maker-dmg';
6
7
  import { MakerDeb } from '@electron-forge/maker-deb';
7
8
  import { MakerRpm } from '@electron-forge/maker-rpm';
@@ -9,9 +10,7 @@ import { VitePlugin } from '@electron-forge/plugin-vite';
9
10
  import { FusesPlugin } from '@electron-forge/plugin-fuses';
10
11
  import { FuseV1Options, FuseVersion } from '@electron/fuses';
11
12
 
12
- const executableName = manifest.productName
13
- .toLowerCase()
14
- .replace(/[^a-z0-9-]/g, '-');
13
+ const executableName = manifest.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
15
14
 
16
15
  // specTemplate is supported by electron-installer-redhat but absent from Forge's types.
17
16
  const rpmOptions = {
@@ -35,7 +34,11 @@ const config: ForgeConfig = {
35
34
  asar: true,
36
35
  executableName,
37
36
  icon: 'src/assets/icon',
38
- appBundleId: process.env.MACOS_BUNDLE_ID || 'dev.disposabl.starter.desktop',
37
+ appBundleId:
38
+ process.env.MACOS_BUNDLE_ID ||
39
+ ('disposablDesktopId' in manifest
40
+ ? `dev.disposabl.app.d${manifest.disposablDesktopId}`
41
+ : 'dev.disposabl.starter.desktop'),
39
42
  ...(process.platform === 'darwin'
40
43
  ? {
41
44
  osxSign: signedRelease
@@ -79,6 +82,7 @@ const config: ForgeConfig = {
79
82
  },
80
83
  makers: [
81
84
  new MakerSquirrel({ setupIcon: 'src/assets/icon.ico' }),
85
+ new MakerZIP({}, ['darwin']),
82
86
  new MakerDMG({ format: 'ULFO' }),
83
87
  new MakerRpm({ options: rpmOptions }),
84
88
  new MakerDeb({ options: { name: executableName, bin: executableName } }),
@@ -39,8 +39,10 @@
39
39
  "@electron-forge/maker-dmg": "8.0.1",
40
40
  "@electron-forge/maker-rpm": "8.0.1",
41
41
  "@electron-forge/maker-squirrel": "8.0.1",
42
+ "@electron-forge/maker-zip": "8.0.1",
42
43
  "@electron-forge/plugin-fuses": "8.0.1",
43
44
  "@electron-forge/plugin-vite": "8.0.1",
45
+ "@electron-forge/publisher-github": "8.0.1",
44
46
  "@electron-forge/shared-types": "8.0.1",
45
47
  "@electron/fuses": "^2.1.3",
46
48
  "@types/electron-squirrel-startup": "^1.0.2",
@@ -49,7 +51,6 @@
49
51
  "oxfmt": "^0.77.0",
50
52
  "oxlint": "^1.92.0",
51
53
  "typescript": "~6.0.3",
52
- "vite": "^8.3.6",
53
- "@electron-forge/publisher-github": "8.0.1"
54
+ "vite": "^8.3.6"
54
55
  }
55
56
  }
@@ -0,0 +1,93 @@
1
+ import { createReadStream } from 'node:fs';
2
+ import { readFile, readdir, stat } from 'node:fs/promises';
3
+ import { createHash } from 'node:crypto';
4
+ import { spawnSync } from 'node:child_process';
5
+ import { join } from 'node:path';
6
+
7
+ const {
8
+ DISPOSABL_DESKTOP_ID: app,
9
+ DISPOSABL_DESKTOP_PLATFORM: target,
10
+ DISPOSABL_DESKTOP_UPDATE_CHANNEL: channel = 'production',
11
+ DISPOSABL_RELEASE_VERSION: version,
12
+ } = process.env;
13
+ const targets = { windows: ['win32', 'x64'], macos: ['darwin', 'arm64'] };
14
+ if (!targets[target]) process.exit(0);
15
+ if (target === 'macos' && process.env.MACOS_NOTARIZE !== 'true')
16
+ process.exit(0);
17
+ if (
18
+ !/^[a-f0-9]{32}$/.test(app ?? '') ||
19
+ !/^1\.[1-9]\d*\.[1-9]\d*$/.test(version ?? '')
20
+ )
21
+ throw new Error('Invalid update identity or version');
22
+ const [platform, arch] = targets[target];
23
+ const directory = join('dist/update', channel, platform, arch);
24
+ const files = await readdir(directory);
25
+ const candidates = files.filter((f) =>
26
+ platform === 'darwin' ? f.endsWith('.zip') : f.endsWith('-full.nupkg'),
27
+ );
28
+ if (candidates.length !== 1)
29
+ throw new Error('Expected exactly one full update package');
30
+ const filename = candidates[0];
31
+ const path = join(directory, filename);
32
+ const size = (await stat(path)).size;
33
+ const sha256 = createHash('sha256');
34
+ const sha1 = createHash('sha1');
35
+ for await (const chunk of createReadStream(path)) {
36
+ sha256.update(chunk);
37
+ sha1.update(chunk);
38
+ }
39
+ const hash = sha256.digest('hex');
40
+ const squirrelHash = sha1.digest('hex').toUpperCase();
41
+ if (platform === 'win32') {
42
+ const releases = (await readFile(join(directory, 'RELEASES'), 'utf8')).trim();
43
+ if (releases !== `${squirrelHash} ${filename} ${size}`)
44
+ throw new Error('Squirrel RELEASES does not match the full package');
45
+ }
46
+ function run(name, args) {
47
+ const result = spawnSync(
48
+ 'bun',
49
+ [
50
+ 'x',
51
+ '--no-install',
52
+ 'convex',
53
+ 'run',
54
+ '--prod',
55
+ '--codegen=disable',
56
+ '--typecheck=disable',
57
+ name,
58
+ JSON.stringify(args),
59
+ ],
60
+ { cwd: 'packages/backend', encoding: 'utf8' },
61
+ );
62
+ if (result.status !== 0)
63
+ throw new Error(`Convex ${name} failed: ${result.stderr}`);
64
+ return result.stdout.trim() ? JSON.parse(result.stdout) : null;
65
+ }
66
+ const uploadUrl = run('desktopUpdates:uploadUrl', {});
67
+ const response = await fetch(uploadUrl, {
68
+ method: 'POST',
69
+ headers: { 'Content-Type': 'application/octet-stream' },
70
+ body: createReadStream(path),
71
+ duplex: 'half',
72
+ });
73
+ if (!response.ok) throw new Error(`Update upload failed: ${response.status}`);
74
+ const { storageId } = await response.json();
75
+ try {
76
+ run('desktopUpdates:publish', {
77
+ app,
78
+ channel,
79
+ platform,
80
+ arch,
81
+ version,
82
+ build: Number(version.split('.')[1]),
83
+ attempt: Number(version.split('.')[2]),
84
+ filename,
85
+ storageId,
86
+ sha256: hash,
87
+ sha1: squirrelHash,
88
+ size,
89
+ });
90
+ console.log(`Published ${platform}/${arch} ${version} to ${channel}`);
91
+ } finally {
92
+ run('desktopUpdates:discardUpload', { storageId });
93
+ }
@@ -2,3 +2,7 @@
2
2
  declare module '*.css';
3
3
 
4
4
  declare const DISPOSABL_WEB_URL: string;
5
+
6
+ declare const DISPOSABL_UPDATE_URL: string;
7
+ declare const DISPOSABL_UPDATE_CHANNEL: string;
8
+ declare const DISPOSABL_DESKTOP_ID: string;
@@ -1,7 +1,14 @@
1
- import { app, BrowserWindow } from 'electron';
1
+ import { app, autoUpdater, BrowserWindow, dialog, Menu } from 'electron';
2
+ import { createUpdateController, feedUrl, type UpdateState } from './updates';
2
3
  import path from 'node:path';
3
4
  import started from 'electron-squirrel-startup';
4
5
 
6
+ if (DISPOSABL_DESKTOP_ID)
7
+ app.setPath(
8
+ 'userData',
9
+ path.join(app.getPath('appData'), `disposabl-${DISPOSABL_DESKTOP_ID}`),
10
+ );
11
+
5
12
  if (started) app.quit();
6
13
 
7
14
  async function createWindow() {
@@ -44,6 +51,84 @@ async function createWindow() {
44
51
  }
45
52
 
46
53
  app.whenReady().then(() => {
54
+ const supported =
55
+ process.platform === 'darwin' || process.platform === 'win32';
56
+ const feed = app.isPackaged
57
+ ? feedUrl(
58
+ DISPOSABL_UPDATE_URL,
59
+ DISPOSABL_UPDATE_CHANNEL,
60
+ process.platform,
61
+ process.arch,
62
+ )
63
+ : '';
64
+ let state: UpdateState = 'idle';
65
+ const renderMenu = () => {
66
+ const labels = {
67
+ idle: 'Check for updates…',
68
+ checking: 'Checking for updates…',
69
+ downloading: 'Downloading update…',
70
+ ready: 'Restart to update…',
71
+ };
72
+ Menu.setApplicationMenu(
73
+ Menu.buildFromTemplate([
74
+ {
75
+ label: app.name,
76
+ submenu: [
77
+ { label: labels[state], click: updates.check },
78
+ { type: 'separator' },
79
+ { role: 'quit' },
80
+ ],
81
+ },
82
+ { role: 'editMenu' },
83
+ { role: 'viewMenu' },
84
+ { role: 'windowMenu' },
85
+ ]),
86
+ );
87
+ };
88
+ const updates = createUpdateController({
89
+ onState: (next) => {
90
+ state = next;
91
+ renderMenu();
92
+ },
93
+ supported,
94
+ feed,
95
+ readyAt:
96
+ process.platform === 'win32' &&
97
+ process.argv.includes('--squirrel-firstrun')
98
+ ? Date.now() + 10_000
99
+ : 0,
100
+ start: () => {
101
+ autoUpdater.setFeedURL(
102
+ process.platform === 'darwin'
103
+ ? { url: `${feed}/RELEASES.json`, serverType: 'json' }
104
+ : { url: feed },
105
+ );
106
+ autoUpdater.checkForUpdates();
107
+ },
108
+ install: () => autoUpdater.quitAndInstall(),
109
+ show: (type, message, detail) => {
110
+ void dialog.showMessageBox({ type, message, detail });
111
+ },
112
+ confirmRestart: async () =>
113
+ (
114
+ await dialog.showMessageBox({
115
+ type: 'info',
116
+ message: 'Update downloaded',
117
+ detail:
118
+ 'Restart to install the update. It may also be installed the next time you open the app.',
119
+ buttons: ['Restart', 'Later'],
120
+ defaultId: 0,
121
+ cancelId: 1,
122
+ })
123
+ ).response === 0,
124
+ });
125
+ if (supported) {
126
+ autoUpdater.on('update-available', updates.available);
127
+ autoUpdater.on('update-not-available', updates.unavailable);
128
+ autoUpdater.on('update-downloaded', updates.downloaded);
129
+ autoUpdater.on('error', updates.error);
130
+ }
131
+ renderMenu();
47
132
  void createWindow();
48
133
  app.on('activate', () => {
49
134
  if (BrowserWindow.getAllWindows().length === 0) void createWindow();