@pipelab/cli 2.0.0-beta.17 → 2.0.0-beta.19

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-CoHipk5y.mjs";
2
+ import "./dist-BC_B45iu.mjs";
3
+ import { c as setupSettingsConfigFile } from "./config-C4SmHbuE.mjs";
4
+ export { setupSettingsConfigFile };
@@ -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 { i as savedFileMigrator, n as connectionsMigrator, r as fileRepoMigrations, t as appSettingsMigrator, w as useLogger } from "./src-CoHipk5y.mjs";
3
3
  import path, { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { constants } from "node:os";
@@ -40327,14 +40327,10 @@ async function getFolderSize(dirPath) {
40327
40327
  }
40328
40328
  //#endregion
40329
40329
  //#region ../../packages/core-node/src/config.ts
40330
- const getMigrator = (name) => {
40331
- return configRegistry[name] || configRegistry["pipeline"];
40332
- };
40333
- const setupConfigFile = async (name, options) => {
40334
- const ctx = options.context;
40335
- const migrator = options.migrator || getMigrator(name);
40336
- if (!migrator) throw new Error(`No migrator found for configuration: ${name}. All managed files must have a migration schema.`);
40337
- const filesPath = path.isAbsolute(name) ? name : ctx.getConfigPath(`${name}.json`);
40330
+ const setupConfigFile = async (filesPath, options) => {
40331
+ options.context;
40332
+ const parsedPath = path.parse(filesPath);
40333
+ const migrator = options.migrator;
40338
40334
  await ensure(filesPath, JSON.stringify(migrator.defaultValue));
40339
40335
  return {
40340
40336
  setConfig: async (config) => {
@@ -40343,7 +40339,7 @@ const setupConfigFile = async (name, options) => {
40343
40339
  await fs$1.writeFile(filesPath, JSON.stringify(config));
40344
40340
  return true;
40345
40341
  } catch (e) {
40346
- logger().error(`Error saving config ${name}:`, e);
40342
+ logger().error(`Error saving config ${parsedPath.name}:`, e);
40347
40343
  return false;
40348
40344
  }
40349
40345
  },
@@ -40356,7 +40352,7 @@ const setupConfigFile = async (name, options) => {
40356
40352
  content = await fs$1.readFile(filesPath, "utf8");
40357
40353
  if (content !== void 0) originalJson = JSON.parse(content);
40358
40354
  } catch (e) {
40359
- logger().error(`Error reading or parsing config ${name}:`, e);
40355
+ logger().error(`Error reading or parsing config ${parsedPath.name}:`, e);
40360
40356
  parseFailed = true;
40361
40357
  }
40362
40358
  let json = void 0;
@@ -40365,44 +40361,79 @@ const setupConfigFile = async (name, options) => {
40365
40361
  if (!parseFailed) json = await migrator.migrate(originalJson, {
40366
40362
  debug: false,
40367
40363
  onStep: async (state, version) => {
40368
- const parsedPath = path.parse(filesPath);
40369
40364
  const versionedPath = path.join(parsedPath.dir, `${parsedPath.name}.v${version}.json`);
40370
40365
  try {
40371
40366
  await fs$1.writeFile(versionedPath, JSON.stringify(state));
40372
- logger().info(`Intermediate backup created for ${name} at ${versionedPath}`);
40367
+ logger().info(`Intermediate backup created for ${parsedPath.name} at ${versionedPath}`);
40373
40368
  } catch (e) {
40374
- logger().error(`Failed to create intermediate backup for ${name} at v${version}:`, e);
40369
+ logger().error(`Failed to create intermediate backup for ${parsedPath.name} at v${version}:`, e);
40375
40370
  }
40376
40371
  }
40377
40372
  });
40378
40373
  else json = migrator.defaultValue;
40379
40374
  } catch (e) {
40380
- logger().error(`Error migrating config ${name}:`, e);
40375
+ logger().error(`Error migrating config ${parsedPath.name}:`, e);
40381
40376
  migrationFailed = true;
40382
40377
  json = migrator.defaultValue;
40383
40378
  }
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) {
40379
+ if (originalJson?.version !== json?.version || content === void 0 || parseFailed || migrationFailed) {
40387
40380
  if (parseFailed || migrationFailed) try {
40388
- const parsedPath = path.parse(filesPath);
40389
40381
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
40390
40382
  const corruptedPath = path.join(parsedPath.dir, `${parsedPath.name}.corrupted.${timestamp}.json`);
40391
40383
  const backupContent = parseFailed ? content || "" : JSON.stringify(originalJson, null, 2);
40392
40384
  await fs$1.writeFile(corruptedPath, backupContent);
40393
40385
  logger().info(`Corrupted config file preserved at ${corruptedPath}`);
40394
40386
  } catch (e) {
40395
- logger().error(`Failed to backup corrupted config ${name}:`, e);
40387
+ logger().error(`Failed to backup corrupted config ${parsedPath.name}:`, e);
40396
40388
  }
40397
40389
  try {
40398
40390
  await fs$1.writeFile(filesPath, JSON.stringify(json));
40399
40391
  } catch (e) {
40400
- logger().error(`Error saving migrated config ${name}:`, e);
40392
+ logger().error(`Error saving migrated config ${parsedPath.name}:`, e);
40401
40393
  }
40402
40394
  }
40403
40395
  return json;
40404
40396
  }
40405
40397
  };
40406
40398
  };
40399
+ const setupSettingsConfigFile = (context) => {
40400
+ return setupConfigFile(context.getSettingsPath(), {
40401
+ context,
40402
+ migrator: appSettingsMigrator
40403
+ });
40404
+ };
40405
+ const setupConnectionsConfigFile = (context) => {
40406
+ return setupConfigFile(context.getConnectionsPath(), {
40407
+ context,
40408
+ migrator: connectionsMigrator
40409
+ });
40410
+ };
40411
+ const setupProjectsConfigFile = (context) => {
40412
+ return setupConfigFile(context.getProjectsPath(), {
40413
+ context,
40414
+ migrator: fileRepoMigrations
40415
+ });
40416
+ };
40417
+ const setupPipelineConfigFileByName = (name, context) => {
40418
+ return setupConfigFile(context.getConfigPath(`${name}.json`), {
40419
+ context,
40420
+ migrator: savedFileMigrator
40421
+ });
40422
+ };
40423
+ const setupPipelineConfigFileByPath = (absolutePath, context) => {
40424
+ return setupConfigFile(absolutePath, {
40425
+ context,
40426
+ migrator: savedFileMigrator
40427
+ });
40428
+ };
40429
+ const deleteConfigFile = async (filesPath) => {
40430
+ await fs$1.rm(filesPath, { force: true });
40431
+ };
40432
+ const deletePipelineConfigFileByName = async (name, context) => {
40433
+ await deleteConfigFile(context.getConfigPath(`${name}.json`));
40434
+ };
40435
+ const deletePipelineConfigFileByPath = async (absolutePath, context) => {
40436
+ await deleteConfigFile(absolutePath);
40437
+ };
40407
40438
  //#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 };
40439
+ export { setupPipelineConfigFileByName as a, setupSettingsConfigFile as c, extractTarGz as d, extractZip as f, execa as g, require_balanced_match as h, setupConnectionsConfigFile as i, downloadFile as l, require_commonjs$2 as m, deletePipelineConfigFileByPath as n, setupPipelineConfigFileByPath as o, getFolderSize as p, setupConfigFile as r, setupProjectsConfigFile as s, deletePipelineConfigFileByName as t, ensure as u };