@sixb/deploy-ssh 0.2.6 → 0.2.7

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 (64) hide show
  1. package/README.md +51 -44
  2. package/dist/check/index.d.ts +24 -0
  3. package/dist/check/index.d.ts.map +1 -0
  4. package/dist/check/judge.d.ts +23 -0
  5. package/dist/check/judge.d.ts.map +1 -0
  6. package/dist/index.js +599 -1527
  7. package/dist/index.js.map +10 -16
  8. package/dist/layout.d.ts +87 -30
  9. package/dist/layout.d.ts.map +1 -1
  10. package/dist/operations.d.ts +5 -3
  11. package/dist/operations.d.ts.map +1 -1
  12. package/dist/plan.d.ts +25 -0
  13. package/dist/plan.d.ts.map +1 -0
  14. package/dist/render.d.ts +15 -11
  15. package/dist/render.d.ts.map +1 -1
  16. package/dist/server/manifest.d.ts +10 -4
  17. package/dist/server/manifest.d.ts.map +1 -1
  18. package/dist/server/release-host.d.ts +4 -0
  19. package/dist/server/release-host.d.ts.map +1 -0
  20. package/dist/server/release.d.ts +46 -0
  21. package/dist/server/release.d.ts.map +1 -0
  22. package/dist/server/state.d.ts +0 -4
  23. package/dist/server/state.d.ts.map +1 -1
  24. package/dist/server/supervisor.d.ts +8 -8
  25. package/dist/server/supervisor.d.ts.map +1 -1
  26. package/dist/ssh-target.d.ts +3 -24
  27. package/dist/ssh-target.d.ts.map +1 -1
  28. package/dist/transport.d.ts.map +1 -1
  29. package/package.json +3 -3
  30. package/src/bootstrap.sh +93 -0
  31. package/src/check/index.ts +117 -0
  32. package/src/check/judge.ts +299 -0
  33. package/src/check/probe.sh +99 -0
  34. package/src/layout.ts +109 -61
  35. package/src/operations.ts +105 -65
  36. package/src/plan.ts +59 -0
  37. package/src/render.ts +54 -35
  38. package/src/server/cli.ts +16 -20
  39. package/src/server/manifest.ts +13 -6
  40. package/src/server/release-host.ts +81 -0
  41. package/src/server/release.ts +738 -0
  42. package/src/server/state.ts +1 -5
  43. package/src/server/supervisor.ts +45 -238
  44. package/src/sh.d.ts +4 -0
  45. package/src/ssh-target.ts +43 -285
  46. package/src/transport.ts +28 -12
  47. package/dist/access.d.ts +0 -11
  48. package/dist/access.d.ts.map +0 -1
  49. package/dist/check.d.ts +0 -31
  50. package/dist/check.d.ts.map +0 -1
  51. package/dist/ci.d.ts +0 -27
  52. package/dist/ci.d.ts.map +0 -1
  53. package/dist/keys.d.ts +0 -13
  54. package/dist/keys.d.ts.map +0 -1
  55. package/dist/scripts.d.ts +0 -48
  56. package/dist/scripts.d.ts.map +0 -1
  57. package/dist/setup.d.ts +0 -32
  58. package/dist/setup.d.ts.map +0 -1
  59. package/src/access.ts +0 -107
  60. package/src/check.ts +0 -257
  61. package/src/ci.ts +0 -88
  62. package/src/keys.ts +0 -57
  63. package/src/scripts.ts +0 -703
  64. package/src/setup.ts +0 -203
package/dist/layout.d.ts CHANGED
@@ -1,57 +1,114 @@
1
+ /** The read-only token a deploy pulls `.env` with, for a project with a source. */
2
+ export declare const ENV_TOKEN_FILE = "env-token";
1
3
  /**
2
- * Where a deployment lives on its server. Everything but the Bun binaries and the Caddy route
3
- * sits in one directory in the deploy user's home, so projects under one user never share files.
4
- *
5
- * ~/<name>/releases/<id> immutable release directories (code, node_modules, .sixb/dist)
6
- * ~/<name>/current symlink to the active release directory
7
- * ~/<name>/code symlink to `current` (migrated in place from single-folder deploys)
8
- * ~/<name>/shared/.env shared project `.env`, linked from each release
9
- * ~/<name>/env-token the read-only token a deploy pulls `.env` with, if it has a source
10
- * ~/<name>/deploy lock, uploads, manifests, release record, ctl
11
- * ~/<name>/run supervisor state, control requests, and logs
12
- * ~/.sixb/bun/<v> Bun, shared by the user's projects that pin the same version
4
+ * A deployment runs in one of two slots. A release starts in the idle one, beside the live one,
5
+ * and takes traffic once it is healthy.
13
6
  */
14
- export declare const ENV_TOKEN_FILE = "env-token";
15
7
  export type DeploySlot = "blue" | "green";
8
+ export declare const SLOTS: readonly DeploySlot[];
9
+ /** The loopback ports each slot's HTTP services listen on. Caddy forwards to the live slot's. */
10
+ export declare const SLOT_PORTS: {
11
+ readonly blue: {
12
+ readonly app: 3001;
13
+ readonly api: 3002;
14
+ };
15
+ readonly green: {
16
+ readonly app: 3011;
17
+ readonly api: 3012;
18
+ };
19
+ };
20
+ export declare function otherSlot(slot: DeploySlot): DeploySlot;
21
+ /**
22
+ * Where a deployment lives on its server: one folder in the deploy account's home, plus Bun, the
23
+ * slot service and the Caddy routes.
24
+ *
25
+ * ~/<name>/releases/<id> immutable releases: code, node_modules, .sixb/dist, .env
26
+ * ~/<name>/current the live release
27
+ * ~/<name>/code `current`, for scripts and older tools that look here
28
+ * ~/<name>/shared/.env the `.env` kept on the server, for a project without a source
29
+ * ~/<name>/env-token the token a deploy pulls `.env` with, for a project with one
30
+ * ~/<name>/deploy/ lock, uploads, release record, live slot, slot launchers, ctl
31
+ * ~/<name>/run/<slot>/ each slot's supervisor state, control requests and logs
32
+ * ~/.sixb/bun/<version>/ Bun, shared by releases on the same version
33
+ */
16
34
  export interface DeploymentLayout {
35
+ readonly name: string;
36
+ readonly home: string;
17
37
  readonly root: string;
18
38
  readonly releasesDir: string;
19
39
  readonly currentLink: string;
20
40
  readonly code: string;
21
- readonly sharedDir: string;
22
41
  readonly sharedEnv: string;
23
42
  readonly envToken: string;
24
- readonly project: string;
25
- readonly projectPath: string;
26
43
  readonly deployDir: string;
27
44
  readonly incomingDir: string;
45
+ readonly runsDir: string;
28
46
  readonly lock: string;
29
- readonly fileList: string;
30
- readonly manifest: string;
31
- readonly candidateManifest: string;
32
47
  readonly releaseRecord: string;
33
- /** Runs the server half of this package with the project's Bun and manifest. */
48
+ /** Names the live slot. */
49
+ readonly liveSlotFile: string;
50
+ /** What `status`, `logs` and the other operations run: the live release's server half. */
34
51
  readonly ctl: string;
52
+ readonly unitDir: string;
53
+ /** The slot service's template, instantiated as `sixb-<name>@blue` and `sixb-<name>@green`. */
54
+ readonly unitTemplate: string;
55
+ readonly caddyDir: string;
56
+ readonly caddySnippet: string;
57
+ }
58
+ export interface SlotLayout {
59
+ readonly slot: DeploySlot;
60
+ readonly unit: string;
61
+ readonly manifest: string;
62
+ /** What the slot's service runs: its release's supervisor, with its Bun. */
63
+ readonly launcher: string;
35
64
  readonly runDir: string;
36
65
  readonly logDir: string;
37
- readonly bunDir: string;
38
- readonly bun: string;
39
- readonly unitName: string;
66
+ }
67
+ /** A deployment from before slots: one service, one manifest. Adopted by its first slot deploy. */
68
+ export interface LegacyLayout {
40
69
  readonly unit: string;
41
- readonly caddyDir: string;
42
- readonly caddySnippet: string;
70
+ readonly unitPath: string;
71
+ readonly manifest: string;
43
72
  }
73
+ /** Where a deployment lives: under the home of the account it runs as, whichever that is. */
74
+ export declare function deploymentLayout(input: {
75
+ readonly home: string;
76
+ readonly user: string;
77
+ readonly name: string;
78
+ }): {
79
+ name: string;
80
+ home: string;
81
+ root: string;
82
+ releasesDir: string;
83
+ currentLink: string;
84
+ code: string;
85
+ sharedEnv: string;
86
+ envToken: string;
87
+ deployDir: string;
88
+ incomingDir: string;
89
+ runsDir: string;
90
+ lock: string;
91
+ releaseRecord: string;
92
+ liveSlotFile: string;
93
+ ctl: string;
94
+ unitDir: string;
95
+ unitTemplate: string;
96
+ caddyDir: string;
97
+ caddySnippet: string;
98
+ };
99
+ export declare function slotLayout(layout: DeploymentLayout, slot: DeploySlot): SlotLayout;
100
+ export declare function legacyLayout(layout: DeploymentLayout): LegacyLayout;
44
101
  export interface ReleaseLayout {
45
102
  readonly id: string;
46
103
  readonly root: string;
104
+ /** The project inside the release: its root, or a folder of a monorepo. */
47
105
  readonly project: string;
106
+ readonly bunDir: string;
107
+ readonly bun: string;
48
108
  }
49
- export declare function deploymentLayout(input: {
50
- readonly home: string;
51
- readonly user: string;
52
- readonly name: string;
109
+ export declare function releaseLayout(layout: DeploymentLayout, input: {
110
+ readonly id: string;
53
111
  readonly projectPath: string;
54
112
  readonly bunVersion: string;
55
- }): DeploymentLayout;
56
- export declare function releaseLayout(layout: DeploymentLay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,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;;;;;;;;;;;;;;;;;;;;EA2BA;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CAUjF;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,YAAY,CAOnE;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACxF,aAAa,CAUf"}
@@ -1,8 +1,10 @@
1
1
  import type { DeployContext, DeployControlAction, DeployLogsOptions, DeployRelease, DeployScript, DeploySource, DeployStatus } from "@sixb/core/deploy";
2
- import type { SlotPorts } from "./render";
3
2
  import { type RemoteShell } from "./transport";
4
- /** Uploads the source, then runs the release on the server as one locked script. */
5
- export declare function deployRelease(shell: RemoteShell, user: string, release: DeployRelease, source: DeploySource, context: DeployContext, slotPorts?: SlotPorts): Promise<void>;
3
+ /**
4
+ * Uploads the source and the plan, starts the release on the server detached from this
5
+ * connection, and follows its log until it ends. A dropped connection leaves the deploy running.
6
+ */
7
+ export declare function deployRelease(shell: RemoteShell, release: DeployRelease, source: DeploySource, context: DeployContext): Promise<void>;
6
8
  export declare function readStatus(shell: RemoteShell, name: string): Promise<DeployStatus>;
7
9
  export declare function streamLogs(shell: RemoteShell, name: string, options: DeployLogsOptions & {
8
10
  readonly terminal?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACb,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AASzC,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAIjE,oFAAoF;AACpF,wBAAsB,aAAa,CACjC,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,aAAa,EACtB,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,IAAI,CAAC,CAmCf;AAmCD,wBAAsB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAOxF;AAED,wBAAsB,UAAU,CAC9B,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,GAAG;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAC3D,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,wBAAsB,eAAe,CACnC,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,OAA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ED
@@ -0,0 +1,25 @@
1
+ import type { DeployCommand, DeployRecord, DeployRelease } from "@sixb/core/deploy";
2
+ /** What the laptop sends the server's runner: the release, and how it was asked for. */
3
+ export interface ReleasePlan {
4
+ readonly version: 1;
5
+ readonly release: DeployRelease;
6
+ readonly record: DeployRecord;
7
+ readonly releaseId: string;
8
+ readonly projectPath: string;
9
+ }
10
+ /** Starts every progress line, so the laptop tells events from a command's output (RFC 7464). */
11
+ export declare const EVENT_PREFIX = "\u001E";
12
+ export type ReleaseEvent = {
13
+ readonly step: string;
14
+ readonly status: "running" | "done";
15
+ } | {
16
+ readonly exit: number;
17
+ };
18
+ export declare function event(value: ReleaseEvent): string;
19
+ export declare function parseEvent(line: string): ReleaseEvent | null;
20
+ /** The steps a deploy runs, in order: the upload, then what the server does. */
21
+ export declare function releaseStepLabels(release: DeployRelease): string[];
22
+ export declare function commandLabel(command: DeployCommand): string;
23
+ /** A release folder's name: when, to the millisecond, then which commit. */
24
+ export declare function deriveReleaseId(record: DeployRecord): string;
25
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEnF,wFAAwF;AACxF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IACnB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;IAC/B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED,iGAAiG;AACjG,eAAO,MAAM,YAAY,WAAW,CAAA;AAEpC,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAA;CAAE,GAC9D;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAE7B,wBAAgB,KAAK,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAEjD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAO5D;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,EAAE,CAelE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAE3D;AAED,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAI5D"}
package/dist/render.d.ts CHANGED
@@ -1,21 +1,25 @@
1
1
  import type { DeployHttpServiceName, DeployRelease } from "@sixb/core/deploy";
2
- import type { DeploymentLayout, DeploySlot } from "./layout";
2
+ import type { DeploymentLayout, ReleaseLayout, SlotLayout } from "./layout";
3
3
  import type { ProcessManifest } from "./server/manifest";
4
- export type SlotPorts = Readonly<Record<DeploySlot, Readonly<Record<DeployHttpServiceName, number>>>>;
5
4
  /** Rewrites a release's HTTP services to listen on the given slot's loopback ports. */
6
5
  export declare function releaseForSlot(release: DeployRelease, ports: Readonly<Record<DeployHttpServiceName, number>>): DeployRelease;
7
- /** The supervisor's view of the release: absolute commands, full environments. */
8
- export declare function renderProcessManifest(release: DeployRelease, layout: DeploymentLayout, options?: {
9
- readonly projectDir?: string;
10
- readonly slot?: DeploySlot;
6
+ /** The supervisor's view of a release in one slot: absolute commands, full environments. */
7
+ export declare function renderProcessManifest(release: DeployRelease, input: {
8
+ readonly layout: DeploymentLayout;
9
+ readonly slot: SlotLayout;
10
+ readonly release: ReleaseLayout;
11
+ readonly holdExclusive: boolean;
11
12
  }): ProcessManifest;
12
- /** Pins the server half of this package to the project's Bun and manifest. */
13
- export declare function renderCtl(layout: DeploymentLayout): string;
13
+ /** What a slot's service runs: its release's supervisor, with that release's Bun. */
14
+ export declare function renderLauncher(release: ReleaseLayout, slot: SlotLayout): string;
15
+ /** What `status`, `logs` and the other operations run: the live release's server half. */
16
+ export declare function renderCtl(release: ReleaseLayout, slot: SlotLayout): string;
14
17
  /**
15
- * The deployment's `systemd --user` unit. Linger starts the user's systemd at boot, so the
16
- * unit comes back after a reboot without anyone logged in.
18
+ * The slot service's template: `sixb-<name>@blue` and `sixb-<name>@green` each run their slot's
19
+ * launcher. Lingering starts the live slot's at boot. Stopping one signals only the supervisor,
20
+ * which lets its HTTP services and workers drain before systemd's stop timeout.
17
21
  */
18
- export declare function renderUnit(release: DeployRelease, layout: DeploymentLayout): string;
22
+ export declare function renderSlotUnit(release: DeployRelease, layout: DeploymentLayout): string;
19
23
  /** One site per HTTP service, forwarded to the active slot's loopback port. */
20
24
  export declare function renderCaddySnippet(release: DeployRelease): string;
21
25
  //# sourceMappingURL=render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAwB,MAAM,mBAAmB,CAAA;AACnG,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAOxD,MAAM,MAAM,SAAS,GAAG,QAAQ,CAC9B,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC,CACpE,CAAA;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,GACrD,aAAa,CAqBf;AAWD,kFAAkF;AAClF,wBAAgB,qBAAqB,CACnC,OAAO,EAA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I,EAAE,UAAU,GAAG,MAAM,CAE/E;AAED,0FAA0F;AAC1F,wBAAgB,SAAS,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAE1E;AAoBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAwBvF;AAED,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAkBjE"}
@@ -6,6 +6,11 @@ export interface ProcessManifest {
6
6
  readonly name: string;
7
7
  /** Which port pair (`blue` or `green`) this release's HTTP services bind. */
8
8
  readonly slot?: DeploySlot;
9
+ /**
10
+ * Leaves the singletons and project scripts stopped at start, while another slot still runs
11
+ * them: a deploy starts them here once the routes have moved. See `isExclusiveService`.
12
+ */
13
+ readonly holdExclusive?: boolean;
9
14
  /** The project directory every process starts in. */
10
15
  readonly cwd: string;
11
16
  /** Supervisor state, control requests, and logs live here. */
@@ -32,10 +37,11 @@ export interface ProcessServiceManifest {
32
37
  readonly restartDelayMs: number;
33
38
  readonly maxMemory?: string;
34
39
  }
35
- export declare function isOverlapSafeService(service: ProcessServiceManifest): boolean;
40
+ /** A service two releases must never run at once: a singleton, or a project script. */
41
+ export declare function isExclusiveService(service: ProcessServiceManifest): boolean;
36
42
  export declare function loadProcessManifest(path: string): Promise<ProcessManifest>;
37
- export declare function statePath(manifest: ProcessManifest): string;
38
- export declare function controlDir(manifest: ProcessManifest): string;
39
- export declare function responseDir(manifest: ProcessManifest): string;
43
+ export declare function statePath(manifest: Pick<ProcessManifest, "runDir">): string;
44
+ export declare function controlDir(manifest: Pick<ProcessManifest, "runDir">): string;
45
+ export declare function responseDir(manifest: Pick<ProcessManifest, "runDir">): string;
40
46
  export declare function parseProcessManifest(value: unknown, source?: string): ProcessManifest;
41
47
  //# sourceMappingURL=manifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.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,CAsBjG"}
@@ -0,0 +1,4 @@
1
+ import type { ReleaseHost } from "./release";
2
+ /** The server itself: commands share the release's log, and systemd is the account's own. */
3
+ export declare function createReleaseHost(): ReleaseHost;
4
+ //# sourceMappingURL=release-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-host.d.ts","sourceRoot":"","sources":["../../src/server/release-host.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAI5C,6FAA6F;AAC7F,wBAAgB,iBAAiB,IAAI,WAAW,CAyE/C"}
@@ -0,0 +1,46 @@
1
+ import { type ReleasePlan } from "../plan";
2
+ import { type ProcessState } from "./state";
3
+ import type { SupervisorCommand } from "./supervisor";
4
+ /** What the rollout does to the server beyond its own files, so a test can stand in for it. */
5
+ export interface ReleaseHost {
6
+ /** Runs a command with its output in the release's log; resolves with its exit code. */
7
+ run(command: readonly string[], options?: {
8
+ readonly cwd?: string;
9
+ readonly env?: Readonly<Record<string, string>>;
10
+ }): Promise<number>;
11
+ systemctl(...args: string[]): Promise<number>;
12
+ /** Whether a unit runs anything: started, starting, or still stopping while it drains. */
13
+ isActive(unit: string): Promise<boolean>;
14
+ /** Whether a unit starts at boot. */
15
+ isEnabled(unit: string): Promise<boolean>;
16
+ readRoutes(path: string): Promise<string | null>;
17
+ /** Writes the deployment's routes, or removes them with null. */
18
+ writeRoutes(path: string, routes: string | null): Promise<void>;
19
+ /** Validates the whole Caddy configuration; resolves with Caddy's complaint, or null. */
20
+ validateCaddy(): Promise<string | null>;
21
+ reloadCaddy(): Promise<boolean>;
22
+ /** Whether a URL answers with a 2xx. */
23
+ answers(url: string): Promise<boolean>;
24
+ supervise(runDir: string, command: SupervisorCommand, service: string): Promise<void>;
25
+ readState(runDir: string): Promise<ProcessState | null>;
26
+ sleep(ms: number): Promise<void>;
27
+ print(line: string): void;
28
+ }
29
+ /**
30
+ * Rolls a release out beside the live one, under the deploy lock the bootstrap holds. The live
31
+ * release keeps serving until the new one has passed its checks after the routes move; any
32
+ * failure before that leaves it serving, and one after it moves the routes back.
33
+ *
34
+ * Moving the routes is the commit point: `live-slot` names the new slot from then on, so a deploy
35
+ * that dies before it retires the previous release never leads the next one to stop what serves.
36
+ */
37
+ export declare function runRelease(plan: ReleasePlan, host: ReleaseHost, account: {
38
+ readonly home: string;
39
+ readonly user: string;
40
+ }): Promise<void>;
41
+ /**
42
+ * Carries one generation of content-hashed assets from the previous build into the new one, so a
43
+ * tab opened before the deploy never asks for a lazy chunk that is gone.
44
+ */
45
+ export declare function carryAssets(previousProject: string, nextProject: string): Promise<void>;
46
+ //# sourceMappingURL=release.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../../src/server/release.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,SAAS,CAAA;AAiB/D,OAAO,EAA2B,KAAK,YAAY,EAAuB,MAAM,SAAS,CAAA;AACzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAErD,+FAA+F;AAC/F,MAAM,WAAW,WAAW;IAC1B,wFAAwF;IACxF,GAAG,CACD,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;KAAE,GACnF,OAAO,CAAC,MAAM,CAAC,CAAA;IAClB,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7C,0FAA0F;IAC1F,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACxC,qCAAqC;IACrC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACzC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAChD,iEAAiE;IACjE,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/D,yFAAyF;IACzF,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IACvC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/B,wCAAwC;IACxC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACtC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACrF,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAA;IACvD,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAChC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B;AAgBD;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,iBAwK1D;AA0VD;;;GAGG;AACH,wBAAsB,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwB7F"}
@@ -8,10 +8,6 @@ export interface ProcessState {
8
8
  readonly updatedAt: string;
9
9
  readonly slot?: DeploySlot;
10
10
  readonly instances: readonly ProcessInstanceState[];
11
- /** Overlap-safe instances of a candidate release waiting to cut over. */
12
- readonly staged?: readonly ProcessInstanceState[];
13
- /** Release `cwd`s still held by background-draining processes after a cutover. */
14
- readonly retiringCwds?: readonly string[];
15
11
  }
16
12
  export interface ProcessInstanceState {
17
13
  readonly service: string;
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/server/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAA;AAE9F,mFAAmF;AACnF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,SAAS,oBAAoB,EAAE,CAAA;IACnD,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAA;IACjD,kFAAkF;IAClF,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAA;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC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AAC,IAAI,CAAC,CAItF;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,SAAkB,GAAG,YAAY,CAWxF;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOjD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEjD"}
@@ -1,22 +1,22 @@
1
1
  import { type ProcessManifest } from "./manifest";
2
- export type SupervisorCommand = "restart" | "start" | "stop" | "stage" | "activate" | "discard";
2
+ export type SupervisorCommand = "restart" | "start" | "stop";
3
3
  /** SIGINT comes this long before SIGKILL, so a draining role can still record its partial work. */
4
4
  export declare const INTERRUPT_LEAD_MS = 10000;
5
- /** A retiring process gets the cutover's drain window, or its own kill timeout when longer. */
6
- export declare function retiringKillTimeoutMs(killTimeoutMs: number): number;
5
+ /** A draining process gets the drain window, or its own kill timeout when longer. */
6
+ export declare function drainKillTimeoutMs(killTimeoutMs: number): number;
7
7
  /**
8
- * Runs every process a deployment's manifest lists, restarting any that exit, and answers
9
- * control requests. One per deployment, started by the deployment's `systemd --user` unit.
8
+ * Runs every process one slot's manifest lists, restarting any that exit, and answers control
9
+ * requests. One per slot, started by the slot's `systemd --user` service; stopping that service
10
+ * lets the HTTP services and workers finish their work for up to five minutes.
10
11
  *
11
12
  * Requests arrive as files in `run/control` followed by `SIGUSR2`, so a caller needs nothing but
12
13
  * the file system and the supervisor's pid from `run/state.json`. The supervisor answers in
13
14
  * `run/responses`.
14
15
  */
15
16
  export declare function runSupervisor(manifestPath: string): Promise<void>;
16
- /** Asks the running supervisor to control services or cut over a staged release. */
17
- export declare function sendSupervisorCommand(manifest: ProcessManifest, type: SupervisorCommand, options?: {
17
+ /** Asks a slot's running supervisor to restart, start or stop services. */
18
+ export declare function sendSupervisorCommand(manifest: Pick<ProcessManifest, "runDir">, type: SupervisorCommand, options?: {
18
19
  readonly service?: string;
19
- readonly manifestPath?: string;
20
20
  readonly timeoutMs?: number;
21
21
  }): Promise<string>;
22
22
  export declare function parseMemoryLimit(value: string): number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../src/server/supervisor.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,eAAe,EAIrB,MAAM,YAAY,CAAA;AAYnB,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAA;AAQ/F,mGAAmG;AACnG,eAAO,MAAM,iBAAiB,QAAS,CAAA;AAEvC,+FAA+F;AAC/F,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEnE;AAkDD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvE;AAED,oFAAoF;AACpF,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,iBAAiB,EACvB,OAAO,GAAE;IACP,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CACvB,GACL,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAgnBD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM7D;AAoCD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKjD"}
1
+ {"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../src/server/supervisor.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,KAAK,eAAe,EAIrB,MAAM,YAAY,CAAA;AAYnB,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAA;AAQ5D,mGAAmG;AACnG,eAAO,MAAM,iBAAiB,QAAS,CAAA;AAEvC,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEhE;AA2CD;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvE;AAED,2EAA2E;AAC3E,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,EACzC,IAAI,EAAE,iBAAiB,EACvB,OAAO,GAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACvE,OAAO,CAAC,MAAM,CAAC,CAwBjB;AA4bD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM7D;AAoCD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKjD"}
@@ -1,46 +1,25 @@
1
- import type { DeployAccess, DeployCheck, DeployCheckContext, DeployCi, DeployContext, DeployControlAction, DeployHttpServiceName, DeployListenAddress, DeployLogsOptions, DeployOperationContext, DeployRelease, DeployScript, DeploySetupContext, DeploySource, DeployStatus, DeployTarget } from "@sixb/core/deploy";
1
+ import type { DeployCheck, DeployCheckContext, DeployContext, DeployControlAction, DeployHttpServiceName, DeployListenAddress, DeployLogsOptions, DeployOperationContext, DeployRelease, DeployScript, DeploySource, DeployStatus, DeployTarget } from "@sixb/core/deploy";
2
2
  export interface SshTargetOptions {
3
3
  /** The server: a hostname, an IP address, or a `Host` alias from your SSH config. */
4
4
  readonly host: string;
5
- /**
6
- * The Linux user the deployment runs as. Projects under one user can read each other's files,
7
- * so give a project its own user to wall it off from the others on the server. Defaults to
8
- * `"sixb"`.
9
- */
5
+ /** The account the deployment logs in and runs as, never `root`. Defaults to `"sixb"`. */
10
6
  readonly user?: string;
11
- /**
12
- * Local ports for the HTTP services, which Caddy on the server forwards to. Set them when
13
- * projects share a server, so that each has its own. Defaults: app 3001, api 3002.
14
- */
15
- readonly ports?: Readonly<Partial<Record<DeployHttpServiceName, number>>>;
16
- /**
17
- * Second local port pair for blue-green cutovers while the active slot keeps serving. Defaults
18
- * to `ports` plus 10 (app 3011, api 3012).
19
- */
20
- readonly standbyPorts?: Readonly<Partial<Record<DeployHttpServiceName, number>>>;
21
7
  }
22
8
  /** A server reached over SSH, where Caddy routes each domain to its service. */
23
9
  export declare class SshTarget implements DeployTarget {
24
10
  #private;
25
11
  readonly kind = "ssh";
26
12
  readonly host: string;
13
+ /** The account the deployment logs in and runs as. */
27
14
  readonly user: string;
28
15
  readonly location: string;
29
16
  constructor(options: SshTargetOptions);
30
17
  listenAddress(service: DeployHttpServiceName): DeployListenAddress;
31
- standbyListenAddress(service: DeployHttpServiceName): DeployListenAddress;
32
18
  deploy(release: DeployRelease, source: DeploySource, context: DeployContext): Promise<void>;
33
19
  status(context: DeployOperationContext): Promise<DeployStatus>;
34
20
  logs(options: DeployLogsOptions, context: DeployOperationContext): Promise<void>;
35
21
  control(action: DeployControlAction, service: string | undefined, context: DeployOperationContext): Promise<void>;
36
22
  run(script: DeployScript, context: DeployOperationContext): Promise<number>;
37
23
  check(release: DeployRelease, context: DeployCheckContext): Promise<DeployCheck[]>;
38
- /**
39
- * Prepares the server as the admin login when the deploy user or the server is not set up
40
- * yet, then the project as the deploy user. Running it again changes nothing that is right.
41
- */
42
- setup(release: DeployRelease, context: DeploySetupContext): Promise<void>;
43
- readonly access: DeployAccess;
44
- readonly ci: DeployCi;
45
24
  }
46
25
  //# sourceMappingURL=ssh-target.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ssh-target.d.ts","sourceRoot":"","sources":["../src/ssh-target.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAEZ,WAAW,EACX,kBAAkB,EAClB,QAAQ,EAER,aAAa,EACb,mBAAmB,EACnB,qBAAqB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
1
1
  {
2
2
  "name": "@sixb/deploy-ssh",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Deploy a Sixb project to your own server over SSH",
5
5
  "keywords": [
6
6
  "sixb",
@@ -38,10 +38,10 @@
38
38
  "prepack": "bun run build"
39
39
  },
40
40
  "peerDependencies": {
41
- "@sixb/core": "^0.2.6"
41
+ "@sixb/core": "^0.2.7"
42
42
  },
43
43
  "devDependencies": {
44
- "@sixb/core": "0.2.6",
44
+ "@sixb/core": "0.2.7",
45
45
  "@types/bun": "latest",
46
46
  "typescript": "^5.7.0"
47
47
  },
@@ -0,0 +1,93 @@
1
+ # Starts a release on the server: takes the deploy lock, unpacks the upload into its release
2
+ # folder, installs Bun and the dependencies, then hands over to the release's own runner
3
+ # (server/release.ts), which still holds the lock. Runs detached from the SSH session, so a
4
+ # dropped connection never leaves half a deploy; the laptop follows its log.
5
+ #
6
+ # Usage: bootstrap.sh <name> <release-id> <project-path> <bun-version> <incoming> <plan>
7
+
8
+ set -euo pipefail
9
+ name=$1 release_id=$2 project_path=$3 bun_version=$4 incoming=$5 plan=$6
10
+
11
+ root="$HOME/$name"
12
+ release="$root/releases/$release_id"
13
+ project="$release/$project_path"
14
+ bun_dir="$HOME/.sixb/bun/$bun_version"
15
+ bun="$bun_dir/bun"
16
+
17
+ # Progress for the laptop, as RFC 7464 JSON text sequences; a release ends with its exit code.
18
+ event() { printf '\036{"step":"%s","status":"%s"}\n' "$1" "$2"; }
19
+ trap 'printf "\036{\"exit\":%d}\n" "$?"' EXIT
20
+ # `systemctl --user` finds the account's systemd through this; SSH sessions usually set it.
21
+ export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
22
+
23
+ exec 9> "$root/deploy/lock"
24
+ if ! flock -n 9; then
25
+ echo "Waiting for another deploy or script run of $name to finish…"
26
+ if ! flock -w 600 9; then
27
+ echo "Another deploy or script run of $name has held its lock for 10 minutes." >&2
28
+ exit 1
29
+ fi
30
+ fi
31
+
32
+ event "Prepare release" "running"
33
+ # Unpacking replaces the folder, so it must never be the one that serves.
34
+ if [ "$(readlink "$root/current" 2> /dev/null)" = "releases/$release_id" ]; then
35
+ echo "Release $release_id is the live one. Deploy again to make a new release." >&2
36
+ exit 1
37
+ fi
38
+ rm -rf "$release"
39
+ mkdir -p "$release" "$root/shared"
40
+ (cd "$incoming" && tar -c -f - --exclude=.env .) | (cd "$release" && tar -x -f -)
41
+ chmod 755 "$release"
42
+ mkdir -p "$project"
43
+ # A deployment from before releases kept its `.env` in its code folder.
44
+ if [ ! -L "$root/code" ] && [ -f "$root/code/$project_path/.env" ] && [ ! -f "$root/shared/.env" ]; then
45
+ cp -p "$root/code/$project_path/.env" "$root/shared/.env"
46
+ chmod 600 "$root/shared/.env"
47
+ fi
48
+ rm -rf "$incoming"
49
+ # Uploads and logs of deploys long gone.
50
+ find "$root/deploy/incoming" "$root/deploy/runs" -mindepth 1 -maxdepth 1 -mtime +7 -exec rm -rf {} + 2> /dev/null || true
51
+ event "Prepare release" "done"
52
+
53
+ event "Install Bun $bun_version" "running"
54
+ if [ ! -x "$bun" ]; then
55
+ case "$(uname -m)" in
56
+ x86_64 | amd64) arch=x64 ;;
57
+ aarch64 | arm64) arch=aarch64 ;;
58
+ *) echo "Bun has no Linux build for $(uname -m)." >&2; exit 1 ;;
59
+ esac
60
+ # Bun's default x64 build needs AVX2; older CPUs take the baseline build.
61
+ if [ "$arch" = x64 ] && ! grep -q avx2 /proc/cpuinfo; then arch=x64-baseline; fi
62
+ asset="bun-linux-$arch"
63
+ url="https://github.com/oven-sh/bun/releases/download/bun-v$bun_version"
64
+ download="$(mktemp -d)"
65
+ curl -fsSL --retry 3 -o "$download/$asset.zip" "$url/$asset.zip"
66
+ curl -fsSL --retry 3 -o "$download/SHASUMS256.txt" "$url/SHASUMS256.txt"
67
+ (cd "$download" && grep " $asset.zip\$" SHASUMS256.txt | sha256sum -c --quiet -)
68
+ unzip -q "$download/$asset.zip" -d "$download"
69
+ mkdir -p "$bun_dir"
70
+ mv "$download/$asset/bun" "$bun"
71
+ rm -rf "$download"
72
+ fi
73
+ # Dependency lifecycle scripts call `node`; with none installed, Bun runs them.
74
+ command -v node > /dev/null || ln -sf "$bun" "$bun_dir/node"
75
+ "$bun" --version
76
+ event "Install Bun $bun_version" "done"
77
+
78
+ event "Install dependencies" "running"
79
+ cd "$project"
80
+ PATH="$bun_dir:$PATH" "$bun" install --frozen-lockfile --backend=hardlink
81
+ for package in @sixb/cli:sixb @sixb/deploy-ssh:sixb-deploy-ssh; do
82
+ if [ ! -e "node_modules/.bin/${package#*:}" ]; then
83
+ echo "${package%%:*} is not installed. Add it to the project's dependencies." >&2
84
+ exit 1
85
+ fi
86
+ done
87
+ if [ ! -e node_modules/@sixb/deploy-ssh/src/server/release.ts ]; then
88
+ echo "This commit's @sixb/deploy-ssh is older than this sixb, which needs its release runner. Upgrade it, or deploy the commit with its own sixb." >&2
89
+ exit 1
90
+ fi
91
+ event "Install dependencies" "done"
92
+
93
+ "$bun" "node_modules/.bin/sixb-deploy-ssh" release "$plan"