@pipelab/core-node 1.0.0-beta.17 → 1.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.
- package/CHANGELOG.md +18 -0
- package/dist/config-Bi0ORcTK.mjs +2 -0
- package/dist/config-CFgGRD9U.mjs +265 -0
- package/dist/config-CFgGRD9U.mjs.map +1 -0
- package/dist/index.d.mts +39 -24
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +875 -427
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/config.test.ts +81 -25
- package/src/config.ts +79 -43
- package/src/context.ts +59 -4
- package/src/handlers/build-history.ts +47 -90
- package/src/handlers/config.ts +255 -94
- package/src/handlers/engine.ts +28 -24
- package/src/handlers/history.ts +0 -40
- package/src/handlers/index.ts +2 -0
- package/src/handlers/migration.ts +598 -0
- package/src/index.ts +9 -2
- package/src/plugins-registry.ts +17 -19
- package/src/runner.ts +2 -7
- package/src/server.ts +1 -3
- package/src/utils/github.test.ts +3 -5
- package/src/utils/remote.test.ts +15 -6
- package/src/utils/remote.ts +8 -5
- package/src/utils/storage.ts +2 -1
- package/src/utils.ts +8 -8
- package/dist/config-CEkOf95p.mjs +0 -2
- package/src/migrations.ts +0 -60
package/src/handlers/engine.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useAPI, HandleListenerSendFn } from "../ipc-core";
|
|
2
|
-
import { PipelabContext } from "../context";
|
|
2
|
+
import { PipelabContext, CacheFolder } from "../context";
|
|
3
3
|
import { useLogger } from "@pipelab/shared";
|
|
4
4
|
import { getFinalPlugins, executeGraphWithHistory } from "../utils";
|
|
5
5
|
import { presets } from "../presets/list";
|
|
6
6
|
import { handleActionExecute } from "../handler-func";
|
|
7
7
|
import { join } from "node:path";
|
|
8
|
-
import {
|
|
8
|
+
import { rm } from "node:fs/promises";
|
|
9
|
+
import { setupSettingsConfigFile } from "../config";
|
|
9
10
|
import { AppConfig } from "@pipelab/shared";
|
|
10
11
|
|
|
11
12
|
export const registerEngineHandlers = (context: PipelabContext) => {
|
|
@@ -78,32 +79,35 @@ export const registerEngineHandlers = (context: PipelabContext) => {
|
|
|
78
79
|
|
|
79
80
|
handle("action:execute", async (event, { send, value }) => {
|
|
80
81
|
const { nodeId, params, pluginId } = value;
|
|
81
|
-
const
|
|
82
|
-
const config = await settings.getConfig();
|
|
83
|
-
|
|
84
|
-
const cachePath = join(context.userDataPath, "cache", "actions", pluginId, nodeId);
|
|
82
|
+
const cachePath = context.getCachePath(CacheFolder.Actions, pluginId, nodeId);
|
|
85
83
|
const cwd = await context.createTempFolder("action-execute-");
|
|
86
84
|
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
try {
|
|
86
|
+
const mainWindow: undefined = undefined;
|
|
87
|
+
abortControllerGraph = new AbortController();
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
const signalPromise = new Promise((resolve, reject) => {
|
|
90
|
+
abortControllerGraph!.signal.addEventListener("abort", async () => {
|
|
91
|
+
await send({
|
|
92
|
+
type: "end",
|
|
93
|
+
data: {
|
|
94
|
+
ipcError: "Action aborted",
|
|
95
|
+
type: "error",
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
return reject(new Error("Action interrupted"));
|
|
98
99
|
});
|
|
99
|
-
return reject(new Error("Action interrupted"));
|
|
100
100
|
});
|
|
101
|
-
});
|
|
102
101
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
await Promise.race([
|
|
103
|
+
signalPromise,
|
|
104
|
+
effectiveActionExecute(nodeId, pluginId, params, mainWindow, send, cwd, cachePath),
|
|
105
|
+
]);
|
|
106
|
+
} finally {
|
|
107
|
+
await rm(cwd, { recursive: true, force: true }).catch((err) => {
|
|
108
|
+
console.warn(`Failed to cleanup temp folder at ${cwd}:`, err);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
107
111
|
});
|
|
108
112
|
|
|
109
113
|
handle("constants:get", async (_, { send }) => {
|
|
@@ -138,13 +142,13 @@ export const registerEngineHandlers = (context: PipelabContext) => {
|
|
|
138
142
|
|
|
139
143
|
handle("graph:execute", async (event, { send, value }) => {
|
|
140
144
|
const { graph, variables, projectName, projectPath, pipelineId } = value;
|
|
141
|
-
const settings = await
|
|
145
|
+
const settings = await setupSettingsConfigFile(context);
|
|
142
146
|
const config = await settings.getConfig();
|
|
143
147
|
|
|
144
148
|
const effectiveProjectName = projectName || "Unnamed Project";
|
|
145
149
|
const effectiveProjectPath = projectPath || "";
|
|
146
150
|
const effectivePipelineId = pipelineId || "unknown";
|
|
147
|
-
const effectiveCachePath =
|
|
151
|
+
const effectiveCachePath = context.getCachePath(CacheFolder.Pipelines, effectivePipelineId);
|
|
148
152
|
|
|
149
153
|
const mainWindow: undefined = undefined;
|
|
150
154
|
abortControllerGraph = new AbortController();
|
package/src/handlers/history.ts
CHANGED
|
@@ -284,44 +284,4 @@ export const registerHistoryHandlers = (context: PipelabContext) => {
|
|
|
284
284
|
});
|
|
285
285
|
}
|
|
286
286
|
});
|
|
287
|
-
|
|
288
|
-
handle("build-history:configure", async (_, { send, value }) => {
|
|
289
|
-
try {
|
|
290
|
-
logger().info("Updating build history configuration:", value.config);
|
|
291
|
-
|
|
292
|
-
const settings = await setupConfigFile<AppConfig>("settings", { context });
|
|
293
|
-
const currentConfig = await settings.getConfig();
|
|
294
|
-
|
|
295
|
-
// Deep merge the new config with the existing one
|
|
296
|
-
const newConfig = {
|
|
297
|
-
...currentConfig,
|
|
298
|
-
buildHistory: {
|
|
299
|
-
...currentConfig?.buildHistory,
|
|
300
|
-
retentionPolicy: {
|
|
301
|
-
...currentConfig?.buildHistory?.retentionPolicy,
|
|
302
|
-
...value.config.retentionPolicy,
|
|
303
|
-
},
|
|
304
|
-
},
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
await settings.setConfig(newConfig);
|
|
308
|
-
|
|
309
|
-
send({
|
|
310
|
-
type: "end",
|
|
311
|
-
data: {
|
|
312
|
-
type: "success",
|
|
313
|
-
result: { result: "ok" },
|
|
314
|
-
},
|
|
315
|
-
});
|
|
316
|
-
} catch (error) {
|
|
317
|
-
logger().error("Failed to configure build history:", error);
|
|
318
|
-
send({
|
|
319
|
-
type: "end",
|
|
320
|
-
data: {
|
|
321
|
-
type: "error",
|
|
322
|
-
ipcError: error instanceof Error ? error.message : "Failed to configure build history",
|
|
323
|
-
},
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
287
|
};
|
package/src/handlers/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { registerAgentsHandlers } from "./agents";
|
|
|
7
7
|
import { registerAuthHandlers } from "./auth";
|
|
8
8
|
import { registerSystemHandlers } from "./system";
|
|
9
9
|
import { registerPluginsHandlers } from "./plugins";
|
|
10
|
+
import { registerMigrationHandlers } from "./migration";
|
|
10
11
|
import { builtInPlugins } from "../plugins-registry";
|
|
11
12
|
import { usePlugins } from "@pipelab/shared";
|
|
12
13
|
import { PipelabContext } from "../context";
|
|
@@ -26,6 +27,7 @@ export const registerAllHandlers = async (options: {
|
|
|
26
27
|
registerAuthHandlers(context);
|
|
27
28
|
registerSystemHandlers(options);
|
|
28
29
|
registerPluginsHandlers(context);
|
|
30
|
+
registerMigrationHandlers(context);
|
|
29
31
|
|
|
30
32
|
const { registerPlugins } = usePlugins();
|
|
31
33
|
// Execute in the background! The plugins will be dynamically registered and broadcasted to the UI.
|