@pipelab/cli 2.0.0-beta.16 → 2.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.
@@ -0,0 +1,4 @@
1
+ import "./src-Cgn6322X.mjs";
2
+ import "./dist-BC_B45iu.mjs";
3
+ import { r as setupConfigFile } from "./config-wyW8CcHw.mjs";
4
+ export { setupConfigFile };
@@ -1,5 +1,5 @@
1
1
  import { a as __require, s as __toESM, t as __commonJSMin } from "./chunk-M2dkpuaD.mjs";
2
- import { C as useLogger, n as normalizePipelineConfig, t as configRegistry } from "./src-IhkP0N4B.mjs";
2
+ import { S as useLogger, t as configRegistry } from "./src-Cgn6322X.mjs";
3
3
  import path, { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { constants } from "node:os";
@@ -40366,7 +40366,7 @@ const setupConfigFile = async (name, options) => {
40366
40366
  debug: false,
40367
40367
  onStep: async (state, version) => {
40368
40368
  const parsedPath = path.parse(filesPath);
40369
- const versionedPath = path.join(parsedPath.dir, `${parsedPath.name}.v${version}.json`);
40369
+ const versionedPath = ctx.getConfigPath(`${parsedPath.name}.v${version}.json`);
40370
40370
  try {
40371
40371
  await fs$1.writeFile(versionedPath, JSON.stringify(state));
40372
40372
  logger().info(`Intermediate backup created for ${name} at ${versionedPath}`);
@@ -40381,13 +40381,11 @@ const setupConfigFile = async (name, options) => {
40381
40381
  migrationFailed = true;
40382
40382
  json = migrator.defaultValue;
40383
40383
  }
40384
- let normalized = false;
40385
- if (name.startsWith("pipeline-") || path.isAbsolute(name) || name.endsWith(".json") || name === "pipeline") normalized = normalizePipelineConfig(json);
40386
- if (originalJson?.version !== json?.version || normalized || content === void 0 || parseFailed || migrationFailed) {
40384
+ if (originalJson?.version !== json?.version || content === void 0 || parseFailed || migrationFailed) {
40387
40385
  if (parseFailed || migrationFailed) try {
40388
40386
  const parsedPath = path.parse(filesPath);
40389
40387
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
40390
- const corruptedPath = path.join(parsedPath.dir, `${parsedPath.name}.corrupted.${timestamp}.json`);
40388
+ const corruptedPath = ctx.getConfigPath(`${parsedPath.name}.corrupted.${timestamp}.json`);
40391
40389
  const backupContent = parseFailed ? content || "" : JSON.stringify(originalJson, null, 2);
40392
40390
  await fs$1.writeFile(corruptedPath, backupContent);
40393
40391
  logger().info(`Corrupted config file preserved at ${corruptedPath}`);
@@ -40404,5 +40402,9 @@ const setupConfigFile = async (name, options) => {
40404
40402
  }
40405
40403
  };
40406
40404
  };
40405
+ const deleteConfigFile = async (nameOrPath, context) => {
40406
+ const filesPath = path.isAbsolute(nameOrPath) ? nameOrPath : context.getConfigPath(`${nameOrPath}.json`);
40407
+ await fs$1.rm(filesPath, { force: true });
40408
+ };
40407
40409
  //#endregion
40408
- export { extractTarGz as a, require_commonjs$2 as c, ensure as i, require_balanced_match as l, setupConfigFile as n, extractZip as o, downloadFile as r, getFolderSize as s, getMigrator as t, execa as u };
40410
+ export { ensure as a, getFolderSize as c, execa as d, downloadFile as i, require_commonjs$2 as l, getMigrator as n, extractTarGz as o, setupConfigFile as r, extractZip as s, deleteConfigFile as t, require_balanced_match as u };
package/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import { a as __require, n as __esmMin, s as __toESM, t as __commonJSMin } from "./chunk-M2dkpuaD.mjs";
3
- import { C as useLogger, _ as processGraph, a as isWebSocketRequestMessage, c as isSupabaseAvailable, d as usePlugins, i as WebSocketError, l as supabase, o as isRequired, r as savedFileMigrator, s as transformUrl, u as SubscriptionRequiredError } from "./src-IhkP0N4B.mjs";
3
+ import { S as useLogger, a as isRequired, c as supabase, g as processGraph, i as isWebSocketRequestMessage, l as SubscriptionRequiredError, n as savedFileMigrator, o as transformUrl, r as WebSocketError, s as isSupabaseAvailable, u as usePlugins } from "./src-Cgn6322X.mjs";
4
4
  import "./dist-BC_B45iu.mjs";
5
- import { a as extractTarGz, c as require_commonjs$8, l as require_balanced_match, n as setupConfigFile, o as extractZip, r as downloadFile, s as getFolderSize, t as getMigrator, u as execa } from "./config-C2_-dWDC.mjs";
5
+ import { c as getFolderSize, d as execa, i as downloadFile, l as require_commonjs$8, n as getMigrator, o as extractTarGz, r as setupConfigFile, s as extractZip, t as deleteConfigFile, u as require_balanced_match } from "./config-wyW8CcHw.mjs";
6
6
  import path, { delimiter, dirname, isAbsolute, join, normalize, resolve, sep } from "node:path";
7
7
  import { fileURLToPath, pathToFileURL } from "node:url";
8
8
  import { homedir, platform, release } from "node:os";
9
9
  import fs, { createReadStream, existsSync, readFileSync, readdirSync, statSync } from "node:fs";
10
- import fs$1, { access, chmod, cp, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
10
+ import { access, chmod, cp, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
11
11
  import http from "http";
12
12
  import http$1 from "node:http";
13
13
  import { webcrypto } from "node:crypto";
@@ -69,6 +69,11 @@ function findProjectRoot(startDir) {
69
69
  return null;
70
70
  }
71
71
  const projectRoot = findProjectRoot(_dirname);
72
+ const CacheFolder = {
73
+ Actions: "actions",
74
+ Pipelines: "pipelines",
75
+ Pacote: "pacote"
76
+ };
72
77
  var PipelabContext = class {
73
78
  userDataPath;
74
79
  releaseTag;
@@ -93,12 +98,16 @@ var PipelabContext = class {
93
98
  await mkdir(baseDir, { recursive: true });
94
99
  return await mkdtemp(join(await realpath(baseDir), prefix));
95
100
  }
96
- getCachePath(...subpaths) {
97
- return join(this.userDataPath, "cache", ...subpaths);
101
+ getCachePath(folder, ...subpaths) {
102
+ if (!folder) return join(this.userDataPath, "cache");
103
+ return join(this.userDataPath, "cache", folder, ...subpaths);
98
104
  }
99
105
  getPnpmPath(...subpaths) {
100
106
  return join(this.userDataPath, "pnpm", ...subpaths);
101
107
  }
108
+ getBuildHistoryPath(...subpaths) {
109
+ return join(this.userDataPath, "build-history", ...subpaths);
110
+ }
102
111
  getNodePath(version = DEFAULT_NODE_VERSION) {
103
112
  const isWindows = process.platform === "win32";
104
113
  return this.getThirdPartyPath("node", version, isWindows ? "node.exe" : "bin/node");
@@ -4090,18 +4099,7 @@ const registerConfigHandlers = (context) => {
4090
4099
  const { config: name } = value;
4091
4100
  logger().info("config:delete", name);
4092
4101
  try {
4093
- const filesPath = path.isAbsolute(name) ? name : context.getConfigPath(`${name}.json`);
4094
- await fs$1.rm(filesPath, { force: true });
4095
- const parsedPath = path.parse(filesPath);
4096
- const dirEntries = await fs$1.readdir(parsedPath.dir).catch(() => []);
4097
- const prefix = `${parsedPath.name}.v`;
4098
- const suffix = `.json`;
4099
- for (const entry of dirEntries) if (entry.startsWith(prefix) && entry.endsWith(suffix)) {
4100
- const backupPath = path.join(parsedPath.dir, entry);
4101
- await fs$1.rm(backupPath, { force: true }).catch((err) => {
4102
- logger().error(`Failed to delete backup ${backupPath}:`, err);
4103
- });
4104
- }
4102
+ await deleteConfigFile(name, context);
4105
4103
  send({
4106
4104
  type: "end",
4107
4105
  data: {
@@ -4284,11 +4282,10 @@ var BuildHistoryStorage = class {
4284
4282
  this.context = context;
4285
4283
  }
4286
4284
  getStoragePath() {
4287
- return join(this.context.userDataPath, "build-history");
4285
+ return this.context.getConfigPath("pipelines");
4288
4286
  }
4289
4287
  getPipelinePath(pipelineId) {
4290
- const sanitizedId = pipelineId.replace(/[/\:*?"<>|]/g, "_").replace(/__/g, "_").replace(/^_+|_+$/g, "");
4291
- return join(this.getStoragePath(), `pipeline-${sanitizedId}.json`);
4288
+ return join(this.getStoragePath(), `${pipelineId}.history.json`);
4292
4289
  }
4293
4290
  async ensureStoragePath() {
4294
4291
  try {
@@ -4315,35 +4312,6 @@ var BuildHistoryStorage = class {
4315
4312
  throw new Error(`Failed to save pipeline history: ${error}`);
4316
4313
  }
4317
4314
  }
4318
- async applyRetentionPolicy() {
4319
- try {
4320
- this.logger.logger().info("Applying build history retention policy...");
4321
- const policy = (await (await setupConfigFile("settings", { context: this.context })).getConfig())?.buildHistory?.retentionPolicy;
4322
- if (!policy || !policy.enabled) {
4323
- this.logger.logger().info("Retention policy is disabled. Skipping.");
4324
- return;
4325
- }
4326
- const { maxAge, maxEntries } = policy;
4327
- const pipelineFiles = await this.getAllPipelineFiles();
4328
- for (const file of pipelineFiles) {
4329
- const pipelineId = file.replace("pipeline-", "").replace(".json", "");
4330
- let entries = await this.loadPipelineHistory(pipelineId);
4331
- const originalCount = entries.length;
4332
- if (maxAge > 0) {
4333
- const minDate = Date.now() - maxAge * 24 * 60 * 60 * 1e3;
4334
- entries = entries.filter((entry) => entry.createdAt >= minDate);
4335
- }
4336
- if (maxEntries > 0 && entries.length > maxEntries) entries = entries.sort((a, b) => b.createdAt - a.createdAt).slice(0, maxEntries);
4337
- if (entries.length < originalCount) {
4338
- this.logger.logger().info(`[${pipelineId}] Pruned ${originalCount - entries.length} history entries.`);
4339
- await this.savePipelineHistory(pipelineId, entries);
4340
- }
4341
- }
4342
- this.logger.logger().info("Retention policy applied successfully.");
4343
- } catch (error) {
4344
- this.logger.logger().error("Failed to apply retention policy:", error);
4345
- }
4346
- }
4347
4315
  async save(entry) {
4348
4316
  try {
4349
4317
  const entries = await this.loadPipelineHistory(entry.pipelineId);
@@ -4352,9 +4320,6 @@ var BuildHistoryStorage = class {
4352
4320
  else entries.push(entry);
4353
4321
  await this.savePipelineHistory(entry.pipelineId, entries);
4354
4322
  this.logger.logger().info(`Saved build history entry: ${entry.id} for pipeline: ${entry.pipelineId}`);
4355
- this.applyRetentionPolicy().catch((err) => {
4356
- this.logger.logger().error("Failed to apply retention policy after save:", err);
4357
- });
4358
4323
  } catch (error) {
4359
4324
  this.logger.logger().error("Failed to save build history entry:", error);
4360
4325
  throw new Error(`Failed to save build history entry: ${error}`);
@@ -4365,7 +4330,8 @@ var BuildHistoryStorage = class {
4365
4330
  if (pipelineId) return (await this.loadPipelineHistory(pipelineId)).find((e) => e.id === id);
4366
4331
  const files = await this.getAllPipelineFiles();
4367
4332
  for (const file of files) {
4368
- const pId = file.replace("pipeline-", "").replace(".json", "");
4333
+ const pId = this.parsePipelineIdFromFilename(file);
4334
+ if (!pId) continue;
4369
4335
  const entry = (await this.loadPipelineHistory(pId)).find((e) => e.id === id);
4370
4336
  if (entry) return entry;
4371
4337
  }
@@ -4380,7 +4346,8 @@ var BuildHistoryStorage = class {
4380
4346
  const files = await this.getAllPipelineFiles();
4381
4347
  const allEntries = [];
4382
4348
  for (const file of files) {
4383
- const pipelineId = file.replace("pipeline-", "").replace(".json", "");
4349
+ const pipelineId = this.parsePipelineIdFromFilename(file);
4350
+ if (!pipelineId) continue;
4384
4351
  const entries = await this.loadPipelineHistory(pipelineId);
4385
4352
  allEntries.push(...entries);
4386
4353
  }
@@ -4415,7 +4382,8 @@ var BuildHistoryStorage = class {
4415
4382
  } else {
4416
4383
  const files = await this.getAllPipelineFiles();
4417
4384
  for (const file of files) {
4418
- const pId = file.replace("pipeline-", "").replace(".json", "");
4385
+ const pId = this.parsePipelineIdFromFilename(file);
4386
+ if (!pId) continue;
4419
4387
  const entries = await this.loadPipelineHistory(pId);
4420
4388
  const entryIndex = entries.findIndex((e) => e.id === id);
4421
4389
  if (entryIndex >= 0) {
@@ -4449,7 +4417,8 @@ var BuildHistoryStorage = class {
4449
4417
  } else {
4450
4418
  const files = await this.getAllPipelineFiles();
4451
4419
  for (const file of files) {
4452
- const pId = file.replace("pipeline-", "").replace(".json", "");
4420
+ const pId = this.parsePipelineIdFromFilename(file);
4421
+ if (!pId) continue;
4453
4422
  const entries = await this.loadPipelineHistory(pId);
4454
4423
  const entryIndex = entries.findIndex((e) => e.id === id);
4455
4424
  if (entryIndex >= 0) {
@@ -4470,8 +4439,20 @@ var BuildHistoryStorage = class {
4470
4439
  try {
4471
4440
  await this.ensureStoragePath();
4472
4441
  const files = await this.getAllPipelineFiles();
4473
- await Promise.all(files.map((file) => unlink(join(this.getStoragePath(), file))));
4442
+ const cachePathsToDelete = /* @__PURE__ */ new Set();
4443
+ for (const file of files) {
4444
+ const pipelineId = this.parsePipelineIdFromFilename(file);
4445
+ if (pipelineId) {
4446
+ const entries = await this.loadPipelineHistory(pipelineId);
4447
+ for (const entry of entries) if (entry.cachePath) cachePathsToDelete.add(entry.cachePath);
4448
+ }
4449
+ await unlink(join(this.getStoragePath(), file));
4450
+ }
4474
4451
  this.logger.logger().info("Cleared all build history");
4452
+ for (const cachePath of cachePathsToDelete) await rm(cachePath, {
4453
+ recursive: true,
4454
+ force: true
4455
+ }).catch(() => {});
4475
4456
  } catch (error) {
4476
4457
  this.logger.logger().error("Failed to clear build history:", error);
4477
4458
  throw new Error(`Failed to clear build history: ${error}`);
@@ -4479,8 +4460,16 @@ var BuildHistoryStorage = class {
4479
4460
  }
4480
4461
  async clearByPipeline(pipelineId) {
4481
4462
  try {
4482
- await unlink(this.getPipelinePath(pipelineId));
4463
+ const pipelinePath = this.getPipelinePath(pipelineId);
4464
+ const entries = await this.loadPipelineHistory(pipelineId);
4465
+ await unlink(pipelinePath);
4483
4466
  this.logger.logger().info(`Cleared history for pipeline "${pipelineId}"`);
4467
+ const cachePathsToDelete = /* @__PURE__ */ new Set();
4468
+ for (const entry of entries) if (entry.cachePath) cachePathsToDelete.add(entry.cachePath);
4469
+ for (const cachePath of cachePathsToDelete) await rm(cachePath, {
4470
+ recursive: true,
4471
+ force: true
4472
+ }).catch(() => {});
4484
4473
  } catch (error) {
4485
4474
  if (error.code === "ENOENT") {
4486
4475
  this.logger.logger().warn(`No history file found for pipeline "${pipelineId}". Nothing to clear.`);
@@ -4505,21 +4494,11 @@ var BuildHistoryStorage = class {
4505
4494
  size
4506
4495
  });
4507
4496
  }
4508
- const policy = (await (await setupConfigFile("settings", { context: this.context })).getConfig())?.buildHistory?.retentionPolicy || {
4509
- enabled: false,
4510
- maxEntries: 50,
4511
- maxAge: 30
4512
- };
4513
4497
  if (allEntries.length === 0) return {
4514
4498
  totalEntries: 0,
4515
4499
  totalSize: 0,
4516
4500
  numberOfPipelines: files.length,
4517
4501
  userDataPath: this.context.userDataPath,
4518
- retentionPolicy: {
4519
- enabled: policy.enabled,
4520
- maxEntries: policy.maxEntries,
4521
- maxAge: policy.maxAge
4522
- },
4523
4502
  disk: {
4524
4503
  total: diskSpace.size,
4525
4504
  free: diskSpace.free,
@@ -4544,11 +4523,6 @@ var BuildHistoryStorage = class {
4544
4523
  newestEntry: sortedEntries[sortedEntries.length - 1]?.createdAt,
4545
4524
  numberOfPipelines: files.length,
4546
4525
  userDataPath: this.context.userDataPath,
4547
- retentionPolicy: {
4548
- enabled: policy.enabled,
4549
- maxEntries: policy.maxEntries,
4550
- maxAge: policy.maxAge
4551
- },
4552
4526
  disk: {
4553
4527
  total: diskSpace.size,
4554
4528
  free: diskSpace.free,
@@ -4564,11 +4538,15 @@ var BuildHistoryStorage = class {
4564
4538
  async getAllPipelineFiles() {
4565
4539
  try {
4566
4540
  await this.ensureStoragePath();
4567
- return (await readdir(this.getStoragePath())).filter((file) => file.startsWith("pipeline-") && file.endsWith(".json"));
4541
+ return (await readdir(this.getStoragePath())).filter((file) => file.endsWith(".history.json"));
4568
4542
  } catch (error) {
4569
4543
  return [];
4570
4544
  }
4571
4545
  }
4546
+ parsePipelineIdFromFilename(filename) {
4547
+ const match = filename.match(/^(.+)\.history\.json$/);
4548
+ return match ? match[1] : null;
4549
+ }
4572
4550
  };
4573
4551
  //#endregion
4574
4552
  //#region ../../packages/core-node/src/handlers/history.ts
@@ -4850,40 +4828,6 @@ const registerHistoryHandlers = (context) => {
4850
4828
  });
4851
4829
  }
4852
4830
  });
4853
- handle("build-history:configure", async (_, { send, value }) => {
4854
- try {
4855
- logger().info("Updating build history configuration:", value.config);
4856
- const settings = await setupConfigFile("settings", { context });
4857
- const currentConfig = await settings.getConfig();
4858
- const newConfig = {
4859
- ...currentConfig,
4860
- buildHistory: {
4861
- ...currentConfig?.buildHistory,
4862
- retentionPolicy: {
4863
- ...currentConfig?.buildHistory?.retentionPolicy,
4864
- ...value.config.retentionPolicy
4865
- }
4866
- }
4867
- };
4868
- await settings.setConfig(newConfig);
4869
- send({
4870
- type: "end",
4871
- data: {
4872
- type: "success",
4873
- result: { result: "ok" }
4874
- }
4875
- });
4876
- } catch (error) {
4877
- logger().error("Failed to configure build history:", error);
4878
- send({
4879
- type: "end",
4880
- data: {
4881
- type: "error",
4882
- ipcError: error instanceof Error ? error.message : "Failed to configure build history"
4883
- }
4884
- });
4885
- }
4886
- });
4887
4831
  };
4888
4832
  //#endregion
4889
4833
  //#region ../../node_modules/@npmcli/package-json/node_modules/json-parse-even-better-errors/lib/index.js
@@ -66601,7 +66545,13 @@ async function serveCommand(options, version, _dirname) {
66601
66545
  response.end(`Error: UI directory not found at ${rawAssetFolder}.\nPlease run 'pnpm build' in apps/ui to generate the distribution.`);
66602
66546
  return;
66603
66547
  }
66604
- return (0, import_src$1.default)(request, response, { public: rawAssetFolder });
66548
+ return (0, import_src$1.default)(request, response, {
66549
+ public: rawAssetFolder,
66550
+ rewrites: [{
66551
+ source: "/**",
66552
+ destination: "/index.html"
66553
+ }]
66554
+ });
66605
66555
  });
66606
66556
  console.log(`Starting Pipelab server on port ${options.port}...`);
66607
66557
  console.log(`UI available at http://localhost:${options.port}`);
@@ -66692,7 +66642,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
66692
66642
  console.log(`[Fetcher] ${packageName}: Resolved to local fallback ${resolvedVersion} (${Date.now() - fallbackStart}ms)`);
66693
66643
  } else throw new Error(`Offline and no local fallback version available for ${packageName}`);
66694
66644
  } else try {
66695
- const cachePath = join(ctx.userDataPath, "cache", "pacote");
66645
+ const cachePath = ctx.getCachePath(CacheFolder.Pacote);
66696
66646
  let packumentPromise = packumentRequests.get(packageName);
66697
66647
  if (!packumentPromise) {
66698
66648
  packumentPromise = import_lib.default.packument(packageName, { cache: cachePath });
@@ -66723,7 +66673,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
66723
66673
  console.log(`[Fetcher] ${packageName}: Resolved to local fallback ${resolvedVersion} (${Date.now() - fallbackStart}ms)`);
66724
66674
  } else throw error;
66725
66675
  }
66726
- const cachePath = join(ctx.userDataPath, "cache", "pacote");
66676
+ const cachePath = ctx.getCachePath(CacheFolder.Pacote);
66727
66677
  const packageDir = join(baseDir, resolvedVersion);
66728
66678
  const checkStart = Date.now();
66729
66679
  const isInstalled = options?.installDeps ? isPackageComplete(packageDir) && isDependenciesInstalledSync(packageDir) : isPackageComplete(packageDir);
@@ -66800,7 +66750,7 @@ async function runPnpm(cwd, options) {
66800
66750
  ...process.env,
66801
66751
  NODE_ENV: "production",
66802
66752
  PATH: nodePath ? `${dirname(nodePath)}${delimiter}${process.env.PATH}` : process.env.PATH,
66803
- PNPM_HOME: join(ctx.userDataPath, "pnpm"),
66753
+ PNPM_HOME: ctx.getPnpmPath(),
66804
66754
  PNPM_ONLY_ALLOW_TRUSTED_DEPENDENCIES: "false",
66805
66755
  ...extraEnv
66806
66756
  }
@@ -67219,9 +67169,9 @@ const builtInPlugins = async (options) => {
67219
67169
  const envStart = Date.now();
67220
67170
  await Promise.all([ensureNodeJS(options.context), ensurePNPM(options.context)]);
67221
67171
  console.log(`[Plugins] Environment preparation took ${Date.now() - envStart}ms`);
67222
- const { usePlugins } = await import("./src-XVe3IQMi.mjs");
67172
+ const { usePlugins } = await import("./src-BmqReRBI.mjs");
67223
67173
  const { registerPlugins } = usePlugins();
67224
- const { webSocketServer } = await import("./src-CHr-wGNr.mjs");
67174
+ const { webSocketServer } = await import("./src-DhNbRNuq.mjs");
67225
67175
  webSocketServer.broadcast("startup:progress", { type: "ready" });
67226
67176
  (async () => {
67227
67177
  const totalStart = Date.now();
@@ -67241,7 +67191,7 @@ const builtInPlugins = async (options) => {
67241
67191
  "@pipelab/plugin-netlify"
67242
67192
  ]) pluginsToLoad.set(name, "latest");
67243
67193
  try {
67244
- const { setupConfigFile } = await import("./config-kWOWhsn6.mjs");
67194
+ const { setupConfigFile } = await import("./config-Cjh-mvRR.mjs");
67245
67195
  const settingsPlugins = (await (await setupConfigFile("settings", { context: options.context })).getConfig())?.plugins || [];
67246
67196
  for (const plugin of settingsPlugins) if (plugin.name) if (plugin.enabled) {
67247
67197
  if (!pluginsToLoad.has(plugin.name)) pluginsToLoad.set(plugin.name, "latest");
@@ -67250,7 +67200,7 @@ const builtInPlugins = async (options) => {
67250
67200
  console.error(`[Plugins] Failed to load settings config on startup:`, e);
67251
67201
  }
67252
67202
  console.log(`[Plugins] Total plugins to load on startup:`, Array.from(pluginsToLoad.entries()));
67253
- for (const [packageName, version] of pluginsToLoad.entries()) {
67203
+ const loadPromises = Array.from(pluginsToLoad.entries()).map(async ([packageName, version]) => {
67254
67204
  sendStartupProgress(`Loading plugin: ${packageName}`);
67255
67205
  const pluginStart = Date.now();
67256
67206
  try {
@@ -67263,7 +67213,8 @@ const builtInPlugins = async (options) => {
67263
67213
  } catch (err) {
67264
67214
  console.error(`[Plugins] Failed to load plugin ${packageName} at startup:`, err);
67265
67215
  }
67266
- }
67216
+ });
67217
+ await Promise.all(loadPromises);
67267
67218
  console.log(`[Plugins] All startup plugins loaded in ${Date.now() - totalStart}ms.`);
67268
67219
  sendStartupProgress("All plugins loaded.");
67269
67220
  setTimeout(() => {
@@ -67311,6 +67262,7 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
67311
67262
  projectName,
67312
67263
  projectPath,
67313
67264
  pipelineId,
67265
+ cachePath,
67314
67266
  startTime,
67315
67267
  status: "running",
67316
67268
  logs: [],
@@ -67407,7 +67359,6 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
67407
67359
  }, pipelineId);
67408
67360
  throw error;
67409
67361
  } finally {
67410
- if (!shouldDisableHistory) buildHistoryStorage.applyRetentionPolicy();
67411
67362
  try {
67412
67363
  await rm(sandboxPath, {
67413
67364
  recursive: true,
@@ -67416,6 +67367,14 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
67416
67367
  } catch (e) {
67417
67368
  console.warn(`Failed to cleanup sandbox at ${sandboxPath}:`, e);
67418
67369
  }
67370
+ try {
67371
+ await rm(cachePath, {
67372
+ recursive: true,
67373
+ force: true
67374
+ });
67375
+ } catch (e) {
67376
+ console.warn(`Failed to cleanup cache at ${cachePath}:`, e);
67377
+ }
67419
67378
  }
67420
67379
  };
67421
67380
  //#endregion
@@ -67791,24 +67750,32 @@ const registerEngineHandlers = (context) => {
67791
67750
  };
67792
67751
  handle("action:execute", async (event, { send, value }) => {
67793
67752
  const { nodeId, params, pluginId } = value;
67794
- await (await setupConfigFile("settings", { context })).getConfig();
67795
- const cachePath = join(context.userDataPath, "cache", "actions", pluginId, nodeId);
67753
+ const cachePath = context.getCachePath(CacheFolder.Actions, pluginId, nodeId);
67796
67754
  const cwd = await context.createTempFolder("action-execute-");
67797
- const mainWindow = void 0;
67798
- abortControllerGraph = new AbortController();
67799
- const signalPromise = new Promise((resolve, reject) => {
67800
- abortControllerGraph.signal.addEventListener("abort", async () => {
67801
- await send({
67802
- type: "end",
67803
- data: {
67804
- ipcError: "Action aborted",
67805
- type: "error"
67806
- }
67755
+ try {
67756
+ const mainWindow = void 0;
67757
+ abortControllerGraph = new AbortController();
67758
+ const signalPromise = new Promise((resolve, reject) => {
67759
+ abortControllerGraph.signal.addEventListener("abort", async () => {
67760
+ await send({
67761
+ type: "end",
67762
+ data: {
67763
+ ipcError: "Action aborted",
67764
+ type: "error"
67765
+ }
67766
+ });
67767
+ return reject(/* @__PURE__ */ new Error("Action interrupted"));
67807
67768
  });
67808
- return reject(/* @__PURE__ */ new Error("Action interrupted"));
67809
67769
  });
67810
- });
67811
- await Promise.race([signalPromise, effectiveActionExecute(nodeId, pluginId, params, mainWindow, send, cwd, cachePath)]);
67770
+ await Promise.race([signalPromise, effectiveActionExecute(nodeId, pluginId, params, mainWindow, send, cwd, cachePath)]);
67771
+ } finally {
67772
+ await rm(cwd, {
67773
+ recursive: true,
67774
+ force: true
67775
+ }).catch((err) => {
67776
+ console.warn(`Failed to cleanup temp folder at ${cwd}:`, err);
67777
+ });
67778
+ }
67812
67779
  });
67813
67780
  handle("constants:get", async (_, { send }) => {
67814
67781
  const userData = context.userDataPath;
@@ -67836,7 +67803,7 @@ const registerEngineHandlers = (context) => {
67836
67803
  const effectiveProjectName = projectName || "Unnamed Project";
67837
67804
  const effectiveProjectPath = projectPath || "";
67838
67805
  const effectivePipelineId = pipelineId || "unknown";
67839
- const effectiveCachePath = join(context.userDataPath, "cache", effectivePipelineId);
67806
+ const effectiveCachePath = context.getCachePath(CacheFolder.Pipelines, effectivePipelineId);
67840
67807
  const mainWindow = void 0;
67841
67808
  abortControllerGraph = new AbortController();
67842
67809
  try {
@@ -67944,7 +67911,7 @@ var JsonFileStorage = class {
67944
67911
  filePath;
67945
67912
  logger = useLogger().logger;
67946
67913
  constructor(fileName, context) {
67947
- this.filePath = path.join(context.userDataPath, fileName);
67914
+ this.filePath = context.getConfigPath(fileName);
67948
67915
  const dir = path.dirname(this.filePath);
67949
67916
  if (!fs.existsSync(dir)) try {
67950
67917
  fs.mkdirSync(dir, { recursive: true });
@@ -68408,8 +68375,7 @@ async function runPipelineCommand(file, options, version) {
68408
68375
  context
68409
68376
  });
68410
68377
  registerMigrationHandlers(context);
68411
- await (await setupConfigFile("settings", { context })).getConfig();
68412
- const cachePath = join(context.userDataPath, "cache");
68378
+ const cachePath = context.getCachePath(CacheFolder.Pipelines, effectivePipelineId);
68413
68379
  await mkdir(cachePath, { recursive: true });
68414
68380
  const abortController = new AbortController();
68415
68381
  let supabase;
@@ -68476,7 +68442,7 @@ async function runPipelineCommand(file, options, version) {
68476
68442
  }
68477
68443
  //#endregion
68478
68444
  //#region package.json
68479
- var version$2 = "2.0.0-beta.16";
68445
+ var version$2 = "2.0.0-beta.18";
68480
68446
  //#endregion
68481
68447
  //#region src/paths.ts
68482
68448
  const getDefaultUserDataPath = () => {
@@ -68527,7 +68493,8 @@ function formatBytes(bytes, decimals = 2) {
68527
68493
  return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
68528
68494
  }
68529
68495
  async function usageCommand(options) {
68530
- const info = await new BuildHistoryStorage(new PipelabContext({ userDataPath: options.userData || getDefaultUserDataPath() })).getStorageInfo();
68496
+ const context = new PipelabContext({ userDataPath: options.userData || getDefaultUserDataPath() });
68497
+ const info = await new BuildHistoryStorage(context).getStorageInfo();
68531
68498
  console.log("Build History Storage Usage:");
68532
68499
  console.table({
68533
68500
  "Total Entries": info.totalEntries,
@@ -68536,13 +68503,7 @@ async function usageCommand(options) {
68536
68503
  "Oldest Entry": info.oldestEntry ? new Date(info.oldestEntry).toLocaleString() : "N/A",
68537
68504
  "Newest Entry": info.newestEntry ? new Date(info.newestEntry).toLocaleString() : "N/A",
68538
68505
  "User Data Path": info.userDataPath,
68539
- "Cache Path": join(info.userDataPath, "build-history")
68540
- });
68541
- console.log("\nRetention Policy:");
68542
- console.table({
68543
- Enabled: info.retentionPolicy.enabled ? "Yes" : "No",
68544
- "Max Entries": info.retentionPolicy.maxEntries > 0 ? info.retentionPolicy.maxEntries : "Unlimited",
68545
- "Max Age (days)": info.retentionPolicy.maxAge > 0 ? info.retentionPolicy.maxAge : "Unlimited"
68506
+ "Cache Path": context.getBuildHistoryPath()
68546
68507
  });
68547
68508
  }
68548
68509
  async function purgeCommand(pipelineId, options) {
@@ -68696,14 +68657,8 @@ async function deletePipelineCommand(id, options) {
68696
68657
  }
68697
68658
  const pipeline = repo.pipelines[index];
68698
68659
  if (pipeline.type === "internal") try {
68699
- const filePath = context.getConfigPath(`${pipeline.configName}.json`);
68700
- await unlink(filePath);
68660
+ await deleteConfigFile(pipeline.configName, context);
68701
68661
  console.log(`Deleted pipeline file: ${pipeline.configName}.json`);
68702
- const parsedPath = path.parse(filePath);
68703
- const dirEntries = await readdir(parsedPath.dir).catch(() => []);
68704
- const prefix = `${parsedPath.name}.v`;
68705
- const suffix = `.json`;
68706
- for (const entry of dirEntries) if (entry.startsWith(prefix) && entry.endsWith(suffix)) await unlink(path.join(parsedPath.dir, entry)).catch(() => {});
68707
68662
  } catch (e) {
68708
68663
  if (e.code !== "ENOENT") console.warn(`Warning: Could not delete pipeline file: ${e.message}`);
68709
68664
  }
@@ -76552,4 +76507,4 @@ program.hook("postAction", (thisCommand) => {
76552
76507
  program.parse(process.argv);
76553
76508
  if (!process.argv.slice(2).length) program.outputHelp();
76554
76509
  //#endregion
76555
- export { useAPI as A, registerHistoryHandlers as C, registerShellHandlers as D, registerFsHandlers as E, getDefaultUserDataPath$1 as M, projectRoot as N, WebSocketServer as O, registerMigrationHandlers as S, registerConfigHandlers 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, PipelabContext 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, BuildHistoryStorage as w, serveCommand as x, sendStartupProgress as y };
76510
+ export { useAPI as A, registerHistoryHandlers as C, registerShellHandlers as D, registerFsHandlers as E, PipelabContext as M, getDefaultUserDataPath$1 as N, WebSocketServer as O, projectRoot as P, registerMigrationHandlers as S, registerConfigHandlers 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, BuildHistoryStorage as w, serveCommand as x, sendStartupProgress as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipelab/cli",
3
- "version": "2.0.0-beta.16",
3
+ "version": "2.0.0-beta.18",
4
4
  "description": "The command line interface for Pipelab",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "author": "CynToolkit",
@@ -0,0 +1,3 @@
1
+ import { u as usePlugins } from "./src-Cgn6322X.mjs";
2
+ import "./dist-BC_B45iu.mjs";
3
+ export { usePlugins };
@@ -2080,7 +2080,7 @@ const settingsMigratorInternal = createMigrator();
2080
2080
  const defaultAppSettings = settingsMigratorInternal.createDefault({
2081
2081
  locale: "en-US",
2082
2082
  theme: "light",
2083
- version: "8.0.0",
2083
+ version: "7.0.0",
2084
2084
  autosave: true,
2085
2085
  agents: [],
2086
2086
  tours: {
@@ -2093,11 +2093,6 @@ const defaultAppSettings = settingsMigratorInternal.createDefault({
2093
2093
  completed: false
2094
2094
  }
2095
2095
  },
2096
- buildHistory: { retentionPolicy: {
2097
- enabled: false,
2098
- maxEntries: 50,
2099
- maxAge: 30
2100
- } },
2101
2096
  plugins: DEFAULT_PLUGINS,
2102
2097
  isInternalMigrationBannerClosed: false
2103
2098
  });
@@ -2154,18 +2149,13 @@ const appSettingsMigrator = settingsMigratorInternal.createMigrations({
2154
2149
  return {
2155
2150
  ...rest,
2156
2151
  agents: [],
2157
- buildHistory: { retentionPolicy: {
2158
- enabled: false,
2159
- maxEntries: 50,
2160
- maxAge: 30
2161
- } },
2162
2152
  plugins: DEFAULT_PLUGINS,
2163
2153
  isInternalMigrationBannerClosed: false
2164
2154
  };
2165
2155
  }
2166
2156
  }),
2167
2157
  createMigration({
2168
- version: "8.0.0",
2158
+ version: "7.0.0",
2169
2159
  up: finalVersion
2170
2160
  })
2171
2161
  ]
@@ -2184,7 +2174,7 @@ const connectionsMigrator = connectionsMigratorInternal.createMigrations({
2184
2174
  });
2185
2175
  const fileRepoMigratorInternal = createMigrator();
2186
2176
  const defaultFileRepo = fileRepoMigratorInternal.createDefault({
2187
- version: "2.0.0",
2177
+ version: "3.0.0",
2188
2178
  projects: [{
2189
2179
  id: "main",
2190
2180
  name: "Default project",
@@ -2194,30 +2184,39 @@ const defaultFileRepo = fileRepoMigratorInternal.createDefault({
2194
2184
  });
2195
2185
  const fileRepoMigrations = fileRepoMigratorInternal.createMigrations({
2196
2186
  defaultValue: defaultFileRepo,
2197
- migrations: [createMigration({
2198
- version: "1.0.0",
2199
- up: (state) => {
2200
- const pipelines = Object.entries(state.data || {}).map(([id, file]) => {
2187
+ migrations: [
2188
+ createMigration({
2189
+ version: "1.0.0",
2190
+ up: (state) => {
2191
+ const pipelines = Object.entries(state.data || {}).map(([id, file]) => {
2192
+ return {
2193
+ ...file,
2194
+ id,
2195
+ project: "main"
2196
+ };
2197
+ });
2201
2198
  return {
2202
- ...file,
2203
- id,
2204
- project: "main"
2199
+ ...state,
2200
+ projects: [{
2201
+ id: "main",
2202
+ name: "Default project",
2203
+ description: "The initial default project"
2204
+ }],
2205
+ pipelines
2205
2206
  };
2206
- });
2207
- return {
2208
- ...state,
2209
- projects: [{
2210
- id: "main",
2211
- name: "Default project",
2212
- description: "The initial default project"
2213
- }],
2214
- pipelines
2215
- };
2216
- }
2217
- }), createMigration({
2218
- version: "2.0.0",
2219
- up: finalVersion
2220
- })]
2207
+ }
2208
+ }),
2209
+ createMigration({
2210
+ version: "2.0.0",
2211
+ up: (state) => {
2212
+ return { ...state };
2213
+ }
2214
+ }),
2215
+ createMigration({
2216
+ version: "3.0.0",
2217
+ up: finalVersion
2218
+ })
2219
+ ]
2221
2220
  });
2222
2221
  const savedFileMigratorInternal = createMigrator();
2223
2222
  const savedFileDefaultValue = savedFileMigratorInternal.createDefault({
@@ -2345,31 +2344,6 @@ const getStrictPluginId = (pluginId) => {
2345
2344
  if (!pluginId) return pluginId;
2346
2345
  return LEGACY_ID_MAP[pluginId] || pluginId;
2347
2346
  };
2348
- const normalizeBlockPluginId = (block) => {
2349
- if (!block) return false;
2350
- let changed = false;
2351
- if (block.origin?.pluginId) {
2352
- const strictId = getStrictPluginId(block.origin.pluginId);
2353
- if (block.origin.pluginId !== strictId) {
2354
- block.origin.pluginId = strictId;
2355
- changed = true;
2356
- }
2357
- }
2358
- return changed;
2359
- };
2360
- const normalizePipelineConfig$1 = (state) => {
2361
- if (!state) return false;
2362
- let changed = false;
2363
- if (state.type === "default" && state.canvas) {
2364
- if (Array.isArray(state.canvas.blocks)) {
2365
- for (const block of state.canvas.blocks) if (normalizeBlockPluginId(block)) changed = true;
2366
- }
2367
- if (Array.isArray(state.canvas.triggers)) {
2368
- for (const trigger of state.canvas.triggers) if (normalizeBlockPluginId(trigger)) changed = true;
2369
- }
2370
- }
2371
- return changed;
2372
- };
2373
2347
  const configRegistry$1 = {
2374
2348
  settings: appSettingsMigrator,
2375
2349
  projects: fileRepoMigrations,
@@ -2412,14 +2386,19 @@ object({
2412
2386
  version: literal("1.0.0"),
2413
2387
  data: optional(record(string(), SaveLocationValidator), {})
2414
2388
  });
2415
- const FileRepoProjectValidatorV2$1 = object({
2389
+ const FileRepoProjectValidatorV2 = object({
2416
2390
  id: string(),
2417
2391
  name: string(),
2418
2392
  description: string()
2419
2393
  });
2420
2394
  object({
2421
2395
  version: literal("2.0.0"),
2422
- projects: array(FileRepoProjectValidatorV2$1),
2396
+ projects: array(FileRepoProjectValidatorV2),
2397
+ pipelines: optional(array(SaveLocationValidator), [])
2398
+ });
2399
+ object({
2400
+ version: literal("3.0.0"),
2401
+ projects: array(FileRepoProjectValidatorV2),
2423
2402
  pipelines: optional(array(SaveLocationValidator), [])
2424
2403
  });
2425
2404
  object({
@@ -2528,44 +2507,6 @@ object({
2528
2507
  name: string(),
2529
2508
  url: string()
2530
2509
  })),
2531
- buildHistory: object({ retentionPolicy: object({
2532
- enabled: boolean(),
2533
- maxEntries: number(),
2534
- maxAge: number()
2535
- }) })
2536
- });
2537
- object({
2538
- theme: union([literal("light"), literal("dark")]),
2539
- version: literal("8.0.0"),
2540
- locale: union([
2541
- literal("en-US"),
2542
- literal("fr-FR"),
2543
- literal("pt-BR"),
2544
- literal("zh-CN"),
2545
- literal("es-ES"),
2546
- literal("de-DE")
2547
- ]),
2548
- tours: object({
2549
- dashboard: object({
2550
- step: number(),
2551
- completed: boolean()
2552
- }),
2553
- editor: object({
2554
- step: number(),
2555
- completed: boolean()
2556
- })
2557
- }),
2558
- autosave: boolean(),
2559
- agents: array(object({
2560
- id: string(),
2561
- name: string(),
2562
- url: string()
2563
- })),
2564
- buildHistory: object({ retentionPolicy: object({
2565
- enabled: boolean(),
2566
- maxEntries: number(),
2567
- maxAge: number()
2568
- }) }),
2569
2510
  plugins: array(object({
2570
2511
  name: string(),
2571
2512
  enabled: boolean(),
@@ -32428,24 +32369,9 @@ var WebSocketError = class extends Error {
32428
32369
  const isWebSocketRequestMessage = (message) => {
32429
32370
  return message && typeof message.channel === "string" && message.requestId;
32430
32371
  };
32431
- object({
32432
- version: literal("1.0.0"),
32433
- data: optional(record(string(), SaveLocationValidator), {})
32434
- });
32435
- const FileRepoProjectValidatorV2 = object({
32436
- id: string(),
32437
- name: string(),
32438
- description: string()
32439
- });
32440
- object({
32441
- version: literal("2.0.0"),
32442
- projects: array(FileRepoProjectValidatorV2),
32443
- pipelines: optional(array(SaveLocationValidator), [])
32444
- });
32445
32372
  //#endregion
32446
32373
  //#region ../../packages/shared/src/index.ts
32447
32374
  const savedFileMigrator = savedFileMigrator$1;
32448
32375
  const configRegistry = configRegistry$1;
32449
- const normalizePipelineConfig = normalizePipelineConfig$1;
32450
32376
  //#endregion
32451
- export { useLogger as C, SaveLocationInternalValidator as D, SaveLocationExternalValidator as E, SaveLocationPipelabCloudValidator as O, fmt as S, FileRepoProjectValidatorV2$1 as T, processGraph as _, isWebSocketRequestMessage as a, createQuickJs as b, isSupabaseAvailable as c, usePlugins as d, EditorParamValidatorV3 as f, VariableValidatorV1 as g, SavedFileSimpleValidatorV4 as h, WebSocketError as i, SaveLocationValidator as k, supabase as l, SavedFileDefaultValidatorV4 as m, normalizePipelineConfig as n, isRequired as o, OriginValidator as p, savedFileMigrator as r, transformUrl as s, configRegistry as t, SubscriptionRequiredError as u, variableToFormattedVariable as v, ConnectionValidator as w, createQuickJsFromVariant as x, makeResolvedParams as y };
32377
+ export { ConnectionValidator as C, SaveLocationPipelabCloudValidator as D, SaveLocationInternalValidator as E, SaveLocationValidator as O, useLogger as S, SaveLocationExternalValidator as T, variableToFormattedVariable as _, isRequired as a, createQuickJsFromVariant as b, supabase as c, EditorParamValidatorV3 as d, OriginValidator as f, processGraph as g, VariableValidatorV1 as h, isWebSocketRequestMessage as i, SubscriptionRequiredError as l, SavedFileSimpleValidatorV4 as m, savedFileMigrator as n, transformUrl as o, SavedFileDefaultValidatorV4 as p, WebSocketError as r, isSupabaseAvailable as s, configRegistry as t, usePlugins as u, makeResolvedParams as v, FileRepoProjectValidatorV2 as w, fmt as x, createQuickJs as y };
@@ -1,5 +1,5 @@
1
- import "./src-IhkP0N4B.mjs";
1
+ import "./src-Cgn6322X.mjs";
2
2
  import "./dist-BC_B45iu.mjs";
3
- import "./config-C2_-dWDC.mjs";
3
+ import "./config-wyW8CcHw.mjs";
4
4
  import { k as webSocketServer } from "./index.mjs";
5
5
  export { webSocketServer };
@@ -1,4 +0,0 @@
1
- import "./src-IhkP0N4B.mjs";
2
- import "./dist-BC_B45iu.mjs";
3
- import { n as setupConfigFile } from "./config-C2_-dWDC.mjs";
4
- export { setupConfigFile };
package/src-XVe3IQMi.mjs DELETED
@@ -1,3 +0,0 @@
1
- import { d as usePlugins } from "./src-IhkP0N4B.mjs";
2
- import "./dist-BC_B45iu.mjs";
3
- export { usePlugins };