@theholocron/cli 3.45.2 → 3.45.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +42 -4
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -7,13 +7,13 @@ import yargs from "yargs";
|
|
|
7
7
|
import { hideBin } from "yargs/helpers";
|
|
8
8
|
import { AuthError, ProviderApiError, ProviderApiError as ProviderApiError$1 } from "@theholocron/http-client";
|
|
9
9
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
10
|
+
import { pathToFileURL } from "node:url";
|
|
10
11
|
import ora from "ora";
|
|
11
12
|
import chalk from "chalk";
|
|
12
13
|
import { execFile, execFileSync, spawnSync } from "node:child_process";
|
|
13
14
|
import { homedir } from "node:os";
|
|
14
15
|
import { createHash } from "node:crypto";
|
|
15
16
|
import { access, copyFile, mkdir, readFile, readdir, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
16
|
-
import { pathToFileURL } from "node:url";
|
|
17
17
|
import { generateReadme } from "@theholocron/components-doc/markdown";
|
|
18
18
|
import { getClients, getConfigs, getDocs, getPlugins, getSkills, getThemes, getUtils } from "@theholocron/registry-doc";
|
|
19
19
|
import { createGitHubClient } from "@theholocron/github-client";
|
|
@@ -323,7 +323,13 @@ const style = {
|
|
|
323
323
|
* don't export `verifyToken` can still store — with a warning — because
|
|
324
324
|
* "no verify path" shouldn't block credential storage.
|
|
325
325
|
*/
|
|
326
|
-
const defaultImporter$1 = async (pkg) =>
|
|
326
|
+
const defaultImporter$1 = async (pkg) => {
|
|
327
|
+
try {
|
|
328
|
+
return await import(pathToFileURL(createRequire(process.cwd() + "/").resolve(pkg)).href);
|
|
329
|
+
} catch {
|
|
330
|
+
return await import(pkg);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
327
333
|
/**
|
|
328
334
|
* Resolve a token from (positional → HOLOCRON_<X> → vendor-native env).
|
|
329
335
|
* Keyring is NOT consulted here — `auth set` writes TO the keyring, so
|
|
@@ -494,6 +500,34 @@ async function tryLoadHint(importer, packageName) {
|
|
|
494
500
|
}
|
|
495
501
|
//#endregion
|
|
496
502
|
//#region src/loader.ts
|
|
503
|
+
/**
|
|
504
|
+
* `PluginLoader` — loads provider plugins per the resolved config and
|
|
505
|
+
* builds a typed capability registry the runtime can query.
|
|
506
|
+
*
|
|
507
|
+
* Flow:
|
|
508
|
+
* 1. Walk `config.providers[*]` from `resolveConfig()`
|
|
509
|
+
* 2. For each entry, dynamic-import the resolved package name
|
|
510
|
+
* (`@theholocron/holocron-plugin-<provider>` by default)
|
|
511
|
+
* 3. Call the package's exported `createPlugin(options)` to get a
|
|
512
|
+
* plugin object whose `capabilities` map holds factories
|
|
513
|
+
* 4. Invoke the matching capability factory and stash the impl in
|
|
514
|
+
* the registry — single-cardinality entries hold one impl,
|
|
515
|
+
* many-cardinality entries hold an array
|
|
516
|
+
*
|
|
517
|
+
* A package may instead export a capability config (see
|
|
518
|
+
* `CapabilityConfigPackage` in config.ts). The loader detects the shape
|
|
519
|
+
* at import time and re-resolves to the underlying plugin, merging the
|
|
520
|
+
* preset options with any per-project overrides from the config file
|
|
521
|
+
* (project options win, mirroring ESLint's `extends` precedence).
|
|
522
|
+
*
|
|
523
|
+
* Loader keeps NO knowledge of vendor tokens. Each plugin reads its
|
|
524
|
+
* own env vars (`HOLOCRON_ADMIN_TOKEN`, `HOLOCRON_VERCEL_TOKEN`, etc.)
|
|
525
|
+
* inside its `createPlugin`. That keeps the loader vendor-agnostic
|
|
526
|
+
* and the auth story per-plugin explicit.
|
|
527
|
+
*
|
|
528
|
+
* `importer` is injectable so tests don't need real network or
|
|
529
|
+
* sibling packages installed.
|
|
530
|
+
*/
|
|
497
531
|
var LoaderError = class extends Error {
|
|
498
532
|
name = "LoaderError";
|
|
499
533
|
};
|
|
@@ -579,9 +613,13 @@ var PluginLoader = class {
|
|
|
579
613
|
return defaults;
|
|
580
614
|
}
|
|
581
615
|
};
|
|
582
|
-
/** Default importer —
|
|
616
|
+
/** Default importer — resolves from cwd first so the global CLI finds project plugins. */
|
|
583
617
|
const defaultImporter = async (pkg) => {
|
|
584
|
-
|
|
618
|
+
try {
|
|
619
|
+
return import(pathToFileURL(createRequire(process.cwd() + "/").resolve(pkg)).href);
|
|
620
|
+
} catch {
|
|
621
|
+
return import(pkg);
|
|
622
|
+
}
|
|
585
623
|
};
|
|
586
624
|
function isPluginModule(mod) {
|
|
587
625
|
return typeof mod.createPlugin === "function";
|