@pipelab/core-node 1.0.0-beta.19 → 1.0.0-beta.21
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/CHANGELOG.md +18 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +31 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/context.ts +3 -1
- package/src/handlers/migration.ts +42 -19
- package/src/handlers/system.ts +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipelab/core-node",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.21",
|
|
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.
|
|
44
|
-
"@pipelab/shared": "1.0.0-beta.
|
|
43
|
+
"@pipelab/constants": "1.0.0-beta.19",
|
|
44
|
+
"@pipelab/shared": "1.0.0-beta.17"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/adm-zip": "0.5.7",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"tsdown": "0.21.2",
|
|
57
57
|
"typescript": "^5.0.0",
|
|
58
58
|
"vitest": "3.1.4",
|
|
59
|
-
"@pipelab/tsconfig": "1.0.0-beta.
|
|
59
|
+
"@pipelab/tsconfig": "1.0.0-beta.17"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsdown",
|
package/src/context.ts
CHANGED
|
@@ -17,7 +17,9 @@ const _dirname =
|
|
|
17
17
|
|
|
18
18
|
export const isDev = process.env.NODE_ENV === "development";
|
|
19
19
|
|
|
20
|
-
export
|
|
20
|
+
export type PipelabEnv = "dev" | "beta" | "prod";
|
|
21
|
+
|
|
22
|
+
export const getDefaultUserDataPath = (env?: PipelabEnv) => {
|
|
21
23
|
const base = (() => {
|
|
22
24
|
switch (platform()) {
|
|
23
25
|
case "win32":
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useAPI } from "../ipc-core";
|
|
2
2
|
import { useLogger } from "@pipelab/shared";
|
|
3
|
-
import { PipelabContext, getDefaultUserDataPath } from "../context";
|
|
3
|
+
import { PipelabContext, getDefaultUserDataPath, isDev, PipelabEnv } from "../context";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { join, dirname } from "node:path";
|
|
7
|
-
import { FileRepo, SaveLocation, AppConfig, ConnectionsConfig } from "@pipelab/shared";
|
|
7
|
+
import { FileRepo, SaveLocation, AppConfig, ConnectionsConfig, savedFileMigrator } from "@pipelab/shared";
|
|
8
8
|
import semver from "semver";
|
|
9
9
|
|
|
10
10
|
interface MigrationPipelineItem {
|
|
@@ -70,12 +70,19 @@ export const registerMigrationHandlers = (context: PipelabContext) => {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
handle("migration:scan-stable", async (_, { send }) => {
|
|
73
|
+
handle("migration:scan-stable", async (_, { send, value }) => {
|
|
74
74
|
logger().info("[Migration] Scanning other channel database...");
|
|
75
75
|
try {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
let sourceEnv: PipelabEnv = "prod";
|
|
77
|
+
if (value?.sourceChannel === "stable") {
|
|
78
|
+
sourceEnv = "prod";
|
|
79
|
+
} else if (value?.sourceChannel === "beta") {
|
|
80
|
+
sourceEnv = "beta";
|
|
81
|
+
} else {
|
|
82
|
+
const isStable =
|
|
83
|
+
context.userDataPath.endsWith("app") || !context.userDataPath.includes("app-beta");
|
|
84
|
+
sourceEnv = isStable ? "beta" : "prod";
|
|
85
|
+
}
|
|
79
86
|
const sourcePath = getDefaultUserDataPath(sourceEnv);
|
|
80
87
|
const targetPath = context.userDataPath;
|
|
81
88
|
|
|
@@ -86,8 +93,8 @@ export const registerMigrationHandlers = (context: PipelabContext) => {
|
|
|
86
93
|
data: {
|
|
87
94
|
type: "success",
|
|
88
95
|
result: {
|
|
89
|
-
sourceChannel:
|
|
90
|
-
targetChannel:
|
|
96
|
+
sourceChannel: sourceEnv === "prod" ? "Stable" : "Beta",
|
|
97
|
+
targetChannel: isDev ? "Dev" : (context.userDataPath.endsWith("app") || !context.userDataPath.includes("app-beta") ? "Stable" : "Beta"),
|
|
91
98
|
settingsExists: false,
|
|
92
99
|
settingsVersion: null,
|
|
93
100
|
settingsVersionTarget: null,
|
|
@@ -207,7 +214,8 @@ export const registerMigrationHandlers = (context: PipelabContext) => {
|
|
|
207
214
|
try {
|
|
208
215
|
if (existsSync(sourcePipeFile)) {
|
|
209
216
|
const pipeContent = await fs.readFile(sourcePipeFile, "utf8");
|
|
210
|
-
const
|
|
217
|
+
const rawJson = JSON.parse(pipeContent);
|
|
218
|
+
const pipeJson = await savedFileMigrator.migrate(rawJson);
|
|
211
219
|
pipeName = pipeJson.name || pipeName;
|
|
212
220
|
pipeDesc = pipeJson.description || pipeDesc;
|
|
213
221
|
}
|
|
@@ -249,8 +257,8 @@ export const registerMigrationHandlers = (context: PipelabContext) => {
|
|
|
249
257
|
data: {
|
|
250
258
|
type: "success",
|
|
251
259
|
result: {
|
|
252
|
-
sourceChannel:
|
|
253
|
-
targetChannel:
|
|
260
|
+
sourceChannel: sourceEnv === "prod" ? "Stable" : "Beta",
|
|
261
|
+
targetChannel: isDev ? "Dev" : (context.userDataPath.endsWith("app") || !context.userDataPath.includes("app-beta") ? "Stable" : "Beta"),
|
|
254
262
|
settingsExists,
|
|
255
263
|
settingsVersion,
|
|
256
264
|
settingsVersionTarget: targetSettingsMeta.version,
|
|
@@ -289,11 +297,18 @@ export const registerMigrationHandlers = (context: PipelabContext) => {
|
|
|
289
297
|
handle("migration:perform", async (_, { send, value }) => {
|
|
290
298
|
logger().info("[Migration] Performing migration...");
|
|
291
299
|
try {
|
|
292
|
-
const { migrateSettings, migrateConnections, selectedProjects, selectedPipelines } = value;
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
300
|
+
const { migrateSettings, migrateConnections, selectedProjects, selectedPipelines, sourceChannel } = value;
|
|
301
|
+
|
|
302
|
+
let sourceEnv: PipelabEnv = "prod";
|
|
303
|
+
if (sourceChannel === "stable") {
|
|
304
|
+
sourceEnv = "prod";
|
|
305
|
+
} else if (sourceChannel === "beta") {
|
|
306
|
+
sourceEnv = "beta";
|
|
307
|
+
} else {
|
|
308
|
+
const isStable =
|
|
309
|
+
context.userDataPath.endsWith("app") || !context.userDataPath.includes("app-beta");
|
|
310
|
+
sourceEnv = isStable ? "beta" : "prod";
|
|
311
|
+
}
|
|
297
312
|
const sourcePath = getDefaultUserDataPath(sourceEnv);
|
|
298
313
|
const sourceContext = new PipelabContext({ userDataPath: sourcePath, releaseTag: sourceEnv });
|
|
299
314
|
|
|
@@ -540,14 +555,22 @@ export const registerMigrationHandlers = (context: PipelabContext) => {
|
|
|
540
555
|
}
|
|
541
556
|
}
|
|
542
557
|
|
|
543
|
-
// Copy pipeline file if internal
|
|
558
|
+
// Copy and migrate pipeline file if internal
|
|
544
559
|
if (stablePipe.type === "internal") {
|
|
545
560
|
const stablePipeFile = sourceContext.getConfigPath(`${stablePipe.configName}.json`);
|
|
546
561
|
const betaPipeFile = context.getConfigPath(`${stablePipe.configName}.json`);
|
|
547
562
|
if (existsSync(stablePipeFile)) {
|
|
548
563
|
await fs.mkdir(dirname(betaPipeFile), { recursive: true });
|
|
549
|
-
|
|
550
|
-
|
|
564
|
+
try {
|
|
565
|
+
const pipeContent = await fs.readFile(stablePipeFile, "utf8");
|
|
566
|
+
const rawJson = JSON.parse(pipeContent);
|
|
567
|
+
const migratedJson = await savedFileMigrator.migrate(rawJson);
|
|
568
|
+
await fs.writeFile(betaPipeFile, JSON.stringify(migratedJson, null, 2));
|
|
569
|
+
logger().info(`[Migration] Migrated and copied pipeline file: ${stablePipe.configName}`);
|
|
570
|
+
} catch (err) {
|
|
571
|
+
await fs.copyFile(stablePipeFile, betaPipeFile);
|
|
572
|
+
logger().error(`[Migration] Error migrating during copy of ${stablePipe.configName}, fallback to direct copy:`, err);
|
|
573
|
+
}
|
|
551
574
|
}
|
|
552
575
|
}
|
|
553
576
|
|
package/src/handlers/system.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { useAPI } from "../ipc-core";
|
|
2
|
-
import { PipelabContext } from "../context";
|
|
2
|
+
import { PipelabContext, isDev } from "../context";
|
|
3
3
|
|
|
4
4
|
export const registerSystemHandlers = (options: { version: string; context: PipelabContext }) => {
|
|
5
5
|
const { handle } = useAPI();
|
|
6
6
|
|
|
7
7
|
handle("agent:version:get", async (_, { send }) => {
|
|
8
|
+
const isStable =
|
|
9
|
+
options.context.userDataPath.endsWith("app") ||
|
|
10
|
+
!options.context.userDataPath.includes("app-beta");
|
|
11
|
+
|
|
8
12
|
send({
|
|
9
13
|
type: "end",
|
|
10
14
|
data: {
|
|
11
15
|
type: "success",
|
|
12
16
|
result: {
|
|
13
|
-
version: options.version,
|
|
17
|
+
version: isDev ? "workspace" : options.version,
|
|
18
|
+
channel: isDev ? "dev" : isStable ? "stable" : "beta",
|
|
14
19
|
},
|
|
15
20
|
},
|
|
16
21
|
});
|