@theholocron/cli 5.0.0-alpha.551 → 5.0.0-alpha.553
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/cli.mjs +298 -72
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-DwWELFPL.mjs → config-system-DsyeF_Sy.mjs} +67 -5
- package/dist/{index-jQQ8cGkA.d.mts → index-CCQzRMBg.d.mts} +29 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/plugin/capabilities.d.mts +1 -1
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -717,7 +717,7 @@ commands and the config are provider-neutral; Discord is the first provider.
|
|
|
717
717
|
| `holocron doctor wiki` | Does the wiki the config declares exist, and does it match the sources? Rows: `organization is set` (`fern/fern.config.json` against the declared `fernOrg`), `docs site is declared` (the `instances:` url and `custom-domain` of `fern/docs.yml`), `docs site answers` and `custom domain answers` (one unauthenticated GET each: a 404 or 5xx fails, a 401/403 passes as restricted, no answer is a skip), `navigation pages exist` (every `path:` of the navigation is on disk), an `info` row for pages under `docs/wiki` the navigation leaves out, and `published pages` (the site's sitemap lists at least as many pages as the navigation; fewer fails and names the wiki workflow). Reads through the optional `Wiki.inspect()`; never publishes, writes or sends a token. A provider that cannot inspect, or a site that cannot be reached, is a skip. Read-only |
|
|
718
718
|
| `holocron doctor errors` | Does the error tracker have the organization, projects, keys and alert rules the config relies on? Rows: `organization exists`, and for each project a notifications layout's `relay.errors.projects` declares, `project <slug> exists` (a 404 fails), `project <slug> has a key` (a client key, so an SDK has a DSN; none fails) and `project <slug> has an alert rule` (at least one enabled rule watches its issues; none fails). The Comlink relay's integration and rule stay in `doctor notifications`. Reads through the optional `Errors.inspect()` and returns counts only, never a DSN or key. A missing token or `org`, or alert rules the token cannot read, is a skip. Read-only |
|
|
719
719
|
| `holocron doctor workers` | Do the Workers and deployment projects the config declares exist, route and deploy healthily? Declared Workers are the relay Worker of a notifications layout that feeds an error tracker and the reverse proxy of a wiki with a custom domain. Rows per Worker: `<name> Worker is deployed and routed` (the script exists with a route for its host), `has its bindings` (by name, a value is never read) and `latest deployment is healthy` (the newest deployment serves all traffic). Rows per deployment project (the preview project, else one named like the repo): `<project> project exists`, `has its custom domain` (when one is declared) and `latest deployment is healthy` (the newest production deployment is ready; one that errored fails, one still building is information). Reads through the optional `Workers.inspectScript` / `latestDeployment` / `proxyScriptName` and `Deployment.listProjects` / `listDomains` / `latestDeployment`; never deploys or prints a token. A missing token, a 401 or 403, or a provider that cannot read it is a skip. Read-only |
|
|
720
|
-
| `holocron doctor environments` | Do the deployment environments exist? The ones `
|
|
720
|
+
| `holocron doctor environments` | Do the deployment environments exist? The ones `repo.environments` declares (their reviewers, wait timer and self-review rule are compared too) plus every environment `repo.secrets.environments` names; none declared is an ok. One row. A missing one fails; an extra one is never a problem; no provider with some expected is a skip |
|
|
721
721
|
| `holocron doctor project [--post [channel]]` | Does each board `providers.projects.boards` declares exist and match its template? One row per board, status list, field, view and automation rule; the board's extras and the items `reconcile project` would fix (no status, closed but not done, open blocker but not blocked, blocked without a blocker) are `info` rows, never a failure. A template file that does not read fails, naming the file. Read-only; `--post` shares the failing rows through the `notifications` bot. |
|
|
722
722
|
| `holocron doctor repo` | Do the repository settings `setup` writes match the config? One row per group the config declares: description and homepage, default branch and merge settings, topics, custom properties, team access, branch protection (and, for `strict`, a `repo-ci-pin` row comparing the App `ci / Required checks` is pinned to with the opt-in `ci.pin`; skipped, saying the option is off, when unset); labels and security settings are always checked, plus a `repo-area-labels` row when `repo.labels.areas` is declared (a declared area with no `area:<name>` label fails; an undeclared `area:` label is an `info` note). Read-only. Reads through optional `Source` methods (`getRepoInfo`, `getProperties`, `listLabels`, `listTeamAccess`, `getRulesetDetail`, `getSecurity`); a group that cannot be read is a skip, not a failure |
|
|
723
723
|
| `holocron doctor dns` | Do the DNS records the config makes setup write exist, pointing where they should? The preview domain's apex and wildcard CNAMEs (Cloudflare), the docs site a wiki provider asks for, and the relay Worker's proxied placeholder; one row per zone. A missing record, another target or a missing proxy fails; an extra record never does. A record `ensureCustomDomain()` returns is not checked, because asking for it creates the domain |
|
package/dist/cli.mjs
CHANGED
|
@@ -2851,7 +2851,8 @@ const ENVIRONMENT_LAYERS = [
|
|
|
2851
2851
|
"local",
|
|
2852
2852
|
"dev",
|
|
2853
2853
|
"ci",
|
|
2854
|
-
"prod"
|
|
2854
|
+
"prod",
|
|
2855
|
+
"preview"
|
|
2855
2856
|
];
|
|
2856
2857
|
/** Whether `value` is exactly one of the layer words (case-sensitive: `Prod` is a literal Environment name). */
|
|
2857
2858
|
function isEnvironmentLayer(value) {
|
|
@@ -2915,8 +2916,8 @@ const COMMIT_TYPES = [
|
|
|
2915
2916
|
"style",
|
|
2916
2917
|
"revert"
|
|
2917
2918
|
];
|
|
2918
|
-
const isObject$
|
|
2919
|
-
const KEYS$
|
|
2919
|
+
const isObject$4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2920
|
+
const KEYS$2 = [
|
|
2920
2921
|
"name",
|
|
2921
2922
|
"description",
|
|
2922
2923
|
"color",
|
|
@@ -2935,8 +2936,8 @@ function validateIssueTypes(value, at = "issueTypes") {
|
|
|
2935
2936
|
const seen = /* @__PURE__ */ new Set();
|
|
2936
2937
|
return value.map((entry, index) => {
|
|
2937
2938
|
const where = `${at}[${index}]`;
|
|
2938
|
-
if (!isObject$
|
|
2939
|
-
for (const key of Object.keys(entry)) if (!KEYS$
|
|
2939
|
+
if (!isObject$4(entry)) throw new ConfigError$1(`${where} must be an object with a "name"`);
|
|
2940
|
+
for (const key of Object.keys(entry)) if (!KEYS$2.includes(key)) throw new ConfigError$1(`${where}: "${key}" is not an issue Type option. Known: ${KEYS$2.join(", ")}`);
|
|
2940
2941
|
const { name, description, color, enabled, label, commit } = entry;
|
|
2941
2942
|
if (typeof name !== "string" || name.trim() === "") throw new ConfigError$1(`${where}: "name" must be a non-empty string`);
|
|
2942
2943
|
const key = name.trim().toLowerCase();
|
|
@@ -2956,6 +2957,66 @@ function validateIssueTypes(value, at = "issueTypes") {
|
|
|
2956
2957
|
};
|
|
2957
2958
|
});
|
|
2958
2959
|
}
|
|
2960
|
+
/** GitHub's longest wait timer: 30 days, in minutes. */
|
|
2961
|
+
const MAX_WAIT_TIMER = 43200;
|
|
2962
|
+
const KEYS$1 = /* @__PURE__ */ new Set([
|
|
2963
|
+
"name",
|
|
2964
|
+
"reviewers",
|
|
2965
|
+
"waitTimer",
|
|
2966
|
+
"preventSelfReview"
|
|
2967
|
+
]);
|
|
2968
|
+
const REVIEWER_KEYS = /* @__PURE__ */ new Set(["type", "id"]);
|
|
2969
|
+
const isObject$3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2970
|
+
/** Checks one reviewer of the Environment spelled `named`, and records it in `seen` so none is listed twice. */
|
|
2971
|
+
function validateReviewer(raw, named, seen) {
|
|
2972
|
+
if (!isObject$3(raw)) throw new ConfigError$1(`${named}: a reviewer must be an object`);
|
|
2973
|
+
const extra = Object.keys(raw).find((key) => !REVIEWER_KEYS.has(key));
|
|
2974
|
+
if (extra !== void 0) throw new ConfigError$1(`${named}: a reviewer has no \`${extra}\` (a numeric \`id\`, not a login)`);
|
|
2975
|
+
const { type, id } = raw;
|
|
2976
|
+
if (type !== "User" && type !== "Team") throw new ConfigError$1(`${named}: a reviewer's \`type\` is "User" or "Team"`);
|
|
2977
|
+
if (typeof id !== "number" || !Number.isInteger(id) || id <= 0) throw new ConfigError$1(`${named}: a reviewer's \`id\` is GitHub's numeric id, a positive whole number`);
|
|
2978
|
+
const key = `${type}:${id}`;
|
|
2979
|
+
if (seen.has(key)) throw new ConfigError$1(`${named}: reviewer ${key} is listed twice`);
|
|
2980
|
+
seen.add(key);
|
|
2981
|
+
}
|
|
2982
|
+
/** Checks one entry of `repo.environments`, which is at position `index` and whose name is not yet in `seen`. */
|
|
2983
|
+
function validateEntry(raw, index, seen) {
|
|
2984
|
+
const at = `\`repo.environments[${index}]\``;
|
|
2985
|
+
if (!isObject$3(raw)) throw new ConfigError$1(`${at} must be an object`);
|
|
2986
|
+
const unknown = Object.keys(raw).find((key) => !KEYS$1.has(key));
|
|
2987
|
+
if (unknown !== void 0) throw new ConfigError$1(`${at} has no \`${unknown}\` (use ${[...KEYS$1].map((k) => `\`${k}\``).join(", ")})`);
|
|
2988
|
+
const { name, waitTimer, preventSelfReview, reviewers } = raw;
|
|
2989
|
+
if (typeof name !== "string" || name.trim() === "") throw new ConfigError$1(`${at} needs a \`name\``);
|
|
2990
|
+
const lower = name.toLowerCase();
|
|
2991
|
+
if (seen.has(lower)) throw new ConfigError$1(`${at}: ${JSON.stringify(name)} is declared twice (names ignore case)`);
|
|
2992
|
+
seen.add(lower);
|
|
2993
|
+
const named = `\`repo.environments[${name}]\``;
|
|
2994
|
+
if (waitTimer !== void 0) {
|
|
2995
|
+
if (typeof waitTimer !== "number" || !Number.isInteger(waitTimer) || waitTimer < 0 || waitTimer > 43200) throw new ConfigError$1(`${named}: \`waitTimer\` is a whole number of minutes from 0 to ${MAX_WAIT_TIMER}`);
|
|
2996
|
+
}
|
|
2997
|
+
if (preventSelfReview !== void 0 && typeof preventSelfReview !== "boolean") throw new ConfigError$1(`${named}: \`preventSelfReview\` is true or false`);
|
|
2998
|
+
if (reviewers === void 0) return;
|
|
2999
|
+
if (!Array.isArray(reviewers)) throw new ConfigError$1(`${named}: \`reviewers\` must be a list`);
|
|
3000
|
+
const list = reviewers;
|
|
3001
|
+
if (list.length > 6) throw new ConfigError$1(`${named}: GitHub allows at most 6 reviewers, got ${list.length}`);
|
|
3002
|
+
const seenReviewers = /* @__PURE__ */ new Set();
|
|
3003
|
+
for (const reviewer of list) validateReviewer(reviewer, named, seenReviewers);
|
|
3004
|
+
}
|
|
3005
|
+
/**
|
|
3006
|
+
* Check `repo.environments` (#2674): each entry names an Environment once (names ignore case) and uses only the keys of
|
|
3007
|
+
* `RepoEnvironment`; a reviewer is a `User` or a `Team` with a positive whole `id` (a login would be ignored by GitHub),
|
|
3008
|
+
* at most six and none twice; `waitTimer` is a whole number of minutes from 0 to 43200; `preventSelfReview` is a boolean.
|
|
3009
|
+
*
|
|
3010
|
+
* @param environments - `repo.environments`, if the config has it.
|
|
3011
|
+
* @throws {ConfigError} Naming the path of the first problem found.
|
|
3012
|
+
*/
|
|
3013
|
+
function validateRepoEnvironments(environments) {
|
|
3014
|
+
if (environments === void 0) return;
|
|
3015
|
+
const list = environments;
|
|
3016
|
+
if (!Array.isArray(list)) throw new ConfigError$1("`repo.environments` must be a list");
|
|
3017
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3018
|
+
list.forEach((entry, index) => validateEntry(entry, index, seen));
|
|
3019
|
+
}
|
|
2959
3020
|
// src/config/validate-repo-labels/validate-repo-labels.ts
|
|
2960
3021
|
/** What an area name may be: the rest of `area:<name>`, so no colon, comma, space or leading symbol. */
|
|
2961
3022
|
const AREA_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
@@ -3336,6 +3397,7 @@ function resolveConfig(raw) {
|
|
|
3336
3397
|
if (raw.ideas !== void 0) validateIdeas(raw.ideas);
|
|
3337
3398
|
if (raw.issueTypes !== void 0) validateIssueTypes(raw.issueTypes);
|
|
3338
3399
|
validateRepoLabels(raw.repo?.labels);
|
|
3400
|
+
validateRepoEnvironments(raw.repo?.environments);
|
|
3339
3401
|
validateRequiredChecks(raw.repo?.requiredChecks);
|
|
3340
3402
|
validateVariablesSync(raw.repo?.variables);
|
|
3341
3403
|
validateSecretsDeploy(raw.repo?.secrets);
|
|
@@ -10208,7 +10270,12 @@ function stageDeploy(input) {
|
|
|
10208
10270
|
copyFileSync(join(packageDir, "api", "webhook.mjs"), join(outDir, "api", "webhook.mjs"));
|
|
10209
10271
|
for (const entry of readdirSync(join(packageDir, "api")).filter((f) => f.endsWith(".mjs") && f !== "webhook.mjs")) copyFileSync(join(packageDir, "api", entry), join(outDir, "api", entry));
|
|
10210
10272
|
copyFileSync(distIndex, join(outDir, "dist", "index.mjs"));
|
|
10211
|
-
|
|
10273
|
+
if (input.omitCrons) {
|
|
10274
|
+
const vercelConfig = JSON.parse(readFileSync(join(packageDir, "vercel.json"), "utf8"));
|
|
10275
|
+
delete vercelConfig.crons;
|
|
10276
|
+
writeFileSync(join(outDir, "vercel.json"), stringifyJson(vercelConfig));
|
|
10277
|
+
print(" left the crons out of vercel.json");
|
|
10278
|
+
} else copyFileSync(join(packageDir, "vercel.json"), join(outDir, "vercel.json"));
|
|
10212
10279
|
const deployPkg = {
|
|
10213
10280
|
name: pkg.name,
|
|
10214
10281
|
version: pkg.version,
|
|
@@ -10308,6 +10375,62 @@ async function checkProjectDomain(deployment, project, domain) {
|
|
|
10308
10375
|
message: `${deployment.providerName} project "${project}" does not serve ${domain} (it serves ${served.length ? served.join(", ") : "no domain"}); nothing was written`
|
|
10309
10376
|
};
|
|
10310
10377
|
}
|
|
10378
|
+
// src/commands/preview-instance/preview-instance.ts
|
|
10379
|
+
/**
|
|
10380
|
+
* The preview instance an app declares in its `deployment` options (`instances: { preview: { project, domain } }`), or
|
|
10381
|
+
* `undefined` when it declares none (spec `tech-sentinel-preview-instance`). The one reading of the declaration, shared by
|
|
10382
|
+
* `deploy`, `sync` and `setup`.
|
|
10383
|
+
*
|
|
10384
|
+
* @param app - The app's name, for the message.
|
|
10385
|
+
* @param options - The `deployment` provider's options from the app's config.
|
|
10386
|
+
* @throws {ConfigError} For an `instances.preview` that is not an object with a `project` name.
|
|
10387
|
+
*/
|
|
10388
|
+
function previewInstance(app, options) {
|
|
10389
|
+
const instances = options.instances;
|
|
10390
|
+
const declared = instances && typeof instances === "object" ? instances.preview : void 0;
|
|
10391
|
+
if (declared === void 0) return void 0;
|
|
10392
|
+
if (!declared || typeof declared !== "object") throw new ConfigError$1(`${app}: \`deployment\` option \`instances.preview\` must be an object with a \`project\``);
|
|
10393
|
+
const { project, domain } = declared;
|
|
10394
|
+
if (typeof project !== "string" || project === "") throw new ConfigError$1(`${app}: \`instances.preview\` needs a \`project\` name`);
|
|
10395
|
+
return {
|
|
10396
|
+
project,
|
|
10397
|
+
...typeof domain === "string" ? { domain } : {}
|
|
10398
|
+
};
|
|
10399
|
+
}
|
|
10400
|
+
// src/commands/app-instance/app-instance.ts
|
|
10401
|
+
/**
|
|
10402
|
+
* The project, domain and deployment target an app's `--env` target goes to. `production` is the project named like the
|
|
10403
|
+
* app, as its production target. `preview` is the instance the app declares in its `deployment` options
|
|
10404
|
+
* (`instances: { preview: { project, domain } }`): a project of its own, deployed as that project's production target
|
|
10405
|
+
* with the `crons` left out of its `vercel.json`, because the crons belong to production. An app that declares no preview
|
|
10406
|
+
* instance keeps the earlier meaning: a Vercel preview deployment of its one project.
|
|
10407
|
+
*
|
|
10408
|
+
* @param app - The app folder's name.
|
|
10409
|
+
* @param options - The `deployment` provider's options from the app's config.
|
|
10410
|
+
* @param target - The target `--env` named.
|
|
10411
|
+
* @throws {ConfigError} For an `instances.preview` that is not an object with a `project` name.
|
|
10412
|
+
*/
|
|
10413
|
+
function appInstance(app, options, target) {
|
|
10414
|
+
const domain = typeof options.domain === "string" ? { domain: options.domain } : {};
|
|
10415
|
+
if (target === "production") return {
|
|
10416
|
+
project: app,
|
|
10417
|
+
...domain,
|
|
10418
|
+
production: true,
|
|
10419
|
+
omitCrons: false
|
|
10420
|
+
};
|
|
10421
|
+
const declared = previewInstance(app, options);
|
|
10422
|
+
if (!declared) return {
|
|
10423
|
+
project: app,
|
|
10424
|
+
...domain,
|
|
10425
|
+
production: false,
|
|
10426
|
+
omitCrons: false
|
|
10427
|
+
};
|
|
10428
|
+
return {
|
|
10429
|
+
...declared,
|
|
10430
|
+
production: true,
|
|
10431
|
+
omitCrons: true
|
|
10432
|
+
};
|
|
10433
|
+
}
|
|
10311
10434
|
// src/commands/app-plan/app-plan.ts
|
|
10312
10435
|
/**
|
|
10313
10436
|
* Reads what an app's own config declares: its `deployment` and `workers` providers and whether `repo.secrets.deploy`
|
|
@@ -10328,9 +10451,10 @@ function appPlan(config) {
|
|
|
10328
10451
|
}
|
|
10329
10452
|
// src/commands/app-deploy/app-deploy.ts
|
|
10330
10453
|
/**
|
|
10331
|
-
* `holocron deploy <app> --env <env>`: builds the app, stages it and deploys the staged files
|
|
10332
|
-
*
|
|
10333
|
-
*
|
|
10454
|
+
* `holocron deploy <app> --env <env>`: builds the app, stages it and deploys the staged files, once for each environment
|
|
10455
|
+
* `--env` names (production, then preview). Production goes to the project that takes the app folder's name; preview goes
|
|
10456
|
+
* to the instance the app declares (`appInstance()`: a project of its own, its crons left out), or to a preview deployment
|
|
10457
|
+
* of the same project when it declares none. Before anything is written every project must serve its configured `domain`. An app with no `deployment` provider has nothing to deploy and is
|
|
10334
10458
|
* reported, not failed (Comlink's Worker is made by `setup notifications`; Council is installed by hand).
|
|
10335
10459
|
*
|
|
10336
10460
|
* @param input - The app, the environment, its loaded config and the seams tests replace.
|
|
@@ -10360,12 +10484,23 @@ async function runAppDeploy(input) {
|
|
|
10360
10484
|
print(style.header(`Holocron deploy ${app.name} → ${env.targets.join(" + ")}${dryRun ? " (dry-run)" : ""}`));
|
|
10361
10485
|
await loader.load();
|
|
10362
10486
|
if (!loader.has("deployment")) return fail(`${app.name}: the deployment provider did not load`);
|
|
10363
|
-
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10487
|
+
let instances;
|
|
10488
|
+
try {
|
|
10489
|
+
instances = env.targets.map((target) => ({
|
|
10490
|
+
target,
|
|
10491
|
+
instance: appInstance(app.name, plan.deployment.options, target)
|
|
10492
|
+
}));
|
|
10493
|
+
} catch (err) {
|
|
10494
|
+
return fail(errorMessage(err));
|
|
10495
|
+
}
|
|
10496
|
+
for (const { instance } of instances) {
|
|
10497
|
+
const checked = await checkProjectDomain(loader.get("deployment"), instance.project, instance.domain);
|
|
10498
|
+
if (checked.status === "fail") return fail(checked.message);
|
|
10499
|
+
print(` ${style.dim(checked.message)}`);
|
|
10500
|
+
}
|
|
10367
10501
|
if (dryRun) {
|
|
10368
|
-
const
|
|
10502
|
+
const where = instances.map(({ target, instance }) => `${instance.project} (${target})`).join(" + ");
|
|
10503
|
+
const message = `would: build and stage ${app.path}, then deploy it to ${where}`;
|
|
10369
10504
|
print(` ${style.dim(`… ${message}`)}`);
|
|
10370
10505
|
return {
|
|
10371
10506
|
status: "dry-run",
|
|
@@ -10374,18 +10509,28 @@ async function runAppDeploy(input) {
|
|
|
10374
10509
|
}
|
|
10375
10510
|
const built = input.build(app.dir);
|
|
10376
10511
|
if (built.status === "fail") return fail(built.message);
|
|
10377
|
-
const staged =
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10512
|
+
const staged = /* @__PURE__ */ new Map();
|
|
10513
|
+
for (const { target, instance } of instances) {
|
|
10514
|
+
let dir = staged.get(instance.omitCrons);
|
|
10515
|
+
if (!dir) {
|
|
10516
|
+
const result = input.stage({
|
|
10517
|
+
packageDir: app.dir,
|
|
10518
|
+
print,
|
|
10519
|
+
...instance.omitCrons ? {
|
|
10520
|
+
omitCrons: true,
|
|
10521
|
+
outDir: join(app.dir, ".vercel-deploy-preview")
|
|
10522
|
+
} : {}
|
|
10523
|
+
});
|
|
10524
|
+
if (result.status === "fail" || !result.outDir) return fail(`stage: ${result.message ?? "no payload was made"}`);
|
|
10525
|
+
dir = result.outDir;
|
|
10526
|
+
staged.set(instance.omitCrons, dir);
|
|
10527
|
+
}
|
|
10383
10528
|
const report = await input.deployFiles({
|
|
10384
10529
|
loaded,
|
|
10385
10530
|
context,
|
|
10386
|
-
projectId:
|
|
10387
|
-
dir
|
|
10388
|
-
...
|
|
10531
|
+
projectId: instance.project,
|
|
10532
|
+
dir,
|
|
10533
|
+
...instance.production ? { target: "production" } : {},
|
|
10389
10534
|
loader,
|
|
10390
10535
|
print
|
|
10391
10536
|
});
|
|
@@ -10402,7 +10547,8 @@ const APP_TARGETS = ["production", "preview"];
|
|
|
10402
10547
|
/**
|
|
10403
10548
|
* Reads the `--env` of `deploy <app>` and `sync <app>`: the standard environments of `@theholocron/env-utils`
|
|
10404
10549
|
* (`environment.normalize()`, so `prod` is `production`), the flag repeated for more than one. An app is deployed to
|
|
10405
|
-
* `production` and `preview`;
|
|
10550
|
+
* `production` and `preview`; production takes its secrets from the `prod` vault layer and preview from the `preview`
|
|
10551
|
+
* layer (`appLayer()`), with no fallback between them. Any other environment is refused with
|
|
10406
10552
|
* the reason: `local`, `development` and `ci` are never synced or deployed to, and `test` has no deployment target.
|
|
10407
10553
|
*
|
|
10408
10554
|
* @param values - The `--env` (or `--environment`) values, one or several.
|
|
@@ -10418,10 +10564,7 @@ function parseAppEnv(values) {
|
|
|
10418
10564
|
if (normalized !== "production" && normalized !== "preview") throw new ConfigError$1(`--env ${value} is not an environment an app is deployed or synced to (accepted: ${APP_TARGETS.join(", ")}); \`sync secrets --env ci\` fills GitHub Actions`);
|
|
10419
10565
|
wanted.add(normalized);
|
|
10420
10566
|
}
|
|
10421
|
-
return {
|
|
10422
|
-
layer: "prod",
|
|
10423
|
-
targets: APP_TARGETS.filter((target) => wanted.has(target))
|
|
10424
|
-
};
|
|
10567
|
+
return { targets: APP_TARGETS.filter((target) => wanted.has(target)) };
|
|
10425
10568
|
}
|
|
10426
10569
|
// src/commands/build-app/build-app.ts
|
|
10427
10570
|
/**
|
|
@@ -12711,9 +12854,56 @@ const doctorDnsCommand = {
|
|
|
12711
12854
|
})).status === "fail") process.exitCode = 1;
|
|
12712
12855
|
}
|
|
12713
12856
|
};
|
|
12714
|
-
// src/commands/setup/
|
|
12715
|
-
/**
|
|
12716
|
-
|
|
12857
|
+
// src/commands/setup/declared-environments/declared-environments.ts
|
|
12858
|
+
/**
|
|
12859
|
+
* The Environments `setup` makes and `doctor environments` expects: the ones `repo.environments` declares, and no
|
|
12860
|
+
* others (#2674). Each carries only the settings that were written, so a setting left out is never changed. `setup` used to
|
|
12861
|
+
* make a fixed pair, `staging` and `production`, in every repository whether or not a job used them; it makes only what a
|
|
12862
|
+
* repository declares now, and never deletes one that exists.
|
|
12863
|
+
*
|
|
12864
|
+
* @param declared - `repo.environments`, if the config has it.
|
|
12865
|
+
*/
|
|
12866
|
+
function declaredEnvironments(declared) {
|
|
12867
|
+
return (declared ?? []).map((entry) => ({
|
|
12868
|
+
name: entry.name,
|
|
12869
|
+
...entry.reviewers !== void 0 ? { reviewers: entry.reviewers.map(({ type, id }) => ({
|
|
12870
|
+
type,
|
|
12871
|
+
id
|
|
12872
|
+
})) } : {},
|
|
12873
|
+
...entry.waitTimer !== void 0 ? { waitTimer: entry.waitTimer } : {},
|
|
12874
|
+
...entry.preventSelfReview !== void 0 ? { preventSelfReview: entry.preventSelfReview } : {}
|
|
12875
|
+
}));
|
|
12876
|
+
}
|
|
12877
|
+
// src/commands/doctor-environments/environment-problems/environment-problems.ts
|
|
12878
|
+
const spell = (reviewer) => `${reviewer.type}:${reviewer.id}`;
|
|
12879
|
+
/**
|
|
12880
|
+
* Where the Environments that exist differ from the ones `repo.environments` declares (#2674): a reviewer missing or
|
|
12881
|
+
* extra, a different wait timer, a different self-review rule. Only a setting the declaration writes is compared, so one
|
|
12882
|
+
* left out is never a problem, and an Environment that is missing altogether is the existence check's to report.
|
|
12883
|
+
*
|
|
12884
|
+
* @param declared - `repo.environments`.
|
|
12885
|
+
* @param have - What the provider lists.
|
|
12886
|
+
* @returns One line per difference, naming the Environment; empty when everything declared holds.
|
|
12887
|
+
*/
|
|
12888
|
+
function environmentProblems(declared, have) {
|
|
12889
|
+
const byName = new Map(have.map((env) => [env.name.toLowerCase(), env]));
|
|
12890
|
+
const problems = [];
|
|
12891
|
+
for (const want of declared) {
|
|
12892
|
+
const actual = byName.get(want.name.toLowerCase());
|
|
12893
|
+
if (!actual) continue;
|
|
12894
|
+
if (want.reviewers !== void 0) {
|
|
12895
|
+
const wanted = new Set(want.reviewers.map(spell));
|
|
12896
|
+
const found = new Set((actual.reviewers ?? []).map(spell));
|
|
12897
|
+
const missing = [...wanted].filter((key) => !found.has(key));
|
|
12898
|
+
const extra = [...found].filter((key) => !wanted.has(key));
|
|
12899
|
+
if (missing.length > 0) problems.push(`${want.name}: required reviewers lack ${missing.join(", ")}`);
|
|
12900
|
+
if (extra.length > 0) problems.push(`${want.name}: required reviewers have ${extra.join(", ")}, which the config does not declare`);
|
|
12901
|
+
}
|
|
12902
|
+
if (want.waitTimer !== void 0 && (actual.waitTimer ?? 0) !== want.waitTimer) problems.push(`${want.name}: wait timer is ${actual.waitTimer ?? 0} minutes, the config says ${want.waitTimer}`);
|
|
12903
|
+
if (want.preventSelfReview !== void 0 && (actual.preventSelfReview ?? false) !== want.preventSelfReview) problems.push(`${want.name}: prevent self-review is ${actual.preventSelfReview ?? false}, the config says ${want.preventSelfReview}`);
|
|
12904
|
+
}
|
|
12905
|
+
return problems;
|
|
12906
|
+
}
|
|
12717
12907
|
// src/commands/doctor-environments/doctor-environments.ts
|
|
12718
12908
|
/**
|
|
12719
12909
|
* `holocron doctor environments` — do the deployment environments the config relies on exist?
|
|
@@ -12731,7 +12921,7 @@ async function runDoctorEnvironments(input) {
|
|
|
12731
12921
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
12732
12922
|
await loader.load();
|
|
12733
12923
|
assertPluginsResolvable(loader, "doctor environments");
|
|
12734
|
-
const row = await checkEnvironments(loader, Object.keys(input.loaded.resolved.repo?.secrets?.environments ?? {}));
|
|
12924
|
+
const row = await checkEnvironments(loader, Object.keys(input.loaded.resolved.repo?.secrets?.environments ?? {}), input.loaded.resolved.repo?.environments ?? []);
|
|
12735
12925
|
printCheckRows([row], print);
|
|
12736
12926
|
const summary = summariseChecks([row]);
|
|
12737
12927
|
printCheckSummary(summary, print);
|
|
@@ -12746,7 +12936,7 @@ async function runDoctorEnvironments(input) {
|
|
|
12746
12936
|
...row.status === "skip" ? { reason: row.detail } : {}
|
|
12747
12937
|
};
|
|
12748
12938
|
}
|
|
12749
|
-
async function checkEnvironments(loader, named) {
|
|
12939
|
+
async function checkEnvironments(loader, named, declared) {
|
|
12750
12940
|
const make = (status, detail, problems = []) => ({
|
|
12751
12941
|
id: ID$6,
|
|
12752
12942
|
title: TITLE$6,
|
|
@@ -12754,14 +12944,15 @@ async function checkEnvironments(loader, named) {
|
|
|
12754
12944
|
detail,
|
|
12755
12945
|
problems
|
|
12756
12946
|
});
|
|
12757
|
-
|
|
12758
|
-
|
|
12947
|
+
const names = [...new Set([...declaredEnvironments(declared).map((env) => env.name), ...named].map((n) => n.toLowerCase()))];
|
|
12948
|
+
if (names.length === 0) return make("ok", "none declared");
|
|
12949
|
+
if (!loader.has("environments")) return make("skip", whyMissing(loader, "environments", "no `environments` provider to check them with"));
|
|
12759
12950
|
try {
|
|
12760
12951
|
const have = await loader.get("environments").listEnvironments();
|
|
12761
|
-
const problems = declaredVsActual(new Map(names.map((name) => [name, true])), new Map(have.map((env) => [env.name.toLowerCase(), true])), {
|
|
12952
|
+
const problems = [...declaredVsActual(new Map(names.map((name) => [name, true])), new Map(have.map((env) => [env.name.toLowerCase(), true])), {
|
|
12762
12953
|
noun: "environment",
|
|
12763
12954
|
flagExtra: false
|
|
12764
|
-
});
|
|
12955
|
+
}), ...environmentProblems(declared, have)];
|
|
12765
12956
|
return problems.length > 0 ? make("fail", `${problems.length} problem(s)`, problems) : make("ok", `${names.length} of ${names.length} exist`);
|
|
12766
12957
|
} catch (err) {
|
|
12767
12958
|
const noToken = missingTokenReason(err);
|
|
@@ -19282,7 +19473,7 @@ async function readLayers(vault, slug, layers = ENVIRONMENT_LAYERS) {
|
|
|
19282
19473
|
blind = true;
|
|
19283
19474
|
}
|
|
19284
19475
|
} catch (err) {
|
|
19285
|
-
if (layer === "local") continue;
|
|
19476
|
+
if (layer === "local" || layer === "preview") continue;
|
|
19286
19477
|
rows.push({
|
|
19287
19478
|
id: `skip:${layer}`,
|
|
19288
19479
|
title: `Environment "${environment}"`,
|
|
@@ -19832,7 +20023,7 @@ async function runDoctorSecrets(input) {
|
|
|
19832
20023
|
}
|
|
19833
20024
|
if (input.shared) {
|
|
19834
20025
|
ran = true;
|
|
19835
|
-
const layers = ENVIRONMENT_LAYERS.filter((layer) => wants(layer));
|
|
20026
|
+
const layers = ENVIRONMENT_LAYERS.filter((layer) => layer !== "preview" && wants(layer));
|
|
19836
20027
|
if (layers.length < 2) rows.push({
|
|
19837
20028
|
id: "shared:layers",
|
|
19838
20029
|
title: "compare the layers",
|
|
@@ -24341,9 +24532,9 @@ async function runSetup(input) {
|
|
|
24341
24532
|
if (loader.has("environments")) {
|
|
24342
24533
|
const envs = loader.get("environments");
|
|
24343
24534
|
print(style.step("environments"));
|
|
24344
|
-
for (const
|
|
24345
|
-
steps.push(await runStep("environments", `upsert ${
|
|
24346
|
-
await envs.upsertEnvironment(
|
|
24535
|
+
for (const environment of declaredEnvironments(config.repo?.environments)) {
|
|
24536
|
+
steps.push(await runStep("environments", `upsert ${environment.name}`, dryRun, async () => {
|
|
24537
|
+
await envs.upsertEnvironment(environment);
|
|
24347
24538
|
}));
|
|
24348
24539
|
print(formatStep(steps[steps.length - 1]));
|
|
24349
24540
|
}
|
|
@@ -24445,6 +24636,15 @@ async function runSetup(input) {
|
|
|
24445
24636
|
print(formatStep(steps[steps.length - 1]));
|
|
24446
24637
|
}
|
|
24447
24638
|
if (previewCfg?.domain) await ensureCustomDomain(previewCfg.project, previewCfg.domain);
|
|
24639
|
+
const { options: deploymentOptions } = config.providers.deployment.tuple;
|
|
24640
|
+
const instance = previewInstance(config.name, deploymentOptions);
|
|
24641
|
+
if (instance) {
|
|
24642
|
+
steps.push(await runStep("deployment", `ensureProject ${instance.project}`, dryRun, async () => {
|
|
24643
|
+
await deploy.ensureProject({ name: instance.project });
|
|
24644
|
+
}));
|
|
24645
|
+
print(formatStep(steps[steps.length - 1]));
|
|
24646
|
+
if (instance.domain) await ensureCustomDomain(instance.project, instance.domain);
|
|
24647
|
+
}
|
|
24448
24648
|
if (previewCfg?.domain && deploy.providerName === "cloudflare" && loader.has("dns")) {
|
|
24449
24649
|
const dns = loader.get("dns");
|
|
24450
24650
|
const wildcardDomain = `*.${previewCfg.domain}`;
|
|
@@ -38349,12 +38549,22 @@ const syncArgs = (y) => y.positional("steps", {
|
|
|
38349
38549
|
global: false,
|
|
38350
38550
|
describe: "Repo coords (\"owner/name\"). Defaults to plugin-specific resolution."
|
|
38351
38551
|
});
|
|
38552
|
+
// src/commands/app-layer/app-layer.ts
|
|
38553
|
+
/**
|
|
38554
|
+
* The vault layer an app's secrets for a deployment target are read from: `production` reads `prod` and `preview` reads
|
|
38555
|
+
* its own `preview` layer, never `prod` (spec `tech-sentinel-preview-instance`), so a preview deployment is given only
|
|
38556
|
+
* what its own Environment holds.
|
|
38557
|
+
*/
|
|
38558
|
+
function appLayer(target) {
|
|
38559
|
+
return target === "production" ? "prod" : "preview";
|
|
38560
|
+
}
|
|
38352
38561
|
// src/commands/app-sync/app-sync.ts
|
|
38353
38562
|
/**
|
|
38354
|
-
* `holocron sync <app> --env <env>`: reads the app's vault Environment of
|
|
38355
|
-
* `
|
|
38356
|
-
*
|
|
38357
|
-
* a `
|
|
38563
|
+
* `holocron sync <app> --env <env>`: reads the app's vault Environment of each target's layer (`prod` for production,
|
|
38564
|
+
* `preview` for preview, never one for the other) and sends the secrets `repo.secrets.deploy` names for that layer to the
|
|
38565
|
+
* app's destinations, the way `sync secrets --project-id <app> --target <target>` or `--worker <app>` would: the Vercel
|
|
38566
|
+
* project when the app has a `deployment` provider, the Worker script when it has a `workers` provider, both named after
|
|
38567
|
+
* the app folder. Before anything is written the project must serve the app's
|
|
38358
38568
|
* configured `domain`. An app with neither destination has nothing to sync and is reported, not failed.
|
|
38359
38569
|
*
|
|
38360
38570
|
* @param input - The app, the environment, its loaded config and the seams tests replace.
|
|
@@ -38383,41 +38593,57 @@ async function runAppSync(input) {
|
|
|
38383
38593
|
const { loaded, context, loader } = await input.load();
|
|
38384
38594
|
const destinations = [plan.deployment ? `${app.name} (project)` : "", plan.workers ? `${app.name} (Worker)` : ""];
|
|
38385
38595
|
print(style.header(`Holocron sync ${app.name} → ${destinations.filter(Boolean).join(" + ")}${context.dryRun ? " (dry-run)" : ""}`));
|
|
38596
|
+
const instances = /* @__PURE__ */ new Map();
|
|
38386
38597
|
if (plan.deployment) {
|
|
38387
38598
|
await loader.load();
|
|
38388
38599
|
if (!loader.has("deployment")) return fail(`${app.name}: the deployment provider did not load`);
|
|
38389
|
-
|
|
38390
|
-
|
|
38391
|
-
|
|
38392
|
-
|
|
38600
|
+
try {
|
|
38601
|
+
for (const target of env.targets) instances.set(target, appInstance(app.name, plan.deployment.options, target));
|
|
38602
|
+
} catch (err) {
|
|
38603
|
+
return fail(errorMessage(err));
|
|
38604
|
+
}
|
|
38605
|
+
for (const instance of instances.values()) {
|
|
38606
|
+
const checked = await checkProjectDomain(loader.get("deployment"), instance.project, instance.domain);
|
|
38607
|
+
if (checked.status === "fail") return fail(checked.message);
|
|
38608
|
+
print(` ${style.dim(checked.message)}`);
|
|
38609
|
+
}
|
|
38393
38610
|
}
|
|
38394
|
-
const environment = await input.resolveEnvironment(env.layer);
|
|
38395
38611
|
const resolved = loaded.resolved;
|
|
38396
|
-
const
|
|
38397
|
-
|
|
38398
|
-
|
|
38399
|
-
const
|
|
38400
|
-
|
|
38401
|
-
|
|
38402
|
-
|
|
38403
|
-
|
|
38404
|
-
|
|
38405
|
-
|
|
38406
|
-
|
|
38407
|
-
|
|
38408
|
-
|
|
38409
|
-
|
|
38410
|
-
|
|
38411
|
-
|
|
38412
|
-
|
|
38413
|
-
|
|
38414
|
-
|
|
38612
|
+
const failed = [];
|
|
38613
|
+
let written = 0;
|
|
38614
|
+
let skipped = 0;
|
|
38615
|
+
for (const target of env.targets) {
|
|
38616
|
+
const environment = await input.resolveEnvironment(appLayer(target));
|
|
38617
|
+
const instance = instances.get(target);
|
|
38618
|
+
const routes = secretRoutes(resolved.repo?.secrets?.sync, environment);
|
|
38619
|
+
const variables = variableRoutes(resolved.repo?.variables?.sync, environment);
|
|
38620
|
+
const variablesOnly = variables.length > 0 && routes.length === 0;
|
|
38621
|
+
const filter = deployFilter(resolved.repo?.secrets?.deploy, environment);
|
|
38622
|
+
const report = await input.syncSecrets({
|
|
38623
|
+
loaded,
|
|
38624
|
+
context,
|
|
38625
|
+
loader,
|
|
38626
|
+
environmentId: environment,
|
|
38627
|
+
...instance ? {
|
|
38628
|
+
projectId: instance.project,
|
|
38629
|
+
targets: [instance.production ? "production" : target]
|
|
38630
|
+
} : {},
|
|
38631
|
+
...plan.workers ? { workerScript: app.name } : {},
|
|
38632
|
+
...filter ? { deployFilter: filter } : {},
|
|
38633
|
+
...routes.length ? { secretRoutes: routes } : variablesOnly ? { secretRoutes: [] } : {},
|
|
38634
|
+
...variables.length ? { variableRoutes: variables } : {}
|
|
38635
|
+
});
|
|
38636
|
+
written += report.summary.ok;
|
|
38637
|
+
skipped += report.summary.skip;
|
|
38638
|
+
if (report.summary.fail > 0) failed.push(`${target}: ${report.summary.fail} secret(s) did not sync`);
|
|
38639
|
+
}
|
|
38640
|
+
if (failed.length > 0) return {
|
|
38415
38641
|
status: "fail",
|
|
38416
|
-
message: `${app.name}: ${
|
|
38642
|
+
message: `${app.name}: ${failed.join("; ")}`
|
|
38417
38643
|
};
|
|
38418
38644
|
return {
|
|
38419
38645
|
status: "ok",
|
|
38420
|
-
message: `${app.name} synced (${
|
|
38646
|
+
message: `${app.name} synced (${written} written, ${skipped} skipped)`
|
|
38421
38647
|
};
|
|
38422
38648
|
}
|
|
38423
38649
|
// src/commands/sync/sync-app.ts
|