@astrale-os/adapter-cloudflare 0.4.10 → 0.5.0-beta.100
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 +1193 -0
- package/README.md +29 -0
- package/dist/adapter.d.ts +15 -0
- package/dist/adapter.js +76 -0
- package/dist/build/artifact.d.ts +7 -0
- package/dist/build/artifact.js +165 -0
- package/dist/build/bundle/admit.d.ts +1 -0
- package/dist/build/bundle/admit.js +9 -0
- package/dist/build/closure.d.ts +2 -0
- package/dist/build/closure.js +22 -0
- package/dist/build/codegen/execution.d.ts +3 -0
- package/dist/build/codegen/execution.js +2 -0
- package/dist/{codegen → build/codegen}/merge.d.ts +0 -1
- package/dist/{codegen → build/codegen}/merge.js +0 -1
- package/dist/{codegen → build/codegen}/wrangler.d.ts +19 -4
- package/dist/{codegen → build/codegen}/wrangler.js +49 -13
- package/dist/build/configuration/addressing.d.ts +2 -0
- package/dist/build/configuration/addressing.js +11 -0
- package/dist/build/configuration/invocation-timeout.d.ts +2 -0
- package/dist/build/configuration/invocation-timeout.js +9 -0
- package/dist/build/configuration/request-limit.d.ts +2 -0
- package/dist/build/configuration/request-limit.js +9 -0
- package/dist/build/configuration/router.d.ts +7 -0
- package/dist/build/configuration/router.js +11 -0
- package/dist/build/configuration/worker-name.d.ts +2 -0
- package/dist/build/configuration/worker-name.js +18 -0
- package/dist/build/configuration.d.ts +5 -0
- package/dist/build/configuration.js +5 -0
- package/dist/build/direct.d.ts +4 -0
- package/dist/build/direct.js +93 -0
- package/dist/build/frontend/files.d.ts +7 -0
- package/dist/build/frontend/files.js +60 -0
- package/dist/build/frontend/routes.d.ts +2 -0
- package/dist/build/frontend/routes.js +11 -0
- package/dist/build/index.d.ts +8 -0
- package/dist/build/index.js +7 -0
- package/dist/build/materialize.d.ts +4 -0
- package/dist/build/materialize.js +10 -0
- package/dist/build/metafile.d.ts +5 -0
- package/dist/build/metafile.js +14 -0
- package/dist/build/qualification.d.ts +5 -0
- package/dist/build/qualification.js +7 -0
- package/dist/build/roots.d.ts +2 -0
- package/dist/build/roots.js +34 -0
- package/dist/build/worker/artifact.d.ts +40 -0
- package/dist/build/worker/artifact.js +1 -0
- package/dist/build/worker/artifact.load.d.ts +3 -0
- package/dist/build/worker/artifact.load.js +308 -0
- package/dist/build/worker/artifact.manifest.d.ts +48 -0
- package/dist/build/worker/artifact.manifest.js +87 -0
- package/dist/build/worker/artifact.paths.d.ts +4 -0
- package/dist/build/worker/artifact.paths.js +25 -0
- package/dist/build/worker/codegen/entry.d.ts +2 -0
- package/dist/build/worker/codegen/entry.js +28 -0
- package/dist/build/worker/codegen/service.d.ts +18 -0
- package/dist/build/worker/codegen/service.js +53 -0
- package/dist/build/worker/execution.prepare.d.ts +18 -0
- package/dist/build/worker/execution.prepare.js +112 -0
- package/dist/build/worker/index.d.ts +2 -0
- package/dist/build/worker/index.js +1 -0
- package/dist/build/worker/modules.d.ts +11 -0
- package/dist/build/worker/modules.js +26 -0
- package/dist/build/worker/runtime.d.ts +10 -0
- package/dist/build/worker/runtime.js +35 -0
- package/dist/build/worker/specifier.d.ts +1 -0
- package/dist/build/worker/specifier.js +5 -0
- package/dist/cloudflare.d.ts +1 -37
- package/dist/cloudflare.js +1 -271
- package/dist/deploy/deploy.d.ts +16 -0
- package/dist/deploy/deploy.js +204 -0
- package/dist/deploy/index.d.ts +1 -0
- package/dist/deploy/index.js +1 -0
- package/dist/deploy/output.d.ts +2 -0
- package/dist/deploy/output.js +10 -0
- package/dist/development/develop.d.ts +15 -0
- package/dist/development/develop.js +270 -0
- package/dist/development/frontend.d.ts +11 -0
- package/dist/development/frontend.js +109 -0
- package/dist/development/host.d.ts +2 -0
- package/dist/development/host.js +46 -0
- package/dist/development/port.d.ts +1 -0
- package/dist/development/port.js +12 -0
- package/dist/development/readiness.d.ts +14 -0
- package/dist/development/readiness.js +71 -0
- package/dist/development/resolved-fetch.d.ts +17 -0
- package/dist/development/resolved-fetch.js +80 -0
- package/dist/development/worker-output.d.ts +2 -0
- package/dist/development/worker-output.js +25 -0
- package/dist/development/worker.d.ts +17 -0
- package/dist/development/worker.js +147 -0
- package/dist/identity/binding.d.ts +2 -0
- package/dist/identity/binding.js +2 -0
- package/dist/identity/index.d.ts +3 -0
- package/dist/identity/index.js +3 -0
- package/dist/identity/material.d.ts +7 -0
- package/dist/identity/material.js +42 -0
- package/dist/identity/secret.d.ts +3 -0
- package/dist/identity/secret.js +7 -0
- package/dist/identity/source.d.ts +26 -0
- package/dist/identity/source.js +127 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.js +7 -7
- package/dist/params.d.ts +50 -23
- package/dist/params.js +0 -1
- package/dist/release/deployment.d.ts +44 -0
- package/dist/release/deployment.js +141 -0
- package/dist/release/index.d.ts +2 -0
- package/dist/release/index.js +2 -0
- package/dist/release/staged-worker-name.d.ts +3 -0
- package/dist/release/staged-worker-name.js +10 -0
- package/dist/worker/entry.d.ts +44 -0
- package/dist/worker/entry.js +184 -0
- package/dist/worker/fetch.d.ts +11 -0
- package/dist/worker/fetch.js +31 -0
- package/dist/worker/identity.d.ts +7 -0
- package/dist/worker/identity.js +23 -0
- package/dist/worker/index.d.ts +2 -0
- package/dist/worker/index.js +2 -0
- package/dist/wrangler/bundle.d.ts +10 -0
- package/dist/wrangler/bundle.js +27 -0
- package/dist/wrangler/deploy.d.ts +24 -0
- package/dist/wrangler/deploy.js +44 -0
- package/dist/wrangler/index.d.ts +5 -0
- package/dist/wrangler/index.js +5 -0
- package/dist/wrangler/process.d.ts +17 -0
- package/dist/wrangler/process.js +115 -0
- package/dist/wrangler/secrets.d.ts +6 -0
- package/dist/wrangler/secrets.js +58 -0
- package/dist/wrangler/status.d.ts +14 -0
- package/dist/wrangler/status.js +56 -0
- package/dist/wrangler/type-generation.d.ts +6 -0
- package/dist/wrangler/type-generation.js +19 -0
- package/package.json +41 -18
- package/template/astrale.config.ts +26 -18
- package/dist/assets-pack.d.ts +0 -8
- package/dist/assets-pack.d.ts.map +0 -1
- package/dist/assets-pack.js +0 -30
- package/dist/assets-pack.js.map +0 -1
- package/dist/build.d.ts +0 -16
- package/dist/build.d.ts.map +0 -1
- package/dist/build.js +0 -15
- package/dist/build.js.map +0 -1
- package/dist/client.d.ts +0 -17
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -59
- package/dist/client.js.map +0 -1
- package/dist/cloudflare.d.ts.map +0 -1
- package/dist/cloudflare.js.map +0 -1
- package/dist/codegen/identity.d.ts +0 -10
- package/dist/codegen/identity.d.ts.map +0 -1
- package/dist/codegen/identity.js +0 -32
- package/dist/codegen/identity.js.map +0 -1
- package/dist/codegen/merge.d.ts.map +0 -1
- package/dist/codegen/merge.js.map +0 -1
- package/dist/codegen/worker.d.ts +0 -51
- package/dist/codegen/worker.d.ts.map +0 -1
- package/dist/codegen/worker.js +0 -120
- package/dist/codegen/worker.js.map +0 -1
- package/dist/codegen/wrangler.d.ts.map +0 -1
- package/dist/codegen/wrangler.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/params.d.ts.map +0 -1
- package/dist/params.js.map +0 -1
- package/dist/parse-output.d.ts +0 -25
- package/dist/parse-output.d.ts.map +0 -1
- package/dist/parse-output.js +0 -53
- package/dist/parse-output.js.map +0 -1
- package/dist/wrangler-cli.d.ts +0 -78
- package/dist/wrangler-cli.d.ts.map +0 -1
- package/dist/wrangler-cli.js +0 -251
- package/dist/wrangler-cli.js.map +0 -1
- package/src/assets-pack.ts +0 -32
- package/src/build.ts +0 -16
- package/src/client.ts +0 -89
- package/src/cloudflare.ts +0 -321
- package/src/codegen/identity.ts +0 -40
- package/src/codegen/merge.ts +0 -92
- package/src/codegen/worker.ts +0 -136
- package/src/codegen/wrangler.ts +0 -105
- package/src/index.ts +0 -21
- package/src/params.ts +0 -96
- package/src/parse-output.ts +0 -54
- package/src/wrangler-cli.ts +0 -324
- package/template/.env.example +0 -9
- package/template/.gitignore.template +0 -16
- package/template/CLAUDE.md +0 -13
- package/template/README.md +0 -47
- package/template/client/.gitignore.template +0 -4
- package/template/client/__tests__/app.test.tsx +0 -15
- package/template/client/components.json +0 -25
- package/template/client/index.html +0 -12
- package/template/client/package.json +0 -35
- package/template/client/src/app.tsx +0 -52
- package/template/client/src/components/ui/cn.ts +0 -6
- package/template/client/src/main.tsx +0 -9
- package/template/client/src/styles.css +0 -78
- package/template/client/tsconfig.json +0 -26
- package/template/client/vite.config.ts +0 -22
- package/template/client/vitest.config.ts +0 -13
- package/template/core/README.md +0 -7
- package/template/deps.ts +0 -9
- package/template/domain.ts +0 -11
- package/template/env.ts +0 -8
- package/template/icons.ts +0 -4
- package/template/integrations/README.md +0 -7
- package/template/oxlint.config.ts +0 -1
- package/template/package.json +0 -58
- package/template/pnpm-workspace.yaml +0 -31
- package/template/runtime/index.ts +0 -8
- package/template/schema/index.ts +0 -10
- package/template/simulation/README.md +0 -12
- package/template/tsconfig.json +0 -28
- package/template/vitest.config.ts +0 -7
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
export function wranglerCommand(projectDir, runtime = {
|
|
6
|
+
executable: process.execPath,
|
|
7
|
+
bun: process.versions.bun !== undefined,
|
|
8
|
+
}) {
|
|
9
|
+
const local = join(projectDir, 'node_modules', '.bin', 'wrangler');
|
|
10
|
+
if (existsSync(local))
|
|
11
|
+
return { cmd: local, prefix: [] };
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const packagePath = require.resolve('wrangler/package.json');
|
|
14
|
+
const manifest = JSON.parse(readFileSync(packagePath, 'utf8'));
|
|
15
|
+
const executable = typeof manifest.bin === 'string' ? manifest.bin : manifest.bin?.wrangler;
|
|
16
|
+
if (!executable)
|
|
17
|
+
throw new TypeError('Installed Wrangler package has no wrangler executable.');
|
|
18
|
+
return {
|
|
19
|
+
cmd: runtime.bun ? 'node' : runtime.executable,
|
|
20
|
+
prefix: [resolve(dirname(packagePath), executable)],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** Keep Wrangler CLI diagnostic logs inside the generated project state. */
|
|
24
|
+
export function wranglerProcessEnv(projectDir) {
|
|
25
|
+
return {
|
|
26
|
+
...process.env,
|
|
27
|
+
WRANGLER_SEND_METRICS: 'false',
|
|
28
|
+
WRANGLER_LOG_PATH: process.env.WRANGLER_LOG_PATH || resolve(projectDir, '.astrale', 'logs', 'wrangler'),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function runCapture(cmd, args, cwd, onLog, signal, redact = (input) => input) {
|
|
32
|
+
if (signal?.aborted)
|
|
33
|
+
return Promise.reject(new Error('Wrangler process cancelled.'));
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const child = spawn(cmd, args, {
|
|
36
|
+
cwd,
|
|
37
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
38
|
+
env: wranglerProcessEnv(cwd),
|
|
39
|
+
});
|
|
40
|
+
let out = '';
|
|
41
|
+
let stdout = '';
|
|
42
|
+
let stderr = '';
|
|
43
|
+
let outputBytes = 0;
|
|
44
|
+
let terminating;
|
|
45
|
+
const timeout = setTimeout(() => terminate(new Error('Wrangler process timed out.')), 300_000);
|
|
46
|
+
const abort = () => terminate(new Error('Wrangler process cancelled.'));
|
|
47
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
48
|
+
let escalation;
|
|
49
|
+
const cleanup = () => {
|
|
50
|
+
clearTimeout(timeout);
|
|
51
|
+
if (escalation !== undefined)
|
|
52
|
+
clearTimeout(escalation);
|
|
53
|
+
signal?.removeEventListener('abort', abort);
|
|
54
|
+
};
|
|
55
|
+
function terminate(cause) {
|
|
56
|
+
if (terminating !== undefined)
|
|
57
|
+
return;
|
|
58
|
+
terminating = cause;
|
|
59
|
+
child.kill('SIGTERM');
|
|
60
|
+
escalation = setTimeout(() => {
|
|
61
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
62
|
+
child.kill('SIGKILL');
|
|
63
|
+
}, 1_000);
|
|
64
|
+
}
|
|
65
|
+
const onData = (buffer, stream) => {
|
|
66
|
+
outputBytes += buffer.byteLength;
|
|
67
|
+
if (outputBytes > 1024 * 1024) {
|
|
68
|
+
terminate(new Error('Wrangler process exceeded its output limit.'));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const chunk = buffer.toString();
|
|
72
|
+
out += chunk;
|
|
73
|
+
if (stream === 'stdout')
|
|
74
|
+
stdout += chunk;
|
|
75
|
+
else
|
|
76
|
+
stderr += chunk;
|
|
77
|
+
};
|
|
78
|
+
child.stdout?.on('data', (buffer) => onData(buffer, 'stdout'));
|
|
79
|
+
child.stderr?.on('data', (buffer) => onData(buffer, 'stderr'));
|
|
80
|
+
child.on('exit', (code) => {
|
|
81
|
+
cleanup();
|
|
82
|
+
if (terminating !== undefined)
|
|
83
|
+
reject(terminating);
|
|
84
|
+
else {
|
|
85
|
+
const safe = redact(out);
|
|
86
|
+
for (const line of safe.split('\n'))
|
|
87
|
+
if (line.trim())
|
|
88
|
+
onLog?.(line);
|
|
89
|
+
resolve({
|
|
90
|
+
code: code ?? 1,
|
|
91
|
+
out: safe,
|
|
92
|
+
stdout: redact(stdout),
|
|
93
|
+
stderr: redact(stderr),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
child.on('error', (cause) => {
|
|
98
|
+
cleanup();
|
|
99
|
+
reject(terminating ?? cause);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
export async function stopChild(child) {
|
|
104
|
+
if (child.exitCode !== null)
|
|
105
|
+
return;
|
|
106
|
+
await new Promise((resolve) => {
|
|
107
|
+
child.on('exit', () => resolve());
|
|
108
|
+
child.kill('SIGTERM');
|
|
109
|
+
setTimeout(() => {
|
|
110
|
+
if (child.exitCode === null)
|
|
111
|
+
child.kill('SIGKILL');
|
|
112
|
+
resolve();
|
|
113
|
+
}, 4000).unref?.();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function withSecretsFile<Result>(secrets: Readonly<Record<string, string>>, operation: (path?: string) => Promise<Result>): Promise<Result>;
|
|
2
|
+
export declare function createSecretEnvironment(secrets: Readonly<Record<string, string>>): Promise<{
|
|
3
|
+
readonly path: string;
|
|
4
|
+
remove(): Promise<void>;
|
|
5
|
+
} | undefined>;
|
|
6
|
+
export declare function secretRedactor(secrets: Readonly<Record<string, string>>): (input: string) => string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
export async function withSecretsFile(secrets, operation) {
|
|
5
|
+
if (Object.keys(secrets).length === 0)
|
|
6
|
+
return operation();
|
|
7
|
+
const directory = await mkdtemp(join(tmpdir(), 'astrale-secrets-'));
|
|
8
|
+
const path = join(directory, 'secrets.json');
|
|
9
|
+
try {
|
|
10
|
+
await writeFile(path, JSON.stringify(secrets), { mode: 0o600 });
|
|
11
|
+
return await operation(path);
|
|
12
|
+
}
|
|
13
|
+
finally {
|
|
14
|
+
await rm(directory, { recursive: true, force: true });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export async function createSecretEnvironment(secrets) {
|
|
18
|
+
if (Object.keys(secrets).length === 0)
|
|
19
|
+
return undefined;
|
|
20
|
+
const source = Object.entries(secrets)
|
|
21
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
22
|
+
.map(([name, value]) => `${secretName(name)}=${dotenvSecret(value)}`)
|
|
23
|
+
.join('\n');
|
|
24
|
+
const directory = await mkdtemp(join(tmpdir(), 'astrale-dev-secrets-'));
|
|
25
|
+
const path = join(directory, '.dev.vars');
|
|
26
|
+
await writeFile(path, `${source}\n`, { mode: 0o600 });
|
|
27
|
+
return Object.freeze({
|
|
28
|
+
path,
|
|
29
|
+
remove: () => rm(directory, { recursive: true, force: true }),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export function secretRedactor(secrets) {
|
|
33
|
+
const values = Object.values(secrets)
|
|
34
|
+
.filter((value) => value.length > 0)
|
|
35
|
+
.flatMap((value) => [value, JSON.stringify(value).slice(1, -1)])
|
|
36
|
+
.filter((value, index, all) => all.indexOf(value) === index)
|
|
37
|
+
.sort((left, right) => right.length - left.length);
|
|
38
|
+
return (input) => values.reduce((output, value) => output.replaceAll(value, '[REDACTED]'), input);
|
|
39
|
+
}
|
|
40
|
+
function secretName(input) {
|
|
41
|
+
if (!/^[A-Za-z_]\w*$/u.test(input)) {
|
|
42
|
+
throw new TypeError(`Cloudflare secret name '${input}' is not a Worker binding name.`);
|
|
43
|
+
}
|
|
44
|
+
return input;
|
|
45
|
+
}
|
|
46
|
+
/** Encode without changing a byte under Wrangler's dotenv boundary. */
|
|
47
|
+
function dotenvSecret(input) {
|
|
48
|
+
if (!input.includes("'"))
|
|
49
|
+
return `'${input}'`;
|
|
50
|
+
if (!input.includes('`'))
|
|
51
|
+
return `\`${input}\``;
|
|
52
|
+
if (!input.includes('"') && !input.includes('\\n') && !input.includes('\\r')) {
|
|
53
|
+
return `"${input}"`;
|
|
54
|
+
}
|
|
55
|
+
if (input.trim() === input && !/[#\r\n]/u.test(input))
|
|
56
|
+
return input;
|
|
57
|
+
throw new TypeError('Cloudflare local secret cannot be represented losslessly as dotenv.');
|
|
58
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface WranglerDeploymentStatus {
|
|
2
|
+
readonly deployment: string;
|
|
3
|
+
readonly versions: readonly {
|
|
4
|
+
readonly version: string;
|
|
5
|
+
readonly percentage: number;
|
|
6
|
+
}[];
|
|
7
|
+
}
|
|
8
|
+
export declare function runWranglerDeploymentStatus(args: {
|
|
9
|
+
readonly projectDir: string;
|
|
10
|
+
readonly configPath: string;
|
|
11
|
+
readonly workerName: string;
|
|
12
|
+
readonly signal?: AbortSignal;
|
|
13
|
+
}): Promise<WranglerDeploymentStatus>;
|
|
14
|
+
export declare function admitWranglerDeploymentStatus(output: string): WranglerDeploymentStatus;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { runCapture, wranglerCommand } from './process.js';
|
|
2
|
+
export async function runWranglerDeploymentStatus(args) {
|
|
3
|
+
const { cmd, prefix } = wranglerCommand(args.projectDir);
|
|
4
|
+
const result = await runCapture(cmd, [
|
|
5
|
+
...prefix,
|
|
6
|
+
'deployments',
|
|
7
|
+
'status',
|
|
8
|
+
'--config',
|
|
9
|
+
args.configPath,
|
|
10
|
+
'--name',
|
|
11
|
+
args.workerName,
|
|
12
|
+
'--json',
|
|
13
|
+
], args.projectDir, undefined, args.signal);
|
|
14
|
+
if (result.code !== 0) {
|
|
15
|
+
throw new Error(`wrangler deployments status failed (code ${result.code}):\n${result.out.slice(-2000)}`);
|
|
16
|
+
}
|
|
17
|
+
return admitWranglerDeploymentStatus(result.stdout);
|
|
18
|
+
}
|
|
19
|
+
export function admitWranglerDeploymentStatus(output) {
|
|
20
|
+
let decoded;
|
|
21
|
+
try {
|
|
22
|
+
decoded = JSON.parse(output);
|
|
23
|
+
}
|
|
24
|
+
catch (cause) {
|
|
25
|
+
throw new TypeError('wrangler deployments status returned invalid JSON.', { cause });
|
|
26
|
+
}
|
|
27
|
+
if (decoded === null || typeof decoded !== 'object' || Array.isArray(decoded))
|
|
28
|
+
invalidStatus();
|
|
29
|
+
const deployment = Reflect.get(decoded, 'id');
|
|
30
|
+
const traffic = Reflect.get(decoded, 'versions');
|
|
31
|
+
if (typeof deployment !== 'string' ||
|
|
32
|
+
deployment.length === 0 ||
|
|
33
|
+
!Array.isArray(traffic) ||
|
|
34
|
+
traffic.length === 0) {
|
|
35
|
+
invalidStatus();
|
|
36
|
+
}
|
|
37
|
+
const versions = traffic.map((entry) => {
|
|
38
|
+
if (entry === null || typeof entry !== 'object' || Array.isArray(entry))
|
|
39
|
+
invalidStatus();
|
|
40
|
+
const version = Reflect.get(entry, 'version_id');
|
|
41
|
+
const percentage = Reflect.get(entry, 'percentage');
|
|
42
|
+
if (typeof version !== 'string' ||
|
|
43
|
+
version.length === 0 ||
|
|
44
|
+
typeof percentage !== 'number' ||
|
|
45
|
+
!Number.isFinite(percentage) ||
|
|
46
|
+
percentage <= 0 ||
|
|
47
|
+
percentage > 100) {
|
|
48
|
+
invalidStatus();
|
|
49
|
+
}
|
|
50
|
+
return Object.freeze({ version, percentage });
|
|
51
|
+
});
|
|
52
|
+
return Object.freeze({ deployment, versions: Object.freeze(versions) });
|
|
53
|
+
}
|
|
54
|
+
function invalidStatus() {
|
|
55
|
+
throw new TypeError('wrangler deployments status returned invalid deployment evidence.');
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { dirname, join } from 'node:path';
|
|
2
|
+
import { runCapture, wranglerCommand } from './process.js';
|
|
3
|
+
export async function runWranglerTypes(args) {
|
|
4
|
+
const { cmd, prefix } = wranglerCommand(args.projectDir);
|
|
5
|
+
const outputPath = join(dirname(args.configPath), 'worker-configuration.d.ts');
|
|
6
|
+
const { code, out } = await runCapture(cmd, [
|
|
7
|
+
...prefix,
|
|
8
|
+
'types',
|
|
9
|
+
outputPath,
|
|
10
|
+
'--env-interface',
|
|
11
|
+
'CloudflareEnv',
|
|
12
|
+
'--config',
|
|
13
|
+
args.configPath,
|
|
14
|
+
], args.projectDir, args.onLog, args.signal);
|
|
15
|
+
if (code !== 0) {
|
|
16
|
+
throw new Error(`wrangler types failed (code ${code}):\n${out.slice(-2000)}`);
|
|
17
|
+
}
|
|
18
|
+
return outputPath;
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/adapter-cloudflare",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Deploy an Astrale
|
|
3
|
+
"version": "0.5.0-beta.100",
|
|
4
|
+
"description": "Deploy an Astrale application through Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adapter",
|
|
7
7
|
"astrale",
|
|
@@ -11,49 +11,72 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"author": "Astrale",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/astrale-os/sdk.git"
|
|
17
|
+
},
|
|
14
18
|
"files": [
|
|
15
19
|
"dist",
|
|
16
|
-
"
|
|
20
|
+
"!dist/**/*.map",
|
|
17
21
|
"template",
|
|
18
|
-
"!template
|
|
22
|
+
"!template/**/node_modules",
|
|
23
|
+
"!template/**/node_modules/**",
|
|
24
|
+
"!template/**/pnpm-lock.yaml"
|
|
19
25
|
],
|
|
20
26
|
"type": "module",
|
|
21
|
-
"main": "./
|
|
22
|
-
"types": "./
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
23
29
|
"exports": {
|
|
24
30
|
".": {
|
|
25
31
|
"types": "./dist/index.d.ts",
|
|
26
32
|
"import": "./dist/index.js"
|
|
27
33
|
},
|
|
28
34
|
"./build": {
|
|
29
|
-
"types": "./dist/build.d.ts",
|
|
30
|
-
"import": "./dist/build.js"
|
|
35
|
+
"types": "./dist/build/index.d.ts",
|
|
36
|
+
"import": "./dist/build/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./identity": {
|
|
39
|
+
"types": "./dist/identity/index.d.ts",
|
|
40
|
+
"import": "./dist/identity/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./worker": {
|
|
43
|
+
"types": "./dist/worker/index.d.ts",
|
|
44
|
+
"import": "./dist/worker/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./release": {
|
|
47
|
+
"types": "./dist/release/index.d.ts",
|
|
48
|
+
"import": "./dist/release/index.js"
|
|
31
49
|
},
|
|
32
50
|
"./package.json": "./package.json"
|
|
33
51
|
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"registry": "https://registry.npmjs.org/"
|
|
54
|
+
},
|
|
34
55
|
"dependencies": {
|
|
56
|
+
"@astrale-os/sdk": "0.5.0-beta.97",
|
|
57
|
+
"@noble/hashes": "2.3.0",
|
|
58
|
+
"hono": "^4.6.20",
|
|
35
59
|
"jose": "^6.1.3",
|
|
36
|
-
"
|
|
60
|
+
"wrangler": "4.123.0"
|
|
37
61
|
},
|
|
38
62
|
"devDependencies": {
|
|
39
|
-
"@astrale-os/ox": "
|
|
63
|
+
"@astrale-os/ox": "0.1.3",
|
|
40
64
|
"@types/node": "^22.0.0",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"wrangler": "4.106.0"
|
|
65
|
+
"oxfmt": "0.63.0",
|
|
66
|
+
"oxlint": "1.78.0",
|
|
67
|
+
"typescript": "7.0.2",
|
|
68
|
+
"vitest": "^4.1.10",
|
|
69
|
+
"zod": "4.4.3"
|
|
47
70
|
},
|
|
48
71
|
"engines": {
|
|
49
72
|
"node": ">=22"
|
|
50
73
|
},
|
|
51
74
|
"scripts": {
|
|
52
|
-
"typecheck": "
|
|
75
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json && tsc --noEmit -p __tests__/tsconfig.types.json",
|
|
53
76
|
"test": "vitest run",
|
|
54
77
|
"lint": "oxlint --disable-nested-config .",
|
|
55
78
|
"format": "pnpm exec oxfmt --write .",
|
|
56
79
|
"format:check": "pnpm exec oxfmt --check .",
|
|
57
|
-
"build": "rm -rf dist &&
|
|
80
|
+
"build": "rm -rf dist && tsc && node ../scripts/verify-no-source-maps.mjs dist"
|
|
58
81
|
}
|
|
59
82
|
}
|
|
@@ -1,37 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* astrale.config.ts — binds the
|
|
2
|
+
* astrale.config.ts — binds the authored Application and independently importable Runtime to its
|
|
3
|
+
* deploy
|
|
3
4
|
* adapter for the `astrale-domain` CLI. This is a NODE-only module: it imports
|
|
4
5
|
* the adapter (wrangler + filesystem). The generated worker never imports this
|
|
5
|
-
* file — it imports `
|
|
6
|
+
* file — it imports `runtime.ts` directly — so the adapter stays out of the bundle.
|
|
6
7
|
*
|
|
7
8
|
* This variant deploys to YOUR OWN Cloudflare account (the `cloudflare` adapter).
|
|
8
9
|
*
|
|
9
|
-
* pnpm dev
|
|
10
|
-
*
|
|
11
|
-
* pnpm prod # deploy to your Cloudflare account
|
|
10
|
+
* pnpm dev # local Worker + Vite HMR on allocated ports
|
|
11
|
+
* pnpm prod # deploy to your Cloudflare account
|
|
12
12
|
*/
|
|
13
13
|
import { cloudflare } from '@astrale-os/adapter-cloudflare'
|
|
14
|
-
import { deploy } from '@astrale-os/sdk'
|
|
14
|
+
import { deploy, runtime } from '@astrale-os/sdk/deployment'
|
|
15
15
|
// No Cloudflare account? Swap the adapter for the Astrale-managed one — it
|
|
16
16
|
// publishes the same bundle THROUGH the platform and installs it on your
|
|
17
17
|
// instance (auth = your `astrale auth login` session):
|
|
18
18
|
//
|
|
19
19
|
// import { astrale } from '@astrale-os/adapter-astrale'
|
|
20
|
-
// export default deploy(
|
|
21
|
-
// dev: {
|
|
22
|
-
// prod: {
|
|
23
|
-
// }))
|
|
20
|
+
// export default deploy({ application, entrypoint: runtime('./runtime.ts'), adapter: astrale({
|
|
21
|
+
// dev: { secrets: '.env.dev' }, // tunnel + install + View
|
|
22
|
+
// prod: { instance: '<your-instance-slug>' }, // managed deploy + install
|
|
23
|
+
// }) })
|
|
24
24
|
|
|
25
|
-
import {
|
|
25
|
+
import { application } from './application.js'
|
|
26
26
|
|
|
27
|
-
export default deploy(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
dev:
|
|
27
|
+
export default deploy({
|
|
28
|
+
application,
|
|
29
|
+
entrypoint: runtime('./runtime.ts'),
|
|
30
|
+
adapter: cloudflare({
|
|
31
|
+
// Local dev: allocated Worker/Vite ports, one Worker-facing URL, and HMR.
|
|
32
|
+
// Supply `pnpm dev --host <origin> --port <port>` for ingress you own.
|
|
33
|
+
dev: { secrets: '.env.dev' },
|
|
32
34
|
// Custom-domain prod. Drop `route` to ship to *.workers.dev instead.
|
|
33
|
-
|
|
35
|
+
// The scaffold creates this identity once. Retain it in managed secret
|
|
36
|
+
// storage and restore it at this path in CI before every remote deploy.
|
|
37
|
+
prod: {
|
|
38
|
+
route: 'astrale-domain.example.dev',
|
|
39
|
+
secrets: '.env.prod',
|
|
40
|
+
signingIdentity: '.astrale/identity.json',
|
|
41
|
+
},
|
|
34
42
|
// Author secrets ship via `secrets: '.env.prod'` on any env. Extra bindings
|
|
35
43
|
// (KV, R2, D1, queues, …) ride a `wrangler` block on any env (deep-merged).
|
|
36
44
|
}),
|
|
37
|
-
)
|
|
45
|
+
})
|
package/dist/assets-pack.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pack a built client SPA (the `CLIENT_DIST_DIR` build) into the host box's asset-archive
|
|
3
|
-
* format: `gzip(JSON [{ path, contentBase64 }])` — the exact shape
|
|
4
|
-
* `downloadAssets` on the box consumes (kernel/host workerd service layout).
|
|
5
|
-
*/
|
|
6
|
-
/** Gzip the SPA dir into the box's asset archive. Returns null when empty. */
|
|
7
|
-
export declare function packAssets(distClientDir: string): Buffer | null;
|
|
8
|
-
//# sourceMappingURL=assets-pack.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assets-pack.d.ts","sourceRoot":"","sources":["../src/assets-pack.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqBH,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK/D"}
|
package/dist/assets-pack.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pack a built client SPA (the `CLIENT_DIST_DIR` build) into the host box's asset-archive
|
|
3
|
-
* format: `gzip(JSON [{ path, contentBase64 }])` — the exact shape
|
|
4
|
-
* `downloadAssets` on the box consumes (kernel/host workerd service layout).
|
|
5
|
-
*/
|
|
6
|
-
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
7
|
-
import { join, relative } from 'node:path';
|
|
8
|
-
import { gzipSync } from 'node:zlib';
|
|
9
|
-
function walk(dir, root, out) {
|
|
10
|
-
for (const name of readdirSync(dir)) {
|
|
11
|
-
const full = join(dir, name);
|
|
12
|
-
if (statSync(full).isDirectory())
|
|
13
|
-
walk(full, root, out);
|
|
14
|
-
else {
|
|
15
|
-
out.push({
|
|
16
|
-
path: relative(root, full).split('\\').join('/'),
|
|
17
|
-
contentBase64: readFileSync(full).toString('base64'),
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/** Gzip the SPA dir into the box's asset archive. Returns null when empty. */
|
|
23
|
-
export function packAssets(distClientDir) {
|
|
24
|
-
const files = [];
|
|
25
|
-
walk(distClientDir, distClientDir, files);
|
|
26
|
-
if (files.length === 0)
|
|
27
|
-
return null;
|
|
28
|
-
return gzipSync(Buffer.from(JSON.stringify(files)));
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=assets-pack.js.map
|
package/dist/assets-pack.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assets-pack.js","sourceRoot":"","sources":["../src/assets-pack.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC7D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAIpC,SAAS,IAAI,CAAC,GAAW,EAAE,IAAY,EAAE,GAAgB;IACvD,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QAC5B,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE;YAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;aAClD,CAAC;YACJ,GAAG,CAAC,IAAI,CAAC;gBACP,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBAChD,aAAa,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;aACrD,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,UAAU,CAAC,aAAqB;IAC9C,MAAM,KAAK,GAAgB,EAAE,CAAA;IAC7B,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE,KAAK,CAAC,CAAA;IACzC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACnC,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AACrD,CAAC"}
|
package/dist/build.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@astrale-os/adapter-cloudflare/build` — the shared Cloudflare-Workers build
|
|
3
|
-
* toolkit, exposed for sibling deploy adapters (e.g.
|
|
4
|
-
* `@astrale-os/adapter-astrale`).
|
|
5
|
-
*
|
|
6
|
-
* This is the "compile a `defineDomain` into a Cloudflare Workers bundle + run
|
|
7
|
-
* local dev" surface that every Cloudflare-Workers deploy strategy shares,
|
|
8
|
-
* regardless of WHERE the bundle ultimately ships. It is NOT part of the public
|
|
9
|
-
* adapter API (`@astrale-os/adapter-cloudflare`) — it's the seam two adapters
|
|
10
|
-
* build on so the codegen/bundling/dev logic lives in exactly one place.
|
|
11
|
-
*/
|
|
12
|
-
export { logTo, prepare } from './cloudflare';
|
|
13
|
-
export { buildClient, CLIENT_DIST_DIR, resolveClientDir } from './client';
|
|
14
|
-
export type { ClientConfig } from './client';
|
|
15
|
-
export { runWranglerBundle, runWranglerDev } from './wrangler-cli';
|
|
16
|
-
//# sourceMappingURL=build.d.ts.map
|
package/dist/build.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AACzE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/build.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@astrale-os/adapter-cloudflare/build` — the shared Cloudflare-Workers build
|
|
3
|
-
* toolkit, exposed for sibling deploy adapters (e.g.
|
|
4
|
-
* `@astrale-os/adapter-astrale`).
|
|
5
|
-
*
|
|
6
|
-
* This is the "compile a `defineDomain` into a Cloudflare Workers bundle + run
|
|
7
|
-
* local dev" surface that every Cloudflare-Workers deploy strategy shares,
|
|
8
|
-
* regardless of WHERE the bundle ultimately ships. It is NOT part of the public
|
|
9
|
-
* adapter API (`@astrale-os/adapter-cloudflare`) — it's the seam two adapters
|
|
10
|
-
* build on so the codegen/bundling/dev logic lives in exactly one place.
|
|
11
|
-
*/
|
|
12
|
-
export { logTo, prepare } from './cloudflare';
|
|
13
|
-
export { buildClient, CLIENT_DIST_DIR, resolveClientDir } from './client';
|
|
14
|
-
export { runWranglerBundle, runWranglerDev } from './wrangler-cli';
|
|
15
|
-
//# sourceMappingURL=build.js.map
|
package/dist/build.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEzE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/client.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** Client SPA build helpers. The source dir is adapter env config, not domain config. */
|
|
2
|
-
import type { DomainInfo } from '@astrale-os/sdk';
|
|
3
|
-
export type ClientConfig = {
|
|
4
|
-
/** Vite project directory, relative to the domain project root unless absolute. */
|
|
5
|
-
dir: string;
|
|
6
|
-
};
|
|
7
|
-
/** Built client output, relative to the project root. The Vite config must emit here. */
|
|
8
|
-
export declare const CLIENT_DIST_DIR = ".dist";
|
|
9
|
-
export declare function resolveClientDir(args: {
|
|
10
|
-
adapterName: string;
|
|
11
|
-
env: string;
|
|
12
|
-
projectDir: string;
|
|
13
|
-
client?: ClientConfig;
|
|
14
|
-
domain: DomainInfo;
|
|
15
|
-
}): string | undefined;
|
|
16
|
-
export declare function buildClient(clientDir: string, projectDir: string, onLog?: (line: string) => void): Promise<void>;
|
|
17
|
-
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAEzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAMjD,MAAM,MAAM,YAAY,GAAG;IACzB,mFAAmF;IACnF,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,yFAAyF;AACzF,eAAO,MAAM,eAAe,UAAU,CAAA;AAEtC,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,MAAM,EAAE,UAAU,CAAA;CACnB,GAAG,MAAM,GAAG,SAAS,CAoBrB;AAMD,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,CAef"}
|
package/dist/client.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/** Client SPA build helpers. The source dir is adapter env config, not domain config. */
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
|
-
import { existsSync } from 'node:fs';
|
|
4
|
-
import { isAbsolute, join } from 'node:path';
|
|
5
|
-
/** Built client output, relative to the project root. The Vite config must emit here. */
|
|
6
|
-
export const CLIENT_DIST_DIR = '.dist';
|
|
7
|
-
export function resolveClientDir(args) {
|
|
8
|
-
const { adapterName, projectDir, client, domain } = args;
|
|
9
|
-
for (const view of domain.mountedViews) {
|
|
10
|
-
if (!isUiMount(view.mount)) {
|
|
11
|
-
throw new Error(`${adapterName} adapter: mounted view "${view.slug}" uses mount "${view.mount}", ` +
|
|
12
|
-
'but adapter-managed client assets currently serve only /ui routes.');
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
if (domain.mountedViews.length > 0 && !client) {
|
|
16
|
-
const mounts = domain.mountedViews.map((v) => `${v.slug}:${v.mount}`).join(', ');
|
|
17
|
-
throw new Error(`${adapterName} adapter: ${domain.origin} declares mounted view(s) (${mounts}) ` +
|
|
18
|
-
`but env "${args.env}" has no \`client: { dir: ... }\` config. ` +
|
|
19
|
-
'Add `client` to the selected adapter env in astrale.config.ts.');
|
|
20
|
-
}
|
|
21
|
-
if (!client)
|
|
22
|
-
return undefined;
|
|
23
|
-
return isAbsolute(client.dir) ? client.dir : join(projectDir, client.dir);
|
|
24
|
-
}
|
|
25
|
-
function isUiMount(mount) {
|
|
26
|
-
return mount === '/ui' || mount.startsWith('/ui/');
|
|
27
|
-
}
|
|
28
|
-
export async function buildClient(clientDir, projectDir, onLog) {
|
|
29
|
-
const viteBin = [
|
|
30
|
-
join(clientDir, 'node_modules', '.bin', 'vite'),
|
|
31
|
-
join(projectDir, 'node_modules', '.bin', 'vite'),
|
|
32
|
-
].find((p) => existsSync(p));
|
|
33
|
-
if (!viteBin) {
|
|
34
|
-
throw new Error(`client build: vite not found in ${clientDir}. Run \`pnpm install\` at the project root ` +
|
|
35
|
-
`first.`);
|
|
36
|
-
}
|
|
37
|
-
const { code, out } = await runCapture(viteBin, ['build'], clientDir, onLog);
|
|
38
|
-
if (code !== 0) {
|
|
39
|
-
throw new Error(`client build failed (code ${code}):\n${out.slice(-1500)}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function runCapture(cmd, args, cwd, onLog) {
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
const child = spawn(cmd, args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
45
|
-
let out = '';
|
|
46
|
-
const onData = (buf) => {
|
|
47
|
-
const text = buf.toString();
|
|
48
|
-
out += text;
|
|
49
|
-
for (const line of text.split('\n'))
|
|
50
|
-
if (line.trim())
|
|
51
|
-
onLog?.(line);
|
|
52
|
-
};
|
|
53
|
-
child.stdout?.on('data', onData);
|
|
54
|
-
child.stderr?.on('data', onData);
|
|
55
|
-
child.on('exit', (code) => resolve({ code: code ?? 1, out }));
|
|
56
|
-
child.on('error', reject);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAIzF,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAO5C,yFAAyF;AACzF,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAA;AAEtC,MAAM,UAAU,gBAAgB,CAAC,IAMhC;IACC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IACxD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACvC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACb,GAAG,WAAW,2BAA2B,IAAI,CAAC,IAAI,iBAAiB,IAAI,CAAC,KAAK,KAAK;gBAChF,oEAAoE,CACvE,CAAA;QACH,CAAC;IACH,CAAC;IACD,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAChF,MAAM,IAAI,KAAK,CACb,GAAG,WAAW,aAAa,MAAM,CAAC,MAAM,8BAA8B,MAAM,IAAI;YAC9E,YAAY,IAAI,CAAC,GAAG,4CAA4C;YAChE,gEAAgE,CACnE,CAAA;IACH,CAAC;IACD,IAAI,CAAC,MAAM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