@mp-lb/arcnet 0.3.1 → 0.4.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 +7 -53
- package/dist/arcnetConfig.d.ts +62 -0
- package/dist/arcnetConfig.d.ts.map +1 -0
- package/dist/arcnetConfig.js +53 -0
- package/dist/arcnetConfig.js.map +1 -0
- package/dist/ciOutputs.d.ts.map +1 -1
- package/dist/ciOutputs.js +26 -0
- package/dist/ciOutputs.js.map +1 -1
- package/dist/compileArcnet.d.ts +78 -0
- package/dist/compileArcnet.d.ts.map +1 -0
- package/dist/compileArcnet.js +60 -0
- package/dist/compileArcnet.js.map +1 -0
- package/dist/createCli.d.ts.map +1 -1
- package/dist/createCli.js +17 -4
- package/dist/createCli.js.map +1 -1
- package/dist/environment/grantDomainOwner.d.ts.map +1 -1
- package/dist/environment/grantDomainOwner.js.map +1 -1
- package/dist/resolveEnvironment.d.ts +21 -0
- package/dist/resolveEnvironment.d.ts.map +1 -0
- package/dist/resolveEnvironment.js +37 -0
- package/dist/resolveEnvironment.js.map +1 -0
- package/dist/runTerraform.d.ts.map +1 -1
- package/dist/runTerraform.js +57 -10
- package/dist/runTerraform.js.map +1 -1
- package/dist/runVercel.d.ts.map +1 -1
- package/dist/runVercel.js +16 -3
- package/dist/runVercel.js.map +1 -1
- package/dist/secrets/config.d.ts +2 -0
- package/dist/secrets/config.d.ts.map +1 -1
- package/dist/secrets/config.js +22 -2
- package/dist/secrets/config.js.map +1 -1
- package/dist/secrets/createSecretsCommands.d.ts.map +1 -1
- package/dist/secrets/createSecretsCommands.js +9 -8
- package/dist/secrets/createSecretsCommands.js.map +1 -1
- package/dist/secrets/loadSecrets.d.ts.map +1 -1
- package/dist/secrets/loadSecrets.js.map +1 -1
- package/dist/secrets/provisionSource.d.ts.map +1 -1
- package/dist/secrets/provisionSource.js +4 -4
- package/dist/secrets/provisionSource.js.map +1 -1
- package/dist/secrets/syncSecrets.d.ts.map +1 -1
- package/dist/secrets/syncSecrets.js +11 -2
- package/dist/secrets/syncSecrets.js.map +1 -1
- package/dist/secrets/withDeploymentSecrets.d.ts.map +1 -1
- package/dist/secrets/withDeploymentSecrets.js +11 -5
- package/dist/secrets/withDeploymentSecrets.js.map +1 -1
- package/dist/secrets/writeSecretsWorkflow.d.ts.map +1 -1
- package/dist/secrets/writeSecretsWorkflow.js +5 -4
- package/dist/secrets/writeSecretsWorkflow.js.map +1 -1
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +12 -0
- package/dist/setup.js.map +1 -1
- package/dist/setupArcnet.d.ts +2 -0
- package/dist/setupArcnet.d.ts.map +1 -0
- package/dist/setupArcnet.js +63 -0
- package/dist/setupArcnet.js.map +1 -0
- package/docs/public/llms-full.txt +7 -53
- package/environments/mp-lb.yaml +76 -0
- package/package.json +3 -2
- package/src/arcnetConfig.ts +68 -0
- package/src/ciOutputs.ts +36 -0
- package/src/compileArcnet.ts +82 -0
- package/src/createCli.ts +45 -11
- package/src/environment/grantDomainOwner.ts +16 -3
- package/src/resolveEnvironment.ts +50 -0
- package/src/runTerraform.ts +75 -10
- package/src/runVercel.ts +29 -3
- package/src/secrets/config.ts +26 -2
- package/src/secrets/createSecretsCommands.ts +25 -31
- package/src/secrets/loadSecrets.ts +10 -2
- package/src/secrets/provisionSource.ts +12 -10
- package/src/secrets/syncSecrets.ts +12 -6
- package/src/secrets/withDeploymentSecrets.ts +18 -8
- package/src/secrets/writeSecretsWorkflow.ts +7 -5
- package/src/setup.ts +19 -0
- package/src/setupArcnet.ts +96 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { parse } from "yaml";
|
|
4
|
+
import { addDependency, hasDependency } from "./addDependency.js";
|
|
5
|
+
import { readArcnetConfig } from "./arcnetConfig.js";
|
|
6
|
+
import {
|
|
7
|
+
arcnetMode,
|
|
8
|
+
compileTerraform,
|
|
9
|
+
compileVercel,
|
|
10
|
+
} from "./compileArcnet.js";
|
|
11
|
+
import { packageRoot } from "./packageInfo.js";
|
|
12
|
+
import { setupReport } from "./setupReport.js";
|
|
13
|
+
import { readSecretsConfig } from "./secrets/config.js";
|
|
14
|
+
import { writeSecretsWorkflow } from "./secrets/writeSecretsWorkflow.js";
|
|
15
|
+
|
|
16
|
+
export const setupArcnet = (root: string, dry: boolean) => {
|
|
17
|
+
const config = readArcnetConfig(root);
|
|
18
|
+
const zap = parse(readFileSync(join(root, "zap.yaml"), "utf8"));
|
|
19
|
+
if (zap.project !== config.project)
|
|
20
|
+
throw new Error("ArcNet project must match zap.yaml project.");
|
|
21
|
+
if (
|
|
22
|
+
zap.deploy ||
|
|
23
|
+
[
|
|
24
|
+
"project.json",
|
|
25
|
+
"services.json",
|
|
26
|
+
"vercel.json",
|
|
27
|
+
"network.yaml",
|
|
28
|
+
"env.production.json",
|
|
29
|
+
"secrets.json",
|
|
30
|
+
].some((name) => existsSync(join(root, ".arcnet", name)))
|
|
31
|
+
)
|
|
32
|
+
throw new Error(
|
|
33
|
+
"Existing deployment configuration must be migrated before using arcnet.yaml.",
|
|
34
|
+
);
|
|
35
|
+
const manifestPath = join(root, "package.json");
|
|
36
|
+
if (!existsSync(manifestPath) || !existsSync(join(root, "pnpm-lock.yaml")))
|
|
37
|
+
throw new Error("A pnpm package.json and committed lockfile are required.");
|
|
38
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
39
|
+
if (!/^pnpm@\d+\.\d+\.\d+/.test(manifest.packageManager ?? ""))
|
|
40
|
+
throw new Error("Pin packageManager to an exact pnpm version.");
|
|
41
|
+
const nextManifest = addDependency(manifestPath);
|
|
42
|
+
const mode = arcnetMode(config);
|
|
43
|
+
|
|
44
|
+
if (mode === "terraform") {
|
|
45
|
+
const { deployment } = compileTerraform(config);
|
|
46
|
+
|
|
47
|
+
for (const [name, service] of Object.entries(deployment.services)) {
|
|
48
|
+
if (
|
|
49
|
+
["cloud-run-web", "gce-worker"].includes(service.module) &&
|
|
50
|
+
(!service.dockerfile || !existsSync(join(root, service.dockerfile)))
|
|
51
|
+
)
|
|
52
|
+
throw new Error(`Service ${name} requires its Dockerfile.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (mode === "vercel") compileVercel(config);
|
|
57
|
+
|
|
58
|
+
const workflow =
|
|
59
|
+
mode === "package" ? undefined : ".github/workflows/deploy-arc.yaml";
|
|
60
|
+
|
|
61
|
+
const workflowPath = workflow && join(root, workflow);
|
|
62
|
+
if (workflowPath && existsSync(workflowPath) && !hasDependency(root))
|
|
63
|
+
throw new Error(`Refusing to overwrite existing ${workflow}.`);
|
|
64
|
+
if (config.approved && !hasDependency(root))
|
|
65
|
+
throw new Error("Start a new installation with approved: false.");
|
|
66
|
+
const files = ["package.json", ...(workflow ? [workflow] : [])];
|
|
67
|
+
if (dry)
|
|
68
|
+
return setupReport(
|
|
69
|
+
"dry-run",
|
|
70
|
+
files,
|
|
71
|
+
`Would install ArcNet ${mode} configuration; no cloud resources changed.`,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (workflowPath && !existsSync(workflowPath)) {
|
|
75
|
+
mkdirSync(dirname(workflowPath), { recursive: true });
|
|
76
|
+
writeFileSync(
|
|
77
|
+
workflowPath,
|
|
78
|
+
readFileSync(
|
|
79
|
+
join(
|
|
80
|
+
packageRoot,
|
|
81
|
+
`templates/deploy-${mode === "vercel" ? "vercel" : "arc"}.yaml`,
|
|
82
|
+
),
|
|
83
|
+
),
|
|
84
|
+
{ flag: "wx" },
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!hasDependency(root)) writeFileSync(manifestPath, nextManifest);
|
|
89
|
+
if (config.secrets)
|
|
90
|
+
writeSecretsWorkflow(readSecretsConfig(root), root, ".arcnet/arcnet.yaml");
|
|
91
|
+
return setupReport(
|
|
92
|
+
"installed",
|
|
93
|
+
files,
|
|
94
|
+
"ArcNet installed from .arcnet/arcnet.yaml. Run pnpm install and pnpm exec arcnet check.",
|
|
95
|
+
);
|
|
96
|
+
};
|