@vite-hub/cli 0.3.1 → 0.5.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/README.md +25 -15
- package/dist/{commands-DPg3kL8m.js → commands-W0ijB5R6.js} +829 -1306
- package/dist/{console-auth-xl7kLQNt.js → console-auth-Dz9HHP2G.js} +2 -5
- package/dist/{console-env-C5YeAm2-.js → console-env--3nqqpCV.js} +3 -8
- package/dist/deploy-CHW75le_.js +1125 -0
- package/dist/{env-DzoVtVJO.js → env-MtXhP7A7.js} +309 -751
- package/dist/{envelope-Cf56AJLa.js → envelope-C7e408hm.js} +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +262 -77
- package/dist/{provision-D8OvBBzi.js → provision-DgT_lpyn.js} +974 -191
- package/dist/{provision-C9p1wSzq.d.ts → provision-bhi-xnCG.d.ts} +2 -2
- package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
- package/dist/setup/index.d.ts +71 -20
- package/dist/setup/index.js +11 -9
- package/package.json +6 -5
|
@@ -1,52 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
+
import { $ as isRecord, B as formatInstallArgument, H as installSpecifier, I as featureIds, L as featurePackages, Q as internalErrorDiagnostics, R as featureSupport, V as impliedFeatures, W as invariant, 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 features } from "./provision-DgT_lpyn.js";
|
|
3
|
+
import { i as setupFailure, o as writeSetupError, r as setupExitCodes, s as writeSetupJson, t as isSetupFailure } from "./envelope-C7e408hm.js";
|
|
3
4
|
import { createRequire } from "node:module";
|
|
4
5
|
import { spawn } from "node:child_process";
|
|
5
|
-
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
6
|
+
import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
6
7
|
import process$1 from "node:process";
|
|
7
8
|
import { basename, dirname, join, relative, resolve } from "pathe";
|
|
8
|
-
import { mkdir, mkdtemp, open, readFile, realpath, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
9
|
+
import { mkdir, mkdtemp, open, readFile, readdir, 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 {
|
|
12
|
-
import { constants, tmpdir } from "node:os";
|
|
12
|
+
import { constants, homedir, tmpdir } from "node:os";
|
|
13
13
|
import { parse as parse$1 } from "@babel/parser";
|
|
14
|
+
import { parse as parse$2 } from "rc9";
|
|
14
15
|
import { parseArgs, parseEnv } from "node:util";
|
|
15
16
|
import { createPublicKey, diffieHellman, generateKeyPairSync, randomBytes } from "node:crypto";
|
|
16
17
|
import { hsalsa, xsalsa20poly1305 } from "@noble/ciphers/salsa.js";
|
|
17
18
|
import { blake2b } from "@noble/hashes/blake2.js";
|
|
18
|
-
//#region \0rolldown/runtime.js
|
|
19
|
-
var __defProp = Object.defineProperty;
|
|
20
|
-
var __exportAll = (all, no_symbols) => {
|
|
21
|
-
let target = {};
|
|
22
|
-
for (var name in all) __defProp(target, name, {
|
|
23
|
-
get: all[name],
|
|
24
|
-
enumerable: true
|
|
25
|
-
});
|
|
26
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
27
|
-
return target;
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region ../internal/dist/invariant.js
|
|
31
|
-
const invariantDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
32
|
-
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
33
|
-
codes: { INTERNAL_INVARIANT_FAILED: {
|
|
34
|
-
why: ({ what }) => `ViteHub reached a state that it does not expect: ${what}`,
|
|
35
|
-
fix: "This is a ViteHub bug. Open an issue at https://github.com/vite-hub/vitehub/issues with this error message and its stack trace."
|
|
36
|
-
} }
|
|
37
|
-
});
|
|
38
|
-
/**
|
|
39
|
-
* The error for a state that only a ViteHub bug can reach, such as an impossible branch. `what` says which rule broke.
|
|
40
|
-
* Use a code from the package catalog when a developer can cause the error or fix it.
|
|
41
|
-
*/
|
|
42
|
-
function invariantError(what) {
|
|
43
|
-
return invariantDiagnostics.INTERNAL_INVARIANT_FAILED({ what });
|
|
44
|
-
}
|
|
45
|
-
/** Throws `INTERNAL_INVARIANT_FAILED` when `condition` is falsy. */
|
|
46
|
-
function invariant(condition, what) {
|
|
47
|
-
if (!condition) throw invariantError(what);
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
19
|
//#region ../internal/dist/ast.js
|
|
51
20
|
/** Parses JavaScript or TypeScript. `jsx` adds JSX syntax. */
|
|
52
21
|
function parseProgram(code, options = {}) {
|
|
@@ -1427,7 +1396,7 @@ function locateNuxtOptions(code, program, root, names, namespaces) {
|
|
|
1427
1396
|
}
|
|
1428
1397
|
};
|
|
1429
1398
|
}
|
|
1430
|
-
function parse$
|
|
1399
|
+
function parse$3(code) {
|
|
1431
1400
|
try {
|
|
1432
1401
|
return parseProgram(code);
|
|
1433
1402
|
} catch (error) {
|
|
@@ -1435,7 +1404,7 @@ function parse$2(code) {
|
|
|
1435
1404
|
}
|
|
1436
1405
|
}
|
|
1437
1406
|
function locate(file, code) {
|
|
1438
|
-
const program = parse$
|
|
1407
|
+
const program = parse$3(code);
|
|
1439
1408
|
if ("ok" in program) return program;
|
|
1440
1409
|
let commonjs;
|
|
1441
1410
|
walk(program, (node) => {
|
|
@@ -1633,7 +1602,7 @@ function insertViteHubConfig(file, code, options) {
|
|
|
1633
1602
|
code
|
|
1634
1603
|
};
|
|
1635
1604
|
if (located.reason !== "no-vitehub") return located;
|
|
1636
|
-
const program = parse$
|
|
1605
|
+
const program = parse$3(code);
|
|
1637
1606
|
if ("ok" in program) return program;
|
|
1638
1607
|
const exported = defaultExport(program);
|
|
1639
1608
|
if (!exported) return fail("no-vitehub");
|
|
@@ -1679,593 +1648,6 @@ function insertViteHubConfig(file, code, options) {
|
|
|
1679
1648
|
};
|
|
1680
1649
|
}
|
|
1681
1650
|
//#endregion
|
|
1682
|
-
//#region ../internal/dist/features.js
|
|
1683
|
-
/**
|
|
1684
|
-
* The feature keys of `vitehub({...})`. `vitehub add <feature>` and `vitehub status` read this list before the owner
|
|
1685
|
-
* package of a feature is installed, so the catalog is plain data with no owner imports.
|
|
1686
|
-
*/
|
|
1687
|
-
const featureIds = [
|
|
1688
|
-
"agent",
|
|
1689
|
-
"auth",
|
|
1690
|
-
"blob",
|
|
1691
|
-
"browser",
|
|
1692
|
-
"cache",
|
|
1693
|
-
"channels",
|
|
1694
|
-
"comments",
|
|
1695
|
-
"connections",
|
|
1696
|
-
"console",
|
|
1697
|
-
"database",
|
|
1698
|
-
"email",
|
|
1699
|
-
"env",
|
|
1700
|
-
"i18n",
|
|
1701
|
-
"kv",
|
|
1702
|
-
"mcp",
|
|
1703
|
-
"observability",
|
|
1704
|
-
"queue",
|
|
1705
|
-
"rateLimit",
|
|
1706
|
-
"realtime",
|
|
1707
|
-
"sandboxTask",
|
|
1708
|
-
"schedule",
|
|
1709
|
-
"workflow",
|
|
1710
|
-
"workspace"
|
|
1711
|
-
];
|
|
1712
|
-
/** `dev` stores default Node development support. Use `featureSupport()` with the configured host for development lookups. */
|
|
1713
|
-
const featureHosts = [
|
|
1714
|
-
"dev",
|
|
1715
|
-
"cloudflare",
|
|
1716
|
-
"vercel",
|
|
1717
|
-
"netlify",
|
|
1718
|
-
"deno",
|
|
1719
|
-
"node"
|
|
1720
|
-
];
|
|
1721
|
-
const noHostLimit = "No host limit in ViteHub.";
|
|
1722
|
-
function native(driver, display, detail, guarantee = "native") {
|
|
1723
|
-
return {
|
|
1724
|
-
detail,
|
|
1725
|
-
display,
|
|
1726
|
-
driver,
|
|
1727
|
-
guarantee,
|
|
1728
|
-
level: "native"
|
|
1729
|
-
};
|
|
1730
|
-
}
|
|
1731
|
-
function explicit(option, display, detail) {
|
|
1732
|
-
return {
|
|
1733
|
-
detail,
|
|
1734
|
-
display,
|
|
1735
|
-
level: "explicit",
|
|
1736
|
-
option
|
|
1737
|
-
};
|
|
1738
|
-
}
|
|
1739
|
-
function unsupported$1(detail) {
|
|
1740
|
-
return {
|
|
1741
|
-
detail,
|
|
1742
|
-
level: "unsupported"
|
|
1743
|
-
};
|
|
1744
|
-
}
|
|
1745
|
-
function everywhere(driver, display, detail = noHostLimit) {
|
|
1746
|
-
const support = native(driver, display, detail);
|
|
1747
|
-
return {
|
|
1748
|
-
cloudflare: support,
|
|
1749
|
-
deno: support,
|
|
1750
|
-
dev: support,
|
|
1751
|
-
netlify: support,
|
|
1752
|
-
node: support,
|
|
1753
|
-
vercel: support
|
|
1754
|
-
};
|
|
1755
|
-
}
|
|
1756
|
-
function feature(definition) {
|
|
1757
|
-
return {
|
|
1758
|
-
devPackages: [],
|
|
1759
|
-
enabledByDefault: false,
|
|
1760
|
-
implies: [],
|
|
1761
|
-
packages: [],
|
|
1762
|
-
...definition
|
|
1763
|
-
};
|
|
1764
|
-
}
|
|
1765
|
-
const sourceExtensions = [
|
|
1766
|
-
"ts",
|
|
1767
|
-
"mts",
|
|
1768
|
-
"js",
|
|
1769
|
-
"mjs",
|
|
1770
|
-
"cts",
|
|
1771
|
-
"cjs"
|
|
1772
|
-
];
|
|
1773
|
-
/** `<base>.<ext>` for each source extension. */
|
|
1774
|
-
function sourceFiles(base) {
|
|
1775
|
-
return sourceExtensions.map((extension) => `${base}.${extension}`);
|
|
1776
|
-
}
|
|
1777
|
-
/**
|
|
1778
|
-
* A starter for Definitions in `dir`, one `<name>.ts` file each. With `suffix`, the owner also discovers the Vite
|
|
1779
|
-
* form `src/<name>.<suffix>.ts`, and a Definition folder `<dir>/<name>/` when `folder` names its entry file.
|
|
1780
|
-
*/
|
|
1781
|
-
function starter(dir, template, options = {}) {
|
|
1782
|
-
return {
|
|
1783
|
-
conflicts: (name) => [
|
|
1784
|
-
...sourceFiles(`${dir}/${name}`).slice(1),
|
|
1785
|
-
...options.folder ? sourceFiles(`${dir}/${name}/${options.folder}`) : [],
|
|
1786
|
-
...options.suffix ? [...sourceFiles(`src/${name}.${options.suffix}`), ...sourceFiles(`${name}.${options.suffix}`)] : []
|
|
1787
|
-
],
|
|
1788
|
-
dir,
|
|
1789
|
-
file: (name) => `${dir}/${name}.ts`,
|
|
1790
|
-
template
|
|
1791
|
-
};
|
|
1792
|
-
}
|
|
1793
|
-
const features = {
|
|
1794
|
-
agent: feature({
|
|
1795
|
-
definition: starter("server/agents", (name) => `import { defineAgent } from "vite-hub/agent"
|
|
1796
|
-
|
|
1797
|
-
export default defineAgent({
|
|
1798
|
-
driver: { run: () => ({ text: "Hello from ${name}." }) },
|
|
1799
|
-
})
|
|
1800
|
-
`, {
|
|
1801
|
-
folder: "agent",
|
|
1802
|
-
suffix: "agent"
|
|
1803
|
-
}),
|
|
1804
|
-
docs: "/docs/agents",
|
|
1805
|
-
hosts: {
|
|
1806
|
-
...everywhere("nitro", "Nitro"),
|
|
1807
|
-
deno: native("nitro", "Nitro", "Agent routes run in the Nitro output. The Agent Deno runtime is not supported on this host."),
|
|
1808
|
-
netlify: native("nitro", "Nitro", "Agent HTTP routes run in generated functions. `agent.invocations` is not supported.")
|
|
1809
|
-
},
|
|
1810
|
-
id: "agent",
|
|
1811
|
-
implies: [{
|
|
1812
|
-
except: ["netlify"],
|
|
1813
|
-
feature: "workflow",
|
|
1814
|
-
inline: ["deno"]
|
|
1815
|
-
}],
|
|
1816
|
-
packages: ["@vite-hub/agent"],
|
|
1817
|
-
summary: "Agents in `server/agents/` with tools, Capabilities, channels, and invocations.",
|
|
1818
|
-
title: "Agent"
|
|
1819
|
-
}),
|
|
1820
|
-
auth: feature({
|
|
1821
|
-
docs: "/docs/auth",
|
|
1822
|
-
hosts: everywhere("better-auth", "Better Auth"),
|
|
1823
|
-
id: "auth",
|
|
1824
|
-
packages: ["@vite-hub/auth", "better-auth"],
|
|
1825
|
-
summary: "Better Auth sign-in, sessions, and organizations, with tables that ViteHub owns.",
|
|
1826
|
-
title: "Auth"
|
|
1827
|
-
}),
|
|
1828
|
-
blob: feature({
|
|
1829
|
-
docs: "/docs/blob",
|
|
1830
|
-
hosts: {
|
|
1831
|
-
cloudflare: native("cloudflare", "R2", "Cloudflare R2 binding or S3-compatible HTTP access."),
|
|
1832
|
-
deno: explicit("blob.driver", "S3", "Use a remote S3-compatible store. No Deno-native Blob driver is provided."),
|
|
1833
|
-
dev: native("fs", "fs", "Local filesystem storage for development.", "single-host"),
|
|
1834
|
-
netlify: native("netlify-blobs", "Netlify Blobs", "Netlify Blobs selected from the detected host."),
|
|
1835
|
-
node: native("fs", "fs / S3", "Filesystem, S3-compatible, MinIO, or files-sdk drivers.", "single-host"),
|
|
1836
|
-
vercel: native("vercel", "Vercel Blob", "Vercel Blob through the vercel driver.")
|
|
1837
|
-
},
|
|
1838
|
-
id: "blob",
|
|
1839
|
-
packages: ["@vite-hub/blob"],
|
|
1840
|
-
providerPackages: { driver: { s3: [
|
|
1841
|
-
"@aws-sdk/client-s3",
|
|
1842
|
-
"@aws-sdk/lib-storage",
|
|
1843
|
-
"@aws-sdk/s3-presigned-post",
|
|
1844
|
-
"@aws-sdk/s3-request-presigner"
|
|
1845
|
-
] } },
|
|
1846
|
-
service: "blob",
|
|
1847
|
-
summary: "Object storage for files and uploads, with one API on every host.",
|
|
1848
|
-
title: "Blob"
|
|
1849
|
-
}),
|
|
1850
|
-
browser: feature({
|
|
1851
|
-
docs: "/docs/browser",
|
|
1852
|
-
hosts: {
|
|
1853
|
-
cloudflare: native("cloudflare", "Browser Run", "Cloudflare Browser Run binding and provider output."),
|
|
1854
|
-
deno: unsupported$1("Browser Definitions do not have a Deno provider."),
|
|
1855
|
-
dev: unsupported$1("Browser Definitions need the Cloudflare host. Use createBrowser({ driver: localBrowser({ executablePath }) }) from code for a trusted local process."),
|
|
1856
|
-
netlify: unsupported$1("Browser Definitions do not have a Netlify provider."),
|
|
1857
|
-
node: unsupported$1("The Node host has no built-in Browser Provider. Use localBrowser() from code for a trusted process."),
|
|
1858
|
-
vercel: unsupported$1("Browser Definitions do not have a Vercel provider.")
|
|
1859
|
-
},
|
|
1860
|
-
id: "browser",
|
|
1861
|
-
packages: ["@vite-hub/browser"],
|
|
1862
|
-
service: "browser",
|
|
1863
|
-
summary: "Headless browser sessions for Agents and server code.",
|
|
1864
|
-
title: "Browser"
|
|
1865
|
-
}),
|
|
1866
|
-
cache: feature({
|
|
1867
|
-
developmentOverrides: [
|
|
1868
|
-
"cloudflare",
|
|
1869
|
-
"deno",
|
|
1870
|
-
"vercel"
|
|
1871
|
-
],
|
|
1872
|
-
docs: "/docs/reference/config-options",
|
|
1873
|
-
hosts: {
|
|
1874
|
-
cloudflare: native("cloudflare", "Workers KV", "Workers KV binding `CACHE`."),
|
|
1875
|
-
deno: native("deno-kv", "Deno KV", "Native Deno KV."),
|
|
1876
|
-
dev: native("fs-lite", "fs-lite", "`.vitehub/data/cache` during development.", "single-host"),
|
|
1877
|
-
netlify: explicit("cache.driver", "KV", "`cache: true` has no default store on Netlify. Set `cache: { driver: \"kv\" }` and enable `kv`."),
|
|
1878
|
-
node: native("fs-lite", "fs-lite", "`.vitehub/data/cache` on the server disk.", "single-host"),
|
|
1879
|
-
vercel: native("vercel", "Runtime Cache", "Vercel Runtime Cache.")
|
|
1880
|
-
},
|
|
1881
|
-
id: "cache",
|
|
1882
|
-
summary: "Storage for Nitro's cache mount, used by defineCachedFunction() and defineCachedEventHandler().",
|
|
1883
|
-
title: "Cache"
|
|
1884
|
-
}),
|
|
1885
|
-
channels: feature({
|
|
1886
|
-
docs: "/docs/channels",
|
|
1887
|
-
hosts: everywhere("nitro", "Nitro"),
|
|
1888
|
-
id: "channels",
|
|
1889
|
-
packages: ["@vite-hub/channels"],
|
|
1890
|
-
summary: "Chat channels such as Slack, Discord, and GitHub that deliver messages to Agents.",
|
|
1891
|
-
title: "Channels"
|
|
1892
|
-
}),
|
|
1893
|
-
comments: feature({
|
|
1894
|
-
docs: "/docs/comments",
|
|
1895
|
-
enabledByDiscovery: [
|
|
1896
|
-
"comments.ts",
|
|
1897
|
-
"comments.mts",
|
|
1898
|
-
"comments.js",
|
|
1899
|
-
"comments.mjs"
|
|
1900
|
-
],
|
|
1901
|
-
hosts: everywhere("database", "Database"),
|
|
1902
|
-
id: "comments",
|
|
1903
|
-
implies: [{ feature: "database" }],
|
|
1904
|
-
packages: ["@vite-hub/comments"],
|
|
1905
|
-
summary: "Comments on the app's pages, stored in a ViteHub Database.",
|
|
1906
|
-
title: "Comments"
|
|
1907
|
-
}),
|
|
1908
|
-
connections: feature({
|
|
1909
|
-
docs: "/docs/connections",
|
|
1910
|
-
hosts: everywhere("database", "Database"),
|
|
1911
|
-
id: "connections",
|
|
1912
|
-
implies: [{ feature: "database" }],
|
|
1913
|
-
packages: [
|
|
1914
|
-
"@vite-hub/connections",
|
|
1915
|
-
"@vite-hub/database",
|
|
1916
|
-
"drizzle-orm"
|
|
1917
|
-
],
|
|
1918
|
-
summary: "OAuth and API key Connections in `server/connections/`, with grants stored in a Database.",
|
|
1919
|
-
title: "Connections"
|
|
1920
|
-
}),
|
|
1921
|
-
console: feature({
|
|
1922
|
-
docs: "/docs/development/console",
|
|
1923
|
-
hosts: everywhere("nitro", "Nitro"),
|
|
1924
|
-
id: "console",
|
|
1925
|
-
packages: [],
|
|
1926
|
-
summary: "The Operations endpoint and MCP at `/_vitehub`, which the hosted Console at console.vitehub.dev and the CLI call.",
|
|
1927
|
-
title: "Console"
|
|
1928
|
-
}),
|
|
1929
|
-
database: feature({
|
|
1930
|
-
definition: {
|
|
1931
|
-
conflicts: (name) => [
|
|
1932
|
-
...sourceFiles(`server/databases/${name}`).slice(1),
|
|
1933
|
-
...sourceFiles(`server/databases/${name}/index`),
|
|
1934
|
-
...name === "default" ? ["src/database.ts"] : [...sourceFiles(`src/${name}.database`), "src/database.ts"]
|
|
1935
|
-
],
|
|
1936
|
-
dir: "server/databases",
|
|
1937
|
-
file: (name) => `server/databases/${name}.ts`,
|
|
1938
|
-
template: (name) => `import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"
|
|
1939
|
-
import { defineDatabase } from "vite-hub/database"
|
|
1940
|
-
|
|
1941
|
-
export default defineDatabase({
|
|
1942
|
-
${name === "default" ? "" : ` name: ${JSON.stringify(name)},\n`} schema: {
|
|
1943
|
-
notes: sqliteTable("notes", {
|
|
1944
|
-
id: integer("id").primaryKey(),
|
|
1945
|
-
title: text("title").notNull(),
|
|
1946
|
-
}),
|
|
1947
|
-
},
|
|
1948
|
-
})
|
|
1949
|
-
`
|
|
1950
|
-
},
|
|
1951
|
-
developmentOverrides: [
|
|
1952
|
-
"deno",
|
|
1953
|
-
"netlify",
|
|
1954
|
-
"vercel"
|
|
1955
|
-
],
|
|
1956
|
-
devPackages: ["drizzle-kit"],
|
|
1957
|
-
docs: "/docs/database",
|
|
1958
|
-
hosts: {
|
|
1959
|
-
cloudflare: native("cloudflare", "D1", "Cloudflare D1 binding, with authenticated HTTP available for development. A PostgreSQL Database Definition connects through Hyperdrive or `connection.url`."),
|
|
1960
|
-
deno: explicit("database.connection", "libSQL / D1 / Postgres", "Configure hosted libSQL, D1 over authenticated HTTP, or a PostgreSQL Database Definition. No Deno-native database driver is provided."),
|
|
1961
|
-
dev: native("sqlite", "SQLite", "Local SQLite through libSQL and Drizzle.", "single-host"),
|
|
1962
|
-
netlify: explicit("database.connection", "libSQL / D1 / Postgres", "Configure hosted libSQL, D1 over authenticated HTTP, or a PostgreSQL Database Definition. No Netlify-native database driver is provided."),
|
|
1963
|
-
node: native("sqlite", "SQLite / libSQL / Postgres", "SQLite or hosted libSQL through the selected Database connection, or a PostgreSQL Database Definition.", "single-host"),
|
|
1964
|
-
vercel: explicit("database.connection", "libSQL / D1 / Postgres", "Configure hosted libSQL, D1 over authenticated HTTP, or a PostgreSQL Database Definition. The default local SQLite file is not supported in Vercel functions.")
|
|
1965
|
-
},
|
|
1966
|
-
id: "database",
|
|
1967
|
-
packages: ["@vite-hub/database", "drizzle-orm"],
|
|
1968
|
-
summary: "Drizzle Databases in `server/databases/` with migrations and a local SQLite in development.",
|
|
1969
|
-
title: "Database"
|
|
1970
|
-
}),
|
|
1971
|
-
email: feature({
|
|
1972
|
-
docs: "/docs/email",
|
|
1973
|
-
hosts: {
|
|
1974
|
-
cloudflare: native("cloudflare", "Cloudflare Email", "The Cloudflare Email driver is the default. Resend is also supported."),
|
|
1975
|
-
deno: explicit("email.driver", "Resend", "Configure the built-in fetch-based Resend driver."),
|
|
1976
|
-
dev: explicit("email.driver", "Resend", "Configure the built-in Resend driver for local delivery."),
|
|
1977
|
-
netlify: explicit("email.driver", "Resend", "Configure the built-in Resend driver."),
|
|
1978
|
-
node: explicit("email.driver", "Resend / custom", "Configure Resend or provide a custom ViteHub Email driver."),
|
|
1979
|
-
vercel: explicit("email.driver", "Resend", "Configure the built-in Resend driver.")
|
|
1980
|
-
},
|
|
1981
|
-
id: "email",
|
|
1982
|
-
packages: ["@vite-hub/email"],
|
|
1983
|
-
summary: "Send email from server code and Agents, with a development outbox.",
|
|
1984
|
-
title: "Email"
|
|
1985
|
-
}),
|
|
1986
|
-
env: feature({
|
|
1987
|
-
docs: "/docs/env",
|
|
1988
|
-
enabledByDefault: true,
|
|
1989
|
-
hosts: everywhere("nitro", "Nitro"),
|
|
1990
|
-
id: "env",
|
|
1991
|
-
summary: "Typed environment variables and secrets, validated at build and at runtime.",
|
|
1992
|
-
title: "Env"
|
|
1993
|
-
}),
|
|
1994
|
-
i18n: feature({
|
|
1995
|
-
docs: "/docs/i18n",
|
|
1996
|
-
hosts: everywhere("nitro", "Nitro 3", "Requires Nitro 3 with request async context, or Nuxt 5. Nuxt 4 and Nitro 2 are unsupported."),
|
|
1997
|
-
id: "i18n",
|
|
1998
|
-
packages: ["@vite-hub/i18n"],
|
|
1999
|
-
summary: "Messages with translation records for each locale and a locale for each request.",
|
|
2000
|
-
title: "I18n"
|
|
2001
|
-
}),
|
|
2002
|
-
kv: feature({
|
|
2003
|
-
developmentOverrides: ["netlify"],
|
|
2004
|
-
docs: "/docs/kv",
|
|
2005
|
-
hosts: {
|
|
2006
|
-
cloudflare: native("cloudflare", "Workers KV", "Cloudflare Workers KV binding."),
|
|
2007
|
-
deno: native("deno-kv", "Deno KV", "Native Deno KV through Deno.openKv()."),
|
|
2008
|
-
dev: native("fs-lite", "fs-lite", "Local filesystem-backed KV for development.", "single-host"),
|
|
2009
|
-
netlify: explicit("kv.driver", "Upstash / Redis", "Set `kv.driver` to `upstash`, `redis`, or `database`, or set Upstash REST credentials at build time. No Netlify-native KV output is provided. Without them, KV uses a Postgres Default Database, else `fs-lite` files that other function instances cannot read."),
|
|
2010
|
-
node: native("fs-lite", "Redis / Postgres / fs-lite", "A table in a Postgres Default Database, else local files. Redis requires kv: { driver: 'redis' }; REDIS_URL supplies its URL on every server. Upstash with REST credentials at build time.", "single-host"),
|
|
2011
|
-
vercel: native("upstash", "Upstash", "Upstash Redis with KV REST credentials.")
|
|
2012
|
-
},
|
|
2013
|
-
id: "kv",
|
|
2014
|
-
packages: ["@vite-hub/kv"],
|
|
2015
|
-
summary: "Key-value storage with one API on every host.",
|
|
2016
|
-
title: "KV"
|
|
2017
|
-
}),
|
|
2018
|
-
mcp: feature({
|
|
2019
|
-
docs: "/docs/mcp",
|
|
2020
|
-
hosts: everywhere("nitro", "Nitro"),
|
|
2021
|
-
id: "mcp",
|
|
2022
|
-
packages: ["@vite-hub/mcp"],
|
|
2023
|
-
summary: "The app's own MCP server, with one tool per file in `server/mcp/tools/`.",
|
|
2024
|
-
title: "MCP server"
|
|
2025
|
-
}),
|
|
2026
|
-
observability: feature({
|
|
2027
|
-
docs: "/docs/agents/observability",
|
|
2028
|
-
hosts: everywhere("evlog", "Evlog"),
|
|
2029
|
-
id: "observability",
|
|
2030
|
-
packages: ["evlog"],
|
|
2031
|
-
summary: "Request logs through Evlog, the logs that the Console reads, and Agent telemetry with a service name.",
|
|
2032
|
-
title: "Observability"
|
|
2033
|
-
}),
|
|
2034
|
-
queue: feature({
|
|
2035
|
-
definition: starter("server/queues", (name) => `import { defineQueue } from "vite-hub/queue"
|
|
2036
|
-
|
|
2037
|
-
export default defineQueue<{ id: string }>(async ({ payload }) => {
|
|
2038
|
-
console.log("${name}", payload.id)
|
|
2039
|
-
})
|
|
2040
|
-
`, { suffix: "queue" }),
|
|
2041
|
-
docs: "/docs/queue",
|
|
2042
|
-
hosts: {
|
|
2043
|
-
cloudflare: native("cloudflare", "Queues", "Cloudflare Queues bindings and consumers."),
|
|
2044
|
-
deno: unsupported$1("No Deno Queue driver is provided."),
|
|
2045
|
-
dev: native("local", "Local driver", "The local driver stores jobs in .vitehub/data/queue and runs them in the dev server process.", "single-host"),
|
|
2046
|
-
netlify: unsupported$1("Netlify has no Queue driver, so `vitehub({ queue })` fails on Netlify."),
|
|
2047
|
-
node: native("local", "Postgres / local driver", "With a Postgres Default Database, the postgres driver keeps jobs in Postgres and every instance runs them. Else the local driver keeps jobs on the disk of one host.", "single-host"),
|
|
2048
|
-
vercel: native("vercel", "Vercel Queues", "Vercel Queues callbacks and runtime client.")
|
|
2049
|
-
},
|
|
2050
|
-
id: "queue",
|
|
2051
|
-
packages: ["@vite-hub/queue"],
|
|
2052
|
-
providerPackages: { driver: { postgres: ["postgres"] } },
|
|
2053
|
-
service: "queue",
|
|
2054
|
-
summary: "Background jobs in `server/queues/` with retries and delivery on every supported host.",
|
|
2055
|
-
title: "Queue"
|
|
2056
|
-
}),
|
|
2057
|
-
rateLimit: feature({
|
|
2058
|
-
developmentOverrides: ["cloudflare"],
|
|
2059
|
-
docs: "/docs/rate-limit",
|
|
2060
|
-
hosts: {
|
|
2061
|
-
cloudflare: native("cloudflare", "Cloudflare", "Native Cloudflare Rate Limiting binding."),
|
|
2062
|
-
deno: unsupported$1("ViteHub has no native Deno Rate Limit driver."),
|
|
2063
|
-
dev: native("memory", "memory", "Process-local memory driver for development and tests.", "process-local"),
|
|
2064
|
-
netlify: unsupported$1("ViteHub has no native Netlify Rate Limit driver."),
|
|
2065
|
-
node: native("memory", "memory, or KV", "Without KV, each process counts alone. With KV on, ViteHub selects the kv provider, which shares the counts when KV uses Redis or a Postgres Database.", "process-local"),
|
|
2066
|
-
vercel: unsupported$1("ViteHub has no native Vercel Rate Limit driver.")
|
|
2067
|
-
},
|
|
2068
|
-
id: "rateLimit",
|
|
2069
|
-
packages: ["@vite-hub/rate-limit"],
|
|
2070
|
-
service: "rateLimit",
|
|
2071
|
-
summary: "Rate limits in `server/rate-limits/` that protect routes and Agent tools.",
|
|
2072
|
-
title: "Rate Limit"
|
|
2073
|
-
}),
|
|
2074
|
-
realtime: feature({
|
|
2075
|
-
definition: starter("server/realtime", (name) => `import { defineRealtime } from "vite-hub/realtime"
|
|
2076
|
-
|
|
2077
|
-
export default defineRealtime({
|
|
2078
|
-
auth: true,
|
|
2079
|
-
document: { workspace: "${name}" },
|
|
2080
|
-
})
|
|
2081
|
-
`),
|
|
2082
|
-
developmentOverrides: [
|
|
2083
|
-
"cloudflare",
|
|
2084
|
-
"deno",
|
|
2085
|
-
"netlify",
|
|
2086
|
-
"vercel"
|
|
2087
|
-
],
|
|
2088
|
-
docs: "/docs/realtime",
|
|
2089
|
-
hosts: {
|
|
2090
|
-
cloudflare: native("cloudflare", "Durable Objects", "Cloudflare Durable Objects run the production rooms."),
|
|
2091
|
-
deno: unsupported$1("Realtime has no distributed Deno driver, and process memory is rejected for the Deno host."),
|
|
2092
|
-
dev: native("memory", "memory", "Process-memory driver for local development.", "process-local"),
|
|
2093
|
-
netlify: unsupported$1("Realtime has no distributed Netlify driver, and process memory is rejected for the Netlify host."),
|
|
2094
|
-
node: native("node", "Postgres or Redis", "Each instance keeps its rooms in memory and shares them through Redis with REDIS_URL, else Postgres on a Postgres Default Database. Without either, rooms stay in one process."),
|
|
2095
|
-
vercel: unsupported$1("Realtime has no distributed Vercel driver, and process memory is rejected for the Vercel host.")
|
|
2096
|
-
},
|
|
2097
|
-
id: "realtime",
|
|
2098
|
-
packages: ["@vite-hub/realtime"],
|
|
2099
|
-
service: "realtime",
|
|
2100
|
-
summary: "Shared rooms with presence and Yjs documents.",
|
|
2101
|
-
title: "Realtime"
|
|
2102
|
-
}),
|
|
2103
|
-
sandboxTask: feature({
|
|
2104
|
-
docs: "/docs/sandbox",
|
|
2105
|
-
hosts: {
|
|
2106
|
-
cloudflare: native("cloudflare", "CF Sandbox", "Cloudflare Sandbox execution provider."),
|
|
2107
|
-
deno: unsupported$1("No Deno Sandbox driver is provided."),
|
|
2108
|
-
dev: unsupported$1("The default Node host has no Sandbox Provider. Development with the Vercel host uses Vercel Sandbox when Vercel credentials are set. The Vite or Nuxt dev server cannot host a Cloudflare Container: build, then run `wrangler dev` on the build output."),
|
|
2109
|
-
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
|
-
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
|
-
vercel: native("vercel", "Vercel Sandbox", "Vercel Sandbox execution provider.")
|
|
2112
|
-
},
|
|
2113
|
-
id: "sandboxTask",
|
|
2114
|
-
packages: ["@vite-hub/sandbox"],
|
|
2115
|
-
service: "sandbox",
|
|
2116
|
-
summary: "Sandbox Tasks in `server/sandbox-tasks/`. Each run starts an isolated Cloudflare or Vercel Sandbox.",
|
|
2117
|
-
title: "Sandbox"
|
|
2118
|
-
}),
|
|
2119
|
-
schedule: feature({
|
|
2120
|
-
definition: starter("server/schedules", (name) => `import { defineSchedule } from "vite-hub/schedule"
|
|
2121
|
-
|
|
2122
|
-
export default defineSchedule({
|
|
2123
|
-
cron: "0 * * * *",
|
|
2124
|
-
handler: () => {
|
|
2125
|
-
console.log("${name}")
|
|
2126
|
-
},
|
|
2127
|
-
})
|
|
2128
|
-
`, { suffix: "schedule" }),
|
|
2129
|
-
developmentOverrides: [
|
|
2130
|
-
"cloudflare",
|
|
2131
|
-
"netlify",
|
|
2132
|
-
"vercel"
|
|
2133
|
-
],
|
|
2134
|
-
docs: "/docs/schedule",
|
|
2135
|
-
hosts: {
|
|
2136
|
-
cloudflare: native("cloudflare", "Cron triggers", "Cloudflare scheduled events and Nitro Provider Wake."),
|
|
2137
|
-
deno: native("deno", "Deno.cron", "`Deno.cron` output that the generated `.output/main.ts` loads before the Nitro server."),
|
|
2138
|
-
dev: native("local", "Local / process", "Local development runner and the explicit process runtime.", "single-host"),
|
|
2139
|
-
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. A build needs `schedule: { runtime: { driver: \"process\" } }`, or `providerOutput: false` to wake Schedules yourself.", "single-host"),
|
|
2141
|
-
vercel: native("vercel", "Vercel Cron", "Vercel Cron Jobs provider output.")
|
|
2142
|
-
},
|
|
2143
|
-
id: "schedule",
|
|
2144
|
-
packages: ["@vite-hub/schedule"],
|
|
2145
|
-
summary: "Cron Schedules in `server/schedules/` that run on the host's scheduler.",
|
|
2146
|
-
title: "Schedule"
|
|
2147
|
-
}),
|
|
2148
|
-
workflow: feature({
|
|
2149
|
-
definition: starter("server/workflows", (name) => `import { defineWorkflow } from "vite-hub/workflow"
|
|
2150
|
-
|
|
2151
|
-
export default defineWorkflow(${JSON.stringify(name)}, async (payload: { id: string }) => {
|
|
2152
|
-
return { id: payload.id }
|
|
2153
|
-
})
|
|
2154
|
-
`, {
|
|
2155
|
-
folder: "index",
|
|
2156
|
-
suffix: "workflow"
|
|
2157
|
-
}),
|
|
2158
|
-
docs: "/docs/workflows",
|
|
2159
|
-
hosts: {
|
|
2160
|
-
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. Workflow that only the Agent turns on runs inline in the request process, so a restart loses the run."),
|
|
2162
|
-
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
|
-
netlify: explicit("workflow.driver", "OpenWorkflow", "Use OpenWorkflow explicitly. No Netlify-native Workflow driver is provided."),
|
|
2164
|
-
node: {
|
|
2165
|
-
...native("openworkflow", "OpenWorkflow", "OpenWorkflow is the default, and each server runs its worker. It uses OPENWORKFLOW_POSTGRES_URL or the Postgres Default Database. Without them, runs use a SQLite file on one host.", "single-host"),
|
|
2166
|
-
envOverrides: ["OPENWORKFLOW_POSTGRES_URL"].map((env) => ({
|
|
2167
|
-
env,
|
|
2168
|
-
support: native("openworkflow", "OpenWorkflow (Postgres)", `${env} selects Postgres. Several servers can run the worker on the same database, and each run executes once.`)
|
|
2169
|
-
}))
|
|
2170
|
-
},
|
|
2171
|
-
vercel: native("vercel", "Vercel Workflow", "Vercel Workflow provider and Workflow DevKit output.")
|
|
2172
|
-
},
|
|
2173
|
-
id: "workflow",
|
|
2174
|
-
packages: ["@vite-hub/workflow"],
|
|
2175
|
-
summary: "Durable Workflows in `server/workflows/` with steps and driver retries.",
|
|
2176
|
-
title: "Workflow"
|
|
2177
|
-
}),
|
|
2178
|
-
workspace: feature({
|
|
2179
|
-
developmentOverrides: [
|
|
2180
|
-
"cloudflare",
|
|
2181
|
-
"deno",
|
|
2182
|
-
"netlify",
|
|
2183
|
-
"vercel"
|
|
2184
|
-
],
|
|
2185
|
-
docs: "/docs/workspace",
|
|
2186
|
-
hosts: {
|
|
2187
|
-
cloudflare: native("memory", "Artifacts / GitHub", "Memory by default, or Cloudflare Artifacts beta and GitHub for durable state.", "process-local"),
|
|
2188
|
-
deno: explicit("workspace.store", "GitHub", "Select the GitHub Workspace Store explicitly for durable state."),
|
|
2189
|
-
dev: native("local", "local / memory", "Local filesystem or in-memory Workspace Store.", "single-host"),
|
|
2190
|
-
netlify: explicit("workspace.store", "GitHub", "Select the GitHub Workspace Store explicitly for durable state."),
|
|
2191
|
-
node: native("local", "local / GitHub", "Local filesystem, memory, or GitHub Workspace Store.", "single-host"),
|
|
2192
|
-
vercel: {
|
|
2193
|
-
...native("memory", "memory / Blob / GitHub", "Process-local memory by default. BLOB_READ_WRITE_TOKEN selects Vercel Blob; GitHub can be selected explicitly for durable state.", "process-local"),
|
|
2194
|
-
envOverrides: [{
|
|
2195
|
-
env: "BLOB_READ_WRITE_TOKEN",
|
|
2196
|
-
support: native("vercel", "Blob / GitHub", "BLOB_READ_WRITE_TOKEN selects durable Vercel Blob storage by default.")
|
|
2197
|
-
}]
|
|
2198
|
-
}
|
|
2199
|
-
},
|
|
2200
|
-
id: "workspace",
|
|
2201
|
-
packages: ["@vite-hub/workspace"],
|
|
2202
|
-
summary: "File workspaces that Agents read and edit, backed by local, Blob, or GitHub stores.",
|
|
2203
|
-
title: "Workspace"
|
|
2204
|
-
})
|
|
2205
|
-
};
|
|
2206
|
-
/** Packages needed by a feature, its provider, and its enabled feature integrations. */
|
|
2207
|
-
function featurePackages(id, value, host, enabled = []) {
|
|
2208
|
-
const definition = features[id];
|
|
2209
|
-
const options = value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
2210
|
-
const stores = options?.stores;
|
|
2211
|
-
const selected = (id === "blob" && stores && typeof stores === "object" && !Array.isArray(stores) ? [value, ...Object.values(stores)] : [value]).flatMap((value) => Object.entries(definition.providerPackages ?? {}).flatMap(([key, choices]) => {
|
|
2212
|
-
const choice = value && typeof value === "object" && !Array.isArray(value) ? Reflect.get(value, key) : void 0;
|
|
2213
|
-
return typeof choice === "string" ? choices[choice] ?? [] : [];
|
|
2214
|
-
}));
|
|
2215
|
-
if (id === "observability" && typeof options?.service === "string") selected.push("@vite-hub/agent");
|
|
2216
|
-
if (id === "observability" && options?.posthog) selected.push("posthog-node");
|
|
2217
|
-
const sandboxDriver = typeof options?.driver === "string" ? options.driver : host;
|
|
2218
|
-
if (id === "sandboxTask" && (sandboxDriver === "vercel" || sandboxDriver === "cloudflare")) selected.push(sandboxDriverPackages[sandboxDriver]);
|
|
2219
|
-
if ((id === "queue" || id === "workflow") && host === "vercel" && (options?.driver ?? "vercel") === "vercel") selected.push(...vercelProviderPackages[id]);
|
|
2220
|
-
if (id === "console" && enabled.includes("agent")) selected.push(...consoleFeaturePackages.agents);
|
|
2221
|
-
return [.../* @__PURE__ */ new Set([...definition.packages, ...selected])];
|
|
2222
|
-
}
|
|
2223
|
-
const sandboxDriverPackages = {
|
|
2224
|
-
cloudflare: "@cloudflare/sandbox",
|
|
2225
|
-
vercel: "@vercel/sandbox"
|
|
2226
|
-
};
|
|
2227
|
-
/**
|
|
2228
|
-
* The SDKs of the Vercel provider. Native Vercel Workflows also need `workflow` and `@workflow/builders`, but only
|
|
2229
|
-
* `@vite-hub/workflow` knows when a Workflow is native, so it checks those two itself.
|
|
2230
|
-
*/
|
|
2231
|
-
const vercelProviderPackages = {
|
|
2232
|
-
queue: ["@vercel/queue", "@vercel/functions"],
|
|
2233
|
-
workflow: ["@vercel/functions"]
|
|
2234
|
-
};
|
|
2235
|
-
/** Additional Console owners selected by its enabled Agent integration. */
|
|
2236
|
-
const consoleFeaturePackages = { agents: ["@libsql/client", "drizzle-orm"] };
|
|
2237
|
-
function featureSupport(id, host, appHost) {
|
|
2238
|
-
const definition = features[id];
|
|
2239
|
-
if (host !== "dev") return definition.hosts[host];
|
|
2240
|
-
invariant(appHost, "every caller of featureSupport() for the dev host passes the configured ViteHub host");
|
|
2241
|
-
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
|
-
return definition.hosts[appHost === "node" || definition.developmentOverrides?.includes(appHost) ? "dev" : appHost];
|
|
2243
|
-
}
|
|
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
|
-
/**
|
|
2249
|
-
* The features that `enabled` turn on through implications on `host`, without the ones already in `enabled`.
|
|
2250
|
-
* This follows implications transitively.
|
|
2251
|
-
* `disabled` lists features that the app sets to `false`; an implication never turns them on.
|
|
2252
|
-
*/
|
|
2253
|
-
function impliedFeatures(enabled, host, disabled = []) {
|
|
2254
|
-
const on = new Set(enabled);
|
|
2255
|
-
const implied = [];
|
|
2256
|
-
const pending = [...enabled];
|
|
2257
|
-
while (pending.length) {
|
|
2258
|
-
const id = pending.shift();
|
|
2259
|
-
for (const implication of features[id].implies) {
|
|
2260
|
-
if (implication.except?.includes(host) || on.has(implication.feature) || disabled.includes(implication.feature)) continue;
|
|
2261
|
-
on.add(implication.feature);
|
|
2262
|
-
implied.push(implication.feature);
|
|
2263
|
-
pending.push(implication.feature);
|
|
2264
|
-
}
|
|
2265
|
-
}
|
|
2266
|
-
return implied;
|
|
2267
|
-
}
|
|
2268
|
-
//#endregion
|
|
2269
1651
|
//#region src/setup/project.ts
|
|
2270
1652
|
const nuxtConfigFiles = [
|
|
2271
1653
|
"nuxt.config.ts",
|
|
@@ -2283,7 +1665,8 @@ const viteConfigFiles = [
|
|
|
2283
1665
|
"vite.config.cts",
|
|
2284
1666
|
"vite.config.cjs"
|
|
2285
1667
|
];
|
|
2286
|
-
|
|
1668
|
+
/** The lockfiles and workspace files that name a package manager, in the order that detection reads them. */
|
|
1669
|
+
const setupLockfiles = [
|
|
2287
1670
|
["pnpm-lock.yaml", "pnpm"],
|
|
2288
1671
|
["pnpm-workspace.yaml", "pnpm"],
|
|
2289
1672
|
["bun.lock", "bun"],
|
|
@@ -2315,7 +1698,7 @@ function detectPackageManager(root, manifest, env) {
|
|
|
2315
1698
|
packageManagerSource: "manifest"
|
|
2316
1699
|
};
|
|
2317
1700
|
for (const folder of parentFolders(root)) {
|
|
2318
|
-
const found =
|
|
1701
|
+
const found = setupLockfiles.find(([file]) => existsSync(join(folder, file)));
|
|
2319
1702
|
if (found) return {
|
|
2320
1703
|
packageManager: found[1],
|
|
2321
1704
|
packageManagerSource: "lockfile"
|
|
@@ -2330,21 +1713,57 @@ function detectPackageManager(root, manifest, env) {
|
|
|
2330
1713
|
packageManagerSource: "default"
|
|
2331
1714
|
};
|
|
2332
1715
|
}
|
|
2333
|
-
|
|
1716
|
+
const nuxtLayerKeys = [
|
|
1717
|
+
"extends",
|
|
1718
|
+
"_extends",
|
|
1719
|
+
"theme",
|
|
1720
|
+
"_layers"
|
|
1721
|
+
];
|
|
1722
|
+
function nuxtDirectoryOverride(value) {
|
|
1723
|
+
return value !== null && typeof value === "object" && [
|
|
1724
|
+
"rootDir",
|
|
1725
|
+
"serverDir",
|
|
1726
|
+
...nuxtLayerKeys
|
|
1727
|
+
].some((key) => Object.hasOwn(value, key));
|
|
1728
|
+
}
|
|
1729
|
+
async function nuxtRcAllowsStaticDiscovery(folder) {
|
|
1730
|
+
const file = join(folder, ".nuxtrc");
|
|
1731
|
+
try {
|
|
1732
|
+
if (!(await stat(file)).isFile()) return false;
|
|
1733
|
+
return !nuxtDirectoryOverride(parse$2(await readFile(file, "utf8")));
|
|
1734
|
+
} catch (error) {
|
|
1735
|
+
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
async function nuxtServerDirs(root, config, env) {
|
|
2334
1739
|
const nuxt = config?.ok ? config.site.nuxt : void 0;
|
|
2335
1740
|
if (!nuxt || nuxt.spread) return;
|
|
2336
|
-
const
|
|
2337
|
-
|
|
2338
|
-
|
|
1741
|
+
for (const key of nuxtLayerKeys) {
|
|
1742
|
+
const layer = nuxt.keys[key];
|
|
1743
|
+
if (layer && !(layer.kind === "literal" && Array.isArray(layer.value) && layer.value.length === 0)) return;
|
|
1744
|
+
}
|
|
1745
|
+
for (const [key, override] of Object.entries(nuxt.keys)) {
|
|
1746
|
+
if (!key.startsWith("$") || key === "$meta") continue;
|
|
1747
|
+
if (override.kind === "expression") return;
|
|
1748
|
+
if (key === "$env") {
|
|
1749
|
+
if (override.value !== null && typeof override.value === "object" && Object.values(override.value).some(nuxtDirectoryOverride)) return;
|
|
1750
|
+
} else if (nuxtDirectoryOverride(override.value)) return;
|
|
1751
|
+
}
|
|
1752
|
+
if (existsSync(join(root, "layers"))) return;
|
|
2339
1753
|
const rootDir = nuxt.keys.rootDir;
|
|
2340
1754
|
const serverDir = nuxt.keys.serverDir;
|
|
2341
1755
|
if (rootDir && (rootDir.kind !== "literal" || typeof rootDir.value !== "string")) return;
|
|
2342
1756
|
if (serverDir && (serverDir.kind !== "literal" || typeof serverDir.value !== "string")) return;
|
|
2343
1757
|
const appRoot = rootDir?.kind === "literal" && typeof rootDir.value === "string" ? resolve(root, rootDir.value) : root;
|
|
2344
1758
|
if (existsSync(join(appRoot, "layers"))) return;
|
|
1759
|
+
const home = homedir();
|
|
1760
|
+
for (const folder of /* @__PURE__ */ new Set([
|
|
1761
|
+
...parentFolders(root),
|
|
1762
|
+
home,
|
|
1763
|
+
env.XDG_CONFIG_HOME || join(home, ".config")
|
|
1764
|
+
])) if (!await nuxtRcAllowsStaticDiscovery(folder)) return;
|
|
2345
1765
|
return [resolve(appRoot, serverDir?.kind === "literal" && typeof serverDir.value === "string" ? serverDir.value || "server" : "server")];
|
|
2346
1766
|
}
|
|
2347
|
-
/** The real folders of `name` in NODE_PATH, which Node's resolver reads after every node_modules folder. */
|
|
2348
1767
|
function globalPackageDirs(name) {
|
|
2349
1768
|
return (process$1.env.NODE_PATH ?? "").split(delimiter).filter(Boolean).flatMap((dir) => {
|
|
2350
1769
|
try {
|
|
@@ -2397,10 +1816,67 @@ async function readSetupProject(root, env) {
|
|
|
2397
1816
|
},
|
|
2398
1817
|
...detectPackageManager(root, manifest, env),
|
|
2399
1818
|
root,
|
|
2400
|
-
serverDirs: framework === "nuxt" ? nuxtServerDirs(root, config) : [join(root, "server")]
|
|
1819
|
+
serverDirs: framework === "nuxt" ? await nuxtServerDirs(root, config, env) : [join(root, "server")]
|
|
2401
1820
|
};
|
|
2402
1821
|
}
|
|
2403
1822
|
//#endregion
|
|
1823
|
+
//#region ../internal/dist/definition-catalog.js
|
|
1824
|
+
const sourceFilePattern = /\.(?:c|m)?[jt]sx?$/i;
|
|
1825
|
+
const declarationFilePattern = /\.d\.(?:c|m)?[jt]sx?$/i;
|
|
1826
|
+
const testFilePattern = /\.(?:test|spec)\.(?:c|m)?[jt]sx?$/i;
|
|
1827
|
+
const ignoredDirs = /* @__PURE__ */ new Set([
|
|
1828
|
+
"node_modules",
|
|
1829
|
+
"dist",
|
|
1830
|
+
".output",
|
|
1831
|
+
".nuxt",
|
|
1832
|
+
".vercel",
|
|
1833
|
+
".git",
|
|
1834
|
+
".vitehub"
|
|
1835
|
+
]);
|
|
1836
|
+
function readDirEntries(root) {
|
|
1837
|
+
try {
|
|
1838
|
+
return readdirSync(root, { withFileTypes: true });
|
|
1839
|
+
} catch (error) {
|
|
1840
|
+
if (error.code === "ENOENT") return [];
|
|
1841
|
+
throw error;
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
function isGitRepositoryDirectory(directory) {
|
|
1845
|
+
return existsSync(resolve(directory, ".git"));
|
|
1846
|
+
}
|
|
1847
|
+
function listMatchingFiles(root, predicate, options = {}) {
|
|
1848
|
+
const files = [];
|
|
1849
|
+
for (const entry of readDirEntries(root)) {
|
|
1850
|
+
const absolute = resolve(root, entry.name);
|
|
1851
|
+
if (entry.isDirectory() && !entry.isSymbolicLink()) {
|
|
1852
|
+
if (isGitRepositoryDirectory(absolute)) continue;
|
|
1853
|
+
if (entry.name.startsWith(".")) continue;
|
|
1854
|
+
if (ignoredDirs.has(entry.name)) continue;
|
|
1855
|
+
files.push(...listMatchingFiles(absolute, predicate, options));
|
|
1856
|
+
continue;
|
|
1857
|
+
}
|
|
1858
|
+
if (entry.name.startsWith(".") && !options.includeHidden) continue;
|
|
1859
|
+
if (entry.isFile() && predicate(entry.name)) files.push(absolute);
|
|
1860
|
+
}
|
|
1861
|
+
return files.sort();
|
|
1862
|
+
}
|
|
1863
|
+
/** A module that a Definitions folder can hold: JavaScript or TypeScript, and not a declaration, test, or spec file. */
|
|
1864
|
+
function isDefinitionSourceFile(name) {
|
|
1865
|
+
return sourceFilePattern.test(name) && !declarationFilePattern.test(name) && !testFilePattern.test(name);
|
|
1866
|
+
}
|
|
1867
|
+
function listSourceFiles(root, options = {}) {
|
|
1868
|
+
return listMatchingFiles(root, isDefinitionSourceFile, options);
|
|
1869
|
+
}
|
|
1870
|
+
/**
|
|
1871
|
+
* Whether `path` is a file, or a folder that holds a Definition source file. A Definition file in a server directory,
|
|
1872
|
+
* such as `server/auth.ts` or a file in `server/queues/`, turns its feature on without a key. An empty folder, which
|
|
1873
|
+
* Git does not keep, turns nothing on.
|
|
1874
|
+
*/
|
|
1875
|
+
function hasDefinitionFiles(path) {
|
|
1876
|
+
if (!existsSync(path)) return false;
|
|
1877
|
+
return statSync(path).isFile() || listSourceFiles(path).length > 0;
|
|
1878
|
+
}
|
|
1879
|
+
//#endregion
|
|
2404
1880
|
//#region ../internal/dist/deployment.js
|
|
2405
1881
|
const unsupported = (reason) => ({
|
|
2406
1882
|
reason,
|
|
@@ -2472,7 +1948,7 @@ const plans = {
|
|
|
2472
1948
|
nitroPreset: "netlify",
|
|
2473
1949
|
output: {
|
|
2474
1950
|
directory: ".netlify",
|
|
2475
|
-
entry: "functions
|
|
1951
|
+
entry: "v1/functions/server/server.mjs",
|
|
2476
1952
|
packaging: "none"
|
|
2477
1953
|
},
|
|
2478
1954
|
runtime: "node",
|
|
@@ -2615,6 +2091,10 @@ const addArgs = {
|
|
|
2615
2091
|
prod: ["add"]
|
|
2616
2092
|
}
|
|
2617
2093
|
};
|
|
2094
|
+
/** Quotes `value` for a POSIX shell when it needs quotes. */
|
|
2095
|
+
function shellQuote(value) {
|
|
2096
|
+
return /^[\w@%+=:,./-]+$/u.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
|
|
2097
|
+
}
|
|
2618
2098
|
/** The arguments of the `packageManager` command that installs `packages`, such as `["add", "-D", "drizzle-kit"]`. */
|
|
2619
2099
|
function installArgs(packageManager, packages, dev) {
|
|
2620
2100
|
return [...addArgs[packageManager][dev ? "dev" : "prod"], ...packages];
|
|
@@ -2629,9 +2109,11 @@ const removeArgs = {
|
|
|
2629
2109
|
function uninstallArgs(packageManager, packages) {
|
|
2630
2110
|
return [...removeArgs[packageManager], ...packages];
|
|
2631
2111
|
}
|
|
2632
|
-
|
|
2112
|
+
function formatInstallCommand(command, args) {
|
|
2113
|
+
return [command, ...args].map(formatInstallArgument).join(" ");
|
|
2114
|
+
}
|
|
2633
2115
|
function installCommand(packageManager, prod, dev) {
|
|
2634
|
-
const commands = [...prod.length ? [
|
|
2116
|
+
const commands = [...prod.length ? [formatInstallCommand(packageManager, installArgs(packageManager, prod, false))] : [], ...dev.length ? [formatInstallCommand(packageManager, installArgs(packageManager, dev, true))] : []];
|
|
2635
2117
|
return commands.length ? commands.join(" && ") : void 0;
|
|
2636
2118
|
}
|
|
2637
2119
|
function readHost(project, env) {
|
|
@@ -2660,7 +2142,7 @@ function readHost(project, env) {
|
|
|
2660
2142
|
source: "default"
|
|
2661
2143
|
};
|
|
2662
2144
|
}
|
|
2663
|
-
function readEnabled(project, id) {
|
|
2145
|
+
function readEnabled(project, id, withoutDefinitions) {
|
|
2664
2146
|
const config = project.config;
|
|
2665
2147
|
if (!config || !config.ok && config.reason === "no-vitehub") return {
|
|
2666
2148
|
enabled: "off",
|
|
@@ -2687,6 +2169,10 @@ function readEnabled(project, id) {
|
|
|
2687
2169
|
enabled: "on",
|
|
2688
2170
|
reason: "default"
|
|
2689
2171
|
};
|
|
2172
|
+
if (withoutDefinitions?.has(id)) return {
|
|
2173
|
+
enabled: "off",
|
|
2174
|
+
reason: "default"
|
|
2175
|
+
};
|
|
2690
2176
|
const discovery = features[id].enabledByDiscovery;
|
|
2691
2177
|
const directories = project.serverDirs ?? (project.framework === "nuxt" ? void 0 : [join(project.root, "server")]);
|
|
2692
2178
|
if (discovery && !directories) return {
|
|
@@ -2694,41 +2180,50 @@ function readEnabled(project, id) {
|
|
|
2694
2180
|
reason: "default"
|
|
2695
2181
|
};
|
|
2696
2182
|
return {
|
|
2697
|
-
enabled: discovery?.some((file) => directories?.some((directory) =>
|
|
2183
|
+
enabled: discovery?.some((file) => directories?.some((directory) => hasDefinitionFiles(join(directory, file)))) ? "on" : "off",
|
|
2698
2184
|
reason: "default"
|
|
2699
2185
|
};
|
|
2700
2186
|
}
|
|
2701
|
-
|
|
2702
|
-
function
|
|
2703
|
-
|
|
2704
|
-
|
|
2187
|
+
const kvDefaultStoreOption = "kv.stores.default.driver";
|
|
2188
|
+
function kvStores(value) {
|
|
2189
|
+
return isRecord(value) && isRecord(value.stores) ? value.stores : void 0;
|
|
2190
|
+
}
|
|
2191
|
+
function missingProviderOption(project, option, value) {
|
|
2705
2192
|
const [id, key] = option.split(".");
|
|
2706
|
-
const
|
|
2707
|
-
if (
|
|
2708
|
-
const options = value?.value;
|
|
2709
|
-
|
|
2193
|
+
const configured = project.config?.ok ? project.config.site.keys[id] : void 0;
|
|
2194
|
+
if (configured?.kind === "expression") return;
|
|
2195
|
+
const options = value ?? configured?.value;
|
|
2196
|
+
const stores = option === "kv.driver" ? kvStores(options) : void 0;
|
|
2197
|
+
if (stores) {
|
|
2198
|
+
const store = stores.default;
|
|
2199
|
+
const driver = isRecord(store) ? store.driver : void 0;
|
|
2200
|
+
if (driver !== "upstash" && driver !== "redis" && driver !== "database") return kvDefaultStoreOption;
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
if (!isRecord(options) || !(key in options)) return option;
|
|
2710
2204
|
}
|
|
2711
2205
|
function featureFix(project, id, support, host, missing, providerChosen) {
|
|
2712
|
-
const install = installCommand(project.packageManager, missing.prod, missing.dev);
|
|
2206
|
+
const install = installCommand(project.packageManager, missing.prod.map(installSpecifier), missing.dev.map(installSpecifier));
|
|
2713
2207
|
if (install) return install;
|
|
2714
2208
|
if (support.level === "unsupported") return `Set \`${id}: false\`, or build for another host than ${host}.`;
|
|
2715
|
-
if (support.level === "explicit" && !providerChosen
|
|
2209
|
+
if (support.level === "explicit" && !providerChosen) {
|
|
2210
|
+
const option = missingProviderOption(project, support.option);
|
|
2211
|
+
if (option) return `Set \`${option}\` in vitehub() to choose a provider on ${host}.`;
|
|
2212
|
+
}
|
|
2716
2213
|
}
|
|
2717
2214
|
/** 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) {
|
|
2215
|
+
function setupStatus(project, env, withoutDefinitions) {
|
|
2719
2216
|
const host = readHost(project, env);
|
|
2720
|
-
const enabled = new Map(featureIds.map((id) => [id, readEnabled(project, id)]));
|
|
2217
|
+
const enabled = new Map(featureIds.map((id) => [id, readEnabled(project, id, withoutDefinitions)]));
|
|
2721
2218
|
const on = featureIds.filter((id) => enabled.get(id).enabled === "on");
|
|
2722
2219
|
const keep = featureIds.filter((id) => enabled.get(id).enabled !== "on" && enabled.get(id).reason === "config");
|
|
2723
2220
|
const maybeOn = featureIds.filter((id) => enabled.get(id).enabled !== "off");
|
|
2724
2221
|
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) {
|
|
2222
|
+
const definite = impliedFeatures(on, keep);
|
|
2223
|
+
for (const id of impliedFeatures(maybeOn, disabled)) {
|
|
2729
2224
|
const state = enabled.get(id);
|
|
2730
2225
|
if (state.enabled === "off" && state.reason === "default") enabled.set(id, {
|
|
2731
|
-
enabled: definite.
|
|
2226
|
+
enabled: definite.includes(id) ? "on" : "unknown",
|
|
2732
2227
|
reason: "implied"
|
|
2733
2228
|
});
|
|
2734
2229
|
}
|
|
@@ -2749,7 +2244,8 @@ function setupStatus(project, env) {
|
|
|
2749
2244
|
} : featureSupport(id, host.name);
|
|
2750
2245
|
const definition = features[id];
|
|
2751
2246
|
const value = project.config?.ok ? project.config.site.keys[id] : void 0;
|
|
2752
|
-
const
|
|
2247
|
+
const literal = value?.kind === "literal" ? value.value : void 0;
|
|
2248
|
+
const packages = featurePackages(id, literal, host.name, featureIds.filter((feature) => enabled.get(feature)?.enabled === "on"));
|
|
2753
2249
|
const missing = state.enabled === "on" ? {
|
|
2754
2250
|
dev: definition.devPackages.filter((name) => !project.installed(name)),
|
|
2755
2251
|
prod: packages.filter((name) => !project.installed(name))
|
|
@@ -2757,13 +2253,17 @@ function setupStatus(project, env) {
|
|
|
2757
2253
|
dev: [],
|
|
2758
2254
|
prod: []
|
|
2759
2255
|
};
|
|
2760
|
-
const providerChosen =
|
|
2256
|
+
const providerChosen = id === "workflow" && host.name !== "netlify" && packages.includes("openworkflow");
|
|
2761
2257
|
const fix = state.enabled === "on" ? featureFix(project, id, support, host.name, missing, providerChosen) : void 0;
|
|
2258
|
+
const resolvedSupport = support.level === "explicit" && support.option === "kv.driver" && kvStores(literal) ? {
|
|
2259
|
+
...support,
|
|
2260
|
+
option: kvDefaultStoreOption
|
|
2261
|
+
} : support;
|
|
2762
2262
|
return {
|
|
2763
2263
|
id,
|
|
2764
2264
|
...state,
|
|
2765
2265
|
missingPackages: [...missing.prod, ...missing.dev],
|
|
2766
|
-
support,
|
|
2266
|
+
support: resolvedSupport,
|
|
2767
2267
|
...fix ? { fix } : {}
|
|
2768
2268
|
};
|
|
2769
2269
|
}),
|
|
@@ -2963,13 +2463,14 @@ function createDeployRun(stderr, secrets) {
|
|
|
2963
2463
|
options.signal?.addEventListener("abort", abort, { once: true });
|
|
2964
2464
|
if (options.timeoutMs) timeout = setTimeout(stop, options.timeoutMs);
|
|
2965
2465
|
if (options.signal?.aborted) abort();
|
|
2966
|
-
child.stdin?.on("error", () => {
|
|
2466
|
+
child.stdin?.on("error", (error) => {
|
|
2467
|
+
if (!(error.code === "EPIPE" || stopping && error.code === "ERR_STREAM_DESTROYED")) failure ??= error;
|
|
2468
|
+
});
|
|
2967
2469
|
child.stdin?.end(options.stdin ?? "");
|
|
2968
2470
|
});
|
|
2969
2471
|
}
|
|
2970
2472
|
};
|
|
2971
2473
|
}
|
|
2972
|
-
/** Resolve npm/pnpm Windows shims to Node entrypoints without evaluating any batch or shell syntax. */
|
|
2973
2474
|
function windowsNodeEntry(file) {
|
|
2974
2475
|
if (/\.(?:exe|cmd|bat)$/iu.test(file)) return;
|
|
2975
2476
|
if (!existsSync(file)) return;
|
|
@@ -3153,7 +2654,6 @@ async function build(project, host, context) {
|
|
|
3153
2654
|
function stringList(value) {
|
|
3154
2655
|
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
3155
2656
|
}
|
|
3156
|
-
/** One entry of `env` in `deployment.json`. Only names: the build never writes a value there. */
|
|
3157
2657
|
function readEnvEntry(value) {
|
|
3158
2658
|
if (!isRecord(value)) return [];
|
|
3159
2659
|
const names = stringList(value.names);
|
|
@@ -3171,7 +2671,6 @@ function readEnvEntry(value) {
|
|
|
3171
2671
|
...owners.length ? { owners } : {}
|
|
3172
2672
|
}];
|
|
3173
2673
|
}
|
|
3174
|
-
/** `deploy` of `deployment.json`. Only paths that start with one `/` and a key that IndexNow accepts. */
|
|
3175
2674
|
function readDeploy(value) {
|
|
3176
2675
|
if (!isRecord(value)) return { check: [] };
|
|
3177
2676
|
const check = stringList(value.check).filter((path) => path.startsWith("/") && !path.startsWith("//"));
|
|
@@ -3215,15 +2714,8 @@ async function readBuildOutput(root, host) {
|
|
|
3215
2714
|
}
|
|
3216
2715
|
//#endregion
|
|
3217
2716
|
//#region src/setup/deploy/cloudflare.ts
|
|
3218
|
-
/** The flags that ViteHub's own build writes into `commands.deploy` (`packages/vite-hub/src/plugins.ts`). */
|
|
3219
2717
|
const valueFlags = /* @__PURE__ */ new Set(["--config"]);
|
|
3220
2718
|
const plainFlags = /* @__PURE__ */ new Set(["--containers-rollout=gradual"]);
|
|
3221
|
-
/**
|
|
3222
|
-
* Reads `commands.deploy` from `<output>/nitro.json` and checks that it is the Wrangler deploy that the build writes:
|
|
3223
|
-
* `npx wrangler deploy --config <file> [--containers-rollout=gradual]`. With
|
|
3224
|
-
* `database.migrateOnDeploy`, `npx wrangler d1 migrations apply <binding> --remote --config <file> && ` comes before it
|
|
3225
|
-
* once for each D1 binding (`packages/database/src/internal/migrate-on-deploy.ts`).
|
|
3226
|
-
*/
|
|
3227
2719
|
async function readWranglerCommand(outputDir) {
|
|
3228
2720
|
let manifest;
|
|
3229
2721
|
try {
|
|
@@ -3265,6 +2757,11 @@ async function readWranglerCommand(outputDir) {
|
|
|
3265
2757
|
*/
|
|
3266
2758
|
async function wranglerVarNames(outputDir) {
|
|
3267
2759
|
const { config } = await readWranglerCommand(outputDir);
|
|
2760
|
+
const wrangler = await readWranglerConfig(outputDir, config);
|
|
2761
|
+
return isRecord(wrangler.vars) ? Object.keys(wrangler.vars) : [];
|
|
2762
|
+
}
|
|
2763
|
+
/** The Wrangler config that the `--config` flag of `commands.deploy` names. */
|
|
2764
|
+
async function readWranglerConfig(outputDir, config) {
|
|
3268
2765
|
const file = join(outputDir, config);
|
|
3269
2766
|
let value;
|
|
3270
2767
|
try {
|
|
@@ -3272,9 +2769,40 @@ async function wranglerVarNames(outputDir) {
|
|
|
3272
2769
|
} catch {
|
|
3273
2770
|
throw setupFailure(cliErrorDiagnostics.SETUP_DEPLOY_OUTPUT_MISSING({ file }), setupExitCodes.error);
|
|
3274
2771
|
}
|
|
3275
|
-
return isRecord(value)
|
|
2772
|
+
return isRecord(value) ? value : {};
|
|
2773
|
+
}
|
|
2774
|
+
/**
|
|
2775
|
+
* The D1 bindings of the Wrangler config whose `migrations_dir` holds `.sql` files, except the bindings that the deploy
|
|
2776
|
+
* command migrates. Wrangler reads `migrations_dir` relative to the config file, and its default pattern is `*.sql`
|
|
2777
|
+
* without dot files. A binding with `migrations_pattern` selects other files, and ViteHub's build never writes one.
|
|
2778
|
+
*/
|
|
2779
|
+
async function unmigratedD1Bindings(outputDir, config, wrangler, migrated) {
|
|
2780
|
+
const found = [];
|
|
2781
|
+
for (const entry of Array.isArray(wrangler.d1_databases) ? wrangler.d1_databases : []) {
|
|
2782
|
+
if (!isRecord(entry)) continue;
|
|
2783
|
+
const binding = optionalString$1(entry.binding);
|
|
2784
|
+
const dir = optionalString$1(entry.migrations_dir);
|
|
2785
|
+
if (!binding || !dir || entry.migrations_pattern !== void 0 || migrated.includes(binding)) continue;
|
|
2786
|
+
const files = (await readdir(join(outputDir, dirname(config), dir), { withFileTypes: true }).catch(() => [])).filter((item) => item.isFile() && item.name.endsWith(".sql") && !item.name.startsWith(".")).map((item) => item.name).toSorted();
|
|
2787
|
+
if (files.length) found.push({
|
|
2788
|
+
binding,
|
|
2789
|
+
files,
|
|
2790
|
+
table: optionalString$1(entry.migrations_table) ?? "d1_migrations"
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2793
|
+
return found;
|
|
2794
|
+
}
|
|
2795
|
+
/** The `results` rows of `wrangler d1 execute --json`, which prints one `{ results, success, meta }` per statement. */
|
|
2796
|
+
function d1ResultNames(result) {
|
|
2797
|
+
let value;
|
|
2798
|
+
try {
|
|
2799
|
+
value = JSON.parse(result.stdout.slice(Math.max(result.stdout.indexOf("["), 0)));
|
|
2800
|
+
} catch {
|
|
2801
|
+
return;
|
|
2802
|
+
}
|
|
2803
|
+
if (!Array.isArray(value)) return void 0;
|
|
2804
|
+
return value.flatMap((item) => isRecord(item) && Array.isArray(item.results) ? item.results : []).flatMap((row) => isRecord(row) && typeof row.name === "string" ? [row.name] : []);
|
|
3276
2805
|
}
|
|
3277
|
-
/** Wrangler writes one JSON object per line to `WRANGLER_OUTPUT_FILE_PATH`. */
|
|
3278
2806
|
async function readWranglerOutput(file) {
|
|
3279
2807
|
return (await readFile(file, "utf8").catch(() => "")).split("\n").flatMap((line) => {
|
|
3280
2808
|
try {
|
|
@@ -3291,7 +2819,6 @@ const durationUnits = {
|
|
|
3291
2819
|
hour: 36e5,
|
|
3292
2820
|
day: 864e5
|
|
3293
2821
|
};
|
|
3294
|
-
/** `Claim within: 59 minutes` as an ISO time, from now. */
|
|
3295
2822
|
function claimExpiry(text) {
|
|
3296
2823
|
const match = /Claim within:\s*(\d+)\s*(second|minute|hour|day)s?/u.exec(text);
|
|
3297
2824
|
return match ? new Date(Date.now() + Number(match[1]) * durationUnits[match[2]]).toISOString() : void 0;
|
|
@@ -3311,18 +2838,60 @@ async function cloudflareAdapter(context) {
|
|
|
3311
2838
|
env: options.env ?? env,
|
|
3312
2839
|
...options
|
|
3313
2840
|
});
|
|
3314
|
-
|
|
3315
|
-
|
|
2841
|
+
/** The migrations of `target` that its migrations table does not list. A database without the table has none applied. */
|
|
2842
|
+
const pendingD1Migrations = async (target) => {
|
|
2843
|
+
const query = async (sql) => {
|
|
2844
|
+
const step = `wrangler d1 execute ${target.binding}`;
|
|
3316
2845
|
const result = await run([
|
|
3317
2846
|
"d1",
|
|
3318
|
-
"
|
|
3319
|
-
|
|
3320
|
-
binding,
|
|
2847
|
+
"execute",
|
|
2848
|
+
target.binding,
|
|
3321
2849
|
"--remote",
|
|
3322
2850
|
"--config",
|
|
3323
|
-
command.config
|
|
3324
|
-
|
|
3325
|
-
|
|
2851
|
+
command.config,
|
|
2852
|
+
"--json",
|
|
2853
|
+
"--command",
|
|
2854
|
+
sql
|
|
2855
|
+
], { env: {
|
|
2856
|
+
...env,
|
|
2857
|
+
WRANGLER_LOG: "log"
|
|
2858
|
+
} });
|
|
2859
|
+
if (result.exitCode !== 0) throw hostCliFailed(step, result, context.secrets);
|
|
2860
|
+
const names = d1ResultNames(result);
|
|
2861
|
+
if (!names) throw hostCliFailed(`${step} printed no JSON`, result, context.secrets);
|
|
2862
|
+
return names;
|
|
2863
|
+
};
|
|
2864
|
+
const tables = await query(`SELECT name FROM sqlite_master WHERE type = 'table' AND name = '${target.table.replaceAll("'", "''")}'`);
|
|
2865
|
+
const applied = new Set(tables.length ? await query(`SELECT name FROM "${target.table.replaceAll("\"", "\"\"")}"`) : []);
|
|
2866
|
+
return target.files.filter((file) => !applied.has(file));
|
|
2867
|
+
};
|
|
2868
|
+
return { async deploy() {
|
|
2869
|
+
if (!context.preview && !context.temporary) {
|
|
2870
|
+
const wranglerConfig = await readWranglerConfig(context.outputDir, command.config);
|
|
2871
|
+
const environment = env.CLOUDFLARE_ENV;
|
|
2872
|
+
const named = environment && isRecord(wranglerConfig.env) && Object.hasOwn(wranglerConfig.env, environment) ? wranglerConfig.env[environment] : void 0;
|
|
2873
|
+
const config = isRecord(named) ? named : wranglerConfig;
|
|
2874
|
+
for (const target of await unmigratedD1Bindings(context.outputDir, command.config, config, command.migrations)) {
|
|
2875
|
+
const pending = await pendingD1Migrations(target);
|
|
2876
|
+
if (!pending.length) continue;
|
|
2877
|
+
throw setupFailure(cliErrorDiagnostics.SETUP_DEPLOY_D1_MIGRATIONS_PENDING({
|
|
2878
|
+
apply: `npx wrangler d1 migrations apply ${shellQuote(target.binding)} --remote --config ${shellQuote(command.config)}${environment ? ` --env ${shellQuote(environment)}` : ""}`,
|
|
2879
|
+
binding: target.binding,
|
|
2880
|
+
migrations: pending.join(", ")
|
|
2881
|
+
}), setupExitCodes.error);
|
|
2882
|
+
}
|
|
2883
|
+
for (const binding of command.migrations) {
|
|
2884
|
+
const result = await run([
|
|
2885
|
+
"d1",
|
|
2886
|
+
"migrations",
|
|
2887
|
+
"apply",
|
|
2888
|
+
binding,
|
|
2889
|
+
"--remote",
|
|
2890
|
+
"--config",
|
|
2891
|
+
command.config
|
|
2892
|
+
], { show: true });
|
|
2893
|
+
if (result.exitCode !== 0) throw hostCliFailed(`wrangler d1 migrations apply ${binding}`, result, context.secrets);
|
|
2894
|
+
}
|
|
3326
2895
|
}
|
|
3327
2896
|
return await untilInterrupted(async (signal) => {
|
|
3328
2897
|
const folder = await mkdtemp(join(tmpdir(), "vitehub-deploy-"));
|
|
@@ -3383,7 +2952,6 @@ async function cloudflareAdapter(context) {
|
|
|
3383
2952
|
});
|
|
3384
2953
|
} };
|
|
3385
2954
|
}
|
|
3386
|
-
/** Version and deployment `source` values: https://developers.cloudflare.com/api/resources/workers/subresources/scripts/subresources/versions/methods/list/ */
|
|
3387
2955
|
/**
|
|
3388
2956
|
* The secrets of the linked Worker. Wrangler 4.158 (`wrangler secret put --help`, `wrangler secret list --help`, in
|
|
3389
2957
|
* test/fixtures/host-cli-help/). `secret put` reads the value from stdin when stdin is not a terminal, and creates a
|
|
@@ -3477,7 +3045,6 @@ function parseDeployments(value) {
|
|
|
3477
3045
|
}];
|
|
3478
3046
|
});
|
|
3479
3047
|
}
|
|
3480
|
-
/** A Workers API request that answers undefined on any error, for data that only adds to a listing. */
|
|
3481
3048
|
async function optional(request) {
|
|
3482
3049
|
try {
|
|
3483
3050
|
return await request;
|
|
@@ -3572,7 +3139,6 @@ const listCloudflareDeployments = async (context, { limit, includeLive }) => {
|
|
|
3572
3139
|
};
|
|
3573
3140
|
//#endregion
|
|
3574
3141
|
//#region src/setup/deploy/deno.ts
|
|
3575
|
-
/** The first line of the `deploy.mjs` that ViteHub's Deno build writes (`packages/internal/src/build/deno-runtime-packages.ts`). */
|
|
3576
3142
|
const runnerFirstLine = "import { spawn } from \"node:child_process\"";
|
|
3577
3143
|
async function denoAdapter(context, organization) {
|
|
3578
3144
|
const runner = join(context.outputDir, "deploy.mjs");
|
|
@@ -3608,10 +3174,6 @@ function denoOrganization(link, env) {
|
|
|
3608
3174
|
if (!organization) throw setupFailure(cliErrorDiagnostics.SETUP_DEPLOY_ORG_REQUIRED(), setupExitCodes.inputNeeded, { missing: [{ field: "DENO_DEPLOY_ORG" }] });
|
|
3609
3175
|
return organization;
|
|
3610
3176
|
}
|
|
3611
|
-
/**
|
|
3612
|
-
* One `KEY='value'` line for `deno deploy env load`, which parses the file with `@std/dotenv`. A single-quoted value
|
|
3613
|
-
* is taken as it is. A value with a quote or a line break has no safe dotenv form, so it is refused.
|
|
3614
|
-
*/
|
|
3615
3177
|
function dotenvLine(name, value) {
|
|
3616
3178
|
if (/['\r\n]/u.test(value)) throw setupFailure(cliErrorDiagnostics.SETUP_ENV_VALUE_UNSUPPORTED({
|
|
3617
3179
|
host: "deno",
|
|
@@ -3789,7 +3351,6 @@ function abortReason(signal, message) {
|
|
|
3789
3351
|
}
|
|
3790
3352
|
//#endregion
|
|
3791
3353
|
//#region src/setup/deploy/netlify.ts
|
|
3792
|
-
/** Nitro's Netlify preset writes static files to `dist` (`output.publicDir`). */
|
|
3793
3354
|
const publishDir = "dist";
|
|
3794
3355
|
function netlifyAdapter(context) {
|
|
3795
3356
|
const netlify = hostCli("netlify", "netlify-cli", context.root, context.env);
|
|
@@ -3807,7 +3368,6 @@ function netlifyAdapter(context) {
|
|
|
3807
3368
|
"--json",
|
|
3808
3369
|
...context.preview ? ["--context", "deploy-preview"] : ["--prod"]
|
|
3809
3370
|
];
|
|
3810
|
-
if (existsSync(join(context.outputDir, "functions", "server.mjs"))) args.push("--functions", join(context.outputDir, "functions"));
|
|
3811
3371
|
args.push(...site ? ["--site", site.id] : ["--site-name", context.projectName]);
|
|
3812
3372
|
if (context.commit) args.push("--message", commitMessage(context.commit));
|
|
3813
3373
|
const result = await context.run(netlify[0], [...netlify.slice(1), ...args], {
|
|
@@ -3834,12 +3394,10 @@ function netlifyAdapter(context) {
|
|
|
3834
3394
|
};
|
|
3835
3395
|
} };
|
|
3836
3396
|
}
|
|
3837
|
-
/** The Netlify deploy context of a host env target. */
|
|
3838
3397
|
const netlifyContexts = {
|
|
3839
3398
|
preview: "deploy-preview",
|
|
3840
3399
|
production: "production"
|
|
3841
3400
|
};
|
|
3842
|
-
/** The contexts that one `all` value stands for, as the Netlify UI lists them for "different value for each context". */
|
|
3843
3401
|
const allContexts = [
|
|
3844
3402
|
"production",
|
|
3845
3403
|
"deploy-preview",
|
|
@@ -3860,13 +3418,6 @@ function netlifyValues(value) {
|
|
|
3860
3418
|
}
|
|
3861
3419
|
return values;
|
|
3862
3420
|
}
|
|
3863
|
-
/**
|
|
3864
|
-
* The `updateEnvVar` body that gives an existing variable Functions scope and, for a secret, secret storage. Undefined
|
|
3865
|
-
* when the variable already has both, so PATCH can set the one value. PUT replaces every value, so the body keeps the
|
|
3866
|
-
* values of the other contexts. Netlify masks secret values of every context except `dev`, so a secret with values
|
|
3867
|
-
* in other contexts cannot be rewritten without losing them: that is refused before any write.
|
|
3868
|
-
* https://docs.netlify.com/build/environment-variables/secrets-controller/
|
|
3869
|
-
*/
|
|
3870
3421
|
function netlifyUpdate(existing, name, context, value, secret) {
|
|
3871
3422
|
const refuse = (reason) => setupFailure(cliErrorDiagnostics.SETUP_ENV_VALUE_UNSUPPORTED({
|
|
3872
3423
|
host: "netlify",
|
|
@@ -4079,7 +3630,6 @@ async function hasVercelLogin(root, context) {
|
|
|
4079
3630
|
return false;
|
|
4080
3631
|
}
|
|
4081
3632
|
}
|
|
4082
|
-
/** Reads `claimUrl` and `expiresAt` that `vercel deploy --temporary` keeps in `.vercel/anonymous.json`. Its token stays there. */
|
|
4083
3633
|
async function readClaim(root) {
|
|
4084
3634
|
let value;
|
|
4085
3635
|
try {
|
|
@@ -4200,7 +3750,6 @@ const gitSources = /* @__PURE__ */ new Set([
|
|
|
4200
3750
|
"import/repo",
|
|
4201
3751
|
"clone/repo"
|
|
4202
3752
|
]);
|
|
4203
|
-
/** `source` of a deployment: https://vercel.com/docs/rest-api/reference/endpoints/deployments/list-deployments */
|
|
4204
3753
|
function vercelSource(value, commit) {
|
|
4205
3754
|
if (value === "cli") return "cli";
|
|
4206
3755
|
if (typeof value === "string" && gitSources.has(value)) return "git";
|
|
@@ -4214,7 +3763,6 @@ function vercelState(value) {
|
|
|
4214
3763
|
if (value === "BUILDING" || value === "INITIALIZING" || value === "QUEUED" || value === "BLOCKED") return "building";
|
|
4215
3764
|
return "unknown";
|
|
4216
3765
|
}
|
|
4217
|
-
/** `vitehubCommit` and `vitehubDirty` from `vercel deploy --meta`, else the commit of a Git integration build. */
|
|
4218
3766
|
function vercelCommit(meta) {
|
|
4219
3767
|
if (!isRecord(meta)) return;
|
|
4220
3768
|
const marked = optionalString$1(meta.vitehubCommit);
|
|
@@ -4295,7 +3843,6 @@ function optionalString(value) {
|
|
|
4295
3843
|
function invalidResponse(host) {
|
|
4296
3844
|
return cliErrorDiagnostics.CLI_HOST_RESPONSE_INVALID({ host });
|
|
4297
3845
|
}
|
|
4298
|
-
/** The same normalization as the deployment identity of `vitehub({ name })`. */
|
|
4299
3846
|
function normalizeName(value) {
|
|
4300
3847
|
return value?.trim().toLowerCase().replace(/[^a-z0-9]+/gu, "-").replace(/^-|-$/gu, "") || void 0;
|
|
4301
3848
|
}
|
|
@@ -4316,7 +3863,6 @@ function nameRequired() {
|
|
|
4316
3863
|
rerun: "vitehub link --project <name>"
|
|
4317
3864
|
});
|
|
4318
3865
|
}
|
|
4319
|
-
/** `--project`, else the literal `name` of vitehub(), else the package.json name, normalized as the build does. */
|
|
4320
3866
|
async function projectName(project, option) {
|
|
4321
3867
|
if (option?.trim()) return option.trim();
|
|
4322
3868
|
const config = project.config;
|
|
@@ -4355,6 +3901,11 @@ function rerunCommand(host, name, options, extra) {
|
|
|
4355
3901
|
].join(" ");
|
|
4356
3902
|
}
|
|
4357
3903
|
function notFound(host, name, options, account) {
|
|
3904
|
+
if (host === "deno") return setupFailure(cliErrorDiagnostics.SETUP_LINK_PROJECT_NOT_FOUND({
|
|
3905
|
+
account,
|
|
3906
|
+
host,
|
|
3907
|
+
project: name
|
|
3908
|
+
}), setupExitCodes.conflict);
|
|
4358
3909
|
const rerun = rerunCommand(host, name, options, "--create");
|
|
4359
3910
|
return setupFailure(cliErrorDiagnostics.SETUP_LINK_PROJECT_NOT_FOUND({
|
|
4360
3911
|
account,
|
|
@@ -4363,7 +3914,6 @@ function notFound(host, name, options, account) {
|
|
|
4363
3914
|
rerun
|
|
4364
3915
|
}), setupExitCodes.conflict, { rerun });
|
|
4365
3916
|
}
|
|
4366
|
-
/** Returns undefined when the host API answers 404. */
|
|
4367
3917
|
async function unlessNotFound(request) {
|
|
4368
3918
|
try {
|
|
4369
3919
|
return await request;
|
|
@@ -4534,6 +4084,55 @@ async function linkNetlify(name, options, token, fetchImpl) {
|
|
|
4534
4084
|
verified: true
|
|
4535
4085
|
};
|
|
4536
4086
|
}
|
|
4087
|
+
async function linkDeno(name, options, token, root, context) {
|
|
4088
|
+
const linked = {
|
|
4089
|
+
...options.account ? { account: { id: options.account } } : {},
|
|
4090
|
+
created: false,
|
|
4091
|
+
project: { name }
|
|
4092
|
+
};
|
|
4093
|
+
const organization = options.account ?? context.env.DENO_DEPLOY_ORG?.trim();
|
|
4094
|
+
if (!token || !organization) return {
|
|
4095
|
+
...linked,
|
|
4096
|
+
verified: false
|
|
4097
|
+
};
|
|
4098
|
+
const deno = hostCli("deno", "deno", root, context.env);
|
|
4099
|
+
const step = "deno deploy apps get";
|
|
4100
|
+
const secrets = [token];
|
|
4101
|
+
const run = context.runHostCli ?? createDeployRun(context.stderr, secrets);
|
|
4102
|
+
const runOptions = {
|
|
4103
|
+
cwd: root,
|
|
4104
|
+
env: context.env,
|
|
4105
|
+
timeoutMs: 3e4
|
|
4106
|
+
};
|
|
4107
|
+
const result = await run(deno[0], [
|
|
4108
|
+
...deno.slice(1),
|
|
4109
|
+
"deploy",
|
|
4110
|
+
"apps",
|
|
4111
|
+
"get",
|
|
4112
|
+
"--json",
|
|
4113
|
+
"--non-interactive",
|
|
4114
|
+
"--org",
|
|
4115
|
+
organization,
|
|
4116
|
+
"--app",
|
|
4117
|
+
name
|
|
4118
|
+
], runOptions).catch((error) => {
|
|
4119
|
+
throw hostCliFailed(step, {
|
|
4120
|
+
exitCode: null,
|
|
4121
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
4122
|
+
stdout: ""
|
|
4123
|
+
}, secrets);
|
|
4124
|
+
});
|
|
4125
|
+
if (result.exitCode === 4) throw notFound("deno", name, options, organization);
|
|
4126
|
+
if (result.exitCode !== 0) throw hostCliFailed(step, {
|
|
4127
|
+
...result,
|
|
4128
|
+
stderr: result.stderr ?? ""
|
|
4129
|
+
}, secrets);
|
|
4130
|
+
return {
|
|
4131
|
+
...linked,
|
|
4132
|
+
account: { id: organization },
|
|
4133
|
+
verified: true
|
|
4134
|
+
};
|
|
4135
|
+
}
|
|
4537
4136
|
/** `content` of a `.gitignore` with a `.vitehub` line, or undefined when it already ignores `.vitehub`. */
|
|
4538
4137
|
function gitignoreWithViteHub(content) {
|
|
4539
4138
|
if (content.split(/\r?\n/u).some((line) => /^\/?(?:\*\*\/)?\.vitehub\/?$/u.test(line.trim()))) return;
|
|
@@ -4560,12 +4159,7 @@ async function linkSetupProject(project, options, context) {
|
|
|
4560
4159
|
const credentials = await resolveHostCredentials(host, credentialsContext);
|
|
4561
4160
|
const fetchImpl = context.fetch ?? globalThis.fetch;
|
|
4562
4161
|
let linked;
|
|
4563
|
-
if (host === "deno") linked =
|
|
4564
|
-
...options.account ? { account: { id: options.account } } : {},
|
|
4565
|
-
created: false,
|
|
4566
|
-
project: { name },
|
|
4567
|
-
verified: false
|
|
4568
|
-
};
|
|
4162
|
+
if (host === "deno") linked = await linkDeno(name, options, credentials.ok ? credentials.token : void 0, project.root, context);
|
|
4569
4163
|
else if (!credentials.ok) throw setupFailure(cliErrorDiagnostics.SETUP_LINK_CREDENTIALS_MISSING({
|
|
4570
4164
|
fix: credentials.fix,
|
|
4571
4165
|
host
|
|
@@ -4807,7 +4401,6 @@ async function readSetupLinkStatus(project, host, context) {
|
|
|
4807
4401
|
}
|
|
4808
4402
|
//#endregion
|
|
4809
4403
|
//#region src/setup/env-encrypted.ts
|
|
4810
|
-
/** dotenvx marks an encrypted value with this prefix. */
|
|
4811
4404
|
const prefix = "encrypted:";
|
|
4812
4405
|
/** The file where dotenvx writes private keys. It must never be in git. */
|
|
4813
4406
|
const envKeysFile = ".env.keys";
|
|
@@ -4954,7 +4547,6 @@ function concat(...parts) {
|
|
|
4954
4547
|
}
|
|
4955
4548
|
return out;
|
|
4956
4549
|
}
|
|
4957
|
-
/** "expand 32-byte k" as little-endian words. */
|
|
4958
4550
|
const sigma = new Uint32Array([
|
|
4959
4551
|
1634760805,
|
|
4960
4552
|
857760878,
|
|
@@ -4971,7 +4563,6 @@ function wordBytes(input) {
|
|
|
4971
4563
|
input.forEach((word, index) => view.setUint32(index * 4, word, true));
|
|
4972
4564
|
return out;
|
|
4973
4565
|
}
|
|
4974
|
-
/** `crypto_box_beforenm`: HSalsa20 of the X25519 shared secret with a zero input. */
|
|
4975
4566
|
function boxKey(shared) {
|
|
4976
4567
|
const out = /* @__PURE__ */ new Uint32Array(8);
|
|
4977
4568
|
hsalsa(sigma, words(shared), /* @__PURE__ */ new Uint32Array(4), out);
|
|
@@ -5060,9 +4651,7 @@ var env_exports = /* @__PURE__ */ __exportAll({
|
|
|
5060
4651
|
readLocalEnvValues: () => readLocalEnvValues,
|
|
5061
4652
|
runEnvCommand: () => runEnvCommand
|
|
5062
4653
|
});
|
|
5063
|
-
/** The stage that a deploy without `--preview` reads. */
|
|
5064
4654
|
const defaultStage = "production";
|
|
5065
|
-
/** The host CLI tokens. They are never values to push, and no output may show them. */
|
|
5066
4655
|
const tokenNames = [
|
|
5067
4656
|
"CLOUDFLARE_API_TOKEN",
|
|
5068
4657
|
"VERCEL_TOKEN",
|
|
@@ -5075,7 +4664,6 @@ const hostEnvs = {
|
|
|
5075
4664
|
netlify: netlifyEnv,
|
|
5076
4665
|
vercel: vercelEnv
|
|
5077
4666
|
};
|
|
5078
|
-
/** Hosts without a preview environment: a Worker has one set of secrets, and ViteHub deploys Deno to production only. */
|
|
5079
4667
|
const noPreview = /* @__PURE__ */ new Set(["cloudflare", "deno"]);
|
|
5080
4668
|
function readEnvArgs(args, push, usage) {
|
|
5081
4669
|
try {
|
|
@@ -5152,7 +4740,6 @@ function linkedTarget(links, host, command) {
|
|
|
5152
4740
|
});
|
|
5153
4741
|
return selected.link;
|
|
5154
4742
|
}
|
|
5155
|
-
/** The names and the env folder of the last build for `host`. Builds first when there is no build output for `host`. */
|
|
5156
4743
|
async function readNames(project, host, context) {
|
|
5157
4744
|
try {
|
|
5158
4745
|
return await readBuildOutput(project.root, host);
|
|
@@ -5164,7 +4751,6 @@ async function readNames(project, host, context) {
|
|
|
5164
4751
|
await build(project, host, context);
|
|
5165
4752
|
return await readBuildOutput(project.root, host);
|
|
5166
4753
|
}
|
|
5167
|
-
/** Plain vars set by the build rather than uploaded as secrets. */
|
|
5168
4754
|
async function configVarNames(host, outputDir) {
|
|
5169
4755
|
return new Set(host === "cloudflare" ? await wranglerVarNames(outputDir) : []);
|
|
5170
4756
|
}
|
|
@@ -5206,10 +4792,6 @@ async function openTarget(args, command, context) {
|
|
|
5206
4792
|
target
|
|
5207
4793
|
};
|
|
5208
4794
|
}
|
|
5209
|
-
/**
|
|
5210
|
-
* GitHub is a destination, not a host: the names come from the build of the linked host (or `--host`), and the stage
|
|
5211
|
-
* only picks the local `.env.<stage>` file. Names that GitHub reserves (`GITHUB_*`) drop out of each entry.
|
|
5212
|
-
*/
|
|
5213
4795
|
async function openGitHubTarget(args, options, project, command, context) {
|
|
5214
4796
|
const selected = selectSetupLink(await readSetupLinks(project.root), args.host);
|
|
5215
4797
|
if ("ambiguous" in selected) throw hostRequired(selected.ambiguous, `${command} --to github`);
|
|
@@ -5280,7 +4862,6 @@ function isRequired(entry) {
|
|
|
5280
4862
|
function matchesPrefix(entry, name) {
|
|
5281
4863
|
return !!entry.prefix && name.startsWith(entry.prefix) && name.length > entry.prefix.length;
|
|
5282
4864
|
}
|
|
5283
|
-
/** True when one of `names` sets the entry: one of its names, or a name with its prefix. */
|
|
5284
4865
|
function isSet(entry, names) {
|
|
5285
4866
|
return entry.names.some((name) => names.has(name)) || [...names].some((name) => matchesPrefix(entry, name));
|
|
5286
4867
|
}
|
|
@@ -5320,7 +4901,6 @@ function targetLabel(output) {
|
|
|
5320
4901
|
if (output.github) return `the GitHub Actions secrets of ${output.github.repository}${output.github.environment ? `, environment ${output.github.environment}` : ""}, stage ${output.stage}`;
|
|
5321
4902
|
return `${output.project} on ${output.host}, stage ${output.stage}${output.target === output.stage ? "" : ` (${output.target})`}`;
|
|
5322
4903
|
}
|
|
5323
|
-
/** The flags that name the destination again, for a hint or a rerun. */
|
|
5324
4904
|
function destinationFlags(output) {
|
|
5325
4905
|
return [...output.github ? [
|
|
5326
4906
|
"--to github",
|
|
@@ -5363,12 +4943,10 @@ function destination(target) {
|
|
|
5363
4943
|
...target.github ? { github: target.github } : {}
|
|
5364
4944
|
};
|
|
5365
4945
|
}
|
|
5366
|
-
/** An env file as output names it: relative to the project root, such as `config/.env.production`. */
|
|
5367
4946
|
function fileSource(root, path) {
|
|
5368
4947
|
const folder = relative(root, dirname(path));
|
|
5369
4948
|
return `${folder ? `${folder}/` : ""}.env${basename(path).slice(4)}`;
|
|
5370
4949
|
}
|
|
5371
|
-
/** Trace the same replacements and iteration order as Vite's patched dotenv-expand. */
|
|
5372
4950
|
function expandedFiles(raw, env) {
|
|
5373
4951
|
const parsed = Object.fromEntries([...raw].map(([name, file]) => [name, file.value]));
|
|
5374
4952
|
const files = new Map([...raw].map(([name, file]) => [name, /* @__PURE__ */ new Set([file.path])]));
|
|
@@ -5456,11 +5034,6 @@ async function readLocalEnvValues(root, envDir, stage, env) {
|
|
|
5456
5034
|
}
|
|
5457
5035
|
return values;
|
|
5458
5036
|
}
|
|
5459
|
-
/**
|
|
5460
|
-
* The value of each entry: the first name in read order that has a local value, and every local name of a prefix.
|
|
5461
|
-
* `onHost` keeps what the host has: an entry with one of its names on the host keeps that alias, and a prefix entry
|
|
5462
|
-
* skips only the members that the host has.
|
|
5463
|
-
*/
|
|
5464
5037
|
function planPush(entries, values, only, onHost = /* @__PURE__ */ new Set()) {
|
|
5465
5038
|
const wanted = only.length ? new Set(only) : void 0;
|
|
5466
5039
|
const unknown = only.filter((name) => !entries.some((entry) => entry.names.includes(name) || matchesPrefix(entry, name)));
|
|
@@ -5499,11 +5072,6 @@ function planPush(entries, values, only, onHost = /* @__PURE__ */ new Set()) {
|
|
|
5499
5072
|
skipped
|
|
5500
5073
|
};
|
|
5501
5074
|
}
|
|
5502
|
-
/**
|
|
5503
|
-
* True when `directory` or a parent folder looks like a git repository, or `GIT_DIR` names one: a `.git` file, as in a
|
|
5504
|
-
* worktree, or a `.git` folder with `HEAD`. It does not ask git, because git reports a broken repository the same way
|
|
5505
|
-
* as no repository, and a broken one must refuse.
|
|
5506
|
-
*/
|
|
5507
5075
|
function inGitRepository(directory, env) {
|
|
5508
5076
|
if (env.GIT_DIR) return true;
|
|
5509
5077
|
for (let current = directory;; current = dirname(current)) {
|
|
@@ -5512,7 +5080,6 @@ function inGitRepository(directory, env) {
|
|
|
5512
5080
|
if (dirname(current) === current) return false;
|
|
5513
5081
|
}
|
|
5514
5082
|
}
|
|
5515
|
-
/** What git says about one env file, by its real path. Throws when git cannot answer. */
|
|
5516
5083
|
async function gitFileState(file, label, run, env) {
|
|
5517
5084
|
const failed = (reason) => setupFailure(cliErrorDiagnostics.SETUP_ENV_GIT_FAILED({
|
|
5518
5085
|
file: label,
|
|
@@ -5546,12 +5113,6 @@ async function gitFileState(file, label, run, env) {
|
|
|
5546
5113
|
if (ignored.exitCode === 1) return "unignored";
|
|
5547
5114
|
throw failed(ignored.stderr.trim() || `git check-ignore exited with ${ignored.exitCode}`);
|
|
5548
5115
|
}
|
|
5549
|
-
/**
|
|
5550
|
-
* Refuses a secret whose value reads an env file that git tracks, or that git does not ignore: pushing it would hide
|
|
5551
|
-
* that the secret is in git, or that the next commit can add it. It checks every file that the value reads, through
|
|
5552
|
-
* `$NAME` expansion too, by its real path, so a symlink to a tracked file does not pass. When git cannot answer inside a
|
|
5553
|
-
* repository, it refuses. A file outside any git repository passes with a warning, since git cannot commit it.
|
|
5554
|
-
*/
|
|
5555
5116
|
async function assertUntracked(planned, root, run, env, stderr) {
|
|
5556
5117
|
const byFile = /* @__PURE__ */ new Map();
|
|
5557
5118
|
for (const item of planned) {
|
|
@@ -5582,7 +5143,6 @@ async function assertUntracked(planned, root, run, env, stderr) {
|
|
|
5582
5143
|
const realKeys = await realpath(keysPath).catch(() => void 0);
|
|
5583
5144
|
if (planned.some((item) => item.encrypted) && realKeys && inGitRepository(dirname(realKeys), env) && await gitFileState(realKeys, ".env.keys", run, env) === "tracked") throw setupFailure(cliErrorDiagnostics.SETUP_ENV_KEYS_TRACKED({ file: envKeysFile }), setupExitCodes.conflict);
|
|
5584
5145
|
}
|
|
5585
|
-
/** Replaces each encrypted value with its plaintext. The private keys and the plaintext join the values that output redacts. */
|
|
5586
5146
|
async function decryptPlanned(planned, root, env, secrets) {
|
|
5587
5147
|
const { keys, values } = await decryptEnvValues(root, planned.filter((item) => item.encrypted).map((item) => ({
|
|
5588
5148
|
file: item.source,
|
|
@@ -5627,7 +5187,6 @@ function pushRerun(args) {
|
|
|
5627
5187
|
...args.json ? ["--json"] : []
|
|
5628
5188
|
].join(" ");
|
|
5629
5189
|
}
|
|
5630
|
-
/** Short plain values, such as "1", would hide host output that has nothing to do with them. */
|
|
5631
5190
|
function addRedactions(planned, secrets) {
|
|
5632
5191
|
for (const item of planned) if (item.secret || item.value.length >= 4) secrets.push(item.value);
|
|
5633
5192
|
}
|
|
@@ -5676,7 +5235,6 @@ async function runPush(args, context) {
|
|
|
5676
5235
|
else writePush(output, context);
|
|
5677
5236
|
return setupExitCodes.done;
|
|
5678
5237
|
}
|
|
5679
|
-
/** The name that ViteHub derives its own keys from. A deploy can generate it, because no one else has to know it. */
|
|
5680
5238
|
const appSecretName = "VITEHUB_SECRET";
|
|
5681
5239
|
async function confirmGenerate(label) {
|
|
5682
5240
|
const terminal = createInterface({
|
|
@@ -5781,7 +5339,7 @@ async function checkDeployEnv(options) {
|
|
|
5781
5339
|
if (stored.length && !hostEnv && host !== "cloudflare") throw setupFailure(cliErrorDiagnostics.SETUP_DEPLOY_ENV_NOT_LINKED({
|
|
5782
5340
|
host,
|
|
5783
5341
|
names: stored.map((item) => item.name).join(", ")
|
|
5784
|
-
}), setupExitCodes.inputNeeded, { rerun: `vitehub link --host ${host} --create` });
|
|
5342
|
+
}), setupExitCodes.inputNeeded, { rerun: host === "deno" ? "vitehub link --host deno" : `vitehub link --host ${host} --create` });
|
|
5785
5343
|
await assertUntracked(stored, options.root, options.run, context.env, context.stderr);
|
|
5786
5344
|
const planned = await decryptPlanned(stored, options.root, context.env, options.secrets);
|
|
5787
5345
|
output.missing = missing.map(diffEntry);
|
|
@@ -5817,4 +5375,4 @@ async function runEnvCommand(feature, args, context) {
|
|
|
5817
5375
|
}
|
|
5818
5376
|
}
|
|
5819
5377
|
//#endregion
|
|
5820
|
-
export { readDeployCommit as A,
|
|
5378
|
+
export { readDeployCommit as A, listMatchingFiles as B, denoOrganization as C, build as D, listCloudflareDeployments as E, setupStatus as F, insertViteHubConfig as G, readSetupProject as H, shellQuote as I, locateViteHubConfig as K, uninstallArgs as L, installArgs as M, installCommand as N, readBuildOutput as O, missingProviderOption as P, hostFromNitroPreset as R, denoAdapter as S, cloudflareAdapter as T, setupLockfiles as U, detectPackageManager as V, editViteHubConfig as W, 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, formatInstallCommand as j, createDeployRun as k, readLinkHostOption as l, unlinkSetupProject as m, env_exports as n, gitignoreWithViteHub as o, selectSetupLink as p, 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, hasDefinitionFiles as z };
|