@theholocron/cli 5.0.0-alpha.220 → 5.0.0-alpha.222
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 +2 -0
- package/dist/cli.mjs +53 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/plugin/capabilities.d.mts +5 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -552,6 +552,8 @@ Channels fed by another service are declared with `feeds` on the channel: `{ nam
|
|
|
552
552
|
|
|
553
553
|
Channels fed by the error tracker add `feeds: { errors: true }` and a layout `relay: { host, zone?, script?, code? }`: `setup` makes a dedicated webhook, points `host` at the Comlink Worker (a proxied DNS record via `dns`), and deploys it via `workers.deployScript` with the webhook URL as `COMLINK_<SOURCE>_WEBHOOK`. The URL never leaves the Worker's secret; other secrets on the script are kept. Needs `errors`, `workers` and `dns`; only one channel may be fed.
|
|
554
554
|
|
|
555
|
+
`holocron secrets sync <env> --worker <script>` also sets every key of the vault environment on a deployed Worker as a secret, through the optional `Workers.setSecret(script, name, value)` (write-only; the Cloudflare plugin implements it). The Worker must already exist. Sync only adds and updates: it never removes a binding, because a Worker also holds secrets that are not in the vault (for Comlink, the `COMLINK_<SOURCE>_WEBHOOK` that `notifications setup` sets), so a key deleted from the vault must be deleted from the Worker separately. Keys are written one at a time and each is reported; if one fails, the exit code is 1 and re-running finishes the rest, since every write is idempotent.
|
|
556
|
+
|
|
555
557
|
Pinned messages are declared under the provider's `layout` as `pinned: [{ channel, content }]` (`channel` is a channel in the layout, `content` up to 2000 characters); the layout is the whole set of messages the bot has pinned in those channels.
|
|
556
558
|
|
|
557
559
|
Config shape added for role sync and sign-in (all under the provider's `layout`):
|
package/dist/cli.mjs
CHANGED
|
@@ -7771,6 +7771,12 @@ function describeScope(scope) {
|
|
|
7771
7771
|
* If it doesn't, the command errors with a hint to populate the keys
|
|
7772
7772
|
* individually via `holocron secrets set` (also planned for v5.1).
|
|
7773
7773
|
*/
|
|
7774
|
+
/** Why there is no `workers` provider: the plugin's own load error when it failed to load (e.g. a missing account id). */
|
|
7775
|
+
function workersMissing(loader) {
|
|
7776
|
+
const base = "--worker needs a `workers` provider in holocron.config.ts";
|
|
7777
|
+
const failure = loader.loadFailures().find((f) => f.key === "workers");
|
|
7778
|
+
return failure ? `${base} (\`${failure.provider}\` failed to load: ${describeProviderError(failure.error)})` : base;
|
|
7779
|
+
}
|
|
7774
7780
|
async function runSecretsSync(input) {
|
|
7775
7781
|
const print = input.print ?? ((line) => console.log(line));
|
|
7776
7782
|
const logger = input.logger ?? getLogger();
|
|
@@ -7788,7 +7794,24 @@ async function runSecretsSync(input) {
|
|
|
7788
7794
|
print("");
|
|
7789
7795
|
const vault = loader.get("vault");
|
|
7790
7796
|
if (!vault.readEnvironment) throw new Error(`vault provider (${vault.providerName}) does not implement readEnvironment — sync needs bulk env reads`);
|
|
7791
|
-
|
|
7797
|
+
let envVars;
|
|
7798
|
+
try {
|
|
7799
|
+
envVars = await withSpinner(`Reading vault environment ${input.environmentId}…`, () => vault.readEnvironment(input.environmentId));
|
|
7800
|
+
} catch (err) {
|
|
7801
|
+
const message = describeProviderError(err);
|
|
7802
|
+
print(` ${style.fail(`could not read vault environment ${input.environmentId}: ${message}`)}`);
|
|
7803
|
+
logger.warn({
|
|
7804
|
+
environment: input.environmentId,
|
|
7805
|
+
reason: logReason(err)
|
|
7806
|
+
}, "secrets sync: vault read failed");
|
|
7807
|
+
return summarise([{
|
|
7808
|
+
destination: `vault:${vault.providerName}`,
|
|
7809
|
+
scope: `environment=${input.environmentId}`,
|
|
7810
|
+
key: "(all)",
|
|
7811
|
+
status: "fail",
|
|
7812
|
+
message
|
|
7813
|
+
}], logger, print, dryRun);
|
|
7814
|
+
}
|
|
7792
7815
|
const keys = Object.keys(envVars).sort();
|
|
7793
7816
|
print(style.step(`read ${keys.length} keys from vault`));
|
|
7794
7817
|
print("");
|
|
@@ -7829,6 +7852,31 @@ async function runSecretsSync(input) {
|
|
|
7829
7852
|
}
|
|
7830
7853
|
}
|
|
7831
7854
|
}
|
|
7855
|
+
if (input.workerScript) {
|
|
7856
|
+
const script = input.workerScript;
|
|
7857
|
+
print(style.step(`workers (script=${script})`));
|
|
7858
|
+
const workers = loader.has("workers") ? loader.get("workers") : void 0;
|
|
7859
|
+
if (!workers?.setSecret) {
|
|
7860
|
+
const row = {
|
|
7861
|
+
destination: "workers",
|
|
7862
|
+
scope: `script=${script}`,
|
|
7863
|
+
key: "(all)",
|
|
7864
|
+
status: "fail",
|
|
7865
|
+
message: workers ? `workers provider (${workers.providerName}) cannot set secrets` : workersMissing(loader)
|
|
7866
|
+
};
|
|
7867
|
+
rows.push(row);
|
|
7868
|
+
print(formatRow(row));
|
|
7869
|
+
} else for (const key of keys) {
|
|
7870
|
+
rows.push(await runRow(`workers:${workers.providerName}`, `script=${script}`, key, dryRun, async () => {
|
|
7871
|
+
await workers.setSecret(script, key, envVars[key]);
|
|
7872
|
+
}));
|
|
7873
|
+
print(formatRow(rows[rows.length - 1]));
|
|
7874
|
+
}
|
|
7875
|
+
}
|
|
7876
|
+
return summarise(rows, logger, print, dryRun);
|
|
7877
|
+
}
|
|
7878
|
+
/** Log every row, then print and log the summary. Shared by a finished run and one that stopped at the vault. */
|
|
7879
|
+
function summarise(rows, logger, print, dryRun) {
|
|
7832
7880
|
for (const r of rows) logger[r.status === "fail" ? "warn" : "info"]({
|
|
7833
7881
|
destination: r.destination,
|
|
7834
7882
|
scope: r.scope,
|
|
@@ -13453,6 +13501,9 @@ try {
|
|
|
13453
13501
|
type: "array",
|
|
13454
13502
|
default: ["production", "preview"],
|
|
13455
13503
|
describe: "Deployment targets to sync to. Defaults to production + preview."
|
|
13504
|
+
}).option("worker", {
|
|
13505
|
+
type: "string",
|
|
13506
|
+
describe: "A deployed Worker (script name) to set every vault key on as a secret, e.g. comlink."
|
|
13456
13507
|
}).option("github-secret", {
|
|
13457
13508
|
type: "array",
|
|
13458
13509
|
describe: "Vault key(s) to push to GH Actions secrets (repeatable). Omit to push every key."
|
|
@@ -13477,6 +13528,7 @@ try {
|
|
|
13477
13528
|
},
|
|
13478
13529
|
environmentId,
|
|
13479
13530
|
...argv.projectId ? { projectId: argv.projectId } : {},
|
|
13531
|
+
...argv.worker ? { workerScript: argv.worker } : {},
|
|
13480
13532
|
...argv.githubSecret?.length ? { githubSecretKeys: argv.githubSecret } : {},
|
|
13481
13533
|
githubSecretScope,
|
|
13482
13534
|
targets: argv.target
|