@gadicc/loom 1.25.0 → 1.26.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 +4 -3
- package/esm/src/cli/mod.d.ts +5 -0
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +59 -142
- package/esm/src/cli/releaseCredentials.d.ts +32 -0
- package/esm/src/cli/releaseCredentials.d.ts.map +1 -0
- package/esm/src/cli/releaseCredentials.js +388 -0
- package/esm/src/cli/releaseTrust.d.ts +39 -0
- package/esm/src/cli/releaseTrust.d.ts.map +1 -0
- package/esm/src/cli/releaseTrust.js +125 -0
- package/esm/src/cli/releaseTrustCommand.d.ts +18 -0
- package/esm/src/cli/releaseTrustCommand.d.ts.map +1 -0
- package/esm/src/cli/releaseTrustCommand.js +142 -0
- package/package.json +2 -2
- package/script/src/cli/mod.d.ts +5 -0
- package/script/src/cli/mod.d.ts.map +1 -1
- package/script/src/cli/mod.js +59 -142
- package/script/src/cli/releaseCredentials.d.ts +32 -0
- package/script/src/cli/releaseCredentials.d.ts.map +1 -0
- package/script/src/cli/releaseCredentials.js +392 -0
- package/script/src/cli/releaseTrust.d.ts +39 -0
- package/script/src/cli/releaseTrust.d.ts.map +1 -0
- package/script/src/cli/releaseTrust.js +130 -0
- package/script/src/cli/releaseTrustCommand.d.ts +18 -0
- package/script/src/cli/releaseTrustCommand.d.ts.map +1 -0
- package/script/src/cli/releaseTrustCommand.js +145 -0
- package/skills/loom-db/SKILL.md +17 -9
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { resolveProductionBranch } from "./releaseConfig.js";
|
|
4
|
+
import { prepareGithubReleaseTrust, verifyGithubReleaseTrustApplied, verifyGithubReleaseTrustPlan, } from "./releaseTrust.js";
|
|
5
|
+
function object(value) {
|
|
6
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function json(text, description) {
|
|
9
|
+
try {
|
|
10
|
+
const value = JSON.parse(text);
|
|
11
|
+
if (object(value))
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// Provider stdout can contain credentials; never reproduce it in an error.
|
|
16
|
+
}
|
|
17
|
+
throw new Error(`Invalid ${description} JSON.`);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Plan, apply, or verify one reviewed GitHub production HTTP trust rule.
|
|
21
|
+
* Planning only reads providers and writes an exclusive local proposal file.
|
|
22
|
+
* Apply checks current state twice, requires the reviewed proposal digest, and
|
|
23
|
+
* verifies the exact resulting provider state. It never creates a deploy token.
|
|
24
|
+
*/
|
|
25
|
+
export async function runGithubReleaseTrustCommand(action, args, options) {
|
|
26
|
+
const requiredCount = action === "plan" || action === "apply" ? 2 : 1;
|
|
27
|
+
if (args.length !== requiredCount) {
|
|
28
|
+
throw new Error(action === "plan"
|
|
29
|
+
? "Usage: loom db release trust-plan <workflow-path> <plan-file> [--environment <name>]"
|
|
30
|
+
: action === "apply"
|
|
31
|
+
? "Usage: loom db release trust-apply <plan-file> <reviewed-plan-sha256>"
|
|
32
|
+
: "Usage: loom db release trust-check <plan-file>");
|
|
33
|
+
}
|
|
34
|
+
const { cwd, env, commandRunner, vercelCli } = options;
|
|
35
|
+
async function command(command, args, input) {
|
|
36
|
+
let result;
|
|
37
|
+
try {
|
|
38
|
+
result = await commandRunner(command, args, {
|
|
39
|
+
cwd,
|
|
40
|
+
env,
|
|
41
|
+
...(input === undefined ? {} : { input }),
|
|
42
|
+
stdio: "pipe",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
throw new Error("Trusted Sources provider command did not complete.");
|
|
47
|
+
}
|
|
48
|
+
if (result.code !== 0) {
|
|
49
|
+
throw new Error(`Trusted Sources provider command failed (exit ${result.code}); inspect provider state before retrying an apply.`);
|
|
50
|
+
}
|
|
51
|
+
return result.stdout;
|
|
52
|
+
}
|
|
53
|
+
const link = json(await readFile(resolve(cwd, ".vercel/project.json"), "utf8"), "local Vercel project link");
|
|
54
|
+
if (typeof link.orgId !== "string" ||
|
|
55
|
+
typeof link.projectId !== "string" ||
|
|
56
|
+
!/^[A-Za-z0-9_-]+(?![\s\S])/.test(link.orgId) ||
|
|
57
|
+
!/^[A-Za-z0-9_-]+(?![\s\S])/.test(link.projectId))
|
|
58
|
+
throw new Error("Invalid local Vercel project link.");
|
|
59
|
+
const manifest = json(await readFile(resolve(cwd, "loom.json"), "utf8"), "Loom manifest");
|
|
60
|
+
const db = object(manifest.features) && object(manifest.features.db)
|
|
61
|
+
? manifest.features.db
|
|
62
|
+
: undefined;
|
|
63
|
+
const release = db && object(db.config) ? db.config.release : undefined;
|
|
64
|
+
const productionBranch = resolveProductionBranch(release);
|
|
65
|
+
const repository = json(await command("gh", ["api", "repos/:owner/:repo"]), "GitHub repository");
|
|
66
|
+
if (typeof repository.full_name !== "string" ||
|
|
67
|
+
(typeof repository.id !== "string" &&
|
|
68
|
+
!(typeof repository.id === "number" &&
|
|
69
|
+
Number.isSafeInteger(repository.id))))
|
|
70
|
+
throw new Error("Invalid canonical GitHub repository identity.");
|
|
71
|
+
const providerPath = (version) => `/v${version}/projects/${link.projectId}?teamId=${encodeURIComponent(link.orgId)}`;
|
|
72
|
+
const readProject = async () => json(await command(vercelCli, [
|
|
73
|
+
"api",
|
|
74
|
+
providerPath(10),
|
|
75
|
+
"--method",
|
|
76
|
+
"GET",
|
|
77
|
+
"--raw",
|
|
78
|
+
]), "Vercel project");
|
|
79
|
+
if (action === "plan") {
|
|
80
|
+
if (typeof options.environment !== "string") {
|
|
81
|
+
throw new Error("A resolved GitHub environment is required for planning.");
|
|
82
|
+
}
|
|
83
|
+
// Requiring a local file avoids authorizing a misspelled/nonexistent workflow.
|
|
84
|
+
const workflowPath = args[0];
|
|
85
|
+
const target = {
|
|
86
|
+
projectId: link.projectId,
|
|
87
|
+
teamId: link.orgId,
|
|
88
|
+
repository: repository.full_name,
|
|
89
|
+
repositoryId: String(repository.id),
|
|
90
|
+
productionBranch,
|
|
91
|
+
githubEnvironment: options.environment,
|
|
92
|
+
workflowPath,
|
|
93
|
+
};
|
|
94
|
+
const plan = prepareGithubReleaseTrust(await readProject(), target);
|
|
95
|
+
await readFile(resolve(cwd, workflowPath), "utf8");
|
|
96
|
+
const planFile = resolve(cwd, args[1]);
|
|
97
|
+
await writeFile(planFile, `${JSON.stringify(plan, null, 2)}\n`, {
|
|
98
|
+
flag: "wx",
|
|
99
|
+
mode: 0o600,
|
|
100
|
+
});
|
|
101
|
+
return [
|
|
102
|
+
`Wrote Trusted Sources proposal: ${planFile}`,
|
|
103
|
+
`Reviewed proposal SHA-256: ${plan.approvalSha256}`,
|
|
104
|
+
"No provider settings changed. Review the proposal before trust-apply.",
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
const value = json(await readFile(resolve(cwd, args[0]), "utf8"), "trust proposal");
|
|
108
|
+
if (value.profile !== "loom-github-release-trust-v1" || !object(value.target) ||
|
|
109
|
+
!object(value.patch) || !object(value.patch.trustedSources) ||
|
|
110
|
+
typeof value.approvalSha256 !== "string" ||
|
|
111
|
+
!/^[a-f0-9]{64}$/.test(value.approvalSha256) ||
|
|
112
|
+
value.target.projectId !== link.projectId ||
|
|
113
|
+
value.target.teamId !== link.orgId ||
|
|
114
|
+
value.target.repository !== repository.full_name ||
|
|
115
|
+
value.target.repositoryId !== String(repository.id) ||
|
|
116
|
+
value.target.productionBranch !== productionBranch ||
|
|
117
|
+
(options.environment !== undefined &&
|
|
118
|
+
value.target.githubEnvironment !== options.environment)) {
|
|
119
|
+
throw new Error("Trust proposal does not match this linked project and repository.");
|
|
120
|
+
}
|
|
121
|
+
const plan = value;
|
|
122
|
+
// Validate the workflow path before resolving untrusted proposal contents.
|
|
123
|
+
if (typeof plan.target.workflowPath !== "string" ||
|
|
124
|
+
!/^\.github\/workflows\/[A-Za-z0-9_.-]+\.ya?ml(?![\s\S])/.test(plan.target.workflowPath))
|
|
125
|
+
throw new Error("Invalid workflow path in trust proposal.");
|
|
126
|
+
await readFile(resolve(cwd, plan.target.workflowPath), "utf8");
|
|
127
|
+
if (action === "check") {
|
|
128
|
+
verifyGithubReleaseTrustApplied(await readProject(), plan);
|
|
129
|
+
return ["Verified production Trusted Sources matches the local proposal."];
|
|
130
|
+
}
|
|
131
|
+
verifyGithubReleaseTrustPlan(await readProject(), plan, args[1]);
|
|
132
|
+
if (plan.changed) {
|
|
133
|
+
verifyGithubReleaseTrustPlan(await readProject(), plan, args[1]);
|
|
134
|
+
await command(vercelCli, ["api", providerPath(9), "--method", "PATCH", "--input", "-", "--raw"], JSON.stringify(plan.patch));
|
|
135
|
+
}
|
|
136
|
+
verifyGithubReleaseTrustApplied(await readProject(), plan);
|
|
137
|
+
return [
|
|
138
|
+
plan.changed
|
|
139
|
+
? "Applied and verified the reviewed production Trusted Sources rule."
|
|
140
|
+
: "Trusted Sources already matched; no provider settings changed.",
|
|
141
|
+
];
|
|
142
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gadicc/loom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "Deno-first shared helpers for extracting common Next.js app code.",
|
|
5
5
|
"homepage": "https://github.com/gadicc/loom#readme",
|
|
6
6
|
"repository": {
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
},
|
|
232
232
|
"scripts": {},
|
|
233
233
|
"loom": {
|
|
234
|
-
"gitCommit": "
|
|
234
|
+
"gitCommit": "53d38019c2102bcc40d4eb9ab77b7c562f7c1404"
|
|
235
235
|
},
|
|
236
236
|
"bin": {
|
|
237
237
|
"loom": "script/bin/loom.js"
|
package/script/src/cli/mod.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type VercelReleaseTokenScope } from "./releaseCredentials.js";
|
|
1
2
|
import { type ProjectTooling } from "./projectTooling.js";
|
|
2
3
|
export declare const DEFAULT_LOOM_RANGE = "^1.0.0";
|
|
3
4
|
export declare const LOOM_DEPENDENCY = "@gadicc/loom";
|
|
@@ -292,7 +293,11 @@ type GithubVercelReleaseSetupOptions = {
|
|
|
292
293
|
env?: Record<string, string | undefined>;
|
|
293
294
|
environment?: string;
|
|
294
295
|
io?: CliOutput;
|
|
296
|
+
now?: () => Date;
|
|
297
|
+
rotateToken?: boolean;
|
|
298
|
+
tokenExpiryDays?: number | string;
|
|
295
299
|
tokenName?: string;
|
|
300
|
+
tokenScope?: VercelReleaseTokenScope | string;
|
|
296
301
|
};
|
|
297
302
|
type GithubMigrationCredentialSetupOptions = {
|
|
298
303
|
commandRunner?: CommandRunner;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/cli/mod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/cli/mod.ts"],"names":[],"mappings":"AAgCA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,yBAAyB,CAAC;AAuBjC,OAAO,EAUL,KAAK,cAAc,EAMpB,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAC3C,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAC9C,eAAO,MAAM,oBAAoB,2DACyB,CAAC;AAC3D,eAAO,MAAM,yBAAyB,uCAAuC,CAAC;AAC9E,eAAO,MAAM,uBAAuB,qCAAqC,CAAC;AAC1E,eAAO,MAAM,8BAA8B,8CACE,CAAC;AAC9C,eAAO,MAAM,4BAA4B,4CACE,CAAC;AAC5C,eAAO,MAAM,+BAA+B,6BAA6B,CAAC;AAC1E,eAAO,MAAM,6BAA6B,2BAA2B,CAAC;AACtE,eAAO,MAAM,kCAAkC,yBAAyB,CAAC;AACzE,eAAO,MAAM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AM,GAAG,SAAS,CAAe,EACrD,OAAO,GAAE;IACP,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;;;GAqBP;AAED,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EACrD,OAAO,GAAE,mBAAwB;;;;GA0LlC;AAED,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EACrD,OAAO,GAAE,mBAAwB;;;eAMxB,MAAM;gBACL,sBAAsB;;;;GA2GjC;AAuFD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,uBAAuB,EAC9B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,YAoClD;AA4gCD,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,EAAE,SAAS,EACb,OAAO,GAAE;IACP,aAAa,CAAC,EAAE,aAAa,CAAC;CAC1B,mBAiBP;AAipBD,wBAAsB,MAAM,CAC1B,IAAI,MAAwB,EAC5B,EAAE,GAAE,SAGH,mBA6KF"}
|
package/script/src/cli/mod.js
CHANGED
|
@@ -79,6 +79,8 @@ const node_process_1 = __importDefault(require("node:process"));
|
|
|
79
79
|
const node_util_1 = require("node:util");
|
|
80
80
|
const filesR2Policy_js_1 = require("./filesR2Policy.js");
|
|
81
81
|
const releaseConfig_js_1 = require("./releaseConfig.js");
|
|
82
|
+
const releaseCredentials_js_1 = require("./releaseCredentials.js");
|
|
83
|
+
const releaseTrustCommand_js_1 = require("./releaseTrustCommand.js");
|
|
82
84
|
const retention_js_1 = require("../apiKeys/retention.js");
|
|
83
85
|
const projectSkills_js_1 = require("./projectSkills.js");
|
|
84
86
|
const migrationEnv_js_1 = require("./migrationEnv.js");
|
|
@@ -6504,62 +6506,6 @@ async function hasProductionPushDbMigrationWorkflow(cwd, productionBranch) {
|
|
|
6504
6506
|
}
|
|
6505
6507
|
return false;
|
|
6506
6508
|
}
|
|
6507
|
-
function findStringPropertyDeep(value, propertyName) {
|
|
6508
|
-
if (typeof value !== "object" || value === null) {
|
|
6509
|
-
return null;
|
|
6510
|
-
}
|
|
6511
|
-
if (!Array.isArray(value) &&
|
|
6512
|
-
typeof value[propertyName] === "string") {
|
|
6513
|
-
return value[propertyName];
|
|
6514
|
-
}
|
|
6515
|
-
const children = Array.isArray(value)
|
|
6516
|
-
? value
|
|
6517
|
-
: Object.values(value);
|
|
6518
|
-
for (const child of children) {
|
|
6519
|
-
const found = findStringPropertyDeep(child, propertyName);
|
|
6520
|
-
if (found) {
|
|
6521
|
-
return found;
|
|
6522
|
-
}
|
|
6523
|
-
}
|
|
6524
|
-
return null;
|
|
6525
|
-
}
|
|
6526
|
-
function parseJsonFromCommandOutput(text) {
|
|
6527
|
-
const trimmed = text.trim();
|
|
6528
|
-
if (!trimmed) {
|
|
6529
|
-
return null;
|
|
6530
|
-
}
|
|
6531
|
-
try {
|
|
6532
|
-
return JSON.parse(trimmed);
|
|
6533
|
-
}
|
|
6534
|
-
catch {
|
|
6535
|
-
// Some CLIs print progress lines before JSON even with --format json.
|
|
6536
|
-
}
|
|
6537
|
-
const starts = [trimmed.indexOf("{"), trimmed.indexOf("[")]
|
|
6538
|
-
.filter((index) => index >= 0)
|
|
6539
|
-
.sort((a, b) => a - b);
|
|
6540
|
-
for (const start of starts) {
|
|
6541
|
-
const close = trimmed[start] === "{" ? "}" : "]";
|
|
6542
|
-
const end = trimmed.lastIndexOf(close);
|
|
6543
|
-
if (end <= start) {
|
|
6544
|
-
continue;
|
|
6545
|
-
}
|
|
6546
|
-
try {
|
|
6547
|
-
return JSON.parse(trimmed.slice(start, end + 1));
|
|
6548
|
-
}
|
|
6549
|
-
catch {
|
|
6550
|
-
// Try the next JSON-looking range.
|
|
6551
|
-
}
|
|
6552
|
-
}
|
|
6553
|
-
return null;
|
|
6554
|
-
}
|
|
6555
|
-
function parseVercelCreatedToken(text) {
|
|
6556
|
-
const parsed = parseJsonFromCommandOutput(text);
|
|
6557
|
-
if (!parsed) {
|
|
6558
|
-
return null;
|
|
6559
|
-
}
|
|
6560
|
-
return findStringPropertyDeep(parsed, "bearerToken") ??
|
|
6561
|
-
findStringPropertyDeep(parsed, "token");
|
|
6562
|
-
}
|
|
6563
6509
|
function getProjectSlug(cwd, packageJson, manifest) {
|
|
6564
6510
|
return sanitizeVercelResourceName(manifest?.project?.name ?? packageJson.name ?? (0, node_path_1.basename)(cwd));
|
|
6565
6511
|
}
|
|
@@ -6810,7 +6756,7 @@ function createGithubReleaseConfigCheckStep(state, context) {
|
|
|
6810
6756
|
return networkCheckResult("warning", "GitHub CLI is not available, so Loom could not inspect GitHub Actions secrets and variables.", {
|
|
6811
6757
|
suggestions: [
|
|
6812
6758
|
"Install and authenticate `gh`, then rerun `loom check --network`.",
|
|
6813
|
-
"After `gh` is available, run `loom db release setup-github` from the project root to create a
|
|
6759
|
+
"After `gh` is available, run `loom db release setup-github` from the project root to create a bounded project-scoped Vercel token and store the required GitHub release configuration.",
|
|
6814
6760
|
`Set production release config with \`gh secret set VERCEL_TOKEN --env ${PRODUCTION_GITHUB_ENVIRONMENT}\`, \`gh variable set VERCEL_ORG_ID --env ${PRODUCTION_GITHUB_ENVIRONMENT} --body ${state.vercelOrgId}\`, and \`gh variable set VERCEL_PROJECT_ID --env ${PRODUCTION_GITHUB_ENVIRONMENT} --body ${state.vercelProjectId}\`.`,
|
|
6815
6761
|
],
|
|
6816
6762
|
warnings: [
|
|
@@ -6842,7 +6788,7 @@ function createGithubReleaseConfigCheckStep(state, context) {
|
|
|
6842
6788
|
for (const secretName of REQUIRED_GITHUB_VERCEL_SECRET_NAMES) {
|
|
6843
6789
|
if (!collectionHasName(secretName, environmentSecrets, repoSecrets)) {
|
|
6844
6790
|
issues.push(`GitHub Actions is missing required production secret: ${secretName}.`);
|
|
6845
|
-
suggestions.add("Run `loom db release setup-github` from the project root to create
|
|
6791
|
+
suggestions.add("Run `loom db release setup-github` from the project root to create or preserve the bounded project-scoped Vercel release credential and store the required GitHub configuration.");
|
|
6846
6792
|
suggestions.add(`Run \`gh secret set ${secretName} --env ${PRODUCTION_GITHUB_ENVIRONMENT}\` from the project root.`);
|
|
6847
6793
|
suggestions.add(`If GitHub reports that the ${PRODUCTION_GITHUB_ENVIRONMENT} environment does not exist, create it with \`gh api --method PUT repos/:owner/:repo/environments/${PRODUCTION_GITHUB_ENVIRONMENT}\`, then rerun the secret command.`);
|
|
6848
6794
|
}
|
|
@@ -6866,7 +6812,7 @@ function createGithubReleaseConfigCheckStep(state, context) {
|
|
|
6866
6812
|
else {
|
|
6867
6813
|
issues.push(`GitHub Actions is missing required production variable: ${name}.`);
|
|
6868
6814
|
}
|
|
6869
|
-
suggestions.add("Run `loom db release setup-github` from the project root to create
|
|
6815
|
+
suggestions.add("Run `loom db release setup-github` from the project root to create or preserve the bounded project-scoped Vercel release credential and store the required GitHub configuration.");
|
|
6870
6816
|
suggestions.add(`Run \`gh variable set ${name} --env ${PRODUCTION_GITHUB_ENVIRONMENT} --body ${expectedValues[name]}\` from the project root.`);
|
|
6871
6817
|
}
|
|
6872
6818
|
for (const staleSecret of STALE_GITHUB_RELEASE_SECRET_NAMES) {
|
|
@@ -7624,10 +7570,6 @@ async function setupGithubVercelRelease(cwd, options = {}) {
|
|
|
7624
7570
|
const commandRunner = options.commandRunner ?? defaultCommandRunner;
|
|
7625
7571
|
const env = options.env ?? node_process_1.default.env;
|
|
7626
7572
|
const environment = options.environment ?? PRODUCTION_GITHUB_ENVIRONMENT;
|
|
7627
|
-
const io = options.io ?? {
|
|
7628
|
-
err: (line) => console.error(line),
|
|
7629
|
-
out: (line) => console.log(line),
|
|
7630
|
-
};
|
|
7631
7573
|
const { packageJson } = await readProjectPackageJson(cwd);
|
|
7632
7574
|
const manifestText = await readTextIfExists((0, node_path_1.join)(cwd, "loom.json"));
|
|
7633
7575
|
const manifest = manifestText
|
|
@@ -7648,89 +7590,24 @@ async function setupGithubVercelRelease(cwd, options = {}) {
|
|
|
7648
7590
|
}
|
|
7649
7591
|
const tokenName = options.tokenName ??
|
|
7650
7592
|
getDefaultVercelGithubTokenName(cwd, packageJson, manifest);
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
"api",
|
|
7654
|
-
"--method",
|
|
7655
|
-
"PUT",
|
|
7656
|
-
`repos/:owner/:repo/environments/${environment}`,
|
|
7657
|
-
"--input",
|
|
7658
|
-
"-",
|
|
7659
|
-
], {
|
|
7593
|
+
return await (0, releaseCredentials_js_1.configureGithubVercelReleaseCredential)({
|
|
7594
|
+
commandRunner,
|
|
7660
7595
|
cwd,
|
|
7661
7596
|
env,
|
|
7662
|
-
input: JSON.stringify({
|
|
7663
|
-
deployment_branch_policy: {
|
|
7664
|
-
custom_branch_policies: true,
|
|
7665
|
-
protected_branches: false,
|
|
7666
|
-
},
|
|
7667
|
-
}),
|
|
7668
|
-
stdio: "pipe",
|
|
7669
|
-
});
|
|
7670
|
-
const branchPoliciesResult = await requireCommand(`List GitHub ${environment} deployment branches`, commandRunner, "gh", [
|
|
7671
|
-
"api",
|
|
7672
|
-
`repos/:owner/:repo/environments/${environment}/deployment-branch-policies`,
|
|
7673
|
-
], { cwd, env, stdio: "pipe" });
|
|
7674
|
-
const branchPolicies = parseJson(branchPoliciesResult.stdout || "{}", "GitHub deployment branch policies");
|
|
7675
|
-
if (!branchPolicies.branch_policies?.some((policy) => policy.name === productionBranch)) {
|
|
7676
|
-
await requireCommand(`Allow ${productionBranch} to deploy to GitHub ${environment}`, commandRunner, "gh", [
|
|
7677
|
-
"api",
|
|
7678
|
-
"--method",
|
|
7679
|
-
"POST",
|
|
7680
|
-
`repos/:owner/:repo/environments/${environment}/deployment-branch-policies`,
|
|
7681
|
-
"--input",
|
|
7682
|
-
"-",
|
|
7683
|
-
], {
|
|
7684
|
-
cwd,
|
|
7685
|
-
env,
|
|
7686
|
-
input: JSON.stringify({ name: productionBranch, type: "branch" }),
|
|
7687
|
-
stdio: "pipe",
|
|
7688
|
-
});
|
|
7689
|
-
}
|
|
7690
|
-
notes.push(`Ensured GitHub environment \`${environment}\` exists and allows the ${productionBranch} release branch; existing branch policies are preserved.`);
|
|
7691
|
-
await requireCommand("Set GitHub VERCEL_ORG_ID variable", commandRunner, "gh", [
|
|
7692
|
-
"variable",
|
|
7693
|
-
"set",
|
|
7694
|
-
"VERCEL_ORG_ID",
|
|
7695
|
-
"--env",
|
|
7696
7597
|
environment,
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
notes.push("Set GitHub Vercel project ID variables.");
|
|
7710
|
-
io.out(`Creating Vercel token \`${tokenName}\` scoped to this team...`);
|
|
7711
|
-
const tokenResult = await requireCommand("Create Vercel authentication token", commandRunner, vercelCli.command, [
|
|
7712
|
-
"api",
|
|
7713
|
-
`/v3/user/tokens?teamId=${encodeURIComponent(vercelLink.orgId)}`,
|
|
7714
|
-
"--method",
|
|
7715
|
-
"POST",
|
|
7716
|
-
"--input",
|
|
7717
|
-
"-",
|
|
7718
|
-
"--raw",
|
|
7719
|
-
], {
|
|
7720
|
-
cwd,
|
|
7721
|
-
env,
|
|
7722
|
-
input: JSON.stringify({
|
|
7723
|
-
name: tokenName,
|
|
7724
|
-
}),
|
|
7725
|
-
stdio: "pipe",
|
|
7598
|
+
githubCommand: githubCli.command,
|
|
7599
|
+
hasTokenOverrides: options.tokenExpiryDays !== undefined ||
|
|
7600
|
+
options.tokenName !== undefined || options.tokenScope !== undefined,
|
|
7601
|
+
now: options.now,
|
|
7602
|
+
orgId: vercelLink.orgId,
|
|
7603
|
+
productionBranch,
|
|
7604
|
+
projectId: vercelLink.projectId,
|
|
7605
|
+
rotateToken: options.rotateToken ?? false,
|
|
7606
|
+
tokenExpiryDays: options.tokenExpiryDays,
|
|
7607
|
+
tokenName,
|
|
7608
|
+
tokenScope: options.tokenScope,
|
|
7609
|
+
vercelCommand: vercelCli.command,
|
|
7726
7610
|
});
|
|
7727
|
-
const token = parseVercelCreatedToken(tokenResult.stdout);
|
|
7728
|
-
if (!token) {
|
|
7729
|
-
throw new Error("Vercel token was created, but Loom could not find a token value in the CLI JSON output. Open the Vercel dashboard token page and set `gh secret set VERCEL_TOKEN --env production` manually.");
|
|
7730
|
-
}
|
|
7731
|
-
await requireCommand("Set GitHub VERCEL_TOKEN secret", commandRunner, "gh", ["secret", "set", "VERCEL_TOKEN", "--env", environment], { cwd, env, input: token, stdio: "pipe" });
|
|
7732
|
-
notes.push("Stored the new Vercel token as GitHub secret `VERCEL_TOKEN`.");
|
|
7733
|
-
return { notes };
|
|
7734
7611
|
}
|
|
7735
7612
|
async function applyJobsFeature(cwd, framework, manifest, activate) {
|
|
7736
7613
|
const changedFiles = [];
|
|
@@ -10827,6 +10704,9 @@ function printHelp({ out }) {
|
|
|
10827
10704
|
out(" db migrations verify-env Validate migration URL precedence and role metadata without printing credentials. Add --connect for a live access preflight.");
|
|
10828
10705
|
out(" db migrations setup-github Store an existing direct migration URL as a protected GitHub Environment secret.");
|
|
10829
10706
|
out(" db release setup-github Create/update GitHub production release config for staged Vercel deploys.");
|
|
10707
|
+
out(" db release trust-plan <workflow> <plan> Plan exact Vercel Trusted Sources for a GitHub release workflow.");
|
|
10708
|
+
out(" db release trust-apply <plan> <approval-sha256> Apply a reviewed Trusted Sources plan.");
|
|
10709
|
+
out(" db release trust-check <plan> Verify the reviewed Trusted Sources plan is active.");
|
|
10830
10710
|
out(" db release prepare-build-env <env> <metadata> <policy> <manifest> Prepare metadata-backed placeholders for an external Vercel build.");
|
|
10831
10711
|
out(" db release verify-build-env <output> <manifest> Reject build-only placeholders in a deployable Vercel artifact.");
|
|
10832
10712
|
out(" dev local Enable local Loom development using a managed pnpm override or Deno link.");
|
|
@@ -10857,6 +10737,9 @@ function printHelp({ out }) {
|
|
|
10857
10737
|
out(" --configure-secrets Ask Vercel to prompt securely for missing R2 credentials; never replaces existing credentials.");
|
|
10858
10738
|
out(" --repair Apply declared non-secret Files provider drift; never deletes resources or rotates credentials.");
|
|
10859
10739
|
out(" --token-name <name> Override the Vercel token name for `loom db release setup-github`.");
|
|
10740
|
+
out(" --rotate-token Explicitly replace an existing GitHub VERCEL_TOKEN; the old Vercel token remains active.");
|
|
10741
|
+
out(" --token-scope project|team Vercel release token scope (default project; team is compatibility mode).");
|
|
10742
|
+
out(" --token-expiry-days <days> Vercel release token lifetime (default 90).");
|
|
10860
10743
|
out(" --environment <name> GitHub Environment for migration credential setup (default production).");
|
|
10861
10744
|
out(" --env-file <path> Preserved env snapshot for `db migrations verify-env`; process values take precedence.");
|
|
10862
10745
|
out(" --connect Authenticate and check migration database identity and schema privileges.");
|
|
@@ -11432,7 +11315,10 @@ async function runDbRelease(cwd, command, args, io, options) {
|
|
|
11432
11315
|
const result = await setupGithubVercelRelease(cwd, {
|
|
11433
11316
|
environment: options.environment,
|
|
11434
11317
|
io,
|
|
11318
|
+
rotateToken: options.rotateToken,
|
|
11319
|
+
tokenExpiryDays: options.tokenExpiryDays,
|
|
11435
11320
|
tokenName: options.tokenName,
|
|
11321
|
+
tokenScope: options.tokenScope,
|
|
11436
11322
|
});
|
|
11437
11323
|
for (const note of result.notes) {
|
|
11438
11324
|
io.out(`Note: ${note}`);
|
|
@@ -11440,6 +11326,31 @@ async function runDbRelease(cwd, command, args, io, options) {
|
|
|
11440
11326
|
io.out("Next step: run `loom check --production --network` to verify the release configuration.");
|
|
11441
11327
|
return 0;
|
|
11442
11328
|
}
|
|
11329
|
+
case "trust-plan":
|
|
11330
|
+
case "trust-apply":
|
|
11331
|
+
case "trust-check": {
|
|
11332
|
+
const vercelCli = await detectVercelCliCommand(cwd, defaultCommandRunner, node_process_1.default.env);
|
|
11333
|
+
if (!vercelCli.command) {
|
|
11334
|
+
throw new Error("Vercel CLI is not available. Install it or make `vercel`/`vc` available on PATH.");
|
|
11335
|
+
}
|
|
11336
|
+
const action = command === "trust-plan"
|
|
11337
|
+
? "plan"
|
|
11338
|
+
: command === "trust-apply"
|
|
11339
|
+
? "apply"
|
|
11340
|
+
: "check";
|
|
11341
|
+
const notes = await (0, releaseTrustCommand_js_1.runGithubReleaseTrustCommand)(action, args, {
|
|
11342
|
+
commandRunner: defaultCommandRunner,
|
|
11343
|
+
cwd,
|
|
11344
|
+
env: node_process_1.default.env,
|
|
11345
|
+
environment: action === "plan"
|
|
11346
|
+
? options.environment ?? PRODUCTION_GITHUB_ENVIRONMENT
|
|
11347
|
+
: options.environment,
|
|
11348
|
+
vercelCli: vercelCli.command,
|
|
11349
|
+
});
|
|
11350
|
+
for (const note of notes)
|
|
11351
|
+
io.out(`Note: ${note}`);
|
|
11352
|
+
return 0;
|
|
11353
|
+
}
|
|
11443
11354
|
default:
|
|
11444
11355
|
io.err(`Unknown release subcommand: ${command}`);
|
|
11445
11356
|
io.err("Run `loom --help` for usage.");
|
|
@@ -11684,6 +11595,9 @@ async function runCli(args = node_process_1.default.argv.slice(2), io = {
|
|
|
11684
11595
|
"strict-skills": { type: "boolean" },
|
|
11685
11596
|
"shared-bucket": { type: "string" },
|
|
11686
11597
|
"token-name": { type: "string" },
|
|
11598
|
+
"token-expiry-days": { type: "string" },
|
|
11599
|
+
"token-scope": { type: "string" },
|
|
11600
|
+
"rotate-token": { type: "boolean" },
|
|
11687
11601
|
version: { type: "string" },
|
|
11688
11602
|
},
|
|
11689
11603
|
});
|
|
@@ -11770,6 +11684,9 @@ async function runCli(args = node_process_1.default.argv.slice(2), io = {
|
|
|
11770
11684
|
plan: parsed.values.plan,
|
|
11771
11685
|
region: parsed.values.region,
|
|
11772
11686
|
tokenName: parsed.values["token-name"],
|
|
11687
|
+
tokenScope: parsed.values["token-scope"],
|
|
11688
|
+
tokenExpiryDays: parsed.values["token-expiry-days"],
|
|
11689
|
+
rotateToken: parsed.values["rotate-token"],
|
|
11773
11690
|
});
|
|
11774
11691
|
case "dev":
|
|
11775
11692
|
return await runDev(cwd, arg1, arg2, io, {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CommandRunner } from "./mod.js";
|
|
2
|
+
export declare const DEFAULT_VERCEL_TOKEN_EXPIRY_DAYS = 90;
|
|
3
|
+
export declare const VERCEL_TOKEN_EXPIRY_VARIABLE = "LOOM_VERCEL_TOKEN_EXPIRES_AT";
|
|
4
|
+
export declare const VERCEL_TOKEN_ID_VARIABLE = "LOOM_VERCEL_TOKEN_ID";
|
|
5
|
+
export declare const VERCEL_TOKEN_SCOPE_VARIABLE = "LOOM_VERCEL_TOKEN_SCOPE";
|
|
6
|
+
export type VercelReleaseTokenScope = "project" | "team";
|
|
7
|
+
type ReleaseCredentialSetupOptions = {
|
|
8
|
+
commandRunner: CommandRunner;
|
|
9
|
+
cwd: string;
|
|
10
|
+
env: Record<string, string | undefined>;
|
|
11
|
+
environment: string;
|
|
12
|
+
githubCommand: string;
|
|
13
|
+
hasTokenOverrides: boolean;
|
|
14
|
+
now?: () => Date;
|
|
15
|
+
orgId: string;
|
|
16
|
+
productionBranch: string;
|
|
17
|
+
projectId: string;
|
|
18
|
+
rotateToken: boolean;
|
|
19
|
+
tokenExpiryDays?: number | string;
|
|
20
|
+
tokenName: string;
|
|
21
|
+
tokenScope?: string;
|
|
22
|
+
vercelCommand: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Audits GitHub release protections and installs a bounded Vercel credential
|
|
26
|
+
* without exposing token values in arguments or provider failures.
|
|
27
|
+
*/
|
|
28
|
+
export declare function configureGithubVercelReleaseCredential(options: ReleaseCredentialSetupOptions): Promise<{
|
|
29
|
+
notes: string[];
|
|
30
|
+
}>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=releaseCredentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"releaseCredentials.d.ts","sourceRoot":"","sources":["../../../src/src/cli/releaseCredentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,eAAO,MAAM,gCAAgC,KAAK,CAAC;AACnD,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AAC3E,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAC/D,eAAO,MAAM,2BAA2B,4BAA4B,CAAC;AAErE,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,MAAM,CAAC;AAEzD,KAAK,6BAA6B,GAAG;IACnC,aAAa,EAAE,aAAa,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AA+eF;;;GAGG;AACH,wBAAsB,sCAAsC,CAC1D,OAAO,EAAE,6BAA6B;;GAuHvC"}
|