@theholocron/cli 5.0.0-alpha.366 → 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 +31 -3
- package/dist/cli.mjs.map +1 -1
- package/package.json +12 -12
package/dist/cli.mjs
CHANGED
|
@@ -21498,6 +21498,22 @@ function secretRoutes(entries, environmentId) {
|
|
|
21498
21498
|
...entry.keys ? { keys: entry.keys } : {}
|
|
21499
21499
|
}));
|
|
21500
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
|
+
}
|
|
21501
21517
|
// src/commands/secrets-sync/restore-pem/restore-pem.ts
|
|
21502
21518
|
/** A PEM block written on one line: the begin marker, the body, the end marker, with spaces between them. */
|
|
21503
21519
|
const COLLAPSED = /^(-----BEGIN [A-Z0-9 ]+-----) ([\s\S]+?) (-----END [A-Z0-9 ]+-----)$/;
|
|
@@ -21619,7 +21635,7 @@ async function runSecretsSync(input) {
|
|
|
21619
21635
|
for (const key of route.keys ?? keys) {
|
|
21620
21636
|
rows.push(await pushRow(`secrets:${secrets.providerName}`, scopeLabel(route.scope), key, envVars, dryRun, async (value) => {
|
|
21621
21637
|
await secrets.setSecret(route.scope, key, value);
|
|
21622
|
-
}));
|
|
21638
|
+
}, nameCheck(secrets.providerName)));
|
|
21623
21639
|
print(formatRow(rows[rows.length - 1]));
|
|
21624
21640
|
}
|
|
21625
21641
|
}
|
|
@@ -21652,7 +21668,7 @@ async function runSecretsSync(input) {
|
|
|
21652
21668
|
value,
|
|
21653
21669
|
visibility: route.visibility ?? "all"
|
|
21654
21670
|
} }, { prune: false });
|
|
21655
|
-
}));
|
|
21671
|
+
}, nameCheck(source.providerName)));
|
|
21656
21672
|
print(formatRow(rows[rows.length - 1]));
|
|
21657
21673
|
}
|
|
21658
21674
|
}
|
|
@@ -21742,7 +21758,15 @@ function summarise(rows, logger, print, dryRun) {
|
|
|
21742
21758
|
* for a value still to be found, and pushing it would overwrite a working secret with nothing (which no provider can
|
|
21743
21759
|
* read back to undo). Everything else goes through {@link runRow}.
|
|
21744
21760
|
*/
|
|
21745
|
-
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
|
+
};
|
|
21746
21770
|
const value = Object.hasOwn(envVars, key) ? envVars[key] : void 0;
|
|
21747
21771
|
if (value === void 0) return {
|
|
21748
21772
|
destination,
|
|
@@ -21760,6 +21784,10 @@ async function pushRow(destination, scope, key, envVars, dryRun, body) {
|
|
|
21760
21784
|
};
|
|
21761
21785
|
return runRow(destination, scope, key, dryRun, () => body(restorePem(value)));
|
|
21762
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
|
+
}
|
|
21763
21791
|
async function runRow(destination, scope, key, dryRun, body) {
|
|
21764
21792
|
if (dryRun) return {
|
|
21765
21793
|
destination,
|