veryfront 0.1.486 → 0.1.487
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/esm/deno.js +1 -1
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/mod.d.ts +164 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/mod.js +212 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/parse.d.ts +19 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/parse.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/parse.js +69 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/stringify.d.ts +17 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/stringify.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/stringify.js +45 -0
- package/esm/src/agent/hosted-agent-service-env-files.d.ts +10 -0
- package/esm/src/agent/hosted-agent-service-env-files.d.ts.map +1 -0
- package/esm/src/agent/hosted-agent-service-env-files.js +33 -0
- package/esm/src/agent/index.d.ts +1 -0
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +1 -0
- package/esm/src/platform/compat/std/dotenv.d.ts +18 -0
- package/esm/src/platform/compat/std/dotenv.d.ts.map +1 -0
- package/esm/src/platform/compat/std/dotenv.js +70 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/deps/jsr.io/@std/dotenv/0.225.6/mod.ts +251 -0
- package/src/deps/jsr.io/@std/dotenv/0.225.6/parse.ts +110 -0
- package/src/deps/jsr.io/@std/dotenv/0.225.6/stringify.ts +48 -0
- package/src/src/agent/hosted-agent-service-env-files.ts +55 -0
- package/src/src/agent/index.ts +5 -0
- package/src/src/platform/compat/std/dotenv.ts +87 -0
- package/src/src/utils/version-constant.ts +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { cwd as getCwd, env as getProcessEnv, setEnv } from "../platform/compat/process.js";
|
|
2
|
+
import { load as loadDotenv } from "../platform/compat/std/dotenv.js";
|
|
3
|
+
|
|
4
|
+
const DEFAULT_HOSTED_AGENT_SERVICE_ENV_FILES = [".env", ".env.local"] as const;
|
|
5
|
+
|
|
6
|
+
export type HostedAgentServiceEnvFileLoadResult = {
|
|
7
|
+
loadedFiles: string[];
|
|
8
|
+
loadedVariables: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type HostedAgentServiceEnvFileLoadOptions = {
|
|
12
|
+
cwd?: string;
|
|
13
|
+
files?: readonly string[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function joinEnvPath(cwd: string, file: string): string {
|
|
17
|
+
if (file.startsWith("/") || file.startsWith("./") || file.startsWith("../")) {
|
|
18
|
+
return file;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return `${cwd.replace(/\/$/, "")}/${file}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function loadHostedAgentServiceEnvFiles(
|
|
25
|
+
options: HostedAgentServiceEnvFileLoadOptions = {},
|
|
26
|
+
): Promise<HostedAgentServiceEnvFileLoadResult> {
|
|
27
|
+
const cwd = options.cwd ?? getCwd();
|
|
28
|
+
const files = options.files ?? DEFAULT_HOSTED_AGENT_SERVICE_ENV_FILES;
|
|
29
|
+
const protectedKeys = new Set(Object.keys(getProcessEnv()));
|
|
30
|
+
const loadedFiles: string[] = [];
|
|
31
|
+
let loadedVariables = 0;
|
|
32
|
+
|
|
33
|
+
for (const file of files) {
|
|
34
|
+
const envPath = joinEnvPath(cwd, file);
|
|
35
|
+
const parsed = await loadDotenv({ envPath, allowEmptyValues: true });
|
|
36
|
+
const entries = Object.entries(parsed);
|
|
37
|
+
|
|
38
|
+
if (entries.length === 0) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
loadedFiles.push(envPath);
|
|
43
|
+
|
|
44
|
+
for (const [key, value] of entries) {
|
|
45
|
+
if (protectedKeys.has(key)) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setEnv(key, value);
|
|
50
|
+
loadedVariables++;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { loadedFiles, loadedVariables };
|
|
55
|
+
}
|
package/src/src/agent/index.ts
CHANGED
|
@@ -279,6 +279,11 @@ export {
|
|
|
279
279
|
hostedAgentServiceConfigSchema,
|
|
280
280
|
parseHostedAgentServiceConfig,
|
|
281
281
|
} from "./hosted-agent-service-config.js";
|
|
282
|
+
export {
|
|
283
|
+
type HostedAgentServiceEnvFileLoadOptions,
|
|
284
|
+
type HostedAgentServiceEnvFileLoadResult,
|
|
285
|
+
loadHostedAgentServiceEnvFiles,
|
|
286
|
+
} from "./hosted-agent-service-env-files.js";
|
|
282
287
|
export {
|
|
283
288
|
type AgentServiceBootstrapExit,
|
|
284
289
|
type AgentServiceTraceContext,
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable @std/dotenv shim for Node.js and Bun.
|
|
3
|
+
*
|
|
4
|
+
* In Deno: Uses @std/dotenv
|
|
5
|
+
* In Node.js/Bun: Provides a minimal .env file loader
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { isDeno } from "../runtime.js";
|
|
11
|
+
|
|
12
|
+
interface LoadOptions {
|
|
13
|
+
envPath?: string;
|
|
14
|
+
export?: boolean;
|
|
15
|
+
examplePath?: string | null;
|
|
16
|
+
allowEmptyValues?: boolean;
|
|
17
|
+
defaultsPath?: string | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function parseEnvFile(content: string, allowEmptyValues: boolean): Record<string, string> {
|
|
21
|
+
const result: Record<string, string> = {};
|
|
22
|
+
|
|
23
|
+
for (const line of content.split("\n")) {
|
|
24
|
+
const trimmed = line.trim();
|
|
25
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
26
|
+
|
|
27
|
+
const eqIndex = trimmed.indexOf("=");
|
|
28
|
+
if (eqIndex === -1) continue;
|
|
29
|
+
|
|
30
|
+
const key = trimmed.slice(0, eqIndex).trim();
|
|
31
|
+
if (!key) continue;
|
|
32
|
+
|
|
33
|
+
let value = trimmed.slice(eqIndex + 1).trim();
|
|
34
|
+
if (!value && !allowEmptyValues) continue;
|
|
35
|
+
|
|
36
|
+
const firstChar = value[0];
|
|
37
|
+
if ((firstChar === `"` || firstChar === `'`) && value.endsWith(firstChar)) {
|
|
38
|
+
value = value.slice(1, -1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (value.includes("\\")) {
|
|
42
|
+
value = value
|
|
43
|
+
.replace(/\\n/g, "\n")
|
|
44
|
+
.replace(/\\r/g, "\r")
|
|
45
|
+
.replace(/\\t/g, "\t")
|
|
46
|
+
.replace(/\\\\/g, "\\");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
result[key] = value;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function nodeLoad(options: LoadOptions = {}): Promise<Record<string, string>> {
|
|
56
|
+
const { readFile } = await import("node:fs/promises");
|
|
57
|
+
const { resolve: pathResolve, join } = await import("node:path");
|
|
58
|
+
const { cwd } = await import("node:process");
|
|
59
|
+
|
|
60
|
+
const envPath = options.envPath ?? join(cwd(), ".env");
|
|
61
|
+
const shouldExport = options.export ?? false;
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const content = await readFile(pathResolve(envPath), "utf-8");
|
|
65
|
+
const parsed = parseEnvFile(content, options.allowEmptyValues ?? false);
|
|
66
|
+
|
|
67
|
+
if (shouldExport) {
|
|
68
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
69
|
+
if (process.env[key] === undefined) process.env[key] = value;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return parsed;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return {};
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export let load: (options?: LoadOptions) => Promise<Record<string, string>>;
|
|
81
|
+
|
|
82
|
+
if (isDeno) {
|
|
83
|
+
const stdDotenv = await import("../../../../deps/jsr.io/@std/dotenv/0.225.6/mod.js");
|
|
84
|
+
load = stdDotenv.load;
|
|
85
|
+
} else {
|
|
86
|
+
load = nodeLoad;
|
|
87
|
+
}
|