@theholocron/cli 5.0.0-alpha.365 → 5.0.0-alpha.367

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/dist/cli.mjs CHANGED
@@ -1533,10 +1533,11 @@ async function checkToken(token, module, env, readToken, now) {
1533
1533
  const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
1534
1534
  const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
1535
1535
  if (!value) return row$8(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron auth set ${keyringKey}\`)`);
1536
- if (!module.verifyToken || token.verifiable === false) return row$8(keyringKey, "skip", "set, but its plugin cannot verify it");
1536
+ const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
1537
+ if (!verify) return row$8(keyringKey, "skip", "set, but its plugin cannot verify it");
1537
1538
  const from = fromEnv ?? stored?.source ?? "keyring";
1538
1539
  try {
1539
- const verified = await module.verifyToken(value);
1540
+ const verified = await verify(value);
1540
1541
  if (!verified.ok) return row$8(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
1541
1542
  const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
1542
1543
  if (!expiry) return row$8(keyringKey, "ok", `${verified.subject} (${from})`);
@@ -21497,6 +21498,22 @@ function secretRoutes(entries, environmentId) {
21497
21498
  ...entry.keys ? { keys: entry.keys } : {}
21498
21499
  }));
21499
21500
  }
21501
+ // src/commands/secrets-sync/github-name/github-name.ts
21502
+ /**
21503
+ * Why GitHub would refuse `name` as an Actions secret or variable name, or `undefined` when it would accept it.
21504
+ *
21505
+ * GitHub's rules (the same for repository, environment and organization secrets and variables): letters, digits and
21506
+ * underscores only, no spaces, not starting with a digit, and not starting with `GITHUB_` (reserved, in any case).
21507
+ * A name that breaks one gets a bare 422 from the API, which no retry can fix, so the sync checks first.
21508
+ *
21509
+ * @param name - The secret or variable name.
21510
+ */
21511
+ function githubNameProblem(name) {
21512
+ if (name === "") return "GitHub names cannot be empty";
21513
+ if (!/^[A-Za-z0-9_]+$/.test(name)) return "GitHub names may only contain letters, digits and underscores";
21514
+ if (/^[0-9]/.test(name)) return "GitHub names cannot start with a number";
21515
+ if (/^GITHUB_/i.test(name)) return "GitHub reserves names starting with GITHUB_";
21516
+ }
21500
21517
  // src/commands/secrets-sync/restore-pem/restore-pem.ts
21501
21518
  /** A PEM block written on one line: the begin marker, the body, the end marker, with spaces between them. */
21502
21519
  const COLLAPSED = /^(-----BEGIN [A-Z0-9 ]+-----) ([\s\S]+?) (-----END [A-Z0-9 ]+-----)$/;
@@ -21618,7 +21635,7 @@ async function runSecretsSync(input) {
21618
21635
  for (const key of route.keys ?? keys) {
21619
21636
  rows.push(await pushRow(`secrets:${secrets.providerName}`, scopeLabel(route.scope), key, envVars, dryRun, async (value) => {
21620
21637
  await secrets.setSecret(route.scope, key, value);
21621
- }));
21638
+ }, nameCheck(secrets.providerName)));
21622
21639
  print(formatRow(rows[rows.length - 1]));
21623
21640
  }
21624
21641
  }
@@ -21651,7 +21668,7 @@ async function runSecretsSync(input) {
21651
21668
  value,
21652
21669
  visibility: route.visibility ?? "all"
21653
21670
  } }, { prune: false });
21654
- }));
21671
+ }, nameCheck(source.providerName)));
21655
21672
  print(formatRow(rows[rows.length - 1]));
21656
21673
  }
21657
21674
  }
@@ -21741,7 +21758,15 @@ function summarise(rows, logger, print, dryRun) {
21741
21758
  * for a value still to be found, and pushing it would overwrite a working secret with nothing (which no provider can
21742
21759
  * read back to undo). Everything else goes through {@link runRow}.
21743
21760
  */
21744
- async function pushRow(destination, scope, key, envVars, dryRun, body) {
21761
+ async function pushRow(destination, scope, key, envVars, dryRun, body, nameProblem) {
21762
+ const problem = nameProblem?.(key);
21763
+ if (problem) return {
21764
+ destination,
21765
+ scope,
21766
+ key,
21767
+ status: "skip",
21768
+ message: `invalid name: ${problem}`
21769
+ };
21745
21770
  const value = Object.hasOwn(envVars, key) ? envVars[key] : void 0;
21746
21771
  if (value === void 0) return {
21747
21772
  destination,
@@ -21759,6 +21784,10 @@ async function pushRow(destination, scope, key, envVars, dryRun, body) {
21759
21784
  };
21760
21785
  return runRow(destination, scope, key, dryRun, () => body(restorePem(value)));
21761
21786
  }
21787
+ /** The name check for a destination: GitHub's rules when the provider is `github`, none for any other. */
21788
+ function nameCheck(providerName) {
21789
+ return providerName === "github" ? githubNameProblem : void 0;
21790
+ }
21762
21791
  async function runRow(destination, scope, key, dryRun, body) {
21763
21792
  if (dryRun) return {
21764
21793
  destination,