@pipelab/core-node 1.0.0-beta.2 → 1.0.0-beta.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipelab/core-node",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.5",
4
4
  "private": false,
5
5
  "description": "The Pipelab automation engine for Node.js",
6
6
  "license": "FSL-1.1-MIT",
@@ -40,8 +40,8 @@
40
40
  "type-fest": "4.39.0",
41
41
  "ws": "8.18.3",
42
42
  "yauzl": "2.10.0",
43
- "@pipelab/constants": "1.0.0-beta.1",
44
- "@pipelab/shared": "1.0.0-beta.1"
43
+ "@pipelab/constants": "1.0.0-beta.4",
44
+ "@pipelab/shared": "1.0.0-beta.3"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/adm-zip": "0.5.7",
@@ -54,7 +54,7 @@
54
54
  "@types/yauzl": "2.10.3",
55
55
  "tsdown": "0.21.2",
56
56
  "typescript": "^5.0.0",
57
- "@pipelab/tsconfig": "1.0.0-beta.1"
57
+ "@pipelab/tsconfig": "1.0.0-beta.3"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "tsdown",
package/src/config.ts CHANGED
@@ -66,6 +66,16 @@ export const setupConfigFile = async <T>(
66
66
  try {
67
67
  json = await migrator.migrate(originalJson, {
68
68
  debug: false,
69
+ onStep: async (state: any, version: string) => {
70
+ const parsedPath = path.parse(filesPath);
71
+ const versionedPath = path.join(parsedPath.dir, `${parsedPath.name}.v${version}.json`);
72
+ try {
73
+ await fs.writeFile(versionedPath, JSON.stringify(state));
74
+ logger().info(`Intermediate backup created for ${name} at ${versionedPath}`);
75
+ } catch (e) {
76
+ logger().error(`Failed to create intermediate backup for ${name} at v${version}:`, e);
77
+ }
78
+ },
69
79
  });
70
80
  } catch (e) {
71
81
  logger().error(`Error migrating config ${name}:`, e);
@@ -75,21 +85,6 @@ export const setupConfigFile = async <T>(
75
85
  const originalVersion = originalJson?.version;
76
86
  const newVersion = json?.version;
77
87
 
78
- // Check if migration actually changed the version
79
- if (originalVersion !== newVersion && content !== undefined) {
80
- // Backup previous file before overwriting
81
- const parsedPath = path.parse(filesPath);
82
- const versionSuffix = originalVersion || "unknown";
83
- const backupPath = path.join(parsedPath.dir, `${parsedPath.name}.${versionSuffix}.bak`);
84
-
85
- try {
86
- await fs.copyFile(filesPath, backupPath);
87
- logger().info(`Backup created for ${name} at ${backupPath} (version ${versionSuffix})`);
88
- } catch (e) {
89
- logger().error(`Failed to create backup for ${name}:`, e);
90
- }
91
- }
92
-
93
88
  // Save back migrated config if changed or if it's a new file
94
89
  if (originalVersion !== newVersion || content === undefined) {
95
90
  try {
package/src/context.ts CHANGED
@@ -12,7 +12,7 @@ const _dirname =
12
12
 
13
13
  export const isDev = process.env.NODE_ENV === "development";
14
14
 
15
- export const getDefaultUserDataPath = () => {
15
+ export const getDefaultUserDataPath = (env?: "dev" | "beta" | "prod") => {
16
16
  const base = (() => {
17
17
  switch (platform()) {
18
18
  case "win32":
@@ -24,7 +24,10 @@ export const getDefaultUserDataPath = () => {
24
24
  }
25
25
  })();
26
26
 
27
- return join(base, "@pipelab", isDev ? "app-dev" : "app");
27
+ const mode = env ?? (isDev ? "dev" : "prod");
28
+ const folder = mode === "dev" ? "app-dev" : mode === "beta" ? "app-beta" : "app";
29
+
30
+ return join(base, "@pipelab", folder);
28
31
  };
29
32
 
30
33
  /**
@@ -45,13 +48,16 @@ export const projectRoot = findProjectRoot(_dirname);
45
48
 
46
49
  export interface PipelabContextOptions {
47
50
  userDataPath: string;
51
+ releaseTag?: string;
48
52
  }
49
53
 
50
54
  export class PipelabContext {
51
55
  public readonly userDataPath: string;
56
+ public readonly releaseTag: string;
52
57
 
53
58
  constructor(options: PipelabContextOptions) {
54
59
  this.userDataPath = options.userDataPath;
60
+ this.releaseTag = options.releaseTag || "latest";
55
61
  }
56
62
 
57
63
  getPackagesPath(...subpaths: string[]) {
@@ -23,7 +23,7 @@ const DEFAULT_PLUGIN_IDS = [
23
23
  export const loadPipelabPlugin = async (id: string, options: { context: PipelabContext }) => {
24
24
  try {
25
25
  const packageName = `@pipelab/plugin-${id}`;
26
- const { packageDir, entryPoint } = await fetchPipelabPlugin(packageName, "latest", {
26
+ const { packageDir, entryPoint } = await fetchPipelabPlugin(packageName, options.context.releaseTag, {
27
27
  context: options.context,
28
28
  installDeps: false,
29
29
  });
package/src/server.ts CHANGED
@@ -38,13 +38,15 @@ export const sendStartupReady = () => {
38
38
 
39
39
  export async function serveCommand(options: ServeOptions, version: string, _dirname: string) {
40
40
  if (!options.userData) throw new Error("userDataPath is required for serveCommand");
41
+ const releaseTag = version.includes("beta") ? "beta" : "latest";
41
42
  const context = new PipelabContext({
42
43
  userDataPath: options.userData,
44
+ releaseTag,
43
45
  });
44
46
 
45
47
  let rawAssetFolder: string | undefined;
46
48
  if (!isDev) {
47
- rawAssetFolder = await fetchPipelabAsset("@pipelab/ui", "latest", { context });
49
+ rawAssetFolder = await fetchPipelabAsset("@pipelab/ui", releaseTag, { context });
48
50
  }
49
51
 
50
52
  const server = http.createServer(async (request, response) => {