@theholocron/cli 5.0.0-alpha.345 → 5.0.0-alpha.346
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 +7 -3
- package/dist/cli.mjs +112 -457
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-Bq6510iF.mjs → config-system-CZ0F8Uq7.mjs} +6 -8
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/presets.mjs +1 -1
- package/package.json +11 -11
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";
|
|
@@ -33,6 +34,7 @@ import { access, copyFile, lstat, mkdir, open, readFile, readdir, realpath, rena
|
|
|
33
34
|
import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
34
35
|
import { createServer } from "node:http";
|
|
35
36
|
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";
|
|
37
|
+
import { fetchLatestFromNpm, runUpgradeNode } from "@theholocron/astromech/upgrade";
|
|
36
38
|
import { lintCommitMsgFile } from "@theholocron/astromech/lint";
|
|
37
39
|
import { createGitHubClient } from "@theholocron/github-client";
|
|
38
40
|
// src/plugin/capabilities/capabilities.ts
|
|
@@ -116,12 +118,9 @@ const COMMUNITY_PREFIX = "holocron-plugin-";
|
|
|
116
118
|
* Fully-qualified names (scoped or not) are honored verbatim, which
|
|
117
119
|
* is how third-party plugins published outside the org work.
|
|
118
120
|
*/
|
|
119
|
-
function resolvePluginPackage(provider) {
|
|
121
|
+
function resolvePluginPackage$1(provider) {
|
|
120
122
|
if (!provider) throw new ConfigError("provider name is empty");
|
|
121
|
-
|
|
122
|
-
if (provider.startsWith(COMMUNITY_PREFIX)) return provider;
|
|
123
|
-
if (provider.includes("/")) return provider;
|
|
124
|
-
return PLUGIN_PREFIX + provider;
|
|
123
|
+
return resolvePluginPackage(provider, PLUGIN_PREFIX, COMMUNITY_PREFIX);
|
|
125
124
|
}
|
|
126
125
|
/** A bare `[provider, options]` tuple, with both elements present? */
|
|
127
126
|
function isOptionsTuple(value) {
|
|
@@ -134,13 +133,13 @@ function isOptionsTuple(value) {
|
|
|
134
133
|
function normalizeEntry(entry) {
|
|
135
134
|
if (typeof entry === "string") return {
|
|
136
135
|
provider: entry,
|
|
137
|
-
packageName: resolvePluginPackage(entry),
|
|
136
|
+
packageName: resolvePluginPackage$1(entry),
|
|
138
137
|
options: {}
|
|
139
138
|
};
|
|
140
139
|
const [provider, options] = entry;
|
|
141
140
|
return {
|
|
142
141
|
provider,
|
|
143
|
-
packageName: resolvePluginPackage(provider),
|
|
142
|
+
packageName: resolvePluginPackage$1(provider),
|
|
144
143
|
options
|
|
145
144
|
};
|
|
146
145
|
}
|
|
@@ -401,13 +400,13 @@ async function deriveDefaults$1(found) {
|
|
|
401
400
|
* Probe order is TS-first (`.ts` → `.js` → `.mjs` → `.cjs` → `.json`) —
|
|
402
401
|
* see ADR-0010 / issue #75 / #81.
|
|
403
402
|
*/
|
|
404
|
-
const system = createConfigSystem({
|
|
403
|
+
const system$1 = createConfigSystem({
|
|
405
404
|
name: "holocron",
|
|
406
405
|
derive: deriveDefaults$1,
|
|
407
406
|
resolve: resolveConfig,
|
|
408
407
|
merge: mergeStrategies
|
|
409
408
|
});
|
|
410
|
-
system.defineConfig;
|
|
409
|
+
system$1.defineConfig;
|
|
411
410
|
/**
|
|
412
411
|
* Read + parse + resolve `holocron.config.*` starting from the given
|
|
413
412
|
* directory, walking up through ancestors to the nearest `.git` boundary
|
|
@@ -417,8 +416,8 @@ system.defineConfig;
|
|
|
417
416
|
* Throws `ConfigFileError` when nothing is found or a file cannot
|
|
418
417
|
* be loaded, or `ConfigError` when the config fails schema checks.
|
|
419
418
|
*/
|
|
420
|
-
const loadConfig = system.loadConfig;
|
|
421
|
-
system.compose;
|
|
419
|
+
const loadConfig = system$1.loadConfig;
|
|
420
|
+
system$1.compose;
|
|
422
421
|
// src/auth.ts
|
|
423
422
|
/**
|
|
424
423
|
* The CLI's credentials: the OS keyring every plugin's bootstrap token lives in, and the two token resolvers built on
|
|
@@ -728,21 +727,11 @@ function applyResolvedConfig(argv, resolved) {
|
|
|
728
727
|
* `PluginLoader` — loads provider plugins per the resolved config and
|
|
729
728
|
* builds a typed capability registry the runtime can query.
|
|
730
729
|
*
|
|
731
|
-
*
|
|
732
|
-
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
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).
|
|
730
|
+
* The generic machinery (walking the providers, dynamic-importing a package, calling `createPlugin(options)`,
|
|
731
|
+
* the single / many registry, capability config packages, resolving from the working directory first) is
|
|
732
|
+
* `createPluginSystem` from `@theholocron/kyber/plugins`. This file binds it to Holocron: the
|
|
733
|
+
* `@theholocron/holocron-plugin-<provider>` prefix, where the config lists the providers, the options a plugin is
|
|
734
|
+
* handed (project defaults, the runtime context, the per-plugin token) and the credentials step that runs first.
|
|
746
735
|
*
|
|
747
736
|
* Loader keeps NO knowledge of vendor tokens. Each plugin reads its
|
|
748
737
|
* own env vars (`HOLOCRON_ADMIN_TOKEN`, `HOLOCRON_VERCEL_TOKEN`, etc.)
|
|
@@ -752,184 +741,55 @@ function applyResolvedConfig(argv, resolved) {
|
|
|
752
741
|
* `importer` is injectable so tests don't need real network or
|
|
753
742
|
* sibling packages installed.
|
|
754
743
|
*/
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
config
|
|
760
|
-
context
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
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);
|
|
744
|
+
const system = createPluginSystem({
|
|
745
|
+
packagePrefix: "@theholocron/holocron-plugin-",
|
|
746
|
+
communityPrefix: "holocron-plugin-",
|
|
747
|
+
configFile: "holocron.config.json",
|
|
748
|
+
providers: (config) => config.providers,
|
|
749
|
+
pluginOptions: ({ config, context, tuple }) => {
|
|
750
|
+
const effectiveToken = context.cliTokens?.[tuple.provider] ?? context.cliToken;
|
|
751
|
+
return {
|
|
752
|
+
...config.repo?.name ? { repo: config.repo.name } : {},
|
|
753
|
+
...context,
|
|
754
|
+
...effectiveToken !== void 0 ? { cliToken: effectiveToken } : {},
|
|
755
|
+
cliTokens: void 0,
|
|
756
|
+
...tuple.options
|
|
757
|
+
};
|
|
758
|
+
},
|
|
759
|
+
preload: {
|
|
760
|
+
keys: ["credentials"],
|
|
761
|
+
async run(api, { config, context, options }) {
|
|
762
|
+
const source = `${DOTENV_FILE}:${context.repoRoot}`;
|
|
763
|
+
if (!hasCredentials(source)) {
|
|
764
|
+
const variables = readDotenvFile(context.repoRoot);
|
|
765
|
+
if (variables) setCredentials(source, variables);
|
|
794
766
|
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
767
|
+
const entry = config.providers.credentials;
|
|
768
|
+
if (!entry || entry.cardinality !== "many") return;
|
|
769
|
+
const impls = [];
|
|
770
|
+
for (const tuple of entry.tuples) try {
|
|
771
|
+
const environment = credentialsEnvironment(tuple, config);
|
|
772
|
+
if (!environment) throw new LoaderError(`the ${tuple.provider} credentials provider has no \`environment\` option and \`credentials.environment\` is not set`);
|
|
773
|
+
const impl = await api.loadOne("credentials", tuple);
|
|
774
|
+
impls.push(impl);
|
|
775
|
+
const sourceName = `${tuple.provider}:${environment}`;
|
|
776
|
+
if (options?.readCredentials !== false && !hasCredentials(sourceName)) setCredentials(sourceName, await impl.read(environment));
|
|
777
|
+
} catch (err) {
|
|
778
|
+
api.fail("credentials", tuple, err);
|
|
803
779
|
}
|
|
780
|
+
if (impls.length > 0) api.register("credentials", impls);
|
|
804
781
|
}
|
|
805
782
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
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. */
|
|
783
|
+
});
|
|
784
|
+
/** The Holocron plugin loader: `new PluginLoader(config, context, importer?, options?)`, then `load()`, `get(key)`. */
|
|
785
|
+
var PluginLoader = class extends system.PluginLoader {
|
|
868
786
|
/** The probes each loaded provider offers, by provider name. Empty for a provider that offers none. */
|
|
869
787
|
probes() {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
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;
|
|
916
|
-
}
|
|
917
|
-
};
|
|
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);
|
|
788
|
+
const found = /* @__PURE__ */ new Map();
|
|
789
|
+
for (const [provider, plugin] of this.plugins()) if (plugin.probes && Object.keys(plugin.probes).length > 0) found.set(provider, plugin.probes);
|
|
790
|
+
return found;
|
|
925
791
|
}
|
|
926
792
|
};
|
|
927
|
-
function isPluginModule(mod) {
|
|
928
|
-
return typeof mod.createPlugin === "function";
|
|
929
|
-
}
|
|
930
|
-
function isCapabilityConfigModule(mod) {
|
|
931
|
-
return typeof mod.default?.provider === "string";
|
|
932
|
-
}
|
|
933
793
|
// src/plugin/run-check/run-check.ts
|
|
934
794
|
async function runCheckAgainstUrl(input, opts = {}) {
|
|
935
795
|
const doFetch = opts.fetch ?? fetch;
|
|
@@ -1085,7 +945,8 @@ async function verifyVercelDeploymentProject(url, expectedProjectId, token, opts
|
|
|
1085
945
|
* into one actionable {@link WorkspaceContextError} the CLI prints
|
|
1086
946
|
* instead of a stack trace. Any other mix — some plugins loaded, or a
|
|
1087
947
|
* failure that's an auth/token error rather than a missing package —
|
|
1088
|
-
* is left alone for the command's own soft-skip reporting.
|
|
948
|
+
* is left alone for the command's own soft-skip reporting. The check
|
|
949
|
+
* itself is kyber's; the message here is Holocron's.
|
|
1089
950
|
*
|
|
1090
951
|
* Spec: `docs/wiki/specifications/tech-cli-execution-contexts.spec.md`
|
|
1091
952
|
* (theholocron/holocron#576).
|
|
@@ -1108,21 +969,6 @@ var WorkspaceContextError = class extends Error {
|
|
|
1108
969
|
}
|
|
1109
970
|
};
|
|
1110
971
|
/**
|
|
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
972
|
* Throw {@link WorkspaceContextError} when a loaded `PluginLoader` shows
|
|
1127
973
|
* the global-install signature: nothing in the registry, at least one
|
|
1128
974
|
* failure, and *every* failure is a missing-package error. A no-op in
|
|
@@ -1131,12 +977,8 @@ function isImportFailure(err) {
|
|
|
1131
977
|
*
|
|
1132
978
|
* Call it right after `await loader.load()` in a `workspace` command.
|
|
1133
979
|
*/
|
|
1134
|
-
function assertPluginsResolvable(loader, command) {
|
|
1135
|
-
|
|
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))]);
|
|
980
|
+
function assertPluginsResolvable$1(loader, command) {
|
|
981
|
+
assertPluginsResolvable(loader, command, (cmd, packages) => new WorkspaceContextError(cmd, packages));
|
|
1140
982
|
}
|
|
1141
983
|
// src/commands/auth/auth.ts
|
|
1142
984
|
/**
|
|
@@ -1205,7 +1047,7 @@ async function runAuthSet(input) {
|
|
|
1205
1047
|
env: input.env
|
|
1206
1048
|
});
|
|
1207
1049
|
const isFeatureKey = provider.includes(".");
|
|
1208
|
-
const packageName = isFeatureKey ? null : resolvePluginPackage(provider);
|
|
1050
|
+
const packageName = isFeatureKey ? null : resolvePluginPackage$1(provider);
|
|
1209
1051
|
if (!token) {
|
|
1210
1052
|
print(style.fail(`no token supplied for \`${keyringKey}\`.`));
|
|
1211
1053
|
print(style.hint(` pass as positional arg: holocron auth set ${provider} <token>`));
|
|
@@ -1330,7 +1172,7 @@ async function runAuthCheck(input) {
|
|
|
1330
1172
|
message: "stored"
|
|
1331
1173
|
};
|
|
1332
1174
|
}
|
|
1333
|
-
const packageName = resolvePluginPackage(provider);
|
|
1175
|
+
const packageName = resolvePluginPackage$1(provider);
|
|
1334
1176
|
try {
|
|
1335
1177
|
const module = await importer(packageName);
|
|
1336
1178
|
if (typeof module.verifyToken !== "function") {
|
|
@@ -3207,7 +3049,7 @@ async function runCleanupPreview(input) {
|
|
|
3207
3049
|
// c8 ignore next -- real PluginLoader construction is integration-level; unit tests always supply loader
|
|
3208
3050
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
3209
3051
|
await loader.load();
|
|
3210
|
-
assertPluginsResolvable(loader, "deploy cleanup-preview");
|
|
3052
|
+
assertPluginsResolvable$1(loader, "deploy cleanup-preview");
|
|
3211
3053
|
logger.info({
|
|
3212
3054
|
pr: input.prNumber,
|
|
3213
3055
|
project: input.project
|
|
@@ -3656,7 +3498,7 @@ async function runDeploy(input) {
|
|
|
3656
3498
|
const logger = input.logger ?? getLogger();
|
|
3657
3499
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
3658
3500
|
await loader.load();
|
|
3659
|
-
assertPluginsResolvable(loader, "deploy");
|
|
3501
|
+
assertPluginsResolvable$1(loader, "deploy");
|
|
3660
3502
|
const dryRun = input.context.dryRun ?? false;
|
|
3661
3503
|
logger.info({
|
|
3662
3504
|
branch: input.branch,
|
|
@@ -3726,21 +3568,21 @@ async function runDeploy(input) {
|
|
|
3726
3568
|
};
|
|
3727
3569
|
}
|
|
3728
3570
|
}
|
|
3729
|
-
const SKIP_DIRS$
|
|
3571
|
+
const SKIP_DIRS$2 = [
|
|
3730
3572
|
".git",
|
|
3731
3573
|
"node_modules",
|
|
3732
3574
|
".turbo"
|
|
3733
3575
|
];
|
|
3734
|
-
const defaultWalkFiles$
|
|
3576
|
+
const defaultWalkFiles$1 = (dir) => walkFilesSync(dir, { skip: SKIP_DIRS$2 });
|
|
3735
3577
|
/** `holocron deploy --files <dir>` — the non-git counterpart to `runDeploy`. */
|
|
3736
3578
|
async function runDeployFromFiles(input) {
|
|
3737
3579
|
const print = input.print ?? ((line) => console.log(line));
|
|
3738
3580
|
const logger = input.logger ?? getLogger();
|
|
3739
3581
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
3740
3582
|
await loader.load();
|
|
3741
|
-
assertPluginsResolvable(loader, "deploy");
|
|
3583
|
+
assertPluginsResolvable$1(loader, "deploy");
|
|
3742
3584
|
const dryRun = input.context.dryRun ?? false;
|
|
3743
|
-
const walkFiles = input.walkFiles ?? defaultWalkFiles$
|
|
3585
|
+
const walkFiles = input.walkFiles ?? defaultWalkFiles$1;
|
|
3744
3586
|
const readFile = input.readFile ?? ((p) => readFileSync(p, "utf8"));
|
|
3745
3587
|
const files = {};
|
|
3746
3588
|
for (const abs of walkFiles(input.dir)) {
|
|
@@ -4025,7 +3867,7 @@ async function runTunnelUp(input) {
|
|
|
4025
3867
|
};
|
|
4026
3868
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
4027
3869
|
await withSpinner("Loading plugins…", () => loader.load());
|
|
4028
|
-
assertPluginsResolvable(loader, COMMAND$7);
|
|
3870
|
+
assertPluginsResolvable$1(loader, COMMAND$7);
|
|
4029
3871
|
const dryRun = input.context.dryRun ?? false;
|
|
4030
3872
|
print(style.header(`Holocron tunnel up — ${input.hostname}${dryRun ? " (dry-run)" : ""}`));
|
|
4031
3873
|
print("");
|
|
@@ -4180,7 +4022,7 @@ async function runDev(input) {
|
|
|
4180
4022
|
};
|
|
4181
4023
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
4182
4024
|
await withSpinner("Loading plugins…", () => loader.load());
|
|
4183
|
-
assertPluginsResolvable(loader, COMMAND$6);
|
|
4025
|
+
assertPluginsResolvable$1(loader, COMMAND$6);
|
|
4184
4026
|
const dryRun = input.context.dryRun ?? false;
|
|
4185
4027
|
const [program, ...args] = input.command;
|
|
4186
4028
|
const shown = input.command.join(" ");
|
|
@@ -4610,7 +4452,7 @@ async function runDoctorCredentials(input) {
|
|
|
4610
4452
|
const logger = input.logger ?? getLogger();
|
|
4611
4453
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context, void 0, { readCredentials: false });
|
|
4612
4454
|
await loader.load();
|
|
4613
|
-
assertPluginsResolvable(loader, "doctor credentials");
|
|
4455
|
+
assertPluginsResolvable$1(loader, "doctor credentials");
|
|
4614
4456
|
const rows = await checkCredentials(input, loader);
|
|
4615
4457
|
printCheckRows(rows, print);
|
|
4616
4458
|
const summary = summariseChecks(rows);
|
|
@@ -4821,7 +4663,7 @@ async function readCapped(res, maxBytes, tooBig) {
|
|
|
4821
4663
|
*/
|
|
4822
4664
|
/** Providers cap avatars well below this; it only keeps a wrong file from filling memory. */
|
|
4823
4665
|
const MAX_AVATAR_BYTES = 8388608;
|
|
4824
|
-
const FETCH_TIMEOUT_MS
|
|
4666
|
+
const FETCH_TIMEOUT_MS = 15e3;
|
|
4825
4667
|
const SIGNATURES = [
|
|
4826
4668
|
["image/png", [
|
|
4827
4669
|
137,
|
|
@@ -4881,7 +4723,7 @@ async function loadAvatar(source, baseDir = process.cwd(), fetchImpl = fetch) {
|
|
|
4881
4723
|
const base64 = /^data:[^;,]+;base64,(.*)$/is.exec(source)?.[1];
|
|
4882
4724
|
if (base64 === void 0) throw new Error("it is not a base64 data URI");
|
|
4883
4725
|
bytes = Buffer.from(base64, "base64");
|
|
4884
|
-
} else if (/^https:\/\//i.test(source)) bytes = await fetchAvatarBytes(source, fetchImpl, MAX_AVATAR_BYTES, FETCH_TIMEOUT_MS
|
|
4726
|
+
} else if (/^https:\/\//i.test(source)) bytes = await fetchAvatarBytes(source, fetchImpl, MAX_AVATAR_BYTES, FETCH_TIMEOUT_MS, tooBig);
|
|
4885
4727
|
else {
|
|
4886
4728
|
const path = resolve(baseDir, source);
|
|
4887
4729
|
if ((await stat(path)).size > 8388608) throw tooBig();
|
|
@@ -5184,7 +5026,7 @@ async function runNotificationsChannelAdd(input) {
|
|
|
5184
5026
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
5185
5027
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
5186
5028
|
await loader.load();
|
|
5187
|
-
assertPluginsResolvable(loader, "notifications channel add");
|
|
5029
|
+
assertPluginsResolvable$1(loader, "notifications channel add");
|
|
5188
5030
|
const dryRun = input.context.dryRun ?? false;
|
|
5189
5031
|
print(`Holocron notifications channel add — ${input.name}${dryRun ? " (dry-run)" : ""}`);
|
|
5190
5032
|
try {
|
|
@@ -5481,7 +5323,7 @@ async function runDoctorDns(input) {
|
|
|
5481
5323
|
const logger = input.logger ?? getLogger();
|
|
5482
5324
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
5483
5325
|
await loader.load();
|
|
5484
|
-
assertPluginsResolvable(loader, "doctor dns");
|
|
5326
|
+
assertPluginsResolvable$1(loader, "doctor dns");
|
|
5485
5327
|
const expected = expectedDnsRecords(input.loaded.resolved, {
|
|
5486
5328
|
...loader.has("deployment") ? { deployment: loader.get("deployment") } : {},
|
|
5487
5329
|
...loader.has("wiki") ? { wiki: loader.get("wiki") } : {},
|
|
@@ -5604,7 +5446,7 @@ async function runDoctorEnvironments(input) {
|
|
|
5604
5446
|
const logger = input.logger ?? getLogger();
|
|
5605
5447
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
5606
5448
|
await loader.load();
|
|
5607
|
-
assertPluginsResolvable(loader, "doctor environments");
|
|
5449
|
+
assertPluginsResolvable$1(loader, "doctor environments");
|
|
5608
5450
|
const row = await checkEnvironments(loader, Object.keys(input.loaded.resolved.repo?.secrets?.environments ?? {}));
|
|
5609
5451
|
printCheckRows([row], print);
|
|
5610
5452
|
const summary = summariseChecks([row]);
|
|
@@ -5681,7 +5523,7 @@ async function runDoctorMonitoring(input) {
|
|
|
5681
5523
|
const logger = input.logger ?? getLogger();
|
|
5682
5524
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
5683
5525
|
await loader.load();
|
|
5684
|
-
assertPluginsResolvable(loader, "doctor monitoring");
|
|
5526
|
+
assertPluginsResolvable$1(loader, "doctor monitoring");
|
|
5685
5527
|
const rows = [await checkRow(loader)];
|
|
5686
5528
|
printCheckRows(rows, print);
|
|
5687
5529
|
const summary = summariseChecks(rows);
|
|
@@ -6272,7 +6114,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
6272
6114
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
6273
6115
|
const loader = input$1.loader ?? new PluginLoader(input$1.loaded.resolved, input$1.context);
|
|
6274
6116
|
if (!input$1.preloaded) await loader.load();
|
|
6275
|
-
assertPluginsResolvable(loader, "notifications setup");
|
|
6117
|
+
assertPluginsResolvable$1(loader, "notifications setup");
|
|
6276
6118
|
const dryRun = input$1.context.dryRun ?? false;
|
|
6277
6119
|
const report = {
|
|
6278
6120
|
status: "ok",
|
|
@@ -7003,7 +6845,7 @@ async function runNotificationsSyncRoles(input) {
|
|
|
7003
6845
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
7004
6846
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
7005
6847
|
await loader.load();
|
|
7006
|
-
assertPluginsResolvable(loader, "notifications sync-roles");
|
|
6848
|
+
assertPluginsResolvable$1(loader, "notifications sync-roles");
|
|
7007
6849
|
const dryRun = input.context.dryRun ?? false;
|
|
7008
6850
|
const report = {
|
|
7009
6851
|
status: "ok",
|
|
@@ -7109,7 +6951,7 @@ async function runNotificationsLink(input) {
|
|
|
7109
6951
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
7110
6952
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
7111
6953
|
await loader.load();
|
|
7112
|
-
assertPluginsResolvable(loader, "notifications link");
|
|
6954
|
+
assertPluginsResolvable$1(loader, "notifications link");
|
|
7113
6955
|
const dryRun = input.context.dryRun ?? false;
|
|
7114
6956
|
const refuse = (message, reason = message) => {
|
|
7115
6957
|
print(` ${style.fail(message)}`);
|
|
@@ -7550,7 +7392,7 @@ async function runDoctorNotifications(input) {
|
|
|
7550
7392
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
7551
7393
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
7552
7394
|
await loader.load();
|
|
7553
|
-
assertPluginsResolvable(loader, "doctor notifications");
|
|
7395
|
+
assertPluginsResolvable$1(loader, "doctor notifications");
|
|
7554
7396
|
const checks = [];
|
|
7555
7397
|
const add = (id, title, problems, pass) => {
|
|
7556
7398
|
checks.push({
|
|
@@ -8646,7 +8488,7 @@ async function runDoctorProject(input) {
|
|
|
8646
8488
|
const logger = input.logger ?? getLogger();
|
|
8647
8489
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
8648
8490
|
await loader.load();
|
|
8649
|
-
assertPluginsResolvable(loader, "doctor project");
|
|
8491
|
+
assertPluginsResolvable$1(loader, "doctor project");
|
|
8650
8492
|
const rows = await checkBoards(input, loader);
|
|
8651
8493
|
printCheckRows(rows, print);
|
|
8652
8494
|
const summary = summariseChecks(rows);
|
|
@@ -9355,7 +9197,7 @@ async function runDoctorRepo(input) {
|
|
|
9355
9197
|
const logger = input.logger ?? getLogger();
|
|
9356
9198
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
9357
9199
|
await loader.load();
|
|
9358
|
-
assertPluginsResolvable(loader, "doctor repo");
|
|
9200
|
+
assertPluginsResolvable$1(loader, "doctor repo");
|
|
9359
9201
|
const checks = repoChecks(input.loaded.resolved, input.context.repoRoot);
|
|
9360
9202
|
const rows = [];
|
|
9361
9203
|
if (!loader.has("source")) {
|
|
@@ -9542,7 +9384,7 @@ async function runDoctorSecrets(input) {
|
|
|
9542
9384
|
const logger = input.logger ?? getLogger();
|
|
9543
9385
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
9544
9386
|
await loader.load();
|
|
9545
|
-
assertPluginsResolvable(loader, "doctor secrets");
|
|
9387
|
+
assertPluginsResolvable$1(loader, "doctor secrets");
|
|
9546
9388
|
const config = input.loaded.resolved;
|
|
9547
9389
|
const expected = expectedSecrets(config, (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : []));
|
|
9548
9390
|
const org = input.context.org ?? (input.context.repo ?? config.repo?.name ?? "").split("/")[0];
|
|
@@ -9711,7 +9553,7 @@ async function runDoctorVariables(input) {
|
|
|
9711
9553
|
const logger = input.logger ?? getLogger();
|
|
9712
9554
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
9713
9555
|
await loader.load();
|
|
9714
|
-
assertPluginsResolvable(loader, "doctor variables");
|
|
9556
|
+
assertPluginsResolvable$1(loader, "doctor variables");
|
|
9715
9557
|
const config = input.loaded.resolved;
|
|
9716
9558
|
const variables = config.repo?.variables;
|
|
9717
9559
|
const prune = variables?.prune === true;
|
|
@@ -10134,7 +9976,7 @@ async function runDoctor(input) {
|
|
|
10134
9976
|
const print = input.print ?? ((line) => console.log(line));
|
|
10135
9977
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
10136
9978
|
await withSpinner("Loading plugins…", () => loader.load());
|
|
10137
|
-
assertPluginsResolvable(loader, "doctor");
|
|
9979
|
+
assertPluginsResolvable$1(loader, "doctor");
|
|
10138
9980
|
const rows = [];
|
|
10139
9981
|
const config = input.loaded.resolved;
|
|
10140
9982
|
print("");
|
|
@@ -10587,7 +10429,7 @@ const menuCommand = (version) => ({
|
|
|
10587
10429
|
async function resolveMonitoringChecks(input) {
|
|
10588
10430
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
10589
10431
|
await loader.load();
|
|
10590
|
-
assertPluginsResolvable(loader, "monitoring check");
|
|
10432
|
+
assertPluginsResolvable$1(loader, "monitoring check");
|
|
10591
10433
|
return [...loader.get("monitoring").checks];
|
|
10592
10434
|
}
|
|
10593
10435
|
/**
|
|
@@ -12092,13 +11934,13 @@ function generateHolocronConfig(opts) {
|
|
|
12092
11934
|
lines.push(``);
|
|
12093
11935
|
return lines.join("\n");
|
|
12094
11936
|
}
|
|
12095
|
-
const SKIP_DIRS$
|
|
11937
|
+
const SKIP_DIRS$1 = [
|
|
12096
11938
|
".git",
|
|
12097
11939
|
"node_modules",
|
|
12098
11940
|
"dist",
|
|
12099
11941
|
".turbo"
|
|
12100
11942
|
];
|
|
12101
|
-
const defaultWalkFiles
|
|
11943
|
+
const defaultWalkFiles = (dir) => walkFilesSync(dir, { skip: SKIP_DIRS$1 });
|
|
12102
11944
|
function isBinary(content) {
|
|
12103
11945
|
for (let i = 0; i < Math.min(content.length, 8e3); i++) if (content.charCodeAt(i) === 0) return true;
|
|
12104
11946
|
return false;
|
|
@@ -12170,7 +12012,7 @@ async function runNew(input) {
|
|
|
12170
12012
|
const execFn = input.exec ?? defaultExec$2;
|
|
12171
12013
|
const readFn = input.readFile ?? defaultReadFile;
|
|
12172
12014
|
const writeFn = input.writeFile ?? defaultWriteFile;
|
|
12173
|
-
const walkFn = input.walkFiles ?? defaultWalkFiles
|
|
12015
|
+
const walkFn = input.walkFiles ?? defaultWalkFiles;
|
|
12174
12016
|
preflight();
|
|
12175
12017
|
const templateRepo = `${org}/${input.type}-template`;
|
|
12176
12018
|
const newRepo = `${org}/${input.name}`;
|
|
@@ -12817,7 +12659,7 @@ async function runNotificationsCreateServer(input) {
|
|
|
12817
12659
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
12818
12660
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
12819
12661
|
await loader.load();
|
|
12820
|
-
assertPluginsResolvable(loader, "notifications create-server");
|
|
12662
|
+
assertPluginsResolvable$1(loader, "notifications create-server");
|
|
12821
12663
|
const dryRun = input.context.dryRun ?? false;
|
|
12822
12664
|
const sleep = input.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
12823
12665
|
const refuse = (message, reason = message) => {
|
|
@@ -16072,12 +15914,12 @@ function listProbes(groups) {
|
|
|
16072
15914
|
return lines;
|
|
16073
15915
|
}
|
|
16074
15916
|
// src/commands/probe/references/clone-org.ts
|
|
16075
|
-
const SKIP_DIRS
|
|
15917
|
+
const SKIP_DIRS = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
16076
15918
|
const MAX_FILE_BYTES = 5242880;
|
|
16077
15919
|
/** Every text file under `dir`: not in `.git` or `node_modules`, under 5 MiB, and without a NUL in its first KiB. */
|
|
16078
15920
|
function* textFiles(dir, root = dir) {
|
|
16079
15921
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
16080
|
-
if (SKIP_DIRS
|
|
15922
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
16081
15923
|
const path = join(dir, entry.name);
|
|
16082
15924
|
if (entry.isDirectory()) yield* textFiles(path, root);
|
|
16083
15925
|
else if (entry.isFile() && statSync(path).size < MAX_FILE_BYTES) {
|
|
@@ -16769,7 +16611,7 @@ async function runProjectMove(input) {
|
|
|
16769
16611
|
};
|
|
16770
16612
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
16771
16613
|
await loader.load();
|
|
16772
|
-
assertPluginsResolvable(loader, "project move");
|
|
16614
|
+
assertPluginsResolvable$1(loader, "project move");
|
|
16773
16615
|
const opened = await openBoardContext({
|
|
16774
16616
|
loaded: input.loaded,
|
|
16775
16617
|
context: input.context,
|
|
@@ -16895,7 +16737,7 @@ async function openProjects(input, command) {
|
|
|
16895
16737
|
if (entry?.cardinality !== "single") throw new ConfigError(`${command}: needs a \`projects\` provider in holocron.config.ts, e.g. providers: { projects: "github" }`);
|
|
16896
16738
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
16897
16739
|
await withSpinner("Loading plugins…", () => loader.load());
|
|
16898
|
-
assertPluginsResolvable(loader, command);
|
|
16740
|
+
assertPluginsResolvable$1(loader, command);
|
|
16899
16741
|
if (!loader.has("projects")) {
|
|
16900
16742
|
const failure = loader.loadFailures().find((f) => f.key === "projects");
|
|
16901
16743
|
throw new ConfigError(`${command}: the \`projects\` provider is not available${failure ? ` (\`${failure.provider}\` failed to load: ${describeError(failure.error)})` : ""}`);
|
|
@@ -17355,7 +17197,7 @@ async function runProjectReconcile(input) {
|
|
|
17355
17197
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
17356
17198
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
17357
17199
|
await loader.load();
|
|
17358
|
-
assertPluginsResolvable(loader, "project reconcile");
|
|
17200
|
+
assertPluginsResolvable$1(loader, "project reconcile");
|
|
17359
17201
|
const dryRun = input.context.dryRun ?? false;
|
|
17360
17202
|
const report = {
|
|
17361
17203
|
status: "ok",
|
|
@@ -18214,7 +18056,7 @@ async function runSetup(input) {
|
|
|
18214
18056
|
const logger = getLogger();
|
|
18215
18057
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
18216
18058
|
await withSpinner("Loading plugins…", () => loader.load());
|
|
18217
|
-
assertPluginsResolvable(loader, "repo setup");
|
|
18059
|
+
assertPluginsResolvable$1(loader, "repo setup");
|
|
18218
18060
|
const config = input.loaded.resolved;
|
|
18219
18061
|
const dryRun = input.context.dryRun ?? false;
|
|
18220
18062
|
const steps = [];
|
|
@@ -19043,7 +18885,7 @@ async function runCleanupBranches(input) {
|
|
|
19043
18885
|
// c8 ignore next -- real PluginLoader construction is integration-level; unit tests always supply loader
|
|
19044
18886
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
19045
18887
|
await loader.load();
|
|
19046
|
-
assertPluginsResolvable(loader, "repo cleanup branches");
|
|
18888
|
+
assertPluginsResolvable$1(loader, "repo cleanup branches");
|
|
19047
18889
|
if (!loader.has("source")) throw new Error("source capability is not configured — add a source provider to holocron.config.json");
|
|
19048
18890
|
const source = loader.get("source");
|
|
19049
18891
|
const { listPullRequests, listPullRequestCommits, listBranches, deleteBranch } = source;
|
|
@@ -20302,20 +20144,6 @@ const repoSyncCommand = {
|
|
|
20302
20144
|
*
|
|
20303
20145
|
* After running, `pnpm install && holocron run ci`.
|
|
20304
20146
|
*/
|
|
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
20147
|
const HOLOCRON_PACKAGE = /^@theholocron\/[a-z0-9-]+$/;
|
|
20320
20148
|
/**
|
|
20321
20149
|
* Rewrite every `@theholocron/*` pin in a `pnpm-workspace.yaml` to `latest`,
|
|
@@ -20497,188 +20325,15 @@ const upgradeDepsCommand = {
|
|
|
20497
20325
|
}
|
|
20498
20326
|
};
|
|
20499
20327
|
// src/commands/upgrade-node/upgrade-node.ts
|
|
20500
|
-
|
|
20501
|
-
|
|
20502
|
-
|
|
20503
|
-
|
|
20504
|
-
|
|
20505
|
-
|
|
20506
|
-
|
|
20507
|
-
|
|
20508
|
-
|
|
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
|
-
};
|
|
20328
|
+
/**
|
|
20329
|
+
* `holocron repo upgrade node` — the generic Node.js pin rewrite lives in `@theholocron/astromech/upgrade`; this
|
|
20330
|
+
* binds it to the command-scoped logger.
|
|
20331
|
+
*/
|
|
20332
|
+
function runUpgradeNode$1(input) {
|
|
20333
|
+
return runUpgradeNode({
|
|
20334
|
+
logger: getLogger(),
|
|
20335
|
+
...input
|
|
20336
|
+
});
|
|
20682
20337
|
}
|
|
20683
20338
|
// src/commands/upgrade-node/upgrade-node.args.ts
|
|
20684
20339
|
const upgradeNodeArgs = (yy) => yy.positional("to", {
|
|
@@ -20701,7 +20356,7 @@ const upgradeNodeCommand = {
|
|
|
20701
20356
|
const extraRaw = JSON.parse(raw).upgrade?.node?.extra;
|
|
20702
20357
|
if (Array.isArray(extraRaw)) extra = extraRaw;
|
|
20703
20358
|
} catch {}
|
|
20704
|
-
const report = await runUpgradeNode({
|
|
20359
|
+
const report = await runUpgradeNode$1({
|
|
20705
20360
|
to: Number(to),
|
|
20706
20361
|
...argv.from != null ? { from: argv.from } : {},
|
|
20707
20362
|
cwd: argv.cwd,
|
|
@@ -20846,7 +20501,7 @@ async function runSecretSet(input) {
|
|
|
20846
20501
|
const logger = input.logger ?? getLogger();
|
|
20847
20502
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
20848
20503
|
await loader.load();
|
|
20849
|
-
assertPluginsResolvable(loader, "secrets set");
|
|
20504
|
+
assertPluginsResolvable$1(loader, "secrets set");
|
|
20850
20505
|
const dryRun = input.context.dryRun ?? false;
|
|
20851
20506
|
const scope = input.scope ?? { kind: "repo" };
|
|
20852
20507
|
if (!loader.has("secrets")) throw new Error("`secrets` capability is not configured — add a `secrets` provider to holocron.config.json");
|
|
@@ -20975,7 +20630,7 @@ async function runSecretsList(input) {
|
|
|
20975
20630
|
const logger = input.logger ?? getLogger();
|
|
20976
20631
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
20977
20632
|
await loader.load();
|
|
20978
|
-
assertPluginsResolvable(loader, "secrets list");
|
|
20633
|
+
assertPluginsResolvable$1(loader, "secrets list");
|
|
20979
20634
|
if (!loader.has("secrets")) throw new Error("`secrets` capability is not configured — add a `secrets` provider to holocron.config.json");
|
|
20980
20635
|
const secrets = loader.get("secrets");
|
|
20981
20636
|
const groups = [];
|
|
@@ -21175,7 +20830,7 @@ async function runSecretsSync(input) {
|
|
|
21175
20830
|
const logger = input.logger ?? getLogger();
|
|
21176
20831
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
21177
20832
|
await withSpinner("Loading plugins…", () => loader.load());
|
|
21178
|
-
assertPluginsResolvable(loader, "secrets sync");
|
|
20833
|
+
assertPluginsResolvable$1(loader, "secrets sync");
|
|
21179
20834
|
logger.info({
|
|
21180
20835
|
environment: input.environmentId,
|
|
21181
20836
|
dryRun: (input.context.dryRun ?? false) || void 0
|
|
@@ -21890,7 +21545,7 @@ async function runSpecsSync(input) {
|
|
|
21890
21545
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
21891
21546
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
21892
21547
|
await loader.load();
|
|
21893
|
-
assertPluginsResolvable(loader, "specs sync");
|
|
21548
|
+
assertPluginsResolvable$1(loader, "specs sync");
|
|
21894
21549
|
const dryRun = input.context.dryRun ?? false;
|
|
21895
21550
|
const refuse = (message, reason = message) => {
|
|
21896
21551
|
print(` ${style.fail(message)}`);
|