@pipelab/cli 2.0.0-beta.17 → 2.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/config-B-M_kmKR.mjs +4 -0
- package/{config-C2_-dWDC.mjs → config-C4SmHbuE.mjs} +53 -22
- package/index.mjs +896 -231
- package/package.json +1 -1
- package/src-5EzZR-UT.mjs +5 -0
- package/{src-IhkP0N4B.mjs → src-CoHipk5y.mjs} +54 -132
- package/src-DU3j_v2A.mjs +3 -0
- package/config-kWOWhsn6.mjs +0 -4
- package/src-CHr-wGNr.mjs +0 -5
- package/src-XVe3IQMi.mjs +0 -3
package/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as __require, n as __esmMin, s as __toESM, t as __commonJSMin } from "./chunk-M2dkpuaD.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { a as WebSocketError, c as transformUrl, d as SubscriptionRequiredError, f as usePlugins, i as savedFileMigrator, l as isSupabaseAvailable, n as connectionsMigrator, o as isWebSocketRequestMessage, r as fileRepoMigrations, s as isRequired, t as appSettingsMigrator, u as supabase, v as processGraph, w as useLogger } from "./src-CoHipk5y.mjs";
|
|
4
4
|
import "./dist-BC_B45iu.mjs";
|
|
5
|
-
import { a as
|
|
5
|
+
import { a as setupPipelineConfigFileByName, c as setupSettingsConfigFile, d as extractTarGz, f as extractZip, g as execa, h as require_balanced_match, i as setupConnectionsConfigFile, l as downloadFile, m as require_commonjs$8, n as deletePipelineConfigFileByPath, o as setupPipelineConfigFileByPath, p as getFolderSize, s as setupProjectsConfigFile, t as deletePipelineConfigFileByName } from "./config-C4SmHbuE.mjs";
|
|
6
6
|
import path, { delimiter, dirname, isAbsolute, join, normalize, resolve, sep } from "node:path";
|
|
7
7
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
8
|
import { homedir, platform, release } from "node:os";
|
|
@@ -69,6 +69,11 @@ function findProjectRoot(startDir) {
|
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
71
|
const projectRoot = findProjectRoot(_dirname);
|
|
72
|
+
const CacheFolder = {
|
|
73
|
+
Actions: "actions",
|
|
74
|
+
Pipelines: "pipelines",
|
|
75
|
+
Pacote: "pacote"
|
|
76
|
+
};
|
|
72
77
|
var PipelabContext = class {
|
|
73
78
|
userDataPath;
|
|
74
79
|
releaseTag;
|
|
@@ -85,20 +90,50 @@ var PipelabContext = class {
|
|
|
85
90
|
getConfigPath(...subpaths) {
|
|
86
91
|
return join(this.userDataPath, "config", ...subpaths);
|
|
87
92
|
}
|
|
93
|
+
getSettingsPath() {
|
|
94
|
+
return this.getConfigPath("settings.json");
|
|
95
|
+
}
|
|
96
|
+
getConnectionsPath() {
|
|
97
|
+
return this.getConfigPath("connections.json");
|
|
98
|
+
}
|
|
99
|
+
getProjectsPath() {
|
|
100
|
+
return this.getConfigPath("projects.json");
|
|
101
|
+
}
|
|
102
|
+
_cachedSettings = null;
|
|
103
|
+
_cachedSettingsTime = 0;
|
|
104
|
+
getSettings() {
|
|
105
|
+
const settingsPath = this.getSettingsPath();
|
|
106
|
+
if (!existsSync(settingsPath)) return null;
|
|
107
|
+
const now = Date.now();
|
|
108
|
+
if (this._cachedSettings && now - this._cachedSettingsTime < 2e3) return this._cachedSettings;
|
|
109
|
+
try {
|
|
110
|
+
const content = readFileSync(settingsPath, "utf8");
|
|
111
|
+
this._cachedSettings = JSON.parse(content);
|
|
112
|
+
this._cachedSettingsTime = now;
|
|
113
|
+
return this._cachedSettings;
|
|
114
|
+
} catch (e) {
|
|
115
|
+
return this._cachedSettings;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
88
118
|
getTempPath(...subpaths) {
|
|
89
|
-
return join(this.userDataPath, "temp", ...subpaths);
|
|
119
|
+
return join(this.getSettings()?.tempFolder || join(this.userDataPath, "temp"), ...subpaths);
|
|
90
120
|
}
|
|
91
121
|
async createTempFolder(prefix = "pipelab-") {
|
|
92
122
|
const baseDir = this.getTempPath();
|
|
93
123
|
await mkdir(baseDir, { recursive: true });
|
|
94
124
|
return await mkdtemp(join(await realpath(baseDir), prefix));
|
|
95
125
|
}
|
|
96
|
-
getCachePath(...subpaths) {
|
|
97
|
-
|
|
126
|
+
getCachePath(folder, ...subpaths) {
|
|
127
|
+
const base = this.getSettings()?.cacheFolder || join(this.userDataPath, "cache");
|
|
128
|
+
if (!folder) return base;
|
|
129
|
+
return join(base, folder, ...subpaths);
|
|
98
130
|
}
|
|
99
131
|
getPnpmPath(...subpaths) {
|
|
100
132
|
return join(this.userDataPath, "pnpm", ...subpaths);
|
|
101
133
|
}
|
|
134
|
+
getBuildHistoryPath(...subpaths) {
|
|
135
|
+
return join(this.userDataPath, "build-history", ...subpaths);
|
|
136
|
+
}
|
|
102
137
|
getNodePath(version = DEFAULT_NODE_VERSION) {
|
|
103
138
|
const isWindows = process.platform === "win32";
|
|
104
139
|
return this.getThirdPartyPath("node", version, isWindows ? "node.exe" : "bin/node");
|
|
@@ -4009,61 +4044,57 @@ const registerFsHandlers = (_context) => {
|
|
|
4009
4044
|
const registerConfigHandlers = (context) => {
|
|
4010
4045
|
const { handle } = useAPI();
|
|
4011
4046
|
const { logger } = useLogger();
|
|
4012
|
-
handle("
|
|
4013
|
-
|
|
4014
|
-
logger().info("config:load", name);
|
|
4047
|
+
handle("settings:load", async (_, { send }) => {
|
|
4048
|
+
logger().info("settings:load");
|
|
4015
4049
|
try {
|
|
4016
4050
|
send({
|
|
4017
4051
|
type: "end",
|
|
4018
4052
|
data: {
|
|
4019
4053
|
type: "success",
|
|
4020
|
-
result:
|
|
4054
|
+
result: await (await setupSettingsConfigFile(context)).getConfig()
|
|
4021
4055
|
}
|
|
4022
4056
|
});
|
|
4023
4057
|
} catch (e) {
|
|
4024
|
-
logger().error(
|
|
4058
|
+
logger().error("settings:load error:", e);
|
|
4025
4059
|
send({
|
|
4026
4060
|
type: "end",
|
|
4027
4061
|
data: {
|
|
4028
4062
|
type: "error",
|
|
4029
|
-
ipcError: e instanceof Error ? e.message :
|
|
4063
|
+
ipcError: e instanceof Error ? e.message : "Unable to load settings"
|
|
4030
4064
|
}
|
|
4031
4065
|
});
|
|
4032
4066
|
}
|
|
4033
4067
|
});
|
|
4034
|
-
handle("
|
|
4035
|
-
const { data
|
|
4068
|
+
handle("settings:save", async (_, { send, value }) => {
|
|
4069
|
+
const { data } = value;
|
|
4036
4070
|
try {
|
|
4037
|
-
const manager = await
|
|
4071
|
+
const manager = await setupSettingsConfigFile(context);
|
|
4038
4072
|
const json = typeof data === "string" ? JSON.parse(data) : data;
|
|
4039
4073
|
await manager.setConfig(json);
|
|
4040
4074
|
send({
|
|
4041
4075
|
type: "end",
|
|
4042
4076
|
data: {
|
|
4043
4077
|
type: "success",
|
|
4044
|
-
result:
|
|
4078
|
+
result: "ok"
|
|
4045
4079
|
}
|
|
4046
4080
|
});
|
|
4047
4081
|
} catch (e) {
|
|
4048
|
-
logger().error(
|
|
4082
|
+
logger().error("settings:save error:", e);
|
|
4049
4083
|
send({
|
|
4050
4084
|
type: "end",
|
|
4051
4085
|
data: {
|
|
4052
4086
|
type: "error",
|
|
4053
|
-
ipcError: e instanceof Error ? e.message :
|
|
4087
|
+
ipcError: e instanceof Error ? e.message : "Unable to save settings"
|
|
4054
4088
|
}
|
|
4055
4089
|
});
|
|
4056
4090
|
}
|
|
4057
4091
|
});
|
|
4058
|
-
handle("
|
|
4059
|
-
const {
|
|
4060
|
-
logger().info("config:reset", name, key);
|
|
4092
|
+
handle("settings:reset", async (_, { send, value }) => {
|
|
4093
|
+
const { key } = value;
|
|
4061
4094
|
try {
|
|
4062
|
-
const manager = await
|
|
4095
|
+
const manager = await setupSettingsConfigFile(context);
|
|
4063
4096
|
const currentConfig = await manager.getConfig();
|
|
4064
|
-
const
|
|
4065
|
-
if (!migrator) throw new Error(`No migrator found for configuration: ${name}`);
|
|
4066
|
-
const defaultValue = migrator.defaultValue[key];
|
|
4097
|
+
const defaultValue = appSettingsMigrator.defaultValue[key];
|
|
4067
4098
|
await manager.setConfig({
|
|
4068
4099
|
...currentConfig ? currentConfig : {},
|
|
4069
4100
|
[key]: defaultValue
|
|
@@ -4072,50 +4103,300 @@ const registerConfigHandlers = (context) => {
|
|
|
4072
4103
|
type: "end",
|
|
4073
4104
|
data: {
|
|
4074
4105
|
type: "success",
|
|
4075
|
-
result:
|
|
4106
|
+
result: "ok"
|
|
4076
4107
|
}
|
|
4077
4108
|
});
|
|
4078
4109
|
} catch (e) {
|
|
4079
|
-
logger().error(
|
|
4110
|
+
logger().error("settings:reset error:", e);
|
|
4080
4111
|
send({
|
|
4081
4112
|
type: "end",
|
|
4082
4113
|
data: {
|
|
4083
4114
|
type: "error",
|
|
4084
|
-
ipcError: e instanceof Error ? e.message :
|
|
4115
|
+
ipcError: e instanceof Error ? e.message : "Unable to reset settings"
|
|
4085
4116
|
}
|
|
4086
4117
|
});
|
|
4087
4118
|
}
|
|
4088
4119
|
});
|
|
4089
|
-
handle("
|
|
4090
|
-
|
|
4091
|
-
logger().info("config:delete", name);
|
|
4120
|
+
handle("connections:load", async (_, { send }) => {
|
|
4121
|
+
logger().info("connections:load");
|
|
4092
4122
|
try {
|
|
4093
|
-
const filesPath = path.isAbsolute(name) ? name : context.getConfigPath(`${name}.json`);
|
|
4094
|
-
await fs$1.rm(filesPath, { force: true });
|
|
4095
|
-
const parsedPath = path.parse(filesPath);
|
|
4096
|
-
const dirEntries = await fs$1.readdir(parsedPath.dir).catch(() => []);
|
|
4097
|
-
const prefix = `${parsedPath.name}.v`;
|
|
4098
|
-
const suffix = `.json`;
|
|
4099
|
-
for (const entry of dirEntries) if (entry.startsWith(prefix) && entry.endsWith(suffix)) {
|
|
4100
|
-
const backupPath = path.join(parsedPath.dir, entry);
|
|
4101
|
-
await fs$1.rm(backupPath, { force: true }).catch((err) => {
|
|
4102
|
-
logger().error(`Failed to delete backup ${backupPath}:`, err);
|
|
4103
|
-
});
|
|
4104
|
-
}
|
|
4105
4123
|
send({
|
|
4106
4124
|
type: "end",
|
|
4107
4125
|
data: {
|
|
4108
4126
|
type: "success",
|
|
4109
|
-
result:
|
|
4127
|
+
result: await (await setupConnectionsConfigFile(context)).getConfig()
|
|
4128
|
+
}
|
|
4129
|
+
});
|
|
4130
|
+
} catch (e) {
|
|
4131
|
+
logger().error("connections:load error:", e);
|
|
4132
|
+
send({
|
|
4133
|
+
type: "end",
|
|
4134
|
+
data: {
|
|
4135
|
+
type: "error",
|
|
4136
|
+
ipcError: e instanceof Error ? e.message : "Unable to load connections"
|
|
4137
|
+
}
|
|
4138
|
+
});
|
|
4139
|
+
}
|
|
4140
|
+
});
|
|
4141
|
+
handle("connections:save", async (_, { send, value }) => {
|
|
4142
|
+
const { data } = value;
|
|
4143
|
+
try {
|
|
4144
|
+
const manager = await setupConnectionsConfigFile(context);
|
|
4145
|
+
const json = typeof data === "string" ? JSON.parse(data) : data;
|
|
4146
|
+
await manager.setConfig(json);
|
|
4147
|
+
send({
|
|
4148
|
+
type: "end",
|
|
4149
|
+
data: {
|
|
4150
|
+
type: "success",
|
|
4151
|
+
result: "ok"
|
|
4152
|
+
}
|
|
4153
|
+
});
|
|
4154
|
+
} catch (e) {
|
|
4155
|
+
logger().error("connections:save error:", e);
|
|
4156
|
+
send({
|
|
4157
|
+
type: "end",
|
|
4158
|
+
data: {
|
|
4159
|
+
type: "error",
|
|
4160
|
+
ipcError: e instanceof Error ? e.message : "Unable to save connections"
|
|
4161
|
+
}
|
|
4162
|
+
});
|
|
4163
|
+
}
|
|
4164
|
+
});
|
|
4165
|
+
handle("connections:reset", async (_, { send, value }) => {
|
|
4166
|
+
const { key } = value;
|
|
4167
|
+
try {
|
|
4168
|
+
const manager = await setupConnectionsConfigFile(context);
|
|
4169
|
+
const currentConfig = await manager.getConfig();
|
|
4170
|
+
const defaultValue = connectionsMigrator.defaultValue[key];
|
|
4171
|
+
await manager.setConfig({
|
|
4172
|
+
...currentConfig ? currentConfig : {},
|
|
4173
|
+
[key]: defaultValue
|
|
4174
|
+
});
|
|
4175
|
+
send({
|
|
4176
|
+
type: "end",
|
|
4177
|
+
data: {
|
|
4178
|
+
type: "success",
|
|
4179
|
+
result: "ok"
|
|
4110
4180
|
}
|
|
4111
4181
|
});
|
|
4112
4182
|
} catch (e) {
|
|
4113
|
-
logger().error(
|
|
4183
|
+
logger().error("connections:reset error:", e);
|
|
4114
4184
|
send({
|
|
4115
4185
|
type: "end",
|
|
4116
4186
|
data: {
|
|
4117
4187
|
type: "error",
|
|
4118
|
-
ipcError: e instanceof Error ? e.message :
|
|
4188
|
+
ipcError: e instanceof Error ? e.message : "Unable to reset connections"
|
|
4189
|
+
}
|
|
4190
|
+
});
|
|
4191
|
+
}
|
|
4192
|
+
});
|
|
4193
|
+
handle("projects:load", async (_, { send }) => {
|
|
4194
|
+
logger().info("projects:load");
|
|
4195
|
+
try {
|
|
4196
|
+
send({
|
|
4197
|
+
type: "end",
|
|
4198
|
+
data: {
|
|
4199
|
+
type: "success",
|
|
4200
|
+
result: await (await setupProjectsConfigFile(context)).getConfig()
|
|
4201
|
+
}
|
|
4202
|
+
});
|
|
4203
|
+
} catch (e) {
|
|
4204
|
+
logger().error("projects:load error:", e);
|
|
4205
|
+
send({
|
|
4206
|
+
type: "end",
|
|
4207
|
+
data: {
|
|
4208
|
+
type: "error",
|
|
4209
|
+
ipcError: e instanceof Error ? e.message : "Unable to load projects"
|
|
4210
|
+
}
|
|
4211
|
+
});
|
|
4212
|
+
}
|
|
4213
|
+
});
|
|
4214
|
+
handle("projects:save", async (_, { send, value }) => {
|
|
4215
|
+
const { data } = value;
|
|
4216
|
+
try {
|
|
4217
|
+
const manager = await setupProjectsConfigFile(context);
|
|
4218
|
+
const json = typeof data === "string" ? JSON.parse(data) : data;
|
|
4219
|
+
await manager.setConfig(json);
|
|
4220
|
+
send({
|
|
4221
|
+
type: "end",
|
|
4222
|
+
data: {
|
|
4223
|
+
type: "success",
|
|
4224
|
+
result: "ok"
|
|
4225
|
+
}
|
|
4226
|
+
});
|
|
4227
|
+
} catch (e) {
|
|
4228
|
+
logger().error("projects:save error:", e);
|
|
4229
|
+
send({
|
|
4230
|
+
type: "end",
|
|
4231
|
+
data: {
|
|
4232
|
+
type: "error",
|
|
4233
|
+
ipcError: e instanceof Error ? e.message : "Unable to save projects"
|
|
4234
|
+
}
|
|
4235
|
+
});
|
|
4236
|
+
}
|
|
4237
|
+
});
|
|
4238
|
+
handle("projects:reset", async (_, { send, value }) => {
|
|
4239
|
+
const { key } = value;
|
|
4240
|
+
try {
|
|
4241
|
+
const manager = await setupProjectsConfigFile(context);
|
|
4242
|
+
const currentConfig = await manager.getConfig();
|
|
4243
|
+
const defaultValue = fileRepoMigrations.defaultValue[key];
|
|
4244
|
+
await manager.setConfig({
|
|
4245
|
+
...currentConfig ? currentConfig : {},
|
|
4246
|
+
[key]: defaultValue
|
|
4247
|
+
});
|
|
4248
|
+
send({
|
|
4249
|
+
type: "end",
|
|
4250
|
+
data: {
|
|
4251
|
+
type: "success",
|
|
4252
|
+
result: "ok"
|
|
4253
|
+
}
|
|
4254
|
+
});
|
|
4255
|
+
} catch (e) {
|
|
4256
|
+
logger().error("projects:reset error:", e);
|
|
4257
|
+
send({
|
|
4258
|
+
type: "end",
|
|
4259
|
+
data: {
|
|
4260
|
+
type: "error",
|
|
4261
|
+
ipcError: e instanceof Error ? e.message : "Unable to reset projects"
|
|
4262
|
+
}
|
|
4263
|
+
});
|
|
4264
|
+
}
|
|
4265
|
+
});
|
|
4266
|
+
handle("pipeline:load-by-name", async (_, { send, value }) => {
|
|
4267
|
+
const { name } = value;
|
|
4268
|
+
logger().info("pipeline:load-by-name", name);
|
|
4269
|
+
try {
|
|
4270
|
+
send({
|
|
4271
|
+
type: "end",
|
|
4272
|
+
data: {
|
|
4273
|
+
type: "success",
|
|
4274
|
+
result: await (await setupPipelineConfigFileByName(name, context)).getConfig()
|
|
4275
|
+
}
|
|
4276
|
+
});
|
|
4277
|
+
} catch (e) {
|
|
4278
|
+
logger().error(`pipeline:load-by-name error for ${name}:`, e);
|
|
4279
|
+
send({
|
|
4280
|
+
type: "end",
|
|
4281
|
+
data: {
|
|
4282
|
+
type: "error",
|
|
4283
|
+
ipcError: e instanceof Error ? e.message : `Unable to load pipeline ${name}`
|
|
4284
|
+
}
|
|
4285
|
+
});
|
|
4286
|
+
}
|
|
4287
|
+
});
|
|
4288
|
+
handle("pipeline:load-by-path", async (_, { send, value }) => {
|
|
4289
|
+
const { path: absolutePath } = value;
|
|
4290
|
+
logger().info("pipeline:load-by-path", absolutePath);
|
|
4291
|
+
try {
|
|
4292
|
+
send({
|
|
4293
|
+
type: "end",
|
|
4294
|
+
data: {
|
|
4295
|
+
type: "success",
|
|
4296
|
+
result: await (await setupPipelineConfigFileByPath(absolutePath, context)).getConfig()
|
|
4297
|
+
}
|
|
4298
|
+
});
|
|
4299
|
+
} catch (e) {
|
|
4300
|
+
logger().error(`pipeline:load-by-path error for ${absolutePath}:`, e);
|
|
4301
|
+
send({
|
|
4302
|
+
type: "end",
|
|
4303
|
+
data: {
|
|
4304
|
+
type: "error",
|
|
4305
|
+
ipcError: e instanceof Error ? e.message : `Unable to load pipeline ${absolutePath}`
|
|
4306
|
+
}
|
|
4307
|
+
});
|
|
4308
|
+
}
|
|
4309
|
+
});
|
|
4310
|
+
handle("pipeline:save-by-name", async (_, { send, value }) => {
|
|
4311
|
+
const { data, name } = value;
|
|
4312
|
+
try {
|
|
4313
|
+
const manager = await setupPipelineConfigFileByName(name, context);
|
|
4314
|
+
const json = typeof data === "string" ? JSON.parse(data) : data;
|
|
4315
|
+
await manager.setConfig(json);
|
|
4316
|
+
send({
|
|
4317
|
+
type: "end",
|
|
4318
|
+
data: {
|
|
4319
|
+
type: "success",
|
|
4320
|
+
result: "ok"
|
|
4321
|
+
}
|
|
4322
|
+
});
|
|
4323
|
+
} catch (e) {
|
|
4324
|
+
logger().error(`pipeline:save-by-name error for ${name}:`, e);
|
|
4325
|
+
send({
|
|
4326
|
+
type: "end",
|
|
4327
|
+
data: {
|
|
4328
|
+
type: "error",
|
|
4329
|
+
ipcError: e instanceof Error ? e.message : `Unable to save pipeline ${name}`
|
|
4330
|
+
}
|
|
4331
|
+
});
|
|
4332
|
+
}
|
|
4333
|
+
});
|
|
4334
|
+
handle("pipeline:save-by-path", async (_, { send, value }) => {
|
|
4335
|
+
const { data, path: absolutePath } = value;
|
|
4336
|
+
try {
|
|
4337
|
+
const manager = await setupPipelineConfigFileByPath(absolutePath, context);
|
|
4338
|
+
const json = typeof data === "string" ? JSON.parse(data) : data;
|
|
4339
|
+
await manager.setConfig(json);
|
|
4340
|
+
send({
|
|
4341
|
+
type: "end",
|
|
4342
|
+
data: {
|
|
4343
|
+
type: "success",
|
|
4344
|
+
result: "ok"
|
|
4345
|
+
}
|
|
4346
|
+
});
|
|
4347
|
+
} catch (e) {
|
|
4348
|
+
logger().error(`pipeline:save-by-path error for ${absolutePath}:`, e);
|
|
4349
|
+
send({
|
|
4350
|
+
type: "end",
|
|
4351
|
+
data: {
|
|
4352
|
+
type: "error",
|
|
4353
|
+
ipcError: e instanceof Error ? e.message : `Unable to save pipeline ${absolutePath}`
|
|
4354
|
+
}
|
|
4355
|
+
});
|
|
4356
|
+
}
|
|
4357
|
+
});
|
|
4358
|
+
handle("pipeline:delete-by-name", async (_, { send, value }) => {
|
|
4359
|
+
const { name } = value;
|
|
4360
|
+
logger().info("pipeline:delete-by-name", name);
|
|
4361
|
+
try {
|
|
4362
|
+
await deletePipelineConfigFileByName(name, context);
|
|
4363
|
+
send({
|
|
4364
|
+
type: "end",
|
|
4365
|
+
data: {
|
|
4366
|
+
type: "success",
|
|
4367
|
+
result: "ok"
|
|
4368
|
+
}
|
|
4369
|
+
});
|
|
4370
|
+
} catch (e) {
|
|
4371
|
+
logger().error(`pipeline:delete-by-name error for ${name}:`, e);
|
|
4372
|
+
send({
|
|
4373
|
+
type: "end",
|
|
4374
|
+
data: {
|
|
4375
|
+
type: "error",
|
|
4376
|
+
ipcError: e instanceof Error ? e.message : `Unable to delete pipeline ${name}`
|
|
4377
|
+
}
|
|
4378
|
+
});
|
|
4379
|
+
}
|
|
4380
|
+
});
|
|
4381
|
+
handle("pipeline:delete-by-path", async (_, { send, value }) => {
|
|
4382
|
+
const { path: absolutePath } = value;
|
|
4383
|
+
logger().info("pipeline:delete-by-path", absolutePath);
|
|
4384
|
+
try {
|
|
4385
|
+
await deletePipelineConfigFileByPath(absolutePath, context);
|
|
4386
|
+
send({
|
|
4387
|
+
type: "end",
|
|
4388
|
+
data: {
|
|
4389
|
+
type: "success",
|
|
4390
|
+
result: "ok"
|
|
4391
|
+
}
|
|
4392
|
+
});
|
|
4393
|
+
} catch (e) {
|
|
4394
|
+
logger().error(`pipeline:delete-by-path error for ${absolutePath}:`, e);
|
|
4395
|
+
send({
|
|
4396
|
+
type: "end",
|
|
4397
|
+
data: {
|
|
4398
|
+
type: "error",
|
|
4399
|
+
ipcError: e instanceof Error ? e.message : `Unable to delete pipeline ${absolutePath}`
|
|
4119
4400
|
}
|
|
4120
4401
|
});
|
|
4121
4402
|
}
|
|
@@ -4284,11 +4565,10 @@ var BuildHistoryStorage = class {
|
|
|
4284
4565
|
this.context = context;
|
|
4285
4566
|
}
|
|
4286
4567
|
getStoragePath() {
|
|
4287
|
-
return
|
|
4568
|
+
return this.context.getConfigPath("pipelines");
|
|
4288
4569
|
}
|
|
4289
4570
|
getPipelinePath(pipelineId) {
|
|
4290
|
-
|
|
4291
|
-
return join(this.getStoragePath(), `pipeline-${sanitizedId}.json`);
|
|
4571
|
+
return join(this.getStoragePath(), `${pipelineId}.history.json`);
|
|
4292
4572
|
}
|
|
4293
4573
|
async ensureStoragePath() {
|
|
4294
4574
|
try {
|
|
@@ -4315,35 +4595,6 @@ var BuildHistoryStorage = class {
|
|
|
4315
4595
|
throw new Error(`Failed to save pipeline history: ${error}`);
|
|
4316
4596
|
}
|
|
4317
4597
|
}
|
|
4318
|
-
async applyRetentionPolicy() {
|
|
4319
|
-
try {
|
|
4320
|
-
this.logger.logger().info("Applying build history retention policy...");
|
|
4321
|
-
const policy = (await (await setupConfigFile("settings", { context: this.context })).getConfig())?.buildHistory?.retentionPolicy;
|
|
4322
|
-
if (!policy || !policy.enabled) {
|
|
4323
|
-
this.logger.logger().info("Retention policy is disabled. Skipping.");
|
|
4324
|
-
return;
|
|
4325
|
-
}
|
|
4326
|
-
const { maxAge, maxEntries } = policy;
|
|
4327
|
-
const pipelineFiles = await this.getAllPipelineFiles();
|
|
4328
|
-
for (const file of pipelineFiles) {
|
|
4329
|
-
const pipelineId = file.replace("pipeline-", "").replace(".json", "");
|
|
4330
|
-
let entries = await this.loadPipelineHistory(pipelineId);
|
|
4331
|
-
const originalCount = entries.length;
|
|
4332
|
-
if (maxAge > 0) {
|
|
4333
|
-
const minDate = Date.now() - maxAge * 24 * 60 * 60 * 1e3;
|
|
4334
|
-
entries = entries.filter((entry) => entry.createdAt >= minDate);
|
|
4335
|
-
}
|
|
4336
|
-
if (maxEntries > 0 && entries.length > maxEntries) entries = entries.sort((a, b) => b.createdAt - a.createdAt).slice(0, maxEntries);
|
|
4337
|
-
if (entries.length < originalCount) {
|
|
4338
|
-
this.logger.logger().info(`[${pipelineId}] Pruned ${originalCount - entries.length} history entries.`);
|
|
4339
|
-
await this.savePipelineHistory(pipelineId, entries);
|
|
4340
|
-
}
|
|
4341
|
-
}
|
|
4342
|
-
this.logger.logger().info("Retention policy applied successfully.");
|
|
4343
|
-
} catch (error) {
|
|
4344
|
-
this.logger.logger().error("Failed to apply retention policy:", error);
|
|
4345
|
-
}
|
|
4346
|
-
}
|
|
4347
4598
|
async save(entry) {
|
|
4348
4599
|
try {
|
|
4349
4600
|
const entries = await this.loadPipelineHistory(entry.pipelineId);
|
|
@@ -4352,9 +4603,6 @@ var BuildHistoryStorage = class {
|
|
|
4352
4603
|
else entries.push(entry);
|
|
4353
4604
|
await this.savePipelineHistory(entry.pipelineId, entries);
|
|
4354
4605
|
this.logger.logger().info(`Saved build history entry: ${entry.id} for pipeline: ${entry.pipelineId}`);
|
|
4355
|
-
this.applyRetentionPolicy().catch((err) => {
|
|
4356
|
-
this.logger.logger().error("Failed to apply retention policy after save:", err);
|
|
4357
|
-
});
|
|
4358
4606
|
} catch (error) {
|
|
4359
4607
|
this.logger.logger().error("Failed to save build history entry:", error);
|
|
4360
4608
|
throw new Error(`Failed to save build history entry: ${error}`);
|
|
@@ -4365,7 +4613,8 @@ var BuildHistoryStorage = class {
|
|
|
4365
4613
|
if (pipelineId) return (await this.loadPipelineHistory(pipelineId)).find((e) => e.id === id);
|
|
4366
4614
|
const files = await this.getAllPipelineFiles();
|
|
4367
4615
|
for (const file of files) {
|
|
4368
|
-
const pId =
|
|
4616
|
+
const pId = this.parsePipelineIdFromFilename(file);
|
|
4617
|
+
if (!pId) continue;
|
|
4369
4618
|
const entry = (await this.loadPipelineHistory(pId)).find((e) => e.id === id);
|
|
4370
4619
|
if (entry) return entry;
|
|
4371
4620
|
}
|
|
@@ -4380,7 +4629,8 @@ var BuildHistoryStorage = class {
|
|
|
4380
4629
|
const files = await this.getAllPipelineFiles();
|
|
4381
4630
|
const allEntries = [];
|
|
4382
4631
|
for (const file of files) {
|
|
4383
|
-
const pipelineId =
|
|
4632
|
+
const pipelineId = this.parsePipelineIdFromFilename(file);
|
|
4633
|
+
if (!pipelineId) continue;
|
|
4384
4634
|
const entries = await this.loadPipelineHistory(pipelineId);
|
|
4385
4635
|
allEntries.push(...entries);
|
|
4386
4636
|
}
|
|
@@ -4415,7 +4665,8 @@ var BuildHistoryStorage = class {
|
|
|
4415
4665
|
} else {
|
|
4416
4666
|
const files = await this.getAllPipelineFiles();
|
|
4417
4667
|
for (const file of files) {
|
|
4418
|
-
const pId =
|
|
4668
|
+
const pId = this.parsePipelineIdFromFilename(file);
|
|
4669
|
+
if (!pId) continue;
|
|
4419
4670
|
const entries = await this.loadPipelineHistory(pId);
|
|
4420
4671
|
const entryIndex = entries.findIndex((e) => e.id === id);
|
|
4421
4672
|
if (entryIndex >= 0) {
|
|
@@ -4449,7 +4700,8 @@ var BuildHistoryStorage = class {
|
|
|
4449
4700
|
} else {
|
|
4450
4701
|
const files = await this.getAllPipelineFiles();
|
|
4451
4702
|
for (const file of files) {
|
|
4452
|
-
const pId =
|
|
4703
|
+
const pId = this.parsePipelineIdFromFilename(file);
|
|
4704
|
+
if (!pId) continue;
|
|
4453
4705
|
const entries = await this.loadPipelineHistory(pId);
|
|
4454
4706
|
const entryIndex = entries.findIndex((e) => e.id === id);
|
|
4455
4707
|
if (entryIndex >= 0) {
|
|
@@ -4470,8 +4722,20 @@ var BuildHistoryStorage = class {
|
|
|
4470
4722
|
try {
|
|
4471
4723
|
await this.ensureStoragePath();
|
|
4472
4724
|
const files = await this.getAllPipelineFiles();
|
|
4473
|
-
|
|
4725
|
+
const cachePathsToDelete = /* @__PURE__ */ new Set();
|
|
4726
|
+
for (const file of files) {
|
|
4727
|
+
const pipelineId = this.parsePipelineIdFromFilename(file);
|
|
4728
|
+
if (pipelineId) {
|
|
4729
|
+
const entries = await this.loadPipelineHistory(pipelineId);
|
|
4730
|
+
for (const entry of entries) if (entry.cachePath) cachePathsToDelete.add(entry.cachePath);
|
|
4731
|
+
}
|
|
4732
|
+
await unlink(join(this.getStoragePath(), file));
|
|
4733
|
+
}
|
|
4474
4734
|
this.logger.logger().info("Cleared all build history");
|
|
4735
|
+
for (const cachePath of cachePathsToDelete) await rm(cachePath, {
|
|
4736
|
+
recursive: true,
|
|
4737
|
+
force: true
|
|
4738
|
+
}).catch(() => {});
|
|
4475
4739
|
} catch (error) {
|
|
4476
4740
|
this.logger.logger().error("Failed to clear build history:", error);
|
|
4477
4741
|
throw new Error(`Failed to clear build history: ${error}`);
|
|
@@ -4479,8 +4743,16 @@ var BuildHistoryStorage = class {
|
|
|
4479
4743
|
}
|
|
4480
4744
|
async clearByPipeline(pipelineId) {
|
|
4481
4745
|
try {
|
|
4482
|
-
|
|
4746
|
+
const pipelinePath = this.getPipelinePath(pipelineId);
|
|
4747
|
+
const entries = await this.loadPipelineHistory(pipelineId);
|
|
4748
|
+
await unlink(pipelinePath);
|
|
4483
4749
|
this.logger.logger().info(`Cleared history for pipeline "${pipelineId}"`);
|
|
4750
|
+
const cachePathsToDelete = /* @__PURE__ */ new Set();
|
|
4751
|
+
for (const entry of entries) if (entry.cachePath) cachePathsToDelete.add(entry.cachePath);
|
|
4752
|
+
for (const cachePath of cachePathsToDelete) await rm(cachePath, {
|
|
4753
|
+
recursive: true,
|
|
4754
|
+
force: true
|
|
4755
|
+
}).catch(() => {});
|
|
4484
4756
|
} catch (error) {
|
|
4485
4757
|
if (error.code === "ENOENT") {
|
|
4486
4758
|
this.logger.logger().warn(`No history file found for pipeline "${pipelineId}". Nothing to clear.`);
|
|
@@ -4505,21 +4777,11 @@ var BuildHistoryStorage = class {
|
|
|
4505
4777
|
size
|
|
4506
4778
|
});
|
|
4507
4779
|
}
|
|
4508
|
-
const policy = (await (await setupConfigFile("settings", { context: this.context })).getConfig())?.buildHistory?.retentionPolicy || {
|
|
4509
|
-
enabled: false,
|
|
4510
|
-
maxEntries: 50,
|
|
4511
|
-
maxAge: 30
|
|
4512
|
-
};
|
|
4513
4780
|
if (allEntries.length === 0) return {
|
|
4514
4781
|
totalEntries: 0,
|
|
4515
4782
|
totalSize: 0,
|
|
4516
4783
|
numberOfPipelines: files.length,
|
|
4517
4784
|
userDataPath: this.context.userDataPath,
|
|
4518
|
-
retentionPolicy: {
|
|
4519
|
-
enabled: policy.enabled,
|
|
4520
|
-
maxEntries: policy.maxEntries,
|
|
4521
|
-
maxAge: policy.maxAge
|
|
4522
|
-
},
|
|
4523
4785
|
disk: {
|
|
4524
4786
|
total: diskSpace.size,
|
|
4525
4787
|
free: diskSpace.free,
|
|
@@ -4544,11 +4806,6 @@ var BuildHistoryStorage = class {
|
|
|
4544
4806
|
newestEntry: sortedEntries[sortedEntries.length - 1]?.createdAt,
|
|
4545
4807
|
numberOfPipelines: files.length,
|
|
4546
4808
|
userDataPath: this.context.userDataPath,
|
|
4547
|
-
retentionPolicy: {
|
|
4548
|
-
enabled: policy.enabled,
|
|
4549
|
-
maxEntries: policy.maxEntries,
|
|
4550
|
-
maxAge: policy.maxAge
|
|
4551
|
-
},
|
|
4552
4809
|
disk: {
|
|
4553
4810
|
total: diskSpace.size,
|
|
4554
4811
|
free: diskSpace.free,
|
|
@@ -4564,11 +4821,15 @@ var BuildHistoryStorage = class {
|
|
|
4564
4821
|
async getAllPipelineFiles() {
|
|
4565
4822
|
try {
|
|
4566
4823
|
await this.ensureStoragePath();
|
|
4567
|
-
return (await readdir(this.getStoragePath())).filter((file) => file.
|
|
4824
|
+
return (await readdir(this.getStoragePath())).filter((file) => file.endsWith(".history.json"));
|
|
4568
4825
|
} catch (error) {
|
|
4569
4826
|
return [];
|
|
4570
4827
|
}
|
|
4571
4828
|
}
|
|
4829
|
+
parsePipelineIdFromFilename(filename) {
|
|
4830
|
+
const match = filename.match(/^(.+)\.history\.json$/);
|
|
4831
|
+
return match ? match[1] : null;
|
|
4832
|
+
}
|
|
4572
4833
|
};
|
|
4573
4834
|
//#endregion
|
|
4574
4835
|
//#region ../../packages/core-node/src/handlers/history.ts
|
|
@@ -4850,40 +5111,6 @@ const registerHistoryHandlers = (context) => {
|
|
|
4850
5111
|
});
|
|
4851
5112
|
}
|
|
4852
5113
|
});
|
|
4853
|
-
handle("build-history:configure", async (_, { send, value }) => {
|
|
4854
|
-
try {
|
|
4855
|
-
logger().info("Updating build history configuration:", value.config);
|
|
4856
|
-
const settings = await setupConfigFile("settings", { context });
|
|
4857
|
-
const currentConfig = await settings.getConfig();
|
|
4858
|
-
const newConfig = {
|
|
4859
|
-
...currentConfig,
|
|
4860
|
-
buildHistory: {
|
|
4861
|
-
...currentConfig?.buildHistory,
|
|
4862
|
-
retentionPolicy: {
|
|
4863
|
-
...currentConfig?.buildHistory?.retentionPolicy,
|
|
4864
|
-
...value.config.retentionPolicy
|
|
4865
|
-
}
|
|
4866
|
-
}
|
|
4867
|
-
};
|
|
4868
|
-
await settings.setConfig(newConfig);
|
|
4869
|
-
send({
|
|
4870
|
-
type: "end",
|
|
4871
|
-
data: {
|
|
4872
|
-
type: "success",
|
|
4873
|
-
result: { result: "ok" }
|
|
4874
|
-
}
|
|
4875
|
-
});
|
|
4876
|
-
} catch (error) {
|
|
4877
|
-
logger().error("Failed to configure build history:", error);
|
|
4878
|
-
send({
|
|
4879
|
-
type: "end",
|
|
4880
|
-
data: {
|
|
4881
|
-
type: "error",
|
|
4882
|
-
ipcError: error instanceof Error ? error.message : "Failed to configure build history"
|
|
4883
|
-
}
|
|
4884
|
-
});
|
|
4885
|
-
}
|
|
4886
|
-
});
|
|
4887
5114
|
};
|
|
4888
5115
|
//#endregion
|
|
4889
5116
|
//#region ../../node_modules/@npmcli/package-json/node_modules/json-parse-even-better-errors/lib/index.js
|
|
@@ -66052,8 +66279,8 @@ var require_error$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66052
66279
|
})();
|
|
66053
66280
|
}));
|
|
66054
66281
|
//#endregion
|
|
66055
|
-
//#region ../../
|
|
66056
|
-
var
|
|
66282
|
+
//#region ../../node_modules/serve-handler/src/index.js
|
|
66283
|
+
var require_src$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
66057
66284
|
const { promisify: promisify$1 } = __require("util");
|
|
66058
66285
|
const path$3 = __require("path");
|
|
66059
66286
|
const { createHash } = __require("crypto");
|
|
@@ -66505,47 +66732,12 @@ var import_src$1 = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((expo
|
|
|
66505
66732
|
response.writeHead(response.statusCode || 200, headers);
|
|
66506
66733
|
stream.pipe(response);
|
|
66507
66734
|
};
|
|
66508
|
-
}))
|
|
66509
|
-
var import_semver = /* @__PURE__ */ __toESM(require_semver(), 1);
|
|
66510
|
-
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
66511
|
-
/**
|
|
66512
|
-
* Registers migration handlers for the CLI/Standalone server.
|
|
66513
|
-
* This overrides the default handlers from @pipelab/core-node to include
|
|
66514
|
-
* pipeline and file repo migrations directly in the backend.
|
|
66515
|
-
*/
|
|
66516
|
-
function registerMigrationHandlers(context) {
|
|
66517
|
-
const { handle } = useAPI();
|
|
66518
|
-
const { logger } = useLogger();
|
|
66519
|
-
handle("config:load", async (_, { send, value }) => {
|
|
66520
|
-
const { config: name } = value;
|
|
66521
|
-
logger().info("[CLI Migration] config:load", name);
|
|
66522
|
-
try {
|
|
66523
|
-
const migrator = getMigrator(name);
|
|
66524
|
-
if (!migrator) throw new Error(`No migrator found for configuration: ${name}. All files loaded via config:load MUST have a migration schema.`);
|
|
66525
|
-
send({
|
|
66526
|
-
type: "end",
|
|
66527
|
-
data: {
|
|
66528
|
-
type: "success",
|
|
66529
|
-
result: { result: await (await setupConfigFile(name, {
|
|
66530
|
-
context,
|
|
66531
|
-
migrator
|
|
66532
|
-
})).getConfig() }
|
|
66533
|
-
}
|
|
66534
|
-
});
|
|
66535
|
-
} catch (e) {
|
|
66536
|
-
logger().error(`[CLI Migration] config:load error for ${name}:`, e);
|
|
66537
|
-
send({
|
|
66538
|
-
type: "end",
|
|
66539
|
-
data: {
|
|
66540
|
-
type: "error",
|
|
66541
|
-
ipcError: e instanceof Error ? e.message : `Unable to load config ${name}`
|
|
66542
|
-
}
|
|
66543
|
-
});
|
|
66544
|
-
}
|
|
66545
|
-
});
|
|
66546
|
-
}
|
|
66735
|
+
}));
|
|
66547
66736
|
//#endregion
|
|
66548
66737
|
//#region ../../packages/core-node/src/server.ts
|
|
66738
|
+
var import_semver = /* @__PURE__ */ __toESM(require_semver(), 1);
|
|
66739
|
+
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
66740
|
+
var import_src$1 = /* @__PURE__ */ __toESM(require_src$1(), 1);
|
|
66549
66741
|
const sendStartupProgress = (message) => {
|
|
66550
66742
|
console.log(`[Startup Progress] ${message}`);
|
|
66551
66743
|
webSocketServer.broadcast("startup:progress", {
|
|
@@ -66601,7 +66793,13 @@ async function serveCommand(options, version, _dirname) {
|
|
|
66601
66793
|
response.end(`Error: UI directory not found at ${rawAssetFolder}.\nPlease run 'pnpm build' in apps/ui to generate the distribution.`);
|
|
66602
66794
|
return;
|
|
66603
66795
|
}
|
|
66604
|
-
return (0, import_src$1.default)(request, response, {
|
|
66796
|
+
return (0, import_src$1.default)(request, response, {
|
|
66797
|
+
public: rawAssetFolder,
|
|
66798
|
+
rewrites: [{
|
|
66799
|
+
source: "/**",
|
|
66800
|
+
destination: "/index.html"
|
|
66801
|
+
}]
|
|
66802
|
+
});
|
|
66605
66803
|
});
|
|
66606
66804
|
console.log(`Starting Pipelab server on port ${options.port}...`);
|
|
66607
66805
|
console.log(`UI available at http://localhost:${options.port}`);
|
|
@@ -66610,7 +66808,6 @@ async function serveCommand(options, version, _dirname) {
|
|
|
66610
66808
|
version,
|
|
66611
66809
|
context
|
|
66612
66810
|
});
|
|
66613
|
-
registerMigrationHandlers(context);
|
|
66614
66811
|
sendStartupReady();
|
|
66615
66812
|
return server;
|
|
66616
66813
|
}
|
|
@@ -66692,7 +66889,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
|
|
|
66692
66889
|
console.log(`[Fetcher] ${packageName}: Resolved to local fallback ${resolvedVersion} (${Date.now() - fallbackStart}ms)`);
|
|
66693
66890
|
} else throw new Error(`Offline and no local fallback version available for ${packageName}`);
|
|
66694
66891
|
} else try {
|
|
66695
|
-
const cachePath =
|
|
66892
|
+
const cachePath = ctx.getCachePath(CacheFolder.Pacote);
|
|
66696
66893
|
let packumentPromise = packumentRequests.get(packageName);
|
|
66697
66894
|
if (!packumentPromise) {
|
|
66698
66895
|
packumentPromise = import_lib.default.packument(packageName, { cache: cachePath });
|
|
@@ -66723,7 +66920,7 @@ async function fetchPackage(packageName, versionOrRange, options) {
|
|
|
66723
66920
|
console.log(`[Fetcher] ${packageName}: Resolved to local fallback ${resolvedVersion} (${Date.now() - fallbackStart}ms)`);
|
|
66724
66921
|
} else throw error;
|
|
66725
66922
|
}
|
|
66726
|
-
const cachePath =
|
|
66923
|
+
const cachePath = ctx.getCachePath(CacheFolder.Pacote);
|
|
66727
66924
|
const packageDir = join(baseDir, resolvedVersion);
|
|
66728
66925
|
const checkStart = Date.now();
|
|
66729
66926
|
const isInstalled = options?.installDeps ? isPackageComplete(packageDir) && isDependenciesInstalledSync(packageDir) : isPackageComplete(packageDir);
|
|
@@ -66800,7 +66997,7 @@ async function runPnpm(cwd, options) {
|
|
|
66800
66997
|
...process.env,
|
|
66801
66998
|
NODE_ENV: "production",
|
|
66802
66999
|
PATH: nodePath ? `${dirname(nodePath)}${delimiter}${process.env.PATH}` : process.env.PATH,
|
|
66803
|
-
PNPM_HOME:
|
|
67000
|
+
PNPM_HOME: ctx.getPnpmPath(),
|
|
66804
67001
|
PNPM_ONLY_ALLOW_TRUSTED_DEPENDENCIES: "false",
|
|
66805
67002
|
...extraEnv
|
|
66806
67003
|
}
|
|
@@ -67219,9 +67416,9 @@ const builtInPlugins = async (options) => {
|
|
|
67219
67416
|
const envStart = Date.now();
|
|
67220
67417
|
await Promise.all([ensureNodeJS(options.context), ensurePNPM(options.context)]);
|
|
67221
67418
|
console.log(`[Plugins] Environment preparation took ${Date.now() - envStart}ms`);
|
|
67222
|
-
const { usePlugins } = await import("./src-
|
|
67419
|
+
const { usePlugins } = await import("./src-DU3j_v2A.mjs");
|
|
67223
67420
|
const { registerPlugins } = usePlugins();
|
|
67224
|
-
const { webSocketServer } = await import("./src-
|
|
67421
|
+
const { webSocketServer } = await import("./src-5EzZR-UT.mjs");
|
|
67225
67422
|
webSocketServer.broadcast("startup:progress", { type: "ready" });
|
|
67226
67423
|
(async () => {
|
|
67227
67424
|
const totalStart = Date.now();
|
|
@@ -67241,8 +67438,8 @@ const builtInPlugins = async (options) => {
|
|
|
67241
67438
|
"@pipelab/plugin-netlify"
|
|
67242
67439
|
]) pluginsToLoad.set(name, "latest");
|
|
67243
67440
|
try {
|
|
67244
|
-
const {
|
|
67245
|
-
const settingsPlugins = (await (await
|
|
67441
|
+
const { setupSettingsConfigFile } = await import("./config-B-M_kmKR.mjs");
|
|
67442
|
+
const settingsPlugins = (await (await setupSettingsConfigFile(options.context)).getConfig())?.plugins || [];
|
|
67246
67443
|
for (const plugin of settingsPlugins) if (plugin.name) if (plugin.enabled) {
|
|
67247
67444
|
if (!pluginsToLoad.has(plugin.name)) pluginsToLoad.set(plugin.name, "latest");
|
|
67248
67445
|
} else pluginsToLoad.delete(plugin.name);
|
|
@@ -67312,6 +67509,7 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
|
|
|
67312
67509
|
projectName,
|
|
67313
67510
|
projectPath,
|
|
67314
67511
|
pipelineId,
|
|
67512
|
+
cachePath,
|
|
67315
67513
|
startTime,
|
|
67316
67514
|
status: "running",
|
|
67317
67515
|
logs: [],
|
|
@@ -67340,7 +67538,7 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
|
|
|
67340
67538
|
} else logger().error(`[Runner] Failed to load or register plugin "${pluginId}"`);
|
|
67341
67539
|
}
|
|
67342
67540
|
logger().info(`[Sandbox] Execution sandbox created at: ${sandboxPath}`);
|
|
67343
|
-
await (await
|
|
67541
|
+
await (await setupSettingsConfigFile(ctx)).getConfig();
|
|
67344
67542
|
try {
|
|
67345
67543
|
const result = await processGraph({
|
|
67346
67544
|
graph,
|
|
@@ -67408,7 +67606,6 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
|
|
|
67408
67606
|
}, pipelineId);
|
|
67409
67607
|
throw error;
|
|
67410
67608
|
} finally {
|
|
67411
|
-
if (!shouldDisableHistory) buildHistoryStorage.applyRetentionPolicy();
|
|
67412
67609
|
try {
|
|
67413
67610
|
await rm(sandboxPath, {
|
|
67414
67611
|
recursive: true,
|
|
@@ -67417,6 +67614,14 @@ const executeGraphWithHistory = async ({ graph, variables, projectName, projectP
|
|
|
67417
67614
|
} catch (e) {
|
|
67418
67615
|
console.warn(`Failed to cleanup sandbox at ${sandboxPath}:`, e);
|
|
67419
67616
|
}
|
|
67617
|
+
try {
|
|
67618
|
+
await rm(cachePath, {
|
|
67619
|
+
recursive: true,
|
|
67620
|
+
force: true
|
|
67621
|
+
});
|
|
67622
|
+
} catch (e) {
|
|
67623
|
+
console.warn(`Failed to cleanup cache at ${cachePath}:`, e);
|
|
67624
|
+
}
|
|
67420
67625
|
}
|
|
67421
67626
|
};
|
|
67422
67627
|
//#endregion
|
|
@@ -67792,24 +67997,32 @@ const registerEngineHandlers = (context) => {
|
|
|
67792
67997
|
};
|
|
67793
67998
|
handle("action:execute", async (event, { send, value }) => {
|
|
67794
67999
|
const { nodeId, params, pluginId } = value;
|
|
67795
|
-
|
|
67796
|
-
const cachePath = join(context.userDataPath, "cache", "actions", pluginId, nodeId);
|
|
68000
|
+
const cachePath = context.getCachePath(CacheFolder.Actions, pluginId, nodeId);
|
|
67797
68001
|
const cwd = await context.createTempFolder("action-execute-");
|
|
67798
|
-
|
|
67799
|
-
|
|
67800
|
-
|
|
67801
|
-
|
|
67802
|
-
|
|
67803
|
-
|
|
67804
|
-
|
|
67805
|
-
|
|
67806
|
-
|
|
67807
|
-
|
|
68002
|
+
try {
|
|
68003
|
+
const mainWindow = void 0;
|
|
68004
|
+
abortControllerGraph = new AbortController();
|
|
68005
|
+
const signalPromise = new Promise((resolve, reject) => {
|
|
68006
|
+
abortControllerGraph.signal.addEventListener("abort", async () => {
|
|
68007
|
+
await send({
|
|
68008
|
+
type: "end",
|
|
68009
|
+
data: {
|
|
68010
|
+
ipcError: "Action aborted",
|
|
68011
|
+
type: "error"
|
|
68012
|
+
}
|
|
68013
|
+
});
|
|
68014
|
+
return reject(/* @__PURE__ */ new Error("Action interrupted"));
|
|
67808
68015
|
});
|
|
67809
|
-
return reject(/* @__PURE__ */ new Error("Action interrupted"));
|
|
67810
68016
|
});
|
|
67811
|
-
|
|
67812
|
-
|
|
68017
|
+
await Promise.race([signalPromise, effectiveActionExecute(nodeId, pluginId, params, mainWindow, send, cwd, cachePath)]);
|
|
68018
|
+
} finally {
|
|
68019
|
+
await rm(cwd, {
|
|
68020
|
+
recursive: true,
|
|
68021
|
+
force: true
|
|
68022
|
+
}).catch((err) => {
|
|
68023
|
+
console.warn(`Failed to cleanup temp folder at ${cwd}:`, err);
|
|
68024
|
+
});
|
|
68025
|
+
}
|
|
67813
68026
|
});
|
|
67814
68027
|
handle("constants:get", async (_, { send }) => {
|
|
67815
68028
|
const userData = context.userDataPath;
|
|
@@ -67833,11 +68046,11 @@ const registerEngineHandlers = (context) => {
|
|
|
67833
68046
|
});
|
|
67834
68047
|
handle("graph:execute", async (event, { send, value }) => {
|
|
67835
68048
|
const { graph, variables, projectName, projectPath, pipelineId } = value;
|
|
67836
|
-
await (await
|
|
68049
|
+
await (await setupSettingsConfigFile(context)).getConfig();
|
|
67837
68050
|
const effectiveProjectName = projectName || "Unnamed Project";
|
|
67838
68051
|
const effectiveProjectPath = projectPath || "";
|
|
67839
68052
|
const effectivePipelineId = pipelineId || "unknown";
|
|
67840
|
-
const effectiveCachePath =
|
|
68053
|
+
const effectiveCachePath = context.getCachePath(CacheFolder.Pipelines, effectivePipelineId);
|
|
67841
68054
|
const mainWindow = void 0;
|
|
67842
68055
|
abortControllerGraph = new AbortController();
|
|
67843
68056
|
try {
|
|
@@ -67945,7 +68158,7 @@ var JsonFileStorage = class {
|
|
|
67945
68158
|
filePath;
|
|
67946
68159
|
logger = useLogger().logger;
|
|
67947
68160
|
constructor(fileName, context) {
|
|
67948
|
-
this.filePath =
|
|
68161
|
+
this.filePath = context.getConfigPath(fileName);
|
|
67949
68162
|
const dir = path.dirname(this.filePath);
|
|
67950
68163
|
if (!fs.existsSync(dir)) try {
|
|
67951
68164
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -68365,6 +68578,470 @@ const registerPluginsHandlers = (context) => {
|
|
|
68365
68578
|
});
|
|
68366
68579
|
};
|
|
68367
68580
|
//#endregion
|
|
68581
|
+
//#region ../../packages/core-node/src/handlers/migration.ts
|
|
68582
|
+
const registerMigrationHandlers = (context) => {
|
|
68583
|
+
const { handle } = useAPI();
|
|
68584
|
+
const { logger } = useLogger();
|
|
68585
|
+
const getFileMetadata = async (filePath) => {
|
|
68586
|
+
const exists = existsSync(filePath);
|
|
68587
|
+
let mtime = Date.now();
|
|
68588
|
+
let version = null;
|
|
68589
|
+
if (exists) {
|
|
68590
|
+
try {
|
|
68591
|
+
const stat = await fs$1.stat(filePath);
|
|
68592
|
+
mtime = stat.mtime ? stat.mtime.getTime() : Date.now();
|
|
68593
|
+
} catch (e) {
|
|
68594
|
+
mtime = Date.now();
|
|
68595
|
+
}
|
|
68596
|
+
try {
|
|
68597
|
+
const content = await fs$1.readFile(filePath, "utf8");
|
|
68598
|
+
const json = JSON.parse(content);
|
|
68599
|
+
version = json && typeof json.version === "string" ? json.version : null;
|
|
68600
|
+
} catch (e) {}
|
|
68601
|
+
} else mtime = Date.now();
|
|
68602
|
+
return {
|
|
68603
|
+
exists,
|
|
68604
|
+
mtime,
|
|
68605
|
+
version
|
|
68606
|
+
};
|
|
68607
|
+
};
|
|
68608
|
+
const isVersionImportable = (sourceVer, targetVer) => {
|
|
68609
|
+
if (!sourceVer) return false;
|
|
68610
|
+
if (!targetVer) return true;
|
|
68611
|
+
try {
|
|
68612
|
+
const coercedSource = import_semver.default.coerce(sourceVer);
|
|
68613
|
+
const coercedTarget = import_semver.default.coerce(targetVer);
|
|
68614
|
+
if (!coercedSource) return false;
|
|
68615
|
+
if (!coercedTarget) return true;
|
|
68616
|
+
return import_semver.default.lte(coercedSource, coercedTarget);
|
|
68617
|
+
} catch {
|
|
68618
|
+
return sourceVer <= targetVer;
|
|
68619
|
+
}
|
|
68620
|
+
};
|
|
68621
|
+
handle("migration:scan-stable", async (_, { send }) => {
|
|
68622
|
+
logger().info("[Migration] Scanning other channel database...");
|
|
68623
|
+
try {
|
|
68624
|
+
const isStable = context.userDataPath.endsWith("app") || !context.userDataPath.includes("app-beta");
|
|
68625
|
+
const sourceEnv = isStable ? "beta" : "prod";
|
|
68626
|
+
const sourcePath = getDefaultUserDataPath$1(sourceEnv);
|
|
68627
|
+
if (sourcePath === context.userDataPath) {
|
|
68628
|
+
logger().info("[Migration] Running in same channel. Disabling migration scan.");
|
|
68629
|
+
return send({
|
|
68630
|
+
type: "end",
|
|
68631
|
+
data: {
|
|
68632
|
+
type: "success",
|
|
68633
|
+
result: {
|
|
68634
|
+
sourceChannel: isStable ? "Beta" : "Stable",
|
|
68635
|
+
targetChannel: isStable ? "Stable" : "Beta",
|
|
68636
|
+
settingsExists: false,
|
|
68637
|
+
settingsVersion: null,
|
|
68638
|
+
settingsVersionTarget: null,
|
|
68639
|
+
settingsMtimeSource: Date.now(),
|
|
68640
|
+
settingsMtimeTarget: Date.now(),
|
|
68641
|
+
settingsImportable: false,
|
|
68642
|
+
connectionsExists: false,
|
|
68643
|
+
connectionsCount: 0,
|
|
68644
|
+
connectionsVersion: null,
|
|
68645
|
+
connectionsVersionTarget: null,
|
|
68646
|
+
connectionsMtimeSource: Date.now(),
|
|
68647
|
+
connectionsMtimeTarget: Date.now(),
|
|
68648
|
+
connectionsImportable: false,
|
|
68649
|
+
projectsExists: false,
|
|
68650
|
+
projectsVersion: null,
|
|
68651
|
+
projectsVersionTarget: null,
|
|
68652
|
+
projectsMtimeSource: Date.now(),
|
|
68653
|
+
projectsMtimeTarget: Date.now(),
|
|
68654
|
+
projectsImportable: false,
|
|
68655
|
+
projects: []
|
|
68656
|
+
}
|
|
68657
|
+
}
|
|
68658
|
+
});
|
|
68659
|
+
}
|
|
68660
|
+
const sourceContext = new PipelabContext({
|
|
68661
|
+
userDataPath: sourcePath,
|
|
68662
|
+
releaseTag: sourceEnv
|
|
68663
|
+
});
|
|
68664
|
+
const sourceSettingsPath = sourceContext.getSettingsPath();
|
|
68665
|
+
const targetSettingsPath = context.getSettingsPath();
|
|
68666
|
+
const sourceConnectionsPath = sourceContext.getConnectionsPath();
|
|
68667
|
+
const targetConnectionsPath = context.getConnectionsPath();
|
|
68668
|
+
const sourceProjectsPath = sourceContext.getProjectsPath();
|
|
68669
|
+
const targetProjectsPath = context.getProjectsPath();
|
|
68670
|
+
const sourceSettingsMeta = await getFileMetadata(sourceSettingsPath);
|
|
68671
|
+
const targetSettingsMeta = await getFileMetadata(targetSettingsPath);
|
|
68672
|
+
const sourceConnectionsMeta = await getFileMetadata(sourceConnectionsPath);
|
|
68673
|
+
const targetConnectionsMeta = await getFileMetadata(targetConnectionsPath);
|
|
68674
|
+
const sourceProjectsMeta = await getFileMetadata(sourceProjectsPath);
|
|
68675
|
+
const targetProjectsMeta = await getFileMetadata(targetProjectsPath);
|
|
68676
|
+
const settingsExists = sourceSettingsMeta.exists;
|
|
68677
|
+
const settingsVersion = sourceSettingsMeta.version;
|
|
68678
|
+
const settingsMtimeSource = sourceSettingsMeta.mtime;
|
|
68679
|
+
const settingsMtimeTarget = targetSettingsMeta.mtime;
|
|
68680
|
+
const settingsImportable = isVersionImportable(settingsVersion, targetSettingsMeta.version);
|
|
68681
|
+
const connectionsExists = sourceConnectionsMeta.exists;
|
|
68682
|
+
const connectionsVersion = sourceConnectionsMeta.version;
|
|
68683
|
+
const connectionsMtimeSource = sourceConnectionsMeta.mtime;
|
|
68684
|
+
const connectionsMtimeTarget = targetConnectionsMeta.mtime;
|
|
68685
|
+
const connectionsImportable = isVersionImportable(connectionsVersion, targetConnectionsMeta.version);
|
|
68686
|
+
const projectsExists = sourceProjectsMeta.exists;
|
|
68687
|
+
const projectsVersion = sourceProjectsMeta.version;
|
|
68688
|
+
const projectsMtimeSource = sourceProjectsMeta.mtime;
|
|
68689
|
+
const projectsMtimeTarget = targetProjectsMeta.mtime;
|
|
68690
|
+
const projectsImportable = isVersionImportable(projectsVersion, targetProjectsMeta.version);
|
|
68691
|
+
let connectionsCount = 0;
|
|
68692
|
+
try {
|
|
68693
|
+
if (sourceConnectionsMeta.exists) {
|
|
68694
|
+
const connContent = await fs$1.readFile(sourceConnectionsPath, "utf8");
|
|
68695
|
+
const connJson = JSON.parse(connContent);
|
|
68696
|
+
if (connJson && Array.isArray(connJson.connections)) connectionsCount = connJson.connections.length;
|
|
68697
|
+
}
|
|
68698
|
+
} catch (err) {
|
|
68699
|
+
logger().error("[Migration] Error parsing source connections.json:", err);
|
|
68700
|
+
}
|
|
68701
|
+
let sourceProjectsList = [];
|
|
68702
|
+
let sourcePipelinesList = [];
|
|
68703
|
+
try {
|
|
68704
|
+
if (sourceProjectsMeta.exists) {
|
|
68705
|
+
const projContent = await fs$1.readFile(sourceProjectsPath, "utf8");
|
|
68706
|
+
const projJson = JSON.parse(projContent);
|
|
68707
|
+
sourceProjectsList = projJson.projects || [];
|
|
68708
|
+
sourcePipelinesList = projJson.pipelines || [];
|
|
68709
|
+
}
|
|
68710
|
+
} catch (err) {
|
|
68711
|
+
logger().error("[Migration] Error parsing source projects.json:", err);
|
|
68712
|
+
}
|
|
68713
|
+
let targetPipelinesList = [];
|
|
68714
|
+
try {
|
|
68715
|
+
if (targetProjectsMeta.exists) {
|
|
68716
|
+
const targetProjContent = await fs$1.readFile(targetProjectsPath, "utf8");
|
|
68717
|
+
targetPipelinesList = JSON.parse(targetProjContent).pipelines || [];
|
|
68718
|
+
}
|
|
68719
|
+
} catch (err) {}
|
|
68720
|
+
const projectsReport = [];
|
|
68721
|
+
for (const proj of sourceProjectsList) {
|
|
68722
|
+
const projPipelines = sourcePipelinesList.filter((p) => p.project === proj.id);
|
|
68723
|
+
const pipelinesReport = [];
|
|
68724
|
+
for (const pipe of projPipelines) {
|
|
68725
|
+
const targetPipe = targetPipelinesList.find((bp) => bp.id === pipe.id);
|
|
68726
|
+
const existsInBeta = !!targetPipe;
|
|
68727
|
+
let pipeName = pipe.id;
|
|
68728
|
+
let pipeDesc = "";
|
|
68729
|
+
if (pipe.type === "internal") {
|
|
68730
|
+
const sourcePipeFile = sourceContext.getConfigPath(`${pipe.configName}.json`);
|
|
68731
|
+
try {
|
|
68732
|
+
if (existsSync(sourcePipeFile)) {
|
|
68733
|
+
const pipeContent = await fs$1.readFile(sourcePipeFile, "utf8");
|
|
68734
|
+
const pipeJson = JSON.parse(pipeContent);
|
|
68735
|
+
pipeName = pipeJson.name || pipeName;
|
|
68736
|
+
pipeDesc = pipeJson.description || pipeDesc;
|
|
68737
|
+
}
|
|
68738
|
+
} catch (err) {
|
|
68739
|
+
logger().error(`[Migration] Error reading source pipeline file ${sourcePipeFile}:`, err);
|
|
68740
|
+
}
|
|
68741
|
+
} else if (pipe.type === "external") {
|
|
68742
|
+
pipeName = pipe.summary?.name || pipeName;
|
|
68743
|
+
pipeDesc = pipe.summary?.description || pipeDesc;
|
|
68744
|
+
}
|
|
68745
|
+
pipelinesReport.push({
|
|
68746
|
+
id: pipe.id,
|
|
68747
|
+
name: pipeName,
|
|
68748
|
+
description: pipeDesc,
|
|
68749
|
+
type: pipe.type,
|
|
68750
|
+
lastModifiedStable: pipe.type !== "pipelab-cloud" ? pipe.lastModified : void 0,
|
|
68751
|
+
lastModifiedBeta: targetPipe && targetPipe.type !== "pipelab-cloud" ? targetPipe.lastModified : void 0,
|
|
68752
|
+
existsInBeta
|
|
68753
|
+
});
|
|
68754
|
+
}
|
|
68755
|
+
projectsReport.push({
|
|
68756
|
+
id: proj.id,
|
|
68757
|
+
name: proj.name,
|
|
68758
|
+
description: proj.description || "",
|
|
68759
|
+
pipelines: pipelinesReport
|
|
68760
|
+
});
|
|
68761
|
+
}
|
|
68762
|
+
send({
|
|
68763
|
+
type: "end",
|
|
68764
|
+
data: {
|
|
68765
|
+
type: "success",
|
|
68766
|
+
result: {
|
|
68767
|
+
sourceChannel: isStable ? "Beta" : "Stable",
|
|
68768
|
+
targetChannel: isStable ? "Stable" : "Beta",
|
|
68769
|
+
settingsExists,
|
|
68770
|
+
settingsVersion,
|
|
68771
|
+
settingsVersionTarget: targetSettingsMeta.version,
|
|
68772
|
+
settingsMtimeSource,
|
|
68773
|
+
settingsMtimeTarget,
|
|
68774
|
+
settingsImportable,
|
|
68775
|
+
connectionsExists,
|
|
68776
|
+
connectionsCount,
|
|
68777
|
+
connectionsVersion,
|
|
68778
|
+
connectionsVersionTarget: targetConnectionsMeta.version,
|
|
68779
|
+
connectionsMtimeSource,
|
|
68780
|
+
connectionsMtimeTarget,
|
|
68781
|
+
connectionsImportable,
|
|
68782
|
+
projectsExists,
|
|
68783
|
+
projectsVersion,
|
|
68784
|
+
projectsVersionTarget: targetProjectsMeta.version,
|
|
68785
|
+
projectsMtimeSource,
|
|
68786
|
+
projectsMtimeTarget,
|
|
68787
|
+
projectsImportable,
|
|
68788
|
+
projects: projectsReport
|
|
68789
|
+
}
|
|
68790
|
+
}
|
|
68791
|
+
});
|
|
68792
|
+
} catch (e) {
|
|
68793
|
+
logger().error("[Migration] Error scanning other channel folder:", e);
|
|
68794
|
+
send({
|
|
68795
|
+
type: "end",
|
|
68796
|
+
data: {
|
|
68797
|
+
type: "error",
|
|
68798
|
+
ipcError: e instanceof Error ? e.message : "Failed to scan other channel database"
|
|
68799
|
+
}
|
|
68800
|
+
});
|
|
68801
|
+
}
|
|
68802
|
+
});
|
|
68803
|
+
handle("migration:perform", async (_, { send, value }) => {
|
|
68804
|
+
logger().info("[Migration] Performing migration...");
|
|
68805
|
+
try {
|
|
68806
|
+
const { migrateSettings, migrateConnections, selectedProjects, selectedPipelines } = value;
|
|
68807
|
+
const sourceEnv = context.userDataPath.endsWith("app") || !context.userDataPath.includes("app-beta") ? "beta" : "prod";
|
|
68808
|
+
const sourcePath = getDefaultUserDataPath$1(sourceEnv);
|
|
68809
|
+
const sourceContext = new PipelabContext({
|
|
68810
|
+
userDataPath: sourcePath,
|
|
68811
|
+
releaseTag: sourceEnv
|
|
68812
|
+
});
|
|
68813
|
+
sourceContext.getConfigPath();
|
|
68814
|
+
const targetConfigDir = context.getConfigPath();
|
|
68815
|
+
if (sourcePath === context.userDataPath) throw new Error("Cannot migrate data: Source and target directories are identical.");
|
|
68816
|
+
if (existsSync(targetConfigDir)) {
|
|
68817
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
68818
|
+
const backupDir = context.getConfigPath("backups", `backup_${timestamp}`);
|
|
68819
|
+
await fs$1.mkdir(backupDir, { recursive: true });
|
|
68820
|
+
const entries = await fs$1.readdir(targetConfigDir, { withFileTypes: true });
|
|
68821
|
+
for (const entry of entries) {
|
|
68822
|
+
if (entry.name === "backups") continue;
|
|
68823
|
+
const srcPath = join(targetConfigDir, entry.name);
|
|
68824
|
+
const destPath = join(backupDir, entry.name);
|
|
68825
|
+
try {
|
|
68826
|
+
await fs$1.cp(srcPath, destPath, { recursive: true });
|
|
68827
|
+
} catch (copyErr) {
|
|
68828
|
+
logger().error(`[Migration] Failed to backup ${entry.name}:`, copyErr);
|
|
68829
|
+
}
|
|
68830
|
+
}
|
|
68831
|
+
logger().info(`[Migration] Config backup successfully created at ${backupDir}`);
|
|
68832
|
+
}
|
|
68833
|
+
if (migrateSettings) {
|
|
68834
|
+
const sourceSettingsFile = sourceContext.getSettingsPath();
|
|
68835
|
+
const targetSettingsFile = context.getSettingsPath();
|
|
68836
|
+
const sourceMeta = await getFileMetadata(sourceSettingsFile);
|
|
68837
|
+
const targetMeta = await getFileMetadata(targetSettingsFile);
|
|
68838
|
+
if (!isVersionImportable(sourceMeta.version, targetMeta.version)) throw new Error("Cannot migrate settings: Source version is newer than current version.");
|
|
68839
|
+
if (existsSync(sourceSettingsFile)) {
|
|
68840
|
+
let stableSettings = {
|
|
68841
|
+
version: "7.0.0",
|
|
68842
|
+
locale: "en-US",
|
|
68843
|
+
theme: "light",
|
|
68844
|
+
autosave: true,
|
|
68845
|
+
agents: [],
|
|
68846
|
+
plugins: [],
|
|
68847
|
+
tours: {
|
|
68848
|
+
dashboard: {
|
|
68849
|
+
step: 0,
|
|
68850
|
+
completed: false
|
|
68851
|
+
},
|
|
68852
|
+
editor: {
|
|
68853
|
+
step: 0,
|
|
68854
|
+
completed: false
|
|
68855
|
+
}
|
|
68856
|
+
}
|
|
68857
|
+
};
|
|
68858
|
+
try {
|
|
68859
|
+
const stableContent = await fs$1.readFile(sourceSettingsFile, "utf8");
|
|
68860
|
+
stableSettings = JSON.parse(stableContent);
|
|
68861
|
+
} catch (e) {
|
|
68862
|
+
logger().error("[Migration] Failed to read source settings.json:", e);
|
|
68863
|
+
}
|
|
68864
|
+
let betaSettings = {
|
|
68865
|
+
version: "7.0.0",
|
|
68866
|
+
locale: "en-US",
|
|
68867
|
+
theme: "light",
|
|
68868
|
+
autosave: true,
|
|
68869
|
+
agents: [],
|
|
68870
|
+
plugins: [],
|
|
68871
|
+
tours: {
|
|
68872
|
+
dashboard: {
|
|
68873
|
+
step: 0,
|
|
68874
|
+
completed: false
|
|
68875
|
+
},
|
|
68876
|
+
editor: {
|
|
68877
|
+
step: 0,
|
|
68878
|
+
completed: false
|
|
68879
|
+
}
|
|
68880
|
+
}
|
|
68881
|
+
};
|
|
68882
|
+
if (existsSync(targetSettingsFile)) try {
|
|
68883
|
+
const betaContent = await fs$1.readFile(targetSettingsFile, "utf8");
|
|
68884
|
+
betaSettings = JSON.parse(betaContent);
|
|
68885
|
+
} catch (e) {}
|
|
68886
|
+
betaSettings.theme = stableSettings.theme ?? betaSettings.theme;
|
|
68887
|
+
betaSettings.locale = stableSettings.locale ?? betaSettings.locale;
|
|
68888
|
+
betaSettings.autosave = stableSettings.autosave ?? betaSettings.autosave;
|
|
68889
|
+
if (stableSettings.tours) {
|
|
68890
|
+
betaSettings.tours = betaSettings.tours || {
|
|
68891
|
+
dashboard: {
|
|
68892
|
+
step: 0,
|
|
68893
|
+
completed: false
|
|
68894
|
+
},
|
|
68895
|
+
editor: {
|
|
68896
|
+
step: 0,
|
|
68897
|
+
completed: false
|
|
68898
|
+
}
|
|
68899
|
+
};
|
|
68900
|
+
if (stableSettings.tours.dashboard) betaSettings.tours.dashboard = stableSettings.tours.dashboard;
|
|
68901
|
+
if (stableSettings.tours.editor) betaSettings.tours.editor = stableSettings.tours.editor;
|
|
68902
|
+
}
|
|
68903
|
+
const betaAgents = betaSettings.agents || [];
|
|
68904
|
+
const stableAgents = stableSettings.agents || [];
|
|
68905
|
+
for (const sAgent of stableAgents) {
|
|
68906
|
+
const existingIdx = betaAgents.findIndex((a) => a.id === sAgent.id);
|
|
68907
|
+
if (existingIdx >= 0) betaAgents[existingIdx] = { ...sAgent };
|
|
68908
|
+
else betaAgents.push({ ...sAgent });
|
|
68909
|
+
}
|
|
68910
|
+
betaSettings.agents = betaAgents;
|
|
68911
|
+
const betaPlugins = betaSettings.plugins || [];
|
|
68912
|
+
const stablePlugins = stableSettings.plugins || [];
|
|
68913
|
+
for (const sPlugin of stablePlugins) {
|
|
68914
|
+
const existingIdx = betaPlugins.findIndex((p) => p.name === sPlugin.name);
|
|
68915
|
+
if (existingIdx >= 0) betaPlugins[existingIdx] = { ...sPlugin };
|
|
68916
|
+
else betaPlugins.push({ ...sPlugin });
|
|
68917
|
+
}
|
|
68918
|
+
betaSettings.plugins = betaPlugins;
|
|
68919
|
+
await fs$1.mkdir(dirname(targetSettingsFile), { recursive: true });
|
|
68920
|
+
await fs$1.writeFile(targetSettingsFile, JSON.stringify(betaSettings, null, 2));
|
|
68921
|
+
logger().info("[Migration] Settings merged successfully");
|
|
68922
|
+
}
|
|
68923
|
+
}
|
|
68924
|
+
if (migrateConnections) {
|
|
68925
|
+
const sourceConnectionsFile = sourceContext.getConnectionsPath();
|
|
68926
|
+
const targetConnectionsFile = context.getConnectionsPath();
|
|
68927
|
+
const sourceMeta = await getFileMetadata(sourceConnectionsFile);
|
|
68928
|
+
const targetMeta = await getFileMetadata(targetConnectionsFile);
|
|
68929
|
+
if (!isVersionImportable(sourceMeta.version, targetMeta.version)) throw new Error("Cannot migrate connections: Source version is newer than current version.");
|
|
68930
|
+
if (existsSync(sourceConnectionsFile)) {
|
|
68931
|
+
let stableConnections = {
|
|
68932
|
+
version: "1.0.0",
|
|
68933
|
+
connections: []
|
|
68934
|
+
};
|
|
68935
|
+
try {
|
|
68936
|
+
const stableContent = await fs$1.readFile(sourceConnectionsFile, "utf8");
|
|
68937
|
+
stableConnections = JSON.parse(stableContent);
|
|
68938
|
+
} catch (e) {
|
|
68939
|
+
logger().error("[Migration] Failed to read source connections.json:", e);
|
|
68940
|
+
}
|
|
68941
|
+
let betaConnections = {
|
|
68942
|
+
version: "1.0.0",
|
|
68943
|
+
connections: []
|
|
68944
|
+
};
|
|
68945
|
+
if (existsSync(targetConnectionsFile)) try {
|
|
68946
|
+
const betaContent = await fs$1.readFile(targetConnectionsFile, "utf8");
|
|
68947
|
+
betaConnections = JSON.parse(betaContent);
|
|
68948
|
+
} catch (e) {}
|
|
68949
|
+
betaConnections.connections = betaConnections.connections || [];
|
|
68950
|
+
stableConnections.connections = stableConnections.connections || [];
|
|
68951
|
+
for (const sConn of stableConnections.connections) {
|
|
68952
|
+
const existingIdx = betaConnections.connections.findIndex((c) => c.id === sConn.id);
|
|
68953
|
+
if (existingIdx >= 0) betaConnections.connections[existingIdx] = { ...sConn };
|
|
68954
|
+
else betaConnections.connections.push({ ...sConn });
|
|
68955
|
+
}
|
|
68956
|
+
await fs$1.mkdir(dirname(targetConnectionsFile), { recursive: true });
|
|
68957
|
+
await fs$1.writeFile(targetConnectionsFile, JSON.stringify(betaConnections, null, 2));
|
|
68958
|
+
logger().info("[Migration] Connections merged successfully");
|
|
68959
|
+
}
|
|
68960
|
+
}
|
|
68961
|
+
if (selectedPipelines.length > 0 || selectedProjects.length > 0) {
|
|
68962
|
+
const sourceProjectsFile = sourceContext.getProjectsPath();
|
|
68963
|
+
const targetProjectsFile = context.getProjectsPath();
|
|
68964
|
+
const sourceMeta = await getFileMetadata(sourceProjectsFile);
|
|
68965
|
+
const targetMeta = await getFileMetadata(targetProjectsFile);
|
|
68966
|
+
if (!isVersionImportable(sourceMeta.version, targetMeta.version)) throw new Error("Cannot migrate projects: Source version is newer than current version.");
|
|
68967
|
+
let stableFileRepo = {
|
|
68968
|
+
version: "3.0.0",
|
|
68969
|
+
projects: [],
|
|
68970
|
+
pipelines: []
|
|
68971
|
+
};
|
|
68972
|
+
if (existsSync(sourceProjectsFile)) {
|
|
68973
|
+
const stableContent = await fs$1.readFile(sourceProjectsFile, "utf8");
|
|
68974
|
+
stableFileRepo = JSON.parse(stableContent);
|
|
68975
|
+
}
|
|
68976
|
+
let betaFileRepo = {
|
|
68977
|
+
version: "3.0.0",
|
|
68978
|
+
projects: [],
|
|
68979
|
+
pipelines: []
|
|
68980
|
+
};
|
|
68981
|
+
if (existsSync(targetProjectsFile)) try {
|
|
68982
|
+
const betaContent = await fs$1.readFile(targetProjectsFile, "utf8");
|
|
68983
|
+
betaFileRepo = JSON.parse(betaContent);
|
|
68984
|
+
} catch (readErr) {
|
|
68985
|
+
logger().warn("[Migration] Failed to parse existing target projects.json, starting fresh:", readErr);
|
|
68986
|
+
}
|
|
68987
|
+
betaFileRepo.projects = betaFileRepo.projects || [];
|
|
68988
|
+
betaFileRepo.pipelines = betaFileRepo.pipelines || [];
|
|
68989
|
+
for (const projId of selectedProjects) {
|
|
68990
|
+
const stableProj = stableFileRepo.projects.find((p) => p.id === projId);
|
|
68991
|
+
if (stableProj) {
|
|
68992
|
+
const existingProjIdx = betaFileRepo.projects.findIndex((p) => p.id === projId);
|
|
68993
|
+
if (existingProjIdx >= 0) betaFileRepo.projects[existingProjIdx] = { ...stableProj };
|
|
68994
|
+
else betaFileRepo.projects.push({ ...stableProj });
|
|
68995
|
+
}
|
|
68996
|
+
}
|
|
68997
|
+
for (const pipeId of selectedPipelines) {
|
|
68998
|
+
const stablePipe = (stableFileRepo.pipelines || []).find((p) => p.id === pipeId);
|
|
68999
|
+
if (stablePipe) {
|
|
69000
|
+
const parentProjId = stablePipe.project;
|
|
69001
|
+
if (!betaFileRepo.projects.some((p) => p.id === parentProjId)) {
|
|
69002
|
+
const stableProj = stableFileRepo.projects.find((p) => p.id === parentProjId);
|
|
69003
|
+
if (stableProj) betaFileRepo.projects.push({ ...stableProj });
|
|
69004
|
+
}
|
|
69005
|
+
if (stablePipe.type === "internal") {
|
|
69006
|
+
const stablePipeFile = sourceContext.getConfigPath(`${stablePipe.configName}.json`);
|
|
69007
|
+
const betaPipeFile = context.getConfigPath(`${stablePipe.configName}.json`);
|
|
69008
|
+
if (existsSync(stablePipeFile)) {
|
|
69009
|
+
await fs$1.mkdir(dirname(betaPipeFile), { recursive: true });
|
|
69010
|
+
await fs$1.copyFile(stablePipeFile, betaPipeFile);
|
|
69011
|
+
logger().info(`[Migration] Copied pipeline file: ${stablePipe.configName}`);
|
|
69012
|
+
}
|
|
69013
|
+
}
|
|
69014
|
+
const updatedPipe = { ...stablePipe };
|
|
69015
|
+
if (updatedPipe.type !== "pipelab-cloud") updatedPipe.lastModified = (/* @__PURE__ */ new Date()).toISOString();
|
|
69016
|
+
const existingPipeIdx = betaFileRepo.pipelines.findIndex((p) => p.id === pipeId);
|
|
69017
|
+
if (existingPipeIdx >= 0) betaFileRepo.pipelines[existingPipeIdx] = updatedPipe;
|
|
69018
|
+
else betaFileRepo.pipelines.push(updatedPipe);
|
|
69019
|
+
}
|
|
69020
|
+
}
|
|
69021
|
+
await fs$1.mkdir(dirname(targetProjectsFile), { recursive: true });
|
|
69022
|
+
await fs$1.writeFile(targetProjectsFile, JSON.stringify(betaFileRepo, null, 2));
|
|
69023
|
+
logger().info("[Migration] Merged and saved projects.json successfully");
|
|
69024
|
+
}
|
|
69025
|
+
send({
|
|
69026
|
+
type: "end",
|
|
69027
|
+
data: {
|
|
69028
|
+
type: "success",
|
|
69029
|
+
result: { result: "ok" }
|
|
69030
|
+
}
|
|
69031
|
+
});
|
|
69032
|
+
} catch (e) {
|
|
69033
|
+
logger().error("[Migration] Error performing migration:", e);
|
|
69034
|
+
send({
|
|
69035
|
+
type: "end",
|
|
69036
|
+
data: {
|
|
69037
|
+
type: "error",
|
|
69038
|
+
ipcError: e instanceof Error ? e.message : "Failed to migrate selected data"
|
|
69039
|
+
}
|
|
69040
|
+
});
|
|
69041
|
+
}
|
|
69042
|
+
});
|
|
69043
|
+
};
|
|
69044
|
+
//#endregion
|
|
68368
69045
|
//#region ../../packages/core-node/src/handlers/index.ts
|
|
68369
69046
|
const registerAllHandlers = async (options) => {
|
|
68370
69047
|
const context = options.context;
|
|
@@ -68377,6 +69054,7 @@ const registerAllHandlers = async (options) => {
|
|
|
68377
69054
|
registerAuthHandlers(context);
|
|
68378
69055
|
registerSystemHandlers(options);
|
|
68379
69056
|
registerPluginsHandlers(context);
|
|
69057
|
+
registerMigrationHandlers(context);
|
|
68380
69058
|
const { registerPlugins } = usePlugins();
|
|
68381
69059
|
builtInPlugins({ context });
|
|
68382
69060
|
};
|
|
@@ -68408,9 +69086,7 @@ async function runPipelineCommand(file, options, version) {
|
|
|
68408
69086
|
version,
|
|
68409
69087
|
context
|
|
68410
69088
|
});
|
|
68411
|
-
|
|
68412
|
-
await (await setupConfigFile("settings", { context })).getConfig();
|
|
68413
|
-
const cachePath = join(context.userDataPath, "cache");
|
|
69089
|
+
const cachePath = context.getCachePath(CacheFolder.Pipelines, effectivePipelineId);
|
|
68414
69090
|
await mkdir(cachePath, { recursive: true });
|
|
68415
69091
|
const abortController = new AbortController();
|
|
68416
69092
|
let supabase;
|
|
@@ -68477,7 +69153,7 @@ async function runPipelineCommand(file, options, version) {
|
|
|
68477
69153
|
}
|
|
68478
69154
|
//#endregion
|
|
68479
69155
|
//#region package.json
|
|
68480
|
-
var version$2 = "2.0.0-beta.
|
|
69156
|
+
var version$2 = "2.0.0-beta.19";
|
|
68481
69157
|
//#endregion
|
|
68482
69158
|
//#region src/paths.ts
|
|
68483
69159
|
const getDefaultUserDataPath = () => {
|
|
@@ -68528,7 +69204,8 @@ function formatBytes(bytes, decimals = 2) {
|
|
|
68528
69204
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
|
68529
69205
|
}
|
|
68530
69206
|
async function usageCommand(options) {
|
|
68531
|
-
const
|
|
69207
|
+
const context = new PipelabContext({ userDataPath: options.userData || getDefaultUserDataPath() });
|
|
69208
|
+
const info = await new BuildHistoryStorage(context).getStorageInfo();
|
|
68532
69209
|
console.log("Build History Storage Usage:");
|
|
68533
69210
|
console.table({
|
|
68534
69211
|
"Total Entries": info.totalEntries,
|
|
@@ -68537,13 +69214,7 @@ async function usageCommand(options) {
|
|
|
68537
69214
|
"Oldest Entry": info.oldestEntry ? new Date(info.oldestEntry).toLocaleString() : "N/A",
|
|
68538
69215
|
"Newest Entry": info.newestEntry ? new Date(info.newestEntry).toLocaleString() : "N/A",
|
|
68539
69216
|
"User Data Path": info.userDataPath,
|
|
68540
|
-
"Cache Path":
|
|
68541
|
-
});
|
|
68542
|
-
console.log("\nRetention Policy:");
|
|
68543
|
-
console.table({
|
|
68544
|
-
Enabled: info.retentionPolicy.enabled ? "Yes" : "No",
|
|
68545
|
-
"Max Entries": info.retentionPolicy.maxEntries > 0 ? info.retentionPolicy.maxEntries : "Unlimited",
|
|
68546
|
-
"Max Age (days)": info.retentionPolicy.maxAge > 0 ? info.retentionPolicy.maxAge : "Unlimited"
|
|
69217
|
+
"Cache Path": context.getBuildHistoryPath()
|
|
68547
69218
|
});
|
|
68548
69219
|
}
|
|
68549
69220
|
async function purgeCommand(pipelineId, options) {
|
|
@@ -68565,7 +69236,7 @@ async function purgeCommand(pipelineId, options) {
|
|
|
68565
69236
|
async function listPipelinesCommand(options) {
|
|
68566
69237
|
const context = new PipelabContext({ userDataPath: options.userData || getDefaultUserDataPath() });
|
|
68567
69238
|
try {
|
|
68568
|
-
const repo = await (await
|
|
69239
|
+
const repo = await (await setupProjectsConfigFile(context)).getConfig();
|
|
68569
69240
|
if (!repo.pipelines || repo.pipelines.length === 0) {
|
|
68570
69241
|
console.log("No pipelines found.");
|
|
68571
69242
|
return;
|
|
@@ -68602,7 +69273,7 @@ async function listPipelinesCommand(options) {
|
|
|
68602
69273
|
async function showPipelineCommand(idOrName, options) {
|
|
68603
69274
|
const context = new PipelabContext({ userDataPath: options.userData || getDefaultUserDataPath() });
|
|
68604
69275
|
try {
|
|
68605
|
-
const pipeline = (await (await
|
|
69276
|
+
const pipeline = (await (await setupProjectsConfigFile(context)).getConfig()).pipelines?.find((p) => p.id === idOrName || p.type === "internal" && p.configName === idOrName || p.type === "external" && p.path.includes(idOrName));
|
|
68606
69277
|
if (!pipeline) {
|
|
68607
69278
|
console.error(`Pipeline "${idOrName}" not found.`);
|
|
68608
69279
|
process.exit(1);
|
|
@@ -68684,7 +69355,7 @@ async function deletePipelineCommand(id, options) {
|
|
|
68684
69355
|
}
|
|
68685
69356
|
const context = new PipelabContext({ userDataPath: options.userData || getDefaultUserDataPath() });
|
|
68686
69357
|
try {
|
|
68687
|
-
const projectsConfig = await
|
|
69358
|
+
const projectsConfig = await setupProjectsConfigFile(context);
|
|
68688
69359
|
const repo = await projectsConfig.getConfig();
|
|
68689
69360
|
if (!repo.pipelines) {
|
|
68690
69361
|
console.error(`Pipeline "${id}" not found.`);
|
|
@@ -68697,16 +69368,10 @@ async function deletePipelineCommand(id, options) {
|
|
|
68697
69368
|
}
|
|
68698
69369
|
const pipeline = repo.pipelines[index];
|
|
68699
69370
|
if (pipeline.type === "internal") try {
|
|
68700
|
-
|
|
68701
|
-
await unlink(filePath);
|
|
69371
|
+
await deletePipelineConfigFileByName(pipeline.configName, context);
|
|
68702
69372
|
console.log(`Deleted pipeline file: ${pipeline.configName}.json`);
|
|
68703
|
-
const parsedPath = path.parse(filePath);
|
|
68704
|
-
const dirEntries = await readdir(parsedPath.dir).catch(() => []);
|
|
68705
|
-
const prefix = `${parsedPath.name}.v`;
|
|
68706
|
-
const suffix = `.json`;
|
|
68707
|
-
for (const entry of dirEntries) if (entry.startsWith(prefix) && entry.endsWith(suffix)) await unlink(path.join(parsedPath.dir, entry)).catch(() => {});
|
|
68708
69373
|
} catch (e) {
|
|
68709
|
-
|
|
69374
|
+
console.warn(`Warning: Could not delete pipeline file: ${e.message}`);
|
|
68710
69375
|
}
|
|
68711
69376
|
repo.pipelines.splice(index, 1);
|
|
68712
69377
|
await projectsConfig.setConfig(repo);
|
|
@@ -69909,7 +70574,7 @@ async function setupCommand(options) {
|
|
|
69909
70574
|
await setTimeout$1(1500);
|
|
69910
70575
|
s.stop("Authenticated successfully!");
|
|
69911
70576
|
}
|
|
69912
|
-
const settings = await
|
|
70577
|
+
const settings = await setupSettingsConfigFile(context);
|
|
69913
70578
|
const config = await settings.getConfig();
|
|
69914
70579
|
const configChanges = await dt({
|
|
69915
70580
|
theme: () => _t({
|
|
@@ -76553,4 +77218,4 @@ program.hook("postAction", (thisCommand) => {
|
|
|
76553
77218
|
program.parse(process.argv);
|
|
76554
77219
|
if (!process.argv.slice(2).length) program.outputHelp();
|
|
76555
77220
|
//#endregion
|
|
76556
|
-
export {
|
|
77221
|
+
export { CacheFolder as A, BuildHistoryStorage as C, WebSocketServer as D, registerShellHandlers as E, getDefaultUserDataPath$1 as M, projectRoot as N, webSocketServer as O, registerHistoryHandlers as S, registerFsHandlers as T, isOnline as _, executeGraphWithHistory as a, sendStartupReady as b, findInstalledPlugins as c, handleActionExecute as d, ensureNodeJS as f, fetchPipelabPlugin as g, fetchPipelabAsset as h, registerEngineHandlers as i, PipelabContext as j, useAPI as k, loadCustomPlugin as l, fetchPackage as m, registerAllHandlers as n, getFinalPlugins as o, ensurePNPM as p, registerAgentsHandlers as r, builtInPlugins as s, runPipelineCommand as t, loadPipelabPlugin as u, runPnpm as v, registerConfigHandlers as w, serveCommand as x, sendStartupProgress as y };
|