@pipelab/plugin-core 1.0.0-beta.1 → 1.0.0-beta.11
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/dist/index.cjs +53 -91
- package/dist/index.mjs +53 -91
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -5
- package/CHANGELOG.md +0 -19
- package/src/archive-utils.ts +0 -127
- package/src/create-plugin.ts +0 -8
- package/src/custom-errors.ts +0 -11
- package/src/fs-utils.ts +0 -31
- package/src/node-utils.ts +0 -52
- package/src/pipelab.ts +0 -95
- package/src/utils.ts +0 -26
- package/tsconfig.json +0 -9
- package/tsdown.config.ts +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipelab/plugin-core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
4
4
|
"description": "Core library for building Pipelab plugins",
|
|
5
5
|
"license": "FSL-1.1-MIT",
|
|
6
6
|
"author": "CynToolkit",
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"url": "https://github.com/CynToolkit/pipelab.git",
|
|
10
10
|
"directory": "plugins/plugin-core"
|
|
11
11
|
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
12
15
|
"type": "module",
|
|
13
16
|
"main": "./dist/index.cjs",
|
|
14
17
|
"module": "./dist/index.mjs",
|
|
@@ -35,7 +38,7 @@
|
|
|
35
38
|
"type-fest": "4.26.1",
|
|
36
39
|
"yauzl": "2.10.0",
|
|
37
40
|
"zod": "4.3.6",
|
|
38
|
-
"@pipelab/core-node": "1.0.0-beta.
|
|
41
|
+
"@pipelab/core-node": "1.0.0-beta.10"
|
|
39
42
|
},
|
|
40
43
|
"devDependencies": {
|
|
41
44
|
"@types/archiver": "7.0.0",
|
|
@@ -44,9 +47,9 @@
|
|
|
44
47
|
"@types/yauzl": "2.10.3",
|
|
45
48
|
"tsdown": "0.21.2",
|
|
46
49
|
"typescript": "5.9.3",
|
|
47
|
-
"@pipelab/constants": "1.0.0-beta.
|
|
48
|
-
"@pipelab/shared": "1.0.0-beta.
|
|
49
|
-
"@pipelab/tsconfig": "1.0.0-beta.
|
|
50
|
+
"@pipelab/constants": "1.0.0-beta.8",
|
|
51
|
+
"@pipelab/shared": "1.0.0-beta.6",
|
|
52
|
+
"@pipelab/tsconfig": "1.0.0-beta.6"
|
|
50
53
|
},
|
|
51
54
|
"scripts": {
|
|
52
55
|
"build": "tsdown",
|
package/CHANGELOG.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# @pipelab/plugin-core
|
|
2
|
-
|
|
3
|
-
## 1.0.0-beta.1
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies
|
|
8
|
-
- @pipelab/core-node@1.0.0-beta.1
|
|
9
|
-
|
|
10
|
-
## 1.0.0-beta.0
|
|
11
|
-
|
|
12
|
-
### Major Changes
|
|
13
|
-
|
|
14
|
-
- e1befbf: initial release
|
|
15
|
-
|
|
16
|
-
### Patch Changes
|
|
17
|
-
|
|
18
|
-
- Updated dependencies [e1befbf]
|
|
19
|
-
- @pipelab/core-node@1.0.0-beta.0
|
package/src/archive-utils.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { mkdir, createReadStream, createWriteStream } from "node:fs";
|
|
2
|
-
import { mkdir as mkdirP } from "node:fs/promises";
|
|
3
|
-
import { join, dirname } from "node:path";
|
|
4
|
-
import zlib from "zlib";
|
|
5
|
-
import tar from "tar";
|
|
6
|
-
import yauzl from "yauzl";
|
|
7
|
-
import archiver from "archiver";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Extracts a .tar.gz archive.
|
|
11
|
-
* @param archivePath The full path to the .tar.gz file.
|
|
12
|
-
* @param destinationDir The directory to extract contents into.
|
|
13
|
-
* @returns A Promise that resolves when extraction is complete.
|
|
14
|
-
*/
|
|
15
|
-
export async function extractTarGz(archivePath: string, destinationDir: string): Promise<void> {
|
|
16
|
-
console.log(`Extracting ${archivePath} to ${destinationDir}...`);
|
|
17
|
-
|
|
18
|
-
// Ensure the destination directory exists
|
|
19
|
-
await mkdirP(destinationDir, { recursive: true });
|
|
20
|
-
|
|
21
|
-
await tar.x({
|
|
22
|
-
file: archivePath,
|
|
23
|
-
cwd: destinationDir,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
console.log("Extraction finished.");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Extracts a .zip archive.
|
|
31
|
-
* @param archivePath The full path to the .zip file.
|
|
32
|
-
* @param destinationDir The directory to extract contents into.
|
|
33
|
-
* @returns A Promise that resolves when extraction is complete.
|
|
34
|
-
*/
|
|
35
|
-
export async function extractZip(archivePath: string, destinationDir: string): Promise<void> {
|
|
36
|
-
console.log(`Extracting ${archivePath} to ${destinationDir}...`);
|
|
37
|
-
|
|
38
|
-
// Ensure the destination directory exists
|
|
39
|
-
await mkdirP(destinationDir, { recursive: true });
|
|
40
|
-
|
|
41
|
-
return new Promise((resolve, reject) => {
|
|
42
|
-
yauzl.open(archivePath, { lazyEntries: true }, (err, zipfile) => {
|
|
43
|
-
if (err || !zipfile) {
|
|
44
|
-
return reject(err || new Error("Could not open zip file"));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
zipfile.on("error", reject);
|
|
48
|
-
|
|
49
|
-
zipfile.readEntry(); // Start reading entries
|
|
50
|
-
|
|
51
|
-
zipfile.on("entry", (entry) => {
|
|
52
|
-
const entryPath = join(destinationDir, entry.fileName);
|
|
53
|
-
|
|
54
|
-
if (/\/$/.test(entry.fileName)) {
|
|
55
|
-
// It's a directory
|
|
56
|
-
mkdirP(entryPath, { recursive: true })
|
|
57
|
-
.then(() => zipfile.readEntry())
|
|
58
|
-
.catch(reject);
|
|
59
|
-
} else {
|
|
60
|
-
// It's a file
|
|
61
|
-
// Ensure parent directory exists (just in case)
|
|
62
|
-
mkdirP(dirname(entryPath), { recursive: true })
|
|
63
|
-
.then(() => {
|
|
64
|
-
zipfile.openReadStream(entry, (err, readStream) => {
|
|
65
|
-
if (err || !readStream) {
|
|
66
|
-
return reject(err || new Error("Could not open read stream"));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
readStream.on("error", reject);
|
|
70
|
-
const writeStream = createWriteStream(entryPath);
|
|
71
|
-
writeStream.on("error", reject);
|
|
72
|
-
writeStream.on("close", () => {
|
|
73
|
-
zipfile.readEntry();
|
|
74
|
-
});
|
|
75
|
-
readStream.pipe(writeStream);
|
|
76
|
-
});
|
|
77
|
-
})
|
|
78
|
-
.catch(reject);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
zipfile.on("end", () => {
|
|
83
|
-
console.log("Zip extraction finished.");
|
|
84
|
-
resolve();
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export const zipFolder = async (from: string, to: string, log: typeof console.log) => {
|
|
91
|
-
const output = createWriteStream(to);
|
|
92
|
-
|
|
93
|
-
const archive = archiver("zip", {
|
|
94
|
-
zlib: { level: 9 }, // Sets the compression level.
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// eslint-disable-next-line no-async-promise-executor
|
|
98
|
-
return new Promise<string>(async (resolve, reject) => {
|
|
99
|
-
// listen for all archive data to be written
|
|
100
|
-
// 'close' event is fired only when a file descriptor is involved
|
|
101
|
-
output.on("close", function () {
|
|
102
|
-
log(archive.pointer() + " total bytes");
|
|
103
|
-
log("archiver has been finalized and the output file descriptor has closed.");
|
|
104
|
-
resolve(to);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// This event is fired when the data source is drained no matter what was the data source.
|
|
108
|
-
// It is not part of this library but part of NodeJS.
|
|
109
|
-
output.on("end", function () {
|
|
110
|
-
log("Data has been drained");
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
// good practice to catch this error and expose it to the user
|
|
114
|
-
archive.on("error", function (err) {
|
|
115
|
-
reject(err);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// pipe archive data to the file
|
|
119
|
-
archive.pipe(output);
|
|
120
|
-
|
|
121
|
-
archive.directory(from, false);
|
|
122
|
-
|
|
123
|
-
// finalize the archive (ie we are done appending files but streams have to finish yet)
|
|
124
|
-
// 'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand
|
|
125
|
-
await archive.finalize();
|
|
126
|
-
});
|
|
127
|
-
};
|
package/src/create-plugin.ts
DELETED
package/src/custom-errors.ts
DELETED
package/src/fs-utils.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { access, mkdir, realpath, writeFile, mkdtemp } from "node:fs/promises";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { readdirSync, copyFileSync, statSync } from "node:fs";
|
|
5
|
-
|
|
6
|
-
export const ensure = async (filesPath: string, defaultContent = "{}") => {
|
|
7
|
-
// create parent folder
|
|
8
|
-
await mkdir(dirname(filesPath), {
|
|
9
|
-
recursive: true,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
// ensure file exist
|
|
13
|
-
try {
|
|
14
|
-
await access(filesPath);
|
|
15
|
-
} catch {
|
|
16
|
-
// File doesn't exist, create it
|
|
17
|
-
await writeFile(filesPath, defaultContent); // json
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const generateTempFolder = async (base?: string) => {
|
|
22
|
-
const targetBase = base || tmpdir();
|
|
23
|
-
await mkdir(targetBase, {
|
|
24
|
-
recursive: true,
|
|
25
|
-
});
|
|
26
|
-
const realPath = await realpath(targetBase);
|
|
27
|
-
console.log("join", join(realPath, "pipelab-"));
|
|
28
|
-
const tempFolder = await mkdtemp(join(realPath, "pipelab-"));
|
|
29
|
-
|
|
30
|
-
return tempFolder;
|
|
31
|
-
};
|
package/src/node-utils.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { access } from "node:fs/promises";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
|
|
4
|
-
export type OutputRuntimes = "construct" | "godot";
|
|
5
|
-
|
|
6
|
-
const fileExists = async (path: string): Promise<boolean> => {
|
|
7
|
-
try {
|
|
8
|
-
await access(path);
|
|
9
|
-
return true;
|
|
10
|
-
} catch {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Detects the runtime of an app folder by checking for specific files.
|
|
17
|
-
* This function depends on Node.js APIs and should only be used in Node environments.
|
|
18
|
-
*/
|
|
19
|
-
export const detectRuntime = async (
|
|
20
|
-
appFolder: string | undefined,
|
|
21
|
-
): Promise<OutputRuntimes | undefined> => {
|
|
22
|
-
if (!appFolder) {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const indexExist = await fileExists(join(appFolder, "index.html"));
|
|
27
|
-
const swExist = await fileExists(join(appFolder, "sw.js"));
|
|
28
|
-
const offlineJSON = await fileExists(join(appFolder, "offline.json"));
|
|
29
|
-
const dataJSON = await fileExists(join(appFolder, "data.json"));
|
|
30
|
-
const scriptsFolder = await fileExists(join(appFolder, "scripts"));
|
|
31
|
-
const workermainJs = await fileExists(join(appFolder, "workermain.js"));
|
|
32
|
-
|
|
33
|
-
if (!indexExist) {
|
|
34
|
-
throw new Error("The input folder does not contain an index.html file");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let detectedRuntime: OutputRuntimes | undefined = undefined;
|
|
38
|
-
|
|
39
|
-
if (swExist || dataJSON || workermainJs || scriptsFolder) {
|
|
40
|
-
detectedRuntime = "construct";
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.log("Detected runtime", detectedRuntime);
|
|
44
|
-
|
|
45
|
-
if (detectedRuntime === "construct" && offlineJSON && swExist) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
"Construct runtime detected, please disable offline capabilties when using HTML5 export. Offline is already supported by default.",
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return detectedRuntime;
|
|
52
|
-
};
|
package/src/pipelab.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import type { BrowserWindow } from "electron";
|
|
2
|
-
import type {
|
|
3
|
-
Action,
|
|
4
|
-
Condition,
|
|
5
|
-
Loop,
|
|
6
|
-
Expression,
|
|
7
|
-
Event,
|
|
8
|
-
SetOutputActionFn,
|
|
9
|
-
SetOutputLoopFn,
|
|
10
|
-
SetOutputExpressionFn,
|
|
11
|
-
ExtractInputsFromAction,
|
|
12
|
-
ExtractInputsFromCondition,
|
|
13
|
-
ExtractInputsFromLoop,
|
|
14
|
-
ExtractInputsFromEvent,
|
|
15
|
-
ExtractInputsFromExpression,
|
|
16
|
-
} from "@pipelab/shared";
|
|
17
|
-
|
|
18
|
-
export * from "@pipelab/shared";
|
|
19
|
-
import {
|
|
20
|
-
type RunnerCallbackFnArgument,
|
|
21
|
-
type ActionRunnerData,
|
|
22
|
-
type ActionRunner,
|
|
23
|
-
type ConditionRunner,
|
|
24
|
-
type LoopRunner,
|
|
25
|
-
type ExpressionRunner,
|
|
26
|
-
type EventRunner,
|
|
27
|
-
type Runner,
|
|
28
|
-
PipelabContext,
|
|
29
|
-
} from "@pipelab/core-node";
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
type RunnerCallbackFnArgument,
|
|
33
|
-
type ActionRunnerData,
|
|
34
|
-
type ActionRunner,
|
|
35
|
-
type ConditionRunner,
|
|
36
|
-
type LoopRunner,
|
|
37
|
-
type ExpressionRunner,
|
|
38
|
-
type EventRunner,
|
|
39
|
-
type Runner,
|
|
40
|
-
PipelabContext,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const createActionRunner = <ACTION extends Action>(
|
|
44
|
-
runner: (data: ActionRunnerData<ACTION>) => Promise<void>,
|
|
45
|
-
) => runner;
|
|
46
|
-
|
|
47
|
-
export const createConditionRunner = <CONDITION extends Condition>(
|
|
48
|
-
runner: (data: {
|
|
49
|
-
log: typeof console.log;
|
|
50
|
-
inputs: ExtractInputsFromCondition<CONDITION>;
|
|
51
|
-
setMeta: (callback: (data: CONDITION["meta"]) => CONDITION["meta"]) => void;
|
|
52
|
-
meta: CONDITION["meta"];
|
|
53
|
-
cwd: string;
|
|
54
|
-
context: PipelabContext;
|
|
55
|
-
}) => Promise<boolean>,
|
|
56
|
-
) => runner;
|
|
57
|
-
|
|
58
|
-
export const createLoopRunner = <LOOP extends Loop>(
|
|
59
|
-
runner: (data: {
|
|
60
|
-
log: typeof console.log;
|
|
61
|
-
setOutput: SetOutputLoopFn<LOOP>;
|
|
62
|
-
inputs: ExtractInputsFromLoop<LOOP>;
|
|
63
|
-
setMeta: (callback: (data: LOOP["meta"]) => LOOP["meta"]) => void;
|
|
64
|
-
meta: LOOP["meta"];
|
|
65
|
-
cwd: string;
|
|
66
|
-
context: PipelabContext;
|
|
67
|
-
}) => Promise<"step" | "exit">,
|
|
68
|
-
) => runner;
|
|
69
|
-
|
|
70
|
-
export const createExpressionRunner = <EXPRESSION extends Expression>(
|
|
71
|
-
runner: (data: {
|
|
72
|
-
log: typeof console.log;
|
|
73
|
-
setOutput: SetOutputExpressionFn<EXPRESSION>;
|
|
74
|
-
inputs: ExtractInputsFromExpression<EXPRESSION>;
|
|
75
|
-
setMeta: (callback: (data: EXPRESSION["meta"]) => EXPRESSION["meta"]) => void;
|
|
76
|
-
meta: EXPRESSION["meta"];
|
|
77
|
-
cwd: string;
|
|
78
|
-
context: PipelabContext;
|
|
79
|
-
}) => Promise<string>,
|
|
80
|
-
) => runner;
|
|
81
|
-
|
|
82
|
-
export const createEventRunner = <EVENT extends Event>(
|
|
83
|
-
runner: (data: {
|
|
84
|
-
log: typeof console.log;
|
|
85
|
-
inputs: ExtractInputsFromEvent<EVENT>;
|
|
86
|
-
setMeta: (callback: (data: EVENT["meta"]) => EVENT["meta"]) => void;
|
|
87
|
-
meta: EVENT["meta"];
|
|
88
|
-
cwd: string;
|
|
89
|
-
context: PipelabContext;
|
|
90
|
-
}) => Promise<void>,
|
|
91
|
-
) => runner;
|
|
92
|
-
|
|
93
|
-
export const sleep = (duration: number) => {
|
|
94
|
-
return new Promise((resolve) => setTimeout(resolve, duration));
|
|
95
|
-
};
|
package/src/utils.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Options, Subprocess } from "execa";
|
|
2
|
-
export {
|
|
3
|
-
fetchPackage,
|
|
4
|
-
fetchPipelabAsset,
|
|
5
|
-
fetchPipelabPlugin,
|
|
6
|
-
fetchPipelabCli,
|
|
7
|
-
runPnpm,
|
|
8
|
-
downloadFile,
|
|
9
|
-
runWithLiveLogs,
|
|
10
|
-
} from "@pipelab/core-node";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Re-exporting hooks type for backward compatibility
|
|
14
|
-
*/
|
|
15
|
-
export type { DownloadHooks as Hooks } from "@pipelab/core-node";
|
|
16
|
-
|
|
17
|
-
// Keep runtime-only utilities that don't depend on complex engine state
|
|
18
|
-
export const fileExists = async (path: string): Promise<boolean> => {
|
|
19
|
-
try {
|
|
20
|
-
const { access } = await import("node:fs/promises");
|
|
21
|
-
await access(path);
|
|
22
|
-
return true;
|
|
23
|
-
} catch {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
};
|
package/tsconfig.json
DELETED
package/tsdown.config.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsdown";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: ["src/index.ts"],
|
|
5
|
-
format: ["esm", "cjs"],
|
|
6
|
-
dts: true,
|
|
7
|
-
clean: true,
|
|
8
|
-
loader: {
|
|
9
|
-
".webp": "dataurl",
|
|
10
|
-
".png": "dataurl",
|
|
11
|
-
".jpg": "dataurl",
|
|
12
|
-
".jpeg": "dataurl",
|
|
13
|
-
".svg": "dataurl",
|
|
14
|
-
},
|
|
15
|
-
});
|