@pipelab/core-node 1.0.0-beta.27 → 1.0.0-beta.31
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 +36 -0
- package/dist/{config-CFgGRD9U.mjs → config-6j2vtyRe.mjs} +29 -5
- package/dist/config-6j2vtyRe.mjs.map +1 -0
- package/dist/config-CAz_XbPS.cjs +448 -0
- package/dist/config-DRifo1Uc.mjs +2 -0
- package/dist/index.cjs +54034 -0
- package/dist/index.d.cts +774 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +316 -17
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +70 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/context.ts +17 -8
- package/src/handlers/system.ts +26 -0
- package/src/runner.ts +2 -0
- package/src/utils/fs-extras.ts +42 -3
- package/src/utils/github.test.ts +6 -0
- package/src/utils/remote.ts +61 -2
- package/tsconfig.json +0 -2
- package/tsdown.config.ts +12 -0
- package/dist/config-Bi0ORcTK.mjs +0 -2
- package/dist/config-CFgGRD9U.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @pipelab/core-node
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- sd
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @pipelab/constants@1.0.0-beta.27
|
|
10
|
+
- @pipelab/shared@1.0.0-beta.26
|
|
11
|
+
|
|
12
|
+
## 1.0.0-beta.30
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- sdsd
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @pipelab/constants@1.0.0-beta.26
|
|
19
|
+
- @pipelab/shared@1.0.0-beta.25
|
|
20
|
+
|
|
21
|
+
## 1.0.0-beta.29
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- sd
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
- @pipelab/constants@1.0.0-beta.25
|
|
28
|
+
- @pipelab/shared@1.0.0-beta.24
|
|
29
|
+
|
|
30
|
+
## 1.0.0-beta.28
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- sd
|
|
35
|
+
- Updated dependencies
|
|
36
|
+
- @pipelab/constants@1.0.0-beta.24
|
|
37
|
+
- @pipelab/shared@1.0.0-beta.23
|
|
38
|
+
|
|
3
39
|
## 1.0.0-beta.27
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
|
@@ -60,18 +60,42 @@ async function extractZip(archivePath, destinationDir) {
|
|
|
60
60
|
/**
|
|
61
61
|
* Zips a folder.
|
|
62
62
|
*/
|
|
63
|
-
const zipFolder = async (from, to, log = console.log) => {
|
|
63
|
+
const zipFolder = async (from, to, log = console.log, abortSignal) => {
|
|
64
|
+
if (abortSignal?.aborted) {
|
|
65
|
+
const abortError = /* @__PURE__ */ new Error("Aborted");
|
|
66
|
+
abortError.name = "AbortError";
|
|
67
|
+
throw abortError;
|
|
68
|
+
}
|
|
64
69
|
const output = createWriteStream(to);
|
|
65
70
|
const archive = archiver("zip", { zlib: { level: 9 } });
|
|
66
71
|
return new Promise((resolve, reject) => {
|
|
72
|
+
const onAbort = () => {
|
|
73
|
+
try {
|
|
74
|
+
archive.abort();
|
|
75
|
+
} catch {}
|
|
76
|
+
try {
|
|
77
|
+
output.destroy();
|
|
78
|
+
} catch {}
|
|
79
|
+
const abortError = /* @__PURE__ */ new Error("Aborted");
|
|
80
|
+
abortError.name = "AbortError";
|
|
81
|
+
reject(abortError);
|
|
82
|
+
};
|
|
83
|
+
if (abortSignal) abortSignal.addEventListener("abort", onAbort);
|
|
67
84
|
output.on("close", () => {
|
|
85
|
+
if (abortSignal) abortSignal.removeEventListener("abort", onAbort);
|
|
68
86
|
log(archive.pointer() + " total bytes");
|
|
69
87
|
resolve(to);
|
|
70
88
|
});
|
|
71
|
-
archive.on("error",
|
|
89
|
+
archive.on("error", (err) => {
|
|
90
|
+
if (abortSignal) abortSignal.removeEventListener("abort", onAbort);
|
|
91
|
+
reject(err);
|
|
92
|
+
});
|
|
72
93
|
archive.pipe(output);
|
|
73
94
|
archive.directory(from, false);
|
|
74
|
-
archive.finalize()
|
|
95
|
+
archive.finalize().catch((err) => {
|
|
96
|
+
if (abortSignal) abortSignal.removeEventListener("abort", onAbort);
|
|
97
|
+
reject(err);
|
|
98
|
+
});
|
|
75
99
|
});
|
|
76
100
|
};
|
|
77
101
|
const downloadFile = async (url, localPath, hooks, abortSignal) => {
|
|
@@ -107,7 +131,7 @@ const runWithLiveLogs = async (command, args, execaOptions, log, hooks, abortSig
|
|
|
107
131
|
TERM: "xterm-256color",
|
|
108
132
|
FORCE_STDERR_LOGGING: "1"
|
|
109
133
|
},
|
|
110
|
-
cancelSignal: abortSignal
|
|
134
|
+
cancelSignal: abortSignal ?? execaOptions.cancelSignal
|
|
111
135
|
});
|
|
112
136
|
hooks?.onCreated?.(subprocess);
|
|
113
137
|
subprocess.stdout?.on("data", (data) => {
|
|
@@ -262,4 +286,4 @@ const deletePipelineConfigFileByPath = async (absolutePath, context) => {
|
|
|
262
286
|
//#endregion
|
|
263
287
|
export { setupPipelineConfigFileByName as a, setupSettingsConfigFile as c, extractTarGz as d, extractZip as f, zipFolder as h, setupConnectionsConfigFile as i, downloadFile as l, runWithLiveLogs as m, deletePipelineConfigFileByPath as n, setupPipelineConfigFileByPath as o, getFolderSize as p, setupConfigFile as r, setupProjectsConfigFile as s, deletePipelineConfigFileByName as t, ensure as u };
|
|
264
288
|
|
|
265
|
-
//# sourceMappingURL=config-
|
|
289
|
+
//# sourceMappingURL=config-6j2vtyRe.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-6j2vtyRe.mjs","names":["mkdirP","fs"],"sources":["../src/utils/fs-extras.ts","../src/config.ts"],"sourcesContent":["import { createWriteStream } from \"node:fs\";\nimport { execa, Options, Subprocess } from \"execa\";\nimport { mkdir as mkdirP, writeFile, stat, readdir } from \"node:fs/promises\";\nimport { join, dirname } from \"node:path\";\nimport tar from \"tar\";\nimport yauzl from \"yauzl\";\nimport archiver from \"archiver\";\nimport { pipeline } from \"node:stream/promises\";\n\n/**\n * Ensures a directory exists and a file is created with default content if missing.\n */\nexport const ensure = async (filesPath: string, defaultContent = \"{}\") => {\n await mkdirP(dirname(filesPath), { recursive: true });\n try {\n const s = await stat(filesPath);\n if (s.size === 0) {\n await writeFile(filesPath, defaultContent);\n }\n } catch {\n await writeFile(filesPath, defaultContent);\n }\n};\n\n/**\n * Extracts a .tar.gz archive.\n */\nexport async function extractTarGz(archivePath: string, destinationDir: string): Promise<void> {\n await mkdirP(destinationDir, { recursive: true });\n await tar.x({\n file: archivePath,\n cwd: destinationDir,\n });\n}\n\n/**\n * Extracts a .zip archive.\n */\nexport async function extractZip(archivePath: string, destinationDir: string): Promise<void> {\n await mkdirP(destinationDir, { recursive: true });\n return new Promise((resolve, reject) => {\n yauzl.open(archivePath, { lazyEntries: true }, (err, zipfile) => {\n if (err || !zipfile) return reject(err || new Error(\"Could not open zip file\"));\n zipfile.on(\"error\", reject);\n zipfile.readEntry();\n zipfile.on(\"entry\", (entry) => {\n const entryPath = join(destinationDir, entry.fileName);\n if (/\\/$/.test(entry.fileName)) {\n mkdirP(entryPath, { recursive: true })\n .then(() => zipfile.readEntry())\n .catch(reject);\n } else {\n mkdirP(dirname(entryPath), { recursive: true })\n .then(() => {\n zipfile.openReadStream(entry, (err, readStream) => {\n if (err || !readStream)\n return reject(err || new Error(\"Could not open read stream\"));\n readStream.on(\"error\", reject);\n const writeStream = createWriteStream(entryPath);\n writeStream.on(\"error\", reject);\n writeStream.on(\"close\", () => zipfile.readEntry());\n readStream.pipe(writeStream);\n });\n })\n .catch(reject);\n }\n });\n zipfile.on(\"end\", () => resolve());\n });\n });\n}\n\n/**\n * Zips a folder.\n */\nexport const zipFolder = async (\n from: string,\n to: string,\n log: typeof console.log = console.log,\n abortSignal?: AbortSignal,\n) => {\n if (abortSignal?.aborted) {\n const abortError = new Error(\"Aborted\");\n abortError.name = \"AbortError\";\n throw abortError;\n }\n\n const output = createWriteStream(to);\n const archive = archiver(\"zip\", { zlib: { level: 9 } });\n\n return new Promise<string>((resolve, reject) => {\n const onAbort = () => {\n try {\n archive.abort();\n } catch {}\n try {\n output.destroy();\n } catch {}\n const abortError = new Error(\"Aborted\");\n abortError.name = \"AbortError\";\n reject(abortError);\n };\n\n if (abortSignal) {\n abortSignal.addEventListener(\"abort\", onAbort);\n }\n\n output.on(\"close\", () => {\n if (abortSignal) {\n abortSignal.removeEventListener(\"abort\", onAbort);\n }\n log(archive.pointer() + \" total bytes\");\n resolve(to);\n });\n\n archive.on(\"error\", (err) => {\n if (abortSignal) {\n abortSignal.removeEventListener(\"abort\", onAbort);\n }\n reject(err);\n });\n\n archive.pipe(output);\n archive.directory(from, false);\n archive.finalize().catch((err) => {\n if (abortSignal) {\n abortSignal.removeEventListener(\"abort\", onAbort);\n }\n reject(err);\n });\n });\n};\n\n/**\n * Downloads a file with progress tracking.\n */\nexport interface DownloadHooks {\n onProgress?: (data: { progress: number; downloadedSize: number }) => void;\n}\n\nexport const downloadFile = async (\n url: string,\n localPath: string,\n hooks?: DownloadHooks,\n abortSignal?: AbortSignal,\n): Promise<void> => {\n const response = await fetch(url, { signal: abortSignal });\n if (!response.ok) throw new Error(`Failed to fetch file: ${response.statusText}`);\n const contentLength = response.headers.get(\"content-length\");\n if (!contentLength) throw new Error(\"Content-Length header is missing\");\n const totalSize = parseInt(contentLength, 10);\n let downloadedSize = 0;\n const fileStream = createWriteStream(localPath);\n const progressStream = new TransformStream({\n transform(chunk, controller) {\n downloadedSize += chunk.length;\n const progress = (downloadedSize / totalSize) * 100;\n hooks?.onProgress?.({ progress, downloadedSize });\n controller.enqueue(chunk);\n },\n });\n const readable = response.body?.pipeThrough(progressStream);\n if (!readable) throw new Error(\"Failed to create a readable stream\");\n await pipeline(readable, fileStream);\n};\n\nexport const runWithLiveLogs = async (\n command: string,\n args: string[],\n execaOptions: Options,\n log: typeof console.log,\n hooks?: {\n onStdout?: (data: string, subprocess: Subprocess) => void;\n onStderr?: (data: string, subprocess: Subprocess) => void;\n onExit?: (code: number) => void;\n onCreated?: (subprocess: Subprocess) => void;\n },\n abortSignal?: AbortSignal,\n): Promise<void> => {\n const subprocess = execa(command, args, {\n ...execaOptions,\n stdout: \"pipe\",\n stderr: \"pipe\",\n stdin: \"pipe\",\n env: {\n ...process.env,\n ...execaOptions.env,\n TERM: \"xterm-256color\",\n FORCE_STDERR_LOGGING: \"1\",\n },\n cancelSignal: abortSignal ?? execaOptions.cancelSignal,\n });\n\n hooks?.onCreated?.(subprocess);\n\n subprocess.stdout?.on(\"data\", (data: Buffer) => {\n hooks?.onStdout?.(data.toString(), subprocess);\n });\n\n subprocess.stderr?.on(\"data\", (data: Buffer) => {\n hooks?.onStderr?.(data.toString(), subprocess);\n });\n\n try {\n const { exitCode } = await subprocess;\n hooks?.onExit?.(exitCode ?? 0);\n } catch (error: any) {\n const code = error.exitCode ?? 1;\n hooks?.onExit?.(code);\n throw new Error(`Command failed with exit code ${code}: ${error.message}`);\n }\n};\n\n/**\n * Calculates the total size of a directory recursively.\n */\nexport async function getFolderSize(dirPath: string): Promise<number> {\n try {\n const files = await readdir(dirPath, { withFileTypes: true });\n const ArrayOfPromises = files.map(async (file) => {\n const path = join(dirPath, file.name);\n if (file.isDirectory()) {\n try {\n return await getFolderSize(path);\n } catch {\n return 0;\n }\n }\n try {\n const { size } = await stat(path);\n return size;\n } catch {\n return 0;\n }\n });\n const results = await Promise.all(ArrayOfPromises);\n return results.reduce((acc, size) => acc + size, 0);\n } catch {\n return 0;\n }\n}\n","import { PipelabContext } from \"./context\";\nimport path from \"node:path\";\nimport { ensure } from \"./utils/fs-extras\";\nimport fs from \"node:fs/promises\";\nimport {\n useLogger,\n Migrator,\n AppConfig,\n ConnectionsConfig,\n FileRepo,\n SavedFile,\n appSettingsMigrator,\n connectionsMigrator,\n fileRepoMigrations,\n savedFileMigrator,\n} from \"@pipelab/shared\";\n\nexport const setupConfigFile = async <T>(\n filesPath: string,\n options: { context: PipelabContext; migrator: Migrator<T> },\n) => {\n const ctx = options.context;\n const parsedPath = path.parse(filesPath);\n const migrator = options.migrator;\n\n await ensure(filesPath, JSON.stringify(migrator.defaultValue));\n\n return {\n setConfig: async (config: T) => {\n const { logger } = useLogger();\n try {\n await fs.writeFile(filesPath, JSON.stringify(config));\n return true;\n } catch (e) {\n logger().error(`Error saving config ${parsedPath.name}:`, e);\n return false;\n }\n },\n getConfig: async () => {\n const { logger } = useLogger();\n let content = undefined;\n let originalJson: any = undefined;\n let parseFailed = false;\n\n try {\n content = await fs.readFile(filesPath, \"utf8\");\n if (content !== undefined) {\n originalJson = JSON.parse(content);\n }\n } catch (e) {\n logger().error(`Error reading or parsing config ${parsedPath.name}:`, e);\n parseFailed = true;\n }\n\n let json: any = undefined;\n let migrationFailed = false;\n try {\n if (!parseFailed) {\n json = await migrator.migrate(originalJson, {\n debug: false,\n onStep: async (state: any, version: string) => {\n const versionedPath = path.join(\n parsedPath.dir,\n `${parsedPath.name}.v${version}.json`,\n );\n try {\n await fs.writeFile(versionedPath, JSON.stringify(state));\n logger().info(\n `Intermediate backup created for ${parsedPath.name} at ${versionedPath}`,\n );\n } catch (e) {\n logger().error(\n `Failed to create intermediate backup for ${parsedPath.name} at v${version}:`,\n e,\n );\n }\n },\n });\n } else {\n json = migrator.defaultValue;\n }\n } catch (e) {\n logger().error(`Error migrating config ${parsedPath.name}:`, e);\n migrationFailed = true;\n json = migrator.defaultValue;\n }\n\n const originalVersion = originalJson?.version;\n const newVersion = json?.version;\n\n const shouldSaveBack =\n originalVersion !== newVersion || content === undefined || parseFailed || migrationFailed;\n\n if (shouldSaveBack) {\n if (parseFailed || migrationFailed) {\n try {\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const corruptedPath = path.join(\n parsedPath.dir,\n `${parsedPath.name}.corrupted.${timestamp}.json`,\n );\n const backupContent = parseFailed\n ? content || \"\"\n : JSON.stringify(originalJson, null, 2);\n await fs.writeFile(corruptedPath, backupContent);\n logger().info(`Corrupted config file preserved at ${corruptedPath}`);\n } catch (e) {\n logger().error(`Failed to backup corrupted config ${parsedPath.name}:`, e);\n }\n }\n\n try {\n await fs.writeFile(filesPath, JSON.stringify(json));\n } catch (e) {\n logger().error(`Error saving migrated config ${parsedPath.name}:`, e);\n }\n }\n\n return json as T;\n },\n };\n};\n\nexport const setupSettingsConfigFile = (context: PipelabContext) => {\n return setupConfigFile<AppConfig>(context.getSettingsPath(), {\n context,\n migrator: appSettingsMigrator,\n });\n};\n\nexport const setupConnectionsConfigFile = (context: PipelabContext) => {\n return setupConfigFile<ConnectionsConfig>(context.getConnectionsPath(), {\n context,\n migrator: connectionsMigrator,\n });\n};\n\nexport const setupProjectsConfigFile = (context: PipelabContext) => {\n return setupConfigFile<FileRepo>(context.getProjectsPath(), {\n context,\n migrator: fileRepoMigrations,\n });\n};\n\nexport const setupPipelineConfigFileByName = (name: string, context: PipelabContext) => {\n const filesPath = context.getConfigPath(`${name}.json`);\n return setupConfigFile<SavedFile>(filesPath, {\n context,\n migrator: savedFileMigrator,\n });\n};\n\nexport const setupPipelineConfigFileByPath = (absolutePath: string, context: PipelabContext) => {\n return setupConfigFile<SavedFile>(absolutePath, {\n context,\n migrator: savedFileMigrator,\n });\n};\n\nconst deleteConfigFile = async (filesPath: string) => {\n await fs.rm(filesPath, { force: true });\n};\n\nexport const deletePipelineConfigFileByName = async (name: string, context: PipelabContext) => {\n const filesPath = context.getConfigPath(`${name}.json`);\n await deleteConfigFile(filesPath);\n};\n\nexport const deletePipelineConfigFileByPath = async (\n absolutePath: string,\n context: PipelabContext,\n) => {\n await deleteConfigFile(absolutePath);\n};\n"],"mappings":";;;;;;;;;;;;;AAYA,MA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a,2BAA2B,YAA4B;AAClE,QAAO,gBAA0B,QAAQ,iBAAiB,EAAE;EAC1D;EACA,UAAU;EACX,CAAC;;AAGJ,MAAa,iCAAiC,MAAc,YAA4B;AAEtF,QAAO,gBADW,QAAQ,cAAc,GAAG,KAAK,OAAO,EACV;EAC3C;EACA,UAAU;EACX,CAAC;;AAGJ,MAAa,iCAAiC,cAAsB,YAA4B;AAC9F,QAAO,gBAA2B,cAAc;EAC9C;EACA,UAAU;EACX,CAAC;;AAGJ,MAAM,mBAAmB,OAAO,cAAsB;AACpD,OAAMA,KAAG,GAAG,WAAW,EAAE,OAAO,MAAM,CAAC;;AAGzC,MAAa,iCAAiC,OAAO,MAAc,YAA4B;AAE7F,OAAM,iBADY,QAAQ,cAAc,GAAG,KAAK,OAAO,CACtB;;AAGnC,MAAa,iCAAiC,OAC5C,cACA,YACG;AACH,OAAM,iBAAiB,aAAa"}
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
+
key = keys[i];
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
+
get: ((k) => from[k]).bind(null, key),
|
|
23
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
//#endregion
|
|
34
|
+
let node_path = require("node:path");
|
|
35
|
+
node_path = __toESM(node_path);
|
|
36
|
+
let node_fs = require("node:fs");
|
|
37
|
+
let node_fs_promises = require("node:fs/promises");
|
|
38
|
+
node_fs_promises = __toESM(node_fs_promises);
|
|
39
|
+
let _pipelab_shared = require("@pipelab/shared");
|
|
40
|
+
let execa = require("execa");
|
|
41
|
+
let tar = require("tar");
|
|
42
|
+
tar = __toESM(tar);
|
|
43
|
+
let yauzl = require("yauzl");
|
|
44
|
+
yauzl = __toESM(yauzl);
|
|
45
|
+
let archiver = require("archiver");
|
|
46
|
+
archiver = __toESM(archiver);
|
|
47
|
+
let node_stream_promises = require("node:stream/promises");
|
|
48
|
+
//#region src/utils/fs-extras.ts
|
|
49
|
+
/**
|
|
50
|
+
* Ensures a directory exists and a file is created with default content if missing.
|
|
51
|
+
*/
|
|
52
|
+
const ensure = async (filesPath, defaultContent = "{}") => {
|
|
53
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(filesPath), { recursive: true });
|
|
54
|
+
try {
|
|
55
|
+
if ((await (0, node_fs_promises.stat)(filesPath)).size === 0) await (0, node_fs_promises.writeFile)(filesPath, defaultContent);
|
|
56
|
+
} catch {
|
|
57
|
+
await (0, node_fs_promises.writeFile)(filesPath, defaultContent);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Extracts a .tar.gz archive.
|
|
62
|
+
*/
|
|
63
|
+
async function extractTarGz(archivePath, destinationDir) {
|
|
64
|
+
await (0, node_fs_promises.mkdir)(destinationDir, { recursive: true });
|
|
65
|
+
await tar.default.x({
|
|
66
|
+
file: archivePath,
|
|
67
|
+
cwd: destinationDir
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Extracts a .zip archive.
|
|
72
|
+
*/
|
|
73
|
+
async function extractZip(archivePath, destinationDir) {
|
|
74
|
+
await (0, node_fs_promises.mkdir)(destinationDir, { recursive: true });
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
yauzl.default.open(archivePath, { lazyEntries: true }, (err, zipfile) => {
|
|
77
|
+
if (err || !zipfile) return reject(err || /* @__PURE__ */ new Error("Could not open zip file"));
|
|
78
|
+
zipfile.on("error", reject);
|
|
79
|
+
zipfile.readEntry();
|
|
80
|
+
zipfile.on("entry", (entry) => {
|
|
81
|
+
const entryPath = (0, node_path.join)(destinationDir, entry.fileName);
|
|
82
|
+
if (/\/$/.test(entry.fileName)) (0, node_fs_promises.mkdir)(entryPath, { recursive: true }).then(() => zipfile.readEntry()).catch(reject);
|
|
83
|
+
else (0, node_fs_promises.mkdir)((0, node_path.dirname)(entryPath), { recursive: true }).then(() => {
|
|
84
|
+
zipfile.openReadStream(entry, (err, readStream) => {
|
|
85
|
+
if (err || !readStream) return reject(err || /* @__PURE__ */ new Error("Could not open read stream"));
|
|
86
|
+
readStream.on("error", reject);
|
|
87
|
+
const writeStream = (0, node_fs.createWriteStream)(entryPath);
|
|
88
|
+
writeStream.on("error", reject);
|
|
89
|
+
writeStream.on("close", () => zipfile.readEntry());
|
|
90
|
+
readStream.pipe(writeStream);
|
|
91
|
+
});
|
|
92
|
+
}).catch(reject);
|
|
93
|
+
});
|
|
94
|
+
zipfile.on("end", () => resolve());
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Zips a folder.
|
|
100
|
+
*/
|
|
101
|
+
const zipFolder = async (from, to, log = console.log, abortSignal) => {
|
|
102
|
+
if (abortSignal?.aborted) {
|
|
103
|
+
const abortError = /* @__PURE__ */ new Error("Aborted");
|
|
104
|
+
abortError.name = "AbortError";
|
|
105
|
+
throw abortError;
|
|
106
|
+
}
|
|
107
|
+
const output = (0, node_fs.createWriteStream)(to);
|
|
108
|
+
const archive = (0, archiver.default)("zip", { zlib: { level: 9 } });
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
const onAbort = () => {
|
|
111
|
+
try {
|
|
112
|
+
archive.abort();
|
|
113
|
+
} catch {}
|
|
114
|
+
try {
|
|
115
|
+
output.destroy();
|
|
116
|
+
} catch {}
|
|
117
|
+
const abortError = /* @__PURE__ */ new Error("Aborted");
|
|
118
|
+
abortError.name = "AbortError";
|
|
119
|
+
reject(abortError);
|
|
120
|
+
};
|
|
121
|
+
if (abortSignal) abortSignal.addEventListener("abort", onAbort);
|
|
122
|
+
output.on("close", () => {
|
|
123
|
+
if (abortSignal) abortSignal.removeEventListener("abort", onAbort);
|
|
124
|
+
log(archive.pointer() + " total bytes");
|
|
125
|
+
resolve(to);
|
|
126
|
+
});
|
|
127
|
+
archive.on("error", (err) => {
|
|
128
|
+
if (abortSignal) abortSignal.removeEventListener("abort", onAbort);
|
|
129
|
+
reject(err);
|
|
130
|
+
});
|
|
131
|
+
archive.pipe(output);
|
|
132
|
+
archive.directory(from, false);
|
|
133
|
+
archive.finalize().catch((err) => {
|
|
134
|
+
if (abortSignal) abortSignal.removeEventListener("abort", onAbort);
|
|
135
|
+
reject(err);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
const downloadFile = async (url, localPath, hooks, abortSignal) => {
|
|
140
|
+
const response = await fetch(url, { signal: abortSignal });
|
|
141
|
+
if (!response.ok) throw new Error(`Failed to fetch file: ${response.statusText}`);
|
|
142
|
+
const contentLength = response.headers.get("content-length");
|
|
143
|
+
if (!contentLength) throw new Error("Content-Length header is missing");
|
|
144
|
+
const totalSize = parseInt(contentLength, 10);
|
|
145
|
+
let downloadedSize = 0;
|
|
146
|
+
const fileStream = (0, node_fs.createWriteStream)(localPath);
|
|
147
|
+
const progressStream = new TransformStream({ transform(chunk, controller) {
|
|
148
|
+
downloadedSize += chunk.length;
|
|
149
|
+
const progress = downloadedSize / totalSize * 100;
|
|
150
|
+
hooks?.onProgress?.({
|
|
151
|
+
progress,
|
|
152
|
+
downloadedSize
|
|
153
|
+
});
|
|
154
|
+
controller.enqueue(chunk);
|
|
155
|
+
} });
|
|
156
|
+
const readable = response.body?.pipeThrough(progressStream);
|
|
157
|
+
if (!readable) throw new Error("Failed to create a readable stream");
|
|
158
|
+
await (0, node_stream_promises.pipeline)(readable, fileStream);
|
|
159
|
+
};
|
|
160
|
+
const runWithLiveLogs = async (command, args, execaOptions, log, hooks, abortSignal) => {
|
|
161
|
+
const subprocess = (0, execa.execa)(command, args, {
|
|
162
|
+
...execaOptions,
|
|
163
|
+
stdout: "pipe",
|
|
164
|
+
stderr: "pipe",
|
|
165
|
+
stdin: "pipe",
|
|
166
|
+
env: {
|
|
167
|
+
...process.env,
|
|
168
|
+
...execaOptions.env,
|
|
169
|
+
TERM: "xterm-256color",
|
|
170
|
+
FORCE_STDERR_LOGGING: "1"
|
|
171
|
+
},
|
|
172
|
+
cancelSignal: abortSignal ?? execaOptions.cancelSignal
|
|
173
|
+
});
|
|
174
|
+
hooks?.onCreated?.(subprocess);
|
|
175
|
+
subprocess.stdout?.on("data", (data) => {
|
|
176
|
+
hooks?.onStdout?.(data.toString(), subprocess);
|
|
177
|
+
});
|
|
178
|
+
subprocess.stderr?.on("data", (data) => {
|
|
179
|
+
hooks?.onStderr?.(data.toString(), subprocess);
|
|
180
|
+
});
|
|
181
|
+
try {
|
|
182
|
+
const { exitCode } = await subprocess;
|
|
183
|
+
hooks?.onExit?.(exitCode ?? 0);
|
|
184
|
+
} catch (error) {
|
|
185
|
+
const code = error.exitCode ?? 1;
|
|
186
|
+
hooks?.onExit?.(code);
|
|
187
|
+
throw new Error(`Command failed with exit code ${code}: ${error.message}`);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Calculates the total size of a directory recursively.
|
|
192
|
+
*/
|
|
193
|
+
async function getFolderSize(dirPath) {
|
|
194
|
+
try {
|
|
195
|
+
const ArrayOfPromises = (await (0, node_fs_promises.readdir)(dirPath, { withFileTypes: true })).map(async (file) => {
|
|
196
|
+
const path = (0, node_path.join)(dirPath, file.name);
|
|
197
|
+
if (file.isDirectory()) try {
|
|
198
|
+
return await getFolderSize(path);
|
|
199
|
+
} catch {
|
|
200
|
+
return 0;
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
const { size } = await (0, node_fs_promises.stat)(path);
|
|
204
|
+
return size;
|
|
205
|
+
} catch {
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
return (await Promise.all(ArrayOfPromises)).reduce((acc, size) => acc + size, 0);
|
|
210
|
+
} catch {
|
|
211
|
+
return 0;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/config.ts
|
|
216
|
+
var config_exports = /* @__PURE__ */ __exportAll({
|
|
217
|
+
deletePipelineConfigFileByName: () => deletePipelineConfigFileByName,
|
|
218
|
+
deletePipelineConfigFileByPath: () => deletePipelineConfigFileByPath,
|
|
219
|
+
setupConfigFile: () => setupConfigFile,
|
|
220
|
+
setupConnectionsConfigFile: () => setupConnectionsConfigFile,
|
|
221
|
+
setupPipelineConfigFileByName: () => setupPipelineConfigFileByName,
|
|
222
|
+
setupPipelineConfigFileByPath: () => setupPipelineConfigFileByPath,
|
|
223
|
+
setupProjectsConfigFile: () => setupProjectsConfigFile,
|
|
224
|
+
setupSettingsConfigFile: () => setupSettingsConfigFile
|
|
225
|
+
});
|
|
226
|
+
const setupConfigFile = async (filesPath, options) => {
|
|
227
|
+
options.context;
|
|
228
|
+
const parsedPath = node_path.default.parse(filesPath);
|
|
229
|
+
const migrator = options.migrator;
|
|
230
|
+
await ensure(filesPath, JSON.stringify(migrator.defaultValue));
|
|
231
|
+
return {
|
|
232
|
+
setConfig: async (config) => {
|
|
233
|
+
const { logger } = (0, _pipelab_shared.useLogger)();
|
|
234
|
+
try {
|
|
235
|
+
await node_fs_promises.default.writeFile(filesPath, JSON.stringify(config));
|
|
236
|
+
return true;
|
|
237
|
+
} catch (e) {
|
|
238
|
+
logger().error(`Error saving config ${parsedPath.name}:`, e);
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
getConfig: async () => {
|
|
243
|
+
const { logger } = (0, _pipelab_shared.useLogger)();
|
|
244
|
+
let content = void 0;
|
|
245
|
+
let originalJson = void 0;
|
|
246
|
+
let parseFailed = false;
|
|
247
|
+
try {
|
|
248
|
+
content = await node_fs_promises.default.readFile(filesPath, "utf8");
|
|
249
|
+
if (content !== void 0) originalJson = JSON.parse(content);
|
|
250
|
+
} catch (e) {
|
|
251
|
+
logger().error(`Error reading or parsing config ${parsedPath.name}:`, e);
|
|
252
|
+
parseFailed = true;
|
|
253
|
+
}
|
|
254
|
+
let json = void 0;
|
|
255
|
+
let migrationFailed = false;
|
|
256
|
+
try {
|
|
257
|
+
if (!parseFailed) json = await migrator.migrate(originalJson, {
|
|
258
|
+
debug: false,
|
|
259
|
+
onStep: async (state, version) => {
|
|
260
|
+
const versionedPath = node_path.default.join(parsedPath.dir, `${parsedPath.name}.v${version}.json`);
|
|
261
|
+
try {
|
|
262
|
+
await node_fs_promises.default.writeFile(versionedPath, JSON.stringify(state));
|
|
263
|
+
logger().info(`Intermediate backup created for ${parsedPath.name} at ${versionedPath}`);
|
|
264
|
+
} catch (e) {
|
|
265
|
+
logger().error(`Failed to create intermediate backup for ${parsedPath.name} at v${version}:`, e);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
else json = migrator.defaultValue;
|
|
270
|
+
} catch (e) {
|
|
271
|
+
logger().error(`Error migrating config ${parsedPath.name}:`, e);
|
|
272
|
+
migrationFailed = true;
|
|
273
|
+
json = migrator.defaultValue;
|
|
274
|
+
}
|
|
275
|
+
if (originalJson?.version !== json?.version || content === void 0 || parseFailed || migrationFailed) {
|
|
276
|
+
if (parseFailed || migrationFailed) try {
|
|
277
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
278
|
+
const corruptedPath = node_path.default.join(parsedPath.dir, `${parsedPath.name}.corrupted.${timestamp}.json`);
|
|
279
|
+
const backupContent = parseFailed ? content || "" : JSON.stringify(originalJson, null, 2);
|
|
280
|
+
await node_fs_promises.default.writeFile(corruptedPath, backupContent);
|
|
281
|
+
logger().info(`Corrupted config file preserved at ${corruptedPath}`);
|
|
282
|
+
} catch (e) {
|
|
283
|
+
logger().error(`Failed to backup corrupted config ${parsedPath.name}:`, e);
|
|
284
|
+
}
|
|
285
|
+
try {
|
|
286
|
+
await node_fs_promises.default.writeFile(filesPath, JSON.stringify(json));
|
|
287
|
+
} catch (e) {
|
|
288
|
+
logger().error(`Error saving migrated config ${parsedPath.name}:`, e);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return json;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
const setupSettingsConfigFile = (context) => {
|
|
296
|
+
return setupConfigFile(context.getSettingsPath(), {
|
|
297
|
+
context,
|
|
298
|
+
migrator: _pipelab_shared.appSettingsMigrator
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
const setupConnectionsConfigFile = (context) => {
|
|
302
|
+
return setupConfigFile(context.getConnectionsPath(), {
|
|
303
|
+
context,
|
|
304
|
+
migrator: _pipelab_shared.connectionsMigrator
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
const setupProjectsConfigFile = (context) => {
|
|
308
|
+
return setupConfigFile(context.getProjectsPath(), {
|
|
309
|
+
context,
|
|
310
|
+
migrator: _pipelab_shared.fileRepoMigrations
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
const setupPipelineConfigFileByName = (name, context) => {
|
|
314
|
+
return setupConfigFile(context.getConfigPath(`${name}.json`), {
|
|
315
|
+
context,
|
|
316
|
+
migrator: _pipelab_shared.savedFileMigrator
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
const setupPipelineConfigFileByPath = (absolutePath, context) => {
|
|
320
|
+
return setupConfigFile(absolutePath, {
|
|
321
|
+
context,
|
|
322
|
+
migrator: _pipelab_shared.savedFileMigrator
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
const deleteConfigFile = async (filesPath) => {
|
|
326
|
+
await node_fs_promises.default.rm(filesPath, { force: true });
|
|
327
|
+
};
|
|
328
|
+
const deletePipelineConfigFileByName = async (name, context) => {
|
|
329
|
+
await deleteConfigFile(context.getConfigPath(`${name}.json`));
|
|
330
|
+
};
|
|
331
|
+
const deletePipelineConfigFileByPath = async (absolutePath, context) => {
|
|
332
|
+
await deleteConfigFile(absolutePath);
|
|
333
|
+
};
|
|
334
|
+
//#endregion
|
|
335
|
+
Object.defineProperty(exports, "__commonJSMin", {
|
|
336
|
+
enumerable: true,
|
|
337
|
+
get: function() {
|
|
338
|
+
return __commonJSMin;
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
Object.defineProperty(exports, "__exportAll", {
|
|
342
|
+
enumerable: true,
|
|
343
|
+
get: function() {
|
|
344
|
+
return __exportAll;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
Object.defineProperty(exports, "__reExport", {
|
|
348
|
+
enumerable: true,
|
|
349
|
+
get: function() {
|
|
350
|
+
return __reExport;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
Object.defineProperty(exports, "__toESM", {
|
|
354
|
+
enumerable: true,
|
|
355
|
+
get: function() {
|
|
356
|
+
return __toESM;
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
Object.defineProperty(exports, "config_exports", {
|
|
360
|
+
enumerable: true,
|
|
361
|
+
get: function() {
|
|
362
|
+
return config_exports;
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
Object.defineProperty(exports, "deletePipelineConfigFileByName", {
|
|
366
|
+
enumerable: true,
|
|
367
|
+
get: function() {
|
|
368
|
+
return deletePipelineConfigFileByName;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
Object.defineProperty(exports, "deletePipelineConfigFileByPath", {
|
|
372
|
+
enumerable: true,
|
|
373
|
+
get: function() {
|
|
374
|
+
return deletePipelineConfigFileByPath;
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
Object.defineProperty(exports, "downloadFile", {
|
|
378
|
+
enumerable: true,
|
|
379
|
+
get: function() {
|
|
380
|
+
return downloadFile;
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
Object.defineProperty(exports, "ensure", {
|
|
384
|
+
enumerable: true,
|
|
385
|
+
get: function() {
|
|
386
|
+
return ensure;
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
Object.defineProperty(exports, "extractTarGz", {
|
|
390
|
+
enumerable: true,
|
|
391
|
+
get: function() {
|
|
392
|
+
return extractTarGz;
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
Object.defineProperty(exports, "extractZip", {
|
|
396
|
+
enumerable: true,
|
|
397
|
+
get: function() {
|
|
398
|
+
return extractZip;
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
Object.defineProperty(exports, "getFolderSize", {
|
|
402
|
+
enumerable: true,
|
|
403
|
+
get: function() {
|
|
404
|
+
return getFolderSize;
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
Object.defineProperty(exports, "runWithLiveLogs", {
|
|
408
|
+
enumerable: true,
|
|
409
|
+
get: function() {
|
|
410
|
+
return runWithLiveLogs;
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
Object.defineProperty(exports, "setupConnectionsConfigFile", {
|
|
414
|
+
enumerable: true,
|
|
415
|
+
get: function() {
|
|
416
|
+
return setupConnectionsConfigFile;
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
Object.defineProperty(exports, "setupPipelineConfigFileByName", {
|
|
420
|
+
enumerable: true,
|
|
421
|
+
get: function() {
|
|
422
|
+
return setupPipelineConfigFileByName;
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
Object.defineProperty(exports, "setupPipelineConfigFileByPath", {
|
|
426
|
+
enumerable: true,
|
|
427
|
+
get: function() {
|
|
428
|
+
return setupPipelineConfigFileByPath;
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
Object.defineProperty(exports, "setupProjectsConfigFile", {
|
|
432
|
+
enumerable: true,
|
|
433
|
+
get: function() {
|
|
434
|
+
return setupProjectsConfigFile;
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
Object.defineProperty(exports, "setupSettingsConfigFile", {
|
|
438
|
+
enumerable: true,
|
|
439
|
+
get: function() {
|
|
440
|
+
return setupSettingsConfigFile;
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
Object.defineProperty(exports, "zipFolder", {
|
|
444
|
+
enumerable: true,
|
|
445
|
+
get: function() {
|
|
446
|
+
return zipFolder;
|
|
447
|
+
}
|
|
448
|
+
});
|