@astrale-os/adapter-cloudflare 0.1.1 → 0.1.2
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/client.d.ts +7 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +43 -0
- package/dist/client.js.map +1 -0
- package/dist/cloudflare.d.ts +15 -0
- package/dist/cloudflare.d.ts.map +1 -0
- package/dist/cloudflare.js +186 -0
- package/dist/cloudflare.js.map +1 -0
- package/dist/codegen/identity.d.ts +10 -0
- package/dist/codegen/identity.d.ts.map +1 -0
- package/dist/codegen/identity.js +32 -0
- package/dist/codegen/identity.js.map +1 -0
- package/dist/codegen/merge.d.ts +20 -0
- package/dist/codegen/merge.d.ts.map +1 -0
- package/dist/codegen/merge.js +91 -0
- package/dist/codegen/merge.js.map +1 -0
- package/dist/codegen/worker.d.ts +31 -0
- package/dist/codegen/worker.d.ts.map +1 -0
- package/dist/codegen/worker.js +93 -0
- package/dist/codegen/worker.js.map +1 -0
- package/dist/codegen/wrangler.d.ts +34 -0
- package/dist/codegen/wrangler.d.ts.map +1 -0
- package/dist/codegen/wrangler.js +61 -0
- package/dist/codegen/wrangler.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/params.d.ts +50 -0
- package/dist/params.d.ts.map +1 -0
- package/dist/params.js +2 -0
- package/dist/params.js.map +1 -0
- package/dist/parse-output.d.ts +25 -0
- package/dist/parse-output.d.ts.map +1 -0
- package/dist/parse-output.js +53 -0
- package/dist/parse-output.js.map +1 -0
- package/dist/wrangler-cli.d.ts +63 -0
- package/dist/wrangler-cli.d.ts.map +1 -0
- package/dist/wrangler-cli.js +185 -0
- package/dist/wrangler-cli.js.map +1 -0
- package/package.json +2 -2
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the optional client SPA (the Views' UI). Best-effort: if the project
|
|
3
|
+
* has no `client/` or no resolvable Vite, we skip — the RPC surface and inline
|
|
4
|
+
* Views still work without a built SPA.
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildClient(clientDir: string, projectDir: string, onLog?: (line: string) => void): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,IAAI,CAAC,CAkBf"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the optional client SPA (the Views' UI). Best-effort: if the project
|
|
3
|
+
* has no `client/` or no resolvable Vite, we skip — the RPC surface and inline
|
|
4
|
+
* Views still work without a built SPA.
|
|
5
|
+
*/
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
export async function buildClient(clientDir, projectDir, onLog) {
|
|
10
|
+
const viteBin = [
|
|
11
|
+
join(clientDir, 'node_modules', '.bin', 'vite'),
|
|
12
|
+
join(projectDir, 'node_modules', '.bin', 'vite'),
|
|
13
|
+
].find((p) => existsSync(p));
|
|
14
|
+
if (!viteBin) {
|
|
15
|
+
// The project has a client/ but its deps aren't installed — wrangler would
|
|
16
|
+
// otherwise fail cryptically on the missing dist-client assets dir. Fail
|
|
17
|
+
// loud with the fix (the client is a workspace package — one install covers it).
|
|
18
|
+
throw new Error(`client build: vite not found in ${clientDir}. Run \`pnpm install\` at the project root ` +
|
|
19
|
+
`first (the client/ SPA is a workspace package).`);
|
|
20
|
+
}
|
|
21
|
+
const { code, out } = await runCapture(viteBin, ['build'], clientDir, onLog);
|
|
22
|
+
if (code !== 0) {
|
|
23
|
+
throw new Error(`client build failed (code ${code}):\n${out.slice(-1500)}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function runCapture(cmd, args, cwd, onLog) {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
const child = spawn(cmd, args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
29
|
+
let out = '';
|
|
30
|
+
const onData = (buf) => {
|
|
31
|
+
const text = buf.toString();
|
|
32
|
+
out += text;
|
|
33
|
+
for (const line of text.split('\n'))
|
|
34
|
+
if (line.trim())
|
|
35
|
+
onLog?.(line);
|
|
36
|
+
};
|
|
37
|
+
child.stdout?.on('data', onData);
|
|
38
|
+
child.stderr?.on('data', onData);
|
|
39
|
+
child.on('exit', (code) => resolve({ code: code ?? 1, out }));
|
|
40
|
+
child.on('error', reject);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,SAAiB,EACjB,UAAkB,EAClB,KAA8B;IAE9B,MAAM,OAAO,GAAG;QACd,IAAI,CAAC,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC;QAC/C,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC;KACjD,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA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C,CAAA;QAChC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;QAC7D,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cloudflare(envs)` — the Cloudflare deployment adapter.
|
|
3
|
+
*
|
|
4
|
+
* Owns everything target-specific: it codegens the Worker entry + wrangler
|
|
5
|
+
* config (the dev never sees a `wrangler.jsonc`), builds the optional client
|
|
6
|
+
* SPA, and shells out to `wrangler`. `watch` → `wrangler dev` (local URL);
|
|
7
|
+
* `deploy` → `wrangler deploy` (workers.dev or a custom-domain URL); secrets →
|
|
8
|
+
* `wrangler secret bulk`. Both `watch` and `deploy` return the URL the devkit
|
|
9
|
+
* prints and `astrale instance install <url>` consumes.
|
|
10
|
+
*/
|
|
11
|
+
import type { DomainAdapter } from '@astrale-os/devkit';
|
|
12
|
+
import type { CloudflareParams } from './params';
|
|
13
|
+
export declare function cloudflare(envs: Record<string, CloudflareParams>): DomainAdapter<CloudflareParams>;
|
|
14
|
+
export declare function workerName(params: CloudflareParams, origin: string): string;
|
|
15
|
+
//# sourceMappingURL=cloudflare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAa,aAAa,EAAY,MAAM,oBAAoB,CAAA;AAM5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAUhD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GACrC,aAAa,CAAC,gBAAgB,CAAC,CAsDjC;AAsHD,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAsB3E"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cloudflare(envs)` — the Cloudflare deployment adapter.
|
|
3
|
+
*
|
|
4
|
+
* Owns everything target-specific: it codegens the Worker entry + wrangler
|
|
5
|
+
* config (the dev never sees a `wrangler.jsonc`), builds the optional client
|
|
6
|
+
* SPA, and shells out to `wrangler`. `watch` → `wrangler dev` (local URL);
|
|
7
|
+
* `deploy` → `wrangler deploy` (workers.dev or a custom-domain URL); secrets →
|
|
8
|
+
* `wrangler secret bulk`. Both `watch` and `deploy` return the URL the devkit
|
|
9
|
+
* prints and `astrale instance install <url>` consumes.
|
|
10
|
+
*/
|
|
11
|
+
import { defineAdapter, hasStarModule } from '@astrale-os/devkit';
|
|
12
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
import { buildClient } from './client';
|
|
15
|
+
import { ensureIdentity } from './codegen/identity';
|
|
16
|
+
import { generateWorkerEntry } from './codegen/worker';
|
|
17
|
+
import { generateWranglerConfig } from './codegen/wrangler';
|
|
18
|
+
import { bulkPutSecrets, runWranglerDeploy, runWranglerDev } from './wrangler-cli';
|
|
19
|
+
const DEFAULT_PORT = 8787;
|
|
20
|
+
export function cloudflare(envs) {
|
|
21
|
+
return defineAdapter({
|
|
22
|
+
name: 'cloudflare',
|
|
23
|
+
envs,
|
|
24
|
+
async watch(params, ctx) {
|
|
25
|
+
const { configPath, port } = await prepare(params, ctx, 'dev');
|
|
26
|
+
if (ctx.clientDir)
|
|
27
|
+
await buildClient(ctx.clientDir, ctx.projectDir, logTo());
|
|
28
|
+
const handle = await runWranglerDev({
|
|
29
|
+
projectDir: ctx.projectDir,
|
|
30
|
+
configPath,
|
|
31
|
+
port,
|
|
32
|
+
remote: Boolean(params.remote),
|
|
33
|
+
onReload: ctx.onReload,
|
|
34
|
+
onLog: logTo(),
|
|
35
|
+
});
|
|
36
|
+
return { url: handle.url, stop: handle.stop };
|
|
37
|
+
},
|
|
38
|
+
async deploy(params, ctx) {
|
|
39
|
+
const { configPath, fallbackConfigPath, workerName: name, } = await prepare(params, ctx, 'deploy');
|
|
40
|
+
if (ctx.clientDir)
|
|
41
|
+
await buildClient(ctx.clientDir, ctx.projectDir, logTo());
|
|
42
|
+
const { url } = await runWranglerDeploy({
|
|
43
|
+
projectDir: ctx.projectDir,
|
|
44
|
+
configPath,
|
|
45
|
+
workerName: name,
|
|
46
|
+
...(fallbackConfigPath ? { fallbackConfigPath } : {}),
|
|
47
|
+
...(params.route ? { route: params.route } : {}),
|
|
48
|
+
onLog: logTo(),
|
|
49
|
+
});
|
|
50
|
+
if (Object.keys(ctx.secrets).length > 0) {
|
|
51
|
+
await bulkPutSecrets({
|
|
52
|
+
projectDir: ctx.projectDir,
|
|
53
|
+
configPath,
|
|
54
|
+
secrets: ctx.secrets,
|
|
55
|
+
onLog: logTo(),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// A first deploy on a fresh `*.workers.dev` host can take ~30-60s to
|
|
59
|
+
// propagate; an `astrale instance install <url>` issued right away would
|
|
60
|
+
// 404 (Cloudflare 1042). Block until the URL actually serves so the
|
|
61
|
+
// install line we print is immediately actionable.
|
|
62
|
+
await waitUntilLive(url, logTo());
|
|
63
|
+
return { url };
|
|
64
|
+
},
|
|
65
|
+
secretsFile(params) {
|
|
66
|
+
return params.secrets;
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// ── codegen orchestration ──────────────────────────────────────────────────
|
|
71
|
+
async function prepare(params, ctx, mode) {
|
|
72
|
+
const astraleDir = join(ctx.projectDir, '.astrale');
|
|
73
|
+
await mkdir(astraleDir, { recursive: true });
|
|
74
|
+
await ensureIdentity(astraleDir, ctx.domain.origin);
|
|
75
|
+
const name = workerName(params, ctx.domain.origin);
|
|
76
|
+
// Shared ★-files probe: must agree with the codegen's `import { views } from
|
|
77
|
+
// '../views'` resolution (folder index OR sibling file) — a folder-only
|
|
78
|
+
// existsSync would deploy a worker whose graph silently lacks a sibling-file
|
|
79
|
+
// module the diagnostic spec includes.
|
|
80
|
+
const hasViews = hasStarModule(ctx.projectDir, 'views');
|
|
81
|
+
const hasFunctions = hasStarModule(ctx.projectDir, 'functions');
|
|
82
|
+
const hasClient = Boolean(ctx.clientDir);
|
|
83
|
+
await writeFile(join(astraleDir, 'worker.gen.ts'), generateWorkerEntry({
|
|
84
|
+
origin: ctx.domain.origin,
|
|
85
|
+
...(ctx.domain.postInstall ? { postInstall: ctx.domain.postInstall } : {}),
|
|
86
|
+
requires: ctx.domain.requires,
|
|
87
|
+
hasViews,
|
|
88
|
+
hasFunctions,
|
|
89
|
+
hasClient,
|
|
90
|
+
}));
|
|
91
|
+
// Pin the worker's canonical serving URL (its `iss` identity) for routed
|
|
92
|
+
// deploys: a routed worker may ALSO be reachable via `*.workers.dev`, so
|
|
93
|
+
// resolving the URL from the per-request Host would let `iss` drift between
|
|
94
|
+
// hostnames. Dev + workers.dev-only deploys are single-host, so the worker
|
|
95
|
+
// falls back to the per-request Host (always the canonical URL there).
|
|
96
|
+
// An explicit `vars.WORKER_URL` (e.g. a tunnel/proxy front) wins.
|
|
97
|
+
const workerUrl = mode === 'deploy' && params.route ? `https://${params.route}` : undefined;
|
|
98
|
+
// Dev injects secrets as local vars (the gitignored .astrale config never
|
|
99
|
+
// ships); deploy keeps secrets out of the config and pushes them encrypted.
|
|
100
|
+
const vars = {
|
|
101
|
+
...(workerUrl ? { WORKER_URL: workerUrl } : {}),
|
|
102
|
+
...(mode === 'dev' ? { ...params.vars, ...ctx.secrets } : { ...params.vars }),
|
|
103
|
+
};
|
|
104
|
+
const baseConfig = {
|
|
105
|
+
workerName: name,
|
|
106
|
+
...(mode === 'deploy' && params.route ? { route: params.route } : {}),
|
|
107
|
+
hasClient,
|
|
108
|
+
vars,
|
|
109
|
+
// Escape hatch: extra bindings (KV/R2/D1/queues/…) deep-merged on top. Same
|
|
110
|
+
// overlay in dev and deploy — it's infra, not env-specific plumbing — and it
|
|
111
|
+
// flows into both the SELF and the SELF-less fallback config below.
|
|
112
|
+
...(params.wrangler ? { wrangler: params.wrangler } : {}),
|
|
113
|
+
};
|
|
114
|
+
// Always self-bind: it enables autobinding (a handler calling its own domain).
|
|
115
|
+
// Locally the dev registry resolves it; on deploy the first deploy of a fresh
|
|
116
|
+
// worker can't (the script doesn't exist yet), so we also emit a SELF-less
|
|
117
|
+
// fallback config that `runWranglerDeploy` uses for a one-time two-pass deploy.
|
|
118
|
+
const configPath = join(astraleDir, 'wrangler.gen.jsonc');
|
|
119
|
+
await writeFile(configPath, generateWranglerConfig({ ...baseConfig, selfBinding: true }));
|
|
120
|
+
let fallbackConfigPath;
|
|
121
|
+
if (mode === 'deploy') {
|
|
122
|
+
fallbackConfigPath = join(astraleDir, 'wrangler.no-self.gen.jsonc');
|
|
123
|
+
await writeFile(fallbackConfigPath, generateWranglerConfig({ ...baseConfig, selfBinding: false }));
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
configPath,
|
|
127
|
+
...(fallbackConfigPath ? { fallbackConfigPath } : {}),
|
|
128
|
+
port: params.port ?? DEFAULT_PORT,
|
|
129
|
+
workerName: name,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Poll the deployed URL until the worker answers (anything but the Cloudflare
|
|
134
|
+
* 1042 "no script on this host" 404), or give up after `timeoutMs`. Resolves
|
|
135
|
+
* silently on the fast path; logs only when propagation actually makes us wait.
|
|
136
|
+
*/
|
|
137
|
+
async function waitUntilLive(url, onLog, timeoutMs = 90_000) {
|
|
138
|
+
const probe = new URL('/health', url);
|
|
139
|
+
const deadline = Date.now() + timeoutMs;
|
|
140
|
+
let waited = false;
|
|
141
|
+
for (;;) {
|
|
142
|
+
try {
|
|
143
|
+
const res = await fetch(probe, { redirect: 'manual' });
|
|
144
|
+
if (res.status !== 404)
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// Network hiccup — treat like "not live yet" and keep polling.
|
|
149
|
+
}
|
|
150
|
+
if (Date.now() >= deadline) {
|
|
151
|
+
onLog(`URL not reachable yet after ${Math.round(timeoutMs / 1000)}s — it may need a moment.`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (!waited) {
|
|
155
|
+
waited = true;
|
|
156
|
+
onLog('waiting for the URL to go live (first deploys can take ~30-60s)…');
|
|
157
|
+
}
|
|
158
|
+
await new Promise((r) => setTimeout(r, 3000));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const WORKER_NAME_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
162
|
+
export function workerName(params, origin) {
|
|
163
|
+
// An explicit name is the deployed worker's identity (and the SELF service
|
|
164
|
+
// target) — validate and reject an invalid one rather than silently rewriting
|
|
165
|
+
// it, so the dev fixes it instead of deploying under a surprising name.
|
|
166
|
+
if (params.workerName !== undefined) {
|
|
167
|
+
if (!WORKER_NAME_RE.test(params.workerName) || params.workerName.length > 63) {
|
|
168
|
+
throw new Error(`cloudflare adapter: invalid \`workerName\` "${params.workerName}". A Cloudflare worker ` +
|
|
169
|
+
'name must be lowercase, start with a letter or digit, contain only letters, digits and ' +
|
|
170
|
+
'dashes, and be at most 63 chars.');
|
|
171
|
+
}
|
|
172
|
+
return params.workerName;
|
|
173
|
+
}
|
|
174
|
+
// Derive from the origin: lowercase, collapse non-alphanumerics to a dash, then
|
|
175
|
+
// SLICE before trimming dashes so a cut landing mid-dash can't leave a trailing
|
|
176
|
+
// "-" (which wrangler rejects).
|
|
177
|
+
return origin
|
|
178
|
+
.toLowerCase()
|
|
179
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
180
|
+
.slice(0, 54)
|
|
181
|
+
.replace(/^-+|-+$/g, '');
|
|
182
|
+
}
|
|
183
|
+
function logTo() {
|
|
184
|
+
return (line) => process.stderr.write(`\x1b[2m ${line}\x1b[0m\n`);
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=cloudflare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudflare.js","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAIhC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAElF,MAAM,YAAY,GAAG,IAAI,CAAA;AAEzB,MAAM,UAAU,UAAU,CACxB,IAAsC;IAEtC,OAAO,aAAa,CAAmB;QACrC,IAAI,EAAE,YAAY;QAClB,IAAI;QAEJ,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG;YACrB,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;YAC9D,IAAI,GAAG,CAAC,SAAS;gBAAE,MAAM,WAAW,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CAAA;YAC5E,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC;gBAClC,UAAU,EAAE,GAAG,CAAC,UAAU;gBAC1B,UAAU;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Ed25519 signing identity at
|
|
3
|
+
* `.astrale/identity.ts`. Generated ONCE (first `dev`/`deploy` or by the
|
|
4
|
+
* scaffolder) and never regenerated — the private key IS the domain's identity,
|
|
5
|
+
* so rotating it would orphan every instance that installed the old key. The
|
|
6
|
+
* file is gitignored; for real production this key should graduate to a managed
|
|
7
|
+
* secret.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ensureIdentity(astraleDir: string, origin: string): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/codegen/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBtF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensure the domain has a stable Ed25519 signing identity at
|
|
3
|
+
* `.astrale/identity.ts`. Generated ONCE (first `dev`/`deploy` or by the
|
|
4
|
+
* scaffolder) and never regenerated — the private key IS the domain's identity,
|
|
5
|
+
* so rotating it would orphan every instance that installed the old key. The
|
|
6
|
+
* file is gitignored; for real production this key should graduate to a managed
|
|
7
|
+
* secret.
|
|
8
|
+
*/
|
|
9
|
+
import { exportJWK, generateKeyPair } from 'jose';
|
|
10
|
+
import { existsSync } from 'node:fs';
|
|
11
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
export async function ensureIdentity(astraleDir, origin) {
|
|
14
|
+
const file = join(astraleDir, 'identity.ts');
|
|
15
|
+
if (existsSync(file))
|
|
16
|
+
return;
|
|
17
|
+
const { privateKey } = await generateKeyPair('EdDSA', { extractable: true });
|
|
18
|
+
const jwk = (await exportJWK(privateKey));
|
|
19
|
+
jwk.alg = 'EdDSA';
|
|
20
|
+
jwk.kid = `${origin}-key`;
|
|
21
|
+
await mkdir(astraleDir, { recursive: true });
|
|
22
|
+
await writeFile(file, `// AUTO-GENERATED stable signing identity for "${origin}" — do not edit, do not commit.\n` +
|
|
23
|
+
`export const PRIVATE_JWK = ${JSON.stringify(jwk, null, 2)} as const\n`);
|
|
24
|
+
// Loud on purpose: the file is gitignored, so a fresh clone / CI runner
|
|
25
|
+
// silently mints a NEW key — and a redeploy with a new key breaks JWKS
|
|
26
|
+
// verification on every instance that installed the old one, with no hint
|
|
27
|
+
// why. Make the lifecycle visible the one time it happens.
|
|
28
|
+
process.stderr.write(`\x1b[33m!\x1b[0m new signing identity generated at .astrale/identity.ts (kid ${String(jwk.kid)}).\n` +
|
|
29
|
+
` This key IS "${origin}"'s identity: back it up (or move it to a managed secret) —\n` +
|
|
30
|
+
` deploying from another machine without it re-keys the domain and breaks existing installs.\n`);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/codegen/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,UAAkB,EAAE,MAAc;IACrE,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAA;IAC5C,IAAI,UAAU,CAAC,IAAI,CAAC;QAAE,OAAM;IAE5B,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5E,MAAM,GAAG,GAAG,CAAC,MAAM,SAAS,CAAC,UAAU,CAAC,CAA4B,CAAA;IACpE,GAAG,CAAC,GAAG,GAAG,OAAO,CAAA;IACjB,GAAG,CAAC,GAAG,GAAG,GAAG,MAAM,MAAM,CAAA;IAEzB,MAAM,KAAK,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5C,MAAM,SAAS,CACb,IAAI,EACJ,kDAAkD,MAAM,mCAAmC;QACzF,8BAA8B,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,aAAa,CAC1E,CAAA;IAED,wEAAwE;IACxE,uEAAuE;IACvE,0EAA0E;IAC1E,2DAA2D;IAC3D,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,gFAAgF,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM;QACnG,kBAAkB,MAAM,+DAA+D;QACvF,gGAAgG,CACnG,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep-merge for the generated wrangler config. `base` is what the adapter
|
|
3
|
+
* generates; `overlay` is the dev's `params.wrangler` escape hatch. The merge
|
|
4
|
+
* is additive so a dev can declare extra bindings without losing the adapter's
|
|
5
|
+
* invariants:
|
|
6
|
+
* - plain objects → recurse
|
|
7
|
+
* - arrays → concat, de-duplicating BOTH primitive members and
|
|
8
|
+
* object bindings by an identity key (`binding` /
|
|
9
|
+
* `pattern` / `queue` / `name`, else structural value),
|
|
10
|
+
* with the overlay entry overriding a base entry of the
|
|
11
|
+
* same identity. So a dev overlay that re-declares the
|
|
12
|
+
* adapter's `SELF` service (or any binding) replaces it
|
|
13
|
+
* instead of emitting a duplicate wrangler rejects.
|
|
14
|
+
* - scalars / new keys → overlay wins
|
|
15
|
+
*
|
|
16
|
+
* Protecting the load-bearing keys (`main`, `assets`, …) is policy enforced by
|
|
17
|
+
* the caller (`generateWranglerConfig`), not here — this stays a generic merge.
|
|
18
|
+
*/
|
|
19
|
+
export declare function deepMergeConfig(base: Record<string, unknown>, overlay: Record<string, unknown>): Record<string, unknown>;
|
|
20
|
+
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/codegen/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep-merge for the generated wrangler config. `base` is what the adapter
|
|
3
|
+
* generates; `overlay` is the dev's `params.wrangler` escape hatch. The merge
|
|
4
|
+
* is additive so a dev can declare extra bindings without losing the adapter's
|
|
5
|
+
* invariants:
|
|
6
|
+
* - plain objects → recurse
|
|
7
|
+
* - arrays → concat, de-duplicating BOTH primitive members and
|
|
8
|
+
* object bindings by an identity key (`binding` /
|
|
9
|
+
* `pattern` / `queue` / `name`, else structural value),
|
|
10
|
+
* with the overlay entry overriding a base entry of the
|
|
11
|
+
* same identity. So a dev overlay that re-declares the
|
|
12
|
+
* adapter's `SELF` service (or any binding) replaces it
|
|
13
|
+
* instead of emitting a duplicate wrangler rejects.
|
|
14
|
+
* - scalars / new keys → overlay wins
|
|
15
|
+
*
|
|
16
|
+
* Protecting the load-bearing keys (`main`, `assets`, …) is policy enforced by
|
|
17
|
+
* the caller (`generateWranglerConfig`), not here — this stays a generic merge.
|
|
18
|
+
*/
|
|
19
|
+
export function deepMergeConfig(base, overlay) {
|
|
20
|
+
const out = { ...base };
|
|
21
|
+
for (const [key, value] of Object.entries(overlay)) {
|
|
22
|
+
const prev = out[key];
|
|
23
|
+
if (isPlainObject(prev) && isPlainObject(value)) {
|
|
24
|
+
out[key] = deepMergeConfig(prev, value);
|
|
25
|
+
}
|
|
26
|
+
else if (Array.isArray(prev) && Array.isArray(value)) {
|
|
27
|
+
out[key] = mergeArrays(prev, value);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
out[key] = value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Concat two arrays, de-duplicating by identity. Primitives dedup by value;
|
|
37
|
+
* objects dedup by an identity key (`binding`/`pattern`/`queue`/`name`, else
|
|
38
|
+
* their structural JSON) with the later (overlay) entry overriding an earlier
|
|
39
|
+
* (base) one at the base entry's position. This stops a re-declared object
|
|
40
|
+
* binding (e.g. a second `SELF` service) from producing a duplicate that
|
|
41
|
+
* wrangler rejects, while still appending genuinely distinct bindings.
|
|
42
|
+
*/
|
|
43
|
+
function mergeArrays(a, b) {
|
|
44
|
+
const out = [];
|
|
45
|
+
const seenPrimitives = new Set();
|
|
46
|
+
const indexByKey = new Map();
|
|
47
|
+
for (const item of [...a, ...b]) {
|
|
48
|
+
if (isPrimitive(item)) {
|
|
49
|
+
if (seenPrimitives.has(item))
|
|
50
|
+
continue;
|
|
51
|
+
seenPrimitives.add(item);
|
|
52
|
+
out.push(item);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const key = identityKey(item);
|
|
56
|
+
const existing = indexByKey.get(key);
|
|
57
|
+
if (existing !== undefined) {
|
|
58
|
+
out[existing] = item; // overlay (later) overrides the base entry in place
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
indexByKey.set(key, out.length);
|
|
62
|
+
out.push(item);
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Stable identity for an array's object member: the first recognized wrangler
|
|
68
|
+
* binding field (`binding` for services/KV/R2/D1/queue producers, `pattern` for
|
|
69
|
+
* routes, `queue` for consumers, `name` as a generic fallback), else the member's
|
|
70
|
+
* full structural JSON so identical objects dedup but distinct ones all survive.
|
|
71
|
+
*/
|
|
72
|
+
function identityKey(item) {
|
|
73
|
+
const rec = item;
|
|
74
|
+
for (const field of ['binding', 'pattern', 'queue', 'name']) {
|
|
75
|
+
if (typeof rec[field] === 'string')
|
|
76
|
+
return `${field}:${rec[field]}`;
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
return `json:${JSON.stringify(item)}`;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return `ref:${String(item)}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function isPlainObject(v) {
|
|
86
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
87
|
+
}
|
|
88
|
+
function isPrimitive(v) {
|
|
89
|
+
return v === null || (typeof v !== 'object' && typeof v !== 'function');
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/codegen/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAC7B,IAA6B,EAC7B,OAAgC;IAEhC,MAAM,GAAG,GAA4B,EAAE,GAAG,IAAI,EAAE,CAAA;IAChD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;QACrB,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAChD,GAAG,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QACzC,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,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AG,IAA+B,CAAA;IAC3C,KAAK,MAAM,KAAK,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;QAC5D,IAAI,OAAO,GAAG,CAAC,KAAK,CAAC,KAAK,QAAQ;YAAE,OAAO,GAAG,KAAK,IAAI,GAAG,CAAC,KAAK,CAAW,EAAE,CAAA;IAC/E,CAAC;IACD,IAAI,CAAC;QACH,OAAO,QAAQ,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAA;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAA;IAC9B,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,CAAU;IAC/B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AACjE,CAAC;AAED,SAAS,WAAW,CAAC,CAAU;IAC7B,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,UAAU,CAAC,CAAA;AACzE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codegen for the Cloudflare Worker entry (`.astrale/worker.gen.ts`).
|
|
3
|
+
*
|
|
4
|
+
* The dev writes only schema/methods/views/functions; this generates the
|
|
5
|
+
* `export default { fetch }` plumbing the adapter owns. Key properties:
|
|
6
|
+
*
|
|
7
|
+
* • Per-request `url` = the live serving origin (`scheme://host`). It is passed
|
|
8
|
+
* only to `createRemoteServer({ url })`; the SDK stamps every
|
|
9
|
+
* `binding.remoteUrl` from that single value at spec-build time — so deployed
|
|
10
|
+
* Function nodes point back at THIS worker with zero hardcoded URLs.
|
|
11
|
+
* • Self-issued JWKS: a Worker can't fetch its own hostname; the verifier
|
|
12
|
+
* resolves a credential whose `iss` is this worker from the in-memory key,
|
|
13
|
+
* so no self-fetch is attempted (the worker's JWKS is served as a normal
|
|
14
|
+
* route by createRemoteServer).
|
|
15
|
+
* • Self-binding (autobinding): when a handler calls back into its OWN domain
|
|
16
|
+
* (`ctx.callRemote`), the redirect resolves to this worker's own host — a
|
|
17
|
+
* forbidden same-host subrequest. We route those through the `SELF` service
|
|
18
|
+
* binding instead.
|
|
19
|
+
* • SPA: `/ui/*` is served from the `ASSETS` binding (or proxied to Vite in
|
|
20
|
+
* dev via `VIEW_DEV_URL`).
|
|
21
|
+
*/
|
|
22
|
+
export interface WorkerCodegenOptions {
|
|
23
|
+
origin: string;
|
|
24
|
+
postInstall?: string;
|
|
25
|
+
requires: readonly string[];
|
|
26
|
+
hasViews: boolean;
|
|
27
|
+
hasFunctions: boolean;
|
|
28
|
+
hasClient: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function generateWorkerEntry(opts: WorkerCodegenOptions): string;
|
|
31
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/codegen/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;IAC3B,QAAQ,EAAE,OAAO,CAAA;IACjB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAyEtE"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codegen for the Cloudflare Worker entry (`.astrale/worker.gen.ts`).
|
|
3
|
+
*
|
|
4
|
+
* The dev writes only schema/methods/views/functions; this generates the
|
|
5
|
+
* `export default { fetch }` plumbing the adapter owns. Key properties:
|
|
6
|
+
*
|
|
7
|
+
* • Per-request `url` = the live serving origin (`scheme://host`). It is passed
|
|
8
|
+
* only to `createRemoteServer({ url })`; the SDK stamps every
|
|
9
|
+
* `binding.remoteUrl` from that single value at spec-build time — so deployed
|
|
10
|
+
* Function nodes point back at THIS worker with zero hardcoded URLs.
|
|
11
|
+
* • Self-issued JWKS: a Worker can't fetch its own hostname; the verifier
|
|
12
|
+
* resolves a credential whose `iss` is this worker from the in-memory key,
|
|
13
|
+
* so no self-fetch is attempted (the worker's JWKS is served as a normal
|
|
14
|
+
* route by createRemoteServer).
|
|
15
|
+
* • Self-binding (autobinding): when a handler calls back into its OWN domain
|
|
16
|
+
* (`ctx.callRemote`), the redirect resolves to this worker's own host — a
|
|
17
|
+
* forbidden same-host subrequest. We route those through the `SELF` service
|
|
18
|
+
* binding instead.
|
|
19
|
+
* • SPA: `/ui/*` is served from the `ASSETS` binding (or proxied to Vite in
|
|
20
|
+
* dev via `VIEW_DEV_URL`).
|
|
21
|
+
*/
|
|
22
|
+
export function generateWorkerEntry(opts) {
|
|
23
|
+
const optionalImports = [
|
|
24
|
+
opts.hasViews ? `import { views } from '../views'` : `const views = undefined`,
|
|
25
|
+
opts.hasFunctions ? `import { functions } from '../functions'` : `const functions = undefined`,
|
|
26
|
+
].join('\n');
|
|
27
|
+
const postInstallLine = opts.postInstall !== undefined
|
|
28
|
+
? `const POST_INSTALL = ${JSON.stringify(opts.postInstall)}`
|
|
29
|
+
: `const POST_INSTALL = undefined`;
|
|
30
|
+
return `// AUTO-GENERATED by @astrale-os/adapter-cloudflare — do not edit.
|
|
31
|
+
// Regenerated on every \`astrale-domain dev|deploy\`. Edit schema/methods/views
|
|
32
|
+
// instead. (origin: ${opts.origin})
|
|
33
|
+
import { defineRemoteDomain } from '@astrale-os/sdk'
|
|
34
|
+
import { createWorkerEntry } from '@astrale-os/sdk/server'
|
|
35
|
+
|
|
36
|
+
import { schema } from '../schema'
|
|
37
|
+
import { methods } from '../methods'
|
|
38
|
+
${optionalImports}
|
|
39
|
+
import { PRIVATE_JWK } from './identity'
|
|
40
|
+
|
|
41
|
+
const REQUIRES = ${JSON.stringify(opts.requires)}
|
|
42
|
+
${postInstallLine}
|
|
43
|
+
|
|
44
|
+
interface Env {
|
|
45
|
+
WORKER_URL?: string
|
|
46
|
+
ASSETS?: { fetch(request: Request): Promise<Response> }
|
|
47
|
+
SELF?: { fetch(request: Request): Promise<Response> }
|
|
48
|
+
VIEW_DEV_URL?: string
|
|
49
|
+
[key: string]: unknown
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// All the shared worker plumbing — JWKS self-fetch shim, SELF-binding routing,
|
|
53
|
+
// per-URL app cache, canonical iss resolution — lives in createWorkerEntry.
|
|
54
|
+
export default createWorkerEntry<Env>({
|
|
55
|
+
// The worker's serving URL = its identity (iss). Prefer the adapter-injected
|
|
56
|
+
// WORKER_URL (pins one canonical host for routed deploys, so iss stays stable
|
|
57
|
+
// even when also reachable via *.workers.dev); fall back to the per-request
|
|
58
|
+
// host for dev / workers.dev-only (single-host → it IS the canonical URL).
|
|
59
|
+
resolveUrl: (env, requestOrigin) => env.WORKER_URL ?? requestOrigin,
|
|
60
|
+
selfBinding: (env) => env.SELF,
|
|
61
|
+
build: (url, env) => {
|
|
62
|
+
const domain = defineRemoteDomain()({
|
|
63
|
+
schema,
|
|
64
|
+
methods,
|
|
65
|
+
...(views ? { views } : {}),
|
|
66
|
+
...(functions ? { remoteFunctions: functions } : {}),
|
|
67
|
+
})
|
|
68
|
+
return {
|
|
69
|
+
domain,
|
|
70
|
+
deps: env,
|
|
71
|
+
url,
|
|
72
|
+
privateKey: PRIVATE_JWK,
|
|
73
|
+
...(POST_INSTALL ? { postInstall: POST_INSTALL } : {}),
|
|
74
|
+
...(REQUIRES.length ? { requires: REQUIRES } : {}),
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
// SPA under /ui/* (views with a client renderer).
|
|
78
|
+
before: (env, url, request) => {
|
|
79
|
+
if (env.ASSETS && (url.pathname === '/ui' || url.pathname.startsWith('/ui/'))) {
|
|
80
|
+
if (env.VIEW_DEV_URL) {
|
|
81
|
+
const devBase = env.VIEW_DEV_URL.replace(/\\/$/, '')
|
|
82
|
+
return fetch(new Request(\`\${devBase}\${url.pathname}\${url.search}\`, request))
|
|
83
|
+
}
|
|
84
|
+
const stripped = url.pathname.replace(/^\\/ui\\/?/, '/')
|
|
85
|
+
const rewritten = new URL(stripped + url.search, url.origin)
|
|
86
|
+
return env.ASSETS.fetch(new Request(rewritten, request))
|
|
87
|
+
}
|
|
88
|
+
return undefined
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/codegen/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAWH,MAAM,UAAU,mBAAmB,CAAC,IAA0B;IAC5D,MAAM,eAAe,GAAG;QACtB,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,yBAAyB;QAC9E,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC,6BAA6B;KAC/F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEZ,MAAM,eAAe,GACnB,IAAI,CAAC,WAAW,KAAK,SAAS;QAC5B,CAAC,CAAC,wBAAwB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QAC5D,CAAC,CAAC,gCAAgC,CAAA;IAEtC,OAAO;;uBAEc,IAAI,CAAC,MAAM;;;;;;EAMhC,eAAe;;;mBAGE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;EAC9C,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDhB,CAAA;AACD,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codegen for the Worker config (`.astrale/wrangler.gen.jsonc`). This is the
|
|
3
|
+
* `wrangler.jsonc` that used to be hand-copied into every domain — now an
|
|
4
|
+
* internal adapter detail the dev never sees.
|
|
5
|
+
*
|
|
6
|
+
* `main` is `./worker.gen.ts` (same dir). `assets.directory` is `../dist-client`
|
|
7
|
+
* (the project's Vite build). A `SELF` service binding enables autobinding
|
|
8
|
+
* (a handler calling back into its own domain). Custom-domain deploys attach a
|
|
9
|
+
* `custom_domain` route; otherwise the Worker ships to `*.workers.dev`.
|
|
10
|
+
*
|
|
11
|
+
* A dev's `params.wrangler` escape hatch is deep-merged on top of this base
|
|
12
|
+
* (extra bindings: KV, R2, D1, queues, …) — see `mergeUserConfig`.
|
|
13
|
+
*/
|
|
14
|
+
export interface WranglerCodegenOptions {
|
|
15
|
+
workerName: string;
|
|
16
|
+
/** Full custom hostname for a routed deploy (e.g. 'crm.acme.dev'). */
|
|
17
|
+
route?: string;
|
|
18
|
+
/** Whether the project has a built client SPA to serve under /ui/*. */
|
|
19
|
+
hasClient: boolean;
|
|
20
|
+
/** Plain (non-secret) vars to bake in. */
|
|
21
|
+
vars?: Record<string, string>;
|
|
22
|
+
/** Add the SELF service binding (autobinding). */
|
|
23
|
+
selfBinding: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Raw wrangler config to deep-merge over the generated base — the escape
|
|
26
|
+
* hatch for extra bindings (KV, R2, D1, queues, service bindings, extra
|
|
27
|
+
* `compatibility_flags`, cron `triggers`, …). Arrays concat; new keys are
|
|
28
|
+
* added as-is. The adapter-owned keys `name`, `main`, `assets`, `routes` are
|
|
29
|
+
* rejected (throws) — use `workerName` / `route` instead.
|
|
30
|
+
*/
|
|
31
|
+
wrangler?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
export declare function generateWranglerConfig(opts: WranglerCodegenOptions): string;
|
|
34
|
+
//# sourceMappingURL=wrangler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler.d.ts","sourceRoot":"","sources":["../../src/codegen/wrangler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uEAAuE;IACvE,SAAS,EAAE,OAAO,CAAA;IAClB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,kDAAkD;IAClD,WAAW,EAAE,OAAO,CAAA;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AAID,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,sBAAsB,GAAG,MAAM,CAiC3E"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codegen for the Worker config (`.astrale/wrangler.gen.jsonc`). This is the
|
|
3
|
+
* `wrangler.jsonc` that used to be hand-copied into every domain — now an
|
|
4
|
+
* internal adapter detail the dev never sees.
|
|
5
|
+
*
|
|
6
|
+
* `main` is `./worker.gen.ts` (same dir). `assets.directory` is `../dist-client`
|
|
7
|
+
* (the project's Vite build). A `SELF` service binding enables autobinding
|
|
8
|
+
* (a handler calling back into its own domain). Custom-domain deploys attach a
|
|
9
|
+
* `custom_domain` route; otherwise the Worker ships to `*.workers.dev`.
|
|
10
|
+
*
|
|
11
|
+
* A dev's `params.wrangler` escape hatch is deep-merged on top of this base
|
|
12
|
+
* (extra bindings: KV, R2, D1, queues, …) — see `mergeUserConfig`.
|
|
13
|
+
*/
|
|
14
|
+
import { deepMergeConfig } from './merge';
|
|
15
|
+
const COMPATIBILITY_DATE = '2025-03-01';
|
|
16
|
+
export function generateWranglerConfig(opts) {
|
|
17
|
+
const config = {
|
|
18
|
+
name: opts.workerName,
|
|
19
|
+
main: './worker.gen.ts',
|
|
20
|
+
compatibility_date: COMPATIBILITY_DATE,
|
|
21
|
+
compatibility_flags: ['nodejs_compat', 'nodejs_compat_populate_process_env'],
|
|
22
|
+
workers_dev: true,
|
|
23
|
+
observability: { enabled: true },
|
|
24
|
+
};
|
|
25
|
+
if (opts.route) {
|
|
26
|
+
config.routes = [{ pattern: opts.route, custom_domain: true }];
|
|
27
|
+
}
|
|
28
|
+
if (opts.hasClient) {
|
|
29
|
+
config.assets = {
|
|
30
|
+
directory: '../dist-client',
|
|
31
|
+
binding: 'ASSETS',
|
|
32
|
+
not_found_handling: 'single-page-application',
|
|
33
|
+
run_worker_first: true,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (opts.selfBinding) {
|
|
37
|
+
config.services = [{ binding: 'SELF', service: opts.workerName }];
|
|
38
|
+
}
|
|
39
|
+
if (opts.vars && Object.keys(opts.vars).length > 0) {
|
|
40
|
+
config.vars = opts.vars;
|
|
41
|
+
}
|
|
42
|
+
const merged = opts.wrangler ? mergeUserConfig(config, opts.wrangler) : config;
|
|
43
|
+
return JSON.stringify(merged, null, 2) + '\n';
|
|
44
|
+
}
|
|
45
|
+
/** Keys the adapter owns and won't let `params.wrangler` clobber. */
|
|
46
|
+
const ADAPTER_OWNED_KEYS = ['name', 'main', 'assets', 'routes'];
|
|
47
|
+
/**
|
|
48
|
+
* Deep-merge the dev's raw wrangler overlay over the generated config, after
|
|
49
|
+
* refusing any attempt to override an adapter-owned key. Throwing (rather than
|
|
50
|
+
* silently dropping) keeps a stray `main` from breaking the Worker unnoticed.
|
|
51
|
+
*/
|
|
52
|
+
function mergeUserConfig(base, user) {
|
|
53
|
+
const collisions = ADAPTER_OWNED_KEYS.filter((k) => k in user);
|
|
54
|
+
if (collisions.length > 0) {
|
|
55
|
+
throw new Error(`wrangler: cannot override adapter-managed key(s): ${collisions.join(', ')}. ` +
|
|
56
|
+
'Use `workerName` for the worker name and `route` for routing; ' +
|
|
57
|
+
'`main` and `assets` are generated by the adapter.');
|
|
58
|
+
}
|
|
59
|
+
return deepMergeConfig(base, user);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=wrangler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler.js","sourceRoot":"","sources":["../../src/codegen/wrangler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAsBzC,MAAM,kBAAkB,GAAG,YAAY,CAAA;AAEvC,MAAM,UAAU,sBAAsB,CAAC,IAA4B;IACjE,MAAM,MAAM,GAA4B;QACtC,IAAI,EAAE,IAAI,CAAC,UAAU;QACrB,IAAI,EAAE,iBAAiB;QACvB,kBAAkB,EAAE,kBAAkB;QACtC,mBAAmB,EAAE,CAAC,eAAe,EAAE,oCAAoC,CAAC;QAC5E,WAAW,EAAE,IAAI;QACjB,aAAa,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;KACjC,CAAA;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IAChE,CAAC;IAED,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,MAAM,CAAC,MAAM,GAAG;YACd,SAAS,EAAE,gBAAgB;YAC3B,OAAO,EAAE,QAAQ;YACjB,kBAAkB,EAAE,yBAAyB;YAC7C,gBAAgB,EAAE,IAAI;SACvB,CAAA;IACH,CAAC;IAED,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;IACnE,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnD,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;IACzB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IAC9E,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAA;AAC/C,CAAC;AAED,qEAAqE;AACrE,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;AAE/D;;;;GAIG;AACH,SAAS,eAAe,CACtB,IAA6B,EAC7B,IAA6B;IAE7B,MAAM,UAAU,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAA;IAC9D,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,qDAAqD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YAC5E,gEAAgE;YAChE,mDAAmD,CACtD,CAAA;IACH,CAAC;IACD,OAAO,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACpC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@astrale-os/adapter-cloudflare` — deploy an Astrale domain as a standalone
|
|
3
|
+
* Cloudflare Worker.
|
|
4
|
+
*
|
|
5
|
+
* import { cloudflare } from '@astrale-os/adapter-cloudflare'
|
|
6
|
+
*
|
|
7
|
+
* adapter: cloudflare({
|
|
8
|
+
* dev: { secrets: '.env.dev' },
|
|
9
|
+
* prod: { route: 'crm.acme.dev', secrets: '.env.prod' },
|
|
10
|
+
* })
|
|
11
|
+
*
|
|
12
|
+
* `dev` runs `wrangler dev` locally; an env with no `route` ships to
|
|
13
|
+
* `*.workers.dev`; an env with a `route` ships to that custom domain.
|
|
14
|
+
*/
|
|
15
|
+
export { cloudflare } from './cloudflare';
|
|
16
|
+
export type { CloudflareParams } from './params';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@astrale-os/adapter-cloudflare` — deploy an Astrale domain as a standalone
|
|
3
|
+
* Cloudflare Worker.
|
|
4
|
+
*
|
|
5
|
+
* import { cloudflare } from '@astrale-os/adapter-cloudflare'
|
|
6
|
+
*
|
|
7
|
+
* adapter: cloudflare({
|
|
8
|
+
* dev: { secrets: '.env.dev' },
|
|
9
|
+
* prod: { route: 'crm.acme.dev', secrets: '.env.prod' },
|
|
10
|
+
* })
|
|
11
|
+
*
|
|
12
|
+
* `dev` runs `wrangler dev` locally; an env with no `route` ships to
|
|
13
|
+
* `*.workers.dev`; an env with a `route` ships to that custom domain.
|
|
14
|
+
*/
|
|
15
|
+
export { cloudflare } from './cloudflare';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/params.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `CloudflareParams` — the provider-typed config for the Cloudflare adapter.
|
|
3
|
+
*
|
|
4
|
+
* One type covers every env; per-env differences are just optional fields. The
|
|
5
|
+
* same `{ dev, prod, canary, … }` map a developer writes in `astrale.config.ts`
|
|
6
|
+
* is `Record<string, CloudflareParams>`.
|
|
7
|
+
*
|
|
8
|
+
* Three deployment shapes fall out of which fields are set:
|
|
9
|
+
* • dev (local) — `watch()` runs `wrangler dev`; URL = http://localhost:<port>
|
|
10
|
+
* • dev-remote — `deploy()` with no `route`; URL = https://<name>.<sub>.workers.dev
|
|
11
|
+
* • remote (custom) — `deploy()` with `route`; URL = https://<route>
|
|
12
|
+
*/
|
|
13
|
+
export interface CloudflareParams {
|
|
14
|
+
/**
|
|
15
|
+
* Custom route / hostname for a routed deploy, e.g. `'crm.acme.dev'`. Omit to
|
|
16
|
+
* deploy to `*.workers.dev`. Ignored by local `wrangler dev` (URL is
|
|
17
|
+
* localhost) but still used as the placeholder base domain there.
|
|
18
|
+
*/
|
|
19
|
+
route?: string;
|
|
20
|
+
/** Gitignored secrets file (whole contents = secrets), e.g. `'.env.dev'`. */
|
|
21
|
+
secrets?: string;
|
|
22
|
+
/** Local dev port for `wrangler dev`. Default 8787. */
|
|
23
|
+
port?: number;
|
|
24
|
+
/** Override the Worker name. Default: derived from the domain origin. */
|
|
25
|
+
workerName?: string;
|
|
26
|
+
/** Run `wrangler dev --remote` (edge isolate) instead of local workerd. */
|
|
27
|
+
remote?: boolean;
|
|
28
|
+
/** Extra plain (non-secret) vars to inject as Worker vars. */
|
|
29
|
+
vars?: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Escape hatch: raw wrangler config deep-merged over the generated base. Use
|
|
32
|
+
* it to declare extra bindings the adapter has no typed field for — KV, R2,
|
|
33
|
+
* D1, queues, service bindings, extra `compatibility_flags`, cron `triggers`,
|
|
34
|
+
* Hyperdrive, etc.
|
|
35
|
+
*
|
|
36
|
+
* wrangler: {
|
|
37
|
+
* kv_namespaces: [{ binding: 'CACHE', id: '<kv-id>' }],
|
|
38
|
+
* r2_buckets: [{ binding: 'FILES', bucket_name: 'my-bucket' }],
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* The merge is additive: arrays concat (so your `services` keep the adapter's
|
|
42
|
+
* `SELF` binding and your `compatibility_flags` keep `nodejs_compat`); new
|
|
43
|
+
* keys are added as-is. The adapter-owned keys `name`, `main`, `assets`,
|
|
44
|
+
* `routes` are rejected — use `workerName` and `route` instead. Avoid
|
|
45
|
+
* the reserved binding names `SELF` and `ASSETS`. Durable Objects need extra
|
|
46
|
+
* worker-entry codegen and aren't supported through this field yet.
|
|
47
|
+
*/
|
|
48
|
+
wrangler?: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../src/params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC"}
|
package/dist/params.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.js","sourceRoot":"","sources":["../src/params.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure parsers for `wrangler` stdout. Kept separate from the process-spawning in
|
|
3
|
+
* `wrangler-cli.ts` so the brittle bit — scraping wrangler's human output — is
|
|
4
|
+
* unit-testable against captured fixtures without shelling out.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Local dev URL from `wrangler dev` output, normalized to an origin on the given
|
|
8
|
+
* port. Returns `undefined` when the output hasn't reported readiness yet.
|
|
9
|
+
*
|
|
10
|
+
* The fallback (when no explicit "Ready on" line) only accepts a localhost URL
|
|
11
|
+
* on the EXPECTED port — wrangler may print unrelated localhost URLs (e.g. an
|
|
12
|
+
* inspector/devtools endpoint on a different port) before readiness, and taking
|
|
13
|
+
* one of those would point `astrale instance install <url>` at a dead endpoint.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseDevReadyUrl(text: string, port: number): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Authoritative public URL from `wrangler deploy` output. A custom-domain
|
|
18
|
+
* `route` wins (the deploy attaches it); otherwise the printed `*.workers.dev`
|
|
19
|
+
* URL. Returns `undefined` when neither is available (caller surfaces the raw
|
|
20
|
+
* output).
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseDeployUrl(text: string, route?: string): string | undefined;
|
|
23
|
+
/** Normalize a local dev URL to an origin: `0.0.0.0` → `localhost`, fill the port. */
|
|
24
|
+
export declare function normalizeLocal(url: string, port: number): string;
|
|
25
|
+
//# sourceMappingURL=parse-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-output.d.ts","sourceRoot":"","sources":["../src/parse-output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW/E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI/E;AAED,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAShE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure parsers for `wrangler` stdout. Kept separate from the process-spawning in
|
|
3
|
+
* `wrangler-cli.ts` so the brittle bit — scraping wrangler's human output — is
|
|
4
|
+
* unit-testable against captured fixtures without shelling out.
|
|
5
|
+
*/
|
|
6
|
+
const READY_RE = /(?:Ready on|Listening on|⎔.*?at)\s+(https?:\/\/[^\s]+)/i;
|
|
7
|
+
const WORKERS_DEV_RE = /(https:\/\/[^\s]+\.workers\.dev)/i;
|
|
8
|
+
/**
|
|
9
|
+
* Local dev URL from `wrangler dev` output, normalized to an origin on the given
|
|
10
|
+
* port. Returns `undefined` when the output hasn't reported readiness yet.
|
|
11
|
+
*
|
|
12
|
+
* The fallback (when no explicit "Ready on" line) only accepts a localhost URL
|
|
13
|
+
* on the EXPECTED port — wrangler may print unrelated localhost URLs (e.g. an
|
|
14
|
+
* inspector/devtools endpoint on a different port) before readiness, and taking
|
|
15
|
+
* one of those would point `astrale instance install <url>` at a dead endpoint.
|
|
16
|
+
*/
|
|
17
|
+
export function parseDevReadyUrl(text, port) {
|
|
18
|
+
const ready = READY_RE.exec(text);
|
|
19
|
+
if (ready)
|
|
20
|
+
return normalizeLocal(ready[1], port);
|
|
21
|
+
// `port` is a number, so it's safe to interpolate into the pattern. The
|
|
22
|
+
// negative lookahead stops `:8787` from matching inside `:87870`.
|
|
23
|
+
const localhostOnPort = new RegExp(`(https?://(?:localhost|127\\.0\\.0\\.1):${port})(?![0-9])`, 'i');
|
|
24
|
+
const m = localhostOnPort.exec(text);
|
|
25
|
+
return m ? normalizeLocal(m[1], port) : undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Authoritative public URL from `wrangler deploy` output. A custom-domain
|
|
29
|
+
* `route` wins (the deploy attaches it); otherwise the printed `*.workers.dev`
|
|
30
|
+
* URL. Returns `undefined` when neither is available (caller surfaces the raw
|
|
31
|
+
* output).
|
|
32
|
+
*/
|
|
33
|
+
export function parseDeployUrl(text, route) {
|
|
34
|
+
if (route)
|
|
35
|
+
return `https://${route.replace(/\/.*$/, '')}`;
|
|
36
|
+
const m = WORKERS_DEV_RE.exec(text);
|
|
37
|
+
return m ? m[1] : undefined;
|
|
38
|
+
}
|
|
39
|
+
/** Normalize a local dev URL to an origin: `0.0.0.0` → `localhost`, fill the port. */
|
|
40
|
+
export function normalizeLocal(url, port) {
|
|
41
|
+
try {
|
|
42
|
+
const u = new URL(url);
|
|
43
|
+
if (u.hostname === '0.0.0.0')
|
|
44
|
+
u.hostname = 'localhost';
|
|
45
|
+
if (!u.port)
|
|
46
|
+
u.port = String(port);
|
|
47
|
+
return u.origin;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return `http://localhost:${port}`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=parse-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-output.js","sourceRoot":"","sources":["../src/parse-output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,QAAQ,GAAG,yDAAyD,CAAA;AAC1E,MAAM,cAAc,GAAG,mCAAmC,CAAA;AAE1D;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,IAAY;IACzD,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjC,IAAI,KAAK;QAAE,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,IAAI,CAAC,CAAA;IACjD,wEAAwE;IACxE,kEAAkE;IAClE,MAAM,eAAe,GAAG,IAAI,MAAM,CAChC,2CAA2C,IAAI,YAAY,EAC3D,GAAG,CACJ,CAAA;IACD,MAAM,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACpC,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,KAAc;IACzD,IAAI,KAAK;QAAE,OAAO,WAAW,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAA;IACzD,MAAM,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACnC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AAC7B,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,IAAY;IACtD,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QACtB,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS;YAAE,CAAC,CAAC,QAAQ,GAAG,WAAW,CAAA;QACtD,IAAI,CAAC,CAAC,CAAC,IAAI;YAAE,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;QAClC,OAAO,CAAC,CAAC,MAAM,CAAA;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,oBAAoB,IAAI,EAAE,CAAA;IACnC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin wrapper around the `wrangler` binary — the only place the adapter shells
|
|
3
|
+
* out. `watch` runs `wrangler dev` (local workerd) and resolves once the worker
|
|
4
|
+
* reports its local URL; `deploy` runs `wrangler deploy` and parses the
|
|
5
|
+
* authoritative public URL from the output; secrets go through `wrangler secret
|
|
6
|
+
* bulk`. The wrangler binary is resolved from the project's `node_modules/.bin`,
|
|
7
|
+
* falling back to `npx wrangler`.
|
|
8
|
+
*/
|
|
9
|
+
export interface DevHandle {
|
|
10
|
+
url: string;
|
|
11
|
+
stop(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare function runWranglerDev(args: {
|
|
14
|
+
projectDir: string;
|
|
15
|
+
configPath: string;
|
|
16
|
+
port: number;
|
|
17
|
+
remote: boolean;
|
|
18
|
+
onReload: () => void;
|
|
19
|
+
onLog?: (line: string) => void;
|
|
20
|
+
}): Promise<DevHandle>;
|
|
21
|
+
export interface DeployArgs {
|
|
22
|
+
configPath: string;
|
|
23
|
+
/** SELF-less config for the first-deploy two-pass (see `deployWithSelfFallback`). */
|
|
24
|
+
fallbackConfigPath?: string;
|
|
25
|
+
/** The worker's own name, to scope the self-binding-missing detection. */
|
|
26
|
+
workerName?: string;
|
|
27
|
+
route?: string;
|
|
28
|
+
onLog?: (line: string) => void;
|
|
29
|
+
}
|
|
30
|
+
export declare function runWranglerDeploy(args: DeployArgs & {
|
|
31
|
+
projectDir: string;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
url: string;
|
|
34
|
+
raw: string;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Deploy with a one-time SELF-binding first-deploy recovery. A fresh worker that
|
|
38
|
+
* declares a `services: SELF` binding can't deploy (its own script doesn't exist
|
|
39
|
+
* yet); on THAT specific failure we deploy the SELF-less fallback to create the
|
|
40
|
+
* script, then redeploy WITH SELF so autobinding works. Steady state (every
|
|
41
|
+
* deploy after the first) is a single pass. The `deploy` runner is injected so
|
|
42
|
+
* the orchestration is unit-testable without shelling out.
|
|
43
|
+
*/
|
|
44
|
+
export declare function deployWithSelfFallback(deploy: (configPath: string) => Promise<{
|
|
45
|
+
code: number;
|
|
46
|
+
out: string;
|
|
47
|
+
}>, args: DeployArgs): Promise<{
|
|
48
|
+
url: string;
|
|
49
|
+
raw: string;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* True when wrangler failed specifically because the worker's OWN `SELF` service
|
|
53
|
+
* binding can't resolve yet (first deploy of a fresh script). Requires the
|
|
54
|
+
* worker name so an unrelated missing-service error doesn't trigger the two-pass.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isSelfBindingMissing(out: string, workerName?: string): boolean;
|
|
57
|
+
export declare function bulkPutSecrets(args: {
|
|
58
|
+
projectDir: string;
|
|
59
|
+
configPath: string;
|
|
60
|
+
secrets: Record<string, string>;
|
|
61
|
+
onLog?: (line: string) => void;
|
|
62
|
+
}): Promise<void>;
|
|
63
|
+
//# sourceMappingURL=wrangler-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler-cli.d.ts","sourceRoot":"","sources":["../src/wrangler-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B,GAAG,OAAO,CAAC,SAAS,CAAC,CAkErB;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,qFAAqF;IACrF,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,UAAU,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,GACxC,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAKvC;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,EACtE,IAAI,EAAE,UAAU,GACf,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAwBvC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAO9E;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhB"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin wrapper around the `wrangler` binary — the only place the adapter shells
|
|
3
|
+
* out. `watch` runs `wrangler dev` (local workerd) and resolves once the worker
|
|
4
|
+
* reports its local URL; `deploy` runs `wrangler deploy` and parses the
|
|
5
|
+
* authoritative public URL from the output; secrets go through `wrangler secret
|
|
6
|
+
* bulk`. The wrangler binary is resolved from the project's `node_modules/.bin`,
|
|
7
|
+
* falling back to `npx wrangler`.
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from 'node:child_process';
|
|
10
|
+
import { existsSync } from 'node:fs';
|
|
11
|
+
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
12
|
+
import { tmpdir } from 'node:os';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
import { parseDeployUrl, parseDevReadyUrl } from './parse-output';
|
|
15
|
+
function wranglerCommand(projectDir) {
|
|
16
|
+
const local = join(projectDir, 'node_modules', '.bin', 'wrangler');
|
|
17
|
+
if (existsSync(local))
|
|
18
|
+
return { cmd: local, prefix: [] };
|
|
19
|
+
return { cmd: 'npx', prefix: ['--yes', 'wrangler'] };
|
|
20
|
+
}
|
|
21
|
+
export async function runWranglerDev(args) {
|
|
22
|
+
const { cmd, prefix } = wranglerCommand(args.projectDir);
|
|
23
|
+
const wranglerArgs = [
|
|
24
|
+
...prefix,
|
|
25
|
+
'dev',
|
|
26
|
+
'--config',
|
|
27
|
+
args.configPath,
|
|
28
|
+
'--port',
|
|
29
|
+
String(args.port),
|
|
30
|
+
'--local-protocol',
|
|
31
|
+
'http',
|
|
32
|
+
'--ip',
|
|
33
|
+
'127.0.0.1',
|
|
34
|
+
...(args.remote ? ['--remote'] : []),
|
|
35
|
+
];
|
|
36
|
+
const child = spawn(cmd, wranglerArgs, {
|
|
37
|
+
cwd: args.projectDir,
|
|
38
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
39
|
+
env: { ...process.env, WRANGLER_SEND_METRICS: 'false' },
|
|
40
|
+
});
|
|
41
|
+
const fallbackUrl = `http://localhost:${args.port}`;
|
|
42
|
+
let resolved = false;
|
|
43
|
+
const url = await new Promise((resolve, reject) => {
|
|
44
|
+
const onData = (buf) => {
|
|
45
|
+
const text = buf.toString();
|
|
46
|
+
for (const line of text.split('\n')) {
|
|
47
|
+
if (line.trim())
|
|
48
|
+
args.onLog?.(line);
|
|
49
|
+
}
|
|
50
|
+
if (!resolved) {
|
|
51
|
+
const ready = parseDevReadyUrl(text, args.port);
|
|
52
|
+
if (ready) {
|
|
53
|
+
resolved = true;
|
|
54
|
+
resolve(ready);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (/Reloading|Detected changes|Updated/i.test(text)) {
|
|
58
|
+
args.onReload();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
child.stdout?.on('data', onData);
|
|
62
|
+
child.stderr?.on('data', onData);
|
|
63
|
+
child.on('exit', (code) => {
|
|
64
|
+
if (!resolved) {
|
|
65
|
+
resolved = true;
|
|
66
|
+
reject(new Error(`wrangler dev exited before becoming ready (code ${code ?? 'null'}).`));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
child.on('error', (err) => {
|
|
70
|
+
if (!resolved) {
|
|
71
|
+
resolved = true;
|
|
72
|
+
reject(err);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
// Safety net: if we never matched a URL but the process is alive, assume the
|
|
76
|
+
// conventional localhost URL after a grace period.
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
if (!resolved && child.exitCode === null) {
|
|
79
|
+
resolved = true;
|
|
80
|
+
resolve(fallbackUrl);
|
|
81
|
+
}
|
|
82
|
+
}, 15_000).unref?.();
|
|
83
|
+
});
|
|
84
|
+
return { url, stop: () => stopChild(child) };
|
|
85
|
+
}
|
|
86
|
+
export async function runWranglerDeploy(args) {
|
|
87
|
+
const { cmd, prefix } = wranglerCommand(args.projectDir);
|
|
88
|
+
const deploy = (configPath) => runCapture(cmd, [...prefix, 'deploy', '--config', configPath], args.projectDir, args.onLog);
|
|
89
|
+
return deployWithSelfFallback(deploy, args);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Deploy with a one-time SELF-binding first-deploy recovery. A fresh worker that
|
|
93
|
+
* declares a `services: SELF` binding can't deploy (its own script doesn't exist
|
|
94
|
+
* yet); on THAT specific failure we deploy the SELF-less fallback to create the
|
|
95
|
+
* script, then redeploy WITH SELF so autobinding works. Steady state (every
|
|
96
|
+
* deploy after the first) is a single pass. The `deploy` runner is injected so
|
|
97
|
+
* the orchestration is unit-testable without shelling out.
|
|
98
|
+
*/
|
|
99
|
+
export async function deployWithSelfFallback(deploy, args) {
|
|
100
|
+
let { code, out } = await deploy(args.configPath);
|
|
101
|
+
if (code !== 0 && args.fallbackConfigPath && isSelfBindingMissing(out, args.workerName)) {
|
|
102
|
+
args.onLog?.('SELF service binding not resolvable yet (first deploy) — creating the worker, then re-binding SELF');
|
|
103
|
+
const first = await deploy(args.fallbackConfigPath);
|
|
104
|
+
if (first.code !== 0) {
|
|
105
|
+
throw new Error(`wrangler deploy (no-self pass) failed (code ${first.code}):\n${first.out.slice(-2000)}`);
|
|
106
|
+
}
|
|
107
|
+
;
|
|
108
|
+
({ code, out } = await deploy(args.configPath));
|
|
109
|
+
}
|
|
110
|
+
if (code !== 0) {
|
|
111
|
+
throw new Error(`wrangler deploy failed (code ${code}):\n${out.slice(-2000)}`);
|
|
112
|
+
}
|
|
113
|
+
const url = parseDeployUrl(out, args.route);
|
|
114
|
+
if (!url) {
|
|
115
|
+
throw new Error(`could not determine deployed URL from wrangler output:\n${out.slice(-2000)}`);
|
|
116
|
+
}
|
|
117
|
+
return { url, raw: out };
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* True when wrangler failed specifically because the worker's OWN `SELF` service
|
|
121
|
+
* binding can't resolve yet (first deploy of a fresh script). Requires the
|
|
122
|
+
* worker name so an unrelated missing-service error doesn't trigger the two-pass.
|
|
123
|
+
*/
|
|
124
|
+
export function isSelfBindingMissing(out, workerName) {
|
|
125
|
+
const bindingError = /could not resolve binding/i.test(out) ||
|
|
126
|
+
/service\b[^\n]*\bnot found/i.test(out) ||
|
|
127
|
+
/script\b[^\n]*\bnot found/i.test(out);
|
|
128
|
+
if (!bindingError || !/\bSELF\b/.test(out))
|
|
129
|
+
return false;
|
|
130
|
+
return workerName ? out.includes(workerName) : true;
|
|
131
|
+
}
|
|
132
|
+
export async function bulkPutSecrets(args) {
|
|
133
|
+
const names = Object.keys(args.secrets);
|
|
134
|
+
if (names.length === 0)
|
|
135
|
+
return;
|
|
136
|
+
const { cmd, prefix } = wranglerCommand(args.projectDir);
|
|
137
|
+
const dir = await mkdtemp(join(tmpdir(), 'astrale-secrets-'));
|
|
138
|
+
const file = join(dir, 'secrets.json');
|
|
139
|
+
try {
|
|
140
|
+
await writeFile(file, JSON.stringify(args.secrets));
|
|
141
|
+
const { code, out } = await runCapture(cmd, [...prefix, 'secret', 'bulk', file, '--config', args.configPath], args.projectDir, args.onLog);
|
|
142
|
+
if (code !== 0) {
|
|
143
|
+
throw new Error(`wrangler secret bulk failed (code ${code}):\n${out.slice(-1500)}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
await rm(dir, { recursive: true, force: true });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// ── internals ──────────────────────────────────────────────────────────────
|
|
151
|
+
function runCapture(cmd, args, cwd, onLog) {
|
|
152
|
+
return new Promise((resolve, reject) => {
|
|
153
|
+
const child = spawn(cmd, args, {
|
|
154
|
+
cwd,
|
|
155
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
156
|
+
env: { ...process.env, WRANGLER_SEND_METRICS: 'false' },
|
|
157
|
+
});
|
|
158
|
+
let out = '';
|
|
159
|
+
const onData = (buf) => {
|
|
160
|
+
const text = buf.toString();
|
|
161
|
+
out += text;
|
|
162
|
+
for (const line of text.split('\n'))
|
|
163
|
+
if (line.trim())
|
|
164
|
+
onLog?.(line);
|
|
165
|
+
};
|
|
166
|
+
child.stdout?.on('data', onData);
|
|
167
|
+
child.stderr?.on('data', onData);
|
|
168
|
+
child.on('exit', (code) => resolve({ code: code ?? 1, out }));
|
|
169
|
+
child.on('error', reject);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
async function stopChild(child) {
|
|
173
|
+
if (child.exitCode !== null)
|
|
174
|
+
return;
|
|
175
|
+
await new Promise((resolve) => {
|
|
176
|
+
child.on('exit', () => resolve());
|
|
177
|
+
child.kill('SIGTERM');
|
|
178
|
+
setTimeout(() => {
|
|
179
|
+
if (child.exitCode === null)
|
|
180
|
+
child.kill('SIGKILL');
|
|
181
|
+
resolve();
|
|
182
|
+
}, 4000).unref?.();
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=wrangler-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler-cli.js","sourceRoot":"","sources":["../src/wrangler-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjE,SAAS,eAAe,CAAC,UAAkB;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,CAAC,CAAA;IAClE,IAAI,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;IACxD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAA;AACtD,CAAC;AAOD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAOpC;IACC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACxD,MAAM,YAAY,GAAG;QACnB,GAAG,MAAM;QACT,K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,IAAI,EAAE;oBAAE,KAAK,EAAE,CAAC,IAAI,CAAC,CAAA;QACrE,CAAC,CAAA;QACD,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAChC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAChC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;QAC7D,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,KAAmB;IAC1C,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI;QAAE,OAAM;IACnC,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QAClC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAA;QACjC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACrB,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI;gBAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAClD,OAAO,EAAE,CAAA;QACX,CAAC,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/adapter-cloudflare",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Deploy an Astrale domain as a standalone Cloudflare Worker",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adapter",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"jose": "^6.1.3",
|
|
31
|
-
"@astrale-os/devkit": "^0.1.
|
|
31
|
+
"@astrale-os/devkit": "^0.1.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@astrale-os/ox": ">=0.1.0 <1.0.0",
|