@pipelab/cli 2.0.0-beta.32 → 2.0.0-beta.34

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/index.mjs CHANGED
@@ -66874,7 +66874,6 @@ var import_semver = /* @__PURE__ */ __toESM(require_semver(), 1);
66874
66874
  var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
66875
66875
  var import_src$1 = /* @__PURE__ */ __toESM(require_src$1(), 1);
66876
66876
  const sendStartupProgress = (message) => {
66877
- console.log(`[Startup Progress] ${message}`);
66878
66877
  webSocketServer.broadcast("startup:progress", {
66879
66878
  type: "progress",
66880
66879
  data: { message }
@@ -67026,7 +67025,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
67026
67025
  const includePrerelease = !!(ctx.releaseTag && ctx.releaseTag !== "latest");
67027
67026
  let resolvedVersionOrRange = versionOrRange;
67028
67027
  if (resolvedVersionOrRange === "local") resolvedVersionOrRange = "latest";
67029
- console.log(`[Fetcher] Resolving ${packageName}@${resolvedVersionOrRange || "latest"}...`);
67028
+ console.debug(`[Fetcher] Resolving ${packageName}@${resolvedVersionOrRange || "latest"}...`);
67030
67029
  const resolveStart = Date.now();
67031
67030
  if (!await isOnline()) {
67032
67031
  console.warn(`[Fetcher] ${packageName}: offline mode detected (${Date.now() - resolveStart}ms), trying local fallback...`);
@@ -67034,7 +67033,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
67034
67033
  const fallbackVersion = await tryLocalFallback(resolvedVersionOrRange, /* @__PURE__ */ new Error("Offline"), baseDir, packageName, includePrerelease);
67035
67034
  if (fallbackVersion) {
67036
67035
  resolvedVersion = fallbackVersion;
67037
- console.log(`[Fetcher] ${packageName}: Resolved to local fallback ${resolvedVersion} (${Date.now() - fallbackStart}ms)`);
67036
+ console.debug(`[Fetcher] ${packageName}: Resolved to local fallback ${resolvedVersion} (${Date.now() - fallbackStart}ms)`);
67038
67037
  } else throw new Error(`Offline and no local fallback version available for ${packageName}`);
67039
67038
  } else try {
67040
67039
  const cachePath = ctx.getCachePath(CacheFolder.Pacote);
@@ -67052,7 +67051,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
67052
67051
  if (releaseTagVersion && import_semver.default.valid(releaseTagVersion)) {
67053
67052
  const rewrittenRangeForCheck = allowPrereleaseInRange(range);
67054
67053
  if (import_semver.default.satisfies(releaseTagVersion, rewrittenRangeForCheck, { includePrerelease: true })) {
67055
- console.log(`[Fetcher] Using release tag "${ctx.releaseTag}" (${releaseTagVersion}) for ${packageName}@${range} because it satisfies the range`);
67054
+ console.debug(`[Fetcher] Using release tag "${ctx.releaseTag}" (${releaseTagVersion}) for ${packageName}@${range} because it satisfies the range`);
67056
67055
  foundVersion = releaseTagVersion;
67057
67056
  }
67058
67057
  }
@@ -67062,7 +67061,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
67062
67061
  if (rewrittenRange !== range) {
67063
67062
  const matched = import_semver.default.maxSatisfying(versions, rewrittenRange, { includePrerelease });
67064
67063
  if (matched) {
67065
- console.log(`[Fetcher] Resolved ${packageName}@${range} to ${matched} via rewritten range ${rewrittenRange}`);
67064
+ console.debug(`[Fetcher] Resolved ${packageName}@${range} to ${matched} via rewritten range ${rewrittenRange}`);
67066
67065
  foundVersion = matched;
67067
67066
  }
67068
67067
  }
@@ -67071,21 +67070,21 @@ async function fetchPackage(packageName, versionOrRange, options) {
67071
67070
  const releaseTagVersion = packument["dist-tags"]?.[ctx.releaseTag];
67072
67071
  if (releaseTagVersion && import_semver.default.valid(releaseTagVersion)) {
67073
67072
  if (!foundVersion || import_semver.default.valid(foundVersion) && import_semver.default.gte(releaseTagVersion, foundVersion)) {
67074
- console.log(`[Fetcher] Using release tag "${ctx.releaseTag}" (${releaseTagVersion}) instead of "latest" (${foundVersion || "none"}) for ${packageName}`);
67073
+ console.debug(`[Fetcher] Using release tag "${ctx.releaseTag}" (${releaseTagVersion}) instead of "latest" (${foundVersion || "none"}) for ${packageName}`);
67075
67074
  foundVersion = releaseTagVersion;
67076
67075
  } else if (foundVersion) console.warn(`[Fetcher] Tag "${ctx.releaseTag}" (${releaseTagVersion}) is older than "latest" (${foundVersion}) for ${packageName}, keeping "latest"`);
67077
67076
  }
67078
67077
  }
67079
67078
  if (!foundVersion) throw new Error(`Package ${packageName}@${range} not found on npm (available tags: ${Object.keys(packument["dist-tags"] || {}).join(", ")})`);
67080
67079
  resolvedVersion = foundVersion;
67081
- console.log(`[Fetcher] ${packageName}: Resolved to v${resolvedVersion} via npm (${Date.now() - resolveStart}ms)`);
67080
+ console.debug(`[Fetcher] ${packageName}: Resolved to v${resolvedVersion} via npm (${Date.now() - resolveStart}ms)`);
67082
67081
  } catch (error) {
67083
67082
  console.warn(`[Fetcher] ${packageName}: remote resolution failed (${Date.now() - resolveStart}ms), trying local fallback...`);
67084
67083
  const fallbackStart = Date.now();
67085
67084
  const fallbackVersion = await tryLocalFallback(resolvedVersionOrRange, error, baseDir, packageName, includePrerelease);
67086
67085
  if (fallbackVersion) {
67087
67086
  resolvedVersion = fallbackVersion;
67088
- console.log(`[Fetcher] ${packageName}: Resolved to local fallback ${resolvedVersion} (${Date.now() - fallbackStart}ms)`);
67087
+ console.debug(`[Fetcher] ${packageName}: Resolved to local fallback ${resolvedVersion} (${Date.now() - fallbackStart}ms)`);
67089
67088
  } else throw error;
67090
67089
  }
67091
67090
  const cachePath = ctx.getCachePath(CacheFolder.Pacote);
@@ -67094,7 +67093,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
67094
67093
  const isInstalled = options?.installDeps ? isPackageComplete(packageDir) && isDependenciesInstalledSync(packageDir) : isPackageComplete(packageDir);
67095
67094
  const checkDuration = Date.now() - checkStart;
67096
67095
  if (isInstalled) {
67097
- console.log(`[Fetcher] ${packageName}@${resolvedVersion}: Already installed (check took ${checkDuration}ms, fetchPackage took ${Date.now() - start}ms)`);
67096
+ console.debug(`[Fetcher] ${packageName}@${resolvedVersion}: Already installed (check took ${checkDuration}ms, fetchPackage took ${Date.now() - start}ms)`);
67098
67097
  return {
67099
67098
  packageDir,
67100
67099
  resolvedVersion
@@ -67102,7 +67101,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
67102
67101
  }
67103
67102
  return withLock(`package:${packageName}:${resolvedVersion}`, async () => {
67104
67103
  if (!isPackageComplete(packageDir)) {
67105
- console.log(`[Fetcher] ${packageName}@${resolvedVersion}: Downloading to ${packageDir}...`);
67104
+ console.debug(`[Fetcher] ${packageName}@${resolvedVersion}: Downloading to ${packageDir}...`);
67106
67105
  const downloadStart = Date.now();
67107
67106
  const tempDir = join(baseDir, `.tmp-${resolvedVersion}-${Math.random().toString(36).slice(2)}`);
67108
67107
  await mkdir(tempDir, { recursive: true });
@@ -67116,10 +67115,10 @@ async function fetchPackage(packageName, versionOrRange, options) {
67116
67115
  try {
67117
67116
  await rename(tempDir, packageDir);
67118
67117
  } catch (err) {
67119
- if (isPackageComplete(packageDir)) console.log(`[Fetcher] Destination ${packageDir} already exists and is valid.`);
67118
+ if (isPackageComplete(packageDir)) console.debug(`[Fetcher] Destination ${packageDir} already exists and is valid.`);
67120
67119
  else throw err;
67121
67120
  }
67122
- console.log(`[Fetcher] ${packageName}@${resolvedVersion}: Downloaded and extracted in ${Date.now() - downloadStart}ms`);
67121
+ console.debug(`[Fetcher] ${packageName}@${resolvedVersion}: Downloaded and extracted in ${Date.now() - downloadStart}ms`);
67123
67122
  } catch (err) {
67124
67123
  await rm(tempDir, {
67125
67124
  recursive: true,
@@ -67130,13 +67129,13 @@ async function fetchPackage(packageName, versionOrRange, options) {
67130
67129
  }
67131
67130
  const entryStart = Date.now();
67132
67131
  const entryPoint = await resolveEntryPoint(packageDir, packageName);
67133
- console.log(`[Fetcher] ${packageName}@${resolvedVersion}: Resolved entry point in ${Date.now() - entryStart}ms`);
67132
+ console.debug(`[Fetcher] ${packageName}@${resolvedVersion}: Resolved entry point in ${Date.now() - entryStart}ms`);
67134
67133
  if (options?.installDeps) {
67135
67134
  const depsStart = Date.now();
67136
67135
  await installDependencies(packageDir, packageName, options);
67137
- console.log(`[Fetcher] ${packageName}@${resolvedVersion}: Installed dependencies in ${Date.now() - depsStart}ms`);
67136
+ console.debug(`[Fetcher] ${packageName}@${resolvedVersion}: Installed dependencies in ${Date.now() - depsStart}ms`);
67138
67137
  }
67139
- console.log(`[Fetcher] ${packageName}@${resolvedVersion}: FetchPackage complete in ${Date.now() - start}ms`);
67138
+ console.debug(`[Fetcher] ${packageName}@${resolvedVersion}: FetchPackage complete in ${Date.now() - start}ms`);
67140
67139
  return {
67141
67140
  packageDir,
67142
67141
  resolvedVersion,
@@ -67180,7 +67179,7 @@ async function ensureNodeJS(context, version = DEFAULT_NODE_VERSION) {
67180
67179
  const nodeDir = context.getThirdPartyPath("node", version);
67181
67180
  const finalNodePath = join(nodeDir, isWindows ? "node.exe" : "bin/node");
67182
67181
  if (isNodeJSComplete(finalNodePath)) {
67183
- console.log(`[Environment] Node.js check took ${Date.now() - checkStart}ms (found at ${finalNodePath})`);
67182
+ console.debug(`[Environment] Node.js check took ${Date.now() - checkStart}ms (found at ${finalNodePath})`);
67184
67183
  return finalNodePath;
67185
67184
  }
67186
67185
  return withLock(`node:${version}`, async () => {
@@ -67196,7 +67195,7 @@ async function ensureNodeJS(context, version = DEFAULT_NODE_VERSION) {
67196
67195
  console.log(`Downloading Node.js from ${downloadUrl}...`);
67197
67196
  const dlStart = Date.now();
67198
67197
  await downloadFile(downloadUrl, archivePath);
67199
- console.log(`[Environment] Node.js download took ${Date.now() - dlStart}ms`);
67198
+ console.debug(`[Environment] Node.js download took ${Date.now() - dlStart}ms`);
67200
67199
  sendStartupProgress(`Extracting Node.js v${version}...`);
67201
67200
  console.log(`Extracting Node.js to ${tempDir}...`);
67202
67201
  const extStart = Date.now();
@@ -67221,10 +67220,10 @@ async function ensureNodeJS(context, version = DEFAULT_NODE_VERSION) {
67221
67220
  try {
67222
67221
  await rename(tempNodeDir, nodeDir);
67223
67222
  } catch (err) {
67224
- if (isNodeJSComplete(finalNodePath)) console.log(`[Fetcher] Node.js directory already exists and is valid.`);
67223
+ if (isNodeJSComplete(finalNodePath)) console.debug(`[Fetcher] Node.js directory already exists and is valid.`);
67225
67224
  else throw err;
67226
67225
  }
67227
- console.log(`[Environment] Node.js extraction took ${Date.now() - extStart}ms`);
67226
+ console.debug(`[Environment] Node.js extraction took ${Date.now() - extStart}ms`);
67228
67227
  } finally {
67229
67228
  await rm(tempNodeDir, {
67230
67229
  recursive: true,
@@ -67235,7 +67234,7 @@ async function ensureNodeJS(context, version = DEFAULT_NODE_VERSION) {
67235
67234
  force: true
67236
67235
  }).catch(() => {});
67237
67236
  }
67238
- console.log(`[Environment] Node.js set up complete in ${Date.now() - checkStart}ms`);
67237
+ console.debug(`[Environment] Node.js set up complete in ${Date.now() - checkStart}ms`);
67239
67238
  return finalNodePath;
67240
67239
  });
67241
67240
  }
@@ -67246,14 +67245,14 @@ async function ensurePNPM(context, version = DEFAULT_PNPM_VERSION) {
67246
67245
  const checkStart = Date.now();
67247
67246
  const pnpmPath = join(context.getPackagesPath("pnpm", version), "bin", "pnpm.cjs");
67248
67247
  if (existsSync(pnpmPath)) {
67249
- console.log(`[Environment] PNPM check took ${Date.now() - checkStart}ms (found at ${pnpmPath})`);
67248
+ console.debug(`[Environment] PNPM check took ${Date.now() - checkStart}ms (found at ${pnpmPath})`);
67250
67249
  return pnpmPath;
67251
67250
  }
67252
67251
  return withLock(`pnpm:${version}`, async () => {
67253
67252
  if (existsSync(pnpmPath)) return pnpmPath;
67254
67253
  sendStartupProgress(`Checking PNPM v${version}...`);
67255
67254
  const { packageDir } = await fetchPackage("pnpm", version, { context });
67256
- console.log(`[Environment] PNPM set up complete in ${Date.now() - checkStart}ms`);
67255
+ console.debug(`[Environment] PNPM set up complete in ${Date.now() - checkStart}ms`);
67257
67256
  return join(packageDir, "bin", "pnpm.cjs");
67258
67257
  });
67259
67258
  }
@@ -67261,19 +67260,19 @@ async function installDependencies(packageDir, packageName, options) {
67261
67260
  const start = Date.now();
67262
67261
  const nodeModulesPath = join(packageDir, "node_modules");
67263
67262
  if (isDependenciesInstalledSync(packageDir)) {
67264
- console.log(`[Fetcher] ${packageName}: Dependencies already installed, skipping.`);
67263
+ console.debug(`[Fetcher] ${packageName}: Dependencies already installed, skipping.`);
67265
67264
  return;
67266
67265
  }
67267
67266
  try {
67268
- console.log(`[Fetcher] ${packageName}: Ensuring dependencies are installed...`);
67267
+ console.debug(`[Fetcher] ${packageName}: Ensuring dependencies are installed...`);
67269
67268
  const pnpmStart = Date.now();
67270
67269
  const { all } = await runPnpm(packageDir, {
67271
67270
  signal: options.signal,
67272
67271
  context: options.context
67273
67272
  });
67274
- console.log(`[Fetcher] ${packageName}: pnpm install command took ${Date.now() - pnpmStart}ms`);
67275
- if (all) console.log(`[Fetcher] ${packageName}: Installation trace:\n${all}`);
67276
- console.log(`[Fetcher] ${packageName}: Dependencies installed successfully (total installDependencies took ${Date.now() - start}ms).`);
67273
+ console.debug(`[Fetcher] ${packageName}: pnpm install command took ${Date.now() - pnpmStart}ms`);
67274
+ if (all) console.debug(`[Fetcher] ${packageName}: Installation trace:\n${all}`);
67275
+ console.debug(`[Fetcher] ${packageName}: Dependencies installed successfully (total installDependencies took ${Date.now() - start}ms).`);
67277
67276
  } catch (err) {
67278
67277
  console.error(`[Fetcher] ${packageName}: CRITICAL ERROR during dependency installation: ${err.message}`);
67279
67278
  if (err.all) console.error(`[Fetcher] ${packageName}: Error details:\n${err.all}`);
@@ -67451,191 +67450,6 @@ const handleActionExecute = async (nodeId, pluginId, params, mainWindow, send, a
67451
67450
  }
67452
67451
  };
67453
67452
  //#endregion
67454
- //#region ../../packages/core-node/src/plugins-registry.ts
67455
- const enhancePluginDefinition = async (plugin, packageDir, fallbackName, fallbackVersion) => {
67456
- if (!plugin) return plugin;
67457
- let packageName = fallbackName;
67458
- let version = fallbackVersion;
67459
- let pipelabMeta = null;
67460
- let pkgDescription = "";
67461
- try {
67462
- const pkgJsonPath = join(packageDir, "package.json");
67463
- if (existsSync(pkgJsonPath)) {
67464
- const pkgContent = await readFile(pkgJsonPath, "utf8");
67465
- const pkg = JSON.parse(pkgContent);
67466
- if (pkg.name) packageName = pkg.name;
67467
- if (pkg.version) version = pkg.version;
67468
- if (pkg.description) pkgDescription = pkg.description;
67469
- if (pkg.pipelab) pipelabMeta = pkg.pipelab;
67470
- }
67471
- } catch (e) {
67472
- console.error(`[Plugins] Failed to read package.json in ${packageDir}:`, e);
67473
- }
67474
- plugin.packageName = packageName;
67475
- plugin.id = packageName;
67476
- plugin.version = fallbackVersion === "local" ? "local" : version;
67477
- plugin.isOfficial = packageName.startsWith("@pipelab/");
67478
- plugin.name = pipelabMeta?.name || packageName;
67479
- plugin.description = pipelabMeta?.description || pkgDescription || "";
67480
- if (pipelabMeta?.icon) if (typeof pipelabMeta.icon === "string") {
67481
- let iconPath = pipelabMeta.icon;
67482
- if (iconPath.startsWith(".")) iconPath = pathToFileURL(join(packageDir, iconPath)).href;
67483
- plugin.icon = {
67484
- type: "image",
67485
- image: iconPath
67486
- };
67487
- } else plugin.icon = pipelabMeta.icon;
67488
- else plugin.icon = {
67489
- type: "icon",
67490
- icon: "pi pi-box"
67491
- };
67492
- return plugin;
67493
- };
67494
- const loadPipelabPlugin = async (id, options) => {
67495
- const start = Date.now();
67496
- try {
67497
- const packageName = id;
67498
- const fetchStart = Date.now();
67499
- const { packageDir, entryPoint } = await fetchPipelabPlugin(packageName, options.context.releaseTag, {
67500
- context: options.context,
67501
- installDeps: false
67502
- });
67503
- const fetchDuration = Date.now() - fetchStart;
67504
- console.log(`[Plugins] [${id}] Attempting to import from: ${entryPoint}`);
67505
- if (!existsSync(entryPoint)) {
67506
- console.error(`[Plugins] [${id}] CRITICAL: Plugin entry point not found at ${entryPoint}`);
67507
- try {
67508
- const files = await readdir(packageDir, { recursive: true });
67509
- console.log(`[Plugins] [${id}] Directory contents:`, files);
67510
- } catch (e) {}
67511
- }
67512
- const importStart = Date.now();
67513
- const pluginModule = await import(pathToFileURL(entryPoint).href);
67514
- const importDuration = Date.now() - importStart;
67515
- const totalDuration = Date.now() - start;
67516
- console.log(`[Plugins] [${id}] Successfully loaded from: ${packageDir} (fetch: ${fetchDuration}ms, import: ${importDuration}ms, total: ${totalDuration}ms)`);
67517
- const plugin = pluginModule.default;
67518
- await enhancePluginDefinition(plugin, packageDir, packageName, options.context.releaseTag);
67519
- return plugin;
67520
- } catch (e) {
67521
- console.error(`[Plugins] [${id}] CRITICAL: Failed to load after ${Date.now() - start}ms:`, e);
67522
- if (e.code === "ERR_MODULE_NOT_FOUND") console.error(`[Plugins] [${id}] This usually means a dependency is missing in the plugin's node_modules.`);
67523
- return null;
67524
- }
67525
- };
67526
- const loadCustomPlugin = async (packageName, version, options) => {
67527
- const start = Date.now();
67528
- try {
67529
- const fetchStart = Date.now();
67530
- const { packageDir, entryPoint } = await fetchPipelabPlugin(packageName, version, {
67531
- context: options.context,
67532
- installDeps: false
67533
- });
67534
- const fetchDuration = Date.now() - fetchStart;
67535
- console.log(`[Plugins] [${packageName}] Attempting to import custom plugin from: ${entryPoint}`);
67536
- if (!existsSync(entryPoint)) {
67537
- console.error(`[Plugins] [${packageName}] CRITICAL: Plugin entry point not found at ${entryPoint}`);
67538
- return null;
67539
- }
67540
- const importStart = Date.now();
67541
- const pluginModule = await import(pathToFileURL(entryPoint).href);
67542
- const importDuration = Date.now() - importStart;
67543
- const totalDuration = Date.now() - start;
67544
- console.log(`[Plugins] [${packageName}] Successfully loaded custom plugin from: ${packageDir} (fetch: ${fetchDuration}ms, import: ${importDuration}ms, total: ${totalDuration}ms)`);
67545
- const plugin = pluginModule.default;
67546
- await enhancePluginDefinition(plugin, packageDir, packageName, version);
67547
- return plugin;
67548
- } catch (e) {
67549
- console.error(`[Plugins] [${packageName}] CRITICAL: Failed to load after ${Date.now() - start}ms:`, e);
67550
- return null;
67551
- }
67552
- };
67553
- async function findInstalledPlugins(packagesDir) {
67554
- const installed = [];
67555
- if (!existsSync(packagesDir)) return installed;
67556
- async function scan(dir, depth = 0) {
67557
- if (depth > 4) return;
67558
- try {
67559
- const entries = await readdir(dir, { withFileTypes: true });
67560
- if (entries.some((e) => e.isFile() && e.name === "package.json")) {
67561
- try {
67562
- const content = await readFile(join(dir, "package.json"), "utf8");
67563
- const pkg = JSON.parse(content);
67564
- if (pkg.name && pkg.name !== "pnpm") installed.push({
67565
- name: pkg.name,
67566
- version: pkg.version || "0.0.0",
67567
- packageDir: dir,
67568
- description: pkg.description || ""
67569
- });
67570
- } catch (e) {}
67571
- return;
67572
- }
67573
- for (const entry of entries) if (entry.isDirectory() && entry.name !== "node_modules" && !entry.name.startsWith(".")) await scan(join(dir, entry.name), depth + 1);
67574
- } catch (e) {}
67575
- }
67576
- await scan(packagesDir);
67577
- return installed;
67578
- }
67579
- const builtInPlugins = async (options) => {
67580
- console.log("[Plugins] Starting background plugin loading...");
67581
- sendStartupProgress("Preparing environment...");
67582
- const envStart = Date.now();
67583
- await Promise.all([ensureNodeJS(options.context), ensurePNPM(options.context)]);
67584
- console.log(`[Plugins] Environment preparation took ${Date.now() - envStart}ms`);
67585
- const { usePlugins } = await import("./src-BiFlFfFL.mjs");
67586
- const { registerPlugins } = usePlugins();
67587
- const { webSocketServer } = await import("./src-B_k6ITjY.mjs");
67588
- webSocketServer.broadcast("startup:progress", { type: "ready" });
67589
- (async () => {
67590
- const totalStart = Date.now();
67591
- const pluginsToLoad = /* @__PURE__ */ new Map();
67592
- for (const name of [
67593
- "@pipelab/plugin-construct",
67594
- "@pipelab/plugin-filesystem",
67595
- "@pipelab/plugin-system",
67596
- "@pipelab/plugin-steam",
67597
- "@pipelab/plugin-itch",
67598
- "@pipelab/plugin-electron",
67599
- "@pipelab/plugin-discord",
67600
- "@pipelab/plugin-poki",
67601
- "@pipelab/plugin-nvpatch",
67602
- "@pipelab/plugin-tauri",
67603
- "@pipelab/plugin-minify",
67604
- "@pipelab/plugin-netlify"
67605
- ]) pluginsToLoad.set(name, "latest");
67606
- try {
67607
- const { setupSettingsConfigFile } = await import("./config-CzJC4vJj.mjs");
67608
- const settingsPlugins = (await (await setupSettingsConfigFile(options.context)).getConfig())?.plugins || [];
67609
- for (const plugin of settingsPlugins) if (plugin.name) if (plugin.enabled) {
67610
- if (!pluginsToLoad.has(plugin.name)) pluginsToLoad.set(plugin.name, "latest");
67611
- } else pluginsToLoad.delete(plugin.name);
67612
- } catch (e) {
67613
- console.error(`[Plugins] Failed to load settings config on startup:`, e);
67614
- }
67615
- console.log(`[Plugins] Total plugins to load on startup:`, Array.from(pluginsToLoad.entries()));
67616
- const loadPromises = Array.from(pluginsToLoad.entries()).map(async ([packageName, version]) => {
67617
- sendStartupProgress(`Loading plugin: ${packageName}`);
67618
- const pluginStart = Date.now();
67619
- try {
67620
- const plugin = await loadCustomPlugin(packageName, version, options);
67621
- if (plugin) {
67622
- registerPlugins([plugin]);
67623
- webSocketServer.broadcast("plugin:loaded", { plugin });
67624
- console.log(`[Plugins] Loaded ${packageName}@${version} in ${Date.now() - pluginStart}ms`);
67625
- }
67626
- } catch (err) {
67627
- console.error(`[Plugins] Failed to load plugin ${packageName} at startup:`, err);
67628
- }
67629
- });
67630
- await Promise.all(loadPromises);
67631
- console.log(`[Plugins] All startup plugins loaded in ${Date.now() - totalStart}ms.`);
67632
- sendStartupProgress("All plugins loaded.");
67633
- setTimeout(() => {
67634
- webSocketServer.broadcast("startup:progress", { type: "done" });
67635
- }, 2e3);
67636
- })();
67637
- };
67638
- //#endregion
67639
67453
  //#region ../../packages/core-node/src/utils.ts
67640
67454
  const getFinalPlugins = () => {
67641
67455
  const { plugins } = usePlugins();
@@ -67695,13 +67509,12 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
67695
67509
  let completedSteps = 0;
67696
67510
  const { registerPlugins, plugins: registeredPlugins } = usePlugins();
67697
67511
  const pluginIds = new Set(graph.map((node) => node.origin?.pluginId).filter(Boolean));
67698
- for (const pluginId of pluginIds) if (!registeredPlugins.value.some((p) => p.id === pluginId)) {
67699
- logger().info(`[Runner] Plugin "${pluginId}" not found, attempting to load...`);
67700
- const pluginDefinition = await loadPipelabPlugin(pluginId, { context: ctx });
67701
- if (pluginDefinition) {
67702
- registerPlugins([pluginDefinition]);
67703
- logger().info(`[Runner] Plugin "${pluginId}" loaded and registered successfully`);
67704
- } else logger().error(`[Runner] Failed to load or register plugin "${pluginId}"`);
67512
+ const missingPlugins = [];
67513
+ for (const pluginId of pluginIds) if (!registeredPlugins.value.some((p) => p.id === pluginId)) missingPlugins.push(pluginId);
67514
+ if (missingPlugins.length > 0) {
67515
+ const errorMsg = `Fail-fast: The following required plugins are not loaded: ${missingPlugins.join(", ")}. Please ensure they are installed and enabled in settings.`;
67516
+ logger().error(`[Runner] ${errorMsg}`);
67517
+ throw new Error(errorMsg);
67705
67518
  }
67706
67519
  logger().info(`[Sandbox] Execution sandbox created at: ${sandboxPath}`);
67707
67520
  await (await setupSettingsConfigFile(ctx)).getConfig();
@@ -68562,6 +68375,160 @@ const registerSystemHandlers = (options) => {
68562
68375
  }
68563
68376
  });
68564
68377
  };
68378
+ //#endregion
68379
+ //#region ../../packages/core-node/src/plugins-registry.ts
68380
+ const enhancePluginDefinition = async (plugin, packageDir, fallbackName, fallbackVersion) => {
68381
+ if (!plugin) return plugin;
68382
+ let packageName = fallbackName;
68383
+ let version = fallbackVersion;
68384
+ let pipelabMeta = null;
68385
+ let pkgDescription = "";
68386
+ try {
68387
+ const pkgJsonPath = join(packageDir, "package.json");
68388
+ if (existsSync(pkgJsonPath)) {
68389
+ const pkgContent = await readFile(pkgJsonPath, "utf8");
68390
+ const pkg = JSON.parse(pkgContent);
68391
+ if (pkg.name) packageName = pkg.name;
68392
+ if (pkg.version) version = pkg.version;
68393
+ if (pkg.description) pkgDescription = pkg.description;
68394
+ if (pkg.pipelab) pipelabMeta = pkg.pipelab;
68395
+ }
68396
+ } catch (e) {
68397
+ console.error(`[Plugins] Failed to read package.json in ${packageDir}:`, e);
68398
+ }
68399
+ plugin.packageName = packageName;
68400
+ plugin.id = packageName;
68401
+ plugin.version = fallbackVersion === "local" ? "local" : version;
68402
+ plugin.isOfficial = packageName.startsWith("@pipelab/");
68403
+ plugin.name = pipelabMeta?.name || packageName;
68404
+ plugin.description = pipelabMeta?.description || pkgDescription || "";
68405
+ if (pipelabMeta?.icon) if (typeof pipelabMeta.icon === "string") {
68406
+ let iconPath = pipelabMeta.icon;
68407
+ if (iconPath.startsWith(".")) iconPath = pathToFileURL(join(packageDir, iconPath)).href;
68408
+ plugin.icon = {
68409
+ type: "image",
68410
+ image: iconPath
68411
+ };
68412
+ } else plugin.icon = pipelabMeta.icon;
68413
+ else plugin.icon = {
68414
+ type: "icon",
68415
+ icon: "pi pi-box"
68416
+ };
68417
+ return plugin;
68418
+ };
68419
+ const loadCustomPlugin = async (packageName, version, options) => {
68420
+ const start = Date.now();
68421
+ try {
68422
+ const fetchStart = Date.now();
68423
+ const { packageDir, entryPoint } = await fetchPipelabPlugin(packageName, version, {
68424
+ context: options.context,
68425
+ installDeps: false
68426
+ });
68427
+ const fetchDuration = Date.now() - fetchStart;
68428
+ console.debug(`[Plugins] [${packageName}] Attempting to import custom plugin from: ${entryPoint}`);
68429
+ if (!existsSync(entryPoint)) {
68430
+ console.error(`[Plugins] [${packageName}] CRITICAL: Plugin entry point not found at ${entryPoint}`);
68431
+ return null;
68432
+ }
68433
+ const importStart = Date.now();
68434
+ const pluginModule = await import(pathToFileURL(entryPoint).href);
68435
+ const importDuration = Date.now() - importStart;
68436
+ const totalDuration = Date.now() - start;
68437
+ console.debug(`[Plugins] [${packageName}] Successfully loaded custom plugin from: ${packageDir} (fetch: ${fetchDuration}ms, import: ${importDuration}ms, total: ${totalDuration}ms)`);
68438
+ const plugin = pluginModule.default;
68439
+ await enhancePluginDefinition(plugin, packageDir, packageName, version);
68440
+ return plugin;
68441
+ } catch (e) {
68442
+ console.error(`[Plugins] [${packageName}] CRITICAL: Failed to load after ${Date.now() - start}ms:`, e);
68443
+ return null;
68444
+ }
68445
+ };
68446
+ async function findInstalledPlugins(packagesDir) {
68447
+ const installed = [];
68448
+ if (!existsSync(packagesDir)) return installed;
68449
+ async function scan(dir, depth = 0) {
68450
+ if (depth > 4) return;
68451
+ try {
68452
+ const entries = await readdir(dir, { withFileTypes: true });
68453
+ if (entries.some((e) => e.isFile() && e.name === "package.json")) {
68454
+ try {
68455
+ const content = await readFile(join(dir, "package.json"), "utf8");
68456
+ const pkg = JSON.parse(content);
68457
+ if (pkg.name && pkg.name !== "pnpm") installed.push({
68458
+ name: pkg.name,
68459
+ version: pkg.version || "0.0.0",
68460
+ packageDir: dir,
68461
+ description: pkg.description || ""
68462
+ });
68463
+ } catch (e) {}
68464
+ return;
68465
+ }
68466
+ for (const entry of entries) if (entry.isDirectory() && entry.name !== "node_modules" && !entry.name.startsWith(".")) await scan(join(dir, entry.name), depth + 1);
68467
+ } catch (e) {}
68468
+ }
68469
+ await scan(packagesDir);
68470
+ return installed;
68471
+ }
68472
+ const builtInPlugins = async (options) => {
68473
+ console.debug("[Plugins] Starting background plugin loading...");
68474
+ sendStartupProgress("Preparing environment...");
68475
+ const envStart = Date.now();
68476
+ await Promise.all([ensureNodeJS(options.context), ensurePNPM(options.context)]);
68477
+ console.debug(`[Plugins] Environment preparation took ${Date.now() - envStart}ms`);
68478
+ const { usePlugins } = await import("./src-BiFlFfFL.mjs");
68479
+ const { registerPlugins } = usePlugins();
68480
+ const { webSocketServer } = await import("./src-BiR5FNvm.mjs");
68481
+ webSocketServer.broadcast("startup:progress", { type: "ready" });
68482
+ return (async () => {
68483
+ const totalStart = Date.now();
68484
+ const pluginsToLoad = /* @__PURE__ */ new Map();
68485
+ for (const name of [
68486
+ "@pipelab/plugin-construct",
68487
+ "@pipelab/plugin-filesystem",
68488
+ "@pipelab/plugin-system",
68489
+ "@pipelab/plugin-steam",
68490
+ "@pipelab/plugin-itch",
68491
+ "@pipelab/plugin-electron",
68492
+ "@pipelab/plugin-discord",
68493
+ "@pipelab/plugin-poki",
68494
+ "@pipelab/plugin-nvpatch",
68495
+ "@pipelab/plugin-tauri",
68496
+ "@pipelab/plugin-minify",
68497
+ "@pipelab/plugin-netlify"
68498
+ ]) pluginsToLoad.set(name, "latest");
68499
+ try {
68500
+ const { setupSettingsConfigFile } = await import("./config-CzJC4vJj.mjs");
68501
+ const settingsPlugins = (await (await setupSettingsConfigFile(options.context)).getConfig())?.plugins || [];
68502
+ for (const plugin of settingsPlugins) if (plugin.name) if (plugin.enabled) {
68503
+ if (!pluginsToLoad.has(plugin.name)) pluginsToLoad.set(plugin.name, "latest");
68504
+ } else pluginsToLoad.delete(plugin.name);
68505
+ } catch (e) {
68506
+ console.error(`[Plugins] Failed to load settings config on startup:`, e);
68507
+ }
68508
+ const pluginList = Array.from(pluginsToLoad.keys()).map((p) => ` - ${p}`).join("\n");
68509
+ console.log(`\n[Plugins] Loading plugins in background:\n${pluginList}\n`);
68510
+ const loadPromises = Array.from(pluginsToLoad.entries()).map(async ([packageName, version]) => {
68511
+ sendStartupProgress(`Loading plugin: ${packageName}`);
68512
+ const pluginStart = Date.now();
68513
+ try {
68514
+ const plugin = await loadCustomPlugin(packageName, version, options);
68515
+ if (plugin) {
68516
+ registerPlugins([plugin]);
68517
+ webSocketServer.broadcast("plugin:loaded", { plugin });
68518
+ console.debug(`[Plugins] Loaded ${packageName}@${version} in ${Date.now() - pluginStart}ms`);
68519
+ }
68520
+ } catch (err) {
68521
+ console.error(`[Plugins] Failed to load plugin ${packageName} at startup:`, err);
68522
+ }
68523
+ });
68524
+ await Promise.all(loadPromises);
68525
+ console.log(`\n[Plugins] All startup plugins loaded in ${Date.now() - totalStart}ms.\n`);
68526
+ sendStartupProgress("All plugins loaded.");
68527
+ setTimeout(() => {
68528
+ webSocketServer.broadcast("startup:progress", { type: "done" });
68529
+ }, 2e3);
68530
+ })();
68531
+ };
68565
68532
  /**
68566
68533
  * Resolves a requested plugin version.
68567
68534
  * If the plugin is present in the local workspace map during development,
@@ -68743,23 +68710,12 @@ const registerPluginsHandlers = (context) => {
68743
68710
  if (p.packageName !== packageName) return false;
68744
68711
  if (mappedVersion === "latest") return true;
68745
68712
  return p.version === mappedVersion;
68746
- })) continue;
68747
- try {
68748
- console.log(`[Plugins] JIT loading plugin "${packageName}@${mappedVersion}" for pipeline...`);
68749
- const plugin = await loadCustomPlugin(packageName, mappedVersion, { context });
68750
- if (plugin) {
68751
- registerPlugins([plugin]);
68752
- webSocketServer.broadcast("plugin:loaded", { plugin });
68753
- loaded.push(packageName);
68754
- console.log(`[Plugins] JIT loaded "${packageName}" successfully.`);
68755
- } else {
68756
- console.warn(`[Plugins] JIT load for "${packageName}" returned no plugin.`);
68757
- failed.push(packageName);
68758
- }
68759
- } catch (e) {
68760
- console.error(`[Plugins] JIT load failed for "${packageName}":`, e);
68761
- failed.push(packageName);
68713
+ })) {
68714
+ loaded.push(packageName);
68715
+ continue;
68762
68716
  }
68717
+ console.warn(`[Plugins] Plugin "${packageName}" is required but not loaded at startup.`);
68718
+ failed.push(packageName);
68763
68719
  }
68764
68720
  send({
68765
68721
  type: "end",
@@ -69266,7 +69222,8 @@ const registerAllHandlers = async (options) => {
69266
69222
  registerPluginsHandlers(context);
69267
69223
  registerMigrationHandlers(context);
69268
69224
  const { registerPlugins } = usePlugins();
69269
- builtInPlugins({ context });
69225
+ const pluginsPromise = builtInPlugins({ context });
69226
+ if (options.waitForPlugins) await pluginsPromise;
69270
69227
  };
69271
69228
  //#endregion
69272
69229
  //#region ../../packages/core-node/src/runner.ts
@@ -69298,7 +69255,8 @@ async function runPipelineCommand(file, options, version) {
69298
69255
  });
69299
69256
  await registerAllHandlers({
69300
69257
  version,
69301
- context
69258
+ context,
69259
+ waitForPlugins: true
69302
69260
  });
69303
69261
  const cachePath = context.getCachePath(CacheFolder.Pipelines, effectivePipelineId);
69304
69262
  await mkdir(cachePath, { recursive: true });
@@ -69367,7 +69325,7 @@ async function runPipelineCommand(file, options, version) {
69367
69325
  }
69368
69326
  //#endregion
69369
69327
  //#region package.json
69370
- var version$2 = "2.0.0-beta.32";
69328
+ var version$2 = "2.0.0-beta.34";
69371
69329
  //#endregion
69372
69330
  //#region src/paths.ts
69373
69331
  const getDefaultUserDataPath = () => {
@@ -77319,7 +77277,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
77319
77277
  const isProduction = process.env.TEST !== "true";
77320
77278
  let posthog;
77321
77279
  if (isProduction && "phc_oXBjgJkl3ORfM2b6FZlbwaWHkGxJp9jFrj0l5aLjJql") posthog = new PostHog("phc_oXBjgJkl3ORfM2b6FZlbwaWHkGxJp9jFrj0l5aLjJql", { host: "https://eu.i.posthog.com" });
77322
- let version = "2.0.0-beta.32";
77280
+ let version = "2.0.0-beta.34";
77323
77281
  if (version === "0.0.0") try {
77324
77282
  const packageJsonPath = existsSync(join(__dirname, "package.json")) ? join(__dirname, "package.json") : join(__dirname, "..", "package.json");
77325
77283
  if (existsSync(packageJsonPath)) version = JSON.parse(readFileSync(packageJsonPath, "utf-8")).version;
@@ -77432,4 +77390,4 @@ program.hook("postAction", (thisCommand) => {
77432
77390
  program.parse(process.argv);
77433
77391
  if (!process.argv.slice(2).length) program.outputHelp();
77434
77392
  //#endregion
77435
- export { useAPI as A, BuildHistoryStorage as C, registerShellHandlers as D, isPathBlacklisted as E, PipelabContext as M, getDefaultUserDataPath$1 as N, WebSocketServer as O, projectRoot as P, registerHistoryHandlers as S, registerFsHandlers as T, isOnline as _, executeGraphWithHistory as a, sendStartupReady as b, findInstalledPlugins as c, handleActionExecute as d, ensureNodeJS as f, fetchPipelabPlugin as g, fetchPipelabAsset as h, registerEngineHandlers as i, CacheFolder as j, webSocketServer as k, loadCustomPlugin as l, fetchPackage as m, registerAllHandlers as n, getFinalPlugins as o, ensurePNPM as p, registerAgentsHandlers as r, builtInPlugins as s, runPipelineCommand as t, loadPipelabPlugin as u, runPnpm as v, registerConfigHandlers as w, serveCommand as x, sendStartupProgress as y };
77393
+ export { CacheFolder as A, registerConfigHandlers as C, WebSocketServer as D, registerShellHandlers as E, getDefaultUserDataPath$1 as M, projectRoot as N, webSocketServer as O, BuildHistoryStorage as S, isPathBlacklisted as T, runPnpm as _, loadCustomPlugin as a, serveCommand as b, executeGraphWithHistory as c, ensureNodeJS as d, ensurePNPM as f, isOnline as g, fetchPipelabPlugin as h, findInstalledPlugins as i, PipelabContext as j, useAPI as k, getFinalPlugins as l, fetchPipelabAsset as m, registerAllHandlers as n, registerAgentsHandlers as o, fetchPackage as p, builtInPlugins as r, registerEngineHandlers as s, runPipelineCommand as t, handleActionExecute as u, sendStartupProgress as v, registerFsHandlers as w, registerHistoryHandlers as x, sendStartupReady as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipelab/cli",
3
- "version": "2.0.0-beta.32",
3
+ "version": "2.0.0-beta.34",
4
4
  "description": "The command line interface for Pipelab",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "author": "CynToolkit",
@@ -1,5 +1,5 @@
1
1
  import "./src-PqA91tjF.mjs";
2
2
  import "./dist-BC_B45iu.mjs";
3
3
  import "./config-DJaqZVxZ.mjs";
4
- import { k as webSocketServer } from "./index.mjs";
4
+ import { O as webSocketServer } from "./index.mjs";
5
5
  export { webSocketServer };