@vite-hub/env 0.5.0 → 0.6.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 +1 -1
- package/dist/{access-C5sPO6C2.js → access-DIErLk3w.js} +2 -3
- package/dist/{bridge-Cs9YfQWk.d.ts → bridge-BWwIooe0.d.ts} +0 -12
- package/dist/{bridge-error-t9bc6xvE.js → bridge-error-DEqzARPJ.js} +1 -2
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +6 -9
- package/dist/{cli-DJtQF4Wi.d.ts → cli-B-LW6l_J.d.ts} +0 -6
- package/dist/{cli-BctSFldY.js → cli-BXzUIcnA.js} +19 -25
- package/dist/cli.d.ts +3 -6
- package/dist/cli.js +1 -2
- package/dist/database.d.ts +2 -4
- package/dist/database.js +2 -3
- package/dist/{declarations-BEL0yvEY.d.ts → declarations-DNjO52_s.d.ts} +1 -3
- package/dist/{schema-CnCp0Muw.js → declarations-meg4Rmgd.js} +6 -71
- package/dist/{object-DICxAEoH.js → error-diagnostics-5BceFRdD.js} +52 -13
- package/dist/{error-diagnostics-CwQGNVnK.js → error-diagnostics-BFzFaXcH.js} +1 -2
- package/dist/index.d.ts +3 -13
- package/dist/index.js +8 -12
- package/dist/internal/agent.d.ts +2 -4
- package/dist/internal/agent.js +3 -4
- package/dist/internal/connections.d.ts +2 -4
- package/dist/internal/connections.js +3 -4
- package/dist/internal/server.d.ts +2 -2
- package/dist/internal/server.js +1 -2
- package/dist/{operation-definition-CI2PJGqu.d.ts → operation-definition-CqZkx1Rm.d.ts} +0 -4
- package/dist/{operations-LVaCzpR0.js → operations-BftegDMd.js} +2 -3
- package/dist/operations.d.ts +2 -6
- package/dist/operations.js +6 -721
- package/dist/runtime/public-env.d.ts +2 -4
- package/dist/runtime/public-env.js +2 -3
- package/dist/runtime/server-env.d.ts +2 -3
- package/dist/runtime/server-env.js +2 -3
- package/dist/seal.d.ts +1 -3
- package/dist/seal.js +1 -2
- package/dist/{secret-DJd-fy5T.js → secret-VhbE53Vm.js} +1 -2
- package/dist/{server-OvARy_y9.d.ts → server-CPEywepM.d.ts} +1 -11
- package/dist/{server-Ct3uvhf9.js → server-pTqnkM7n.js} +209 -152
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -2
- package/dist/vite.d.ts +4 -16
- package/dist/vite.js +20 -21
- package/package.json +12 -10
package/dist/vite.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as OperationContributionEntry } from "./operation-definition-
|
|
1
|
+
import { t as env } from "./declarations-DNjO52_s.js";
|
|
2
|
+
import { A as EnvRuntimeRegistry, b as EnvDeclarations, k as EnvRuntimeConfigOptions, w as EnvOptions } from "./bridge-BWwIooe0.js";
|
|
3
|
+
import { n as ViteHubCliContributor } from "./cli-B-LW6l_J.js";
|
|
4
|
+
import { n as OperationContributionEntry } from "./operation-definition-CqZkx1Rm.js";
|
|
5
5
|
import { Plugin, UserConfig } from "vite";
|
|
6
|
-
//#region ../internal/src/deployment.d.ts
|
|
7
6
|
/** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
|
|
8
7
|
type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region ../internal/src/build/deployment-plan-output.d.ts
|
|
11
8
|
/**
|
|
12
9
|
* One set of host variables that the deployed app reads, as `deployment.json` lists it: a Server Env declaration, or
|
|
13
10
|
* a variable that a primitive reads itself, such as `VITEHUB_SECRET` or `BLOB_READ_WRITE_TOKEN`.
|
|
@@ -37,12 +34,8 @@ interface DeploymentEnvContext {
|
|
|
37
34
|
* Return names only, never values.
|
|
38
35
|
*/
|
|
39
36
|
type DeploymentEnvContribution = (context: DeploymentEnvContext) => readonly DeploymentEnvEntry[];
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region ../internal/src/build/vite.d.ts
|
|
42
37
|
declare const VITEHUB_ENV_PUBLIC_ID: "#vitehub/env/public";
|
|
43
38
|
declare const VITEHUB_ENV_SERVER_ID: "#vitehub/env/server";
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/core/resolve.d.ts
|
|
46
39
|
interface RuntimeRegistryOptions {
|
|
47
40
|
path?: string;
|
|
48
41
|
prefix?: string | false;
|
|
@@ -50,8 +43,6 @@ interface RuntimeRegistryOptions {
|
|
|
50
43
|
schemaModules?: boolean;
|
|
51
44
|
}
|
|
52
45
|
declare function createRuntimeRegistry(declarations: EnvRuntimeConfigOptions | undefined, options?: RuntimeRegistryOptions): EnvRuntimeRegistry;
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/env-schema/importer.d.ts
|
|
55
46
|
interface EnvSchemaOptions {
|
|
56
47
|
prefix?: string;
|
|
57
48
|
/** Exact schema key to output path. Only Server Env supports nested paths. */
|
|
@@ -59,8 +50,6 @@ interface EnvSchemaOptions {
|
|
|
59
50
|
}
|
|
60
51
|
/** Import a committed env-spec-v1 contract. Reads schema metadata, never developer env files. */
|
|
61
52
|
export declare function envSchema(file: string | URL, options?: EnvSchemaOptions): EnvDeclarations;
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region src/vite.d.ts
|
|
64
53
|
export declare const ENV_VITE_PLUGIN_NAME = "@vite-hub/env/vite";
|
|
65
54
|
export declare const ENV_PUBLIC_ID: typeof VITEHUB_ENV_PUBLIC_ID;
|
|
66
55
|
export declare const ENV_SERVER_ID: typeof VITEHUB_ENV_SERVER_ID;
|
|
@@ -97,5 +86,4 @@ export declare function createEnvTypeScriptPaths(options?: EnvGeneratedPathOptio
|
|
|
97
86
|
*/
|
|
98
87
|
export declare function createEnvTypes(config: EnvDeclarations | undefined, options?: Pick<EnvOptions, "prefix" | "runtimeImports" | "projectRoot">): string;
|
|
99
88
|
export declare function hubEnv(options?: EnvOptions): EnvVitePlugin;
|
|
100
|
-
//#endregion
|
|
101
89
|
export { type EnvSchemaOptions, createRuntimeRegistry as createRuntimeEnvRegistry, env };
|
package/dist/vite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { A as schemaContainsEnum, E as envValueTypeName, F as envSourceFailed, I as invalidEnvDeclaration, L as isAbortError, M as isEnvSchemaValue, N as parseSchema, O as parseEnvValue, R as missingRequiredEnv, S as readViteHubSecret, f as invariant, g as runtimeRegistryEntries, h as isRuntimeProviderEntry, j as stringValueSchema, m as isRuntimeLiteralEntry, p as isRuntimeEnvEntry, r as describeServerEnv } from "./server-pTqnkM7n.js";
|
|
2
|
+
import { a as VITEHUB_ENV_SERVER, c as createViteHubEnvImportAliases, d as viteHubEnvAmbientTypesPath, f as viteHubEnvDescriptionModulePath, g as viteHubEnvServerModuleTypesPath, h as viteHubEnvServerModulePath, i as VITEHUB_ENV_PUBLIC_ID, l as isServerEnvironment, m as viteHubEnvPublicModuleTypesPath, o as VITEHUB_ENV_SERVER_ID, p as viteHubEnvPublicModulePath, r as loadAllEnv, s as createNoExternalAddition, t as createEnvCliContributor, u as resolveViteHubProjectRoot } from "./cli-BXzUIcnA.js";
|
|
3
|
+
import { i as schemaModuleReference, n as env, r as runtimeValueSchema, t as descriptorVariable } from "./declarations-meg4Rmgd.js";
|
|
4
|
+
import { t as envErrorDiagnostics } from "./error-diagnostics-BFzFaXcH.js";
|
|
5
5
|
import { Diagnostic } from "nostics";
|
|
6
6
|
import { isViteHubError } from "@vite-hub/runtime";
|
|
7
7
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -9,11 +9,12 @@ import { dirname, isAbsolute, relative, resolve, win32 } from "node:path";
|
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
import { chmod, mkdir, open, readFile, rename, stat, unlink, writeFile } from "node:fs/promises";
|
|
11
11
|
import { createHash, randomBytes } from "node:crypto";
|
|
12
|
+
import MagicString from "magic-string";
|
|
12
13
|
import { loadEnv } from "vite";
|
|
13
14
|
import { execFile } from "node:child_process";
|
|
14
15
|
import { promisify } from "node:util";
|
|
15
16
|
import { ParsedEnvSpecFunctionCall, ParsedEnvSpecKeyValuePair, ParsedEnvSpecStaticValue, parseEnvSpecDotEnvFile } from "@env-spec/parser";
|
|
16
|
-
|
|
17
|
+
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
17
18
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
18
19
|
function normalizeWindowsPath(input = "") {
|
|
19
20
|
if (!input) return input;
|
|
@@ -97,8 +98,7 @@ const dirname$1 = function(p) {
|
|
|
97
98
|
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
98
99
|
return segments.join("/") || (isAbsolute$1(p) ? "/" : ".");
|
|
99
100
|
};
|
|
100
|
-
|
|
101
|
-
//#region ../internal/src/build/paths.ts
|
|
101
|
+
// ../internal/src/build/paths.ts
|
|
102
102
|
function resolveRuntimeModule(packageDir, modulePath) {
|
|
103
103
|
const distFile = resolve$1(packageDir, "dist", `${modulePath}.js`);
|
|
104
104
|
return existsSync(distFile) ? distFile : resolve$1(packageDir, "src", `${modulePath}.ts`);
|
|
@@ -125,16 +125,14 @@ function findPackageDir(file) {
|
|
|
125
125
|
function ownModule(importMetaUrl, modulePath) {
|
|
126
126
|
return resolveRuntimeModule(findPackageDir(fileURLToPath(importMetaUrl)), modulePath);
|
|
127
127
|
}
|
|
128
|
-
|
|
129
|
-
//#region ../internal/src/definition-catalog.ts
|
|
128
|
+
// ../internal/src/definition-catalog.ts
|
|
130
129
|
/** `writeFileIfChangedSync` for async callers. */
|
|
131
130
|
async function writeFileIfChanged(file, contents) {
|
|
132
131
|
if (await readFile(file, "utf8").catch(() => void 0) === contents) return;
|
|
133
132
|
await mkdir(resolve$1(file, ".."), { recursive: true });
|
|
134
133
|
await writeFile(file, contents, "utf8");
|
|
135
134
|
}
|
|
136
|
-
|
|
137
|
-
//#region src/core/diagnostics.ts
|
|
135
|
+
// src/core/diagnostics.ts
|
|
138
136
|
function shouldTraceDiagnostics(option) {
|
|
139
137
|
return option === "trace" || process.env.VITEHUB_ENV_TRACE === "true";
|
|
140
138
|
}
|
|
@@ -152,8 +150,7 @@ function formatDiagnostics(entries, option = "summary") {
|
|
|
152
150
|
entry.masked ? " value: ********" : void 0
|
|
153
151
|
].filter(Boolean))].join("\n");
|
|
154
152
|
}
|
|
155
|
-
|
|
156
|
-
//#region src/core/resolve.ts
|
|
153
|
+
// src/core/resolve.ts
|
|
157
154
|
const execFileAsync = promisify(execFile);
|
|
158
155
|
const envOptionKeys = /* @__PURE__ */ new Set([
|
|
159
156
|
"define",
|
|
@@ -638,8 +635,7 @@ function readPath(value, path) {
|
|
|
638
635
|
return current[segment];
|
|
639
636
|
}, value);
|
|
640
637
|
}
|
|
641
|
-
|
|
642
|
-
//#region src/env-schema/profile.ts
|
|
638
|
+
// src/env-schema/profile.ts
|
|
643
639
|
function fail$1(context, reason) {
|
|
644
640
|
throw envErrorDiagnostics.ENV_B0006({ message: `${context.file}:${context.line}${context.key ? ` (${context.key})` : ""}: ${reason}` });
|
|
645
641
|
}
|
|
@@ -931,8 +927,7 @@ function parseEnvSchema(source, filename) {
|
|
|
931
927
|
return field;
|
|
932
928
|
});
|
|
933
929
|
}
|
|
934
|
-
|
|
935
|
-
//#region src/env-schema/importer.ts
|
|
930
|
+
// src/env-schema/importer.ts
|
|
936
931
|
function fail(field, reason) {
|
|
937
932
|
const path = field ? `${field.source.file}:${field.source.line} (${field.key})` : "envSchema";
|
|
938
933
|
throw invalidEnvDeclaration(path, `${path}: ${reason}`);
|
|
@@ -1052,8 +1047,7 @@ function envSchema(file, options = {}) {
|
|
|
1052
1047
|
server: serverConfig(server)
|
|
1053
1048
|
};
|
|
1054
1049
|
}
|
|
1055
|
-
|
|
1056
|
-
//#region src/vite.ts
|
|
1050
|
+
// src/vite.ts
|
|
1057
1051
|
const ENV_VITE_PLUGIN_NAME = "@vite-hub/env/vite";
|
|
1058
1052
|
const envNoExternal = createNoExternalAddition("@vite-hub/env");
|
|
1059
1053
|
const ENV_PUBLIC_ID = VITEHUB_ENV_PUBLIC_ID;
|
|
@@ -1340,7 +1334,13 @@ function hubEnv(options = {}) {
|
|
|
1340
1334
|
filter: { code: "/* @vitehub-env */" },
|
|
1341
1335
|
handler(code) {
|
|
1342
1336
|
if (!code.includes("/* @vitehub-env */") || !code.includes(ENV_SERVER_ID)) return;
|
|
1343
|
-
|
|
1337
|
+
const output = new MagicString(code);
|
|
1338
|
+
output.replaceAll(/\/\* @vite-ignore \*\/\s*\/\* @vitehub-env \*\/\s*[\w$]+/g, JSON.stringify(ENV_SERVER_ID));
|
|
1339
|
+
if (!output.hasChanged()) return;
|
|
1340
|
+
return {
|
|
1341
|
+
code: output.toString(),
|
|
1342
|
+
map: output.generateMap({ hires: "boundary" })
|
|
1343
|
+
};
|
|
1344
1344
|
}
|
|
1345
1345
|
}
|
|
1346
1346
|
};
|
|
@@ -1755,5 +1755,4 @@ function literalType(value) {
|
|
|
1755
1755
|
default: return "unknown";
|
|
1756
1756
|
}
|
|
1757
1757
|
}
|
|
1758
|
-
//#endregion
|
|
1759
1758
|
export { ENV_PUBLIC_ID, ENV_SERVER_ID, ENV_VITE_PLUGIN_NAME, createEnvImportAliases, createEnvTypeScriptPaths, createEnvTypes, createRuntimeRegistry as createRuntimeEnvRegistry, env, envSchema, hubEnv };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/env",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Safe build and runtime environment variables for ViteHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"env",
|
|
@@ -96,29 +96,31 @@
|
|
|
96
96
|
"./package.json": "./package.json"
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|
|
99
|
-
"@env-spec/parser": "0.6.
|
|
100
|
-
"@
|
|
99
|
+
"@env-spec/parser": "0.6.3",
|
|
100
|
+
"@valibot/to-json-schema": "^1.8.0",
|
|
101
|
+
"@vite-hub/runtime": "0.6.0",
|
|
102
|
+
"magic-string": "^1.4.5",
|
|
101
103
|
"nostics": "1.4.0",
|
|
102
104
|
"valibot": "^1.5.0"
|
|
103
105
|
},
|
|
104
106
|
"devDependencies": {
|
|
105
|
-
"@types/node": "^24.19.
|
|
107
|
+
"@types/node": "^24.19.2",
|
|
106
108
|
"zod": "^4.6.7",
|
|
107
109
|
"@vite-hub/internal": "0.0.1",
|
|
108
110
|
"publint": "^0.3.25",
|
|
109
111
|
"typescript": "^6.0.3",
|
|
110
|
-
"vite": "^8.
|
|
111
|
-
"vite-plus": "^
|
|
112
|
-
"vitest": "
|
|
113
|
-
"drizzle-orm": "1.0.0-rc.
|
|
112
|
+
"vite": "^8.3.8",
|
|
113
|
+
"vite-plus": "^1.7.0",
|
|
114
|
+
"vitest": "5.1.0",
|
|
115
|
+
"drizzle-orm": "1.0.0-rc.6",
|
|
114
116
|
"@libsql/client": "^0.18.0",
|
|
115
117
|
"miniflare": "4.20260730.0",
|
|
116
118
|
"nitro": "^3.0.261103-rc"
|
|
117
119
|
},
|
|
118
120
|
"peerDependencies": {
|
|
119
121
|
"vite": ">=8.0.0",
|
|
120
|
-
"drizzle-orm": "1.0.0-rc.5 || ^1.0.0",
|
|
121
|
-
"@vite-hub/agent": "0.
|
|
122
|
+
"drizzle-orm": "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0",
|
|
123
|
+
"@vite-hub/agent": "0.6.0",
|
|
122
124
|
"nitro": "3.0.261102-rc || ^3.0.261103-rc"
|
|
123
125
|
},
|
|
124
126
|
"peerDependenciesMeta": {
|