Lines 38-78javascript
38 if (!trimmed) throw new Error("parseSpec: empty specifier");
39 const at = trimmed.lastIndexOf("@");
41 return { name: trimmed, range: "*" };
43 const name = trimmed.slice(0, at);
44 const range = trimmed.slice(at + 1);
45 return { name, range: range.length > 0 ? range : "*" };
47function specName(spec) {
48 return parseSpec(spec).name;
51// cli/src/plugin-store/load.ts
52async function loadPlugins(projectDir, plugins, registry = pluginRegistry, opts = {}) {
55 for (const spec of plugins) {
57 const { name } = parseSpec(spec);
58 const entry = resolvePluginEntry(projectDir, name);
59 const mod = await import(pathToFileURL(entry).href);
60 if (typeof mod.register !== "function") {
MediumDynamic Require
Package source references dynamic require/import behavior.
dist/plugin-store-3DAVGKHN.jsView on unpkg · L58 61 throw new Error(`plugin "${name}" does not export a register() function`);
63 mod.register(registry);
66 const message = err instanceof Error ? err.message : String(err);
67 failed.push({ spec, error: `failed to load plugin "${spec}": ${message}` });
68 opts.log?.warn(`plugin load failed: ${spec}`, { error: message });
71 return { loaded, failed };
73var defaultInstall = async (dir) => {
74 const { portableSpawn } = await import('./core/index.js');
75 const hasLock = existsSync(`${dir}/bun.lock`) || existsSync(`${dir}/bun.lockb`) || existsSync(`${dir}/package-lock.json`);
76 const args = hasLock ? ["bun", "install", "--frozen-lockfile"] : ["bun", "install"];
77 const proc = portableSpawn(args, { cwd: dir });