vyft 0.4.0-alpha → 0.4.1-alpha
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/LICENSE +191 -21
- package/README.md +3 -49
- package/dist/commands/context/add.d.ts +4 -0
- package/dist/commands/context/add.d.ts.map +1 -0
- package/dist/commands/context/add.js +98 -0
- package/dist/commands/context/add.js.map +1 -0
- package/dist/commands/context/index.d.ts +4 -0
- package/dist/commands/context/index.d.ts.map +1 -0
- package/dist/commands/context/index.js +12 -0
- package/dist/commands/context/index.js.map +1 -0
- package/dist/commands/context/list.d.ts +4 -0
- package/dist/commands/context/list.d.ts.map +1 -0
- package/dist/commands/context/list.js +25 -0
- package/dist/commands/context/list.js.map +1 -0
- package/dist/commands/context/remove.d.ts +4 -0
- package/dist/commands/context/remove.d.ts.map +1 -0
- package/dist/commands/context/remove.js +36 -0
- package/dist/commands/context/remove.js.map +1 -0
- package/dist/commands/context/use.d.ts +4 -0
- package/dist/commands/context/use.d.ts.map +1 -0
- package/dist/commands/context/use.js +32 -0
- package/dist/commands/context/use.js.map +1 -0
- package/dist/commands/deploy.d.ts +4 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +55 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/destroy.d.ts +4 -0
- package/dist/commands/destroy.d.ts.map +1 -0
- package/dist/commands/destroy.js +70 -0
- package/dist/commands/destroy.js.map +1 -0
- package/dist/commands/diff.d.ts +4 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +52 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +92 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/local/detect.d.ts +7 -0
- package/dist/commands/local/detect.d.ts.map +1 -0
- package/dist/commands/local/detect.js +146 -0
- package/dist/commands/local/detect.js.map +1 -0
- package/dist/commands/local/dev.d.ts +4 -0
- package/dist/commands/local/dev.d.ts.map +1 -0
- package/dist/commands/local/dev.js +339 -0
- package/dist/commands/local/dev.js.map +1 -0
- package/dist/commands/local/down.d.ts +4 -0
- package/dist/commands/local/down.d.ts.map +1 -0
- package/dist/commands/local/down.js +61 -0
- package/dist/commands/local/down.js.map +1 -0
- package/dist/commands/local/index.d.ts +4 -0
- package/dist/commands/local/index.d.ts.map +1 -0
- package/dist/commands/local/index.js +12 -0
- package/dist/commands/local/index.js.map +1 -0
- package/dist/commands/local/reset.d.ts +4 -0
- package/dist/commands/local/reset.d.ts.map +1 -0
- package/dist/commands/local/reset.js +67 -0
- package/dist/commands/local/reset.js.map +1 -0
- package/dist/commands/local/up.d.ts +4 -0
- package/dist/commands/local/up.d.ts.map +1 -0
- package/dist/commands/local/up.js +58 -0
- package/dist/commands/local/up.js.map +1 -0
- package/dist/commands/refresh.d.ts +4 -0
- package/dist/commands/refresh.d.ts.map +1 -0
- package/dist/commands/refresh.js +39 -0
- package/dist/commands/refresh.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +69 -0
- package/dist/config.js.map +1 -0
- package/dist/contexts.d.ts +21 -0
- package/dist/contexts.d.ts.map +1 -0
- package/dist/contexts.js +72 -0
- package/dist/contexts.js.map +1 -0
- package/dist/index.d.ts +2 -9
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -7
- package/dist/index.js.map +1 -0
- package/dist/lib.d.ts +7 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +6 -0
- package/dist/lib.js.map +1 -0
- package/dist/providers.d.ts +9 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +41 -0
- package/dist/providers.js.map +1 -0
- package/dist/runtime.d.ts +18 -15
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +154 -0
- package/dist/runtime.js.map +1 -0
- package/dist/runtime.test.d.ts +2 -0
- package/dist/runtime.test.d.ts.map +1 -0
- package/dist/runtime.test.js +119 -0
- package/dist/runtime.test.js.map +1 -0
- package/dist/utils/fs.d.ts +4 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +33 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/pm.d.ts +3 -0
- package/dist/utils/pm.d.ts.map +1 -0
- package/dist/utils/pm.js +17 -0
- package/dist/utils/pm.js.map +1 -0
- package/dist/utils/prompts.d.ts +2 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +6 -0
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/templates.d.ts +3 -0
- package/dist/utils/templates.d.ts.map +1 -0
- package/dist/utils/templates.js +48 -0
- package/dist/utils/templates.js.map +1 -0
- package/package.json +31 -48
- package/templates/bun/index.ts +8 -0
- package/templates/bun/package.json +15 -0
- package/templates/bun/tsconfig.json +15 -0
- package/templates/bun/vyft.config.ts +3 -0
- package/dist/build.d.ts +0 -12
- package/dist/build.js +0 -44
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -842
- package/dist/context.d.ts +0 -39
- package/dist/context.js +0 -101
- package/dist/docker.d.ts +0 -69
- package/dist/docker.js +0 -958
- package/dist/exec.d.ts +0 -2
- package/dist/exec.js +0 -28
- package/dist/init.d.ts +0 -1
- package/dist/init.js +0 -117
- package/dist/interpolate.d.ts +0 -13
- package/dist/interpolate.js +0 -19
- package/dist/local/dev.d.ts +0 -31
- package/dist/local/dev.js +0 -109
- package/dist/local/index.d.ts +0 -2
- package/dist/local/index.js +0 -2
- package/dist/local/runtime.d.ts +0 -61
- package/dist/local/runtime.js +0 -391
- package/dist/logger.d.ts +0 -2
- package/dist/logger.js +0 -10
- package/dist/proxy.d.ts +0 -16
- package/dist/proxy.js +0 -0
- package/dist/resource.d.ts +0 -181
- package/dist/resource.js +0 -45
- package/dist/services/index.d.ts +0 -26
- package/dist/services/index.js +0 -35
- package/dist/services/minio.d.ts +0 -36
- package/dist/services/minio.js +0 -53
- package/dist/services/mongo.d.ts +0 -28
- package/dist/services/mongo.js +0 -45
- package/dist/services/mysql.d.ts +0 -28
- package/dist/services/mysql.js +0 -44
- package/dist/services/nats.d.ts +0 -26
- package/dist/services/nats.js +0 -38
- package/dist/services/postgres.d.ts +0 -28
- package/dist/services/postgres.js +0 -45
- package/dist/services/rabbitmq.d.ts +0 -28
- package/dist/services/rabbitmq.js +0 -44
- package/dist/services/redis.d.ts +0 -28
- package/dist/services/redis.js +0 -49
- package/dist/services/storage.d.ts +0 -39
- package/dist/services/storage.js +0 -94
- package/dist/swarm/factories.d.ts +0 -16
- package/dist/swarm/factories.js +0 -63
- package/dist/swarm/index.d.ts +0 -20
- package/dist/swarm/index.js +0 -5
- package/dist/swarm/proxy.d.ts +0 -24
- package/dist/swarm/proxy.js +0 -339
- package/dist/swarm/types.d.ts +0 -26
- package/dist/swarm/types.js +0 -0
- package/dist/symbols.d.ts +0 -15
- package/dist/symbols.js +0 -4
- package/templates/fullstack/apps/api/Dockerfile +0 -22
- package/templates/fullstack/apps/api/package.json +0 -26
- package/templates/fullstack/apps/api/src/auth.ts +0 -21
- package/templates/fullstack/apps/api/src/db.ts +0 -16
- package/templates/fullstack/apps/api/src/index.ts +0 -17
- package/templates/fullstack/apps/api/src/router.ts +0 -11
- package/templates/fullstack/apps/api/src/schema.ts +0 -11
- package/templates/fullstack/apps/api/tsconfig.json +0 -8
- package/templates/fullstack/apps/web/index.html +0 -12
- package/templates/fullstack/apps/web/package.json +0 -21
- package/templates/fullstack/apps/web/src/app.tsx +0 -8
- package/templates/fullstack/apps/web/src/main.tsx +0 -9
- package/templates/fullstack/apps/web/tsconfig.json +0 -7
- package/templates/fullstack/apps/web/vite.config.ts +0 -14
- package/templates/fullstack/dockerignore +0 -7
- package/templates/fullstack/gitignore +0 -3
- package/templates/fullstack/package.json +0 -14
- package/templates/fullstack/pnpm-workspace.yaml +0 -2
- package/templates/fullstack/tsconfig.json +0 -11
- package/templates/fullstack/vyft.config.ts +0 -22
package/dist/exec.d.ts
DELETED
package/dist/exec.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
export async function exec(command, cwd, env, log, silent) {
|
|
3
|
-
const start = performance.now();
|
|
4
|
-
log?.debug({ command, cwd }, "process spawning");
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
const proc = spawn(command, {
|
|
7
|
-
cwd,
|
|
8
|
-
stdio: silent ? "pipe" : "inherit",
|
|
9
|
-
shell: true,
|
|
10
|
-
env: env ? { ...process.env, ...env } : undefined,
|
|
11
|
-
});
|
|
12
|
-
proc.on("close", (code) => {
|
|
13
|
-
const durationMs = Math.round(performance.now() - start);
|
|
14
|
-
if (code !== 0) {
|
|
15
|
-
log?.debug({ command, cwd, exitCode: code, durationMs }, "process exited with error");
|
|
16
|
-
reject(new Error(`Command failed with exit code ${code}`));
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
log?.debug({ command, cwd, exitCode: 0, durationMs }, "process exited");
|
|
20
|
-
resolve();
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
proc.on("error", (err) => {
|
|
24
|
-
log?.debug({ err, command, cwd }, "process spawn failed");
|
|
25
|
-
reject(err);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
package/dist/init.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function init(directory?: string): Promise<void>;
|
package/dist/init.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { execSync } from "node:child_process";
|
|
2
|
-
import { mkdir, readdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { confirm, intro, isCancel, log, outro, text } from "@clack/prompts";
|
|
6
|
-
const TEMPLATES_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../templates/fullstack");
|
|
7
|
-
async function walkDir(dir) {
|
|
8
|
-
const files = [];
|
|
9
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
10
|
-
for (const entry of entries) {
|
|
11
|
-
const full = path.join(dir, entry.name);
|
|
12
|
-
if (entry.isDirectory()) {
|
|
13
|
-
files.push(...(await walkDir(full)));
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
files.push(full);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return files;
|
|
20
|
-
}
|
|
21
|
-
async function dirExists(dir) {
|
|
22
|
-
try {
|
|
23
|
-
const s = await stat(dir);
|
|
24
|
-
return s.isDirectory();
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async function dirIsNonEmpty(dir) {
|
|
31
|
-
try {
|
|
32
|
-
const entries = await readdir(dir);
|
|
33
|
-
return entries.length > 0;
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export async function init(directory) {
|
|
40
|
-
intro("Create a new project");
|
|
41
|
-
const name = await text({
|
|
42
|
-
message: "Project name",
|
|
43
|
-
placeholder: "my-app",
|
|
44
|
-
defaultValue: directory || "my-app",
|
|
45
|
-
validate(value) {
|
|
46
|
-
if (!value)
|
|
47
|
-
return "Project name is required";
|
|
48
|
-
if (!/^[a-z0-9-]+$/.test(value))
|
|
49
|
-
return "Use lowercase letters, numbers, and hyphens only";
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
if (isCancel(name))
|
|
53
|
-
return;
|
|
54
|
-
const domain = await text({
|
|
55
|
-
message: "Domain",
|
|
56
|
-
placeholder: "example.com",
|
|
57
|
-
validate(value) {
|
|
58
|
-
if (!value)
|
|
59
|
-
return "Domain is required";
|
|
60
|
-
if (!/^[a-z0-9.-]+\.[a-z]{2,}$/.test(value))
|
|
61
|
-
return "Enter a valid domain (e.g. example.com)";
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
if (isCancel(domain))
|
|
65
|
-
return;
|
|
66
|
-
const targetDir = path.resolve(process.cwd(), directory || name);
|
|
67
|
-
if ((await dirExists(targetDir)) && (await dirIsNonEmpty(targetDir))) {
|
|
68
|
-
const ok = await confirm({
|
|
69
|
-
message: `Directory ${path.basename(targetDir)} is not empty. Continue?`,
|
|
70
|
-
});
|
|
71
|
-
if (isCancel(ok) || !ok)
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const templateFiles = await walkDir(TEMPLATES_DIR);
|
|
75
|
-
const replacements = {
|
|
76
|
-
"{{name}}": name,
|
|
77
|
-
"{{domain}}": domain,
|
|
78
|
-
};
|
|
79
|
-
for (const templateFile of templateFiles) {
|
|
80
|
-
let relativePath = path.relative(TEMPLATES_DIR, templateFile);
|
|
81
|
-
if (relativePath === "gitignore")
|
|
82
|
-
relativePath = ".gitignore";
|
|
83
|
-
if (relativePath === "dockerignore")
|
|
84
|
-
relativePath = ".dockerignore";
|
|
85
|
-
const destPath = path.join(targetDir, relativePath);
|
|
86
|
-
await mkdir(path.dirname(destPath), { recursive: true });
|
|
87
|
-
let content = await readFile(templateFile, "utf-8");
|
|
88
|
-
for (const [placeholder, value] of Object.entries(replacements)) {
|
|
89
|
-
content = content.replaceAll(placeholder, value);
|
|
90
|
-
}
|
|
91
|
-
await writeFile(destPath, content);
|
|
92
|
-
log.step(relativePath);
|
|
93
|
-
}
|
|
94
|
-
const ua = process.env.npm_config_user_agent ?? "";
|
|
95
|
-
const pm = ua.startsWith("pnpm")
|
|
96
|
-
? "pnpm"
|
|
97
|
-
: ua.startsWith("bun")
|
|
98
|
-
? "bun"
|
|
99
|
-
: "npm";
|
|
100
|
-
const install = await confirm({
|
|
101
|
-
message: `Install dependencies with ${pm}?`,
|
|
102
|
-
});
|
|
103
|
-
if (isCancel(install))
|
|
104
|
-
return;
|
|
105
|
-
if (install) {
|
|
106
|
-
log.step(`Running ${pm} install...`);
|
|
107
|
-
execSync(`${pm} install`, { cwd: targetDir, stdio: "inherit" });
|
|
108
|
-
}
|
|
109
|
-
outro("Project created");
|
|
110
|
-
console.log();
|
|
111
|
-
console.log("Next steps:");
|
|
112
|
-
console.log(` cd ${path.relative(process.cwd(), targetDir)}`);
|
|
113
|
-
if (!install)
|
|
114
|
-
console.log(` ${pm} install`);
|
|
115
|
-
console.log(` ${pm} dev`);
|
|
116
|
-
console.log();
|
|
117
|
-
}
|
package/dist/interpolate.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Interpolation, Reference } from "./resource.js";
|
|
2
|
-
/**
|
|
3
|
-
* Tagged template literal for building strings that contain {@link Reference} values
|
|
4
|
-
* (e.g. secrets) which are resolved at deploy time.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* const connStr = interpolate`postgres://user:${dbPassword}@${db.host}:5432/app`;
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* @throws If none of the interpolated values are a {@link Reference}.
|
|
12
|
-
*/
|
|
13
|
-
export declare function interpolate(strings: TemplateStringsArray, ...values: Array<Reference | string>): Interpolation;
|
package/dist/interpolate.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { isReference } from "./resource.js";
|
|
2
|
-
/**
|
|
3
|
-
* Tagged template literal for building strings that contain {@link Reference} values
|
|
4
|
-
* (e.g. secrets) which are resolved at deploy time.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* const connStr = interpolate`postgres://user:${dbPassword}@${db.host}:5432/app`;
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* @throws If none of the interpolated values are a {@link Reference}.
|
|
12
|
-
*/
|
|
13
|
-
export function interpolate(strings, ...values) {
|
|
14
|
-
const hasRef = values.some(isReference);
|
|
15
|
-
if (!hasRef) {
|
|
16
|
-
throw new Error("interpolate() requires at least one Reference — use a plain string instead");
|
|
17
|
-
}
|
|
18
|
-
return { type: "interpolation", strings, values };
|
|
19
|
-
}
|
package/dist/local/dev.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { EnvValue, Service } from "../resource.js";
|
|
2
|
-
export interface DevProcess {
|
|
3
|
-
service: Service;
|
|
4
|
-
command: string;
|
|
5
|
-
cwd: string;
|
|
6
|
-
env: Record<string, string>;
|
|
7
|
-
}
|
|
8
|
-
type LogHandler = (service: string, stream: "stdout" | "stderr", text: string) => void;
|
|
9
|
-
/**
|
|
10
|
-
* Manages user service child processes for local development.
|
|
11
|
-
*/
|
|
12
|
-
export declare class DevRunner {
|
|
13
|
-
private processes;
|
|
14
|
-
private onLog;
|
|
15
|
-
constructor(opts?: {
|
|
16
|
-
onLog?: LogHandler;
|
|
17
|
-
});
|
|
18
|
-
start(devProcesses: DevProcess[]): void;
|
|
19
|
-
stop(): void;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Resolve env vars for a dev process.
|
|
23
|
-
*
|
|
24
|
-
* - Secrets → generated plaintext value
|
|
25
|
-
* - Interpolations → fully resolved, with known service hosts remapped to localhost
|
|
26
|
-
* - Plain strings → as-is, with known service hosts remapped to localhost
|
|
27
|
-
*/
|
|
28
|
-
export declare function resolveDevEnv(env: Record<string, EnvValue>, secretValues: Map<string, string>, hostRemap: Map<string, string>): Record<string, string>;
|
|
29
|
-
/** Detect the project's package manager from lock files. */
|
|
30
|
-
export declare function detectPackageManager(projectRoot: string): string;
|
|
31
|
-
export {};
|
package/dist/local/dev.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { isInterpolation, isReference } from "../resource.js";
|
|
5
|
-
/**
|
|
6
|
-
* Manages user service child processes for local development.
|
|
7
|
-
*/
|
|
8
|
-
export class DevRunner {
|
|
9
|
-
processes = [];
|
|
10
|
-
onLog;
|
|
11
|
-
constructor(opts) {
|
|
12
|
-
this.onLog = opts?.onLog;
|
|
13
|
-
}
|
|
14
|
-
start(devProcesses) {
|
|
15
|
-
for (const dp of devProcesses) {
|
|
16
|
-
const child = spawn(dp.command, {
|
|
17
|
-
cwd: dp.cwd,
|
|
18
|
-
env: { ...process.env, ...dp.env },
|
|
19
|
-
shell: true,
|
|
20
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
21
|
-
});
|
|
22
|
-
const name = dp.service.id;
|
|
23
|
-
child.stdout?.on("data", (chunk) => {
|
|
24
|
-
for (const line of chunk.toString().split("\n")) {
|
|
25
|
-
if (line)
|
|
26
|
-
this.onLog?.(name, "stdout", line);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
child.stderr?.on("data", (chunk) => {
|
|
30
|
-
for (const line of chunk.toString().split("\n")) {
|
|
31
|
-
if (line)
|
|
32
|
-
this.onLog?.(name, "stderr", line);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
child.on("exit", (code) => {
|
|
36
|
-
this.onLog?.(name, "stderr", `process exited with code ${code}`);
|
|
37
|
-
});
|
|
38
|
-
this.processes.push(child);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
stop() {
|
|
42
|
-
for (const child of this.processes) {
|
|
43
|
-
child.kill("SIGTERM");
|
|
44
|
-
}
|
|
45
|
-
this.processes = [];
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Resolve env vars for a dev process.
|
|
50
|
-
*
|
|
51
|
-
* - Secrets → generated plaintext value
|
|
52
|
-
* - Interpolations → fully resolved, with known service hosts remapped to localhost
|
|
53
|
-
* - Plain strings → as-is, with known service hosts remapped to localhost
|
|
54
|
-
*/
|
|
55
|
-
export function resolveDevEnv(env, secretValues, hostRemap) {
|
|
56
|
-
const result = {};
|
|
57
|
-
for (const [key, value] of Object.entries(env)) {
|
|
58
|
-
if (typeof value === "string") {
|
|
59
|
-
result[key] = remapHosts(value, hostRemap);
|
|
60
|
-
}
|
|
61
|
-
else if (isReference(value)) {
|
|
62
|
-
const secretValue = secretValues.get(value.id);
|
|
63
|
-
if (!secretValue) {
|
|
64
|
-
throw new Error(`Secret ${value.id} not yet generated`);
|
|
65
|
-
}
|
|
66
|
-
result[key] = secretValue;
|
|
67
|
-
}
|
|
68
|
-
else if (isInterpolation(value)) {
|
|
69
|
-
const parts = [];
|
|
70
|
-
for (let i = 0; i < value.strings.length; i++) {
|
|
71
|
-
parts.push(value.strings[i]);
|
|
72
|
-
if (i < value.values.length) {
|
|
73
|
-
const v = value.values[i];
|
|
74
|
-
if (isReference(v)) {
|
|
75
|
-
const secretValue = secretValues.get(v.id);
|
|
76
|
-
if (!secretValue) {
|
|
77
|
-
throw new Error(`Secret ${v.id} not yet generated`);
|
|
78
|
-
}
|
|
79
|
-
parts.push(secretValue);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
parts.push(remapHosts(v, hostRemap));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
result[key] = parts.join("");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return result;
|
|
90
|
-
}
|
|
91
|
-
function remapHosts(value, hostRemap) {
|
|
92
|
-
let result = value;
|
|
93
|
-
for (const [from, to] of hostRemap) {
|
|
94
|
-
result = result.replaceAll(from, to);
|
|
95
|
-
}
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
/** Detect the project's package manager from lock files. */
|
|
99
|
-
export function detectPackageManager(projectRoot) {
|
|
100
|
-
if (existsSync(path.join(projectRoot, "bun.lock")))
|
|
101
|
-
return "bun";
|
|
102
|
-
if (existsSync(path.join(projectRoot, "bun.lockb")))
|
|
103
|
-
return "bun";
|
|
104
|
-
if (existsSync(path.join(projectRoot, "pnpm-lock.yaml")))
|
|
105
|
-
return "pnpm";
|
|
106
|
-
if (existsSync(path.join(projectRoot, "yarn.lock")))
|
|
107
|
-
return "yarn";
|
|
108
|
-
return "npm";
|
|
109
|
-
}
|
package/dist/local/index.d.ts
DELETED
package/dist/local/index.js
DELETED
package/dist/local/runtime.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { Logger } from "pino";
|
|
2
|
-
import type { EnvValue, Secret, Service, Volume } from "../resource.js";
|
|
3
|
-
/**
|
|
4
|
-
* Docker runtime for local development.
|
|
5
|
-
*
|
|
6
|
-
* Runs managed infrastructure (databases, caches, etc.) as plain Docker
|
|
7
|
-
* containers with ports published to localhost. Secrets are generated
|
|
8
|
-
* in-memory and injected as environment variables.
|
|
9
|
-
*/
|
|
10
|
-
export declare class LocalRuntime {
|
|
11
|
-
private docker;
|
|
12
|
-
private project;
|
|
13
|
-
private log;
|
|
14
|
-
private secretValues;
|
|
15
|
-
private containers;
|
|
16
|
-
private networkName;
|
|
17
|
-
constructor(project: string, opts?: {
|
|
18
|
-
parentLogger?: Logger;
|
|
19
|
-
});
|
|
20
|
-
/** Create bridge network for inter-container DNS. */
|
|
21
|
-
ensureInfrastructure(): Promise<void>;
|
|
22
|
-
/** Generate a random secret value and store it in memory. */
|
|
23
|
-
createSecret(secret: Secret): void;
|
|
24
|
-
/** Get the generated value for a secret. */
|
|
25
|
-
getSecretValue(id: string): string | undefined;
|
|
26
|
-
/** Create a Docker volume for persistent data. */
|
|
27
|
-
createVolume(volume: Volume): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Resolve env vars for a managed service container.
|
|
30
|
-
*
|
|
31
|
-
* Secrets become plain `KEY=<value>` env vars.
|
|
32
|
-
* Interpolations are fully resolved with generated secret values.
|
|
33
|
-
*/
|
|
34
|
-
resolveEnv(env: Record<string, EnvValue>): string[];
|
|
35
|
-
/**
|
|
36
|
-
* Build an entrypoint wrapper that writes secret values to /run/secrets/
|
|
37
|
-
* before exec'ing the original entrypoint.
|
|
38
|
-
*
|
|
39
|
-
* This is needed because some factory images (e.g. redis) read passwords
|
|
40
|
-
* from `/run/secrets/*-password` via shell glob.
|
|
41
|
-
*/
|
|
42
|
-
private buildSecretInit;
|
|
43
|
-
/** Pull, create, and start a container for a managed service. */
|
|
44
|
-
createService(service: Service): Promise<number>;
|
|
45
|
-
/** Wait for a container to pass its health check. */
|
|
46
|
-
waitForHealthy(id: string, timeoutMs?: number): Promise<void>;
|
|
47
|
-
/** Stream logs from a container. */
|
|
48
|
-
containerLogs(id: string): AsyncGenerator<{
|
|
49
|
-
stream: "stdout" | "stderr";
|
|
50
|
-
text: string;
|
|
51
|
-
}>;
|
|
52
|
-
/** Stop and remove all managed containers (keep volumes). */
|
|
53
|
-
stop(): Promise<void>;
|
|
54
|
-
/** List running dev containers for this project. */
|
|
55
|
-
listContainers(): Promise<Array<{
|
|
56
|
-
id: string;
|
|
57
|
-
name: string;
|
|
58
|
-
containerId: string;
|
|
59
|
-
}>>;
|
|
60
|
-
private removeContainer;
|
|
61
|
-
}
|