@pipelab/test-utils 1.0.0-beta.28 → 1.0.0-beta.32
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 +32 -0
- package/dist/index.cjs +150 -0
- package/dist/index.d.cts +66 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -0
- package/package.json +4 -3
- package/src/index.ts +0 -1
- package/tsconfig.json +14 -0
- package/tsdown.config.ts +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @pipelab/test-utils
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.32
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- sd
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @pipelab/plugin-core@1.0.0-beta.32
|
|
10
|
+
|
|
11
|
+
## 1.0.0-beta.31
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- sdsd
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @pipelab/plugin-core@1.0.0-beta.31
|
|
18
|
+
|
|
19
|
+
## 1.0.0-beta.30
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- sd
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
- @pipelab/plugin-core@1.0.0-beta.30
|
|
26
|
+
|
|
27
|
+
## 1.0.0-beta.29
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- sd
|
|
32
|
+
- Updated dependencies
|
|
33
|
+
- @pipelab/plugin-core@1.0.0-beta.29
|
|
34
|
+
|
|
3
35
|
## 1.0.0-beta.28
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
let node_url = require("node:url");
|
|
4
|
+
let node_fs_promises = require("node:fs/promises");
|
|
5
|
+
let node_fs = require("node:fs");
|
|
6
|
+
let node_os = require("node:os");
|
|
7
|
+
let _pipelab_plugin_core = require("@pipelab/plugin-core");
|
|
8
|
+
let execa = require("execa");
|
|
9
|
+
//#region src/index.ts
|
|
10
|
+
const __dirname$1 = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
11
|
+
/**
|
|
12
|
+
* Finds the monorepo root by looking for pnpm-workspace.yaml.
|
|
13
|
+
*/
|
|
14
|
+
function findProjectRoot(startDir) {
|
|
15
|
+
let curr = startDir;
|
|
16
|
+
while (curr !== (0, node_path.dirname)(curr)) {
|
|
17
|
+
if ((0, node_fs.existsSync)((0, node_path.join)(curr, "pnpm-workspace.yaml"))) return curr;
|
|
18
|
+
curr = (0, node_path.dirname)(curr);
|
|
19
|
+
}
|
|
20
|
+
throw new Error("Could not find project root (pnpm-workspace.yaml)");
|
|
21
|
+
}
|
|
22
|
+
const isWindows = process.platform === "win32";
|
|
23
|
+
const isMac = process.platform === "darwin";
|
|
24
|
+
const isLinux = process.platform === "linux";
|
|
25
|
+
/**
|
|
26
|
+
* Creates a unique sandbox directory and returns a bundle containing its path
|
|
27
|
+
* and a pre-filled remove utility.
|
|
28
|
+
*/
|
|
29
|
+
const createSandbox = async (prefix) => {
|
|
30
|
+
const sandboxPath = (0, node_path.join)((0, node_os.tmpdir)(), `${prefix}-${Math.random().toString(36).substring(7)}`);
|
|
31
|
+
const paths = {
|
|
32
|
+
input: (0, node_path.join)(sandboxPath, "input"),
|
|
33
|
+
output: (0, node_path.join)(sandboxPath, "output"),
|
|
34
|
+
userData: (0, node_path.join)(sandboxPath, "user-data"),
|
|
35
|
+
project: (0, node_path.join)(sandboxPath, "project"),
|
|
36
|
+
thirdparty: (0, node_path.join)(sandboxPath, "thirdparty")
|
|
37
|
+
};
|
|
38
|
+
await (0, node_fs_promises.mkdir)(sandboxPath, { recursive: true });
|
|
39
|
+
await Promise.all([
|
|
40
|
+
(0, node_fs_promises.mkdir)(paths.input, { recursive: true }),
|
|
41
|
+
(0, node_fs_promises.mkdir)(paths.output, { recursive: true }),
|
|
42
|
+
(0, node_fs_promises.mkdir)(paths.userData, { recursive: true })
|
|
43
|
+
]);
|
|
44
|
+
return {
|
|
45
|
+
path: sandboxPath,
|
|
46
|
+
paths,
|
|
47
|
+
mockBinary: async (relativePath, content, options = {}) => {
|
|
48
|
+
const fullPath = (0, node_path.join)(sandboxPath, relativePath);
|
|
49
|
+
let platformPath = fullPath;
|
|
50
|
+
if (options.extension === false) {} else if (options.extension) platformPath = `${fullPath}.${options.extension}`;
|
|
51
|
+
else platformPath = /\.[a-z0-9]+$/i.test(relativePath) ? fullPath : isWindows ? `${fullPath}.cmd` : `${fullPath}.sh`;
|
|
52
|
+
const defaultContent = isWindows ? `@echo off\necho Mock Binary Execution: %*\nexit /b 0` : `#!/bin/bash\necho "Mock Binary Execution: $@"\nexit 0`;
|
|
53
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(platformPath), { recursive: true });
|
|
54
|
+
await (0, node_fs_promises.writeFile)(platformPath, content || defaultContent);
|
|
55
|
+
if (!isWindows) await (0, node_fs_promises.chmod)(platformPath, 493);
|
|
56
|
+
return platformPath;
|
|
57
|
+
},
|
|
58
|
+
remove: async () => {
|
|
59
|
+
await (0, node_fs_promises.rm)(sandboxPath, {
|
|
60
|
+
recursive: true,
|
|
61
|
+
force: true,
|
|
62
|
+
maxRetries: 20,
|
|
63
|
+
retryDelay: 500
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Runs the Pipelab CLI out-of-process.
|
|
70
|
+
*/
|
|
71
|
+
const runCLI = async (args, options = {}) => {
|
|
72
|
+
const projectRoot = findProjectRoot(__dirname$1);
|
|
73
|
+
return (0, execa.execa)("tsx", [(0, node_path.resolve)(projectRoot, "apps/cli/src/index.ts"), ...args], {
|
|
74
|
+
cwd: options.cwd || projectRoot,
|
|
75
|
+
env: {
|
|
76
|
+
...process.env,
|
|
77
|
+
PIPELAB_DISABLE_HISTORY: "true",
|
|
78
|
+
...options.env
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Runs a Pipelab action runner directly in-process for focused testing.
|
|
84
|
+
*/
|
|
85
|
+
const runAction = async (runner, options) => {
|
|
86
|
+
const outputs = {};
|
|
87
|
+
const pnpmShimPath = (0, node_path.join)(options.sandboxPath, "pnpm-shim.cjs");
|
|
88
|
+
await (0, node_fs_promises.writeFile)(pnpmShimPath, `const { spawnSync } = require('child_process');
|
|
89
|
+
const result = spawnSync('pnpm', process.argv.slice(2), { stdio: 'inherit', shell: true });
|
|
90
|
+
process.exit(result.status ?? 0);`);
|
|
91
|
+
const context = {
|
|
92
|
+
inputs: options.inputs,
|
|
93
|
+
log: (...args) => {
|
|
94
|
+
console.log("[Runner Log]", ...args);
|
|
95
|
+
},
|
|
96
|
+
setOutput: (key, value) => {
|
|
97
|
+
console.log(`[Runner Output] ${key} = ${value}`);
|
|
98
|
+
outputs[key] = value;
|
|
99
|
+
},
|
|
100
|
+
cwd: options.sandboxPath,
|
|
101
|
+
paths: {
|
|
102
|
+
cache: (0, node_path.join)(options.sandboxPath, "cache"),
|
|
103
|
+
pnpm: pnpmShimPath,
|
|
104
|
+
node: process.execPath,
|
|
105
|
+
userData: (0, node_path.join)(options.sandboxPath, "user-data"),
|
|
106
|
+
modules: (0, node_path.join)(options.sandboxPath, "modules"),
|
|
107
|
+
thirdparty: (0, node_path.join)(options.sandboxPath, "thirdparty")
|
|
108
|
+
},
|
|
109
|
+
api: { fetchAsset: async (packageName) => {
|
|
110
|
+
const sandboxAssetPath = (0, node_path.join)(options.sandboxPath, "assets", packageName);
|
|
111
|
+
if ((0, node_fs.existsSync)(sandboxAssetPath)) return sandboxAssetPath;
|
|
112
|
+
const folderName = packageName.startsWith("@pipelab/") ? packageName.replace("@pipelab/", "") : packageName;
|
|
113
|
+
return (0, node_path.join)(findProjectRoot(__dirname$1), "assets", folderName);
|
|
114
|
+
} },
|
|
115
|
+
browserWindow: void 0,
|
|
116
|
+
abortSignal: new AbortController().signal,
|
|
117
|
+
context: new _pipelab_plugin_core.PipelabContext({ userDataPath: (0, node_path.join)(options.sandboxPath, "user-data") }),
|
|
118
|
+
setMeta: () => {},
|
|
119
|
+
meta: {}
|
|
120
|
+
};
|
|
121
|
+
const originalEnv = { ...process.env };
|
|
122
|
+
if (options.extraEnv) Object.assign(process.env, options.extraEnv);
|
|
123
|
+
try {
|
|
124
|
+
await runner(context);
|
|
125
|
+
} finally {
|
|
126
|
+
if (options.extraEnv) {
|
|
127
|
+
for (const key in options.extraEnv) if (!(key in originalEnv)) delete process.env[key];
|
|
128
|
+
Object.assign(process.env, originalEnv);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return { outputs };
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Runs the packaged electron app (smoke test)
|
|
135
|
+
*/
|
|
136
|
+
const runElectronApp = async (app_path, options = {}) => {
|
|
137
|
+
return (0, execa.execa)(app_path, [], {
|
|
138
|
+
cleanup: true,
|
|
139
|
+
timeout: options.timeoutMs || 12e4
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
//#endregion
|
|
143
|
+
exports.createSandbox = createSandbox;
|
|
144
|
+
exports.findProjectRoot = findProjectRoot;
|
|
145
|
+
exports.isLinux = isLinux;
|
|
146
|
+
exports.isMac = isMac;
|
|
147
|
+
exports.isWindows = isWindows;
|
|
148
|
+
exports.runAction = runAction;
|
|
149
|
+
exports.runCLI = runCLI;
|
|
150
|
+
exports.runElectronApp = runElectronApp;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as execa from "execa";
|
|
2
|
+
import { Action, ActionRunner, ActionRunnerData } from "@pipelab/plugin-core";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Finds the monorepo root by looking for pnpm-workspace.yaml.
|
|
7
|
+
*/
|
|
8
|
+
declare function findProjectRoot(startDir: string): string;
|
|
9
|
+
declare const isWindows: boolean;
|
|
10
|
+
declare const isMac: boolean;
|
|
11
|
+
declare const isLinux: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a unique sandbox directory and returns a bundle containing its path
|
|
14
|
+
* and a pre-filled remove utility.
|
|
15
|
+
*/
|
|
16
|
+
declare const createSandbox: (prefix: string) => Promise<{
|
|
17
|
+
path: string;
|
|
18
|
+
paths: {
|
|
19
|
+
input: string;
|
|
20
|
+
output: string;
|
|
21
|
+
userData: string;
|
|
22
|
+
project: string;
|
|
23
|
+
thirdparty: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Creates a mock binary/script in the sandbox.
|
|
27
|
+
*/
|
|
28
|
+
mockBinary: (relativePath: string, content?: string, options?: {
|
|
29
|
+
extension?: string | false;
|
|
30
|
+
}) => Promise<string>;
|
|
31
|
+
remove: () => Promise<void>;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Runs the Pipelab CLI out-of-process.
|
|
35
|
+
*/
|
|
36
|
+
declare const runCLI: (args: string[], options?: {
|
|
37
|
+
cwd?: string;
|
|
38
|
+
env?: Record<string, string>;
|
|
39
|
+
}) => Promise<execa.Result<{
|
|
40
|
+
cwd: string;
|
|
41
|
+
env: {
|
|
42
|
+
PIPELAB_DISABLE_HISTORY: string;
|
|
43
|
+
};
|
|
44
|
+
}>>;
|
|
45
|
+
/**
|
|
46
|
+
* Runs a Pipelab action runner directly in-process for focused testing.
|
|
47
|
+
*/
|
|
48
|
+
declare const runAction: <A extends Action>(runner: ActionRunner<A>, options: {
|
|
49
|
+
inputs: ActionRunnerData<A>["inputs"];
|
|
50
|
+
sandboxPath: string;
|
|
51
|
+
extraEnv?: Record<string, string>;
|
|
52
|
+
}) => Promise<{
|
|
53
|
+
outputs: Record<string, unknown>;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Runs the packaged electron app (smoke test)
|
|
57
|
+
*/
|
|
58
|
+
declare const runElectronApp: (app_path: string, options?: {
|
|
59
|
+
timeoutMs?: number;
|
|
60
|
+
}) => Promise<execa.Result<{
|
|
61
|
+
cleanup: true;
|
|
62
|
+
timeout: number;
|
|
63
|
+
}>>;
|
|
64
|
+
//#endregion
|
|
65
|
+
export { createSandbox, findProjectRoot, isLinux, isMac, isWindows, runAction, runCLI, runElectronApp };
|
|
66
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;iBAmBgB,eAAA,CAAgB,QAAA;AAAA,cAWnB,SAAA;AAAA,cACA,KAAA;AAAA,cACA,OAAA;;AAFb;;;cAQa,aAAA,GAAuB,MAAA,aAAc,OAAA;;;;;;;;;;;;qCAyBxB,OAAA,WACJ,OAAA;IACL,SAAA;EAAA,MAA4B,OAAA;;;;;;cAyChC,MAAA,GACX,IAAA,YACA,OAAA;EACE,GAAA;EACA,GAAA,GAAM,MAAA;AAAA,MACF,OAAA,CADQ,KAAA,CACR,MAAA;;;;;;;;;cAkBK,SAAA,aAA6B,MAAA,EACxC,MAAA,EAAQ,YAAA,CAAa,CAAA,GACrB,OAAA;EACE,MAAA,EAAQ,gBAAA,CAAiB,CAAA;EACzB,WAAA;EACA,QAAA,GAAW,MAAA;AAAA,MAEZ,OAAA;EAAU,OAAA,EAAS,MAAA;AAAA;AA9BtB;;;AAAA,cAmHa,cAAA,GAAwB,QAAA,UAAkB,OAAA;EAAW,SAAA;AAAA,MAAyB,OAAA,CAM1F,KAAA,CAN0F,MAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -62,4 +62,5 @@ declare const runElectronApp: (app_path: string, options?: {
|
|
|
62
62
|
timeout: number;
|
|
63
63
|
}>>;
|
|
64
64
|
//#endregion
|
|
65
|
-
export { createSandbox, findProjectRoot, isLinux, isMac, isWindows, runAction, runCLI, runElectronApp };
|
|
65
|
+
export { createSandbox, findProjectRoot, isLinux, isMac, isWindows, runAction, runCLI, runElectronApp };
|
|
66
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;iBAmBgB,eAAA,CAAgB,QAAA;AAAA,cAWnB,SAAA;AAAA,cACA,KAAA;AAAA,cACA,OAAA;;AAFb;;;cAQa,aAAA,GAAuB,MAAA,aAAc,OAAA;;;;;;;;;;;;qCAyBxB,OAAA,WACJ,OAAA;IACL,SAAA;EAAA,MAA4B,OAAA;;;;;;cAyChC,MAAA,GACX,IAAA,YACA,OAAA;EACE,GAAA;EACA,GAAA,GAAM,MAAA;AAAA,MACF,OAAA,CADQ,OAAA,CACR,MAAA;;;;;;;;;cAkBK,SAAA,aAA6B,MAAA,EACxC,MAAA,EAAQ,YAAA,CAAa,CAAA,GACrB,OAAA;EACE,MAAA,EAAQ,gBAAA,CAAiB,CAAA;EACzB,WAAA;EACA,QAAA,GAAW,MAAA;AAAA,MAEZ,OAAA;EAAU,OAAA,EAAS,MAAA;AAAA;AA9BtB;;;AAAA,cAmHa,cAAA,GAAwB,QAAA,UAAkB,OAAA;EAAW,SAAA;AAAA,MAAyB,OAAA,CAM1F,OAAA,CAN0F,MAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -98,7 +98,6 @@ process.exit(result.status ?? 0);`);
|
|
|
98
98
|
},
|
|
99
99
|
cwd: options.sandboxPath,
|
|
100
100
|
paths: {
|
|
101
|
-
assets: join(options.sandboxPath, "assets"),
|
|
102
101
|
cache: join(options.sandboxPath, "cache"),
|
|
103
102
|
pnpm: pnpmShimPath,
|
|
104
103
|
node: process.execPath,
|
|
@@ -141,3 +140,5 @@ const runElectronApp = async (app_path, options = {}) => {
|
|
|
141
140
|
};
|
|
142
141
|
//#endregion
|
|
143
142
|
export { createSandbox, findProjectRoot, isLinux, isMac, isWindows, runAction, runCLI, runElectronApp };
|
|
143
|
+
|
|
144
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["existsSyncSync"],"sources":["../src/index.ts"],"sourcesContent":["import { resolve, dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { mkdir, writeFile, chmod, rm } from \"node:fs/promises\";\nimport { existsSync as existsSyncSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport {\n type ActionRunner,\n type ActionRunnerData,\n type Action,\n PipelabContext,\n} from \"@pipelab/plugin-core\";\nimport { execa } from \"execa\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Finds the monorepo root by looking for pnpm-workspace.yaml.\n */\nexport function findProjectRoot(startDir: string): string {\n let curr = startDir;\n while (curr !== dirname(curr)) {\n if (existsSyncSync(join(curr, \"pnpm-workspace.yaml\"))) {\n return curr;\n }\n curr = dirname(curr);\n }\n throw new Error(\"Could not find project root (pnpm-workspace.yaml)\");\n}\n\nexport const isWindows = process.platform === \"win32\";\nexport const isMac = process.platform === \"darwin\";\nexport const isLinux = process.platform === \"linux\";\n\n/**\n * Creates a unique sandbox directory and returns a bundle containing its path\n * and a pre-filled remove utility.\n */\nexport const createSandbox = async (prefix: string) => {\n const sandboxPath = join(tmpdir(), `${prefix}-${Math.random().toString(36).substring(7)}`);\n\n const paths = {\n input: join(sandboxPath, \"input\"),\n output: join(sandboxPath, \"output\"),\n userData: join(sandboxPath, \"user-data\"),\n project: join(sandboxPath, \"project\"),\n thirdparty: join(sandboxPath, \"thirdparty\"),\n };\n\n await mkdir(sandboxPath, { recursive: true });\n await Promise.all([\n mkdir(paths.input, { recursive: true }),\n mkdir(paths.output, { recursive: true }),\n mkdir(paths.userData, { recursive: true }),\n ]);\n\n return {\n path: sandboxPath,\n paths,\n /**\n * Creates a mock binary/script in the sandbox.\n */\n mockBinary: async (\n relativePath: string,\n content?: string,\n options: { extension?: string | false } = {},\n ) => {\n const fullPath = join(sandboxPath, relativePath);\n let platformPath = fullPath;\n\n if (options.extension === false) {\n // Use exactly the path provided\n } else if (options.extension) {\n platformPath = `${fullPath}.${options.extension}`;\n } else {\n const hasExtension = /\\.[a-z0-9]+$/i.test(relativePath);\n platformPath = hasExtension ? fullPath : isWindows ? `${fullPath}.cmd` : `${fullPath}.sh`;\n }\n\n const defaultContent = isWindows\n ? `@echo off\\necho Mock Binary Execution: %*\\nexit /b 0`\n : `#!/bin/bash\\necho \"Mock Binary Execution: $@\"\\nexit 0`;\n\n await mkdir(dirname(platformPath), { recursive: true });\n await writeFile(platformPath, content || defaultContent);\n\n if (!isWindows) {\n await chmod(platformPath, 0o755);\n }\n\n return platformPath;\n },\n remove: async () => {\n await rm(sandboxPath, {\n recursive: true,\n force: true,\n maxRetries: 20,\n retryDelay: 500,\n });\n },\n };\n};\n\n/**\n * Runs the Pipelab CLI out-of-process.\n */\nexport const runCLI = async (\n args: string[],\n options: {\n cwd?: string;\n env?: Record<string, string>;\n } = {},\n) => {\n const projectRoot = findProjectRoot(__dirname);\n const cliPath = resolve(projectRoot, \"apps/cli/src/index.ts\");\n\n return execa(\"tsx\", [cliPath, ...args], {\n cwd: options.cwd || projectRoot,\n env: {\n ...process.env,\n PIPELAB_DISABLE_HISTORY: \"true\",\n ...options.env,\n },\n });\n};\n\n/**\n * Runs a Pipelab action runner directly in-process for focused testing.\n */\nexport const runAction = async <A extends Action>(\n runner: ActionRunner<A>,\n options: {\n inputs: ActionRunnerData<A>[\"inputs\"];\n sandboxPath: string;\n extraEnv?: Record<string, string>;\n },\n): Promise<{ outputs: Record<string, unknown> }> => {\n const outputs: Record<string, unknown> = {};\n\n // Create a pnpm shim because ensureNPMPackage expects a JS file runnable by node\n const pnpmShimPath = join(options.sandboxPath, \"pnpm-shim.cjs\");\n await writeFile(\n pnpmShimPath,\n `const { spawnSync } = require('child_process');\nconst result = spawnSync('pnpm', process.argv.slice(2), { stdio: 'inherit', shell: true });\nprocess.exit(result.status ?? 0);`,\n );\n\n const context: ActionRunnerData<A> = {\n inputs: options.inputs,\n log: (...args: any[]) => {\n console.log(\"[Runner Log]\", ...args);\n },\n setOutput: (key: any, value: any) => {\n console.log(`[Runner Output] ${key} = ${value}`);\n outputs[key] = value;\n },\n cwd: options.sandboxPath,\n paths: {\n cache: join(options.sandboxPath, \"cache\"),\n pnpm: pnpmShimPath,\n node: process.execPath,\n userData: join(options.sandboxPath, \"user-data\"),\n modules: join(options.sandboxPath, \"modules\"),\n thirdparty: join(options.sandboxPath, \"thirdparty\"),\n },\n api: {\n fetchAsset: async (packageName: string) => {\n const sandboxAssetPath = join(options.sandboxPath, \"assets\", packageName);\n if (existsSyncSync(sandboxAssetPath)) {\n return sandboxAssetPath;\n }\n // Fallback to real monorepo assets\n // Normalize: remove @pipelab/ prefix if present\n const folderName = packageName.startsWith(\"@pipelab/\")\n ? packageName.replace(\"@pipelab/\", \"\")\n : packageName;\n\n const projectRoot = findProjectRoot(__dirname);\n return join(projectRoot, \"assets\", folderName);\n },\n },\n // @ts-ignore - Mocking BrowserWindow\n browserWindow: undefined,\n abortSignal: new AbortController().signal,\n context: new PipelabContext({\n userDataPath: join(options.sandboxPath, \"user-data\"),\n }),\n // @ts-ignore - Mocking setMeta\n setMeta: () => {},\n meta: {} as any,\n };\n\n // Set environment variables for the test if provided\n const originalEnv = { ...process.env };\n if (options.extraEnv) {\n Object.assign(process.env, options.extraEnv);\n }\n\n try {\n await runner(context);\n } finally {\n // Restore original environment\n if (options.extraEnv) {\n // Remove keys that were added\n for (const key in options.extraEnv) {\n if (!(key in originalEnv)) {\n delete process.env[key];\n }\n }\n // Restore original values\n Object.assign(process.env, originalEnv);\n }\n }\n\n return { outputs };\n};\n\n/**\n * Runs the packaged electron app (smoke test)\n */\nexport const runElectronApp = async (app_path: string, options: { timeoutMs?: number } = {}) => {\n const child = execa(app_path, [], {\n cleanup: true,\n timeout: options.timeoutMs || 120000,\n });\n return child;\n};\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipelab/test-utils",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.32",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Testing utilities for Pipelab plugins and monorepo",
|
|
6
6
|
"license": "FSL-1.1-MIT",
|
|
@@ -27,17 +27,18 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"execa": "9.5.1",
|
|
30
|
-
"@pipelab/plugin-core": "1.0.0-beta.
|
|
30
|
+
"@pipelab/plugin-core": "1.0.0-beta.32"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "24.12.2",
|
|
34
34
|
"tsdown": "0.21.2",
|
|
35
35
|
"typescript": "^5.0.0",
|
|
36
|
-
"@pipelab/tsconfig": "1.0.0-beta.
|
|
36
|
+
"@pipelab/tsconfig": "1.0.0-beta.25"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsdown",
|
|
40
40
|
"format": "oxfmt .",
|
|
41
|
+
"typecheck": "tsc -b",
|
|
41
42
|
"lint": "oxlint ."
|
|
42
43
|
}
|
|
43
44
|
}
|
package/src/index.ts
CHANGED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig/node.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"moduleResolution": "bundler",
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"baseUrl": "."
|
|
10
|
+
},
|
|
11
|
+
"include": ["src/**/*"],
|
|
12
|
+
"exclude": ["node_modules", "dist"],
|
|
13
|
+
"references": [{ "path": "../../plugins/plugin-core" }]
|
|
14
|
+
}
|