@theholocron/cli 5.0.0-alpha.344 → 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 +8 -4
- package/dist/cli.mjs +117 -598
- 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 +13 -13
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";
|
|
@@ -28,11 +29,12 @@ import { Separator, checkbox, confirm, input, select } from "@inquirer/prompts";
|
|
|
28
29
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
29
30
|
import { stringifyJson } from "@theholocron/json-utils";
|
|
30
31
|
import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-utils";
|
|
31
|
-
import { serveHandler, superviseProcesses } from "@theholocron/dagobah";
|
|
32
|
+
import { appManifestPage, buildAppManifest, convertAppManifest, serveAppManifest, serveHandler, superviseProcesses } from "@theholocron/dagobah";
|
|
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";
|
|
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;
|
|
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;
|
|
916
791
|
}
|
|
917
792
|
};
|
|
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
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({
|
|
@@ -8308,7 +8150,7 @@ const FIELD_TYPES = [
|
|
|
8308
8150
|
"iteration"
|
|
8309
8151
|
];
|
|
8310
8152
|
const LAYOUTS = ["board", "table"];
|
|
8311
|
-
function isRecord
|
|
8153
|
+
function isRecord(value) {
|
|
8312
8154
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8313
8155
|
}
|
|
8314
8156
|
function isText(value) {
|
|
@@ -8321,7 +8163,7 @@ function namedList(label, value, check) {
|
|
|
8321
8163
|
const seen = /* @__PURE__ */ new Set();
|
|
8322
8164
|
value.forEach((entry, i) => {
|
|
8323
8165
|
const where = `${label}[${i}]`;
|
|
8324
|
-
if (!isRecord
|
|
8166
|
+
if (!isRecord(entry)) {
|
|
8325
8167
|
problems.push(`${where} must be an object`);
|
|
8326
8168
|
return;
|
|
8327
8169
|
}
|
|
@@ -8338,7 +8180,7 @@ function namedList(label, value, check) {
|
|
|
8338
8180
|
* status, the fields and the views). Returns the file typed, or every problem found, so one run lists them all.
|
|
8339
8181
|
*/
|
|
8340
8182
|
function validateTemplateFile(value) {
|
|
8341
|
-
if (!isRecord
|
|
8183
|
+
if (!isRecord(value)) return {
|
|
8342
8184
|
ok: false,
|
|
8343
8185
|
problems: ["a template must be an object"]
|
|
8344
8186
|
};
|
|
@@ -8357,7 +8199,7 @@ function validateTemplateFile(value) {
|
|
|
8357
8199
|
if (value.views !== void 0) problems.push(...namedList("views", value.views, (v, where) => typeof v.layout === "string" && LAYOUTS.includes(v.layout) ? [] : [`${where} needs a layout: ${LAYOUTS.join(", ")}`]));
|
|
8358
8200
|
if (value.extends === void 0) {
|
|
8359
8201
|
if (!Array.isArray(value.statuses) || value.statuses.length === 0) problems.push("a template without extends must list its statuses");
|
|
8360
|
-
else if (!value.statuses.some((s) => isRecord
|
|
8202
|
+
else if (!value.statuses.some((s) => isRecord(s) && s.category === "done")) problems.push("statuses need one in the done category");
|
|
8361
8203
|
if (value.fields === void 0) problems.push("a template without extends must list its fields (an empty list is fine)");
|
|
8362
8204
|
if (!Array.isArray(value.views) || value.views.length === 0) problems.push("a template without extends must list its views");
|
|
8363
8205
|
}
|
|
@@ -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("");
|
|
@@ -10355,142 +10197,6 @@ const doctorCommand = {
|
|
|
10355
10197
|
})).summary.fail > 0) process.exitCode = 1;
|
|
10356
10198
|
}
|
|
10357
10199
|
};
|
|
10358
|
-
// src/commands/app-manifest-page/app-manifest-page.ts
|
|
10359
|
-
const ESCAPES = {
|
|
10360
|
-
"&": "&",
|
|
10361
|
-
"<": "<",
|
|
10362
|
-
">": ">",
|
|
10363
|
-
"\"": """,
|
|
10364
|
-
"'": "'"
|
|
10365
|
-
};
|
|
10366
|
-
const escapeHtml = (text) => text.replace(/[&<>"']/g, (c) => ESCAPES[c]);
|
|
10367
|
-
/**
|
|
10368
|
-
* The page the local server shows: a form that posts the manifest to GitHub on load (the manifest flow takes a form
|
|
10369
|
-
* post, not a link), with a button for a browser that blocks the script.
|
|
10370
|
-
*/
|
|
10371
|
-
function appManifestPage(action, manifest) {
|
|
10372
|
-
return `<!doctype html>
|
|
10373
|
-
<html lang="en">
|
|
10374
|
-
<head><meta charset="utf-8"><title>Create ${escapeHtml(manifest.name)}</title></head>
|
|
10375
|
-
<body>
|
|
10376
|
-
<form id="form" method="post" action="${escapeHtml(action)}">
|
|
10377
|
-
<input type="hidden" name="manifest" value="${escapeHtml(JSON.stringify(manifest))}">
|
|
10378
|
-
<p>Sending the manifest to GitHub. If nothing happens, <button type="submit">continue</button>.</p>
|
|
10379
|
-
</form>
|
|
10380
|
-
<script>document.getElementById("form").submit();<\/script>
|
|
10381
|
-
</body>
|
|
10382
|
-
</html>
|
|
10383
|
-
`;
|
|
10384
|
-
}
|
|
10385
|
-
// src/commands/build-app-manifest/build-app-manifest.ts
|
|
10386
|
-
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10387
|
-
/**
|
|
10388
|
-
* The manifest to post to GitHub: the shared part read from a file, with this instance's name, webhook and redirect.
|
|
10389
|
-
* Throws a message that names the problem when the file or the webhook URL is not usable, so nothing reaches GitHub.
|
|
10390
|
-
*/
|
|
10391
|
-
function buildAppManifest(input) {
|
|
10392
|
-
const { base } = input;
|
|
10393
|
-
if (!isRecord(base)) throw new Error("the manifest file must hold a JSON object");
|
|
10394
|
-
const permissions = base["default_permissions"];
|
|
10395
|
-
if (!isRecord(permissions) || !Object.values(permissions).every((access) => typeof access === "string")) throw new Error("the manifest file needs a default_permissions object of permission name to access");
|
|
10396
|
-
const events = base["default_events"];
|
|
10397
|
-
if (!Array.isArray(events) || !events.every((event) => typeof event === "string")) throw new Error("the manifest file needs a default_events list of event names");
|
|
10398
|
-
let webhook;
|
|
10399
|
-
try {
|
|
10400
|
-
webhook = new URL(input.webhookUrl);
|
|
10401
|
-
} catch {
|
|
10402
|
-
throw new Error(`the webhook URL is not a URL: ${input.webhookUrl}`);
|
|
10403
|
-
}
|
|
10404
|
-
if (webhook.protocol !== "https:") throw new Error("the webhook URL must be https: GitHub only delivers to one");
|
|
10405
|
-
return {
|
|
10406
|
-
name: input.name,
|
|
10407
|
-
...typeof base["description"] === "string" ? { description: base["description"] } : {},
|
|
10408
|
-
...typeof base["url"] === "string" ? { url: base["url"] } : {},
|
|
10409
|
-
public: base["public"] === true,
|
|
10410
|
-
redirect_url: input.redirectUrl,
|
|
10411
|
-
hook_attributes: {
|
|
10412
|
-
url: webhook.href,
|
|
10413
|
-
active: true
|
|
10414
|
-
},
|
|
10415
|
-
default_permissions: permissions,
|
|
10416
|
-
default_events: events
|
|
10417
|
-
};
|
|
10418
|
-
}
|
|
10419
|
-
// src/commands/convert-app-manifest/convert-app-manifest.ts
|
|
10420
|
-
/**
|
|
10421
|
-
* Exchanges the one-time code from the manifest flow for the App's id, private key and webhook secret
|
|
10422
|
-
* (`POST /app-manifests/{code}/conversions`, which takes no token). The code works once, and GitHub shows the key
|
|
10423
|
-
* once. An error names the status, never the body: the body of a success is the secrets.
|
|
10424
|
-
*/
|
|
10425
|
-
async function convertAppManifest(code, fetchImpl = fetch) {
|
|
10426
|
-
const response = await fetchImpl(`https://api.github.com/app-manifests/${encodeURIComponent(code)}/conversions`, {
|
|
10427
|
-
method: "POST",
|
|
10428
|
-
headers: {
|
|
10429
|
-
accept: "application/vnd.github+json",
|
|
10430
|
-
"x-github-api-version": "2022-11-28"
|
|
10431
|
-
}
|
|
10432
|
-
});
|
|
10433
|
-
if (!response.ok) throw new Error(`GitHub did not convert the manifest (HTTP ${response.status})`);
|
|
10434
|
-
const { id, slug, html_url: htmlUrl, pem, webhook_secret: webhookSecret } = await response.json();
|
|
10435
|
-
if (typeof id !== "number" || typeof slug !== "string" || typeof htmlUrl !== "string" || typeof pem !== "string" || typeof webhookSecret !== "string") throw new Error("GitHub's answer did not hold the App id, private key and webhook secret");
|
|
10436
|
-
return {
|
|
10437
|
-
id,
|
|
10438
|
-
slug,
|
|
10439
|
-
htmlUrl,
|
|
10440
|
-
pem,
|
|
10441
|
-
webhookSecret
|
|
10442
|
-
};
|
|
10443
|
-
}
|
|
10444
|
-
// src/commands/serve-app-manifest/serve-app-manifest.ts
|
|
10445
|
-
const LOOPBACK = "127.0.0.1";
|
|
10446
|
-
const FIVE_MINUTES = 3e5;
|
|
10447
|
-
/**
|
|
10448
|
-
* A one-shot server on a random loopback port: `/` shows the page that posts the manifest to GitHub, `/callback` takes
|
|
10449
|
-
* the one-time code GitHub redirects back with. The code is only accepted with the `state` it was started with, and a
|
|
10450
|
-
* request that does not name this server's own address (a DNS-rebinding page) is refused.
|
|
10451
|
-
*/
|
|
10452
|
-
async function serveAppManifest(input) {
|
|
10453
|
-
let resolveCode;
|
|
10454
|
-
let rejectCode;
|
|
10455
|
-
const code = new Promise((resolve, reject) => {
|
|
10456
|
-
resolveCode = resolve;
|
|
10457
|
-
rejectCode = reject;
|
|
10458
|
-
});
|
|
10459
|
-
code.catch(() => {});
|
|
10460
|
-
const server = createServer((req, res) => {
|
|
10461
|
-
const reply = (status, type, body) => {
|
|
10462
|
-
res.writeHead(status, {
|
|
10463
|
-
"content-type": `${type}; charset=utf-8`,
|
|
10464
|
-
"cache-control": "no-store"
|
|
10465
|
-
});
|
|
10466
|
-
res.end(body);
|
|
10467
|
-
};
|
|
10468
|
-
const { port } = server.address();
|
|
10469
|
-
if (req.headers.host !== `${LOOPBACK}:${port}`) return reply(403, "text/plain", "forbidden");
|
|
10470
|
-
const url = new URL(req.url, `http://${LOOPBACK}:${port}`);
|
|
10471
|
-
if (url.pathname === "/") return reply(200, "text/html", input.page(`http://${LOOPBACK}:${port}/callback`));
|
|
10472
|
-
if (url.pathname === "/callback") {
|
|
10473
|
-
const got = url.searchParams.get("code");
|
|
10474
|
-
if (url.searchParams.get("state") !== input.state || !got) return reply(400, "text/plain", "bad request");
|
|
10475
|
-
reply(200, "text/plain", "Done. You can close this tab and go back to the terminal.");
|
|
10476
|
-
resolveCode(got);
|
|
10477
|
-
return;
|
|
10478
|
-
}
|
|
10479
|
-
reply(404, "text/plain", "not found");
|
|
10480
|
-
});
|
|
10481
|
-
await new Promise((resolve) => server.listen(0, LOOPBACK, resolve));
|
|
10482
|
-
const timer = setTimeout(() => rejectCode(/* @__PURE__ */ new Error("timed out waiting for GitHub: the App was not created")), input.timeoutMs ?? FIVE_MINUTES);
|
|
10483
|
-
const close = () => {
|
|
10484
|
-
clearTimeout(timer);
|
|
10485
|
-
server.close();
|
|
10486
|
-
server.closeAllConnections();
|
|
10487
|
-
};
|
|
10488
|
-
return {
|
|
10489
|
-
url: `http://${LOOPBACK}:${server.address().port}/`,
|
|
10490
|
-
code,
|
|
10491
|
-
close
|
|
10492
|
-
};
|
|
10493
|
-
}
|
|
10494
10200
|
// src/commands/github-app-create/github-app-create.ts
|
|
10495
10201
|
/**
|
|
10496
10202
|
* `holocron github-app create` — create a GitHub App from a manifest (GitHub's manifest flow), and keep its
|
|
@@ -10723,7 +10429,7 @@ const menuCommand = (version) => ({
|
|
|
10723
10429
|
async function resolveMonitoringChecks(input) {
|
|
10724
10430
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
10725
10431
|
await loader.load();
|
|
10726
|
-
assertPluginsResolvable(loader, "monitoring check");
|
|
10432
|
+
assertPluginsResolvable$1(loader, "monitoring check");
|
|
10727
10433
|
return [...loader.get("monitoring").checks];
|
|
10728
10434
|
}
|
|
10729
10435
|
/**
|
|
@@ -12228,13 +11934,13 @@ function generateHolocronConfig(opts) {
|
|
|
12228
11934
|
lines.push(``);
|
|
12229
11935
|
return lines.join("\n");
|
|
12230
11936
|
}
|
|
12231
|
-
const SKIP_DIRS$
|
|
11937
|
+
const SKIP_DIRS$1 = [
|
|
12232
11938
|
".git",
|
|
12233
11939
|
"node_modules",
|
|
12234
11940
|
"dist",
|
|
12235
11941
|
".turbo"
|
|
12236
11942
|
];
|
|
12237
|
-
const defaultWalkFiles
|
|
11943
|
+
const defaultWalkFiles = (dir) => walkFilesSync(dir, { skip: SKIP_DIRS$1 });
|
|
12238
11944
|
function isBinary(content) {
|
|
12239
11945
|
for (let i = 0; i < Math.min(content.length, 8e3); i++) if (content.charCodeAt(i) === 0) return true;
|
|
12240
11946
|
return false;
|
|
@@ -12306,7 +12012,7 @@ async function runNew(input) {
|
|
|
12306
12012
|
const execFn = input.exec ?? defaultExec$2;
|
|
12307
12013
|
const readFn = input.readFile ?? defaultReadFile;
|
|
12308
12014
|
const writeFn = input.writeFile ?? defaultWriteFile;
|
|
12309
|
-
const walkFn = input.walkFiles ?? defaultWalkFiles
|
|
12015
|
+
const walkFn = input.walkFiles ?? defaultWalkFiles;
|
|
12310
12016
|
preflight();
|
|
12311
12017
|
const templateRepo = `${org}/${input.type}-template`;
|
|
12312
12018
|
const newRepo = `${org}/${input.name}`;
|
|
@@ -12953,7 +12659,7 @@ async function runNotificationsCreateServer(input) {
|
|
|
12953
12659
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
12954
12660
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
12955
12661
|
await loader.load();
|
|
12956
|
-
assertPluginsResolvable(loader, "notifications create-server");
|
|
12662
|
+
assertPluginsResolvable$1(loader, "notifications create-server");
|
|
12957
12663
|
const dryRun = input.context.dryRun ?? false;
|
|
12958
12664
|
const sleep = input.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
12959
12665
|
const refuse = (message, reason = message) => {
|
|
@@ -16208,12 +15914,12 @@ function listProbes(groups) {
|
|
|
16208
15914
|
return lines;
|
|
16209
15915
|
}
|
|
16210
15916
|
// src/commands/probe/references/clone-org.ts
|
|
16211
|
-
const SKIP_DIRS
|
|
15917
|
+
const SKIP_DIRS = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
16212
15918
|
const MAX_FILE_BYTES = 5242880;
|
|
16213
15919
|
/** Every text file under `dir`: not in `.git` or `node_modules`, under 5 MiB, and without a NUL in its first KiB. */
|
|
16214
15920
|
function* textFiles(dir, root = dir) {
|
|
16215
15921
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
16216
|
-
if (SKIP_DIRS
|
|
15922
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
16217
15923
|
const path = join(dir, entry.name);
|
|
16218
15924
|
if (entry.isDirectory()) yield* textFiles(path, root);
|
|
16219
15925
|
else if (entry.isFile() && statSync(path).size < MAX_FILE_BYTES) {
|
|
@@ -16905,7 +16611,7 @@ async function runProjectMove(input) {
|
|
|
16905
16611
|
};
|
|
16906
16612
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
16907
16613
|
await loader.load();
|
|
16908
|
-
assertPluginsResolvable(loader, "project move");
|
|
16614
|
+
assertPluginsResolvable$1(loader, "project move");
|
|
16909
16615
|
const opened = await openBoardContext({
|
|
16910
16616
|
loaded: input.loaded,
|
|
16911
16617
|
context: input.context,
|
|
@@ -17031,7 +16737,7 @@ async function openProjects(input, command) {
|
|
|
17031
16737
|
if (entry?.cardinality !== "single") throw new ConfigError(`${command}: needs a \`projects\` provider in holocron.config.ts, e.g. providers: { projects: "github" }`);
|
|
17032
16738
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
17033
16739
|
await withSpinner("Loading plugins…", () => loader.load());
|
|
17034
|
-
assertPluginsResolvable(loader, command);
|
|
16740
|
+
assertPluginsResolvable$1(loader, command);
|
|
17035
16741
|
if (!loader.has("projects")) {
|
|
17036
16742
|
const failure = loader.loadFailures().find((f) => f.key === "projects");
|
|
17037
16743
|
throw new ConfigError(`${command}: the \`projects\` provider is not available${failure ? ` (\`${failure.provider}\` failed to load: ${describeError(failure.error)})` : ""}`);
|
|
@@ -17491,7 +17197,7 @@ async function runProjectReconcile(input) {
|
|
|
17491
17197
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
17492
17198
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
17493
17199
|
await loader.load();
|
|
17494
|
-
assertPluginsResolvable(loader, "project reconcile");
|
|
17200
|
+
assertPluginsResolvable$1(loader, "project reconcile");
|
|
17495
17201
|
const dryRun = input.context.dryRun ?? false;
|
|
17496
17202
|
const report = {
|
|
17497
17203
|
status: "ok",
|
|
@@ -18350,7 +18056,7 @@ async function runSetup(input) {
|
|
|
18350
18056
|
const logger = getLogger();
|
|
18351
18057
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
18352
18058
|
await withSpinner("Loading plugins…", () => loader.load());
|
|
18353
|
-
assertPluginsResolvable(loader, "repo setup");
|
|
18059
|
+
assertPluginsResolvable$1(loader, "repo setup");
|
|
18354
18060
|
const config = input.loaded.resolved;
|
|
18355
18061
|
const dryRun = input.context.dryRun ?? false;
|
|
18356
18062
|
const steps = [];
|
|
@@ -19179,7 +18885,7 @@ async function runCleanupBranches(input) {
|
|
|
19179
18885
|
// c8 ignore next -- real PluginLoader construction is integration-level; unit tests always supply loader
|
|
19180
18886
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
19181
18887
|
await loader.load();
|
|
19182
|
-
assertPluginsResolvable(loader, "repo cleanup branches");
|
|
18888
|
+
assertPluginsResolvable$1(loader, "repo cleanup branches");
|
|
19183
18889
|
if (!loader.has("source")) throw new Error("source capability is not configured — add a source provider to holocron.config.json");
|
|
19184
18890
|
const source = loader.get("source");
|
|
19185
18891
|
const { listPullRequests, listPullRequestCommits, listBranches, deleteBranch } = source;
|
|
@@ -20438,20 +20144,6 @@ const repoSyncCommand = {
|
|
|
20438
20144
|
*
|
|
20439
20145
|
* After running, `pnpm install && holocron run ci`.
|
|
20440
20146
|
*/
|
|
20441
|
-
const FETCH_TIMEOUT_MS = 4e3;
|
|
20442
|
-
/** Resolve a package's `latest` dist-tag from the npm registry. */
|
|
20443
|
-
const fetchLatestFromNpm = async (pkg) => {
|
|
20444
|
-
try {
|
|
20445
|
-
const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(pkg)}`, {
|
|
20446
|
-
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
|
|
20447
|
-
headers: { accept: "application/vnd.npm.install-v1+json" }
|
|
20448
|
-
});
|
|
20449
|
-
if (!res.ok) return null;
|
|
20450
|
-
return (await res.json())["dist-tags"]?.["latest"] ?? null;
|
|
20451
|
-
} catch {
|
|
20452
|
-
return null;
|
|
20453
|
-
}
|
|
20454
|
-
};
|
|
20455
20147
|
const HOLOCRON_PACKAGE = /^@theholocron\/[a-z0-9-]+$/;
|
|
20456
20148
|
/**
|
|
20457
20149
|
* Rewrite every `@theholocron/*` pin in a `pnpm-workspace.yaml` to `latest`,
|
|
@@ -20633,188 +20325,15 @@ const upgradeDepsCommand = {
|
|
|
20633
20325
|
}
|
|
20634
20326
|
};
|
|
20635
20327
|
// src/commands/upgrade-node/upgrade-node.ts
|
|
20636
|
-
|
|
20637
|
-
|
|
20638
|
-
|
|
20639
|
-
|
|
20640
|
-
|
|
20641
|
-
|
|
20642
|
-
|
|
20643
|
-
|
|
20644
|
-
|
|
20645
|
-
];
|
|
20646
|
-
function patchPackageJson(content, from, to) {
|
|
20647
|
-
let pkg;
|
|
20648
|
-
try {
|
|
20649
|
-
pkg = JSON.parse(content);
|
|
20650
|
-
} catch {
|
|
20651
|
-
return null;
|
|
20652
|
-
}
|
|
20653
|
-
let changed = false;
|
|
20654
|
-
const engines = pkg.engines;
|
|
20655
|
-
if (engines?.node && /^>=\d+(?:\.0\.0)?$/.test(engines.node)) {
|
|
20656
|
-
if (parseInt(engines.node.match(/\d+/)[0], 10) === from) {
|
|
20657
|
-
engines.node = `>=${to}.0.0`;
|
|
20658
|
-
changed = true;
|
|
20659
|
-
}
|
|
20660
|
-
}
|
|
20661
|
-
for (const field of ["devDependencies", "dependencies"]) {
|
|
20662
|
-
const deps = pkg[field];
|
|
20663
|
-
if (!deps?.["@types/node"]) continue;
|
|
20664
|
-
if (deps["@types/node"] === `^${from}.0.0`) {
|
|
20665
|
-
deps["@types/node"] = `^${to}.0.0`;
|
|
20666
|
-
changed = true;
|
|
20667
|
-
}
|
|
20668
|
-
}
|
|
20669
|
-
return changed ? stringifyJson(pkg, { like: content }) : null;
|
|
20670
|
-
}
|
|
20671
|
-
function patchYaml(content, from, to) {
|
|
20672
|
-
const updated = content.replace(/node-version:\s+['"]?(\d+)['"]?/g, (match, ver) => ver === String(from) ? match.replace(String(from), String(to)) : match);
|
|
20673
|
-
return updated !== content ? updated : null;
|
|
20674
|
-
}
|
|
20675
|
-
function patchPinFile(content, from, to) {
|
|
20676
|
-
const trimmed = content.trim();
|
|
20677
|
-
if (trimmed === String(from) || trimmed.startsWith(`${from}.`)) return `${to}\n`;
|
|
20678
|
-
return null;
|
|
20679
|
-
}
|
|
20680
|
-
function patchDockerfile(content, from, to) {
|
|
20681
|
-
const updated = content.replace(/^(FROM\s+node:)(\d+)/gm, (match, prefix, ver) => ver === String(from) ? `${prefix}${to}` : match);
|
|
20682
|
-
return updated !== content ? updated : null;
|
|
20683
|
-
}
|
|
20684
|
-
function patchToolVersions(content, from, to) {
|
|
20685
|
-
const updated = content.replace(/^(nodejs\s+)(\d+)/gm, (match, prefix, ver) => ver === String(from) ? `${prefix}${to}` : match);
|
|
20686
|
-
return updated !== content ? updated : null;
|
|
20687
|
-
}
|
|
20688
|
-
const PATTERNS = [
|
|
20689
|
-
{
|
|
20690
|
-
matches: (n) => n === "package.json",
|
|
20691
|
-
patch: patchPackageJson
|
|
20692
|
-
},
|
|
20693
|
-
{
|
|
20694
|
-
matches: (n) => n.endsWith(".yml") || n.endsWith(".yaml"),
|
|
20695
|
-
patch: patchYaml
|
|
20696
|
-
},
|
|
20697
|
-
{
|
|
20698
|
-
matches: (n) => n === ".nvmrc" || n === ".node-version",
|
|
20699
|
-
patch: patchPinFile
|
|
20700
|
-
},
|
|
20701
|
-
{
|
|
20702
|
-
matches: (n) => n === "Dockerfile" || n.startsWith("Dockerfile."),
|
|
20703
|
-
patch: patchDockerfile
|
|
20704
|
-
},
|
|
20705
|
-
{
|
|
20706
|
-
matches: (n) => n === ".tool-versions",
|
|
20707
|
-
patch: patchToolVersions
|
|
20708
|
-
}
|
|
20709
|
-
];
|
|
20710
|
-
function detectFrom(cwd, _readFile) {
|
|
20711
|
-
for (const name of [".nvmrc", ".node-version"]) try {
|
|
20712
|
-
const major = parseInt(_readFile(join(cwd, name)).trim(), 10);
|
|
20713
|
-
if (!isNaN(major)) return major;
|
|
20714
|
-
} catch {}
|
|
20715
|
-
try {
|
|
20716
|
-
const node = JSON.parse(_readFile(join(cwd, "package.json"))).engines?.node;
|
|
20717
|
-
if (node) {
|
|
20718
|
-
const m = node.match(/(\d+)/);
|
|
20719
|
-
if (m) return parseInt(m[1], 10);
|
|
20720
|
-
}
|
|
20721
|
-
} catch {}
|
|
20722
|
-
return null;
|
|
20723
|
-
}
|
|
20724
|
-
const defaultWalkFiles = (dir) => walkFilesSync(dir, { skip: SKIP_DIRS });
|
|
20725
|
-
async function runUpgradeNode(input) {
|
|
20726
|
-
const print = input.print ?? ((line) => console.log(line));
|
|
20727
|
-
const logger = input.logger ?? getLogger();
|
|
20728
|
-
const cwd = input.cwd ?? process.cwd();
|
|
20729
|
-
const { to, dryRun = false, extra = [] } = input;
|
|
20730
|
-
const _readFile = input.readFile ?? ((p) => readFileSync(p, "utf8"));
|
|
20731
|
-
const _writeFile = input.writeFile ?? ((p, c) => writeFileSync(p, c));
|
|
20732
|
-
const _walkFiles = input.walkFiles ?? defaultWalkFiles;
|
|
20733
|
-
let walked;
|
|
20734
|
-
try {
|
|
20735
|
-
walked = _walkFiles(cwd);
|
|
20736
|
-
} catch (error) {
|
|
20737
|
-
const message = `could not read ${cwd}: ${errorMessage(error)}`;
|
|
20738
|
-
logger.warn({
|
|
20739
|
-
to,
|
|
20740
|
-
reason: message
|
|
20741
|
-
}, "upgrade node: done");
|
|
20742
|
-
return {
|
|
20743
|
-
status: "fail",
|
|
20744
|
-
updated: [],
|
|
20745
|
-
message
|
|
20746
|
-
};
|
|
20747
|
-
}
|
|
20748
|
-
const from = input.from ?? detectFrom(cwd, _readFile);
|
|
20749
|
-
if (from === null) {
|
|
20750
|
-
const message = "could not detect current Node version — pass --from <major>";
|
|
20751
|
-
logger.warn({
|
|
20752
|
-
to,
|
|
20753
|
-
reason: message
|
|
20754
|
-
}, "upgrade node: done");
|
|
20755
|
-
return {
|
|
20756
|
-
status: "fail",
|
|
20757
|
-
updated: [],
|
|
20758
|
-
message
|
|
20759
|
-
};
|
|
20760
|
-
}
|
|
20761
|
-
logger.info({
|
|
20762
|
-
from,
|
|
20763
|
-
to,
|
|
20764
|
-
dryRun: dryRun || void 0
|
|
20765
|
-
}, "upgrade node: start");
|
|
20766
|
-
if (from === to) {
|
|
20767
|
-
print(`Already at Node.js ${to} — nothing to do.`);
|
|
20768
|
-
logger.info({
|
|
20769
|
-
from,
|
|
20770
|
-
to,
|
|
20771
|
-
updated: 0,
|
|
20772
|
-
status: "ok"
|
|
20773
|
-
}, "upgrade node: done");
|
|
20774
|
-
return {
|
|
20775
|
-
status: "ok",
|
|
20776
|
-
updated: []
|
|
20777
|
-
};
|
|
20778
|
-
}
|
|
20779
|
-
print(`Upgrading Node.js ${from} → ${to}${dryRun ? " (dry-run)" : ""}…`);
|
|
20780
|
-
const updated = [];
|
|
20781
|
-
const root = resolve(cwd);
|
|
20782
|
-
const scanned = [...walked, ...extra.map((p) => join(cwd, p))];
|
|
20783
|
-
for (const abs of scanned) {
|
|
20784
|
-
const name = basename(abs);
|
|
20785
|
-
const pattern = PATTERNS.find((p) => p.matches(name));
|
|
20786
|
-
if (!pattern) continue;
|
|
20787
|
-
let content;
|
|
20788
|
-
try {
|
|
20789
|
-
content = _readFile(abs);
|
|
20790
|
-
} catch {
|
|
20791
|
-
continue;
|
|
20792
|
-
}
|
|
20793
|
-
const patched = pattern.patch(content, from, to);
|
|
20794
|
-
if (patched === null) continue;
|
|
20795
|
-
const absolute = resolve(abs);
|
|
20796
|
-
const rel = absolute.startsWith(root + sep) ? absolute.slice(root.length + 1) : abs;
|
|
20797
|
-
if (!dryRun) _writeFile(abs, patched);
|
|
20798
|
-
print(` ${dryRun ? "~" : "✓"} ${rel}`);
|
|
20799
|
-
logger.debug({
|
|
20800
|
-
file: rel,
|
|
20801
|
-
from,
|
|
20802
|
-
to
|
|
20803
|
-
}, "upgrade node: patched");
|
|
20804
|
-
updated.push(rel);
|
|
20805
|
-
}
|
|
20806
|
-
if (updated.length === 0) print(` · no files contained Node.js ${from} pins`);
|
|
20807
|
-
const status = dryRun ? "dry-run" : "ok";
|
|
20808
|
-
logger.info({
|
|
20809
|
-
from,
|
|
20810
|
-
to,
|
|
20811
|
-
updated: updated.length,
|
|
20812
|
-
status
|
|
20813
|
-
}, "upgrade node: done");
|
|
20814
|
-
return {
|
|
20815
|
-
status,
|
|
20816
|
-
updated
|
|
20817
|
-
};
|
|
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
|
+
});
|
|
20818
20337
|
}
|
|
20819
20338
|
// src/commands/upgrade-node/upgrade-node.args.ts
|
|
20820
20339
|
const upgradeNodeArgs = (yy) => yy.positional("to", {
|
|
@@ -20837,7 +20356,7 @@ const upgradeNodeCommand = {
|
|
|
20837
20356
|
const extraRaw = JSON.parse(raw).upgrade?.node?.extra;
|
|
20838
20357
|
if (Array.isArray(extraRaw)) extra = extraRaw;
|
|
20839
20358
|
} catch {}
|
|
20840
|
-
const report = await runUpgradeNode({
|
|
20359
|
+
const report = await runUpgradeNode$1({
|
|
20841
20360
|
to: Number(to),
|
|
20842
20361
|
...argv.from != null ? { from: argv.from } : {},
|
|
20843
20362
|
cwd: argv.cwd,
|
|
@@ -20982,7 +20501,7 @@ async function runSecretSet(input) {
|
|
|
20982
20501
|
const logger = input.logger ?? getLogger();
|
|
20983
20502
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
20984
20503
|
await loader.load();
|
|
20985
|
-
assertPluginsResolvable(loader, "secrets set");
|
|
20504
|
+
assertPluginsResolvable$1(loader, "secrets set");
|
|
20986
20505
|
const dryRun = input.context.dryRun ?? false;
|
|
20987
20506
|
const scope = input.scope ?? { kind: "repo" };
|
|
20988
20507
|
if (!loader.has("secrets")) throw new Error("`secrets` capability is not configured — add a `secrets` provider to holocron.config.json");
|
|
@@ -21111,7 +20630,7 @@ async function runSecretsList(input) {
|
|
|
21111
20630
|
const logger = input.logger ?? getLogger();
|
|
21112
20631
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
21113
20632
|
await loader.load();
|
|
21114
|
-
assertPluginsResolvable(loader, "secrets list");
|
|
20633
|
+
assertPluginsResolvable$1(loader, "secrets list");
|
|
21115
20634
|
if (!loader.has("secrets")) throw new Error("`secrets` capability is not configured — add a `secrets` provider to holocron.config.json");
|
|
21116
20635
|
const secrets = loader.get("secrets");
|
|
21117
20636
|
const groups = [];
|
|
@@ -21311,7 +20830,7 @@ async function runSecretsSync(input) {
|
|
|
21311
20830
|
const logger = input.logger ?? getLogger();
|
|
21312
20831
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
21313
20832
|
await withSpinner("Loading plugins…", () => loader.load());
|
|
21314
|
-
assertPluginsResolvable(loader, "secrets sync");
|
|
20833
|
+
assertPluginsResolvable$1(loader, "secrets sync");
|
|
21315
20834
|
logger.info({
|
|
21316
20835
|
environment: input.environmentId,
|
|
21317
20836
|
dryRun: (input.context.dryRun ?? false) || void 0
|
|
@@ -22026,7 +21545,7 @@ async function runSpecsSync(input) {
|
|
|
22026
21545
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
22027
21546
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
22028
21547
|
await loader.load();
|
|
22029
|
-
assertPluginsResolvable(loader, "specs sync");
|
|
21548
|
+
assertPluginsResolvable$1(loader, "specs sync");
|
|
22030
21549
|
const dryRun = input.context.dryRun ?? false;
|
|
22031
21550
|
const refuse = (message, reason = message) => {
|
|
22032
21551
|
print(` ${style.fail(message)}`);
|