@theholocron/cli 5.0.0-alpha.345 → 5.0.0-alpha.347

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
@@ -12,6 +12,7 @@ import { LOG_LEVELS } from "@theholocron/observability/core";
12
12
  import yargs from "yargs";
13
13
  import { hideBin } from "yargs/helpers";
14
14
  import { ConfigError, createConfigSystem, lastWins, mergeByKey, shallowMerge, union } from "@theholocron/kyber/config";
15
+ import { LoaderError, assertPluginsResolvable, createPluginSystem, isModuleNotFound, resolvePluginPackage } from "@theholocron/kyber/plugins";
15
16
  import { KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, checkPackageScripts, createAlexignore, createAlexrc, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, frozenReusablePaths, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, mergeScripts, readWorkspacePackages, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, workflowFile, workflowKey, workflowKeys, workspacePackages } from "@theholocron/astromech";
16
17
  import { loadTasksConfig } from "@theholocron/astromech/config";
17
18
  import { readGitRemote, updateGitignore } from "@theholocron/git-utils";
@@ -32,7 +33,10 @@ import { appManifestPage, buildAppManifest, convertAppManifest, serveAppManifest
32
33
  import { access, copyFile, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
33
34
  import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
34
35
  import { createServer } from "node:http";
36
+ import { runCheckAgainstUrl } from "@theholocron/kyber/checks";
37
+ import { moveMajorTag } from "@theholocron/kyber/git";
35
38
  import { ADR_DIR, ADR_STATUSES, CLOSED_STATUSES, SPEC_DIRS, SPEC_STATUSES, WITHDRAWN_STATE, assignSpecIds, checkSpecs, classifySpecPath, discussionBody, discussionIdLine, discussionPrLine, discussionTitle, evaluateDocsPresence, isAddedDocComment, isFeat, packageOf, parseFrontmatter, parseSkipDocs, reconcileSpecStatus, specSummary, specTitle, updateFrontmatter } from "@theholocron/astromech/repo-validation";
39
+ import { fetchLatestFromNpm, runUpgradeNode } from "@theholocron/astromech/upgrade";
36
40
  import { lintCommitMsgFile } from "@theholocron/astromech/lint";
37
41
  import { createGitHubClient } from "@theholocron/github-client";
38
42
  // src/plugin/capabilities/capabilities.ts
@@ -116,12 +120,9 @@ const COMMUNITY_PREFIX = "holocron-plugin-";
116
120
  * Fully-qualified names (scoped or not) are honored verbatim, which
117
121
  * is how third-party plugins published outside the org work.
118
122
  */
119
- function resolvePluginPackage(provider) {
123
+ function resolvePluginPackage$1(provider) {
120
124
  if (!provider) throw new ConfigError("provider name is empty");
121
- if (provider.startsWith("@")) return provider;
122
- if (provider.startsWith(COMMUNITY_PREFIX)) return provider;
123
- if (provider.includes("/")) return provider;
124
- return PLUGIN_PREFIX + provider;
125
+ return resolvePluginPackage(provider, PLUGIN_PREFIX, COMMUNITY_PREFIX);
125
126
  }
126
127
  /** A bare `[provider, options]` tuple, with both elements present? */
127
128
  function isOptionsTuple(value) {
@@ -134,13 +135,13 @@ function isOptionsTuple(value) {
134
135
  function normalizeEntry(entry) {
135
136
  if (typeof entry === "string") return {
136
137
  provider: entry,
137
- packageName: resolvePluginPackage(entry),
138
+ packageName: resolvePluginPackage$1(entry),
138
139
  options: {}
139
140
  };
140
141
  const [provider, options] = entry;
141
142
  return {
142
143
  provider,
143
- packageName: resolvePluginPackage(provider),
144
+ packageName: resolvePluginPackage$1(provider),
144
145
  options
145
146
  };
146
147
  }
@@ -401,13 +402,13 @@ async function deriveDefaults$1(found) {
401
402
  * Probe order is TS-first (`.ts` → `.js` → `.mjs` → `.cjs` → `.json`) —
402
403
  * see ADR-0010 / issue #75 / #81.
403
404
  */
404
- const system = createConfigSystem({
405
+ const system$1 = createConfigSystem({
405
406
  name: "holocron",
406
407
  derive: deriveDefaults$1,
407
408
  resolve: resolveConfig,
408
409
  merge: mergeStrategies
409
410
  });
410
- system.defineConfig;
411
+ system$1.defineConfig;
411
412
  /**
412
413
  * Read + parse + resolve `holocron.config.*` starting from the given
413
414
  * directory, walking up through ancestors to the nearest `.git` boundary
@@ -417,8 +418,8 @@ system.defineConfig;
417
418
  * Throws `ConfigFileError` when nothing is found or a file cannot
418
419
  * be loaded, or `ConfigError` when the config fails schema checks.
419
420
  */
420
- const loadConfig = system.loadConfig;
421
- system.compose;
421
+ const loadConfig = system$1.loadConfig;
422
+ system$1.compose;
422
423
  // src/auth.ts
423
424
  /**
424
425
  * The CLI's credentials: the OS keyring every plugin's bootstrap token lives in, and the two token resolvers built on
@@ -728,21 +729,11 @@ function applyResolvedConfig(argv, resolved) {
728
729
  * `PluginLoader` — loads provider plugins per the resolved config and
729
730
  * builds a typed capability registry the runtime can query.
730
731
  *
731
- * Flow:
732
- * 1. Walk `config.providers[*]` from `resolveConfig()`
733
- * 2. For each entry, dynamic-import the resolved package name
734
- * (`@theholocron/holocron-plugin-<provider>` by default)
735
- * 3. Call the package's exported `createPlugin(options)` to get a
736
- * plugin object whose `capabilities` map holds factories
737
- * 4. Invoke the matching capability factory and stash the impl in
738
- * the registry — single-cardinality entries hold one impl,
739
- * many-cardinality entries hold an array
740
- *
741
- * A package may instead export a capability config (see
742
- * `CapabilityConfigPackage` in config.ts). The loader detects the shape
743
- * at import time and re-resolves to the underlying plugin, merging the
744
- * preset options with any per-project overrides from the config file
745
- * (project options win, mirroring ESLint's `extends` precedence).
732
+ * The generic machinery (walking the providers, dynamic-importing a package, calling `createPlugin(options)`,
733
+ * the single / many registry, capability config packages, resolving from the working directory first) is
734
+ * `createPluginSystem` from `@theholocron/kyber/plugins`. This file binds it to Holocron: the
735
+ * `@theholocron/holocron-plugin-<provider>` prefix, where the config lists the providers, the options a plugin is
736
+ * handed (project defaults, the runtime context, the per-plugin token) and the credentials step that runs first.
746
737
  *
747
738
  * Loader keeps NO knowledge of vendor tokens. Each plugin reads its
748
739
  * own env vars (`HOLOCRON_ADMIN_TOKEN`, `HOLOCRON_VERCEL_TOKEN`, etc.)
@@ -752,288 +743,55 @@ function applyResolvedConfig(argv, resolved) {
752
743
  * `importer` is injectable so tests don't need real network or
753
744
  * sibling packages installed.
754
745
  */
755
- var LoaderError = class extends Error {
756
- name = "LoaderError";
757
- };
758
- var PluginLoader = class {
759
- config;
760
- context;
761
- importer;
762
- options;
763
- registry = /* @__PURE__ */ new Map();
764
- failures = [];
765
- /** The probes of each provider that was imported, by provider name (`sentry`). */
766
- probeSets = /* @__PURE__ */ new Map();
767
- constructor(config, context, importer = defaultImporter$1, options = {}) {
768
- this.config = config;
769
- this.context = context;
770
- this.importer = importer;
771
- this.options = options;
772
- }
773
- /**
774
- * Imports every configured plugin and builds the capability registry.
775
- *
776
- * Never throws for a single plugin's failure — a missing vendor token,
777
- * an uninstalled package, or an unimplemented capability records a
778
- * {@link PluginLoadFailure} and the load continues. This is the
779
- * "soft-skip over hard-fail" contract: a command that needs a
780
- * capability learns it is absent via `has()` / `get()` (which
781
- * re-surfaces the original error), and orchestrators report the skip
782
- * in their summary. Inspect {@link loadFailures} for the full list.
783
- */
784
- async load() {
785
- this.loadDotenv();
786
- await this.loadCredentials();
787
- const entries = Object.entries(this.config.providers);
788
- for (const [key, entry] of entries) {
789
- if (!entry || key === "credentials") continue;
790
- if (entry.cardinality === "single") try {
791
- this.registry.set(key, await this.loadOne(key, entry.tuple));
792
- } catch (err) {
793
- this.recordFailure(key, entry.tuple, err);
746
+ const system = createPluginSystem({
747
+ packagePrefix: "@theholocron/holocron-plugin-",
748
+ communityPrefix: "holocron-plugin-",
749
+ configFile: "holocron.config.json",
750
+ providers: (config) => config.providers,
751
+ pluginOptions: ({ config, context, tuple }) => {
752
+ const effectiveToken = context.cliTokens?.[tuple.provider] ?? context.cliToken;
753
+ return {
754
+ ...config.repo?.name ? { repo: config.repo.name } : {},
755
+ ...context,
756
+ ...effectiveToken !== void 0 ? { cliToken: effectiveToken } : {},
757
+ cliTokens: void 0,
758
+ ...tuple.options
759
+ };
760
+ },
761
+ preload: {
762
+ keys: ["credentials"],
763
+ async run(api, { config, context, options }) {
764
+ const source = `${DOTENV_FILE}:${context.repoRoot}`;
765
+ if (!hasCredentials(source)) {
766
+ const variables = readDotenvFile(context.repoRoot);
767
+ if (variables) setCredentials(source, variables);
794
768
  }
795
- else {
796
- const impls = [];
797
- for (const tuple of entry.tuples) try {
798
- impls.push(await this.loadOne(key, tuple));
799
- } catch (err) {
800
- this.recordFailure(key, tuple, err);
801
- }
802
- if (impls.length > 0) this.registry.set(key, impls);
769
+ const entry = config.providers.credentials;
770
+ if (!entry || entry.cardinality !== "many") return;
771
+ const impls = [];
772
+ for (const tuple of entry.tuples) try {
773
+ const environment = credentialsEnvironment(tuple, config);
774
+ if (!environment) throw new LoaderError(`the ${tuple.provider} credentials provider has no \`environment\` option and \`credentials.environment\` is not set`);
775
+ const impl = await api.loadOne("credentials", tuple);
776
+ impls.push(impl);
777
+ const sourceName = `${tuple.provider}:${environment}`;
778
+ if (options?.readCredentials !== false && !hasCredentials(sourceName)) setCredentials(sourceName, await impl.read(environment));
779
+ } catch (err) {
780
+ api.fail("credentials", tuple, err);
803
781
  }
782
+ if (impls.length > 0) api.register("credentials", impls);
804
783
  }
805
784
  }
806
- /**
807
- * Reads `<repoRoot>/.env` into the credential store when the file exists, once per process. It is optional and
808
- * needs no config; the token chain tries it after the process environment and before the `credentials` providers.
809
- */
810
- loadDotenv() {
811
- const source = `${DOTENV_FILE}:${this.context.repoRoot}`;
812
- if (hasCredentials(source)) return;
813
- const variables = readDotenvFile(this.context.repoRoot);
814
- if (variables) setCredentials(source, variables);
815
- }
816
- /**
817
- * Loads the `credentials` providers in the order the config lists them and reads each one's environment into the
818
- * credential store, once per process: a second loader finds the source already there and does not ask again, so a
819
- * provider that prompts (Touch ID) prompts once. A provider that fails to load or to read is recorded and skipped.
820
- */
821
- async loadCredentials() {
822
- const entry = this.config.providers.credentials;
823
- if (!entry || entry.cardinality !== "many") return;
824
- const impls = [];
825
- for (const tuple of entry.tuples) try {
826
- const environment = credentialsEnvironment(tuple, this.config);
827
- if (!environment) throw new LoaderError(`the ${tuple.provider} credentials provider has no \`environment\` option and \`credentials.environment\` is not set`);
828
- const impl = await this.loadOne("credentials", tuple);
829
- impls.push(impl);
830
- const source = `${tuple.provider}:${environment}`;
831
- if (this.options.readCredentials !== false && !hasCredentials(source)) setCredentials(source, await impl.read(environment));
832
- } catch (err) {
833
- this.recordFailure("credentials", tuple, err);
834
- }
835
- if (impls.length > 0) this.registry.set("credentials", impls);
836
- }
837
- recordFailure(key, tuple, err) {
838
- this.failures.push({
839
- key,
840
- provider: tuple.provider,
841
- packageName: tuple.packageName,
842
- error: err instanceof Error ? err : new Error(String(err))
843
- });
844
- }
845
- /** Providers that failed to load during {@link load}. Empty on a clean load. */
846
- loadFailures() {
847
- return this.failures;
848
- }
849
- /**
850
- * Type-safe lookup. Single-cardinality keys return one impl;
851
- * many-cardinality keys return an array. `ResolvedCapability<K>`
852
- * encodes the split via the `CARDINALITY` map.
853
- */
854
- get(key) {
855
- const impl = this.registry.get(key);
856
- if (impl === void 0) {
857
- const failure = this.failures.find((f) => f.key === key);
858
- if (failure) throw failure.error;
859
- throw new LoaderError(`capability \`${key}\` is not loaded — is it declared in holocron.config.json?`);
860
- }
861
- return impl;
862
- }
863
- /** Whether a capability has been loaded. */
864
- has(key) {
865
- return this.registry.has(key);
866
- }
867
- /** All capability keys currently loaded. Useful for the doctor command. */
785
+ });
786
+ /** The Holocron plugin loader: `new PluginLoader(config, context, importer?, options?)`, then `load()`, `get(key)`. */
787
+ var PluginLoader = class extends system.PluginLoader {
868
788
  /** The probes each loaded provider offers, by provider name. Empty for a provider that offers none. */
869
789
  probes() {
870
- return this.probeSets;
871
- }
872
- loadedKeys() {
873
- return Array.from(this.registry.keys());
874
- }
875
- /** Internal — invoke a plugin's capability factory and return the impl. */
876
- async loadOne(key, tuple) {
877
- const mod = await this.importer(tuple.packageName).catch((err) => {
878
- throw new LoaderError(`failed to import \`${tuple.packageName}\` for capability \`${key}\`: ${errorMessage(err)}`);
879
- });
880
- if (isPluginModule(mod)) {
881
- const effectiveToken = this.context.cliTokens?.[tuple.provider] ?? this.context.cliToken;
882
- const plugin = mod.createPlugin({
883
- ...this.projectDefaults(),
884
- ...this.context,
885
- ...effectiveToken !== void 0 ? { cliToken: effectiveToken } : {},
886
- cliTokens: void 0,
887
- ...tuple.options
888
- });
889
- if (plugin.probes && Object.keys(plugin.probes).length > 0) this.probeSets.set(tuple.provider, plugin.probes);
890
- const factory = plugin.capabilities[key];
891
- if (typeof factory !== "function") throw new LoaderError(`\`${tuple.packageName}\` does not implement the \`${key}\` capability`);
892
- return factory();
893
- }
894
- if (isCapabilityConfigModule(mod)) {
895
- const cap = mod.default;
896
- return this.loadOne(key, {
897
- provider: cap.provider,
898
- packageName: resolvePluginPackage(cap.provider),
899
- options: {
900
- ...cap.options,
901
- ...tuple.options
902
- }
903
- });
904
- }
905
- throw new LoaderError(`\`${tuple.packageName}\` does not export \`createPlugin(options)\` or a capability config ({ provider, options? })`);
906
- }
907
- /**
908
- * Project-level defaults that get merged into every plugin's options
909
- * unless overridden by the CLI context or per-plugin tuple options.
910
- * See `docs/wiki/specifications/tech-setup-and-config.spec.md` §Design.
911
- */
912
- projectDefaults() {
913
- const defaults = {};
914
- if (this.config.repo?.name) defaults.repo = this.config.repo.name;
915
- return defaults;
790
+ const found = /* @__PURE__ */ new Map();
791
+ for (const [provider, plugin] of this.plugins()) if (plugin.probes && Object.keys(plugin.probes).length > 0) found.set(provider, plugin.probes);
792
+ return found;
916
793
  }
917
794
  };
918
- /** Default importer — resolves from cwd first so the global CLI finds project plugins. */
919
- const defaultImporter$1 = async (pkg) => {
920
- try {
921
- const resolved = createRequire(process.cwd() + "/").resolve(pkg);
922
- return import(pathToFileURL(resolved).href);
923
- } catch {
924
- return import(pkg);
925
- }
926
- };
927
- function isPluginModule(mod) {
928
- return typeof mod.createPlugin === "function";
929
- }
930
- function isCapabilityConfigModule(mod) {
931
- return typeof mod.default?.provider === "string";
932
- }
933
- // src/plugin/run-check/run-check.ts
934
- async function runCheckAgainstUrl(input, opts = {}) {
935
- const doFetch = opts.fetch ?? fetch;
936
- const url = resolveUrl(input.url, opts.url);
937
- const method = input.method ?? "GET";
938
- const hasBody = input.body !== void 0 && method !== "GET" && method !== "HEAD";
939
- const needsBody = (input.assertions ?? []).some((a) => a.source === "body");
940
- const start = Date.now();
941
- let response;
942
- let bodyText = "";
943
- try {
944
- response = await doFetch(url, {
945
- method,
946
- ...hasBody ? { body: input.body } : {},
947
- ...opts.headers ? { headers: opts.headers } : {},
948
- redirect: "manual",
949
- signal: AbortSignal.timeout(opts.timeoutMs ?? 1e4)
950
- });
951
- if (needsBody) bodyText = await readBodyCapped(response, opts.maxBodyBytes ?? 1e6);
952
- } catch (err) {
953
- return {
954
- passed: false,
955
- failures: [],
956
- requestError: requestErrorMessage(err)
957
- };
958
- }
959
- const responseTimeMs = Date.now() - start;
960
- const failures = [];
961
- if (!input.shouldFail && response.status >= 400) failures.push(`HTTP ${response.status} (>= 400 counts as a failure unless \`shouldFail\` is set)`);
962
- for (const assertion of input.assertions ?? []) {
963
- const actual = extractActual(assertion, {
964
- response,
965
- bodyText,
966
- responseTimeMs
967
- });
968
- if (!evaluate(assertion.comparison, actual, assertion.target)) failures.push(`${assertion.source} ${assertion.comparison} "${assertion.target ?? ""}" — got "${truncate(actual)}"`);
969
- }
970
- return {
971
- passed: failures.length === 0,
972
- status: response.status,
973
- responseTimeMs,
974
- failures
975
- };
976
- }
977
- /** Swaps in `overrideUrl`'s origin, keeping `originalUrl`'s own path + query. */
978
- function resolveUrl(originalUrl, overrideUrl) {
979
- if (!overrideUrl) return originalUrl;
980
- const original = new URL(originalUrl);
981
- const resolved = new URL(overrideUrl);
982
- resolved.pathname = original.pathname;
983
- resolved.search = original.search;
984
- return resolved.toString();
985
- }
986
- function requestErrorMessage(err) {
987
- if (err instanceof Error) return err.name === "TimeoutError" ? `request timed out: ${err.message}` : err.message;
988
- return String(err);
989
- }
990
- /** Reads up to `maxBytes` of the response body, discarding the rest — a large/unending body can't exhaust memory. */
991
- async function readBodyCapped(response, maxBytes) {
992
- if (!response.body) return "";
993
- const reader = response.body.getReader();
994
- const chunks = [];
995
- let total = 0;
996
- try {
997
- for (;;) {
998
- const { done, value } = await reader.read();
999
- if (done) break;
1000
- const remaining = maxBytes - total;
1001
- if (remaining <= 0) break;
1002
- const stored = value.length > remaining ? value.slice(0, remaining) : value;
1003
- chunks.push(stored);
1004
- total += stored.length;
1005
- }
1006
- } finally {
1007
- await reader.cancel().catch(() => {});
1008
- }
1009
- return Buffer.concat(chunks.map((c) => Buffer.from(c))).toString("utf8");
1010
- }
1011
- /** Keeps a failure message readable when `actual` is a full HTML/JSON response body. */
1012
- function truncate(value, max = 200) {
1013
- return value.length > max ? `${value.slice(0, max)}…` : value;
1014
- }
1015
- function extractActual(assertion, ctx) {
1016
- switch (assertion.source) {
1017
- case "status_code": return String(ctx.response.status);
1018
- case "response_time": return String(ctx.responseTimeMs);
1019
- case "body": return ctx.bodyText;
1020
- case "header": {
1021
- const name = assertion.property ?? "";
1022
- return name ? ctx.response.headers.get(name) ?? "" : "";
1023
- }
1024
- }
1025
- }
1026
- function evaluate(comparison, actual, target) {
1027
- const t = target ?? "";
1028
- switch (comparison) {
1029
- case "equals": return actual === t;
1030
- case "not_equals": return actual !== t;
1031
- case "contains": return actual.includes(t);
1032
- case "not_contains": return !actual.includes(t);
1033
- case "greater_than": return Number(actual) > Number(t);
1034
- case "less_than": return Number(actual) < Number(t);
1035
- }
1036
- }
1037
795
  // src/plugin/verify-vercel-project/verify-vercel-project.ts
1038
796
  /**
1039
797
  * `true` only when Vercel's API confirms `url` resolves to a deployment
@@ -1085,7 +843,8 @@ async function verifyVercelDeploymentProject(url, expectedProjectId, token, opts
1085
843
  * into one actionable {@link WorkspaceContextError} the CLI prints
1086
844
  * instead of a stack trace. Any other mix — some plugins loaded, or a
1087
845
  * failure that's an auth/token error rather than a missing package —
1088
- * is left alone for the command's own soft-skip reporting.
846
+ * is left alone for the command's own soft-skip reporting. The check
847
+ * itself is kyber's; the message here is Holocron's.
1089
848
  *
1090
849
  * Spec: `docs/wiki/specifications/tech-cli-execution-contexts.spec.md`
1091
850
  * (theholocron/holocron#576).
@@ -1108,21 +867,6 @@ var WorkspaceContextError = class extends Error {
1108
867
  }
1109
868
  };
1110
869
  /**
1111
- * A raw "package isn't installed here" error from `import()` /
1112
- * `require.resolve` — `ERR_MODULE_NOT_FOUND` / `MODULE_NOT_FOUND`, or the
1113
- * "Cannot find package/module" message Node prints for it.
1114
- */
1115
- function isModuleNotFound(err) {
1116
- if (!(err instanceof Error)) return false;
1117
- const code = err.code;
1118
- if (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") return true;
1119
- return /Cannot find (?:package|module)|MODULE_NOT_FOUND/.test(err.message);
1120
- }
1121
- /** Did this failure come from the dynamic `import()` not finding the package? */
1122
- function isImportFailure(err) {
1123
- return err instanceof LoaderError && err.message.startsWith("failed to import");
1124
- }
1125
- /**
1126
870
  * Throw {@link WorkspaceContextError} when a loaded `PluginLoader` shows
1127
871
  * the global-install signature: nothing in the registry, at least one
1128
872
  * failure, and *every* failure is a missing-package error. A no-op in
@@ -1131,12 +875,8 @@ function isImportFailure(err) {
1131
875
  *
1132
876
  * Call it right after `await loader.load()` in a `workspace` command.
1133
877
  */
1134
- function assertPluginsResolvable(loader, command) {
1135
- if (loader.loadedKeys().length > 0) return;
1136
- const failures = loader.loadFailures();
1137
- if (failures.length === 0) return;
1138
- if (!failures.every((f) => isImportFailure(f.error))) return;
1139
- throw new WorkspaceContextError(command, [...new Set(failures.map((f) => f.packageName))]);
878
+ function assertPluginsResolvable$1(loader, command) {
879
+ assertPluginsResolvable(loader, command, (cmd, packages) => new WorkspaceContextError(cmd, packages));
1140
880
  }
1141
881
  // src/commands/auth/auth.ts
1142
882
  /**
@@ -1205,7 +945,7 @@ async function runAuthSet(input) {
1205
945
  env: input.env
1206
946
  });
1207
947
  const isFeatureKey = provider.includes(".");
1208
- const packageName = isFeatureKey ? null : resolvePluginPackage(provider);
948
+ const packageName = isFeatureKey ? null : resolvePluginPackage$1(provider);
1209
949
  if (!token) {
1210
950
  print(style.fail(`no token supplied for \`${keyringKey}\`.`));
1211
951
  print(style.hint(` pass as positional arg: holocron auth set ${provider} <token>`));
@@ -1330,7 +1070,7 @@ async function runAuthCheck(input) {
1330
1070
  message: "stored"
1331
1071
  };
1332
1072
  }
1333
- const packageName = resolvePluginPackage(provider);
1073
+ const packageName = resolvePluginPackage$1(provider);
1334
1074
  try {
1335
1075
  const module = await importer(packageName);
1336
1076
  if (typeof module.verifyToken !== "function") {
@@ -1588,7 +1328,7 @@ const doctorTokensCommand = {
1588
1328
  */
1589
1329
  const COMMAND$8 = "auth export";
1590
1330
  /** Plain code-unit order: the same on every machine, whatever its locale. The names it sorts are all different. */
1591
- const compare$1 = (a, b) => a < b ? -1 : 1;
1331
+ const compare = (a, b) => a < b ? -1 : 1;
1592
1332
  /** The file the lines go to on a terminal when none is named. */
1593
1333
  const DEFAULT_FILE$1 = ".credentials";
1594
1334
  /** What a variable can be called in a dotenv file and in a shell. */
@@ -1672,7 +1412,7 @@ async function runAuthExport(input) {
1672
1412
  }
1673
1413
  }
1674
1414
  if (invalid.length > 0) return refuse("invalid", `not a variable name: ${invalid.join(", ")}`);
1675
- if (unknown.length > 0) return refuse("unknown", `no token named ${unknown.join(", ")}`, `the names are: ${[...tokens.keys()].sort(compare$1).join(", ")}`, ...input.blank ? [] : ["or pass --blank to write a name that is no token as an empty placeholder"]);
1415
+ if (unknown.length > 0) return refuse("unknown", `no token named ${unknown.join(", ")}`, `the names are: ${[...tokens.keys()].sort(compare).join(", ")}`, ...input.blank ? [] : ["or pass --blank to write a name that is no token as an empty placeholder"]);
1676
1416
  for (const name of [...tokens.keys()]) if (!chosen.has(name)) tokens.delete(name);
1677
1417
  for (const name of [...conflicts]) if (!chosen.has(name)) conflicts.delete(name);
1678
1418
  }
@@ -1682,7 +1422,7 @@ async function runAuthExport(input) {
1682
1422
  const missing = [];
1683
1423
  const blank = [];
1684
1424
  const unsupported = [];
1685
- for (const [name, token] of [...tokens].sort(([a], [b]) => compare$1(a, b))) {
1425
+ for (const [name, token] of [...tokens].sort(([a], [b]) => compare(a, b))) {
1686
1426
  if (conflicts.has(name)) continue;
1687
1427
  const written = input.vendorNames && token.vendorEnvName ? token.vendorEnvName : name;
1688
1428
  const value = (input.fromEnv ? env.get(name) || (token.vendorEnvName ? env.get(token.vendorEnvName) : void 0) : void 0) || (input.org ? readToken(`${token.keyringKey}.${input.org}`) : null) || readToken(token.keyringKey);
@@ -1733,7 +1473,7 @@ async function runAuthExport(input) {
1733
1473
  });
1734
1474
  taken.add(name);
1735
1475
  }
1736
- entries.sort((x, y) => compare$1(x.name, y.name));
1476
+ entries.sort((x, y) => compare(x.name, y.name));
1737
1477
  const lines = entries.map((e) => e.line);
1738
1478
  const onTerminal = input.only?.length ? "clipboard" : "file";
1739
1479
  const target = input.to ?? (input.outKind === "terminal" ? onTerminal : void 0);
@@ -1770,12 +1510,12 @@ async function runAuthExport(input) {
1770
1510
  for (const name of exported) print(` ${style.success(name)}`);
1771
1511
  for (const name of blank) print(` ${style.dim("·")} ${name}${style.dim(" (written empty: fill it in)")}`);
1772
1512
  for (const name of missing) print(` ${style.dim("·")} ${name}${tokens.get(name)?.optional ? style.dim(" (optional)") : ""}`);
1773
- for (const name of [...conflicts].sort(compare$1)) print(` ${style.fail(`${name} (listed by two plugins under different keyring entries, so not exported)`)}`);
1513
+ for (const name of [...conflicts].sort(compare)) print(` ${style.fail(`${name} (listed by two plugins under different keyring entries, so not exported)`)}`);
1774
1514
  for (const name of unsupported) print(` ${style.fail(`${name} (a value dotenv cannot carry unchanged, so add it by hand)`)}`);
1775
1515
  if (unavailable.length > 0) {
1776
1516
  print("");
1777
1517
  print("could not load, so the tokens they take are not listed:");
1778
- for (const pkg of [...unavailable].sort(compare$1)) print(` ${style.fail(`${pkg} (${reasons.get(pkg)})`)}`);
1518
+ for (const pkg of [...unavailable].sort(compare)) print(` ${style.fail(`${pkg} (${reasons.get(pkg)})`)}`);
1779
1519
  }
1780
1520
  if (destination === "clipboard" || destination === "file") print("");
1781
1521
  if (destination === "clipboard") print("copied to the clipboard: paste it, then clear the clipboard");
@@ -1795,9 +1535,9 @@ async function runAuthExport(input) {
1795
1535
  exported,
1796
1536
  missing,
1797
1537
  blank,
1798
- conflicts: [...conflicts].sort(compare$1),
1538
+ conflicts: [...conflicts].sort(compare),
1799
1539
  unsupported,
1800
- unavailable: [...unavailable].sort(compare$1),
1540
+ unavailable: [...unavailable].sort(compare),
1801
1541
  ...destination ? { destination } : {},
1802
1542
  ...file ? { file } : {}
1803
1543
  };
@@ -3207,7 +2947,7 @@ async function runCleanupPreview(input) {
3207
2947
  // c8 ignore next -- real PluginLoader construction is integration-level; unit tests always supply loader
3208
2948
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
3209
2949
  await loader.load();
3210
- assertPluginsResolvable(loader, "deploy cleanup-preview");
2950
+ assertPluginsResolvable$1(loader, "deploy cleanup-preview");
3211
2951
  logger.info({
3212
2952
  pr: input.prNumber,
3213
2953
  project: input.project
@@ -3656,7 +3396,7 @@ async function runDeploy(input) {
3656
3396
  const logger = input.logger ?? getLogger();
3657
3397
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
3658
3398
  await loader.load();
3659
- assertPluginsResolvable(loader, "deploy");
3399
+ assertPluginsResolvable$1(loader, "deploy");
3660
3400
  const dryRun = input.context.dryRun ?? false;
3661
3401
  logger.info({
3662
3402
  branch: input.branch,
@@ -3726,21 +3466,21 @@ async function runDeploy(input) {
3726
3466
  };
3727
3467
  }
3728
3468
  }
3729
- const SKIP_DIRS$3 = [
3469
+ const SKIP_DIRS$2 = [
3730
3470
  ".git",
3731
3471
  "node_modules",
3732
3472
  ".turbo"
3733
3473
  ];
3734
- const defaultWalkFiles$2 = (dir) => walkFilesSync(dir, { skip: SKIP_DIRS$3 });
3474
+ const defaultWalkFiles$1 = (dir) => walkFilesSync(dir, { skip: SKIP_DIRS$2 });
3735
3475
  /** `holocron deploy --files <dir>` — the non-git counterpart to `runDeploy`. */
3736
3476
  async function runDeployFromFiles(input) {
3737
3477
  const print = input.print ?? ((line) => console.log(line));
3738
3478
  const logger = input.logger ?? getLogger();
3739
3479
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
3740
3480
  await loader.load();
3741
- assertPluginsResolvable(loader, "deploy");
3481
+ assertPluginsResolvable$1(loader, "deploy");
3742
3482
  const dryRun = input.context.dryRun ?? false;
3743
- const walkFiles = input.walkFiles ?? defaultWalkFiles$2;
3483
+ const walkFiles = input.walkFiles ?? defaultWalkFiles$1;
3744
3484
  const readFile = input.readFile ?? ((p) => readFileSync(p, "utf8"));
3745
3485
  const files = {};
3746
3486
  for (const abs of walkFiles(input.dir)) {
@@ -4025,7 +3765,7 @@ async function runTunnelUp(input) {
4025
3765
  };
4026
3766
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
4027
3767
  await withSpinner("Loading plugins…", () => loader.load());
4028
- assertPluginsResolvable(loader, COMMAND$7);
3768
+ assertPluginsResolvable$1(loader, COMMAND$7);
4029
3769
  const dryRun = input.context.dryRun ?? false;
4030
3770
  print(style.header(`Holocron tunnel up — ${input.hostname}${dryRun ? " (dry-run)" : ""}`));
4031
3771
  print("");
@@ -4180,7 +3920,7 @@ async function runDev(input) {
4180
3920
  };
4181
3921
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
4182
3922
  await withSpinner("Loading plugins…", () => loader.load());
4183
- assertPluginsResolvable(loader, COMMAND$6);
3923
+ assertPluginsResolvable$1(loader, COMMAND$6);
4184
3924
  const dryRun = input.context.dryRun ?? false;
4185
3925
  const [program, ...args] = input.command;
4186
3926
  const shown = input.command.join(" ");
@@ -4610,7 +4350,7 @@ async function runDoctorCredentials(input) {
4610
4350
  const logger = input.logger ?? getLogger();
4611
4351
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context, void 0, { readCredentials: false });
4612
4352
  await loader.load();
4613
- assertPluginsResolvable(loader, "doctor credentials");
4353
+ assertPluginsResolvable$1(loader, "doctor credentials");
4614
4354
  const rows = await checkCredentials(input, loader);
4615
4355
  printCheckRows(rows, print);
4616
4356
  const summary = summariseChecks(rows);
@@ -4821,7 +4561,7 @@ async function readCapped(res, maxBytes, tooBig) {
4821
4561
  */
4822
4562
  /** Providers cap avatars well below this; it only keeps a wrong file from filling memory. */
4823
4563
  const MAX_AVATAR_BYTES = 8388608;
4824
- const FETCH_TIMEOUT_MS$1 = 15e3;
4564
+ const FETCH_TIMEOUT_MS = 15e3;
4825
4565
  const SIGNATURES = [
4826
4566
  ["image/png", [
4827
4567
  137,
@@ -4881,7 +4621,7 @@ async function loadAvatar(source, baseDir = process.cwd(), fetchImpl = fetch) {
4881
4621
  const base64 = /^data:[^;,]+;base64,(.*)$/is.exec(source)?.[1];
4882
4622
  if (base64 === void 0) throw new Error("it is not a base64 data URI");
4883
4623
  bytes = Buffer.from(base64, "base64");
4884
- } else if (/^https:\/\//i.test(source)) bytes = await fetchAvatarBytes(source, fetchImpl, MAX_AVATAR_BYTES, FETCH_TIMEOUT_MS$1, tooBig);
4624
+ } else if (/^https:\/\//i.test(source)) bytes = await fetchAvatarBytes(source, fetchImpl, MAX_AVATAR_BYTES, FETCH_TIMEOUT_MS, tooBig);
4885
4625
  else {
4886
4626
  const path = resolve(baseDir, source);
4887
4627
  if ((await stat(path)).size > 8388608) throw tooBig();
@@ -5184,7 +4924,7 @@ async function runNotificationsChannelAdd(input) {
5184
4924
  /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
5185
4925
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
5186
4926
  await loader.load();
5187
- assertPluginsResolvable(loader, "notifications channel add");
4927
+ assertPluginsResolvable$1(loader, "notifications channel add");
5188
4928
  const dryRun = input.context.dryRun ?? false;
5189
4929
  print(`Holocron notifications channel add — ${input.name}${dryRun ? " (dry-run)" : ""}`);
5190
4930
  try {
@@ -5481,7 +5221,7 @@ async function runDoctorDns(input) {
5481
5221
  const logger = input.logger ?? getLogger();
5482
5222
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
5483
5223
  await loader.load();
5484
- assertPluginsResolvable(loader, "doctor dns");
5224
+ assertPluginsResolvable$1(loader, "doctor dns");
5485
5225
  const expected = expectedDnsRecords(input.loaded.resolved, {
5486
5226
  ...loader.has("deployment") ? { deployment: loader.get("deployment") } : {},
5487
5227
  ...loader.has("wiki") ? { wiki: loader.get("wiki") } : {},
@@ -5604,7 +5344,7 @@ async function runDoctorEnvironments(input) {
5604
5344
  const logger = input.logger ?? getLogger();
5605
5345
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
5606
5346
  await loader.load();
5607
- assertPluginsResolvable(loader, "doctor environments");
5347
+ assertPluginsResolvable$1(loader, "doctor environments");
5608
5348
  const row = await checkEnvironments(loader, Object.keys(input.loaded.resolved.repo?.secrets?.environments ?? {}));
5609
5349
  printCheckRows([row], print);
5610
5350
  const summary = summariseChecks([row]);
@@ -5681,7 +5421,7 @@ async function runDoctorMonitoring(input) {
5681
5421
  const logger = input.logger ?? getLogger();
5682
5422
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
5683
5423
  await loader.load();
5684
- assertPluginsResolvable(loader, "doctor monitoring");
5424
+ assertPluginsResolvable$1(loader, "doctor monitoring");
5685
5425
  const rows = [await checkRow(loader)];
5686
5426
  printCheckRows(rows, print);
5687
5427
  const summary = summariseChecks(rows);
@@ -6272,7 +6012,7 @@ async function runNotificationsSetup(input$1) {
6272
6012
  /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
6273
6013
  const loader = input$1.loader ?? new PluginLoader(input$1.loaded.resolved, input$1.context);
6274
6014
  if (!input$1.preloaded) await loader.load();
6275
- assertPluginsResolvable(loader, "notifications setup");
6015
+ assertPluginsResolvable$1(loader, "notifications setup");
6276
6016
  const dryRun = input$1.context.dryRun ?? false;
6277
6017
  const report = {
6278
6018
  status: "ok",
@@ -7003,7 +6743,7 @@ async function runNotificationsSyncRoles(input) {
7003
6743
  /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
7004
6744
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
7005
6745
  await loader.load();
7006
- assertPluginsResolvable(loader, "notifications sync-roles");
6746
+ assertPluginsResolvable$1(loader, "notifications sync-roles");
7007
6747
  const dryRun = input.context.dryRun ?? false;
7008
6748
  const report = {
7009
6749
  status: "ok",
@@ -7109,7 +6849,7 @@ async function runNotificationsLink(input) {
7109
6849
  /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
7110
6850
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
7111
6851
  await loader.load();
7112
- assertPluginsResolvable(loader, "notifications link");
6852
+ assertPluginsResolvable$1(loader, "notifications link");
7113
6853
  const dryRun = input.context.dryRun ?? false;
7114
6854
  const refuse = (message, reason = message) => {
7115
6855
  print(` ${style.fail(message)}`);
@@ -7550,7 +7290,7 @@ async function runDoctorNotifications(input) {
7550
7290
  /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
7551
7291
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
7552
7292
  await loader.load();
7553
- assertPluginsResolvable(loader, "doctor notifications");
7293
+ assertPluginsResolvable$1(loader, "doctor notifications");
7554
7294
  const checks = [];
7555
7295
  const add = (id, title, problems, pass) => {
7556
7296
  checks.push({
@@ -8646,7 +8386,7 @@ async function runDoctorProject(input) {
8646
8386
  const logger = input.logger ?? getLogger();
8647
8387
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
8648
8388
  await loader.load();
8649
- assertPluginsResolvable(loader, "doctor project");
8389
+ assertPluginsResolvable$1(loader, "doctor project");
8650
8390
  const rows = await checkBoards(input, loader);
8651
8391
  printCheckRows(rows, print);
8652
8392
  const summary = summariseChecks(rows);
@@ -9355,7 +9095,7 @@ async function runDoctorRepo(input) {
9355
9095
  const logger = input.logger ?? getLogger();
9356
9096
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
9357
9097
  await loader.load();
9358
- assertPluginsResolvable(loader, "doctor repo");
9098
+ assertPluginsResolvable$1(loader, "doctor repo");
9359
9099
  const checks = repoChecks(input.loaded.resolved, input.context.repoRoot);
9360
9100
  const rows = [];
9361
9101
  if (!loader.has("source")) {
@@ -9542,7 +9282,7 @@ async function runDoctorSecrets(input) {
9542
9282
  const logger = input.logger ?? getLogger();
9543
9283
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
9544
9284
  await loader.load();
9545
- assertPluginsResolvable(loader, "doctor secrets");
9285
+ assertPluginsResolvable$1(loader, "doctor secrets");
9546
9286
  const config = input.loaded.resolved;
9547
9287
  const expected = expectedSecrets(config, (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : []));
9548
9288
  const org = input.context.org ?? (input.context.repo ?? config.repo?.name ?? "").split("/")[0];
@@ -9711,7 +9451,7 @@ async function runDoctorVariables(input) {
9711
9451
  const logger = input.logger ?? getLogger();
9712
9452
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
9713
9453
  await loader.load();
9714
- assertPluginsResolvable(loader, "doctor variables");
9454
+ assertPluginsResolvable$1(loader, "doctor variables");
9715
9455
  const config = input.loaded.resolved;
9716
9456
  const variables = config.repo?.variables;
9717
9457
  const prune = variables?.prune === true;
@@ -10134,7 +9874,7 @@ async function runDoctor(input) {
10134
9874
  const print = input.print ?? ((line) => console.log(line));
10135
9875
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
10136
9876
  await withSpinner("Loading plugins…", () => loader.load());
10137
- assertPluginsResolvable(loader, "doctor");
9877
+ assertPluginsResolvable$1(loader, "doctor");
10138
9878
  const rows = [];
10139
9879
  const config = input.loaded.resolved;
10140
9880
  print("");
@@ -10587,7 +10327,7 @@ const menuCommand = (version) => ({
10587
10327
  async function resolveMonitoringChecks(input) {
10588
10328
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
10589
10329
  await loader.load();
10590
- assertPluginsResolvable(loader, "monitoring check");
10330
+ assertPluginsResolvable$1(loader, "monitoring check");
10591
10331
  return [...loader.get("monitoring").checks];
10592
10332
  }
10593
10333
  /**
@@ -12092,13 +11832,13 @@ function generateHolocronConfig(opts) {
12092
11832
  lines.push(``);
12093
11833
  return lines.join("\n");
12094
11834
  }
12095
- const SKIP_DIRS$2 = [
11835
+ const SKIP_DIRS$1 = [
12096
11836
  ".git",
12097
11837
  "node_modules",
12098
11838
  "dist",
12099
11839
  ".turbo"
12100
11840
  ];
12101
- const defaultWalkFiles$1 = (dir) => walkFilesSync(dir, { skip: SKIP_DIRS$2 });
11841
+ const defaultWalkFiles = (dir) => walkFilesSync(dir, { skip: SKIP_DIRS$1 });
12102
11842
  function isBinary(content) {
12103
11843
  for (let i = 0; i < Math.min(content.length, 8e3); i++) if (content.charCodeAt(i) === 0) return true;
12104
11844
  return false;
@@ -12170,7 +11910,7 @@ async function runNew(input) {
12170
11910
  const execFn = input.exec ?? defaultExec$2;
12171
11911
  const readFn = input.readFile ?? defaultReadFile;
12172
11912
  const writeFn = input.writeFile ?? defaultWriteFile;
12173
- const walkFn = input.walkFiles ?? defaultWalkFiles$1;
11913
+ const walkFn = input.walkFiles ?? defaultWalkFiles;
12174
11914
  preflight();
12175
11915
  const templateRepo = `${org}/${input.type}-template`;
12176
11916
  const newRepo = `${org}/${input.name}`;
@@ -12817,7 +12557,7 @@ async function runNotificationsCreateServer(input) {
12817
12557
  /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
12818
12558
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
12819
12559
  await loader.load();
12820
- assertPluginsResolvable(loader, "notifications create-server");
12560
+ assertPluginsResolvable$1(loader, "notifications create-server");
12821
12561
  const dryRun = input.context.dryRun ?? false;
12822
12562
  const sleep = input.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
12823
12563
  const refuse = (message, reason = message) => {
@@ -13152,112 +12892,17 @@ const notificationsCommand = {
13152
12892
  handler: () => {}
13153
12893
  };
13154
12894
  // src/commands/move-tag/move-tag.ts
13155
- const STABLE = /^(\d+)\.(\d+)\.(\d+)$/;
13156
- /** Spawns `git` without a shell, so a version or group can never be read as anything but an argument. */
13157
- const defaultGit = (args, cwd) => execFileSync("git", [...args], {
13158
- cwd,
13159
- encoding: "utf8",
13160
- stdio: [
13161
- "ignore",
13162
- "pipe",
13163
- "pipe"
13164
- ]
13165
- }).trim();
13166
- /** Orders stable versions, newest last. */
13167
- function compare(a, b) {
13168
- const [pa, pb] = [a, b].map((v) => STABLE.exec(v).slice(1).map(Number));
13169
- return pa.reduce((diff, n, i) => diff || n - pb[i], 0);
13170
- }
13171
- /**
13172
- * Moves a version group's major tag (`ci-v1`) to its latest stable release (`ci-v1.4.0`) and force-pushes it, so
13173
- * a caller that pins `ci-v1` follows the group without changing its workflow files. Immutable tags
13174
- * (`ci-v1.4.0`) are never touched. Run by the group's release (`publishCmd`) and by hand for a repair.
13175
- *
13176
- * A prerelease is refused: the major tag follows stable releases only.
12895
+ /**
12896
+ * Moves a version group's major tag (`ci-v1`) to its latest stable release (`ci-v1.4.0`) and force-pushes it, so a
12897
+ * caller that pins `ci-v1` follows the group without changing its workflow files. Immutable tags are never touched.
12898
+ * Run by the group's release (`publishCmd`) and by hand for a repair. The tag logic is kyber's `moveMajorTag`; this adds
12899
+ * the command-bound logger.
13177
12900
  */
13178
- async function runMoveTag(input) {
13179
- const print = input.print ?? ((line) => console.log(line));
13180
- const logger = input.logger ?? getLogger();
13181
- const cwd = input.cwd ?? process.cwd();
13182
- const git = input.git ?? defaultGit;
13183
- const { group, dryRun = false, remote = "origin" } = input;
13184
- const fail = (message) => {
13185
- print(` ✗ ${message}`);
13186
- logger.info({
13187
- group,
13188
- status: "fail"
13189
- }, "package move-tag: done");
13190
- return {
13191
- status: "fail",
13192
- message
13193
- };
13194
- };
13195
- let version = input.version;
13196
- try {
13197
- if (version === void 0) {
13198
- version = git([
13199
- "tag",
13200
- "--list",
13201
- `${group}-v*`
13202
- ], cwd).split("\n").map((tag) => tag.slice(`${group}-v`.length)).filter((v) => STABLE.test(v)).sort(compare).at(-1);
13203
- if (version === void 0) return fail(`no stable ${group}-v<version> tag to move ${group}-v<major> to`);
13204
- }
13205
- const parts = STABLE.exec(version);
13206
- if (!parts) return fail(`${version} is not a stable version (x.y.z); the major tag follows stable releases only`);
13207
- const target = `${group}-v${version}`;
13208
- const tag = `${group}-v${parts[1]}`;
13209
- print(`Moving ${tag} to ${target}${dryRun ? " (dry-run)" : ""}…`);
13210
- logger.info({
13211
- group,
13212
- tag,
13213
- target,
13214
- dryRun: dryRun || void 0
13215
- }, "package move-tag: start");
13216
- let commit;
13217
- try {
13218
- commit = git([
13219
- "rev-parse",
13220
- "--verify",
13221
- `refs/tags/${target}^{commit}`
13222
- ], cwd);
13223
- } catch {
13224
- return fail(`no tag ${target} in this clone; fetch the tags first (git fetch --tags)`);
13225
- }
13226
- if (dryRun) {
13227
- print(` ~ ${tag} → ${commit.slice(0, 9)} (${target}), then push --force ${remote}`);
13228
- return {
13229
- status: "dry-run",
13230
- tag,
13231
- target
13232
- };
13233
- }
13234
- git([
13235
- "tag",
13236
- "--force",
13237
- tag,
13238
- commit
13239
- ], cwd);
13240
- git([
13241
- "push",
13242
- "--force",
13243
- remote,
13244
- `refs/tags/${tag}`
13245
- ], cwd);
13246
- print(` ✓ ${tag} → ${commit.slice(0, 9)} (${target})`);
13247
- logger.info({
13248
- group,
13249
- tag,
13250
- target,
13251
- status: "ok"
13252
- }, "package move-tag: done");
13253
- return {
13254
- status: "ok",
13255
- tag,
13256
- target
13257
- };
13258
- } catch (error) {
13259
- return fail(errorMessage(error));
13260
- }
12901
+ function runMoveTag(input) {
12902
+ return moveMajorTag({
12903
+ ...input,
12904
+ logger: input.logger ?? getLogger()
12905
+ });
13261
12906
  }
13262
12907
  // src/commands/move-tag/move-tag.args.ts
13263
12908
  const moveTagArgs = (y) => y.positional("group", {
@@ -16072,12 +15717,12 @@ function listProbes(groups) {
16072
15717
  return lines;
16073
15718
  }
16074
15719
  // src/commands/probe/references/clone-org.ts
16075
- const SKIP_DIRS$1 = /* @__PURE__ */ new Set([".git", "node_modules"]);
15720
+ const SKIP_DIRS = /* @__PURE__ */ new Set([".git", "node_modules"]);
16076
15721
  const MAX_FILE_BYTES = 5242880;
16077
15722
  /** Every text file under `dir`: not in `.git` or `node_modules`, under 5 MiB, and without a NUL in its first KiB. */
16078
15723
  function* textFiles(dir, root = dir) {
16079
15724
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
16080
- if (SKIP_DIRS$1.has(entry.name)) continue;
15725
+ if (SKIP_DIRS.has(entry.name)) continue;
16081
15726
  const path = join(dir, entry.name);
16082
15727
  if (entry.isDirectory()) yield* textFiles(path, root);
16083
15728
  else if (entry.isFile() && statSync(path).size < MAX_FILE_BYTES) {
@@ -16769,7 +16414,7 @@ async function runProjectMove(input) {
16769
16414
  };
16770
16415
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
16771
16416
  await loader.load();
16772
- assertPluginsResolvable(loader, "project move");
16417
+ assertPluginsResolvable$1(loader, "project move");
16773
16418
  const opened = await openBoardContext({
16774
16419
  loaded: input.loaded,
16775
16420
  context: input.context,
@@ -16895,7 +16540,7 @@ async function openProjects(input, command) {
16895
16540
  if (entry?.cardinality !== "single") throw new ConfigError(`${command}: needs a \`projects\` provider in holocron.config.ts, e.g. providers: { projects: "github" }`);
16896
16541
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
16897
16542
  await withSpinner("Loading plugins…", () => loader.load());
16898
- assertPluginsResolvable(loader, command);
16543
+ assertPluginsResolvable$1(loader, command);
16899
16544
  if (!loader.has("projects")) {
16900
16545
  const failure = loader.loadFailures().find((f) => f.key === "projects");
16901
16546
  throw new ConfigError(`${command}: the \`projects\` provider is not available${failure ? ` (\`${failure.provider}\` failed to load: ${describeError(failure.error)})` : ""}`);
@@ -17355,7 +17000,7 @@ async function runProjectReconcile(input) {
17355
17000
  /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
17356
17001
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
17357
17002
  await loader.load();
17358
- assertPluginsResolvable(loader, "project reconcile");
17003
+ assertPluginsResolvable$1(loader, "project reconcile");
17359
17004
  const dryRun = input.context.dryRun ?? false;
17360
17005
  const report = {
17361
17006
  status: "ok",
@@ -18214,7 +17859,7 @@ async function runSetup(input) {
18214
17859
  const logger = getLogger();
18215
17860
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
18216
17861
  await withSpinner("Loading plugins…", () => loader.load());
18217
- assertPluginsResolvable(loader, "repo setup");
17862
+ assertPluginsResolvable$1(loader, "repo setup");
18218
17863
  const config = input.loaded.resolved;
18219
17864
  const dryRun = input.context.dryRun ?? false;
18220
17865
  const steps = [];
@@ -19043,7 +18688,7 @@ async function runCleanupBranches(input) {
19043
18688
  // c8 ignore next -- real PluginLoader construction is integration-level; unit tests always supply loader
19044
18689
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
19045
18690
  await loader.load();
19046
- assertPluginsResolvable(loader, "repo cleanup branches");
18691
+ assertPluginsResolvable$1(loader, "repo cleanup branches");
19047
18692
  if (!loader.has("source")) throw new Error("source capability is not configured — add a source provider to holocron.config.json");
19048
18693
  const source = loader.get("source");
19049
18694
  const { listPullRequests, listPullRequestCommits, listBranches, deleteBranch } = source;
@@ -20302,20 +19947,6 @@ const repoSyncCommand = {
20302
19947
  *
20303
19948
  * After running, `pnpm install && holocron run ci`.
20304
19949
  */
20305
- const FETCH_TIMEOUT_MS = 4e3;
20306
- /** Resolve a package's `latest` dist-tag from the npm registry. */
20307
- const fetchLatestFromNpm = async (pkg) => {
20308
- try {
20309
- const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(pkg)}`, {
20310
- signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
20311
- headers: { accept: "application/vnd.npm.install-v1+json" }
20312
- });
20313
- if (!res.ok) return null;
20314
- return (await res.json())["dist-tags"]?.["latest"] ?? null;
20315
- } catch {
20316
- return null;
20317
- }
20318
- };
20319
19950
  const HOLOCRON_PACKAGE = /^@theholocron\/[a-z0-9-]+$/;
20320
19951
  /**
20321
19952
  * Rewrite every `@theholocron/*` pin in a `pnpm-workspace.yaml` to `latest`,
@@ -20497,188 +20128,15 @@ const upgradeDepsCommand = {
20497
20128
  }
20498
20129
  };
20499
20130
  // src/commands/upgrade-node/upgrade-node.ts
20500
- const SKIP_DIRS = [
20501
- "node_modules",
20502
- ".git",
20503
- "dist",
20504
- "coverage",
20505
- "build",
20506
- ".turbo",
20507
- ".next",
20508
- "out"
20509
- ];
20510
- function patchPackageJson(content, from, to) {
20511
- let pkg;
20512
- try {
20513
- pkg = JSON.parse(content);
20514
- } catch {
20515
- return null;
20516
- }
20517
- let changed = false;
20518
- const engines = pkg.engines;
20519
- if (engines?.node && /^>=\d+(?:\.0\.0)?$/.test(engines.node)) {
20520
- if (parseInt(engines.node.match(/\d+/)[0], 10) === from) {
20521
- engines.node = `>=${to}.0.0`;
20522
- changed = true;
20523
- }
20524
- }
20525
- for (const field of ["devDependencies", "dependencies"]) {
20526
- const deps = pkg[field];
20527
- if (!deps?.["@types/node"]) continue;
20528
- if (deps["@types/node"] === `^${from}.0.0`) {
20529
- deps["@types/node"] = `^${to}.0.0`;
20530
- changed = true;
20531
- }
20532
- }
20533
- return changed ? stringifyJson(pkg, { like: content }) : null;
20534
- }
20535
- function patchYaml(content, from, to) {
20536
- const updated = content.replace(/node-version:\s+['"]?(\d+)['"]?/g, (match, ver) => ver === String(from) ? match.replace(String(from), String(to)) : match);
20537
- return updated !== content ? updated : null;
20538
- }
20539
- function patchPinFile(content, from, to) {
20540
- const trimmed = content.trim();
20541
- if (trimmed === String(from) || trimmed.startsWith(`${from}.`)) return `${to}\n`;
20542
- return null;
20543
- }
20544
- function patchDockerfile(content, from, to) {
20545
- const updated = content.replace(/^(FROM\s+node:)(\d+)/gm, (match, prefix, ver) => ver === String(from) ? `${prefix}${to}` : match);
20546
- return updated !== content ? updated : null;
20547
- }
20548
- function patchToolVersions(content, from, to) {
20549
- const updated = content.replace(/^(nodejs\s+)(\d+)/gm, (match, prefix, ver) => ver === String(from) ? `${prefix}${to}` : match);
20550
- return updated !== content ? updated : null;
20551
- }
20552
- const PATTERNS = [
20553
- {
20554
- matches: (n) => n === "package.json",
20555
- patch: patchPackageJson
20556
- },
20557
- {
20558
- matches: (n) => n.endsWith(".yml") || n.endsWith(".yaml"),
20559
- patch: patchYaml
20560
- },
20561
- {
20562
- matches: (n) => n === ".nvmrc" || n === ".node-version",
20563
- patch: patchPinFile
20564
- },
20565
- {
20566
- matches: (n) => n === "Dockerfile" || n.startsWith("Dockerfile."),
20567
- patch: patchDockerfile
20568
- },
20569
- {
20570
- matches: (n) => n === ".tool-versions",
20571
- patch: patchToolVersions
20572
- }
20573
- ];
20574
- function detectFrom(cwd, _readFile) {
20575
- for (const name of [".nvmrc", ".node-version"]) try {
20576
- const major = parseInt(_readFile(join(cwd, name)).trim(), 10);
20577
- if (!isNaN(major)) return major;
20578
- } catch {}
20579
- try {
20580
- const node = JSON.parse(_readFile(join(cwd, "package.json"))).engines?.node;
20581
- if (node) {
20582
- const m = node.match(/(\d+)/);
20583
- if (m) return parseInt(m[1], 10);
20584
- }
20585
- } catch {}
20586
- return null;
20587
- }
20588
- const defaultWalkFiles = (dir) => walkFilesSync(dir, { skip: SKIP_DIRS });
20589
- async function runUpgradeNode(input) {
20590
- const print = input.print ?? ((line) => console.log(line));
20591
- const logger = input.logger ?? getLogger();
20592
- const cwd = input.cwd ?? process.cwd();
20593
- const { to, dryRun = false, extra = [] } = input;
20594
- const _readFile = input.readFile ?? ((p) => readFileSync(p, "utf8"));
20595
- const _writeFile = input.writeFile ?? ((p, c) => writeFileSync(p, c));
20596
- const _walkFiles = input.walkFiles ?? defaultWalkFiles;
20597
- let walked;
20598
- try {
20599
- walked = _walkFiles(cwd);
20600
- } catch (error) {
20601
- const message = `could not read ${cwd}: ${errorMessage(error)}`;
20602
- logger.warn({
20603
- to,
20604
- reason: message
20605
- }, "upgrade node: done");
20606
- return {
20607
- status: "fail",
20608
- updated: [],
20609
- message
20610
- };
20611
- }
20612
- const from = input.from ?? detectFrom(cwd, _readFile);
20613
- if (from === null) {
20614
- const message = "could not detect current Node version — pass --from <major>";
20615
- logger.warn({
20616
- to,
20617
- reason: message
20618
- }, "upgrade node: done");
20619
- return {
20620
- status: "fail",
20621
- updated: [],
20622
- message
20623
- };
20624
- }
20625
- logger.info({
20626
- from,
20627
- to,
20628
- dryRun: dryRun || void 0
20629
- }, "upgrade node: start");
20630
- if (from === to) {
20631
- print(`Already at Node.js ${to} — nothing to do.`);
20632
- logger.info({
20633
- from,
20634
- to,
20635
- updated: 0,
20636
- status: "ok"
20637
- }, "upgrade node: done");
20638
- return {
20639
- status: "ok",
20640
- updated: []
20641
- };
20642
- }
20643
- print(`Upgrading Node.js ${from} → ${to}${dryRun ? " (dry-run)" : ""}…`);
20644
- const updated = [];
20645
- const root = resolve(cwd);
20646
- const scanned = [...walked, ...extra.map((p) => join(cwd, p))];
20647
- for (const abs of scanned) {
20648
- const name = basename(abs);
20649
- const pattern = PATTERNS.find((p) => p.matches(name));
20650
- if (!pattern) continue;
20651
- let content;
20652
- try {
20653
- content = _readFile(abs);
20654
- } catch {
20655
- continue;
20656
- }
20657
- const patched = pattern.patch(content, from, to);
20658
- if (patched === null) continue;
20659
- const absolute = resolve(abs);
20660
- const rel = absolute.startsWith(root + sep) ? absolute.slice(root.length + 1) : abs;
20661
- if (!dryRun) _writeFile(abs, patched);
20662
- print(` ${dryRun ? "~" : "✓"} ${rel}`);
20663
- logger.debug({
20664
- file: rel,
20665
- from,
20666
- to
20667
- }, "upgrade node: patched");
20668
- updated.push(rel);
20669
- }
20670
- if (updated.length === 0) print(` · no files contained Node.js ${from} pins`);
20671
- const status = dryRun ? "dry-run" : "ok";
20672
- logger.info({
20673
- from,
20674
- to,
20675
- updated: updated.length,
20676
- status
20677
- }, "upgrade node: done");
20678
- return {
20679
- status,
20680
- updated
20681
- };
20131
+ /**
20132
+ * `holocron repo upgrade node` — the generic Node.js pin rewrite lives in `@theholocron/astromech/upgrade`; this
20133
+ * binds it to the command-scoped logger.
20134
+ */
20135
+ function runUpgradeNode$1(input) {
20136
+ return runUpgradeNode({
20137
+ logger: getLogger(),
20138
+ ...input
20139
+ });
20682
20140
  }
20683
20141
  // src/commands/upgrade-node/upgrade-node.args.ts
20684
20142
  const upgradeNodeArgs = (yy) => yy.positional("to", {
@@ -20701,7 +20159,7 @@ const upgradeNodeCommand = {
20701
20159
  const extraRaw = JSON.parse(raw).upgrade?.node?.extra;
20702
20160
  if (Array.isArray(extraRaw)) extra = extraRaw;
20703
20161
  } catch {}
20704
- const report = await runUpgradeNode({
20162
+ const report = await runUpgradeNode$1({
20705
20163
  to: Number(to),
20706
20164
  ...argv.from != null ? { from: argv.from } : {},
20707
20165
  cwd: argv.cwd,
@@ -20846,7 +20304,7 @@ async function runSecretSet(input) {
20846
20304
  const logger = input.logger ?? getLogger();
20847
20305
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
20848
20306
  await loader.load();
20849
- assertPluginsResolvable(loader, "secrets set");
20307
+ assertPluginsResolvable$1(loader, "secrets set");
20850
20308
  const dryRun = input.context.dryRun ?? false;
20851
20309
  const scope = input.scope ?? { kind: "repo" };
20852
20310
  if (!loader.has("secrets")) throw new Error("`secrets` capability is not configured — add a `secrets` provider to holocron.config.json");
@@ -20975,7 +20433,7 @@ async function runSecretsList(input) {
20975
20433
  const logger = input.logger ?? getLogger();
20976
20434
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
20977
20435
  await loader.load();
20978
- assertPluginsResolvable(loader, "secrets list");
20436
+ assertPluginsResolvable$1(loader, "secrets list");
20979
20437
  if (!loader.has("secrets")) throw new Error("`secrets` capability is not configured — add a `secrets` provider to holocron.config.json");
20980
20438
  const secrets = loader.get("secrets");
20981
20439
  const groups = [];
@@ -21125,6 +20583,29 @@ function secretRoutes(entries, environmentId) {
21125
20583
  ...entry.keys ? { keys: entry.keys } : {}
21126
20584
  }));
21127
20585
  }
20586
+ // src/commands/secrets-sync/restore-pem/restore-pem.ts
20587
+ /** A PEM block written on one line: the begin marker, the body, the end marker, with spaces between them. */
20588
+ const COLLAPSED = /^(-----BEGIN [A-Z0-9 ]+-----) ([\s\S]+?) (-----END [A-Z0-9 ]+-----)$/;
20589
+ /** Base64 lines in a PEM are 64 characters wide. */
20590
+ const LINE_WIDTH = 64;
20591
+ /**
20592
+ * Put a PEM back on its lines when its line breaks were turned into spaces. A key pasted into a single-line field
20593
+ * (a 1Password Environment variable, a form) arrives as `-----BEGIN ... KEY----- MIIE... -----END ... KEY-----`, which
20594
+ * Node's crypto, OpenSSL and `actions/create-github-app-token` refuse (`DECODER routines::unsupported`). The header and
20595
+ * footer go on their own lines and the body is cut into 64-character lines.
20596
+ *
20597
+ * Anything else is returned as it came: a PEM already on its lines, a value that is not a PEM, a block whose end marker
20598
+ * does not match its begin marker, and a legacy encrypted key (its body holds `Proc-Type:` header fields, whose own
20599
+ * line breaks cannot be rebuilt). Running it twice gives the same result as running it once.
20600
+ */
20601
+ function restorePem(value) {
20602
+ const match = COLLAPSED.exec(value.trim());
20603
+ if (!match) return value;
20604
+ const [, begin, body, end] = match;
20605
+ if (begin.replace("BEGIN", "END") !== end || body.includes(":")) return value;
20606
+ const lines = body.replace(/\s+/g, "").match(new RegExp(`.{1,${LINE_WIDTH}}`, "g"));
20607
+ return lines ? `${begin}\n${lines.join("\n")}\n${end}\n` : value;
20608
+ }
21128
20609
  // src/commands/secrets-sync/secrets-sync.ts
21129
20610
  /**
21130
20611
  * `holocron secrets sync` — vault → destinations.
@@ -21175,7 +20656,7 @@ async function runSecretsSync(input) {
21175
20656
  const logger = input.logger ?? getLogger();
21176
20657
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
21177
20658
  await withSpinner("Loading plugins…", () => loader.load());
21178
- assertPluginsResolvable(loader, "secrets sync");
20659
+ assertPluginsResolvable$1(loader, "secrets sync");
21179
20660
  logger.info({
21180
20661
  environment: input.environmentId,
21181
20662
  dryRun: (input.context.dryRun ?? false) || void 0
@@ -21325,7 +20806,7 @@ async function pushRow(destination, scope, key, envVars, dryRun, body) {
21325
20806
  status: "skip",
21326
20807
  message: "blank in the vault environment"
21327
20808
  };
21328
- return runRow(destination, scope, key, dryRun, () => body(value));
20809
+ return runRow(destination, scope, key, dryRun, () => body(restorePem(value)));
21329
20810
  }
21330
20811
  async function runRow(destination, scope, key, dryRun, body) {
21331
20812
  if (dryRun) return {
@@ -21890,7 +21371,7 @@ async function runSpecsSync(input) {
21890
21371
  /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
21891
21372
  const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
21892
21373
  await loader.load();
21893
- assertPluginsResolvable(loader, "specs sync");
21374
+ assertPluginsResolvable$1(loader, "specs sync");
21894
21375
  const dryRun = input.context.dryRun ?? false;
21895
21376
  const refuse = (message, reason = message) => {
21896
21377
  print(` ${style.fail(message)}`);