@samebase/convex-hosting 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -128
- package/README.md +136 -398
- package/dist/cli/convex.d.ts +63 -0
- package/dist/cli/convex.js +108 -0
- package/dist/cli/convex.js.map +1 -0
- package/dist/cli/files.d.ts +18 -0
- package/dist/cli/files.js +106 -0
- package/dist/cli/files.js.map +1 -0
- package/dist/cli/index.d.ts +1 -11
- package/dist/cli/index.js +3 -58
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/main.d.ts +5 -0
- package/dist/cli/main.js +346 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/client/index.d.ts +8 -115
- package/dist/client/index.js +65 -254
- package/dist/client/index.js.map +1 -1
- package/dist/client/types.d.ts +5 -0
- package/dist/client/version-module.d.ts +6 -0
- package/dist/component/_generated/api.d.ts +0 -5
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +20 -18
- package/dist/component/_generated/dataModel.d.ts +0 -1
- package/dist/component/_generated/server.d.ts +12 -1
- package/dist/component/_generated/server.js +2 -0
- package/dist/component/_generated/server.js.map +1 -1
- package/dist/component/convex.config.d.ts +0 -1
- package/dist/component/lib.d.ts +175 -156
- package/dist/component/lib.js +396 -710
- package/dist/component/lib.js.map +1 -1
- package/dist/component/schema.d.ts +76 -72
- package/dist/component/schema.js +35 -59
- package/dist/component/schema.js.map +1 -1
- package/dist/workers-shared/asset-worker/src/analytics.d.ts +39 -0
- package/dist/workers-shared/asset-worker/src/analytics.js +86 -0
- package/dist/workers-shared/asset-worker/src/analytics.js.map +1 -0
- package/dist/workers-shared/asset-worker/src/compatibility-flags.d.ts +19 -0
- package/dist/workers-shared/asset-worker/src/compatibility-flags.js +29 -0
- package/dist/workers-shared/asset-worker/src/compatibility-flags.js.map +1 -0
- package/dist/workers-shared/asset-worker/src/configuration.d.ts +3 -0
- package/dist/workers-shared/asset-worker/src/configuration.js +30 -0
- package/dist/workers-shared/asset-worker/src/configuration.js.map +1 -0
- package/dist/workers-shared/asset-worker/src/constants.d.ts +1 -0
- package/dist/workers-shared/asset-worker/src/constants.js +3 -0
- package/dist/workers-shared/asset-worker/src/constants.js.map +1 -0
- package/dist/workers-shared/asset-worker/src/handler.d.ts +28 -0
- package/dist/workers-shared/asset-worker/src/handler.js +717 -0
- package/dist/workers-shared/asset-worker/src/handler.js.map +1 -0
- package/dist/workers-shared/asset-worker/src/types.d.ts +13 -0
- package/dist/workers-shared/asset-worker/src/types.js +2 -0
- package/dist/workers-shared/asset-worker/src/types.js.map +1 -0
- package/dist/workers-shared/asset-worker/src/utils/base-path.d.ts +29 -0
- package/dist/workers-shared/asset-worker/src/utils/base-path.js +56 -0
- package/dist/workers-shared/asset-worker/src/utils/base-path.js.map +1 -0
- package/dist/workers-shared/asset-worker/src/utils/headers.d.ts +11 -0
- package/dist/workers-shared/asset-worker/src/utils/headers.js +77 -0
- package/dist/workers-shared/asset-worker/src/utils/headers.js.map +1 -0
- package/dist/workers-shared/asset-worker/src/utils/rules-engine.d.ts +23 -0
- package/dist/workers-shared/asset-worker/src/utils/rules-engine.js +133 -0
- package/dist/workers-shared/asset-worker/src/utils/rules-engine.js.map +1 -0
- package/dist/workers-shared/asset-worker/src/worker.d.ts +14 -0
- package/dist/workers-shared/asset-worker/src/worker.js +12 -0
- package/dist/workers-shared/asset-worker/src/worker.js.map +1 -0
- package/dist/workers-shared/utils/base-path.d.ts +32 -0
- package/dist/workers-shared/utils/base-path.js +94 -0
- package/dist/workers-shared/utils/base-path.js.map +1 -0
- package/dist/workers-shared/utils/configuration/constants.d.ts +15 -0
- package/dist/workers-shared/utils/configuration/constants.js +16 -0
- package/dist/workers-shared/utils/configuration/constants.js.map +1 -0
- package/dist/workers-shared/utils/configuration/constructConfiguration.d.ts +12 -0
- package/dist/workers-shared/utils/configuration/constructConfiguration.js +103 -0
- package/dist/workers-shared/utils/configuration/constructConfiguration.js.map +1 -0
- package/dist/workers-shared/utils/configuration/parseHeaders.d.ts +5 -0
- package/dist/workers-shared/utils/configuration/parseHeaders.js +181 -0
- package/dist/workers-shared/utils/configuration/parseHeaders.js.map +1 -0
- package/dist/workers-shared/utils/configuration/parseRedirects.d.ts +8 -0
- package/dist/workers-shared/utils/configuration/parseRedirects.js +129 -0
- package/dist/workers-shared/utils/configuration/parseRedirects.js.map +1 -0
- package/dist/workers-shared/utils/configuration/parseStaticRouting.d.ts +2 -0
- package/dist/workers-shared/utils/configuration/parseStaticRouting.js +94 -0
- package/dist/workers-shared/utils/configuration/parseStaticRouting.js.map +1 -0
- package/dist/workers-shared/utils/configuration/types.d.ts +38 -0
- package/dist/workers-shared/utils/configuration/types.js +2 -0
- package/dist/workers-shared/utils/configuration/types.js.map +1 -0
- package/dist/workers-shared/utils/configuration/validateURL.d.ts +3 -0
- package/dist/workers-shared/utils/configuration/validateURL.js +56 -0
- package/dist/workers-shared/utils/configuration/validateURL.js.map +1 -0
- package/dist/workers-shared/utils/constants.d.ts +28 -0
- package/dist/workers-shared/utils/constants.js +34 -0
- package/dist/workers-shared/utils/constants.js.map +1 -0
- package/dist/workers-shared/utils/helpers.d.ts +22 -0
- package/dist/workers-shared/utils/helpers.js +73 -0
- package/dist/workers-shared/utils/helpers.js.map +1 -0
- package/dist/workers-shared/utils/responses.d.ts +43 -0
- package/dist/workers-shared/utils/responses.js +125 -0
- package/dist/workers-shared/utils/responses.js.map +1 -0
- package/dist/workers-shared/utils/tracing.d.ts +3 -0
- package/dist/workers-shared/utils/tracing.js +29 -0
- package/dist/workers-shared/utils/tracing.js.map +1 -0
- package/dist/workers-shared/utils/types.d.ts +131 -0
- package/dist/workers-shared/utils/types.js +72 -0
- package/dist/workers-shared/utils/types.js.map +1 -0
- package/package.json +16 -32
- package/INTEGRATION.md +0 -399
- package/dist/cli/args.d.ts +0 -28
- package/dist/cli/args.d.ts.map +0 -1
- package/dist/cli/args.js +0 -148
- package/dist/cli/args.js.map +0 -1
- package/dist/cli/argumentChunks.d.ts +0 -3
- package/dist/cli/argumentChunks.d.ts.map +0 -1
- package/dist/cli/argumentChunks.js +0 -29
- package/dist/cli/argumentChunks.js.map +0 -1
- package/dist/cli/collectFiles.d.ts +0 -10
- package/dist/cli/collectFiles.d.ts.map +0 -1
- package/dist/cli/collectFiles.js +0 -53
- package/dist/cli/collectFiles.js.map +0 -1
- package/dist/cli/commands.d.ts +0 -8
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -56
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/componentName.d.ts +0 -32
- package/dist/cli/componentName.d.ts.map +0 -1
- package/dist/cli/componentName.js +0 -43
- package/dist/cli/componentName.js.map +0 -1
- package/dist/cli/deploy.d.ts +0 -16
- package/dist/cli/deploy.d.ts.map +0 -1
- package/dist/cli/deploy.js +0 -283
- package/dist/cli/deploy.js.map +0 -1
- package/dist/cli/deployEnvironment.d.ts +0 -10
- package/dist/cli/deployEnvironment.d.ts.map +0 -1
- package/dist/cli/deployEnvironment.js +0 -12
- package/dist/cli/deployEnvironment.js.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/upload.d.ts +0 -22
- package/dist/cli/upload.d.ts.map +0 -1
- package/dist/cli/upload.js +0 -630
- package/dist/cli/upload.js.map +0 -1
- package/dist/client/_generated/_ignore.d.ts +0 -1
- package/dist/client/_generated/_ignore.d.ts.map +0 -1
- package/dist/client/_generated/_ignore.js +0 -3
- package/dist/client/_generated/_ignore.js.map +0 -1
- package/dist/client/index.d.ts.map +0 -1
- package/dist/component/_generated/api.d.ts.map +0 -1
- package/dist/component/_generated/component.d.ts.map +0 -1
- package/dist/component/_generated/dataModel.d.ts.map +0 -1
- package/dist/component/_generated/server.d.ts.map +0 -1
- package/dist/component/convex.config.d.ts.map +0 -1
- package/dist/component/http.d.ts +0 -4
- package/dist/component/http.d.ts.map +0 -1
- package/dist/component/http.js +0 -125
- package/dist/component/http.js.map +0 -1
- package/dist/component/lib.d.ts.map +0 -1
- package/dist/component/schema.d.ts.map +0 -1
- package/dist/component/serving.d.ts +0 -17
- package/dist/component/serving.d.ts.map +0 -1
- package/dist/component/serving.js +0 -150
- package/dist/component/serving.js.map +0 -1
- package/dist/react/index.d.ts +0 -59
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js +0 -137
- package/dist/react/index.js.map +0 -1
- package/src/cli/args.test.ts +0 -79
- package/src/cli/args.ts +0 -153
- package/src/cli/argumentChunks.test.ts +0 -27
- package/src/cli/argumentChunks.ts +0 -40
- package/src/cli/collectFiles.test.ts +0 -26
- package/src/cli/collectFiles.ts +0 -59
- package/src/cli/commands.ts +0 -68
- package/src/cli/componentName.test.ts +0 -41
- package/src/cli/componentName.ts +0 -46
- package/src/cli/deploy.ts +0 -336
- package/src/cli/deployEnvironment.test.ts +0 -27
- package/src/cli/deployEnvironment.ts +0 -17
- package/src/cli/index.ts +0 -65
- package/src/cli/upload.ts +0 -837
- package/src/client/_generated/_ignore.ts +0 -1
- package/src/client/index.test.ts +0 -510
- package/src/client/index.ts +0 -355
- package/src/client/setup.test.ts +0 -22
- package/src/component/_generated/api.ts +0 -54
- package/src/component/_generated/component.ts +0 -55
- package/src/component/_generated/dataModel.ts +0 -60
- package/src/component/_generated/server.ts +0 -156
- package/src/component/convex.config.ts +0 -3
- package/src/component/http.test.ts +0 -223
- package/src/component/http.ts +0 -144
- package/src/component/lib.test.ts +0 -1007
- package/src/component/lib.ts +0 -862
- package/src/component/schema.ts +0 -75
- package/src/component/serving.ts +0 -158
- package/src/component/setup.test.ts +0 -11
- package/src/react/index.tsx +0 -197
- package/src/test.ts +0 -23
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type FunctionArgs, type FunctionReference, type FunctionReturnType, type FunctionType } from "convex/server";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
/** The processes and network calls of the CLI. Tests pass fakes. */
|
|
4
|
+
export interface Cli {
|
|
5
|
+
/** The app's directory, with `convex/` and `.env.local`. */
|
|
6
|
+
cwd: string;
|
|
7
|
+
/** The process environment. */
|
|
8
|
+
env: Record<string, string | undefined>;
|
|
9
|
+
/** Runs the app's `convex` CLI and captures its output. */
|
|
10
|
+
convex: (args: string[]) => Promise<{
|
|
11
|
+
exitCode: number;
|
|
12
|
+
stdout: string;
|
|
13
|
+
stderr: string;
|
|
14
|
+
}>;
|
|
15
|
+
/** Runs the app's `convex` CLI with this process's standard streams; resolves with its exit code. */
|
|
16
|
+
convexInherited: (args: string[]) => Promise<number>;
|
|
17
|
+
/**
|
|
18
|
+
* Runs a shell command in `cwd` with this process's environment and standard streams; resolves
|
|
19
|
+
* with its exit code.
|
|
20
|
+
*/
|
|
21
|
+
shell: (command: string) => Promise<number>;
|
|
22
|
+
fetch: typeof fetch;
|
|
23
|
+
/** Writes a line to standard error. */
|
|
24
|
+
log: (message: string) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare const nodeCli: Cli;
|
|
27
|
+
/** The deployment of a deploy: production by default, `--preview-name <name>`, or `--dev`. */
|
|
28
|
+
export type Destination = {
|
|
29
|
+
kind: "production";
|
|
30
|
+
} | {
|
|
31
|
+
kind: "preview";
|
|
32
|
+
name: string;
|
|
33
|
+
} | {
|
|
34
|
+
kind: "dev";
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The deployment selector of a deploy's `npx convex run` calls. Production gets `--prod`, because
|
|
38
|
+
* `npx convex deploy` goes to production by default while `npx convex run` goes to development; a
|
|
39
|
+
* preview gets `--preview-name <name>`; the development deployment, which `npx convex run` picks
|
|
40
|
+
* from `.env.local`, gets none. A deploy key in the environment wins over the selector. A
|
|
41
|
+
* self-hosted deployment takes no selector.
|
|
42
|
+
*/
|
|
43
|
+
export declare function deploymentSelector(cli: Cli, destination: Destination): string[];
|
|
44
|
+
/** The component instance and the deployment that every call of one command reaches. */
|
|
45
|
+
export type Target = {
|
|
46
|
+
component: string;
|
|
47
|
+
flags: string[];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Probes whether the deployment has the component instance: `undefined` when it has it, and the
|
|
51
|
+
* Convex CLI's output when it does not, which lists the components the deployment has. This probe
|
|
52
|
+
* exists because a function run against a missing component answers a generic
|
|
53
|
+
* `InternalServerError` ("Your request couldn't be completed"), while the Convex CLI's own
|
|
54
|
+
* component lookup for `--inline-query` prints `Component path "<name>" was not found.` The probe
|
|
55
|
+
* is an inline query that reads nothing. Any other failure is an error.
|
|
56
|
+
*/
|
|
57
|
+
export declare function probeComponent(cli: Cli, target: Target): Promise<string | undefined>;
|
|
58
|
+
/**
|
|
59
|
+
* Runs a function of the component with `npx convex run` and validates its result. The Convex CLI
|
|
60
|
+
* prints the result as JSON from another process, so `result` checks it at runtime; its type makes
|
|
61
|
+
* the schema agree with the function's declared return. The CLI prints nothing for `null`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function runComponent<Ref extends FunctionReference<FunctionType, "internal">>(cli: Cli, target: Target, ref: Ref, args: FunctionArgs<Ref>, result: z.ZodType<FunctionReturnType<Ref>>): Promise<FunctionReturnType<Ref>>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { execFile, spawn } from "node:child_process";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { parseEnv } from "node:util";
|
|
6
|
+
import { getFunctionName, } from "convex/server";
|
|
7
|
+
/** The app's own Convex CLI, so the CLI version and the deployment settings match the app. */
|
|
8
|
+
function convexBin(cwd) {
|
|
9
|
+
const requireFromApp = createRequire(join(cwd, "package.json"));
|
|
10
|
+
return join(dirname(requireFromApp.resolve("convex/package.json")), "bin", "main.js");
|
|
11
|
+
}
|
|
12
|
+
export const nodeCli = {
|
|
13
|
+
cwd: process.cwd(),
|
|
14
|
+
env: process.env,
|
|
15
|
+
convex: (args) => new Promise((resolve) => {
|
|
16
|
+
execFile(process.execPath, [convexBin(process.cwd()), ...args], { encoding: "utf8" }, (error, stdout, stderr) => {
|
|
17
|
+
const exitCode = error === null ? 0 : typeof error.code === "number" ? error.code : 1;
|
|
18
|
+
resolve({ exitCode, stdout, stderr });
|
|
19
|
+
});
|
|
20
|
+
}),
|
|
21
|
+
convexInherited: (args) => exitCode(spawn(process.execPath, [convexBin(process.cwd()), ...args], { stdio: "inherit" })),
|
|
22
|
+
shell: (command) => exitCode(spawn(command, { shell: true, stdio: "inherit" })),
|
|
23
|
+
fetch: (input, init) => fetch(input, init),
|
|
24
|
+
log: (message) => console.error(message),
|
|
25
|
+
};
|
|
26
|
+
/** The exit code of `child`, or its spawn error. */
|
|
27
|
+
function exitCode(child) {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
child.on("error", reject).on("close", (code) => resolve(code ?? 1));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The variables that the Convex CLI reads to select a deployment, in its order: the process
|
|
34
|
+
* environment first, then `.env.local`, then `.env`.
|
|
35
|
+
*/
|
|
36
|
+
function readConvexEnv(cli) {
|
|
37
|
+
const fromFile = (name) => {
|
|
38
|
+
const path = join(cli.cwd, name);
|
|
39
|
+
return existsSync(path) ? parseEnv(readFileSync(path, "utf8")) : {};
|
|
40
|
+
};
|
|
41
|
+
return { ...fromFile(".env"), ...fromFile(".env.local"), ...cli.env };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The deployment selector of a deploy's `npx convex run` calls. Production gets `--prod`, because
|
|
45
|
+
* `npx convex deploy` goes to production by default while `npx convex run` goes to development; a
|
|
46
|
+
* preview gets `--preview-name <name>`; the development deployment, which `npx convex run` picks
|
|
47
|
+
* from `.env.local`, gets none. A deploy key in the environment wins over the selector. A
|
|
48
|
+
* self-hosted deployment takes no selector.
|
|
49
|
+
*/
|
|
50
|
+
export function deploymentSelector(cli, destination) {
|
|
51
|
+
if (readConvexEnv(cli).CONVEX_SELF_HOSTED_URL)
|
|
52
|
+
return [];
|
|
53
|
+
switch (destination.kind) {
|
|
54
|
+
case "production":
|
|
55
|
+
return ["--prod"];
|
|
56
|
+
case "preview":
|
|
57
|
+
return ["--preview-name", destination.name];
|
|
58
|
+
case "dev":
|
|
59
|
+
return [];
|
|
60
|
+
default:
|
|
61
|
+
return destination;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Probes whether the deployment has the component instance: `undefined` when it has it, and the
|
|
66
|
+
* Convex CLI's output when it does not, which lists the components the deployment has. This probe
|
|
67
|
+
* exists because a function run against a missing component answers a generic
|
|
68
|
+
* `InternalServerError` ("Your request couldn't be completed"), while the Convex CLI's own
|
|
69
|
+
* component lookup for `--inline-query` prints `Component path "<name>" was not found.` The probe
|
|
70
|
+
* is an inline query that reads nothing. Any other failure is an error.
|
|
71
|
+
*/
|
|
72
|
+
export async function probeComponent(cli, target) {
|
|
73
|
+
const { exitCode, stdout, stderr } = await cli.convex([
|
|
74
|
+
"run",
|
|
75
|
+
"--component",
|
|
76
|
+
target.component,
|
|
77
|
+
"--inline-query",
|
|
78
|
+
"null",
|
|
79
|
+
...target.flags,
|
|
80
|
+
]);
|
|
81
|
+
if (exitCode === 0)
|
|
82
|
+
return undefined;
|
|
83
|
+
const output = `${stderr}\n${stdout}`.trim();
|
|
84
|
+
if (output.includes(`Component path "${target.component}" was not found.`))
|
|
85
|
+
return output;
|
|
86
|
+
throw new Error(stderr.trim() || stdout.trim() || `npx convex run exited with ${exitCode}.`);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Runs a function of the component with `npx convex run` and validates its result. The Convex CLI
|
|
90
|
+
* prints the result as JSON from another process, so `result` checks it at runtime; its type makes
|
|
91
|
+
* the schema agree with the function's declared return. The CLI prints nothing for `null`.
|
|
92
|
+
*/
|
|
93
|
+
export async function runComponent(cli, target, ref, args, result) {
|
|
94
|
+
const functionName = getFunctionName(ref);
|
|
95
|
+
const { exitCode, stdout, stderr } = await cli.convex([
|
|
96
|
+
"run",
|
|
97
|
+
"--component",
|
|
98
|
+
target.component,
|
|
99
|
+
functionName,
|
|
100
|
+
JSON.stringify(args),
|
|
101
|
+
...target.flags,
|
|
102
|
+
]);
|
|
103
|
+
if (exitCode !== 0) {
|
|
104
|
+
throw new Error(stderr.trim() || stdout.trim() || `npx convex run ${functionName} exited with ${exitCode}.`);
|
|
105
|
+
}
|
|
106
|
+
return result.parse(stdout.trim() === "" ? null : JSON.parse(stdout));
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=convex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.js","sourceRoot":"","sources":["../../src/cli/convex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,eAAe,GAKhB,MAAM,eAAe,CAAC;AAuBvB,8FAA8F;AAC9F,SAAS,SAAS,CAAC,GAAW;IAC5B,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC;IAChE,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AACxF,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAQ;IAC1B,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;IAClB,GAAG,EAAE,OAAO,CAAC,GAAG;IAChB,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CACf,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE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AAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Config } from "../component/lib.js";
|
|
2
|
+
export type HandlingOptions = Required<Pick<Config, "html_handling" | "not_found_handling">>;
|
|
3
|
+
/** One file of the build: its URL path, its sha256 in hex, its content type, and its file on disk. */
|
|
4
|
+
export type DistEntry = {
|
|
5
|
+
path: string;
|
|
6
|
+
sha256: string;
|
|
7
|
+
contentType: string | undefined;
|
|
8
|
+
file: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Reads the build in `dist` the way Wrangler reads an assets directory: every file that
|
|
12
|
+
* `.assetsignore` does not ignore, and the config from `_headers` and `_redirects`, parsed by
|
|
13
|
+
* Cloudflare's own parsers.
|
|
14
|
+
*/
|
|
15
|
+
export declare function readDist(dist: string, handling: HandlingOptions, log: (message: string) => void): Promise<{
|
|
16
|
+
config: Config;
|
|
17
|
+
entries: DistEntry[];
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
3
|
+
import { join, relative } from "node:path";
|
|
4
|
+
import { constructHeaders, constructRedirects, } from "../workers-shared/utils/configuration/constructConfiguration.js";
|
|
5
|
+
import { parseHeaders } from "../workers-shared/utils/configuration/parseHeaders.js";
|
|
6
|
+
import { parseRedirects } from "../workers-shared/utils/configuration/parseRedirects.js";
|
|
7
|
+
import { HEADERS_FILENAME, MAX_ASSET_SIZE, REDIRECTS_FILENAME, } from "../workers-shared/utils/constants.js";
|
|
8
|
+
import { createAssetsIgnoreFunction, getContentType, maybeGetFile, normalizeFilePath, } from "../workers-shared/utils/helpers.js";
|
|
9
|
+
/**
|
|
10
|
+
* Convex limits a document to 1 MiB. The version document holds the config next to two short
|
|
11
|
+
* fields, and the encoding needs room too.
|
|
12
|
+
*/
|
|
13
|
+
const MAX_CONFIG_BYTES = 900 * 1024;
|
|
14
|
+
/**
|
|
15
|
+
* Reads the build in `dist` the way Wrangler reads an assets directory: every file that
|
|
16
|
+
* `.assetsignore` does not ignore, and the config from `_headers` and `_redirects`, parsed by
|
|
17
|
+
* Cloudflare's own parsers.
|
|
18
|
+
*/
|
|
19
|
+
export async function readDist(dist, handling, log) {
|
|
20
|
+
if (!existsSync(dist))
|
|
21
|
+
throw new Error(`The --dist folder ${dist} does not exist.`);
|
|
22
|
+
const { assetsIgnoreFunction } = await createAssetsIgnoreFunction(dist);
|
|
23
|
+
const entries = [];
|
|
24
|
+
// The real paths of the folders already walked. A link to a folder that is already included, for
|
|
25
|
+
// example a link to `dist` itself, would otherwise be walked without end.
|
|
26
|
+
const walked = new Set([realpathSync(dist)]);
|
|
27
|
+
const walk = (directory) => {
|
|
28
|
+
for (const name of readdirSync(directory)) {
|
|
29
|
+
const file = join(directory, name);
|
|
30
|
+
// A symbolic link counts as what it points to, as in Wrangler, which reads each path with
|
|
31
|
+
// `stat`. A name that `readdir` lists and `stat` cannot find is a link to nothing.
|
|
32
|
+
const stats = statSync(file, { throwIfNoEntry: false });
|
|
33
|
+
if (stats === undefined) {
|
|
34
|
+
log(`Skipped ${file}: a symbolic link to nothing.`);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
// `ignore` takes paths relative to `dist` with `/`, and a directory with a trailing `/`.
|
|
38
|
+
const ignorePath = relative(dist, file).replaceAll("\\", "/");
|
|
39
|
+
if (stats.isDirectory()) {
|
|
40
|
+
// An ignored directory is not walked: gitignore rules cannot re-include a file in it. It
|
|
41
|
+
// does not count as walked either, so an ignored link does not hide the folder it points to.
|
|
42
|
+
if (assetsIgnoreFunction(`${ignorePath}/`))
|
|
43
|
+
continue;
|
|
44
|
+
const real = realpathSync(file);
|
|
45
|
+
if (walked.has(real)) {
|
|
46
|
+
log(`Skipped ${file}: a link to a folder that is already included.`);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
walked.add(real);
|
|
50
|
+
walk(file);
|
|
51
|
+
}
|
|
52
|
+
else if (stats.isFile() && !assetsIgnoreFunction(ignorePath)) {
|
|
53
|
+
const bytes = readFileSync(file);
|
|
54
|
+
// Cloudflare's limit per asset, 25 MiB. The HTTP action that serves a file cannot answer
|
|
55
|
+
// more than Convex's 100 MiB response limit anyway.
|
|
56
|
+
if (bytes.byteLength > MAX_ASSET_SIZE) {
|
|
57
|
+
throw new Error(`${file} is ${(bytes.byteLength / 1024 / 1024).toFixed(1)} MiB. A file must stay at ` +
|
|
58
|
+
"or below 25 MiB, Cloudflare's limit per asset.");
|
|
59
|
+
}
|
|
60
|
+
entries.push({
|
|
61
|
+
path: normalizeFilePath(relative(dist, file)),
|
|
62
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
63
|
+
contentType: getContentType(file) ?? undefined,
|
|
64
|
+
file,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
walk(dist);
|
|
70
|
+
const logger = {
|
|
71
|
+
debug: () => { },
|
|
72
|
+
log,
|
|
73
|
+
info: log,
|
|
74
|
+
warn: log,
|
|
75
|
+
error: (error) => log(error.message),
|
|
76
|
+
};
|
|
77
|
+
const redirectsFile = join(dist, REDIRECTS_FILENAME);
|
|
78
|
+
const redirects = maybeGetFile(redirectsFile);
|
|
79
|
+
const headersFile = join(dist, HEADERS_FILENAME);
|
|
80
|
+
const headers = maybeGetFile(headersFile);
|
|
81
|
+
const config = {
|
|
82
|
+
html_handling: handling.html_handling,
|
|
83
|
+
not_found_handling: handling.not_found_handling,
|
|
84
|
+
...(redirects === undefined
|
|
85
|
+
? {}
|
|
86
|
+
: constructRedirects({
|
|
87
|
+
redirects: parseRedirects(redirects, { htmlHandling: handling.html_handling }),
|
|
88
|
+
redirectsFile,
|
|
89
|
+
logger,
|
|
90
|
+
})),
|
|
91
|
+
...(headers === undefined
|
|
92
|
+
? {}
|
|
93
|
+
: constructHeaders({ headers: parseHeaders(headers), headersFile, logger })),
|
|
94
|
+
};
|
|
95
|
+
const configBytes = Buffer.byteLength(JSON.stringify(config));
|
|
96
|
+
if (configBytes > MAX_CONFIG_BYTES) {
|
|
97
|
+
const largest = Buffer.byteLength(JSON.stringify(config.redirects ?? {})) >=
|
|
98
|
+
Buffer.byteLength(JSON.stringify(config.headers ?? {}))
|
|
99
|
+
? redirectsFile
|
|
100
|
+
: headersFile;
|
|
101
|
+
throw new Error(`The rules in ${largest} make the version's config ${Math.ceil(configBytes / 1024)} KiB. ` +
|
|
102
|
+
"It must stay at or below 900 KiB, because Convex limits a document to 1 MiB.");
|
|
103
|
+
}
|
|
104
|
+
return { config, entries };
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/cli/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,iEAAiE,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,uDAAuD,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,yDAAyD,CAAC;AACzF,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,kBAAkB,GACnB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,0BAA0B,EAC1B,cAAc,EACd,YAAY,EACZ,iBAAiB,GAClB,MAAM,oCAAoC,CAAC;AAE5C;;;GAGG;AACH,MAAM,gBAAgB,GAAG,GAAG,GAAG,IAAI,CAAC;AAYpC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,IAAY,EACZ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AAE,OAAO,EAAE,CAAC;AAC7B,CAAC"}
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
* CLI for Convex Hosting
|
|
4
|
-
*
|
|
5
|
-
* Commands:
|
|
6
|
-
* deploy One-shot deployment (Convex backend + static files)
|
|
7
|
-
* upload Upload static files to Convex storage
|
|
8
|
-
*/
|
|
9
|
-
declare const command: string;
|
|
10
|
-
declare function main(): Promise<void>;
|
|
11
|
-
declare function printHelp(): void;
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
2
|
+
export {};
|
package/dist/cli/index.js
CHANGED
|
@@ -1,60 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* Commands:
|
|
7
|
-
* deploy One-shot deployment (Convex backend + static files)
|
|
8
|
-
* upload Upload static files to Convex storage
|
|
9
|
-
*/
|
|
10
|
-
const command = process.argv[2];
|
|
11
|
-
async function main() {
|
|
12
|
-
switch (command) {
|
|
13
|
-
case "deploy":
|
|
14
|
-
// Pass remaining args to deploy command
|
|
15
|
-
process.argv.splice(2, 1);
|
|
16
|
-
await import("./deploy.js");
|
|
17
|
-
break;
|
|
18
|
-
case "upload":
|
|
19
|
-
// Pass remaining args to upload command
|
|
20
|
-
process.argv.splice(2, 1);
|
|
21
|
-
await import("./upload.js");
|
|
22
|
-
break;
|
|
23
|
-
case "--help":
|
|
24
|
-
case "-h":
|
|
25
|
-
case undefined:
|
|
26
|
-
printHelp();
|
|
27
|
-
break;
|
|
28
|
-
default:
|
|
29
|
-
console.error(`Unknown command: ${command}`);
|
|
30
|
-
console.log("");
|
|
31
|
-
printHelp();
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function printHelp() {
|
|
36
|
-
console.log(`
|
|
37
|
-
Convex Hosting CLI
|
|
38
|
-
|
|
39
|
-
Usage:
|
|
40
|
-
npx @samebase/convex-hosting <command> [options]
|
|
41
|
-
|
|
42
|
-
Commands:
|
|
43
|
-
deploy One-shot deployment (Convex backend + static files)
|
|
44
|
-
upload Upload static files to Convex storage
|
|
45
|
-
|
|
46
|
-
Examples:
|
|
47
|
-
# One-shot deployment
|
|
48
|
-
npx @samebase/convex-hosting deploy
|
|
49
|
-
|
|
50
|
-
# Upload only (no Convex backend deploy)
|
|
51
|
-
npx @samebase/convex-hosting upload --build --prod
|
|
52
|
-
|
|
53
|
-
Run '<command> --help' for more information on a specific command.
|
|
54
|
-
`);
|
|
55
|
-
}
|
|
56
|
-
main().catch((err) => {
|
|
57
|
-
console.error("Error:", err);
|
|
58
|
-
process.exit(1);
|
|
59
|
-
});
|
|
2
|
+
import { nodeCli } from "./convex.js";
|
|
3
|
+
import { main } from "./main.js";
|
|
4
|
+
process.exitCode = await main(process.argv.slice(2), nodeCli);
|
|
60
5
|
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Cli } from "./convex.js";
|
|
2
|
+
/** The file that the upload writes and the app's `convex/http.ts` imports. */
|
|
3
|
+
export declare const VERSION_FILE: string;
|
|
4
|
+
/** Runs one `convex-hosting` command and returns the exit code. */
|
|
5
|
+
export declare function main(args: string[], cli: Cli): Promise<number>;
|