@samebase/convex-hosting 0.3.2 → 0.4.1
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 +17 -132
- package/README.md +188 -406
- 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 +377 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/client/index.d.ts +8 -115
- package/dist/client/index.js +65 -242
- 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 +21 -37
- 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 -113
- 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 -23
- package/dist/component/serving.d.ts.map +0 -1
- package/dist/component/serving.js +0 -161
- 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 -549
- package/src/client/index.ts +0 -344
- 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 -254
- package/src/component/http.ts +0 -133
- 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 -170
- package/src/component/setup.test.ts +0 -11
- package/src/react/index.tsx +0 -197
- package/src/test.ts +0 -23
package/dist/cli/main.js
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { internal } from "../component/_generated/api.js";
|
|
8
|
+
import { AssetConfigSchema } from "../workers-shared/utils/types.js";
|
|
9
|
+
import { deploymentSelector, probeComponent, runComponent, } from "./convex.js";
|
|
10
|
+
import { readDist } from "./files.js";
|
|
11
|
+
const USAGE = `Usage:
|
|
12
|
+
convex-hosting init
|
|
13
|
+
Once per clone, before npx convex dev: writes .convex-hosting/version.js with no site
|
|
14
|
+
version, so convex/http.ts bundles. Keeps an existing file.
|
|
15
|
+
convex-hosting deploy --build "<command>" --dist <dir> [options]
|
|
16
|
+
Builds, stores the site files, and pushes the functions. The push switches the site.
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
--dev the development deployment of this checkout, instead of production
|
|
20
|
+
--preview-name <name> the preview deployment with this name, instead of production
|
|
21
|
+
--html-handling <value> auto-trailing-slash (default), force-trailing-slash,
|
|
22
|
+
drop-trailing-slash, or none
|
|
23
|
+
--not-found-handling <value> none (default), single-page-application, or 404-page
|
|
24
|
+
--component <name> the component instance (default: hosting)
|
|
25
|
+
-h, --help this text`;
|
|
26
|
+
/**
|
|
27
|
+
* The CLI's state folder at the project root, like Wrangler's `.wrangler/`. It holds its own
|
|
28
|
+
* `.gitignore`, so git ignores it without a line in the app's ignore file.
|
|
29
|
+
*/
|
|
30
|
+
const STATE_DIR = ".convex-hosting";
|
|
31
|
+
/** The file that the upload writes and the app's `convex/http.ts` imports. */
|
|
32
|
+
export const VERSION_FILE = join(STATE_DIR, "version.js");
|
|
33
|
+
/**
|
|
34
|
+
* The inner `upload` of a first install writes this file when the component is not installed yet.
|
|
35
|
+
* `deploy` then uploads after the push.
|
|
36
|
+
*/
|
|
37
|
+
const FIRST_INSTALL_MARKER = join(STATE_DIR, "first-install");
|
|
38
|
+
/**
|
|
39
|
+
* The version that `init` writes. Deploys name versions with random UUIDs, so no version has this
|
|
40
|
+
* id, and `serveAsset` answers 404 naming it until the first deploy writes a real one.
|
|
41
|
+
*/
|
|
42
|
+
const NOT_DEPLOYED = "not-deployed";
|
|
43
|
+
/** Files that the upload sends to storage at once. */
|
|
44
|
+
const UPLOAD_CONCURRENCY = 4;
|
|
45
|
+
/**
|
|
46
|
+
* Files per page of uploads. A page's upload URLs are made together, and its entries are recorded
|
|
47
|
+
* before the next page starts, so a retry after a crash reuses them.
|
|
48
|
+
*/
|
|
49
|
+
const UPLOAD_PAGE = 100;
|
|
50
|
+
/**
|
|
51
|
+
* `npx convex run` passes the arguments on the command line, which Windows limits to 32,767
|
|
52
|
+
* characters; `knownFiles` and `recordFiles` calls stay well below that. The component counts
|
|
53
|
+
* what a call of this length reads and writes.
|
|
54
|
+
*/
|
|
55
|
+
const MAX_ARGUMENT_LENGTH = 8_000;
|
|
56
|
+
const htmlHandlingSchema = AssetConfigSchema.shape.html_handling.unwrap();
|
|
57
|
+
const notFoundHandlingSchema = AssetConfigSchema.shape.not_found_handling.unwrap();
|
|
58
|
+
function parseCommand(args) {
|
|
59
|
+
const { values, positionals } = parseArgs({
|
|
60
|
+
args,
|
|
61
|
+
allowPositionals: true,
|
|
62
|
+
strict: true,
|
|
63
|
+
options: {
|
|
64
|
+
build: { type: "string" },
|
|
65
|
+
dist: { type: "string" },
|
|
66
|
+
dev: { type: "boolean", default: false },
|
|
67
|
+
"preview-name": { type: "string" },
|
|
68
|
+
"html-handling": { type: "string", default: "auto-trailing-slash" },
|
|
69
|
+
"not-found-handling": { type: "string", default: "none" },
|
|
70
|
+
component: { type: "string", default: "hosting" },
|
|
71
|
+
"version-id": { type: "string" },
|
|
72
|
+
help: { type: "boolean", short: "h", default: false },
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
if (args.length === 0 || values.help)
|
|
76
|
+
return { name: "help" };
|
|
77
|
+
const [name, ...rest] = positionals;
|
|
78
|
+
if (name === "init") {
|
|
79
|
+
const deployOption = values.dist ?? values.build ?? values["version-id"] ?? values["preview-name"];
|
|
80
|
+
if (rest.length > 0 || deployOption !== undefined || values.dev)
|
|
81
|
+
throw new Error(USAGE);
|
|
82
|
+
return { name };
|
|
83
|
+
}
|
|
84
|
+
if ((name !== "deploy" && name !== "upload") || rest.length > 0)
|
|
85
|
+
throw new Error(USAGE);
|
|
86
|
+
if (values.dist === undefined)
|
|
87
|
+
throw new Error(`--dist is required.\n\n${USAGE}`);
|
|
88
|
+
if (values.dev && values["preview-name"] !== undefined) {
|
|
89
|
+
throw new Error("--dev and --preview-name exclude each other.");
|
|
90
|
+
}
|
|
91
|
+
const htmlHandling = htmlHandlingSchema.safeParse(values["html-handling"]);
|
|
92
|
+
if (!htmlHandling.success) {
|
|
93
|
+
throw new Error(`--html-handling must be one of: ${htmlHandlingSchema.options.join(", ")}.`);
|
|
94
|
+
}
|
|
95
|
+
const notFoundHandling = notFoundHandlingSchema.safeParse(values["not-found-handling"]);
|
|
96
|
+
if (!notFoundHandling.success) {
|
|
97
|
+
throw new Error(`--not-found-handling must be one of: ${notFoundHandlingSchema.options.join(", ")}.`);
|
|
98
|
+
}
|
|
99
|
+
const options = {
|
|
100
|
+
dist: values.dist,
|
|
101
|
+
html_handling: htmlHandling.data,
|
|
102
|
+
not_found_handling: notFoundHandling.data,
|
|
103
|
+
component: values.component,
|
|
104
|
+
destination: values.dev
|
|
105
|
+
? { kind: "dev" }
|
|
106
|
+
: values["preview-name"] === undefined
|
|
107
|
+
? { kind: "production" }
|
|
108
|
+
: { kind: "preview", name: values["preview-name"] },
|
|
109
|
+
};
|
|
110
|
+
// `upload` is the step that `deploy` runs inside `npx convex deploy --cmd`, after the build.
|
|
111
|
+
if (name === "upload") {
|
|
112
|
+
if (values["version-id"] === undefined || values.build !== undefined || values.dev) {
|
|
113
|
+
throw new Error(USAGE);
|
|
114
|
+
}
|
|
115
|
+
return { name, versionId: values["version-id"], options };
|
|
116
|
+
}
|
|
117
|
+
if (values.build === undefined)
|
|
118
|
+
throw new Error(`--build is required.\n\n${USAGE}`);
|
|
119
|
+
if (values["version-id"] !== undefined)
|
|
120
|
+
throw new Error(USAGE);
|
|
121
|
+
return { name, build: values.build, options };
|
|
122
|
+
}
|
|
123
|
+
/** Runs one `convex-hosting` command and returns the exit code. */
|
|
124
|
+
export async function main(args, cli) {
|
|
125
|
+
try {
|
|
126
|
+
const command = parseCommand(args);
|
|
127
|
+
if (command.name === "help") {
|
|
128
|
+
cli.log(USAGE);
|
|
129
|
+
}
|
|
130
|
+
else if (command.name === "init") {
|
|
131
|
+
init(cli);
|
|
132
|
+
}
|
|
133
|
+
else if (command.name === "deploy") {
|
|
134
|
+
await deploy(cli, command.options, command.build);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
await uploadInsideDeploy(cli, command.options, command.versionId);
|
|
138
|
+
}
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
cli.log(error instanceof Error ? error.message : String(error));
|
|
143
|
+
return 1;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** Quotes one argument of the `--cmd` that `npx convex deploy` runs in a shell. */
|
|
147
|
+
function quote(arg) {
|
|
148
|
+
return process.platform === "win32" ? `"${arg}"` : `'${arg.replaceAll("'", `'\\''`)}'`;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Builds, uploads, writes the version file, and pushes. The push is the switch, and the command
|
|
152
|
+
* ends: the first request that the new code serves marks its version live.
|
|
153
|
+
*/
|
|
154
|
+
async function deploy(cli, options, build) {
|
|
155
|
+
const target = {
|
|
156
|
+
component: options.component,
|
|
157
|
+
flags: deploymentSelector(cli, options.destination),
|
|
158
|
+
};
|
|
159
|
+
const versionId = randomUUID();
|
|
160
|
+
if (options.destination.kind === "dev") {
|
|
161
|
+
await deployDev(cli, options, target, versionId, build);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
await deployWithConvexDeploy(cli, options, target, versionId, build);
|
|
165
|
+
}
|
|
166
|
+
cli.log(`Deployed version ${versionId}.`);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The development deployment, in one process. The build runs as a child of this process in the
|
|
170
|
+
* project directory: the framework reads the deployment's URL from `.env.local` itself (Vite reads
|
|
171
|
+
* `VITE_CONVEX_URL`). Then the upload runs here, and `npx convex run --push` pushes, with an inline
|
|
172
|
+
* query at the app's root, which exists before the push installs the component. It works whether
|
|
173
|
+
* or not `npx convex dev` runs; `npx convex dev --once` refuses while it runs a local deployment's
|
|
174
|
+
* backend.
|
|
175
|
+
*/
|
|
176
|
+
async function deployDev(cli, options, target, versionId, build) {
|
|
177
|
+
const buildExitCode = await cli.shell(build);
|
|
178
|
+
if (buildExitCode !== 0)
|
|
179
|
+
throw new Error(`The build failed with exit code ${buildExitCode}.`);
|
|
180
|
+
const missing = await upload(cli, options, target, versionId);
|
|
181
|
+
if (missing !== undefined)
|
|
182
|
+
cli.log(notInstalledYet(options.component));
|
|
183
|
+
const exitCode = await cli.convexInherited(["run", "--push", "--inline-query", "null"]);
|
|
184
|
+
if (exitCode !== 0)
|
|
185
|
+
throw new Error(`npx convex run --push failed with exit code ${exitCode}.`);
|
|
186
|
+
if (missing !== undefined)
|
|
187
|
+
await uploadAfterPush(cli, options, target, versionId);
|
|
188
|
+
}
|
|
189
|
+
/** Production or a preview: the build and the upload run inside `npx convex deploy --cmd`. */
|
|
190
|
+
async function deployWithConvexDeploy(cli, options, target, versionId, build) {
|
|
191
|
+
const marker = join(cli.cwd, FIRST_INSTALL_MARKER);
|
|
192
|
+
rmSync(marker, { force: true });
|
|
193
|
+
// `npx convex deploy` goes to production by default and has no `--prod` flag.
|
|
194
|
+
const deployFlags = target.flags.filter((flag) => flag !== "--prod");
|
|
195
|
+
const previewFlags = options.destination.kind === "preview" ? ["--preview-name", options.destination.name] : [];
|
|
196
|
+
const innerUpload = [
|
|
197
|
+
process.execPath,
|
|
198
|
+
fileURLToPath(new URL("./index.js", import.meta.url)),
|
|
199
|
+
"upload",
|
|
200
|
+
"--dist",
|
|
201
|
+
options.dist,
|
|
202
|
+
"--version-id",
|
|
203
|
+
versionId,
|
|
204
|
+
"--html-handling",
|
|
205
|
+
options.html_handling,
|
|
206
|
+
"--not-found-handling",
|
|
207
|
+
options.not_found_handling,
|
|
208
|
+
"--component",
|
|
209
|
+
options.component,
|
|
210
|
+
...previewFlags,
|
|
211
|
+
]
|
|
212
|
+
.map(quote)
|
|
213
|
+
.join(" ");
|
|
214
|
+
// The build and the upload run in the project directory; a build must not change directory.
|
|
215
|
+
const exitCode = await cli.convexInherited([
|
|
216
|
+
"deploy",
|
|
217
|
+
"--cmd",
|
|
218
|
+
`${build} && ${innerUpload}`,
|
|
219
|
+
...deployFlags,
|
|
220
|
+
]);
|
|
221
|
+
const firstInstall = existsSync(marker);
|
|
222
|
+
rmSync(marker, { force: true });
|
|
223
|
+
if (exitCode !== 0)
|
|
224
|
+
throw new Error(`npx convex deploy failed with exit code ${exitCode}.`);
|
|
225
|
+
if (firstInstall)
|
|
226
|
+
await uploadAfterPush(cli, options, target, versionId);
|
|
227
|
+
}
|
|
228
|
+
/** The upload inside `npx convex deploy --cmd`. On a first install, `deploy` uploads after the push. */
|
|
229
|
+
async function uploadInsideDeploy(cli, options, versionId) {
|
|
230
|
+
const target = {
|
|
231
|
+
component: options.component,
|
|
232
|
+
flags: deploymentSelector(cli, options.destination),
|
|
233
|
+
};
|
|
234
|
+
if ((await upload(cli, options, target, versionId)) !== undefined) {
|
|
235
|
+
writeStateFile(cli, FIRST_INSTALL_MARKER, "");
|
|
236
|
+
cli.log(notInstalledYet(options.component));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function notInstalledYet(component) {
|
|
240
|
+
return `The component "${component}" is not installed yet. The push installs it, and the upload runs after the push.`;
|
|
241
|
+
}
|
|
242
|
+
/** The upload of a first install, after the push. The probe's output shows a mistyped `--component`. */
|
|
243
|
+
async function uploadAfterPush(cli, options, target, versionId) {
|
|
244
|
+
const missing = await upload(cli, options, target, versionId);
|
|
245
|
+
if (missing !== undefined) {
|
|
246
|
+
throw new Error(`The component "${options.component}" is not installed after the push. The Convex CLI ` +
|
|
247
|
+
`said:\n${missing}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Uploads `--dist` as version `versionId` and writes the version file. When the component is not
|
|
252
|
+
* installed yet, it writes only the version file, so that the push that follows installs the
|
|
253
|
+
* component, and returns the probe's output.
|
|
254
|
+
*/
|
|
255
|
+
async function upload(cli, options, target, versionId) {
|
|
256
|
+
const dist = resolve(cli.cwd, options.dist);
|
|
257
|
+
const { config, entries } = await readDist(dist, options, cli.log);
|
|
258
|
+
const generateUploadUrls = (count) => runComponent(cli, target, internal.lib.generateUploadUrls, { count }, z.array(z.string()).length(count));
|
|
259
|
+
const missing = await probeComponent(cli, target);
|
|
260
|
+
if (missing !== undefined) {
|
|
261
|
+
writeVersionFile(cli, versionId);
|
|
262
|
+
return missing;
|
|
263
|
+
}
|
|
264
|
+
cli.log(`Uploading version ${versionId}: ${entries.length} files.`);
|
|
265
|
+
const [configUrl] = await generateUploadUrls(1);
|
|
266
|
+
const configId = await store(cli, configUrl, JSON.stringify(config), "application/json");
|
|
267
|
+
await runComponent(cli, target, internal.lib.createVersion, { versionId, configId }, z.null());
|
|
268
|
+
// Entries with the same bytes share one stored file.
|
|
269
|
+
const groups = new Map();
|
|
270
|
+
for (const entry of entries) {
|
|
271
|
+
groups.set(entry.sha256, [...(groups.get(entry.sha256) ?? []), entry]);
|
|
272
|
+
}
|
|
273
|
+
/** Sends the complete entries of stored files, in batches that fit a command line. */
|
|
274
|
+
const record = async (stored) => {
|
|
275
|
+
const complete = stored.flatMap(({ sha256, storageId }) => (groups.get(sha256) ?? []).map(({ path, contentType }) => ({
|
|
276
|
+
path,
|
|
277
|
+
sha256,
|
|
278
|
+
contentType,
|
|
279
|
+
storageId,
|
|
280
|
+
})));
|
|
281
|
+
for (const chunk of chunkByLength(complete)) {
|
|
282
|
+
await runComponent(cli, target, internal.lib.recordFiles, { versionId, entries: chunk }, z.null());
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
// Files that an entry of any version has keep their stored file.
|
|
286
|
+
const known = new Set();
|
|
287
|
+
for (const sha256s of chunkByLength([...groups.keys()])) {
|
|
288
|
+
const files = await runComponent(cli, target, internal.lib.knownFiles, { sha256s }, z.array(z.object({ sha256: z.string(), storageId: storageIdSchema })));
|
|
289
|
+
for (const { sha256 } of files)
|
|
290
|
+
known.add(sha256);
|
|
291
|
+
await record(files);
|
|
292
|
+
}
|
|
293
|
+
const unknown = [...groups.values()].filter((group) => !known.has(group[0].sha256));
|
|
294
|
+
for (let start = 0; start < unknown.length; start += UPLOAD_PAGE) {
|
|
295
|
+
const page = unknown.slice(start, start + UPLOAD_PAGE);
|
|
296
|
+
const urls = await generateUploadUrls(page.length);
|
|
297
|
+
const uploaded = [];
|
|
298
|
+
let next = 0;
|
|
299
|
+
const worker = async () => {
|
|
300
|
+
while (next < page.length) {
|
|
301
|
+
const index = next++;
|
|
302
|
+
const [{ sha256, contentType, file }] = page[index];
|
|
303
|
+
const storageId = await store(cli, urls[index], readFileSync(file), contentType);
|
|
304
|
+
uploaded.push({ sha256, storageId });
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
await Promise.all(Array.from({ length: UPLOAD_CONCURRENCY }, worker));
|
|
308
|
+
await record(uploaded);
|
|
309
|
+
}
|
|
310
|
+
await runComponent(cli, target, internal.lib.finishVersion, { versionId }, z.null());
|
|
311
|
+
writeVersionFile(cli, versionId);
|
|
312
|
+
cli.log(`Uploaded version ${versionId} and wrote ${VERSION_FILE}.`);
|
|
313
|
+
return undefined;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Makes a fresh clone bundle: `convex/http.ts` imports `.convex-hosting/version.js`, which only a
|
|
317
|
+
* deploy writes. Keeps an existing file, which names the version that this checkout last deployed.
|
|
318
|
+
*/
|
|
319
|
+
function init(cli) {
|
|
320
|
+
if (existsSync(join(cli.cwd, VERSION_FILE))) {
|
|
321
|
+
cli.log(`${VERSION_FILE} exists. Nothing to do.`);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
writeVersionFile(cli, NOT_DEPLOYED);
|
|
325
|
+
cli.log(`Wrote ${VERSION_FILE} with no site version, so npx convex dev can bundle convex/http.ts. ` +
|
|
326
|
+
"The site answers 404 until the first convex-hosting deploy.");
|
|
327
|
+
}
|
|
328
|
+
function writeVersionFile(cli, versionId) {
|
|
329
|
+
writeStateFile(cli, VERSION_FILE, `export const versionId = ${JSON.stringify(versionId)};\n`);
|
|
330
|
+
}
|
|
331
|
+
/** Writes a file of the state folder, and the folder's `.gitignore` when it is absent. */
|
|
332
|
+
function writeStateFile(cli, path, body) {
|
|
333
|
+
const gitignore = join(cli.cwd, STATE_DIR, ".gitignore");
|
|
334
|
+
if (!existsSync(gitignore)) {
|
|
335
|
+
mkdirSync(join(cli.cwd, STATE_DIR), { recursive: true });
|
|
336
|
+
writeFileSync(gitignore, "*\n");
|
|
337
|
+
}
|
|
338
|
+
writeFileSync(join(cli.cwd, path), body);
|
|
339
|
+
}
|
|
340
|
+
/** Stores one file through an upload URL and returns its storage id. */
|
|
341
|
+
async function store(cli, url, body, contentType) {
|
|
342
|
+
const response = await cli.fetch(url, {
|
|
343
|
+
method: "POST",
|
|
344
|
+
headers: contentType === undefined ? {} : { "Content-Type": contentType },
|
|
345
|
+
body,
|
|
346
|
+
});
|
|
347
|
+
if (!response.ok) {
|
|
348
|
+
throw new Error(`Storing a file failed with ${response.status}: ${await response.text()}`);
|
|
349
|
+
}
|
|
350
|
+
return z.object({ storageId: storageIdSchema }).parse(await response.json()).storageId;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* A storage id that an upload URL answers with, the documented source of an `Id<"_storage">`, or
|
|
354
|
+
* that `knownFiles` returns. At runtime an id is a string, and its table exists only in its type,
|
|
355
|
+
* so the narrowest honest check here is that it is a string; the `v.id("_storage")` validators of
|
|
356
|
+
* `createVersion` and `recordFiles` check the table on the server.
|
|
357
|
+
*/
|
|
358
|
+
const storageIdSchema = z.custom((value) => typeof value === "string");
|
|
359
|
+
function chunkByLength(items) {
|
|
360
|
+
const chunks = [];
|
|
361
|
+
let chunk = [];
|
|
362
|
+
let length = 0;
|
|
363
|
+
for (const item of items) {
|
|
364
|
+
const itemLength = JSON.stringify(item).length + 1;
|
|
365
|
+
if (chunk.length > 0 && length + itemLength > MAX_ARGUMENT_LENGTH) {
|
|
366
|
+
chunks.push(chunk);
|
|
367
|
+
chunk = [];
|
|
368
|
+
length = 0;
|
|
369
|
+
}
|
|
370
|
+
chunk.push(item);
|
|
371
|
+
length += itemLength;
|
|
372
|
+
}
|
|
373
|
+
if (chunk.length > 0)
|
|
374
|
+
chunks.push(chunk);
|
|
375
|
+
return chunks;
|
|
376
|
+
}
|
|
377
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,YAAY,GAIb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAwC,MAAM,YAAY,CAAC;AAE5E,MAAM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Q,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC;AACzF,CAAC;AAED;;;;;GAKG;AACH,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAiB,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC;AAEvF,SAAS,aAAa,CAAI,KAAU;IAClC,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,IAAI,KAAK,GAAQ,EAAE,CAAC;IACpB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QACnD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,UAAU,GAAG,mBAAmB,EAAE,CAAC;YAClE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,KAAK,GAAG,EAAE,CAAC;YACX,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,MAAM,IAAI,UAAU,CAAC;IACvB,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,119 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { GenericActionCtx, GenericDataModel } from "convex/server";
|
|
2
2
|
import type { ComponentApi } from "../component/_generated/component.js";
|
|
3
|
-
import { decodeRequestPath } from "../component/serving.js";
|
|
4
|
-
type CdnBaseUrl = string | ((request: Request) => string);
|
|
5
|
-
/** The parts of an action context needed to serve a static file. */
|
|
6
|
-
type AssetServingCtx = Pick<GenericActionCtx<GenericDataModel>, "runQuery" | "storage">;
|
|
7
3
|
/**
|
|
8
|
-
*
|
|
4
|
+
* Answers `request` with the asset of version `versionId` that Cloudflare's asset handler picks.
|
|
9
5
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* // convex/convex.config.ts
|
|
18
|
-
* const app = defineApp();
|
|
19
|
-
* app.use(hosting); // no httpPrefix: the app owns HTTP routing
|
|
20
|
-
*
|
|
21
|
-
* // convex/http.ts
|
|
22
|
-
* const http = httpRouter();
|
|
23
|
-
* auth.addHttpRoutes(http);
|
|
24
|
-
* registerStaticRoutes(http, components.hosting);
|
|
25
|
-
* export default http;
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare function registerStaticRoutes(http: HttpRouter, component: ComponentApi, { pathPrefix, spaFallback, cdnBaseUrl, }?: {
|
|
29
|
-
/** URL prefix where the app should serve static files. */
|
|
30
|
-
pathPrefix?: string;
|
|
31
|
-
/** Override the deployment's SPA fallback setting. */
|
|
32
|
-
spaFallback?: boolean;
|
|
33
|
-
/** Optional custom base URL for convex-fs blob redirects. */
|
|
34
|
-
cdnBaseUrl?: CdnBaseUrl;
|
|
35
|
-
}): void;
|
|
36
|
-
/**
|
|
37
|
-
* Serve an uploaded static file from your own HTTP action, or return null when
|
|
38
|
-
* no file matches so the action can continue with its own routing: server
|
|
39
|
-
* rendering, prerendered pages, redirects.
|
|
40
|
-
*
|
|
41
|
-
* Found files get the same response as `registerStaticRoutes`: content type,
|
|
42
|
-
* cache headers, ETag revalidation, and legacy CDN redirects. A found file
|
|
43
|
-
* whose storage can't be read gets a 500 response. A request path with
|
|
44
|
-
* malformed percent-encoding matches no file, so it returns null.
|
|
45
|
-
*
|
|
46
|
-
* The lookup is exact by default. `/` is not mapped to `/index.html`, and there
|
|
47
|
-
* is no SPA fallback, so the SPA shell never answers for a route your action
|
|
48
|
-
* handles. To serve the shell, pass `{ path: "/index.html" }`. When your route
|
|
49
|
-
* has a prefix, pass `path` with the prefix removed.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* // convex/http.ts
|
|
54
|
-
* const http = httpRouter();
|
|
55
|
-
* http.route({
|
|
56
|
-
* pathPrefix: "/",
|
|
57
|
-
* method: "GET",
|
|
58
|
-
* handler: httpAction(async (ctx, request) => {
|
|
59
|
-
* const file = await serveStaticAsset(ctx, components.hosting, request);
|
|
60
|
-
* if (file) return file;
|
|
61
|
-
* return await renderPage(request);
|
|
62
|
-
* }),
|
|
63
|
-
* });
|
|
64
|
-
* export default http;
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
export declare function serveStaticAsset(ctx: AssetServingCtx, component: ComponentApi, request: Request, { path, spaFallback, cdnBaseUrl, }?: {
|
|
68
|
-
/**
|
|
69
|
-
* Decoded file path to look up, starting with `/`, such as
|
|
70
|
-
* `/about/index.html`. Defaults to the decoded request path.
|
|
71
|
-
*/
|
|
72
|
-
path?: string;
|
|
73
|
-
/** Serve `/index.html` for a missing path without a file extension. */
|
|
74
|
-
spaFallback?: boolean;
|
|
75
|
-
/** Optional custom base URL for convex-fs blob redirects. */
|
|
76
|
-
cdnBaseUrl?: CdnBaseUrl;
|
|
77
|
-
}): Promise<Response | null>;
|
|
78
|
-
export { decodeRequestPath };
|
|
79
|
-
/**
|
|
80
|
-
* Expose a query that clients can subscribe to for live reload on deploy.
|
|
81
|
-
* This is only needed if you use `UpdateBanner` / `useDeploymentUpdates` from
|
|
82
|
-
* `@samebase/convex-hosting/react`. If you don't surface deployment updates
|
|
83
|
-
* in your app, you don't need to call this.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* // convex/hosting.ts
|
|
88
|
-
* import { exposeDeploymentQuery } from "@samebase/convex-hosting";
|
|
89
|
-
* import { components } from "./_generated/api";
|
|
90
|
-
*
|
|
91
|
-
* export const { getCurrentDeployment } = exposeDeploymentQuery(
|
|
92
|
-
* components.hosting,
|
|
93
|
-
* );
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
export declare function exposeDeploymentQuery(component: ComponentApi): {
|
|
97
|
-
getCurrentDeployment: import("convex/server").RegisteredQuery<"public", {}, Promise<{
|
|
98
|
-
_creationTime: number;
|
|
99
|
-
_id: string;
|
|
100
|
-
currentDeploymentId: string;
|
|
101
|
-
deployedAt: number;
|
|
102
|
-
spaFallback?: boolean;
|
|
103
|
-
} | null>>;
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Derive the Convex cloud URL from a `.convex.site` hostname.
|
|
107
|
-
* Useful when your frontend is served by this component and needs
|
|
108
|
-
* to connect to its own Convex backend without an explicit env var.
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```typescript
|
|
112
|
-
* import { getConvexUrl } from "@samebase/convex-hosting";
|
|
113
|
-
*
|
|
114
|
-
* const convexUrl = import.meta.env.VITE_CONVEX_URL ?? getConvexUrl();
|
|
115
|
-
* const convex = new ConvexReactClient(convexUrl);
|
|
116
|
-
* ```
|
|
6
|
+
* Returns `null` when no asset matches, so the app continues (a static site answers 404, a
|
|
7
|
+
* server-rendered site renders the page). A version that does not exist, is still uploading, or
|
|
8
|
+
* is being deleted answers 404, so a half-installed site does not render pages without their
|
|
9
|
+
* files. The first request for a `ready` version marks it live, which deletes the versions that
|
|
10
|
+
* were live before it.
|
|
117
11
|
*/
|
|
118
|
-
export declare function
|
|
119
|
-
//# sourceMappingURL=index.d.ts.map
|
|
12
|
+
export declare function serveAsset(ctx: Pick<GenericActionCtx<GenericDataModel>, "runQuery" | "runMutation">, component: ComponentApi, request: Request, versionId: string): Promise<Response | null>;
|