@pipelab/cli 2.0.0-beta.2 → 2.0.0-beta.4

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
@@ -1,6 +1,6 @@
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 { A as require_valid, M as require_clean, N as require_valid$1, O as useLogger, S as processGraph, c as isRequired, d as SubscriptionRequiredError, g as usePlugins, i as savedFileMigrator, j as require_satisfies, k as require_semver, l as isSupabaseAvailable, n as configRegistry, o as WebSocketError, r as fileRepoMigrations, s as isWebSocketRequestMessage, t as appSettingsMigrator, u as supabase } from "./src-B7Er1YgO.mjs";
3
+ import { A as require_valid, M as require_clean, N as require_valid$1, O as useLogger, S as processGraph, c as isRequired, d as SubscriptionRequiredError, g as usePlugins, i as savedFileMigrator, j as require_satisfies, k as require_semver, l as isSupabaseAvailable, n as configRegistry, o as WebSocketError, r as fileRepoMigrations, s as isWebSocketRequestMessage, t as appSettingsMigrator, u as supabase } from "./src-CksaCAal.mjs";
4
4
  import "./dist-BC_B45iu.mjs";
5
5
  import path, { delimiter, dirname, isAbsolute, join, normalize, resolve, sep } from "node:path";
6
6
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -36,14 +36,16 @@ var init_esm_shims = __esmMin((() => {
36
36
  //#region ../../packages/core-node/src/context.ts
37
37
  init_esm_shims();
38
38
  const _dirname = typeof __dirname$1 !== "undefined" ? __dirname$1 : typeof import.meta !== "undefined" && import.meta.url ? dirname(fileURLToPath(import.meta.url)) : process.cwd();
39
- const getDefaultUserDataPath = () => {
40
- return join((() => {
39
+ const getDefaultUserDataPath$1 = (env) => {
40
+ const base = (() => {
41
41
  switch (platform()) {
42
42
  case "win32": return process.env.APPDATA || join(homedir(), "AppData", "Roaming");
43
43
  case "darwin": return join(homedir(), "Library", "Application Support");
44
44
  default: return process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
45
45
  }
46
- })(), "@pipelab", "app");
46
+ })();
47
+ const mode = env ?? "prod";
48
+ return join(base, "@pipelab", mode === "dev" ? "app-dev" : mode === "beta" ? "app-beta" : "app");
47
49
  };
48
50
  /**
49
51
  * Finds the monorepo root by looking for pnpm-workspace.yaml.
@@ -59,8 +61,10 @@ function findProjectRoot(startDir) {
59
61
  const projectRoot = findProjectRoot(_dirname);
60
62
  var PipelabContext = class {
61
63
  userDataPath;
64
+ releaseTag;
62
65
  constructor(options) {
63
66
  this.userDataPath = options.userDataPath;
67
+ this.releaseTag = options.releaseTag || "latest";
64
68
  }
65
69
  getPackagesPath(...subpaths) {
66
70
  return join(this.userDataPath, "packages", ...subpaths);
@@ -44290,25 +44294,24 @@ const setupConfigFile = async (name, options) => {
44290
44294
  }
44291
44295
  let json = void 0;
44292
44296
  try {
44293
- json = await migrator.migrate(originalJson, { debug: false });
44297
+ json = await migrator.migrate(originalJson, {
44298
+ debug: false,
44299
+ onStep: async (state, version) => {
44300
+ const parsedPath = path.parse(filesPath);
44301
+ const versionedPath = path.join(parsedPath.dir, `${parsedPath.name}.v${version}.json`);
44302
+ try {
44303
+ await fs$1.writeFile(versionedPath, JSON.stringify(state));
44304
+ logger().info(`Intermediate backup created for ${name} at ${versionedPath}`);
44305
+ } catch (e) {
44306
+ logger().error(`Failed to create intermediate backup for ${name} at v${version}:`, e);
44307
+ }
44308
+ }
44309
+ });
44294
44310
  } catch (e) {
44295
44311
  logger().error(`Error migrating config ${name}:`, e);
44296
44312
  json = migrator.defaultValue;
44297
44313
  }
44298
- const originalVersion = originalJson?.version;
44299
- const newVersion = json?.version;
44300
- if (originalVersion !== newVersion && content !== void 0) {
44301
- const parsedPath = path.parse(filesPath);
44302
- const versionSuffix = originalVersion || "unknown";
44303
- const backupPath = path.join(parsedPath.dir, `${parsedPath.name}.${versionSuffix}.bak`);
44304
- try {
44305
- await fs$1.copyFile(filesPath, backupPath);
44306
- logger().info(`Backup created for ${name} at ${backupPath} (version ${versionSuffix})`);
44307
- } catch (e) {
44308
- logger().error(`Failed to create backup for ${name}:`, e);
44309
- }
44310
- }
44311
- if (originalVersion !== newVersion || content === void 0) try {
44314
+ if (originalJson?.version !== json?.version || content === void 0) try {
44312
44315
  await fs$1.writeFile(filesPath, JSON.stringify(json));
44313
44316
  } catch (e) {
44314
44317
  logger().error(`Error saving migrated config ${name}:`, e);
@@ -104122,9 +104125,13 @@ const sendStartupReady = () => {
104122
104125
  };
104123
104126
  async function serveCommand(options, version, _dirname) {
104124
104127
  if (!options.userData) throw new Error("userDataPath is required for serveCommand");
104125
- const context = new PipelabContext({ userDataPath: options.userData });
104128
+ const releaseTag = version.includes("beta") ? "beta" : "latest";
104129
+ const context = new PipelabContext({
104130
+ userDataPath: options.userData,
104131
+ releaseTag
104132
+ });
104126
104133
  let rawAssetFolder;
104127
- rawAssetFolder = await fetchPipelabAsset("@pipelab/ui", "latest", { context });
104134
+ rawAssetFolder = await fetchPipelabAsset("@pipelab/ui", releaseTag, { context });
104128
104135
  const server = http.createServer(async (request, response) => {
104129
104136
  if (!rawAssetFolder || !existsSync(rawAssetFolder)) {
104130
104137
  response.writeHead(404, { "Content-Type": "text/plain" });
@@ -104539,7 +104546,7 @@ const DEFAULT_PLUGIN_IDS = [
104539
104546
  ];
104540
104547
  const loadPipelabPlugin = async (id, options) => {
104541
104548
  try {
104542
- const { packageDir, entryPoint } = await fetchPipelabPlugin(`@pipelab/plugin-${id}`, "latest", {
104549
+ const { packageDir, entryPoint } = await fetchPipelabPlugin(`@pipelab/plugin-${id}`, options.context.releaseTag, {
104543
104550
  context: options.context,
104544
104551
  installDeps: false
104545
104552
  });
@@ -104564,9 +104571,9 @@ const builtInPlugins = async (options) => {
104564
104571
  console.log("[Plugins] Starting background plugin loading...");
104565
104572
  sendStartupProgress("Preparing environment...");
104566
104573
  await Promise.all([ensureNodeJS(options.context), ensurePNPM(options.context)]);
104567
- const { usePlugins } = await import("./src-DRN4ghka.mjs");
104574
+ const { usePlugins } = await import("./src-7LlbJymi.mjs");
104568
104575
  const { registerPlugins } = usePlugins();
104569
- const { webSocketServer } = await import("./src-5OM24-S2.mjs");
104576
+ const { webSocketServer } = await import("./src-n8V4fRSD.mjs");
104570
104577
  Promise.allSettled(DEFAULT_PLUGIN_IDS.map(async (id) => {
104571
104578
  sendStartupProgress(`Loading plugin: ${id}`);
104572
104579
  const plugin = await loadPipelabPlugin(id, options);
@@ -105574,6 +105581,14 @@ async function runPipelineCommand(file, options, version) {
105574
105581
  }
105575
105582
  }
105576
105583
  //#endregion
105584
+ //#region package.json
105585
+ var version$2 = "2.0.0-beta.4";
105586
+ //#endregion
105587
+ //#region src/paths.ts
105588
+ const getDefaultUserDataPath = () => {
105589
+ return getDefaultUserDataPath$1(version$2.includes("beta") ? "beta" : "prod");
105590
+ };
105591
+ //#endregion
105577
105592
  //#region src/commands/history.ts
105578
105593
  async function historyCommand(pipelineId, options) {
105579
105594
  const storage = new BuildHistoryStorage(new PipelabContext({ userDataPath: options.userData || getDefaultUserDataPath() }));
@@ -113620,4 +113635,4 @@ program.hook("postAction", (thisCommand) => {
113620
113635
  program.parse(process.argv);
113621
113636
  if (!process.argv.slice(2).length) program.outputHelp();
113622
113637
  //#endregion
113623
- export { extractTarGz as A, getDefaultUserDataPath as B, registerHistoryHandlers as C, setupConfigFile as D, getMigrator as E, registerShellHandlers as F, WebSocketServer as I, webSocketServer as L, generateTempFolder as M, getFolderSize as N, downloadFile as O, registerFsHandlers as P, useAPI as R, registerMigrationHandlers as S, registerConfigHandlers as T, projectRoot as V, fetchPipelabPlugin as _, executeGraphWithHistory as a, sendStartupReady as b, loadPipelabPlugin as c, DEFAULT_NODE_VERSION as d, DEFAULT_PNPM_VERSION as f, fetchPipelabAsset as g, fetchPackage as h, registerEngineHandlers as i, extractZip as j, ensure as k, handleActionExecute as l, ensurePNPM as m, registerAllHandlers as n, getFinalPlugins as o, ensureNodeJS as p, registerAgentsHandlers as r, builtInPlugins as s, runPipelineCommand as t, handleConditionExecute as u, runPnpm as v, BuildHistoryStorage as w, serveCommand as x, sendStartupProgress as y, PipelabContext as z };
113638
+ export { extractTarGz as A, getDefaultUserDataPath$1 as B, registerHistoryHandlers as C, setupConfigFile as D, getMigrator as E, registerShellHandlers as F, WebSocketServer as I, webSocketServer as L, generateTempFolder as M, getFolderSize as N, downloadFile as O, registerFsHandlers as P, useAPI as R, registerMigrationHandlers as S, registerConfigHandlers as T, projectRoot as V, fetchPipelabPlugin as _, executeGraphWithHistory as a, sendStartupReady as b, loadPipelabPlugin as c, DEFAULT_NODE_VERSION as d, DEFAULT_PNPM_VERSION as f, fetchPipelabAsset as g, fetchPackage as h, registerEngineHandlers as i, extractZip as j, ensure as k, handleActionExecute as l, ensurePNPM as m, registerAllHandlers as n, getFinalPlugins as o, ensureNodeJS as p, registerAgentsHandlers as r, builtInPlugins as s, runPipelineCommand as t, handleConditionExecute as u, runPnpm as v, BuildHistoryStorage as w, serveCommand as x, sendStartupProgress as y, PipelabContext as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipelab/cli",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.4",
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 { g as usePlugins } from "./src-CksaCAal.mjs";
2
+ import "./dist-BC_B45iu.mjs";
3
+ export { usePlugins };
@@ -4,24 +4,16 @@ import { hostname } from "os";
4
4
  import { normalize } from "path";
5
5
  import { formatWithOptions, types } from "util";
6
6
  //#region ../../packages/migration/src/models/createMigration.ts
7
- function createMigration(migration) {
7
+ function createMigration$1(migration) {
8
8
  return {
9
9
  version: migration.version,
10
10
  up: async (state, nextVersion) => {
11
- const newState = await migration.up(state, nextVersion);
12
- newState.version = nextVersion;
13
- return newState;
14
- },
15
- down: async (state, nextVersion) => {
16
- const newState = await migration.down(state, nextVersion);
11
+ const newState = migration.up ? await migration.up(state, nextVersion) : state;
17
12
  newState.version = nextVersion;
18
13
  return newState;
19
14
  }
20
15
  };
21
16
  }
22
- const initialVersion = () => {
23
- throw new Error("Unable to go down on the initial version!");
24
- };
25
17
  const finalVersion = () => {
26
18
  throw new Error("Unable to go up on the final version!");
27
19
  };
@@ -1945,20 +1937,19 @@ var Migrator = class {
1945
1937
  if (currentIndex === -1) throw new Error(`Current version "${currentVersion}" not found in migrations`);
1946
1938
  if (targetIndex === -1) throw new Error(`Target version "${targetVersion}" not found in migrations`);
1947
1939
  if (currentIndex === targetIndex) return finalState;
1948
- const isUpgrade = currentIndex < targetIndex;
1949
- const increment = isUpgrade ? 1 : -1;
1950
- const direction = isUpgrade ? "up" : "down";
1951
- for (let i = currentIndex; isUpgrade ? i < targetIndex : i > targetIndex; i += increment) {
1940
+ if (!(currentIndex < targetIndex)) return finalState;
1941
+ for (let i = currentIndex; i < targetIndex; i++) {
1952
1942
  const currentVersion = versions[i];
1953
- const nextVersion = versions[i + increment];
1943
+ const nextVersion = versions[i + 1];
1954
1944
  if (options?.debug) console.log(" Migrating to version:", nextVersion);
1955
1945
  const migrationVersion = currentVersion;
1956
1946
  const migration = this.migrations[migrationVersion];
1957
1947
  const { version: _, ...stateWithoutVersion } = finalState;
1958
1948
  finalState = {
1959
- ...await migration[direction](stateWithoutVersion, currentVersion),
1949
+ ...await migration.up(stateWithoutVersion, currentVersion),
1960
1950
  version: nextVersion
1961
1951
  };
1952
+ if (options?.onStep) await options.onStep(finalState, nextVersion);
1962
1953
  if (options?.debug) console.log(" Migrated state:", finalState);
1963
1954
  }
1964
1955
  return finalState;
@@ -1985,10 +1976,9 @@ const createMigrator = () => {
1985
1976
  };
1986
1977
  //#endregion
1987
1978
  //#region ../../packages/shared/src/config/migrators.ts
1979
+ const createMigration = (config) => createMigration$1(config);
1988
1980
  const settingsMigratorInternal = createMigrator();
1989
1981
  const defaultAppSettings = settingsMigratorInternal.createDefault({
1990
- cacheFolder: "",
1991
- clearTemporaryFoldersOnPipelineEnd: false,
1992
1982
  locale: "en-US",
1993
1983
  theme: "light",
1994
1984
  version: "7.0.0",
@@ -2003,15 +1993,19 @@ const defaultAppSettings = settingsMigratorInternal.createDefault({
2003
1993
  step: 0,
2004
1994
  completed: false
2005
1995
  }
2006
- }
1996
+ },
1997
+ buildHistory: { retentionPolicy: {
1998
+ enabled: false,
1999
+ maxEntries: 50,
2000
+ maxAge: 30
2001
+ } }
2007
2002
  });
2008
2003
  const appSettingsMigrator$1 = settingsMigratorInternal.createMigrations({
2009
2004
  defaultValue: defaultAppSettings,
2010
2005
  migrations: [
2011
2006
  createMigration({
2012
2007
  version: "1.0.0",
2013
- up: (state) => state,
2014
- down: initialVersion
2008
+ up: (state) => state
2015
2009
  }),
2016
2010
  createMigration({
2017
2011
  version: "2.0.0",
@@ -2020,9 +2014,6 @@ const appSettingsMigrator$1 = settingsMigratorInternal.createMigrations({
2020
2014
  ...state,
2021
2015
  clearTemporaryFoldersOnPipelineEnd: false
2022
2016
  };
2023
- },
2024
- down: () => {
2025
- throw new Error("Can't migrate down from 2.0.0");
2026
2017
  }
2027
2018
  }),
2028
2019
  createMigration({
@@ -2030,11 +2021,7 @@ const appSettingsMigrator$1 = settingsMigratorInternal.createMigrations({
2030
2021
  up: (state) => ({
2031
2022
  ...state,
2032
2023
  locale: "en-US"
2033
- }),
2034
- down: (state) => {
2035
- const { locale, ...rest } = state;
2036
- return rest;
2037
- }
2024
+ })
2038
2025
  }),
2039
2026
  createMigration({
2040
2027
  version: "4.0.0",
@@ -2050,40 +2037,32 @@ const appSettingsMigrator$1 = settingsMigratorInternal.createMigrations({
2050
2037
  completed: false
2051
2038
  }
2052
2039
  }
2053
- }),
2054
- down: (state) => {
2055
- const { tours, ...rest } = state;
2056
- return rest;
2057
- }
2040
+ })
2058
2041
  }),
2059
2042
  createMigration({
2060
2043
  version: "5.0.0",
2061
2044
  up: (state) => ({
2062
2045
  ...state,
2063
2046
  autosave: true
2064
- }),
2065
- down: (state) => {
2066
- const { autosave, ...rest } = state;
2067
- return rest;
2068
- }
2047
+ })
2069
2048
  }),
2070
2049
  createMigration({
2071
2050
  version: "6.0.0",
2072
- up: (state) => ({
2073
- ...state,
2074
- agents: []
2075
- }),
2076
- down: (state) => {
2077
- const { agents, ...rest } = state;
2078
- return rest;
2051
+ up: (state) => {
2052
+ return {
2053
+ ...state,
2054
+ agents: [],
2055
+ buildHistory: { retentionPolicy: {
2056
+ enabled: false,
2057
+ maxEntries: 50,
2058
+ maxAge: 30
2059
+ } }
2060
+ };
2079
2061
  }
2080
2062
  }),
2081
2063
  createMigration({
2082
2064
  version: "7.0.0",
2083
- up: finalVersion,
2084
- down: () => {
2085
- throw new Error("Can't migrate down from 7.0.0");
2086
- }
2065
+ up: finalVersion
2087
2066
  })
2088
2067
  ]
2089
2068
  });
@@ -2095,38 +2074,33 @@ const defaultFileRepo = fileRepoMigratorInternal.createDefault({
2095
2074
  name: "Default project",
2096
2075
  description: "The initial default project"
2097
2076
  }],
2098
- pipelines: [],
2099
- proxies: []
2077
+ pipelines: []
2100
2078
  });
2101
2079
  const fileRepoMigrations$1 = fileRepoMigratorInternal.createMigrations({
2102
2080
  defaultValue: defaultFileRepo,
2103
2081
  migrations: [createMigration({
2104
2082
  version: "1.0.0",
2105
2083
  up: (state) => {
2084
+ const pipelines = Object.entries(state.data || {}).map(([id, file]) => {
2085
+ return {
2086
+ ...file,
2087
+ id,
2088
+ project: "main"
2089
+ };
2090
+ });
2106
2091
  return {
2107
- version: "2.0.0",
2092
+ ...state,
2108
2093
  projects: [{
2109
2094
  id: "main",
2110
2095
  name: "Default project",
2111
2096
  description: "The initial default project"
2112
2097
  }],
2113
- pipelines: Object.entries(state.data || {}).map(([id, file]) => {
2114
- return {
2115
- ...file,
2116
- id,
2117
- project: "main"
2118
- };
2119
- }),
2120
- proxies: []
2098
+ pipelines
2121
2099
  };
2122
- },
2123
- down: initialVersion
2100
+ }
2124
2101
  }), createMigration({
2125
2102
  version: "2.0.0",
2126
- up: finalVersion,
2127
- down: (state) => {
2128
- throw new Error("Cannot downgrade to version 1.0.0");
2129
- }
2103
+ up: finalVersion
2130
2104
  })]
2131
2105
  });
2132
2106
  const savedFileMigratorInternal = createMigrator();
@@ -2153,21 +2127,19 @@ const savedFileMigrator$1 = savedFileMigratorInternal.createMigrations({
2153
2127
  for (const block of blocks) if (block.type === "event") triggers.push(block);
2154
2128
  else newBlocks.push(block);
2155
2129
  return {
2130
+ ...state,
2156
2131
  canvas: {
2132
+ ...state.canvas,
2157
2133
  blocks: newBlocks,
2158
2134
  triggers
2159
- },
2160
- description: state.description,
2161
- name: state.name,
2162
- variables: state.variables
2135
+ }
2163
2136
  };
2164
- },
2165
- down: initialVersion
2137
+ }
2166
2138
  }),
2167
2139
  createMigration({
2168
2140
  version: "2.0.0",
2169
2141
  up: (state) => {
2170
- const { canvas, ...rest } = state;
2142
+ const { canvas } = state;
2171
2143
  const { blocks, triggers } = canvas;
2172
2144
  const newBlocks = [];
2173
2145
  for (const block of blocks) {
@@ -2186,35 +2158,25 @@ const savedFileMigrator$1 = savedFileMigratorInternal.createMigrations({
2186
2158
  });
2187
2159
  }
2188
2160
  return {
2189
- ...rest,
2161
+ ...state,
2190
2162
  canvas: {
2163
+ ...canvas,
2191
2164
  triggers,
2192
2165
  blocks: newBlocks
2193
2166
  }
2194
2167
  };
2195
- },
2196
- down: () => {
2197
- throw new Error("Migration down not implemented");
2198
2168
  }
2199
2169
  }),
2200
2170
  createMigration({
2201
2171
  version: "3.0.0",
2202
- up: (state) => {
2203
- return {
2204
- ...state,
2205
- type: "default"
2206
- };
2207
- },
2208
- down: () => {
2209
- throw new Error("Migration down not implemented");
2210
- }
2172
+ up: (state) => ({
2173
+ ...state,
2174
+ type: "default"
2175
+ })
2211
2176
  }),
2212
2177
  createMigration({
2213
2178
  version: "4.0.0",
2214
- up: finalVersion,
2215
- down: () => {
2216
- throw new Error("Migration down not implemented");
2217
- }
2179
+ up: finalVersion
2218
2180
  })
2219
2181
  ]
2220
2182
  });
@@ -1,4 +1,4 @@
1
- import "./src-B7Er1YgO.mjs";
1
+ import "./src-CksaCAal.mjs";
2
2
  import "./dist-BC_B45iu.mjs";
3
3
  import { L as webSocketServer } from "./index.mjs";
4
4
  export { webSocketServer };
package/src-DRN4ghka.mjs DELETED
@@ -1,3 +0,0 @@
1
- import { g as usePlugins } from "./src-B7Er1YgO.mjs";
2
- import "./dist-BC_B45iu.mjs";
3
- export { usePlugins };