@pipelab/core-node 1.0.0-beta.17 → 1.0.0-beta.18
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 +9 -0
- package/dist/index.d.mts +12 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +103 -136
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/config.test.ts +23 -15
- package/src/config.ts +18 -21
- package/src/context.ts +19 -2
- package/src/handlers/build-history.ts +47 -90
- package/src/handlers/config.ts +2 -21
- package/src/handlers/engine.ts +26 -22
- package/src/handlers/history.ts +0 -40
- package/src/plugins-registry.ts +15 -17
- package/src/runner.ts +2 -4
- package/src/server.ts +1 -0
- 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 +6 -6
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { DEFAULT_NODE_VERSION, DEFAULT_PNPM_VERSION, SandboxFolder, getUiDevServ
|
|
|
8
8
|
import { WebSocket, WebSocketServer as WebSocketServer$1 } from "ws";
|
|
9
9
|
import http from "node:http";
|
|
10
10
|
import { nanoid } from "nanoid";
|
|
11
|
-
import { SubscriptionRequiredError, WebSocketError, configRegistry, isRequired, isSupabaseAvailable, isWebSocketRequestMessage,
|
|
11
|
+
import { SubscriptionRequiredError, WebSocketError, configRegistry, isRequired, isSupabaseAvailable, isWebSocketRequestMessage, processGraph, savedFileMigrator, supabase, transformUrl, useLogger, usePlugins } from "@pipelab/shared";
|
|
12
12
|
import { execa } from "execa";
|
|
13
13
|
import tar from "tar";
|
|
14
14
|
import yauzl from "yauzl";
|
|
@@ -80,6 +80,11 @@ function findProjectRoot(startDir) {
|
|
|
80
80
|
return null;
|
|
81
81
|
}
|
|
82
82
|
const projectRoot = findProjectRoot(_dirname);
|
|
83
|
+
const CacheFolder = {
|
|
84
|
+
Actions: "actions",
|
|
85
|
+
Pipelines: "pipelines",
|
|
86
|
+
Pacote: "pacote"
|
|
87
|
+
};
|
|
83
88
|
var PipelabContext = class {
|
|
84
89
|
userDataPath;
|
|
85
90
|
releaseTag;
|
|
@@ -104,12 +109,16 @@ var PipelabContext = class {
|
|
|
104
109
|
await mkdir(baseDir, { recursive: true });
|
|
105
110
|
return await mkdtemp(join(await realpath(baseDir), prefix));
|
|
106
111
|
}
|
|
107
|
-
getCachePath(...subpaths) {
|
|
108
|
-
return join(this.userDataPath, "cache"
|
|
112
|
+
getCachePath(folder, ...subpaths) {
|
|
113
|
+
if (!folder) return join(this.userDataPath, "cache");
|
|
114
|
+
return join(this.userDataPath, "cache", folder, ...subpaths);
|
|
109
115
|
}
|
|
110
116
|
getPnpmPath(...subpaths) {
|
|
111
117
|
return join(this.userDataPath, "pnpm", ...subpaths);
|
|
112
118
|
}
|
|
119
|
+
getBuildHistoryPath(...subpaths) {
|
|
120
|
+
return join(this.userDataPath, "build-history", ...subpaths);
|
|
121
|
+
}
|
|
113
122
|
getNodePath(version = DEFAULT_NODE_VERSION) {
|
|
114
123
|
const isWindows = process.platform === "win32";
|
|
115
124
|
return this.getThirdPartyPath("node", version, isWindows ? "node.exe" : "bin/node");
|
|
@@ -685,7 +694,7 @@ const setupConfigFile = async (name, options) => {
|
|
|
685
694
|
debug: false,
|
|
686
695
|
onStep: async (state, version) => {
|
|
687
696
|
const parsedPath = path.parse(filesPath);
|
|
688
|
-
const versionedPath =
|
|
697
|
+
const versionedPath = ctx.getConfigPath(`${parsedPath.name}.v${version}.json`);
|
|
689
698
|
try {
|
|
690
699
|
await fs$1.writeFile(versionedPath, JSON.stringify(state));
|
|
691
700
|
logger().info(`Intermediate backup created for ${name} at ${versionedPath}`);
|
|
@@ -700,13 +709,11 @@ const setupConfigFile = async (name, options) => {
|
|
|
700
709
|
migrationFailed = true;
|
|
701
710
|
json = migrator.defaultValue;
|
|
702
711
|
}
|
|
703
|
-
|
|
704
|
-
if (name.startsWith("pipeline-") || path.isAbsolute(name) || name.endsWith(".json") || name === "pipeline") normalized = normalizePipelineConfig(json);
|
|
705
|
-
if (originalJson?.version !== json?.version || normalized || content === void 0 || parseFailed || migrationFailed) {
|
|
712
|
+
if (originalJson?.version !== json?.version || content === void 0 || parseFailed || migrationFailed) {
|
|
706
713
|
if (parseFailed || migrationFailed) try {
|
|
707
714
|
const parsedPath = path.parse(filesPath);
|
|
708
715
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
709
|
-
const corruptedPath =
|
|
716
|
+
const corruptedPath = ctx.getConfigPath(`${parsedPath.name}.corrupted.${timestamp}.json`);
|
|
710
717
|
const backupContent = parseFailed ? content || "" : JSON.stringify(originalJson, null, 2);
|
|
711
718
|
await fs$1.writeFile(corruptedPath, backupContent);
|
|
712
719
|
logger().info(`Corrupted config file preserved at ${corruptedPath}`);
|
|
@@ -723,6 +730,10 @@ const setupConfigFile = async (name, options) => {
|
|
|
723
730
|
}
|
|
724
731
|
};
|
|
725
732
|
};
|
|
733
|
+
const deleteConfigFile = async (nameOrPath, context) => {
|
|
734
|
+
const filesPath = path.isAbsolute(nameOrPath) ? nameOrPath : context.getConfigPath(`${nameOrPath}.json`);
|
|
735
|
+
await fs$1.rm(filesPath, { force: true });
|
|
736
|
+
};
|
|
726
737
|
//#endregion
|
|
727
738
|
//#region src/handlers/config.ts
|
|
728
739
|
const registerConfigHandlers = (context) => {
|
|
@@ -809,18 +820,7 @@ const registerConfigHandlers = (context) => {
|
|
|
809
820
|
const { config: name } = value;
|
|
810
821
|
logger().info("config:delete", name);
|
|
811
822
|
try {
|
|
812
|
-
|
|
813
|
-
await fs$1.rm(filesPath, { force: true });
|
|
814
|
-
const parsedPath = path.parse(filesPath);
|
|
815
|
-
const dirEntries = await fs$1.readdir(parsedPath.dir).catch(() => []);
|
|
816
|
-
const prefix = `${parsedPath.name}.v`;
|
|
817
|
-
const suffix = `.json`;
|
|
818
|
-
for (const entry of dirEntries) if (entry.startsWith(prefix) && entry.endsWith(suffix)) {
|
|
819
|
-
const backupPath = path.join(parsedPath.dir, entry);
|
|
820
|
-
await fs$1.rm(backupPath, { force: true }).catch((err) => {
|
|
821
|
-
logger().error(`Failed to delete backup ${backupPath}:`, err);
|
|
822
|
-
});
|
|
823
|
-
}
|
|
823
|
+
await deleteConfigFile(name, context);
|
|
824
824
|
send({
|
|
825
825
|
type: "end",
|
|
826
826
|
data: {
|
|
@@ -848,11 +848,10 @@ var BuildHistoryStorage = class {
|
|
|
848
848
|
this.context = context;
|
|
849
849
|
}
|
|
850
850
|
getStoragePath() {
|
|
851
|
-
return
|
|
851
|
+
return this.context.getConfigPath("pipelines");
|
|
852
852
|
}
|
|
853
853
|
getPipelinePath(pipelineId) {
|
|
854
|
-
|
|
855
|
-
return join(this.getStoragePath(), `pipeline-${sanitizedId}.json`);
|
|
854
|
+
return join(this.getStoragePath(), `${pipelineId}.history.json`);
|
|
856
855
|
}
|
|
857
856
|
async ensureStoragePath() {
|
|
858
857
|
try {
|
|
@@ -879,35 +878,6 @@ var BuildHistoryStorage = class {
|
|
|
879
878
|
throw new Error(`Failed to save pipeline history: ${error}`);
|
|
880
879
|
}
|
|
881
880
|
}
|
|
882
|
-
async applyRetentionPolicy() {
|
|
883
|
-
try {
|
|
884
|
-
this.logger.logger().info("Applying build history retention policy...");
|
|
885
|
-
const policy = (await (await setupConfigFile("settings", { context: this.context })).getConfig())?.buildHistory?.retentionPolicy;
|
|
886
|
-
if (!policy || !policy.enabled) {
|
|
887
|
-
this.logger.logger().info("Retention policy is disabled. Skipping.");
|
|
888
|
-
return;
|
|
889
|
-
}
|
|
890
|
-
const { maxAge, maxEntries } = policy;
|
|
891
|
-
const pipelineFiles = await this.getAllPipelineFiles();
|
|
892
|
-
for (const file of pipelineFiles) {
|
|
893
|
-
const pipelineId = file.replace("pipeline-", "").replace(".json", "");
|
|
894
|
-
let entries = await this.loadPipelineHistory(pipelineId);
|
|
895
|
-
const originalCount = entries.length;
|
|
896
|
-
if (maxAge > 0) {
|
|
897
|
-
const minDate = Date.now() - maxAge * 24 * 60 * 60 * 1e3;
|
|
898
|
-
entries = entries.filter((entry) => entry.createdAt >= minDate);
|
|
899
|
-
}
|
|
900
|
-
if (maxEntries > 0 && entries.length > maxEntries) entries = entries.sort((a, b) => b.createdAt - a.createdAt).slice(0, maxEntries);
|
|
901
|
-
if (entries.length < originalCount) {
|
|
902
|
-
this.logger.logger().info(`[${pipelineId}] Pruned ${originalCount - entries.length} history entries.`);
|
|
903
|
-
await this.savePipelineHistory(pipelineId, entries);
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
this.logger.logger().info("Retention policy applied successfully.");
|
|
907
|
-
} catch (error) {
|
|
908
|
-
this.logger.logger().error("Failed to apply retention policy:", error);
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
881
|
async save(entry) {
|
|
912
882
|
try {
|
|
913
883
|
const entries = await this.loadPipelineHistory(entry.pipelineId);
|
|
@@ -916,9 +886,6 @@ var BuildHistoryStorage = class {
|
|
|
916
886
|
else entries.push(entry);
|
|
917
887
|
await this.savePipelineHistory(entry.pipelineId, entries);
|
|
918
888
|
this.logger.logger().info(`Saved build history entry: ${entry.id} for pipeline: ${entry.pipelineId}`);
|
|
919
|
-
this.applyRetentionPolicy().catch((err) => {
|
|
920
|
-
this.logger.logger().error("Failed to apply retention policy after save:", err);
|
|
921
|
-
});
|
|
922
889
|
} catch (error) {
|
|
923
890
|
this.logger.logger().error("Failed to save build history entry:", error);
|
|
924
891
|
throw new Error(`Failed to save build history entry: ${error}`);
|
|
@@ -929,7 +896,8 @@ var BuildHistoryStorage = class {
|
|
|
929
896
|
if (pipelineId) return (await this.loadPipelineHistory(pipelineId)).find((e) => e.id === id);
|
|
930
897
|
const files = await this.getAllPipelineFiles();
|
|
931
898
|
for (const file of files) {
|
|
932
|
-
const pId =
|
|
899
|
+
const pId = this.parsePipelineIdFromFilename(file);
|
|
900
|
+
if (!pId) continue;
|
|
933
901
|
const entry = (await this.loadPipelineHistory(pId)).find((e) => e.id === id);
|
|
934
902
|
if (entry) return entry;
|
|
935
903
|
}
|
|
@@ -944,7 +912,8 @@ var BuildHistoryStorage = class {
|
|
|
944
912
|
const files = await this.getAllPipelineFiles();
|
|
945
913
|
const allEntries = [];
|
|
946
914
|
for (const file of files) {
|
|
947
|
-
const pipelineId =
|
|
915
|
+
const pipelineId = this.parsePipelineIdFromFilename(file);
|
|
916
|
+
if (!pipelineId) continue;
|
|
948
917
|
const entries = await this.loadPipelineHistory(pipelineId);
|
|
949
918
|
allEntries.push(...entries);
|
|
950
919
|
}
|
|
@@ -979,7 +948,8 @@ var BuildHistoryStorage = class {
|
|
|
979
948
|
} else {
|
|
980
949
|
const files = await this.getAllPipelineFiles();
|
|
981
950
|
for (const file of files) {
|
|
982
|
-
const pId =
|
|
951
|
+
const pId = this.parsePipelineIdFromFilename(file);
|
|
952
|
+
if (!pId) continue;
|
|
983
953
|
const entries = await this.loadPipelineHistory(pId);
|
|
984
954
|
const entryIndex = entries.findIndex((e) => e.id === id);
|
|
985
955
|
if (entryIndex >= 0) {
|
|
@@ -1013,7 +983,8 @@ var BuildHistoryStorage = class {
|
|
|
1013
983
|
} else {
|
|
1014
984
|
const files = await this.getAllPipelineFiles();
|
|
1015
985
|
for (const file of files) {
|
|
1016
|
-
const pId =
|
|
986
|
+
const pId = this.parsePipelineIdFromFilename(file);
|
|
987
|
+
if (!pId) continue;
|
|
1017
988
|
const entries = await this.loadPipelineHistory(pId);
|
|
1018
989
|
const entryIndex = entries.findIndex((e) => e.id === id);
|
|
1019
990
|
if (entryIndex >= 0) {
|
|
@@ -1034,8 +1005,20 @@ var BuildHistoryStorage = class {
|
|
|
1034
1005
|
try {
|
|
1035
1006
|
await this.ensureStoragePath();
|
|
1036
1007
|
const files = await this.getAllPipelineFiles();
|
|
1037
|
-
|
|
1008
|
+
const cachePathsToDelete = /* @__PURE__ */ new Set();
|
|
1009
|
+
for (const file of files) {
|
|
1010
|
+
const pipelineId = this.parsePipelineIdFromFilename(file);
|
|
1011
|
+
if (pipelineId) {
|
|
1012
|
+
const entries = await this.loadPipelineHistory(pipelineId);
|
|
1013
|
+
for (const entry of entries) if (entry.cachePath) cachePathsToDelete.add(entry.cachePath);
|
|
1014
|
+
}
|
|
1015
|
+
await unlink(join(this.getStoragePath(), file));
|
|
1016
|
+
}
|
|
1038
1017
|
this.logger.logger().info("Cleared all build history");
|
|
1018
|
+
for (const cachePath of cachePathsToDelete) await rm(cachePath, {
|
|
1019
|
+
recursive: true,
|
|
1020
|
+
force: true
|
|
1021
|
+
}).catch(() => {});
|
|
1039
1022
|
} catch (error) {
|
|
1040
1023
|
this.logger.logger().error("Failed to clear build history:", error);
|
|
1041
1024
|
throw new Error(`Failed to clear build history: ${error}`);
|
|
@@ -1043,8 +1026,16 @@ var BuildHistoryStorage = class {
|
|
|
1043
1026
|
}
|
|
1044
1027
|
async clearByPipeline(pipelineId) {
|
|
1045
1028
|
try {
|
|
1046
|
-
|
|
1029
|
+
const pipelinePath = this.getPipelinePath(pipelineId);
|
|
1030
|
+
const entries = await this.loadPipelineHistory(pipelineId);
|
|
1031
|
+
await unlink(pipelinePath);
|
|
1047
1032
|
this.logger.logger().info(`Cleared history for pipeline "${pipelineId}"`);
|
|
1033
|
+
const cachePathsToDelete = /* @__PURE__ */ new Set();
|
|
1034
|
+
for (const entry of entries) if (entry.cachePath) cachePathsToDelete.add(entry.cachePath);
|
|
1035
|
+
for (const cachePath of cachePathsToDelete) await rm(cachePath, {
|
|
1036
|
+
recursive: true,
|
|
1037
|
+
force: true
|
|
1038
|
+
}).catch(() => {});
|
|
1048
1039
|
} catch (error) {
|
|
1049
1040
|
if (error.code === "ENOENT") {
|
|
1050
1041
|
this.logger.logger().warn(`No history file found for pipeline "${pipelineId}". Nothing to clear.`);
|
|
@@ -1069,21 +1060,11 @@ var BuildHistoryStorage = class {
|
|
|
1069
1060
|
size
|
|
1070
1061
|
});
|
|
1071
1062
|
}
|
|
1072
|
-
const policy = (await (await setupConfigFile("settings", { context: this.context })).getConfig())?.buildHistory?.retentionPolicy || {
|
|
1073
|
-
enabled: false,
|
|
1074
|
-
maxEntries: 50,
|
|
1075
|
-
maxAge: 30
|
|
1076
|
-
};
|
|
1077
1063
|
if (allEntries.length === 0) return {
|
|
1078
1064
|
totalEntries: 0,
|
|
1079
1065
|
totalSize: 0,
|
|
1080
1066
|
numberOfPipelines: files.length,
|
|
1081
1067
|
userDataPath: this.context.userDataPath,
|
|
1082
|
-
retentionPolicy: {
|
|
1083
|
-
enabled: policy.enabled,
|
|
1084
|
-
maxEntries: policy.maxEntries,
|
|
1085
|
-
maxAge: policy.maxAge
|
|
1086
|
-
},
|
|
1087
1068
|
disk: {
|
|
1088
1069
|
total: diskSpace.size,
|
|
1089
1070
|
free: diskSpace.free,
|
|
@@ -1108,11 +1089,6 @@ var BuildHistoryStorage = class {
|
|
|
1108
1089
|
newestEntry: sortedEntries[sortedEntries.length - 1]?.createdAt,
|
|
1109
1090
|
numberOfPipelines: files.length,
|
|
1110
1091
|
userDataPath: this.context.userDataPath,
|
|
1111
|
-
retentionPolicy: {
|
|
1112
|
-
enabled: policy.enabled,
|
|
1113
|
-
maxEntries: policy.maxEntries,
|
|
1114
|
-
maxAge: policy.maxAge
|
|
1115
|
-
},
|
|
1116
1092
|
disk: {
|
|
1117
1093
|
total: diskSpace.size,
|
|
1118
1094
|
free: diskSpace.free,
|
|
@@ -1128,11 +1104,15 @@ var BuildHistoryStorage = class {
|
|
|
1128
1104
|
async getAllPipelineFiles() {
|
|
1129
1105
|
try {
|
|
1130
1106
|
await this.ensureStoragePath();
|
|
1131
|
-
return (await readdir(this.getStoragePath())).filter((file) => file.
|
|
1107
|
+
return (await readdir(this.getStoragePath())).filter((file) => file.endsWith(".history.json"));
|
|
1132
1108
|
} catch (error) {
|
|
1133
1109
|
return [];
|
|
1134
1110
|
}
|
|
1135
1111
|
}
|
|
1112
|
+
parsePipelineIdFromFilename(filename) {
|
|
1113
|
+
const match = filename.match(/^(.+)\.history\.json$/);
|
|
1114
|
+
return match ? match[1] : null;
|
|
1115
|
+
}
|
|
1136
1116
|
};
|
|
1137
1117
|
//#endregion
|
|
1138
1118
|
//#region src/handlers/history.ts
|
|
@@ -1414,40 +1394,6 @@ const registerHistoryHandlers = (context) => {
|
|
|
1414
1394
|
});
|
|
1415
1395
|
}
|
|
1416
1396
|
});
|
|
1417
|
-
handle("build-history:configure", async (_, { send, value }) => {
|
|
1418
|
-
try {
|
|
1419
|
-
logger().info("Updating build history configuration:", value.config);
|
|
1420
|
-
const settings = await setupConfigFile("settings", { context });
|
|
1421
|
-
const currentConfig = await settings.getConfig();
|
|
1422
|
-
const newConfig = {
|
|
1423
|
-
...currentConfig,
|
|
1424
|
-
buildHistory: {
|
|
1425
|
-
...currentConfig?.buildHistory,
|
|
1426
|
-
retentionPolicy: {
|
|
1427
|
-
...currentConfig?.buildHistory?.retentionPolicy,
|
|
1428
|
-
...value.config.retentionPolicy
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
};
|
|
1432
|
-
await settings.setConfig(newConfig);
|
|
1433
|
-
send({
|
|
1434
|
-
type: "end",
|
|
1435
|
-
data: {
|
|
1436
|
-
type: "success",
|
|
1437
|
-
result: { result: "ok" }
|
|
1438
|
-
}
|
|
1439
|
-
});
|
|
1440
|
-
} catch (error) {
|
|
1441
|
-
logger().error("Failed to configure build history:", error);
|
|
1442
|
-
send({
|
|
1443
|
-
type: "end",
|
|
1444
|
-
data: {
|
|
1445
|
-
type: "error",
|
|
1446
|
-
ipcError: error instanceof Error ? error.message : "Failed to configure build history"
|
|
1447
|
-
}
|
|
1448
|
-
});
|
|
1449
|
-
}
|
|
1450
|
-
});
|
|
1451
1397
|
};
|
|
1452
1398
|
//#endregion
|
|
1453
1399
|
//#region ../../node_modules/serve-handler/src/glob-slash.js
|
|
@@ -8997,7 +8943,13 @@ async function serveCommand(options, version, _dirname) {
|
|
|
8997
8943
|
response.end(`Error: UI directory not found at ${rawAssetFolder}.\nPlease run 'pnpm build' in apps/ui to generate the distribution.`);
|
|
8998
8944
|
return;
|
|
8999
8945
|
}
|
|
9000
|
-
return (0, import_src.default)(request, response, {
|
|
8946
|
+
return (0, import_src.default)(request, response, {
|
|
8947
|
+
public: rawAssetFolder,
|
|
8948
|
+
rewrites: [{
|
|
8949
|
+
source: "/**",
|
|
8950
|
+
destination: "/index.html"
|
|
8951
|
+
}]
|
|
8952
|
+
});
|
|
9001
8953
|
});
|
|
9002
8954
|
console.log(`Starting Pipelab server on port ${options.port}...`);
|
|
9003
8955
|
if (isDev) {
|
|
@@ -9104,7 +9056,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
|
|
|
9104
9056
|
console.log(`[Fetcher] ${packageName}: Resolved to local fallback ${resolvedVersion} (${Date.now() - fallbackStart}ms)`);
|
|
9105
9057
|
} else throw new Error(`Offline and no local fallback version available for ${packageName}`);
|
|
9106
9058
|
} else try {
|
|
9107
|
-
const cachePath =
|
|
9059
|
+
const cachePath = ctx.getCachePath(CacheFolder.Pacote);
|
|
9108
9060
|
let packumentPromise = packumentRequests.get(packageName);
|
|
9109
9061
|
if (!packumentPromise) {
|
|
9110
9062
|
packumentPromise = pacote.packument(packageName, { cache: cachePath });
|
|
@@ -9135,7 +9087,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
|
|
|
9135
9087
|
console.log(`[Fetcher] ${packageName}: Resolved to local fallback ${resolvedVersion} (${Date.now() - fallbackStart}ms)`);
|
|
9136
9088
|
} else throw error;
|
|
9137
9089
|
}
|
|
9138
|
-
const cachePath =
|
|
9090
|
+
const cachePath = ctx.getCachePath(CacheFolder.Pacote);
|
|
9139
9091
|
const packageDir = join(baseDir, resolvedVersion);
|
|
9140
9092
|
const checkStart = Date.now();
|
|
9141
9093
|
const isInstalled = options?.installDeps ? isPackageComplete(packageDir) && isDependenciesInstalledSync(packageDir) : isPackageComplete(packageDir);
|
|
@@ -9212,7 +9164,7 @@ async function runPnpm(cwd, options) {
|
|
|
9212
9164
|
...process.env,
|
|
9213
9165
|
NODE_ENV: "production",
|
|
9214
9166
|
PATH: nodePath ? `${dirname(nodePath)}${delimiter}${process.env.PATH}` : process.env.PATH,
|
|
9215
|
-
PNPM_HOME:
|
|
9167
|
+
PNPM_HOME: ctx.getPnpmPath(),
|
|
9216
9168
|
PNPM_ONLY_ALLOW_TRUSTED_DEPENDENCIES: "false",
|
|
9217
9169
|
...extraEnv
|
|
9218
9170
|
}
|
|
@@ -9812,6 +9764,7 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
|
|
|
9812
9764
|
projectName,
|
|
9813
9765
|
projectPath,
|
|
9814
9766
|
pipelineId,
|
|
9767
|
+
cachePath,
|
|
9815
9768
|
startTime,
|
|
9816
9769
|
status: "running",
|
|
9817
9770
|
logs: [],
|
|
@@ -9908,7 +9861,6 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
|
|
|
9908
9861
|
}, pipelineId);
|
|
9909
9862
|
throw error;
|
|
9910
9863
|
} finally {
|
|
9911
|
-
if (!shouldDisableHistory) buildHistoryStorage.applyRetentionPolicy();
|
|
9912
9864
|
try {
|
|
9913
9865
|
await rm(sandboxPath, {
|
|
9914
9866
|
recursive: true,
|
|
@@ -9917,6 +9869,14 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
|
|
|
9917
9869
|
} catch (e) {
|
|
9918
9870
|
console.warn(`Failed to cleanup sandbox at ${sandboxPath}:`, e);
|
|
9919
9871
|
}
|
|
9872
|
+
try {
|
|
9873
|
+
await rm(cachePath, {
|
|
9874
|
+
recursive: true,
|
|
9875
|
+
force: true
|
|
9876
|
+
});
|
|
9877
|
+
} catch (e) {
|
|
9878
|
+
console.warn(`Failed to cleanup cache at ${cachePath}:`, e);
|
|
9879
|
+
}
|
|
9920
9880
|
}
|
|
9921
9881
|
};
|
|
9922
9882
|
//#endregion
|
|
@@ -10292,24 +10252,32 @@ const registerEngineHandlers = (context) => {
|
|
|
10292
10252
|
};
|
|
10293
10253
|
handle("action:execute", async (event, { send, value }) => {
|
|
10294
10254
|
const { nodeId, params, pluginId } = value;
|
|
10295
|
-
|
|
10296
|
-
const cachePath = join(context.userDataPath, "cache", "actions", pluginId, nodeId);
|
|
10255
|
+
const cachePath = context.getCachePath(CacheFolder.Actions, pluginId, nodeId);
|
|
10297
10256
|
const cwd = await context.createTempFolder("action-execute-");
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10257
|
+
try {
|
|
10258
|
+
const mainWindow = void 0;
|
|
10259
|
+
abortControllerGraph = new AbortController();
|
|
10260
|
+
const signalPromise = new Promise((resolve, reject) => {
|
|
10261
|
+
abortControllerGraph.signal.addEventListener("abort", async () => {
|
|
10262
|
+
await send({
|
|
10263
|
+
type: "end",
|
|
10264
|
+
data: {
|
|
10265
|
+
ipcError: "Action aborted",
|
|
10266
|
+
type: "error"
|
|
10267
|
+
}
|
|
10268
|
+
});
|
|
10269
|
+
return reject(/* @__PURE__ */ new Error("Action interrupted"));
|
|
10308
10270
|
});
|
|
10309
|
-
return reject(/* @__PURE__ */ new Error("Action interrupted"));
|
|
10310
10271
|
});
|
|
10311
|
-
|
|
10312
|
-
|
|
10272
|
+
await Promise.race([signalPromise, effectiveActionExecute(nodeId, pluginId, params, mainWindow, send, cwd, cachePath)]);
|
|
10273
|
+
} finally {
|
|
10274
|
+
await rm(cwd, {
|
|
10275
|
+
recursive: true,
|
|
10276
|
+
force: true
|
|
10277
|
+
}).catch((err) => {
|
|
10278
|
+
console.warn(`Failed to cleanup temp folder at ${cwd}:`, err);
|
|
10279
|
+
});
|
|
10280
|
+
}
|
|
10313
10281
|
});
|
|
10314
10282
|
handle("constants:get", async (_, { send }) => {
|
|
10315
10283
|
const userData = context.userDataPath;
|
|
@@ -10337,7 +10305,7 @@ const registerEngineHandlers = (context) => {
|
|
|
10337
10305
|
const effectiveProjectName = projectName || "Unnamed Project";
|
|
10338
10306
|
const effectiveProjectPath = projectPath || "";
|
|
10339
10307
|
const effectivePipelineId = pipelineId || "unknown";
|
|
10340
|
-
const effectiveCachePath =
|
|
10308
|
+
const effectiveCachePath = context.getCachePath(CacheFolder.Pipelines, effectivePipelineId);
|
|
10341
10309
|
const mainWindow = void 0;
|
|
10342
10310
|
abortControllerGraph = new AbortController();
|
|
10343
10311
|
try {
|
|
@@ -10445,7 +10413,7 @@ var JsonFileStorage = class {
|
|
|
10445
10413
|
filePath;
|
|
10446
10414
|
logger = useLogger().logger;
|
|
10447
10415
|
constructor(fileName, context) {
|
|
10448
|
-
this.filePath =
|
|
10416
|
+
this.filePath = context.getConfigPath(fileName);
|
|
10449
10417
|
const dir = path.dirname(this.filePath);
|
|
10450
10418
|
if (!fs.existsSync(dir)) try {
|
|
10451
10419
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -53171,8 +53139,7 @@ async function runPipelineCommand(file, options, version) {
|
|
|
53171
53139
|
context
|
|
53172
53140
|
});
|
|
53173
53141
|
registerMigrationHandlers(context);
|
|
53174
|
-
|
|
53175
|
-
const cachePath = join(context.userDataPath, "cache");
|
|
53142
|
+
const cachePath = context.getCachePath(CacheFolder.Pipelines, effectivePipelineId);
|
|
53176
53143
|
await mkdir(cachePath, { recursive: true });
|
|
53177
53144
|
const abortController = new AbortController();
|
|
53178
53145
|
let supabase;
|
|
@@ -53344,6 +53311,6 @@ async function fetchLatestDesktopRelease(options = {}) {
|
|
|
53344
53311
|
return latest;
|
|
53345
53312
|
}
|
|
53346
53313
|
//#endregion
|
|
53347
|
-
export { BuildHistoryStorage, PipelabContext, WebSocketServer, builtInPlugins, downloadFile, ensure, ensureNodeJS, ensurePNPM, executeGraphWithHistory, extractTarGz, extractZip, fetchLatestDesktopRelease, fetchLatestPackageRelease, fetchPackage, fetchPackageReleases, fetchPipelabAsset, fetchPipelabCli, fetchPipelabPlugin, findInstalledPlugins, getDefaultUserDataPath, getFinalPlugins, getFolderSize, getMigrator, handleActionExecute, isDev, isOnline, loadCustomPlugin, loadPipelabPlugin, projectRoot, registerAgentsHandlers, registerAllHandlers, registerConfigHandlers, registerEngineHandlers, registerFsHandlers, registerHistoryHandlers, registerMigrationHandlers, registerShellHandlers, runPipelineCommand, runPnpm, runWithLiveLogs, sendStartupProgress, sendStartupReady, serveCommand, setupConfigFile, useAPI, usePluginAPI, webSocketServer, zipFolder };
|
|
53314
|
+
export { BuildHistoryStorage, CacheFolder, PipelabContext, WebSocketServer, builtInPlugins, deleteConfigFile, downloadFile, ensure, ensureNodeJS, ensurePNPM, executeGraphWithHistory, extractTarGz, extractZip, fetchLatestDesktopRelease, fetchLatestPackageRelease, fetchPackage, fetchPackageReleases, fetchPipelabAsset, fetchPipelabCli, fetchPipelabPlugin, findInstalledPlugins, getDefaultUserDataPath, getFinalPlugins, getFolderSize, getMigrator, handleActionExecute, isDev, isOnline, loadCustomPlugin, loadPipelabPlugin, projectRoot, registerAgentsHandlers, registerAllHandlers, registerConfigHandlers, registerEngineHandlers, registerFsHandlers, registerHistoryHandlers, registerMigrationHandlers, registerShellHandlers, runPipelineCommand, runPnpm, runWithLiveLogs, sendStartupProgress, sendStartupReady, serveCommand, setupConfigFile, useAPI, usePluginAPI, webSocketServer, zipFolder };
|
|
53348
53315
|
|
|
53349
53316
|
//# sourceMappingURL=index.mjs.map
|