@theholocron/kyber 5.0.0-alpha.442 → 5.0.0-alpha.443

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.
@@ -195,7 +195,7 @@ export declare function createPluginSystem<Caps extends CapabilityShape, Config,
195
195
  * has the plugins) into one actionable error, instead of a stack of `Cannot find package` failures.
196
196
  *
197
197
  * Does nothing in every other case: some capability loaded, a failure that is not a missing package (a bad token, an
198
- * unimplemented capability) or no plugins configured at all. Call it right after `await loader.load()`.
198
+ * unimplemented capability, a plugin whose own dependency is missing) or no plugins configured at all. Call it right after `await loader.load()`.
199
199
  *
200
200
  * @param loader - A loaded plugin loader.
201
201
  * @param command - The command being run, for the message.
package/dist/plugins.mjs CHANGED
@@ -7,11 +7,21 @@ var LoaderError = class extends Error {
7
7
  };
8
8
  // src/plugins/assert-plugins-resolvable/assert-plugins-resolvable.ts
9
9
  /**
10
+ * Whether a failure is the plugin package itself not being found. A plugin that is installed but one of whose own
11
+ * dependencies is not (`Cannot find module 'tslib'`, a half-finished install) also fails to import, but running from
12
+ * a global install would not fix it and "no plugin resolves here" would hide the real cause, so it is not one.
13
+ */
14
+ function isUnresolvedPlugin({ error, packageName }) {
15
+ if (!(error instanceof LoaderError) || !error.message.startsWith("failed to import")) return false;
16
+ const missing = /Cannot find (?:package|module) '([^']+)'/.exec(error.message)?.[1];
17
+ return missing === void 0 || missing === packageName || missing.startsWith(`${packageName}/`);
18
+ }
19
+ /**
10
20
  * Turn "every plugin failed because none is installed here" (a CLI run from a global install, outside the project that
11
21
  * has the plugins) into one actionable error, instead of a stack of `Cannot find package` failures.
12
22
  *
13
23
  * Does nothing in every other case: some capability loaded, a failure that is not a missing package (a bad token, an
14
- * unimplemented capability) or no plugins configured at all. Call it right after `await loader.load()`.
24
+ * unimplemented capability, a plugin whose own dependency is missing) or no plugins configured at all. Call it right after `await loader.load()`.
15
25
  *
16
26
  * @param loader - A loaded plugin loader.
17
27
  * @param command - The command being run, for the message.
@@ -21,8 +31,7 @@ function assertPluginsResolvable(loader, command, createError) {
21
31
  if (loader.loadedKeys().length > 0) return;
22
32
  const failures = loader.loadFailures();
23
33
  if (failures.length === 0) return;
24
- const isImportFailure = (err) => err instanceof LoaderError && err.message.startsWith("failed to import");
25
- if (!failures.every((f) => isImportFailure(f.error))) return;
34
+ if (!failures.every(isUnresolvedPlugin)) return;
26
35
  throw createError(command, [...new Set(failures.map((f) => f.packageName))]);
27
36
  }
28
37
  // src/plugins/default-importer/default-importer.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/kyber",
3
- "version": "5.0.0-alpha.442",
3
+ "version": "5.0.0-alpha.443",
4
4
  "description": "The reusable parts of a command-line tool: terminal output, prompts, the interactive menu, the update notifier, safe handling of tokens, a test harness and the global flags.",
5
5
  "keywords": [
6
6
  "cli",
@@ -105,12 +105,12 @@
105
105
  "typescript": "^5.9.3",
106
106
  "vitest": "^5.1.0",
107
107
  "yargs": "^18.1.0",
108
- "@theholocron/datapad": "5.0.0-alpha.442",
108
+ "@theholocron/eslint-config": "^8.9.0-alpha.17",
109
109
  "@theholocron/tsconfig": "^8.9.0-alpha.17",
110
+ "@theholocron/observability": "0.7.0-alpha.4",
110
111
  "@theholocron/tsdown-config": "^8.9.0-alpha.17",
111
- "@theholocron/eslint-config": "^8.9.0-alpha.17",
112
112
  "@theholocron/vitest-config": "^8.9.0-alpha.17",
113
- "@theholocron/observability": "0.7.0-alpha.4"
113
+ "@theholocron/datapad": "5.0.0-alpha.443"
114
114
  },
115
115
  "peerDependencies": {
116
116
  "@inquirer/prompts": "^8.0.0",
@@ -121,7 +121,7 @@
121
121
  "dotenv": "^17.0.0",
122
122
  "ora": "^9.0.0",
123
123
  "yargs": "^18.0.0",
124
- "@theholocron/datapad": "^5.0.0-alpha.442",
124
+ "@theholocron/datapad": "^5.0.0-alpha.443",
125
125
  "@theholocron/observability": "^0.7.0-alpha.4"
126
126
  },
127
127
  "peerDependenciesMeta": {