@pipelab/core-node 1.0.0-beta.22 → 1.0.0-beta.25
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 +27 -0
- package/dist/config-CFgGRD9U.mjs.map +1 -1
- package/dist/index.d.mts +24 -17
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +144 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/config.test.ts +1 -4
- package/src/config.ts +11 -3
- package/src/context.ts +31 -16
- package/src/fs-utils.test.ts +125 -0
- package/src/fs-utils.ts +142 -0
- package/src/handler-func.ts +15 -2
- package/src/handlers/config.ts +60 -15
- package/src/handlers/fs.ts +25 -0
- package/src/handlers/migration.ts +31 -6
- package/src/index.ts +1 -0
- package/src/server.ts +3 -2
package/src/handlers/fs.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { useAPI } from "../ipc-core";
|
|
|
2
2
|
import { useLogger } from "@pipelab/shared";
|
|
3
3
|
import { writeFile, readFile, readdir, stat } from "node:fs/promises";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
+
import { isPathBlacklisted } from "../fs-utils";
|
|
5
6
|
|
|
6
7
|
import { PipelabContext } from "../context";
|
|
7
8
|
|
|
@@ -94,4 +95,28 @@ export const registerFsHandlers = (_context: PipelabContext) => {
|
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
97
|
});
|
|
98
|
+
|
|
99
|
+
handle("fs:isPathBlacklisted", async (event, { value, send }) => {
|
|
100
|
+
try {
|
|
101
|
+
const isBlacklisted = isPathBlacklisted(value.path);
|
|
102
|
+
send({
|
|
103
|
+
type: "end",
|
|
104
|
+
data: {
|
|
105
|
+
type: "success",
|
|
106
|
+
result: {
|
|
107
|
+
isBlacklisted,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
} catch (error) {
|
|
112
|
+
logger().error("Failed to check blacklist for path:", error);
|
|
113
|
+
send({
|
|
114
|
+
type: "end",
|
|
115
|
+
data: {
|
|
116
|
+
type: "error",
|
|
117
|
+
ipcError: error instanceof Error ? error.message : "Unable to check path blacklist",
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
97
122
|
};
|
|
@@ -4,7 +4,13 @@ import { PipelabContext, getDefaultUserDataPath, isDev, PipelabEnv } from "../co
|
|
|
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 {
|
|
7
|
+
import {
|
|
8
|
+
FileRepo,
|
|
9
|
+
SaveLocation,
|
|
10
|
+
AppConfig,
|
|
11
|
+
ConnectionsConfig,
|
|
12
|
+
savedFileMigrator,
|
|
13
|
+
} from "@pipelab/shared";
|
|
8
14
|
import semver from "semver";
|
|
9
15
|
|
|
10
16
|
interface MigrationPipelineItem {
|
|
@@ -94,7 +100,11 @@ export const registerMigrationHandlers = (context: PipelabContext) => {
|
|
|
94
100
|
type: "success",
|
|
95
101
|
result: {
|
|
96
102
|
sourceChannel: sourceEnv === "prod" ? "Stable" : "Beta",
|
|
97
|
-
targetChannel: isDev
|
|
103
|
+
targetChannel: isDev
|
|
104
|
+
? "Dev"
|
|
105
|
+
: context.userDataPath.endsWith("app") || !context.userDataPath.includes("app-beta")
|
|
106
|
+
? "Stable"
|
|
107
|
+
: "Beta",
|
|
98
108
|
settingsExists: false,
|
|
99
109
|
settingsVersion: null,
|
|
100
110
|
settingsVersionTarget: null,
|
|
@@ -258,7 +268,11 @@ export const registerMigrationHandlers = (context: PipelabContext) => {
|
|
|
258
268
|
type: "success",
|
|
259
269
|
result: {
|
|
260
270
|
sourceChannel: sourceEnv === "prod" ? "Stable" : "Beta",
|
|
261
|
-
targetChannel: isDev
|
|
271
|
+
targetChannel: isDev
|
|
272
|
+
? "Dev"
|
|
273
|
+
: context.userDataPath.endsWith("app") || !context.userDataPath.includes("app-beta")
|
|
274
|
+
? "Stable"
|
|
275
|
+
: "Beta",
|
|
262
276
|
settingsExists,
|
|
263
277
|
settingsVersion,
|
|
264
278
|
settingsVersionTarget: targetSettingsMeta.version,
|
|
@@ -297,7 +311,13 @@ export const registerMigrationHandlers = (context: PipelabContext) => {
|
|
|
297
311
|
handle("migration:perform", async (_, { send, value }) => {
|
|
298
312
|
logger().info("[Migration] Performing migration...");
|
|
299
313
|
try {
|
|
300
|
-
const {
|
|
314
|
+
const {
|
|
315
|
+
migrateSettings,
|
|
316
|
+
migrateConnections,
|
|
317
|
+
selectedProjects,
|
|
318
|
+
selectedPipelines,
|
|
319
|
+
sourceChannel,
|
|
320
|
+
} = value;
|
|
301
321
|
|
|
302
322
|
let sourceEnv: PipelabEnv = "prod";
|
|
303
323
|
if (sourceChannel === "stable") {
|
|
@@ -566,10 +586,15 @@ export const registerMigrationHandlers = (context: PipelabContext) => {
|
|
|
566
586
|
const rawJson = JSON.parse(pipeContent);
|
|
567
587
|
const migratedJson = await savedFileMigrator.migrate(rawJson);
|
|
568
588
|
await fs.writeFile(betaPipeFile, JSON.stringify(migratedJson, null, 2));
|
|
569
|
-
logger().info(
|
|
589
|
+
logger().info(
|
|
590
|
+
`[Migration] Migrated and copied pipeline file: ${stablePipe.configName}`,
|
|
591
|
+
);
|
|
570
592
|
} catch (err) {
|
|
571
593
|
await fs.copyFile(stablePipeFile, betaPipeFile);
|
|
572
|
-
logger().error(
|
|
594
|
+
logger().error(
|
|
595
|
+
`[Migration] Error migrating during copy of ${stablePipe.configName}, fallback to direct copy:`,
|
|
596
|
+
err,
|
|
597
|
+
);
|
|
573
598
|
}
|
|
574
599
|
}
|
|
575
600
|
}
|
package/src/index.ts
CHANGED
package/src/server.ts
CHANGED
|
@@ -50,9 +50,10 @@ export async function serveCommand(options: ServeOptions, version: string, _dirn
|
|
|
50
50
|
|
|
51
51
|
const server = http.createServer(async (request, response) => {
|
|
52
52
|
// Serve local media files securely via HTTP
|
|
53
|
-
|
|
53
|
+
const urlObj = request.url ? new URL(request.url, "http://localhost") : null;
|
|
54
|
+
if (urlObj && urlObj.pathname.startsWith("/media-file/")) {
|
|
54
55
|
const prefix = "/media-file/";
|
|
55
|
-
const encodedPath =
|
|
56
|
+
const encodedPath = urlObj.pathname.substring(prefix.length);
|
|
56
57
|
const filePath = decodeURIComponent(encodedPath);
|
|
57
58
|
// Strip leading slash on Windows if followed by a drive letter (e.g. /C:/...)
|
|
58
59
|
const normalizedPath =
|