@pikku/deploy-standalone 0.12.13 → 0.12.19

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/CHANGELOG.md CHANGED
@@ -1,5 +1,186 @@
1
1
  # @pikku/deploy-standalone
2
2
 
3
+ ## 0.12.19
4
+
5
+ ### Patch Changes
6
+
7
+ - 7434e65: Stop mangling identifiers in a bundle that a second bundler will mangle again.
8
+
9
+ Every standalone bun binary died at boot on `TypeError: t6 is not a function`. The bundle
10
+ esbuild wrote was correct; `bun build --compile`, which is the documented next step for
11
+ that runtime, renamed the parameter of the already-mangled `wireCLI` to `t6` — the name
12
+ esbuild had given the top-level `registerCLICommands` that same function calls — and the
13
+ inner reference then resolved to the parameter object.
14
+
15
+ Neither pass is wrong on its own, so the fix is to stop running both: a provider now
16
+ declares `getMangleIdentifiers()`, and the standalone adapter returns false for the bun
17
+ runtime, where `bundle.js` is an input rather than the artifact that runs. Whitespace and
18
+ syntax minification are unaffected, and every other provider still ships a fully mangled
19
+ bundle — `minify: true` could not express that, because esbuild ORs it over the granular
20
+ flags and silently ignores a `minifyIdentifiers: false` set beside it.
21
+
22
+ - Updated dependencies [7434e65]
23
+ - @pikku/deploy@0.12.7
24
+
25
+ ## 0.12.18
26
+
27
+ ### Patch Changes
28
+
29
+ - 265df92: Lift `PlatformServiceContributor` into `@pikku/deploy` so any provider adapter
30
+ can accept the same service contributors.
31
+
32
+ A contributor now declares the binding sources its emitted code reads from
33
+ (`requires`, defaulting to `env`). An adapter that cannot provide one of them
34
+ refuses the contributor by name at construction instead of silently emitting
35
+ code that reads bindings the runtime never has.
36
+
37
+ `@pikku/deploy-cloudflare` keeps its entry output unchanged and re-exports the
38
+ type from the core package. The container entry it generates now runs only the
39
+ contributors that live on `env`. `@pikku/deploy-standalone` gains a
40
+ `contributors` option: both the node and bun entries build the contributed
41
+ services from `process.env` and spread them last into
42
+ `createSingletonServices`, so a contributed service overrides the in-process
43
+ default.
44
+
45
+ - Updated dependencies [265df92]
46
+ - @pikku/deploy@0.12.6
47
+
48
+ ## 0.12.17
49
+
50
+ ### Patch Changes
51
+
52
+ - b2e038b: Rename `@pikku/sql-migrator` to `@pikku/migrator-sql`, so a future migrator for
53
+ another store sorts beside it rather than under a second prefix. The package has
54
+ never been published under either name, so nothing depends on the old one.
55
+ - Updated dependencies [b2e038b]
56
+ - @pikku/migrator-sql@0.12.3
57
+
58
+ ## 0.12.16
59
+
60
+ ### Patch Changes
61
+
62
+ - f970f8f: Rename `@pikku/db-migrator` to `@pikku/migrator-sql`.
63
+
64
+ It applies `.sql` files and keeps their bookkeeping; it is not a database
65
+ service, and `db-` read as though it were one. Nothing was ever published under
66
+ the old name, so there is no alias to keep.
67
+
68
+ - Updated dependencies [f970f8f]
69
+ - @pikku/migrator-sql@0.12.2
70
+
71
+ ## 0.12.15
72
+
73
+ ### Patch Changes
74
+
75
+ - a057bec: Give a standalone bundle a command line.
76
+
77
+ An operator holding a standalone artifact on a machine had one thing they could
78
+ do with it: start it. Applying the migrations it needs meant a checkout of the
79
+ project and a second copy of the CLI on a production box, and answering "which
80
+ build is this" meant asking whoever ran the deploy.
81
+
82
+ The bundle now takes a command. `serve` remains the default, so an existing
83
+ `node bundle.js` is unchanged. `version` prints the version the project declared
84
+ at build time. `db migrate` and `db status` apply and report the migrations that
85
+ now ship beside the bundle under `db/<engine>/` — the same path Fabric's build
86
+ container stages them to, so the two producers of an artifact cannot disagree
87
+ about where the SQL lives. `backup <path>` writes a consistent copy of a SQLite
88
+ database with `VACUUM INTO`; on postgres it refuses and names `pg_dump`, which
89
+ is the tool for it.
90
+
91
+ Both engines are supported: a postgres build migrates over the connection it
92
+ already opens. `PostgresMigrationClient` grew an optional `begin`, because a
93
+ pooled client is free to answer `BEGIN`, the migration and `COMMIT` on three
94
+ different connections — which leaves a failed migration half applied with
95
+ nothing to roll back.
96
+
97
+ There is deliberately no way to invoke an RPC. A running server already answers
98
+ them with auth, sessions and middleware applied; an in-process invoke would
99
+ answer them with none of that.
100
+
101
+ - Updated dependencies [a057bec]
102
+ - Updated dependencies [a057bec]
103
+ - @pikku/migrator-sql@0.12.1
104
+ - @pikku/deploy@0.12.5
105
+
106
+ ## 0.12.14
107
+
108
+ ### Patch Changes
109
+
110
+ - 3d75643: Run the app's server lifecycle in generated entries, and make an out-of-band
111
+ account signable-in.
112
+
113
+ `pikkuServerLifecycle` was only ever called by `pikku dev` and `pikku serve`, so
114
+ an app that seeds its first admin account, probes a dependency, or warms a cache
115
+ in `beforeStart` did all of that in development and silently skipped it
116
+ everywhere it was actually deployed. The standalone entry and the shared node
117
+ server entry — the one behind every `target: 'server'` unit — now import the
118
+ app's lifecycle and call it: `beforeStart` after `init` and before the port
119
+ opens, so work that must finish before the first request has, `afterStart` once
120
+ the server is listening, and the stop hooks handed to the signal handler that
121
+ already owns shutdown rather than a second listener racing it. Each shutdown
122
+ step is isolated from the ones after it, so a hook that throws is logged without
123
+ taking the service teardown and the socket close down with it.
124
+
125
+ Separately, `createAuthUser` and `setAuthUserPassword` wrote credential accounts
126
+ with no `issuer`. From better-auth 1.7 a credential account is matched by its
127
+ issuer as well as its provider, so those accounts were invisible to sign-in,
128
+ `updatePassword` and `findCredentialAccount` — a user who plainly existed in the
129
+ table was reported as "user not found". The field is written only when the
130
+ resolved schema has it, so older better-auth keeps working, and
131
+ `setAuthUserPassword` repairs an account that predates the fix.
132
+
133
+ - 3d75643: Give a standalone artifact the database connection every other provider's runtime hands it.
134
+
135
+ `createSingletonServices` receives `kysely` from whatever is hosting the app —
136
+ `pikku dev` builds one, a Cloudflare deploy binds one — so app code is written
137
+ expecting it, and the generated templates throw outright when it is absent. The
138
+ standalone provider is its own host and supplied nothing, so a bundle built from
139
+ a project with a database started, called the services factory, and died on the
140
+ first line of it. The artifact was only ever startable by projects that had no
141
+ database at all, which is not the case the provider exists to serve.
142
+
143
+ The generated entry now opens the database itself and passes `kysely` in.
144
+ `EntryGenerationContext` carries a `db` descriptor, and the engine is read from
145
+ the migrations directory the project actually wrote — `db/sqlite` or
146
+ `db/postgres`, the same two conventions the migrator emits to. Having both is
147
+ refused rather than resolved: choosing on directory order would choose which
148
+ database the deployed app talks to, and an app running happily against the
149
+ wrong but entirely valid schema is invisible until someone reads the data.
150
+
151
+ For SQLite the adapter emits the dialect its runtime can actually use —
152
+ `@pikku/kysely-node-sqlite` for the node bundle, `@pikku/kysely-bun-sqlite` for a
153
+ compiled bun binary, which has no `node:sqlite` to reach for. For Postgres it
154
+ emits `PikkuKysely` from `@pikku/kysely-postgres`, connected from `DATABASE_URL`,
155
+ the same variable every other pikku host reads, so an artifact dropped onto a
156
+ machine already running a pikku app needs no new one. An unset `DATABASE_URL`
157
+ fails by name rather than as a driver error about an undefined connection
158
+ string.
159
+
160
+ The connection pool is closed on shutdown, in `afterStop` — after the app's own
161
+ stop hook and the draining server have both finished with it, since a pool
162
+ closed any earlier takes the queries they are still entitled to make down with
163
+ it. SQLite needs no counterpart: the process exiting releases the file.
164
+
165
+ The project's generated coercion map is applied to either engine, so a deployed
166
+ app and `pikku dev` agree about which columns are dates and which are booleans.
167
+ It is attached when the project generated one and skipped when it did not — the
168
+ map is built from `db/annotations.ts` rather than from the dialect, so an app
169
+ that annotates no columns is one with nothing to coerce rather than one that
170
+ should be handed no database at all.
171
+
172
+ A SQLite file is located by `PIKKU_DATA_DIR` rather than derived from the bundle's
173
+ own path: a deploy that swaps the release directory would otherwise take the
174
+ database with it. `PIKKU_DATABASE_FILE` overrides it outright, for when the path
175
+ has to match one something else already chose — notably `pikku db migrate`,
176
+ which has to open the same file or the app runs against an unmigrated schema.
177
+ Neither being set fails with the variable's name rather than as a SQLite error
178
+ about a path of `undefined`.
179
+
180
+ - Updated dependencies [3d75643]
181
+ - Updated dependencies [3d75643]
182
+ - @pikku/deploy@0.12.4
183
+
3
184
  ## 0.12.13
4
185
 
5
186
  ### Patch Changes
package/dist/adapter.d.ts CHANGED
@@ -16,7 +16,8 @@
16
16
  * compiles the bundle into a single self-contained executable via
17
17
  * `bun build --compile`. No runtime needed on the target host.
18
18
  */
19
- import type { EntryGenerationContext, ProviderAdapter } from '@pikku/deploy';
19
+ import type { BindingSource, EntryGenerationContext, PlatformServiceContributor, ProviderAdapter } from '@pikku/deploy';
20
+ export declare const STANDALONE_BINDING_SOURCES: readonly BindingSource[];
20
21
  export type StandaloneRuntime = 'node' | 'bun';
21
22
  /**
22
23
  * Directory the built frontend is copied to, both inside the unit and beside
@@ -48,6 +49,7 @@ export interface StandaloneProviderAdapterOptions {
48
49
  * The window is a webview onto that origin and nothing else is shipped.
49
50
  */
50
51
  desktopUrl?: string;
52
+ contributors?: PlatformServiceContributor[];
51
53
  }
52
54
  export declare class StandaloneProviderAdapter implements ProviderAdapter {
53
55
  readonly name = "standalone";
@@ -58,7 +60,12 @@ export declare class StandaloneProviderAdapter implements ProviderAdapter {
58
60
  readonly projectDir?: string;
59
61
  readonly desktopIdentifier?: string;
60
62
  readonly desktopUrl?: string;
63
+ readonly contributors: PlatformServiceContributor[];
61
64
  constructor(options?: StandaloneProviderAdapterOptions);
65
+ private contributorImportLines;
66
+ private platformServicesBlock;
67
+ private platformServicesCallLines;
68
+ private platformServicesSpreadLines;
62
69
  generateEntrySource(ctx: EntryGenerationContext): string;
63
70
  private generateNodeEntrySource;
64
71
  private generateBunEntrySource;
@@ -66,6 +73,24 @@ export declare class StandaloneProviderAdapter implements ProviderAdapter {
66
73
  generateInfraManifest(): string | null;
67
74
  generateProviderConfigs(): Map<string, string>;
68
75
  getExternals(): string[];
76
+ /**
77
+ * The SQLite driver this runtime cannot load.
78
+ *
79
+ * `loadSqliteRuntime` picks its driver by looking for `globalThis.Bun`, so a
80
+ * node process never runs the bun branch — but esbuild still follows the
81
+ * import, and `bun:sqlite` sits at the top of that module as a static import
82
+ * it cannot resolve. Left in, the bundle fails to build; marked external, it
83
+ * becomes a top-level import node fails to load. Stubbing removes the branch
84
+ * that was already dead.
85
+ */
86
+ getStubModules(): string[];
87
+ /**
88
+ * The bun bundle is not the artifact that runs — `bun build --compile` turns
89
+ * it into the binary — so esbuild must not rename anything bun will rename
90
+ * again. See `getMangleIdentifiers` on the adapter interface for the boot
91
+ * failure the two passes produce together.
92
+ */
93
+ getMangleIdentifiers(): boolean;
69
94
  getPlatform(): 'node';
70
95
  deploy(options: {
71
96
  buildDir: string;