@pipelab/core-node 1.0.1-beta.26 → 1.0.1-beta.28

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.1-beta.26",
3
+ "version": "1.0.1-beta.28",
4
4
  "private": false,
5
5
  "description": "The Pipelab automation engine for Node.js",
6
6
  "license": "FSL-1.1-MIT",
@@ -39,8 +39,8 @@
39
39
  "type-fest": "4.39.0",
40
40
  "ws": "8.18.3",
41
41
  "yauzl": "2.10.0",
42
- "@pipelab/constants": "1.0.1-beta.22",
43
- "@pipelab/shared": "2.0.1-beta.23"
42
+ "@pipelab/constants": "1.0.1-beta.24",
43
+ "@pipelab/shared": "2.0.1-beta.25"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/adm-zip": "0.5.7",
@@ -53,7 +53,7 @@
53
53
  "@types/yauzl": "2.10.3",
54
54
  "tsdown": "0.21.2",
55
55
  "typescript": "^5.0.0",
56
- "@pipelab/tsconfig": "1.0.1-beta.22"
56
+ "@pipelab/tsconfig": "1.0.1-beta.24"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "tsdown",
package/src/context.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { join, dirname, resolve } from "node:path";
2
- import { homedir } from "node:os";
2
+ import { homedir, platform } from "node:os";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { existsSync } from "node:fs";
5
5
 
@@ -12,6 +12,21 @@ const _dirname =
12
12
 
13
13
  export const isDev = process.env.NODE_ENV === "development";
14
14
 
15
+ export const getDefaultUserDataPath = () => {
16
+ const base = (() => {
17
+ switch (platform()) {
18
+ case "win32":
19
+ return process.env.APPDATA || join(homedir(), "AppData", "Roaming");
20
+ case "darwin":
21
+ return join(homedir(), "Library", "Application Support");
22
+ default:
23
+ return process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
24
+ }
25
+ })();
26
+
27
+ return join(base, "@pipelab", isDev ? "app-dev" : "app");
28
+ };
29
+
15
30
  /**
16
31
  * Finds the monorepo root by looking for pnpm-workspace.yaml.
17
32
  */
@@ -226,6 +226,36 @@ export const registerHistoryHandlers = (context: PipelabContext) => {
226
226
  }
227
227
  });
228
228
 
229
+ handle("build-history:clear-by-pipeline", async (event, { send, value }) => {
230
+ try {
231
+ await checkBuildHistoryAuthorization(event);
232
+
233
+ await buildHistoryStorage.clearByPipeline(value.pipelineId);
234
+ send({
235
+ type: "end",
236
+ data: { type: "success", result: { result: "ok" } },
237
+ });
238
+ } catch (error) {
239
+ logger().error(`Failed to clear build history for pipeline ${value.pipelineId}:`, error);
240
+
241
+ if (error instanceof SubscriptionRequiredError) {
242
+ send({
243
+ type: "end",
244
+ data: { type: "error", ipcError: error.userMessage, code: error.code },
245
+ });
246
+ return;
247
+ }
248
+
249
+ send({
250
+ type: "end",
251
+ data: {
252
+ type: "error",
253
+ ipcError: error instanceof Error ? error.message : "Failed to clear build history for pipeline",
254
+ },
255
+ });
256
+ }
257
+ });
258
+
229
259
  handle("build-history:get-storage-info", async (event, { send }) => {
230
260
  try {
231
261
  await checkBuildHistoryAuthorization(event);
package/src/utils.ts CHANGED
@@ -125,6 +125,9 @@ export const executeGraphWithHistory = async ({
125
125
  const logs: any[] = [];
126
126
  const sandboxPath = await generateTempFolder(cachePath);
127
127
  const { logger } = useLogger();
128
+ let completedSteps = 0;
129
+ let failedSteps = 0;
130
+ let cancelledSteps = 0;
128
131
 
129
132
  // Ensure all plugins used in the graph are downloaded and registered
130
133
  const { registerPlugins, plugins: registeredPlugins } = usePlugins();
@@ -175,7 +178,8 @@ export const executeGraphWithHistory = async ({
175
178
  async (data) => {
176
179
  if (data.type === "log") {
177
180
  const logEntry = {
178
- type: data.type,
181
+ id: nanoid(),
182
+ level: "info",
179
183
  message: data.data.message,
180
184
  timestamp: data.data.time,
181
185
  nodeUid: node?.uid,
@@ -195,7 +199,14 @@ export const executeGraphWithHistory = async ({
195
199
  onNodeEnter: (node) => {
196
200
  onNodeEnter?.(node);
197
201
  },
198
- onNodeExit: (node) => {
202
+ onNodeExit: async (node) => {
203
+ completedSteps++;
204
+ if (!shouldDisableHistory) {
205
+ // Update progress in the background
206
+ buildHistoryStorage.update(buildId, { completedSteps }, pipelineId).catch((err) => {
207
+ logger().error(`Failed to update progress for build ${buildId}:`, err);
208
+ });
209
+ }
199
210
  onNodeExit?.(node);
200
211
  },
201
212
  abortSignal,
@@ -211,6 +222,7 @@ export const executeGraphWithHistory = async ({
211
222
  duration: endTime - startTime,
212
223
  output: result.steps,
213
224
  logs,
225
+ completedSteps,
214
226
  },
215
227
  pipelineId,
216
228
  );
@@ -234,6 +246,9 @@ export const executeGraphWithHistory = async ({
234
246
  timestamp: endTime,
235
247
  },
236
248
  logs,
249
+ completedSteps,
250
+ failedSteps: isCanceled ? 0 : 1,
251
+ cancelledSteps: isCanceled ? 1 : 0,
237
252
  },
238
253
  pipelineId,
239
254
  );