@vite-hub/cli 0.3.1 → 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/README.md +23 -14
- package/dist/{commands-DPg3kL8m.js → commands-BQucvYlq.js} +560 -1232
- package/dist/{console-auth-xl7kLQNt.js → console-auth-B0HxFFiX.js} +2 -2
- package/dist/{console-env-C5YeAm2-.js → console-env-DSAuhgRZ.js} +3 -3
- package/dist/deploy-C0RdI5OK.js +1153 -0
- package/dist/{env-DzoVtVJO.js → env-B1Gg-WnA.js} +110 -40
- package/dist/{envelope-Cf56AJLa.js → envelope-B4mPbSbj.js} +1 -1
- package/dist/index.js +32 -13
- package/dist/{provision-D8OvBBzi.js → provision-DXl97xG0.js} +235 -174
- package/dist/setup/index.d.ts +55 -10
- package/dist/setup/index.js +11 -8
- package/package.json +5 -5
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { B as isRecord,
|
|
2
|
-
import { i as setupFailure, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-
|
|
1
|
+
import { B as isRecord, b as loadAllEnv, c as createNetlifyApiClient, f as resolveHostCredentials, l as createVercelProvisionClient, m as cliErrorDiagnostics, o as createCloudflareApiClient, p as runHostCli, s as createCloudflareProvisionClient, u as isProvisionRequestError, x as withViteStageEnvironment, z as internalErrorDiagnostics } from "./provision-DXl97xG0.js";
|
|
2
|
+
import { i as setupFailure, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-B4mPbSbj.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
|
-
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
5
|
+
import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
6
6
|
import process$1 from "node:process";
|
|
7
7
|
import { basename, dirname, join, relative, resolve } from "pathe";
|
|
8
|
+
import { defineDiagnostics } from "nostics";
|
|
8
9
|
import { mkdir, mkdtemp, open, readFile, realpath, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
9
10
|
import { basename as basename$1, delimiter, sep } from "node:path";
|
|
10
11
|
import { createInterface } from "node:readline/promises";
|
|
11
|
-
import { defineDiagnostics } from "nostics";
|
|
12
12
|
import { constants, tmpdir } from "node:os";
|
|
13
13
|
import { parse as parse$1 } from "@babel/parser";
|
|
14
14
|
import { parseArgs, parseEnv } from "node:util";
|
|
@@ -1802,23 +1802,20 @@ export default defineAgent({
|
|
|
1802
1802
|
suffix: "agent"
|
|
1803
1803
|
}),
|
|
1804
1804
|
docs: "/docs/agents",
|
|
1805
|
+
enabledByDiscovery: ["agents"],
|
|
1805
1806
|
hosts: {
|
|
1806
1807
|
...everywhere("nitro", "Nitro"),
|
|
1807
1808
|
deno: native("nitro", "Nitro", "Agent routes run in the Nitro output. The Agent Deno runtime is not supported on this host."),
|
|
1808
1809
|
netlify: native("nitro", "Nitro", "Agent HTTP routes run in generated functions. `agent.invocations` is not supported.")
|
|
1809
1810
|
},
|
|
1810
1811
|
id: "agent",
|
|
1811
|
-
implies: [{
|
|
1812
|
-
except: ["netlify"],
|
|
1813
|
-
feature: "workflow",
|
|
1814
|
-
inline: ["deno"]
|
|
1815
|
-
}],
|
|
1816
1812
|
packages: ["@vite-hub/agent"],
|
|
1817
1813
|
summary: "Agents in `server/agents/` with tools, Capabilities, channels, and invocations.",
|
|
1818
1814
|
title: "Agent"
|
|
1819
1815
|
}),
|
|
1820
1816
|
auth: feature({
|
|
1821
1817
|
docs: "/docs/auth",
|
|
1818
|
+
enabledByDiscovery: sourceFiles("auth"),
|
|
1822
1819
|
hosts: everywhere("better-auth", "Better Auth"),
|
|
1823
1820
|
id: "auth",
|
|
1824
1821
|
packages: ["@vite-hub/auth", "better-auth"],
|
|
@@ -1849,6 +1846,7 @@ export default defineAgent({
|
|
|
1849
1846
|
}),
|
|
1850
1847
|
browser: feature({
|
|
1851
1848
|
docs: "/docs/browser",
|
|
1849
|
+
enabledByDiscovery: ["browsers"],
|
|
1852
1850
|
hosts: {
|
|
1853
1851
|
cloudflare: native("cloudflare", "Browser Run", "Cloudflare Browser Run binding and provider output."),
|
|
1854
1852
|
deno: unsupported$1("Browser Definitions do not have a Deno provider."),
|
|
@@ -1884,6 +1882,7 @@ export default defineAgent({
|
|
|
1884
1882
|
}),
|
|
1885
1883
|
channels: feature({
|
|
1886
1884
|
docs: "/docs/channels",
|
|
1885
|
+
enabledByDiscovery: ["channels"],
|
|
1887
1886
|
hosts: everywhere("nitro", "Nitro"),
|
|
1888
1887
|
id: "channels",
|
|
1889
1888
|
packages: ["@vite-hub/channels"],
|
|
@@ -1907,6 +1906,7 @@ export default defineAgent({
|
|
|
1907
1906
|
}),
|
|
1908
1907
|
connections: feature({
|
|
1909
1908
|
docs: "/docs/connections",
|
|
1909
|
+
enabledByDiscovery: ["connections"],
|
|
1910
1910
|
hosts: everywhere("database", "Database"),
|
|
1911
1911
|
id: "connections",
|
|
1912
1912
|
implies: [{ feature: "database" }],
|
|
@@ -1919,7 +1919,7 @@ export default defineAgent({
|
|
|
1919
1919
|
title: "Connections"
|
|
1920
1920
|
}),
|
|
1921
1921
|
console: feature({
|
|
1922
|
-
docs: "/docs/
|
|
1922
|
+
docs: "/docs/console",
|
|
1923
1923
|
hosts: everywhere("nitro", "Nitro"),
|
|
1924
1924
|
id: "console",
|
|
1925
1925
|
packages: [],
|
|
@@ -1973,11 +1973,16 @@ ${name === "default" ? "" : ` name: ${JSON.stringify(name)},\n`} schema: {
|
|
|
1973
1973
|
hosts: {
|
|
1974
1974
|
cloudflare: native("cloudflare", "Cloudflare Email", "The Cloudflare Email driver is the default. Resend is also supported."),
|
|
1975
1975
|
deno: explicit("email.driver", "Resend", "Configure the built-in fetch-based Resend driver."),
|
|
1976
|
-
dev:
|
|
1976
|
+
dev: native("log", "Log", "`email: true` keeps each message in the development outbox and sends nothing. Set `email.driver` for a production build.", "process-local"),
|
|
1977
1977
|
netlify: explicit("email.driver", "Resend", "Configure the built-in Resend driver."),
|
|
1978
1978
|
node: explicit("email.driver", "Resend / custom", "Configure Resend or provide a custom ViteHub Email driver."),
|
|
1979
1979
|
vercel: explicit("email.driver", "Resend", "Configure the built-in Resend driver.")
|
|
1980
1980
|
},
|
|
1981
|
+
developmentOverrides: [
|
|
1982
|
+
"deno",
|
|
1983
|
+
"netlify",
|
|
1984
|
+
"vercel"
|
|
1985
|
+
],
|
|
1981
1986
|
id: "email",
|
|
1982
1987
|
packages: ["@vite-hub/email"],
|
|
1983
1988
|
summary: "Send email from server code and Agents, with a development outbox.",
|
|
@@ -2034,11 +2039,14 @@ ${name === "default" ? "" : ` name: ${JSON.stringify(name)},\n`} schema: {
|
|
|
2034
2039
|
queue: feature({
|
|
2035
2040
|
definition: starter("server/queues", (name) => `import { defineQueue } from "vite-hub/queue"
|
|
2036
2041
|
|
|
2037
|
-
export default defineQueue<{ id: string }>(
|
|
2038
|
-
|
|
2042
|
+
export default defineQueue<{ id: string }>({
|
|
2043
|
+
handler: async ({ payload }) => {
|
|
2044
|
+
console.log("${name}", payload.id)
|
|
2045
|
+
},
|
|
2039
2046
|
})
|
|
2040
2047
|
`, { suffix: "queue" }),
|
|
2041
2048
|
docs: "/docs/queue",
|
|
2049
|
+
enabledByDiscovery: ["queues"],
|
|
2042
2050
|
hosts: {
|
|
2043
2051
|
cloudflare: native("cloudflare", "Queues", "Cloudflare Queues bindings and consumers."),
|
|
2044
2052
|
deno: unsupported$1("No Deno Queue driver is provided."),
|
|
@@ -2075,7 +2083,7 @@ export default defineQueue<{ id: string }>(async ({ payload }) => {
|
|
|
2075
2083
|
definition: starter("server/realtime", (name) => `import { defineRealtime } from "vite-hub/realtime"
|
|
2076
2084
|
|
|
2077
2085
|
export default defineRealtime({
|
|
2078
|
-
|
|
2086
|
+
authorize: true,
|
|
2079
2087
|
document: { workspace: "${name}" },
|
|
2080
2088
|
})
|
|
2081
2089
|
`),
|
|
@@ -2086,6 +2094,7 @@ export default defineRealtime({
|
|
|
2086
2094
|
"vercel"
|
|
2087
2095
|
],
|
|
2088
2096
|
docs: "/docs/realtime",
|
|
2097
|
+
enabledByDiscovery: ["realtime"],
|
|
2089
2098
|
hosts: {
|
|
2090
2099
|
cloudflare: native("cloudflare", "Durable Objects", "Cloudflare Durable Objects run the production rooms."),
|
|
2091
2100
|
deno: unsupported$1("Realtime has no distributed Deno driver, and process memory is rejected for the Deno host."),
|
|
@@ -2105,7 +2114,7 @@ export default defineRealtime({
|
|
|
2105
2114
|
hosts: {
|
|
2106
2115
|
cloudflare: native("cloudflare", "CF Sandbox", "Cloudflare Sandbox execution provider."),
|
|
2107
2116
|
deno: unsupported$1("No Deno Sandbox driver is provided."),
|
|
2108
|
-
dev: unsupported$1("The default Node host has no Sandbox Provider.
|
|
2117
|
+
dev: unsupported$1("The default Node host has no Sandbox Provider. With the Cloudflare or Vercel host, `vite dev` runs each Sandbox Task as a process on this machine, with no isolation and no provider account. `sandboxTask: { remote: true }` uses the host's Sandbox instead."),
|
|
2109
2118
|
netlify: explicit("sandboxTask.driver", "Vercel Sandbox", "The Netlify host has no Sandbox, so `sandboxTask: true` fails. Set `sandboxTask: { driver: \"vercel\" }` and Vercel credentials to use Vercel Sandbox."),
|
|
2110
2119
|
node: explicit("sandboxTask.driver", "Vercel Sandbox", "The Node host has no Sandbox, so `sandboxTask: true` fails. Set `sandboxTask: { driver: \"vercel\" }` and Vercel credentials to use Vercel Sandbox."),
|
|
2111
2120
|
vercel: native("vercel", "Vercel Sandbox", "Vercel Sandbox execution provider.")
|
|
@@ -2132,12 +2141,13 @@ export default defineSchedule({
|
|
|
2132
2141
|
"vercel"
|
|
2133
2142
|
],
|
|
2134
2143
|
docs: "/docs/schedule",
|
|
2144
|
+
enabledByDiscovery: ["schedules"],
|
|
2135
2145
|
hosts: {
|
|
2136
2146
|
cloudflare: native("cloudflare", "Cron triggers", "Cloudflare scheduled events and Nitro Provider Wake."),
|
|
2137
2147
|
deno: native("deno", "Deno.cron", "`Deno.cron` output that the generated `.output/main.ts` loads before the Nitro server."),
|
|
2138
2148
|
dev: native("local", "Local / process", "Local development runner and the explicit process runtime.", "single-host"),
|
|
2139
2149
|
netlify: native("netlify", "Scheduled fn", "One generated Netlify scheduled function per static Schedule."),
|
|
2140
|
-
node: native("process", "process", "Process runtime for one long-lived process or replica.
|
|
2150
|
+
node: native("process", "process", "Process runtime for one long-lived process or replica. `schedule: true` uses it. Set `providerOutput: false` to wake Schedules yourself.", "single-host"),
|
|
2141
2151
|
vercel: native("vercel", "Vercel Cron", "Vercel Cron Jobs provider output.")
|
|
2142
2152
|
},
|
|
2143
2153
|
id: "schedule",
|
|
@@ -2146,19 +2156,22 @@ export default defineSchedule({
|
|
|
2146
2156
|
title: "Schedule"
|
|
2147
2157
|
}),
|
|
2148
2158
|
workflow: feature({
|
|
2149
|
-
definition: starter("server/workflows", (
|
|
2159
|
+
definition: starter("server/workflows", () => `import { defineWorkflow } from "vite-hub/workflow"
|
|
2150
2160
|
|
|
2151
|
-
export default defineWorkflow
|
|
2152
|
-
|
|
2161
|
+
export default defineWorkflow<{ id: string }>({
|
|
2162
|
+
handler: async ({ payload }) => {
|
|
2163
|
+
return { id: payload.id }
|
|
2164
|
+
},
|
|
2153
2165
|
})
|
|
2154
2166
|
`, {
|
|
2155
2167
|
folder: "index",
|
|
2156
2168
|
suffix: "workflow"
|
|
2157
2169
|
}),
|
|
2158
2170
|
docs: "/docs/workflows",
|
|
2171
|
+
enabledByDiscovery: ["workflows"],
|
|
2159
2172
|
hosts: {
|
|
2160
2173
|
cloudflare: native("cloudflare", "CF Workflows", "Cloudflare Workflows provider."),
|
|
2161
|
-
deno: explicit("workflow.driver", "OpenWorkflow", "Set `workflow.driver` to \"openworkflow\" with `workflow.postgres.url`, and start its worker. A build without a driver fails.
|
|
2174
|
+
deno: explicit("workflow.driver", "OpenWorkflow", "Set `workflow.driver` to \"openworkflow\" with `workflow.postgres.url`, and start its worker. A build without a driver fails."),
|
|
2162
2175
|
dev: native("openworkflow", "OpenWorkflow", "The Node host runs OpenWorkflow and its worker in the dev server, on .vitehub/data/openworkflow.sqlite.db. workflow.remote lets it use the Postgres Default Database or OPENWORKFLOW_POSTGRES_URL."),
|
|
2163
2176
|
netlify: explicit("workflow.driver", "OpenWorkflow", "Use OpenWorkflow explicitly. No Netlify-native Workflow driver is provided."),
|
|
2164
2177
|
node: {
|
|
@@ -2183,6 +2196,7 @@ export default defineWorkflow(${JSON.stringify(name)}, async (payload: { id: str
|
|
|
2183
2196
|
"vercel"
|
|
2184
2197
|
],
|
|
2185
2198
|
docs: "/docs/workspace",
|
|
2199
|
+
enabledByDiscovery: ["workspaces"],
|
|
2186
2200
|
hosts: {
|
|
2187
2201
|
cloudflare: native("memory", "Artifacts / GitHub", "Memory by default, or Cloudflare Artifacts beta and GitHub for durable state.", "process-local"),
|
|
2188
2202
|
deno: explicit("workspace.store", "GitHub", "Select the GitHub Workspace Store explicitly for durable state."),
|
|
@@ -2241,23 +2255,19 @@ function featureSupport(id, host, appHost) {
|
|
|
2241
2255
|
if (id === "workflow" && appHost === "deno") return native("vercel", "Inline", "Development runs each Workflow inline unless OpenWorkflow storage or a provider is configured.", "process-local");
|
|
2242
2256
|
return definition.hosts[appHost === "node" || definition.developmentOverrides?.includes(appHost) ? "dev" : appHost];
|
|
2243
2257
|
}
|
|
2244
|
-
/** True when one of the `enabled` features turns `id` on, and `id` then runs inline on `host` without a provider option. */
|
|
2245
|
-
function impliedInline(id, enabled, host) {
|
|
2246
|
-
return enabled.some((source) => features[source].implies.some((implication) => implication.feature === id && implication.inline?.includes(host)));
|
|
2247
|
-
}
|
|
2248
2258
|
/**
|
|
2249
|
-
* The features that `enabled` turn on through implications
|
|
2259
|
+
* The features that `enabled` turn on through implications, without the ones already in `enabled`.
|
|
2250
2260
|
* This follows implications transitively.
|
|
2251
2261
|
* `disabled` lists features that the app sets to `false`; an implication never turns them on.
|
|
2252
2262
|
*/
|
|
2253
|
-
function impliedFeatures(enabled,
|
|
2263
|
+
function impliedFeatures(enabled, disabled = []) {
|
|
2254
2264
|
const on = new Set(enabled);
|
|
2255
2265
|
const implied = [];
|
|
2256
2266
|
const pending = [...enabled];
|
|
2257
2267
|
while (pending.length) {
|
|
2258
2268
|
const id = pending.shift();
|
|
2259
2269
|
for (const implication of features[id].implies) {
|
|
2260
|
-
if (
|
|
2270
|
+
if (on.has(implication.feature) || disabled.includes(implication.feature)) continue;
|
|
2261
2271
|
on.add(implication.feature);
|
|
2262
2272
|
implied.push(implication.feature);
|
|
2263
2273
|
pending.push(implication.feature);
|
|
@@ -2283,7 +2293,8 @@ const viteConfigFiles = [
|
|
|
2283
2293
|
"vite.config.cts",
|
|
2284
2294
|
"vite.config.cjs"
|
|
2285
2295
|
];
|
|
2286
|
-
|
|
2296
|
+
/** The lockfiles and workspace files that name a package manager, in the order that detection reads them. */
|
|
2297
|
+
const setupLockfiles = [
|
|
2287
2298
|
["pnpm-lock.yaml", "pnpm"],
|
|
2288
2299
|
["pnpm-workspace.yaml", "pnpm"],
|
|
2289
2300
|
["bun.lock", "bun"],
|
|
@@ -2315,7 +2326,7 @@ function detectPackageManager(root, manifest, env) {
|
|
|
2315
2326
|
packageManagerSource: "manifest"
|
|
2316
2327
|
};
|
|
2317
2328
|
for (const folder of parentFolders(root)) {
|
|
2318
|
-
const found =
|
|
2329
|
+
const found = setupLockfiles.find(([file]) => existsSync(join(folder, file)));
|
|
2319
2330
|
if (found) return {
|
|
2320
2331
|
packageManager: found[1],
|
|
2321
2332
|
packageManagerSource: "lockfile"
|
|
@@ -2401,6 +2412,63 @@ async function readSetupProject(root, env) {
|
|
|
2401
2412
|
};
|
|
2402
2413
|
}
|
|
2403
2414
|
//#endregion
|
|
2415
|
+
//#region ../internal/dist/definition-catalog.js
|
|
2416
|
+
const sourceFilePattern = /\.(?:c|m)?[jt]sx?$/i;
|
|
2417
|
+
const declarationFilePattern = /\.d\.(?:c|m)?[jt]sx?$/i;
|
|
2418
|
+
const testFilePattern = /\.(?:test|spec)\.(?:c|m)?[jt]sx?$/i;
|
|
2419
|
+
const ignoredDirs = /* @__PURE__ */ new Set([
|
|
2420
|
+
"node_modules",
|
|
2421
|
+
"dist",
|
|
2422
|
+
".output",
|
|
2423
|
+
".nuxt",
|
|
2424
|
+
".vercel",
|
|
2425
|
+
".git",
|
|
2426
|
+
".vitehub"
|
|
2427
|
+
]);
|
|
2428
|
+
function readDirEntries(root) {
|
|
2429
|
+
try {
|
|
2430
|
+
return readdirSync(root, { withFileTypes: true });
|
|
2431
|
+
} catch (error) {
|
|
2432
|
+
if (error.code === "ENOENT") return [];
|
|
2433
|
+
throw error;
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
function isGitRepositoryDirectory(directory) {
|
|
2437
|
+
return existsSync(resolve(directory, ".git"));
|
|
2438
|
+
}
|
|
2439
|
+
function listMatchingFiles(root, predicate, options = {}) {
|
|
2440
|
+
const files = [];
|
|
2441
|
+
for (const entry of readDirEntries(root)) {
|
|
2442
|
+
const absolute = resolve(root, entry.name);
|
|
2443
|
+
if (entry.isDirectory() && !entry.isSymbolicLink()) {
|
|
2444
|
+
if (isGitRepositoryDirectory(absolute)) continue;
|
|
2445
|
+
if (entry.name.startsWith(".")) continue;
|
|
2446
|
+
if (ignoredDirs.has(entry.name)) continue;
|
|
2447
|
+
files.push(...listMatchingFiles(absolute, predicate, options));
|
|
2448
|
+
continue;
|
|
2449
|
+
}
|
|
2450
|
+
if (entry.name.startsWith(".") && !options.includeHidden) continue;
|
|
2451
|
+
if (entry.isFile() && predicate(entry.name)) files.push(absolute);
|
|
2452
|
+
}
|
|
2453
|
+
return files.sort();
|
|
2454
|
+
}
|
|
2455
|
+
/** A module that a Definitions folder can hold: JavaScript or TypeScript, and not a declaration, test, or spec file. */
|
|
2456
|
+
function isDefinitionSourceFile(name) {
|
|
2457
|
+
return sourceFilePattern.test(name) && !declarationFilePattern.test(name) && !testFilePattern.test(name);
|
|
2458
|
+
}
|
|
2459
|
+
function listSourceFiles(root, options = {}) {
|
|
2460
|
+
return listMatchingFiles(root, isDefinitionSourceFile, options);
|
|
2461
|
+
}
|
|
2462
|
+
/**
|
|
2463
|
+
* Whether `path` is a file, or a folder that holds a Definition source file. A Definition file in a server directory,
|
|
2464
|
+
* such as `server/auth.ts` or a file in `server/queues/`, turns its feature on without a key. An empty folder, which
|
|
2465
|
+
* Git does not keep, turns nothing on.
|
|
2466
|
+
*/
|
|
2467
|
+
function hasDefinitionFiles(path) {
|
|
2468
|
+
if (!existsSync(path)) return false;
|
|
2469
|
+
return statSync(path).isFile() || listSourceFiles(path).length > 0;
|
|
2470
|
+
}
|
|
2471
|
+
//#endregion
|
|
2404
2472
|
//#region ../internal/dist/deployment.js
|
|
2405
2473
|
const unsupported = (reason) => ({
|
|
2406
2474
|
reason,
|
|
@@ -2660,7 +2728,7 @@ function readHost(project, env) {
|
|
|
2660
2728
|
source: "default"
|
|
2661
2729
|
};
|
|
2662
2730
|
}
|
|
2663
|
-
function readEnabled(project, id) {
|
|
2731
|
+
function readEnabled(project, id, withoutDefinitions) {
|
|
2664
2732
|
const config = project.config;
|
|
2665
2733
|
if (!config || !config.ok && config.reason === "no-vitehub") return {
|
|
2666
2734
|
enabled: "off",
|
|
@@ -2687,6 +2755,10 @@ function readEnabled(project, id) {
|
|
|
2687
2755
|
enabled: "on",
|
|
2688
2756
|
reason: "default"
|
|
2689
2757
|
};
|
|
2758
|
+
if (withoutDefinitions?.has(id)) return {
|
|
2759
|
+
enabled: "off",
|
|
2760
|
+
reason: "default"
|
|
2761
|
+
};
|
|
2690
2762
|
const discovery = features[id].enabledByDiscovery;
|
|
2691
2763
|
const directories = project.serverDirs ?? (project.framework === "nuxt" ? void 0 : [join(project.root, "server")]);
|
|
2692
2764
|
if (discovery && !directories) return {
|
|
@@ -2694,7 +2766,7 @@ function readEnabled(project, id) {
|
|
|
2694
2766
|
reason: "default"
|
|
2695
2767
|
};
|
|
2696
2768
|
return {
|
|
2697
|
-
enabled: discovery?.some((file) => directories?.some((directory) =>
|
|
2769
|
+
enabled: discovery?.some((file) => directories?.some((directory) => hasDefinitionFiles(join(directory, file)))) ? "on" : "off",
|
|
2698
2770
|
reason: "default"
|
|
2699
2771
|
};
|
|
2700
2772
|
}
|
|
@@ -2715,20 +2787,18 @@ function featureFix(project, id, support, host, missing, providerChosen) {
|
|
|
2715
2787
|
if (support.level === "explicit" && !providerChosen && !setsOption(project, support.option)) return `Set \`${support.option}\` in vitehub() to choose a provider on ${host}.`;
|
|
2716
2788
|
}
|
|
2717
2789
|
/** What the project enables, on which host, and what each enabled feature still needs. Reads the config without running it. */
|
|
2718
|
-
function setupStatus(project, env) {
|
|
2790
|
+
function setupStatus(project, env, withoutDefinitions) {
|
|
2719
2791
|
const host = readHost(project, env);
|
|
2720
|
-
const enabled = new Map(featureIds.map((id) => [id, readEnabled(project, id)]));
|
|
2792
|
+
const enabled = new Map(featureIds.map((id) => [id, readEnabled(project, id, withoutDefinitions)]));
|
|
2721
2793
|
const on = featureIds.filter((id) => enabled.get(id).enabled === "on");
|
|
2722
2794
|
const keep = featureIds.filter((id) => enabled.get(id).enabled !== "on" && enabled.get(id).reason === "config");
|
|
2723
2795
|
const maybeOn = featureIds.filter((id) => enabled.get(id).enabled !== "off");
|
|
2724
2796
|
const disabled = keep.filter((id) => enabled.get(id).enabled === "off");
|
|
2725
|
-
const
|
|
2726
|
-
const
|
|
2727
|
-
const possible = new Set(hosts.flatMap((name) => impliedFeatures(maybeOn, name, disabled)));
|
|
2728
|
-
for (const id of possible) {
|
|
2797
|
+
const definite = impliedFeatures(on, keep);
|
|
2798
|
+
for (const id of impliedFeatures(maybeOn, disabled)) {
|
|
2729
2799
|
const state = enabled.get(id);
|
|
2730
2800
|
if (state.enabled === "off" && state.reason === "default") enabled.set(id, {
|
|
2731
|
-
enabled: definite.
|
|
2801
|
+
enabled: definite.includes(id) ? "on" : "unknown",
|
|
2732
2802
|
reason: "implied"
|
|
2733
2803
|
});
|
|
2734
2804
|
}
|
|
@@ -2757,7 +2827,7 @@ function setupStatus(project, env) {
|
|
|
2757
2827
|
dev: [],
|
|
2758
2828
|
prod: []
|
|
2759
2829
|
};
|
|
2760
|
-
const providerChosen =
|
|
2830
|
+
const providerChosen = id === "workflow" && host.name !== "netlify" && packages.includes("openworkflow");
|
|
2761
2831
|
const fix = state.enabled === "on" ? featureFix(project, id, support, host.name, missing, providerChosen) : void 0;
|
|
2762
2832
|
return {
|
|
2763
2833
|
id,
|
|
@@ -5817,4 +5887,4 @@ async function runEnvCommand(feature, args, context) {
|
|
|
5817
5887
|
}
|
|
5818
5888
|
}
|
|
5819
5889
|
//#endregion
|
|
5820
|
-
export { readDeployCommit as A,
|
|
5890
|
+
export { readDeployCommit as A, readSetupProject as B, denoOrganization as C, build as D, listCloudflareDeployments as E, uninstallArgs as F, featureSupport as G, featureHosts as H, hostFromNitroPreset as I, editViteHubConfig as J, features as K, hasDefinitionFiles as L, installCommand as M, setsOption as N, readBuildOutput as O, setupStatus as P, listMatchingFiles as R, denoAdapter as S, cloudflareAdapter as T, featureIds as U, setupLockfiles as V, featurePackages as W, locateViteHubConfig as X, insertViteHubConfig as Y, __exportAll as Z, listVercelDeployments as _, ensureViteHubGitignore as a, netlifyAdapter as b, linkSetupProject as c, readSetupLinkStatus as d, readSetupLinks as f, hasVercelLogin as g, writeSeparateResourcesNote as h, addSetupLink as i, installArgs as j, createDeployRun as k, readLinkHostOption as l, unlinkSetupProject as m, env_exports as n, gitignoreWithViteHub as o, selectSetupLink as p, impliedFeatures as q, SETUP_LINK_FILE as r, hostRequired as s, checkDeployEnv as t, readSetupLinkState as u, vercelAdapter as v, listDenoDeployments as w, abortable as x, listNetlifyDeployments as y, detectPackageManager as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as cliErrorDiagnostics } from "./provision-
|
|
1
|
+
import { m as cliErrorDiagnostics } from "./provision-DXl97xG0.js";
|
|
2
2
|
import { formatRuntimeDiagnosticError } from "@vite-hub/runtime";
|
|
3
3
|
//#region src/setup/envelope.ts
|
|
4
4
|
/** Exit codes of the setup commands. */
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as operationInputJsonSchema, B as isRecord, D as operationCliPath, E as operationCall, F as
|
|
1
|
+
import { A as operationInputJsonSchema, B as isRecord, D as operationCliPath, E as operationCall, F as createCliDiscoveryNitroCloser, I as findViteHubDevServerUrl, L as getStableStdoutWrite, M as setupCommandNames, N as resolveViteHubProjectRoot, O as operationsOf, P as collectViteHubCliContribution, R as withStdoutOnStderr, S as callOperation, T as createOperationRegistry, b as loadAllEnv, h as PROVISION_STATE_FILE, j as reservedOperationNamespaces, k as parseOperationInput, m as cliErrorDiagnostics, t as createProvisionNamespace, v as readProvisionStateSync, w as collectOperationContributions, x as withViteStageEnvironment } from "./provision-DXl97xG0.js";
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
4
4
|
import process$1 from "node:process";
|
|
@@ -1219,7 +1219,7 @@ const hostEnvFeatures = {
|
|
|
1219
1219
|
{
|
|
1220
1220
|
description: "Compare the env names of the last build with the names on the linked host. Exits with 1 when a required name is missing. Never reads values.",
|
|
1221
1221
|
name: "diff",
|
|
1222
|
-
run: async (args, context) => await (await import("./env-
|
|
1222
|
+
run: async (args, context) => await (await import("./env-B1Gg-WnA.js").then((n) => n.n)).runEnvCommand({
|
|
1223
1223
|
...hostEnvFeatures.features[0],
|
|
1224
1224
|
name: "diff"
|
|
1225
1225
|
}, args, context),
|
|
@@ -1228,7 +1228,7 @@ const hostEnvFeatures = {
|
|
|
1228
1228
|
{
|
|
1229
1229
|
description: "Set the host variables of the build's env names from the shell and .env.<stage>, with the host CLI. Prints names, never values. Never deletes a host variable.",
|
|
1230
1230
|
name: "push",
|
|
1231
|
-
run: async (args, context) => await (await import("./env-
|
|
1231
|
+
run: async (args, context) => await (await import("./env-B1Gg-WnA.js").then((n) => n.n)).runEnvCommand({
|
|
1232
1232
|
...hostEnvFeatures.features[1],
|
|
1233
1233
|
name: "push"
|
|
1234
1234
|
}, args, context),
|
|
@@ -1237,14 +1237,14 @@ const hostEnvFeatures = {
|
|
|
1237
1237
|
{
|
|
1238
1238
|
description: "Write the env values of a stage from a self-hosted Console to .env.<stage>. Needs `vitehub login` and the owner or admin role.",
|
|
1239
1239
|
name: "pull",
|
|
1240
|
-
run: async (args, context) => await (await import("./console-env-
|
|
1240
|
+
run: async (args, context) => await (await import("./console-env-DSAuhgRZ.js")).envPullFeature.run(args, context),
|
|
1241
1241
|
usage: "vitehub env pull --from console [--stage <name>] [--project <id>] [--console <url>] [--yes] [--json]"
|
|
1242
1242
|
}
|
|
1243
1243
|
],
|
|
1244
1244
|
name: "env"
|
|
1245
1245
|
};
|
|
1246
1246
|
async function loadSetupCommands() {
|
|
1247
|
-
return (await import("./commands-
|
|
1247
|
+
return (await import("./commands-BQucvYlq.js").then((n) => n.t)).setupCommands;
|
|
1248
1248
|
}
|
|
1249
1249
|
async function loadNuxtViteConfig(rootDir, command, mode) {
|
|
1250
1250
|
if (![
|
|
@@ -1487,15 +1487,23 @@ async function runViteHubCli(options = {}) {
|
|
|
1487
1487
|
};
|
|
1488
1488
|
}, stderr);
|
|
1489
1489
|
const loadProvision = options.loadProvision ?? (async (host) => {
|
|
1490
|
-
const
|
|
1491
|
-
|
|
1490
|
+
const discoveryEnv = { ...env };
|
|
1491
|
+
return await withViteStageEnvironment({
|
|
1492
|
+
...discoveryEnv,
|
|
1492
1493
|
VITEHUB_HOST: host,
|
|
1493
1494
|
VITEHUB_HOST_SOURCE: "cli"
|
|
1494
|
-
}, () =>
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1495
|
+
}, async () => {
|
|
1496
|
+
const loaded = await loadProject("build");
|
|
1497
|
+
return {
|
|
1498
|
+
env: {
|
|
1499
|
+
...process$1.env,
|
|
1500
|
+
VITEHUB_HOST: discoveryEnv.VITEHUB_HOST,
|
|
1501
|
+
VITEHUB_HOST_SOURCE: discoveryEnv.VITEHUB_HOST_SOURCE
|
|
1502
|
+
},
|
|
1503
|
+
rootDir: loaded.rootDir,
|
|
1504
|
+
steps: loaded.contribution.provision
|
|
1505
|
+
};
|
|
1506
|
+
});
|
|
1499
1507
|
});
|
|
1500
1508
|
const loadCommands = async () => options.commands ?? [...await loadSetupCommands(), drainCommand];
|
|
1501
1509
|
const setupCommand = options.commands || setupCommandNames.includes(args[0] ?? "") ? (await loadCommands()).find((item) => item.name === args[0]) : void 0;
|
|
@@ -1510,6 +1518,17 @@ async function runViteHubCli(options = {}) {
|
|
|
1510
1518
|
stderr,
|
|
1511
1519
|
stdout
|
|
1512
1520
|
});
|
|
1521
|
+
const provisionNamespace = createProvisionNamespace(loadProvision);
|
|
1522
|
+
if (args[0] === provisionNamespace.name && (!args[1] || isHelpFlag(args[1]) || provisionNamespace.features.some((feature) => feature.name === args[1]))) return await runNamespace(provisionNamespace, args, {
|
|
1523
|
+
cwd,
|
|
1524
|
+
env,
|
|
1525
|
+
...options.fetch ? { fetch: options.fetch } : {},
|
|
1526
|
+
rootDir: cwd,
|
|
1527
|
+
...options.runHostCli ? { runHostCli: options.runHostCli } : {},
|
|
1528
|
+
spawn,
|
|
1529
|
+
stderr,
|
|
1530
|
+
stdout
|
|
1531
|
+
});
|
|
1513
1532
|
const runtimeNamespace = options.runtimeNamespaces?.find((namespace) => namespace.name === args[0] && !BUILTIN_NAMESPACE_NAMES.has(namespace.name));
|
|
1514
1533
|
if (runtimeNamespace) return await runNamespace(runtimeNamespace, args, {
|
|
1515
1534
|
cwd,
|
|
@@ -1546,7 +1565,7 @@ async function runViteHubCli(options = {}) {
|
|
|
1546
1565
|
const namespaces = [
|
|
1547
1566
|
...mergeOperationNamespaces(contribution.namespaces, createOperationNamespaces(operations)).filter((namespace) => !BUILTIN_NAMESPACE_NAMES.has(namespace.name) && !runtimeNames.has(namespace.name)),
|
|
1548
1567
|
createInspectNamespace(plugins, operations, handlers),
|
|
1549
|
-
|
|
1568
|
+
provisionNamespace,
|
|
1550
1569
|
createSeedNamespace(contribution.seeds),
|
|
1551
1570
|
...runtimeNamespaces
|
|
1552
1571
|
];
|