@pipelab/core-node 1.0.0-beta.16 → 1.0.0-beta.18

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/index.mjs CHANGED
@@ -8,7 +8,7 @@ import { DEFAULT_NODE_VERSION, DEFAULT_PNPM_VERSION, SandboxFolder, getUiDevServ
8
8
  import { WebSocket, WebSocketServer as WebSocketServer$1 } from "ws";
9
9
  import http from "node:http";
10
10
  import { nanoid } from "nanoid";
11
- import { SubscriptionRequiredError, WebSocketError, configRegistry, isRequired, isSupabaseAvailable, isWebSocketRequestMessage, normalizePipelineConfig, processGraph, savedFileMigrator, supabase, transformUrl, useLogger, usePlugins } from "@pipelab/shared";
11
+ import { SubscriptionRequiredError, WebSocketError, configRegistry, isRequired, isSupabaseAvailable, isWebSocketRequestMessage, processGraph, savedFileMigrator, supabase, transformUrl, useLogger, usePlugins } from "@pipelab/shared";
12
12
  import { execa } from "execa";
13
13
  import tar from "tar";
14
14
  import yauzl from "yauzl";
@@ -80,6 +80,11 @@ function findProjectRoot(startDir) {
80
80
  return null;
81
81
  }
82
82
  const projectRoot = findProjectRoot(_dirname);
83
+ const CacheFolder = {
84
+ Actions: "actions",
85
+ Pipelines: "pipelines",
86
+ Pacote: "pacote"
87
+ };
83
88
  var PipelabContext = class {
84
89
  userDataPath;
85
90
  releaseTag;
@@ -104,12 +109,16 @@ var PipelabContext = class {
104
109
  await mkdir(baseDir, { recursive: true });
105
110
  return await mkdtemp(join(await realpath(baseDir), prefix));
106
111
  }
107
- getCachePath(...subpaths) {
108
- return join(this.userDataPath, "cache", ...subpaths);
112
+ getCachePath(folder, ...subpaths) {
113
+ if (!folder) return join(this.userDataPath, "cache");
114
+ return join(this.userDataPath, "cache", folder, ...subpaths);
109
115
  }
110
116
  getPnpmPath(...subpaths) {
111
117
  return join(this.userDataPath, "pnpm", ...subpaths);
112
118
  }
119
+ getBuildHistoryPath(...subpaths) {
120
+ return join(this.userDataPath, "build-history", ...subpaths);
121
+ }
113
122
  getNodePath(version = DEFAULT_NODE_VERSION) {
114
123
  const isWindows = process.platform === "win32";
115
124
  return this.getThirdPartyPath("node", version, isWindows ? "node.exe" : "bin/node");
@@ -685,7 +694,7 @@ const setupConfigFile = async (name, options) => {
685
694
  debug: false,
686
695
  onStep: async (state, version) => {
687
696
  const parsedPath = path.parse(filesPath);
688
- const versionedPath = path.join(parsedPath.dir, `${parsedPath.name}.v${version}.json`);
697
+ const versionedPath = ctx.getConfigPath(`${parsedPath.name}.v${version}.json`);
689
698
  try {
690
699
  await fs$1.writeFile(versionedPath, JSON.stringify(state));
691
700
  logger().info(`Intermediate backup created for ${name} at ${versionedPath}`);
@@ -700,13 +709,11 @@ const setupConfigFile = async (name, options) => {
700
709
  migrationFailed = true;
701
710
  json = migrator.defaultValue;
702
711
  }
703
- let normalized = false;
704
- if (name.startsWith("pipeline-") || path.isAbsolute(name) || name.endsWith(".json") || name === "pipeline") normalized = normalizePipelineConfig(json);
705
- if (originalJson?.version !== json?.version || normalized || content === void 0 || parseFailed || migrationFailed) {
712
+ if (originalJson?.version !== json?.version || content === void 0 || parseFailed || migrationFailed) {
706
713
  if (parseFailed || migrationFailed) try {
707
714
  const parsedPath = path.parse(filesPath);
708
715
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
709
- const corruptedPath = path.join(parsedPath.dir, `${parsedPath.name}.corrupted.${timestamp}.json`);
716
+ const corruptedPath = ctx.getConfigPath(`${parsedPath.name}.corrupted.${timestamp}.json`);
710
717
  const backupContent = parseFailed ? content || "" : JSON.stringify(originalJson, null, 2);
711
718
  await fs$1.writeFile(corruptedPath, backupContent);
712
719
  logger().info(`Corrupted config file preserved at ${corruptedPath}`);
@@ -723,6 +730,10 @@ const setupConfigFile = async (name, options) => {
723
730
  }
724
731
  };
725
732
  };
733
+ const deleteConfigFile = async (nameOrPath, context) => {
734
+ const filesPath = path.isAbsolute(nameOrPath) ? nameOrPath : context.getConfigPath(`${nameOrPath}.json`);
735
+ await fs$1.rm(filesPath, { force: true });
736
+ };
726
737
  //#endregion
727
738
  //#region src/handlers/config.ts
728
739
  const registerConfigHandlers = (context) => {
@@ -809,18 +820,7 @@ const registerConfigHandlers = (context) => {
809
820
  const { config: name } = value;
810
821
  logger().info("config:delete", name);
811
822
  try {
812
- const filesPath = path.isAbsolute(name) ? name : context.getConfigPath(`${name}.json`);
813
- await fs$1.rm(filesPath, { force: true });
814
- const parsedPath = path.parse(filesPath);
815
- const dirEntries = await fs$1.readdir(parsedPath.dir).catch(() => []);
816
- const prefix = `${parsedPath.name}.v`;
817
- const suffix = `.json`;
818
- for (const entry of dirEntries) if (entry.startsWith(prefix) && entry.endsWith(suffix)) {
819
- const backupPath = path.join(parsedPath.dir, entry);
820
- await fs$1.rm(backupPath, { force: true }).catch((err) => {
821
- logger().error(`Failed to delete backup ${backupPath}:`, err);
822
- });
823
- }
823
+ await deleteConfigFile(name, context);
824
824
  send({
825
825
  type: "end",
826
826
  data: {
@@ -848,11 +848,10 @@ var BuildHistoryStorage = class {
848
848
  this.context = context;
849
849
  }
850
850
  getStoragePath() {
851
- return join(this.context.userDataPath, "build-history");
851
+ return this.context.getConfigPath("pipelines");
852
852
  }
853
853
  getPipelinePath(pipelineId) {
854
- const sanitizedId = pipelineId.replace(/[/\:*?"<>|]/g, "_").replace(/__/g, "_").replace(/^_+|_+$/g, "");
855
- return join(this.getStoragePath(), `pipeline-${sanitizedId}.json`);
854
+ return join(this.getStoragePath(), `${pipelineId}.history.json`);
856
855
  }
857
856
  async ensureStoragePath() {
858
857
  try {
@@ -879,35 +878,6 @@ var BuildHistoryStorage = class {
879
878
  throw new Error(`Failed to save pipeline history: ${error}`);
880
879
  }
881
880
  }
882
- async applyRetentionPolicy() {
883
- try {
884
- this.logger.logger().info("Applying build history retention policy...");
885
- const policy = (await (await setupConfigFile("settings", { context: this.context })).getConfig())?.buildHistory?.retentionPolicy;
886
- if (!policy || !policy.enabled) {
887
- this.logger.logger().info("Retention policy is disabled. Skipping.");
888
- return;
889
- }
890
- const { maxAge, maxEntries } = policy;
891
- const pipelineFiles = await this.getAllPipelineFiles();
892
- for (const file of pipelineFiles) {
893
- const pipelineId = file.replace("pipeline-", "").replace(".json", "");
894
- let entries = await this.loadPipelineHistory(pipelineId);
895
- const originalCount = entries.length;
896
- if (maxAge > 0) {
897
- const minDate = Date.now() - maxAge * 24 * 60 * 60 * 1e3;
898
- entries = entries.filter((entry) => entry.createdAt >= minDate);
899
- }
900
- if (maxEntries > 0 && entries.length > maxEntries) entries = entries.sort((a, b) => b.createdAt - a.createdAt).slice(0, maxEntries);
901
- if (entries.length < originalCount) {
902
- this.logger.logger().info(`[${pipelineId}] Pruned ${originalCount - entries.length} history entries.`);
903
- await this.savePipelineHistory(pipelineId, entries);
904
- }
905
- }
906
- this.logger.logger().info("Retention policy applied successfully.");
907
- } catch (error) {
908
- this.logger.logger().error("Failed to apply retention policy:", error);
909
- }
910
- }
911
881
  async save(entry) {
912
882
  try {
913
883
  const entries = await this.loadPipelineHistory(entry.pipelineId);
@@ -916,9 +886,6 @@ var BuildHistoryStorage = class {
916
886
  else entries.push(entry);
917
887
  await this.savePipelineHistory(entry.pipelineId, entries);
918
888
  this.logger.logger().info(`Saved build history entry: ${entry.id} for pipeline: ${entry.pipelineId}`);
919
- this.applyRetentionPolicy().catch((err) => {
920
- this.logger.logger().error("Failed to apply retention policy after save:", err);
921
- });
922
889
  } catch (error) {
923
890
  this.logger.logger().error("Failed to save build history entry:", error);
924
891
  throw new Error(`Failed to save build history entry: ${error}`);
@@ -929,7 +896,8 @@ var BuildHistoryStorage = class {
929
896
  if (pipelineId) return (await this.loadPipelineHistory(pipelineId)).find((e) => e.id === id);
930
897
  const files = await this.getAllPipelineFiles();
931
898
  for (const file of files) {
932
- const pId = file.replace("pipeline-", "").replace(".json", "");
899
+ const pId = this.parsePipelineIdFromFilename(file);
900
+ if (!pId) continue;
933
901
  const entry = (await this.loadPipelineHistory(pId)).find((e) => e.id === id);
934
902
  if (entry) return entry;
935
903
  }
@@ -944,7 +912,8 @@ var BuildHistoryStorage = class {
944
912
  const files = await this.getAllPipelineFiles();
945
913
  const allEntries = [];
946
914
  for (const file of files) {
947
- const pipelineId = file.replace("pipeline-", "").replace(".json", "");
915
+ const pipelineId = this.parsePipelineIdFromFilename(file);
916
+ if (!pipelineId) continue;
948
917
  const entries = await this.loadPipelineHistory(pipelineId);
949
918
  allEntries.push(...entries);
950
919
  }
@@ -979,7 +948,8 @@ var BuildHistoryStorage = class {
979
948
  } else {
980
949
  const files = await this.getAllPipelineFiles();
981
950
  for (const file of files) {
982
- const pId = file.replace("pipeline-", "").replace(".json", "");
951
+ const pId = this.parsePipelineIdFromFilename(file);
952
+ if (!pId) continue;
983
953
  const entries = await this.loadPipelineHistory(pId);
984
954
  const entryIndex = entries.findIndex((e) => e.id === id);
985
955
  if (entryIndex >= 0) {
@@ -1013,7 +983,8 @@ var BuildHistoryStorage = class {
1013
983
  } else {
1014
984
  const files = await this.getAllPipelineFiles();
1015
985
  for (const file of files) {
1016
- const pId = file.replace("pipeline-", "").replace(".json", "");
986
+ const pId = this.parsePipelineIdFromFilename(file);
987
+ if (!pId) continue;
1017
988
  const entries = await this.loadPipelineHistory(pId);
1018
989
  const entryIndex = entries.findIndex((e) => e.id === id);
1019
990
  if (entryIndex >= 0) {
@@ -1034,8 +1005,20 @@ var BuildHistoryStorage = class {
1034
1005
  try {
1035
1006
  await this.ensureStoragePath();
1036
1007
  const files = await this.getAllPipelineFiles();
1037
- await Promise.all(files.map((file) => unlink(join(this.getStoragePath(), file))));
1008
+ const cachePathsToDelete = /* @__PURE__ */ new Set();
1009
+ for (const file of files) {
1010
+ const pipelineId = this.parsePipelineIdFromFilename(file);
1011
+ if (pipelineId) {
1012
+ const entries = await this.loadPipelineHistory(pipelineId);
1013
+ for (const entry of entries) if (entry.cachePath) cachePathsToDelete.add(entry.cachePath);
1014
+ }
1015
+ await unlink(join(this.getStoragePath(), file));
1016
+ }
1038
1017
  this.logger.logger().info("Cleared all build history");
1018
+ for (const cachePath of cachePathsToDelete) await rm(cachePath, {
1019
+ recursive: true,
1020
+ force: true
1021
+ }).catch(() => {});
1039
1022
  } catch (error) {
1040
1023
  this.logger.logger().error("Failed to clear build history:", error);
1041
1024
  throw new Error(`Failed to clear build history: ${error}`);
@@ -1043,8 +1026,16 @@ var BuildHistoryStorage = class {
1043
1026
  }
1044
1027
  async clearByPipeline(pipelineId) {
1045
1028
  try {
1046
- await unlink(this.getPipelinePath(pipelineId));
1029
+ const pipelinePath = this.getPipelinePath(pipelineId);
1030
+ const entries = await this.loadPipelineHistory(pipelineId);
1031
+ await unlink(pipelinePath);
1047
1032
  this.logger.logger().info(`Cleared history for pipeline "${pipelineId}"`);
1033
+ const cachePathsToDelete = /* @__PURE__ */ new Set();
1034
+ for (const entry of entries) if (entry.cachePath) cachePathsToDelete.add(entry.cachePath);
1035
+ for (const cachePath of cachePathsToDelete) await rm(cachePath, {
1036
+ recursive: true,
1037
+ force: true
1038
+ }).catch(() => {});
1048
1039
  } catch (error) {
1049
1040
  if (error.code === "ENOENT") {
1050
1041
  this.logger.logger().warn(`No history file found for pipeline "${pipelineId}". Nothing to clear.`);
@@ -1069,21 +1060,11 @@ var BuildHistoryStorage = class {
1069
1060
  size
1070
1061
  });
1071
1062
  }
1072
- const policy = (await (await setupConfigFile("settings", { context: this.context })).getConfig())?.buildHistory?.retentionPolicy || {
1073
- enabled: false,
1074
- maxEntries: 50,
1075
- maxAge: 30
1076
- };
1077
1063
  if (allEntries.length === 0) return {
1078
1064
  totalEntries: 0,
1079
1065
  totalSize: 0,
1080
1066
  numberOfPipelines: files.length,
1081
1067
  userDataPath: this.context.userDataPath,
1082
- retentionPolicy: {
1083
- enabled: policy.enabled,
1084
- maxEntries: policy.maxEntries,
1085
- maxAge: policy.maxAge
1086
- },
1087
1068
  disk: {
1088
1069
  total: diskSpace.size,
1089
1070
  free: diskSpace.free,
@@ -1108,11 +1089,6 @@ var BuildHistoryStorage = class {
1108
1089
  newestEntry: sortedEntries[sortedEntries.length - 1]?.createdAt,
1109
1090
  numberOfPipelines: files.length,
1110
1091
  userDataPath: this.context.userDataPath,
1111
- retentionPolicy: {
1112
- enabled: policy.enabled,
1113
- maxEntries: policy.maxEntries,
1114
- maxAge: policy.maxAge
1115
- },
1116
1092
  disk: {
1117
1093
  total: diskSpace.size,
1118
1094
  free: diskSpace.free,
@@ -1128,11 +1104,15 @@ var BuildHistoryStorage = class {
1128
1104
  async getAllPipelineFiles() {
1129
1105
  try {
1130
1106
  await this.ensureStoragePath();
1131
- return (await readdir(this.getStoragePath())).filter((file) => file.startsWith("pipeline-") && file.endsWith(".json"));
1107
+ return (await readdir(this.getStoragePath())).filter((file) => file.endsWith(".history.json"));
1132
1108
  } catch (error) {
1133
1109
  return [];
1134
1110
  }
1135
1111
  }
1112
+ parsePipelineIdFromFilename(filename) {
1113
+ const match = filename.match(/^(.+)\.history\.json$/);
1114
+ return match ? match[1] : null;
1115
+ }
1136
1116
  };
1137
1117
  //#endregion
1138
1118
  //#region src/handlers/history.ts
@@ -1414,40 +1394,6 @@ const registerHistoryHandlers = (context) => {
1414
1394
  });
1415
1395
  }
1416
1396
  });
1417
- handle("build-history:configure", async (_, { send, value }) => {
1418
- try {
1419
- logger().info("Updating build history configuration:", value.config);
1420
- const settings = await setupConfigFile("settings", { context });
1421
- const currentConfig = await settings.getConfig();
1422
- const newConfig = {
1423
- ...currentConfig,
1424
- buildHistory: {
1425
- ...currentConfig?.buildHistory,
1426
- retentionPolicy: {
1427
- ...currentConfig?.buildHistory?.retentionPolicy,
1428
- ...value.config.retentionPolicy
1429
- }
1430
- }
1431
- };
1432
- await settings.setConfig(newConfig);
1433
- send({
1434
- type: "end",
1435
- data: {
1436
- type: "success",
1437
- result: { result: "ok" }
1438
- }
1439
- });
1440
- } catch (error) {
1441
- logger().error("Failed to configure build history:", error);
1442
- send({
1443
- type: "end",
1444
- data: {
1445
- type: "error",
1446
- ipcError: error instanceof Error ? error.message : "Failed to configure build history"
1447
- }
1448
- });
1449
- }
1450
- });
1451
1397
  };
1452
1398
  //#endregion
1453
1399
  //#region ../../node_modules/serve-handler/src/glob-slash.js
@@ -8997,7 +8943,13 @@ async function serveCommand(options, version, _dirname) {
8997
8943
  response.end(`Error: UI directory not found at ${rawAssetFolder}.\nPlease run 'pnpm build' in apps/ui to generate the distribution.`);
8998
8944
  return;
8999
8945
  }
9000
- return (0, import_src.default)(request, response, { public: rawAssetFolder });
8946
+ return (0, import_src.default)(request, response, {
8947
+ public: rawAssetFolder,
8948
+ rewrites: [{
8949
+ source: "/**",
8950
+ destination: "/index.html"
8951
+ }]
8952
+ });
9001
8953
  });
9002
8954
  console.log(`Starting Pipelab server on port ${options.port}...`);
9003
8955
  if (isDev) {
@@ -9104,7 +9056,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
9104
9056
  console.log(`[Fetcher] ${packageName}: Resolved to local fallback ${resolvedVersion} (${Date.now() - fallbackStart}ms)`);
9105
9057
  } else throw new Error(`Offline and no local fallback version available for ${packageName}`);
9106
9058
  } else try {
9107
- const cachePath = join(ctx.userDataPath, "cache", "pacote");
9059
+ const cachePath = ctx.getCachePath(CacheFolder.Pacote);
9108
9060
  let packumentPromise = packumentRequests.get(packageName);
9109
9061
  if (!packumentPromise) {
9110
9062
  packumentPromise = pacote.packument(packageName, { cache: cachePath });
@@ -9135,7 +9087,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
9135
9087
  console.log(`[Fetcher] ${packageName}: Resolved to local fallback ${resolvedVersion} (${Date.now() - fallbackStart}ms)`);
9136
9088
  } else throw error;
9137
9089
  }
9138
- const cachePath = join(ctx.userDataPath, "cache", "pacote");
9090
+ const cachePath = ctx.getCachePath(CacheFolder.Pacote);
9139
9091
  const packageDir = join(baseDir, resolvedVersion);
9140
9092
  const checkStart = Date.now();
9141
9093
  const isInstalled = options?.installDeps ? isPackageComplete(packageDir) && isDependenciesInstalledSync(packageDir) : isPackageComplete(packageDir);
@@ -9212,7 +9164,7 @@ async function runPnpm(cwd, options) {
9212
9164
  ...process.env,
9213
9165
  NODE_ENV: "production",
9214
9166
  PATH: nodePath ? `${dirname(nodePath)}${delimiter}${process.env.PATH}` : process.env.PATH,
9215
- PNPM_HOME: join(ctx.userDataPath, "pnpm"),
9167
+ PNPM_HOME: ctx.getPnpmPath(),
9216
9168
  PNPM_ONLY_ALLOW_TRUSTED_DEPENDENCIES: "false",
9217
9169
  ...extraEnv
9218
9170
  }
@@ -9750,7 +9702,7 @@ const builtInPlugins = async (options) => {
9750
9702
  console.error(`[Plugins] Failed to load settings config on startup:`, e);
9751
9703
  }
9752
9704
  console.log(`[Plugins] Total plugins to load on startup:`, Array.from(pluginsToLoad.entries()));
9753
- for (const [packageName, version] of pluginsToLoad.entries()) {
9705
+ const loadPromises = Array.from(pluginsToLoad.entries()).map(async ([packageName, version]) => {
9754
9706
  sendStartupProgress(`Loading plugin: ${packageName}`);
9755
9707
  const pluginStart = Date.now();
9756
9708
  try {
@@ -9763,7 +9715,8 @@ const builtInPlugins = async (options) => {
9763
9715
  } catch (err) {
9764
9716
  console.error(`[Plugins] Failed to load plugin ${packageName} at startup:`, err);
9765
9717
  }
9766
- }
9718
+ });
9719
+ await Promise.all(loadPromises);
9767
9720
  console.log(`[Plugins] All startup plugins loaded in ${Date.now() - totalStart}ms.`);
9768
9721
  sendStartupProgress("All plugins loaded.");
9769
9722
  setTimeout(() => {
@@ -9811,6 +9764,7 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
9811
9764
  projectName,
9812
9765
  projectPath,
9813
9766
  pipelineId,
9767
+ cachePath,
9814
9768
  startTime,
9815
9769
  status: "running",
9816
9770
  logs: [],
@@ -9907,7 +9861,6 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
9907
9861
  }, pipelineId);
9908
9862
  throw error;
9909
9863
  } finally {
9910
- if (!shouldDisableHistory) buildHistoryStorage.applyRetentionPolicy();
9911
9864
  try {
9912
9865
  await rm(sandboxPath, {
9913
9866
  recursive: true,
@@ -9916,6 +9869,14 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
9916
9869
  } catch (e) {
9917
9870
  console.warn(`Failed to cleanup sandbox at ${sandboxPath}:`, e);
9918
9871
  }
9872
+ try {
9873
+ await rm(cachePath, {
9874
+ recursive: true,
9875
+ force: true
9876
+ });
9877
+ } catch (e) {
9878
+ console.warn(`Failed to cleanup cache at ${cachePath}:`, e);
9879
+ }
9919
9880
  }
9920
9881
  };
9921
9882
  //#endregion
@@ -10291,24 +10252,32 @@ const registerEngineHandlers = (context) => {
10291
10252
  };
10292
10253
  handle("action:execute", async (event, { send, value }) => {
10293
10254
  const { nodeId, params, pluginId } = value;
10294
- await (await setupConfigFile("settings", { context })).getConfig();
10295
- const cachePath = join(context.userDataPath, "cache", "actions", pluginId, nodeId);
10255
+ const cachePath = context.getCachePath(CacheFolder.Actions, pluginId, nodeId);
10296
10256
  const cwd = await context.createTempFolder("action-execute-");
10297
- const mainWindow = void 0;
10298
- abortControllerGraph = new AbortController();
10299
- const signalPromise = new Promise((resolve, reject) => {
10300
- abortControllerGraph.signal.addEventListener("abort", async () => {
10301
- await send({
10302
- type: "end",
10303
- data: {
10304
- ipcError: "Action aborted",
10305
- type: "error"
10306
- }
10257
+ try {
10258
+ const mainWindow = void 0;
10259
+ abortControllerGraph = new AbortController();
10260
+ const signalPromise = new Promise((resolve, reject) => {
10261
+ abortControllerGraph.signal.addEventListener("abort", async () => {
10262
+ await send({
10263
+ type: "end",
10264
+ data: {
10265
+ ipcError: "Action aborted",
10266
+ type: "error"
10267
+ }
10268
+ });
10269
+ return reject(/* @__PURE__ */ new Error("Action interrupted"));
10307
10270
  });
10308
- return reject(/* @__PURE__ */ new Error("Action interrupted"));
10309
10271
  });
10310
- });
10311
- await Promise.race([signalPromise, effectiveActionExecute(nodeId, pluginId, params, mainWindow, send, cwd, cachePath)]);
10272
+ await Promise.race([signalPromise, effectiveActionExecute(nodeId, pluginId, params, mainWindow, send, cwd, cachePath)]);
10273
+ } finally {
10274
+ await rm(cwd, {
10275
+ recursive: true,
10276
+ force: true
10277
+ }).catch((err) => {
10278
+ console.warn(`Failed to cleanup temp folder at ${cwd}:`, err);
10279
+ });
10280
+ }
10312
10281
  });
10313
10282
  handle("constants:get", async (_, { send }) => {
10314
10283
  const userData = context.userDataPath;
@@ -10336,7 +10305,7 @@ const registerEngineHandlers = (context) => {
10336
10305
  const effectiveProjectName = projectName || "Unnamed Project";
10337
10306
  const effectiveProjectPath = projectPath || "";
10338
10307
  const effectivePipelineId = pipelineId || "unknown";
10339
- const effectiveCachePath = join(context.userDataPath, "cache", effectivePipelineId);
10308
+ const effectiveCachePath = context.getCachePath(CacheFolder.Pipelines, effectivePipelineId);
10340
10309
  const mainWindow = void 0;
10341
10310
  abortControllerGraph = new AbortController();
10342
10311
  try {
@@ -10444,7 +10413,7 @@ var JsonFileStorage = class {
10444
10413
  filePath;
10445
10414
  logger = useLogger().logger;
10446
10415
  constructor(fileName, context) {
10447
- this.filePath = path.join(context.userDataPath, fileName);
10416
+ this.filePath = context.getConfigPath(fileName);
10448
10417
  const dir = path.dirname(this.filePath);
10449
10418
  if (!fs.existsSync(dir)) try {
10450
10419
  fs.mkdirSync(dir, { recursive: true });
@@ -53170,8 +53139,7 @@ async function runPipelineCommand(file, options, version) {
53170
53139
  context
53171
53140
  });
53172
53141
  registerMigrationHandlers(context);
53173
- await (await setupConfigFile("settings", { context })).getConfig();
53174
- const cachePath = join(context.userDataPath, "cache");
53142
+ const cachePath = context.getCachePath(CacheFolder.Pipelines, effectivePipelineId);
53175
53143
  await mkdir(cachePath, { recursive: true });
53176
53144
  const abortController = new AbortController();
53177
53145
  let supabase;
@@ -53249,19 +53217,25 @@ async function fetchPackageReleases(packageName, options = {}) {
53249
53217
  if (override) {
53250
53218
  const targetTag = override.includes("@") ? override : `${packageName}@${override}`;
53251
53219
  console.log(`[GitHub] Fetching specific override release: ${targetTag}`);
53252
- const response = await fetch(`https://api.github.com/repos/${repo}/releases/tags/${encodeURIComponent(targetTag)}`, { headers: {
53253
- "User-Agent": "Pipelab-Desktop-Updater",
53254
- Accept: "application/vnd.github.v3+json"
53255
- } });
53220
+ const response = await fetch(`https://api.github.com/repos/${repo}/releases/tags/${encodeURIComponent(targetTag)}`, {
53221
+ headers: {
53222
+ "User-Agent": "Pipelab-Desktop-Updater",
53223
+ Accept: "application/vnd.github.v3+json"
53224
+ },
53225
+ signal: AbortSignal.timeout(1e4)
53226
+ });
53256
53227
  if (response.ok) return [await response.json()];
53257
53228
  console.warn(`[GitHub] Override release tag ${targetTag} not found or error occurred`);
53258
53229
  }
53259
53230
  const matchingRefsUrl = `https://api.github.com/repos/${repo}/git/matching-refs/tags/${encodeURIComponent(packageName)}`;
53260
53231
  console.log(`[GitHub] Querying matching tags from ${matchingRefsUrl}...`);
53261
- const response = await fetch(matchingRefsUrl, { headers: {
53262
- "User-Agent": "Pipelab-Desktop-Updater",
53263
- Accept: "application/vnd.github.v3+json"
53264
- } });
53232
+ const response = await fetch(matchingRefsUrl, {
53233
+ headers: {
53234
+ "User-Agent": "Pipelab-Desktop-Updater",
53235
+ Accept: "application/vnd.github.v3+json"
53236
+ },
53237
+ signal: AbortSignal.timeout(1e4)
53238
+ });
53265
53239
  if (!response.ok) throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
53266
53240
  const refs = await response.json();
53267
53241
  if (!Array.isArray(refs)) return [];
@@ -53279,10 +53253,13 @@ async function fetchPackageReleases(packageName, options = {}) {
53279
53253
  });
53280
53254
  for (const tag of filteredTags) {
53281
53255
  console.log(`[GitHub] Fetching release details for tag: ${tag}`);
53282
- const releaseResponse = await fetch(`https://api.github.com/repos/${repo}/releases/tags/${encodeURIComponent(tag)}`, { headers: {
53283
- "User-Agent": "Pipelab-Desktop-Updater",
53284
- Accept: "application/vnd.github.v3+json"
53285
- } });
53256
+ const releaseResponse = await fetch(`https://api.github.com/repos/${repo}/releases/tags/${encodeURIComponent(tag)}`, {
53257
+ headers: {
53258
+ "User-Agent": "Pipelab-Desktop-Updater",
53259
+ Accept: "application/vnd.github.v3+json"
53260
+ },
53261
+ signal: AbortSignal.timeout(1e4)
53262
+ });
53286
53263
  if (releaseResponse.status === 404) {
53287
53264
  console.warn(`[GitHub] Tag "${tag}" has no associated Release, skipping.`);
53288
53265
  continue;
@@ -53334,6 +53311,6 @@ async function fetchLatestDesktopRelease(options = {}) {
53334
53311
  return latest;
53335
53312
  }
53336
53313
  //#endregion
53337
- export { BuildHistoryStorage, PipelabContext, WebSocketServer, builtInPlugins, downloadFile, ensure, ensureNodeJS, ensurePNPM, executeGraphWithHistory, extractTarGz, extractZip, fetchLatestDesktopRelease, fetchLatestPackageRelease, fetchPackage, fetchPackageReleases, fetchPipelabAsset, fetchPipelabCli, fetchPipelabPlugin, findInstalledPlugins, getDefaultUserDataPath, getFinalPlugins, getFolderSize, getMigrator, handleActionExecute, isDev, isOnline, loadCustomPlugin, loadPipelabPlugin, projectRoot, registerAgentsHandlers, registerAllHandlers, registerConfigHandlers, registerEngineHandlers, registerFsHandlers, registerHistoryHandlers, registerMigrationHandlers, registerShellHandlers, runPipelineCommand, runPnpm, runWithLiveLogs, sendStartupProgress, sendStartupReady, serveCommand, setupConfigFile, useAPI, usePluginAPI, webSocketServer, zipFolder };
53314
+ export { BuildHistoryStorage, CacheFolder, PipelabContext, WebSocketServer, builtInPlugins, deleteConfigFile, downloadFile, ensure, ensureNodeJS, ensurePNPM, executeGraphWithHistory, extractTarGz, extractZip, fetchLatestDesktopRelease, fetchLatestPackageRelease, fetchPackage, fetchPackageReleases, fetchPipelabAsset, fetchPipelabCli, fetchPipelabPlugin, findInstalledPlugins, getDefaultUserDataPath, getFinalPlugins, getFolderSize, getMigrator, handleActionExecute, isDev, isOnline, loadCustomPlugin, loadPipelabPlugin, projectRoot, registerAgentsHandlers, registerAllHandlers, registerConfigHandlers, registerEngineHandlers, registerFsHandlers, registerHistoryHandlers, registerMigrationHandlers, registerShellHandlers, runPipelineCommand, runPnpm, runWithLiveLogs, sendStartupProgress, sendStartupReady, serveCommand, setupConfigFile, useAPI, usePluginAPI, webSocketServer, zipFolder };
53338
53315
 
53339
53316
  //# sourceMappingURL=index.mjs.map