@pipelab/test-utils 0.0.1

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/.oxfmtrc.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "ignorePatterns": ["dist", "out", "node_modules", "bin"]
3
+ }
@@ -0,0 +1,14 @@
1
+
2
+
3
+ > @pipelab/test-utils@1.0.0-beta.3 build /run/media/armaldio/SSD/Projects/Pipelab/pipelab/packages/test-utils
4
+ > tsdown
5
+
6
+ ℹ tsdown v0.21.2 powered by rolldown v1.0.0-rc.9
7
+ ℹ entry: src/index.ts
8
+ ℹ tsconfig: ../../tsconfig.json
9
+ ℹ Build start
10
+ ℹ Cleaning 2 files
11
+ ℹ dist/index.mjs 5.01 kB │ gzip: 1.95 kB
12
+ ℹ dist/index.d.mts 1.80 kB │ gzip: 0.80 kB
13
+ ℹ 2 files, total: 6.82 kB
14
+ ✔ Build complete in 2141ms
@@ -0,0 +1,6 @@
1
+
2
+
3
+ > @pipelab/test-utils@1.0.0-beta.1 format /run/media/armaldio/SSD/Projects/Pipelab/pipelab/packages/test-utils
4
+ > oxfmt .
5
+
6
+ Finished in 464ms on 4 files using 16 threads.
@@ -0,0 +1,7 @@
1
+
2
+
3
+ > @pipelab/test-utils@1.0.0-beta.1 lint /run/media/armaldio/SSD/Projects/Pipelab/pipelab/packages/test-utils
4
+ > oxlint .
5
+
6
+ Found 0 warnings and 0 errors.
7
+ Finished in 21ms on 1 file with 93 rules using 16 threads.
package/CHANGELOG.md ADDED
@@ -0,0 +1,56 @@
1
+ # @pipelab/test-utils
2
+
3
+ ## 1.0.0-beta.6
4
+
5
+ ### Patch Changes
6
+
7
+ - beta tag
8
+ - Updated dependencies
9
+ - @pipelab/plugin-core@1.0.0-beta.6
10
+
11
+ ## 1.0.0-beta.5
12
+
13
+ ### Patch Changes
14
+
15
+ - bump
16
+ - Updated dependencies
17
+ - @pipelab/plugin-core@1.0.0-beta.5
18
+
19
+ ## 1.0.0-beta.4
20
+
21
+ ### Patch Changes
22
+
23
+ - @pipelab/plugin-core@1.0.0-beta.4
24
+
25
+ ## 1.0.0-beta.3
26
+
27
+ ### Patch Changes
28
+
29
+ - update
30
+ - Updated dependencies
31
+ - @pipelab/plugin-core@1.0.0-beta.3
32
+
33
+ ## 1.0.0-beta.2
34
+
35
+ ### Patch Changes
36
+
37
+ - general improvements
38
+ - Updated dependencies
39
+ - @pipelab/plugin-core@1.0.0-beta.2
40
+
41
+ ## 1.0.0-beta.1
42
+
43
+ ### Patch Changes
44
+
45
+ - @pipelab/plugin-core@1.0.0-beta.1
46
+
47
+ ## 1.0.0-beta.0
48
+
49
+ ### Major Changes
50
+
51
+ - e1befbf: initial release
52
+
53
+ ### Patch Changes
54
+
55
+ - Updated dependencies [e1befbf]
56
+ - @pipelab/plugin-core@1.0.0-beta.0
package/LICENSE ADDED
@@ -0,0 +1,110 @@
1
+ # Functional Source License, Version 1.1, MIT Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-MIT
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 CynToolkit
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the MIT license that is effective on the second anniversary of the date we make
91
+ the Software available. On or after that date, you may use the Software under
92
+ the MIT license, in which case the following will apply:
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
95
+ this software and associated documentation files (the "Software"), to deal in
96
+ the Software without restriction, including without limitation the rights to
97
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98
+ of the Software, and to permit persons to whom the Software is furnished to do
99
+ so, subject to the following conditions:
100
+
101
+ The above copyright notice and this permission notice shall be included in all
102
+ copies or substantial portions of the Software.
103
+
104
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
+ SOFTWARE.
@@ -0,0 +1,65 @@
1
+ import { Action, ActionRunner, ActionRunnerData } from "@pipelab/plugin-core";
2
+ import * as execa$1 from "execa";
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$1.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$1.Result<{
61
+ cleanup: true;
62
+ timeout: number;
63
+ }>>;
64
+ //#endregion
65
+ export { createSandbox, findProjectRoot, isLinux, isMac, isWindows, runAction, runCLI, runElectronApp };
package/dist/index.mjs ADDED
@@ -0,0 +1,142 @@
1
+ import { dirname, join, resolve } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { chmod, mkdir, rm, writeFile } from "node:fs/promises";
4
+ import { existsSync } from "node:fs";
5
+ import { tmpdir } from "node:os";
6
+ import { PipelabContext } from "@pipelab/plugin-core";
7
+ import { execa } from "execa";
8
+ //#region src/index.ts
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+ /**
11
+ * Finds the monorepo root by looking for pnpm-workspace.yaml.
12
+ */
13
+ function findProjectRoot(startDir) {
14
+ let curr = startDir;
15
+ while (curr !== dirname(curr)) {
16
+ if (existsSync(join(curr, "pnpm-workspace.yaml"))) return curr;
17
+ curr = dirname(curr);
18
+ }
19
+ throw new Error("Could not find project root (pnpm-workspace.yaml)");
20
+ }
21
+ const isWindows = process.platform === "win32";
22
+ const isMac = process.platform === "darwin";
23
+ const isLinux = process.platform === "linux";
24
+ /**
25
+ * Creates a unique sandbox directory and returns a bundle containing its path
26
+ * and a pre-filled remove utility.
27
+ */
28
+ const createSandbox = async (prefix) => {
29
+ const sandboxPath = join(tmpdir(), `${prefix}-${Math.random().toString(36).substring(7)}`);
30
+ const paths = {
31
+ input: join(sandboxPath, "input"),
32
+ output: join(sandboxPath, "output"),
33
+ userData: join(sandboxPath, "user-data"),
34
+ project: join(sandboxPath, "project"),
35
+ thirdparty: join(sandboxPath, "thirdparty")
36
+ };
37
+ await mkdir(sandboxPath, { recursive: true });
38
+ await Promise.all([
39
+ mkdir(paths.input, { recursive: true }),
40
+ mkdir(paths.output, { recursive: true }),
41
+ mkdir(paths.userData, { recursive: true })
42
+ ]);
43
+ return {
44
+ path: sandboxPath,
45
+ paths,
46
+ mockBinary: async (relativePath, content, options = {}) => {
47
+ const fullPath = join(sandboxPath, relativePath);
48
+ let platformPath = fullPath;
49
+ if (options.extension === false) {} else if (options.extension) platformPath = `${fullPath}.${options.extension}`;
50
+ else platformPath = /\.[a-z0-9]+$/i.test(relativePath) ? fullPath : isWindows ? `${fullPath}.cmd` : `${fullPath}.sh`;
51
+ const defaultContent = isWindows ? `@echo off\necho Mock Binary Execution: %*\nexit /b 0` : `#!/bin/bash\necho "Mock Binary Execution: $@"\nexit 0`;
52
+ await mkdir(dirname(platformPath), { recursive: true });
53
+ await writeFile(platformPath, content || defaultContent);
54
+ if (!isWindows) await chmod(platformPath, 493);
55
+ return platformPath;
56
+ },
57
+ remove: async () => {
58
+ await rm(sandboxPath, {
59
+ recursive: true,
60
+ force: true,
61
+ maxRetries: 20,
62
+ retryDelay: 500
63
+ });
64
+ }
65
+ };
66
+ };
67
+ /**
68
+ * Runs the Pipelab CLI out-of-process.
69
+ */
70
+ const runCLI = async (args, options = {}) => {
71
+ const projectRoot = findProjectRoot(__dirname);
72
+ return execa("tsx", [resolve(projectRoot, "apps/cli/src/index.ts"), ...args], {
73
+ cwd: options.cwd || projectRoot,
74
+ env: {
75
+ ...process.env,
76
+ PIPELAB_DISABLE_HISTORY: "true",
77
+ ...options.env
78
+ }
79
+ });
80
+ };
81
+ /**
82
+ * Runs a Pipelab action runner directly in-process for focused testing.
83
+ */
84
+ const runAction = async (runner, options) => {
85
+ const outputs = {};
86
+ const pnpmShimPath = join(options.sandboxPath, "pnpm-shim.cjs");
87
+ await writeFile(pnpmShimPath, `const { spawnSync } = require('child_process');
88
+ spawnSync('pnpm', process.argv.slice(2), { stdio: 'inherit', shell: true });`);
89
+ const context = {
90
+ inputs: options.inputs,
91
+ log: (...args) => {
92
+ console.log("[Runner Log]", ...args);
93
+ },
94
+ setOutput: (key, value) => {
95
+ console.log(`[Runner Output] ${key} = ${value}`);
96
+ outputs[key] = value;
97
+ },
98
+ cwd: options.sandboxPath,
99
+ paths: {
100
+ assets: join(options.sandboxPath, "assets"),
101
+ cache: join(options.sandboxPath, "cache"),
102
+ pnpm: pnpmShimPath,
103
+ node: process.execPath,
104
+ userData: join(options.sandboxPath, "user-data"),
105
+ modules: join(options.sandboxPath, "modules"),
106
+ thirdparty: join(options.sandboxPath, "thirdparty")
107
+ },
108
+ api: { fetchAsset: async (packageName) => {
109
+ const sandboxAssetPath = join(options.sandboxPath, "assets", packageName);
110
+ if (existsSync(sandboxAssetPath)) return sandboxAssetPath;
111
+ const folderName = packageName.startsWith("@pipelab/") ? packageName.replace("@pipelab/", "") : packageName;
112
+ return join(findProjectRoot(__dirname), "assets", folderName);
113
+ } },
114
+ browserWindow: void 0,
115
+ abortSignal: new AbortController().signal,
116
+ context: new PipelabContext({ userDataPath: join(options.sandboxPath, "user-data") }),
117
+ setMeta: () => {},
118
+ meta: {}
119
+ };
120
+ const originalEnv = { ...process.env };
121
+ if (options.extraEnv) Object.assign(process.env, options.extraEnv);
122
+ try {
123
+ await runner(context);
124
+ } finally {
125
+ if (options.extraEnv) {
126
+ for (const key in options.extraEnv) if (!(key in originalEnv)) delete process.env[key];
127
+ Object.assign(process.env, originalEnv);
128
+ }
129
+ }
130
+ return { outputs };
131
+ };
132
+ /**
133
+ * Runs the packaged electron app (smoke test)
134
+ */
135
+ const runElectronApp = async (app_path, options = {}) => {
136
+ return execa(app_path, [], {
137
+ cleanup: true,
138
+ timeout: options.timeoutMs || 12e4
139
+ });
140
+ };
141
+ //#endregion
142
+ export { createSandbox, findProjectRoot, isLinux, isMac, isWindows, runAction, runCLI, runElectronApp };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@pipelab/test-utils",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "description": "Testing utilities for Pipelab plugins and monorepo",
6
+ "license": "FSL-1.1-MIT",
7
+ "author": "CynToolkit",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/CynToolkit/pipelab.git",
11
+ "directory": "packages/test-utils"
12
+ },
13
+ "type": "module",
14
+ "main": "./dist/index.cjs",
15
+ "module": "./dist/index.mjs",
16
+ "types": "./dist/index.d.mts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.mts",
20
+ "import": "./dist/index.mjs",
21
+ "require": "./dist/index.cjs",
22
+ "default": "./dist/index.mjs"
23
+ }
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "dependencies": {
29
+ "execa": "9.5.1",
30
+ "@pipelab/plugin-core": "0.0.1"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "24.12.2",
34
+ "tsdown": "0.21.2",
35
+ "typescript": "^5.0.0",
36
+ "@pipelab/tsconfig": "0.0.1"
37
+ },
38
+ "scripts": {
39
+ "build": "tsdown",
40
+ "format": "oxfmt .",
41
+ "lint": "oxlint ."
42
+ }
43
+ }
package/src/index.ts ADDED
@@ -0,0 +1,228 @@
1
+ import { resolve, dirname, join } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { mkdir, writeFile, chmod, rm } from "node:fs/promises";
4
+ import { existsSync as existsSyncSync } from "node:fs";
5
+ import { tmpdir } from "node:os";
6
+ import {
7
+ type ActionRunner,
8
+ type ActionRunnerData,
9
+ type Action,
10
+ PipelabContext,
11
+ } from "@pipelab/plugin-core";
12
+ import { execa } from "execa";
13
+
14
+ const __filename = fileURLToPath(import.meta.url);
15
+ const __dirname = dirname(__filename);
16
+
17
+ /**
18
+ * Finds the monorepo root by looking for pnpm-workspace.yaml.
19
+ */
20
+ export function findProjectRoot(startDir: string): string {
21
+ let curr = startDir;
22
+ while (curr !== dirname(curr)) {
23
+ if (existsSyncSync(join(curr, "pnpm-workspace.yaml"))) {
24
+ return curr;
25
+ }
26
+ curr = dirname(curr);
27
+ }
28
+ throw new Error("Could not find project root (pnpm-workspace.yaml)");
29
+ }
30
+
31
+ export const isWindows = process.platform === "win32";
32
+ export const isMac = process.platform === "darwin";
33
+ export const isLinux = process.platform === "linux";
34
+
35
+ /**
36
+ * Creates a unique sandbox directory and returns a bundle containing its path
37
+ * and a pre-filled remove utility.
38
+ */
39
+ export const createSandbox = async (prefix: string) => {
40
+ const sandboxPath = join(tmpdir(), `${prefix}-${Math.random().toString(36).substring(7)}`);
41
+
42
+ const paths = {
43
+ input: join(sandboxPath, "input"),
44
+ output: join(sandboxPath, "output"),
45
+ userData: join(sandboxPath, "user-data"),
46
+ project: join(sandboxPath, "project"),
47
+ thirdparty: join(sandboxPath, "thirdparty"),
48
+ };
49
+
50
+ await mkdir(sandboxPath, { recursive: true });
51
+ await Promise.all([
52
+ mkdir(paths.input, { recursive: true }),
53
+ mkdir(paths.output, { recursive: true }),
54
+ mkdir(paths.userData, { recursive: true }),
55
+ ]);
56
+
57
+ return {
58
+ path: sandboxPath,
59
+ paths,
60
+ /**
61
+ * Creates a mock binary/script in the sandbox.
62
+ */
63
+ mockBinary: async (
64
+ relativePath: string,
65
+ content?: string,
66
+ options: { extension?: string | false } = {},
67
+ ) => {
68
+ const fullPath = join(sandboxPath, relativePath);
69
+ let platformPath = fullPath;
70
+
71
+ if (options.extension === false) {
72
+ // Use exactly the path provided
73
+ } else if (options.extension) {
74
+ platformPath = `${fullPath}.${options.extension}`;
75
+ } else {
76
+ const hasExtension = /\.[a-z0-9]+$/i.test(relativePath);
77
+ platformPath = hasExtension ? fullPath : isWindows ? `${fullPath}.cmd` : `${fullPath}.sh`;
78
+ }
79
+
80
+ const defaultContent = isWindows
81
+ ? `@echo off\necho Mock Binary Execution: %*\nexit /b 0`
82
+ : `#!/bin/bash\necho "Mock Binary Execution: $@"\nexit 0`;
83
+
84
+ await mkdir(dirname(platformPath), { recursive: true });
85
+ await writeFile(platformPath, content || defaultContent);
86
+
87
+ if (!isWindows) {
88
+ await chmod(platformPath, 0o755);
89
+ }
90
+
91
+ return platformPath;
92
+ },
93
+ remove: async () => {
94
+ await rm(sandboxPath, {
95
+ recursive: true,
96
+ force: true,
97
+ maxRetries: 20,
98
+ retryDelay: 500,
99
+ });
100
+ },
101
+ };
102
+ };
103
+
104
+ /**
105
+ * Runs the Pipelab CLI out-of-process.
106
+ */
107
+ export const runCLI = async (
108
+ args: string[],
109
+ options: {
110
+ cwd?: string;
111
+ env?: Record<string, string>;
112
+ } = {},
113
+ ) => {
114
+ const projectRoot = findProjectRoot(__dirname);
115
+ const cliPath = resolve(projectRoot, "apps/cli/src/index.ts");
116
+
117
+ return execa("tsx", [cliPath, ...args], {
118
+ cwd: options.cwd || projectRoot,
119
+ env: {
120
+ ...process.env,
121
+ PIPELAB_DISABLE_HISTORY: "true",
122
+ ...options.env,
123
+ },
124
+ });
125
+ };
126
+
127
+ /**
128
+ * Runs a Pipelab action runner directly in-process for focused testing.
129
+ */
130
+ export const runAction = async <A extends Action>(
131
+ runner: ActionRunner<A>,
132
+ options: {
133
+ inputs: ActionRunnerData<A>["inputs"];
134
+ sandboxPath: string;
135
+ extraEnv?: Record<string, string>;
136
+ },
137
+ ): Promise<{ outputs: Record<string, unknown> }> => {
138
+ const outputs: Record<string, unknown> = {};
139
+
140
+ // Create a pnpm shim because ensureNPMPackage expects a JS file runnable by node
141
+ const pnpmShimPath = join(options.sandboxPath, "pnpm-shim.cjs");
142
+ await writeFile(
143
+ pnpmShimPath,
144
+ `const { spawnSync } = require('child_process');
145
+ spawnSync('pnpm', process.argv.slice(2), { stdio: 'inherit', shell: true });`,
146
+ );
147
+
148
+ const context: ActionRunnerData<A> = {
149
+ inputs: options.inputs,
150
+ log: (...args: any[]) => {
151
+ console.log("[Runner Log]", ...args);
152
+ },
153
+ setOutput: (key: any, value: any) => {
154
+ console.log(`[Runner Output] ${key} = ${value}`);
155
+ outputs[key] = value;
156
+ },
157
+ cwd: options.sandboxPath,
158
+ paths: {
159
+ assets: join(options.sandboxPath, "assets"),
160
+ cache: join(options.sandboxPath, "cache"),
161
+ pnpm: pnpmShimPath,
162
+ node: process.execPath,
163
+ userData: join(options.sandboxPath, "user-data"),
164
+ modules: join(options.sandboxPath, "modules"),
165
+ thirdparty: join(options.sandboxPath, "thirdparty"),
166
+ },
167
+ api: {
168
+ fetchAsset: async (packageName: string) => {
169
+ const sandboxAssetPath = join(options.sandboxPath, "assets", packageName);
170
+ if (existsSyncSync(sandboxAssetPath)) {
171
+ return sandboxAssetPath;
172
+ }
173
+ // Fallback to real monorepo assets
174
+ // Normalize: remove @pipelab/ prefix if present
175
+ const folderName = packageName.startsWith("@pipelab/")
176
+ ? packageName.replace("@pipelab/", "")
177
+ : packageName;
178
+
179
+ const projectRoot = findProjectRoot(__dirname);
180
+ return join(projectRoot, "assets", folderName);
181
+ },
182
+ },
183
+ // @ts-ignore - Mocking BrowserWindow
184
+ browserWindow: undefined,
185
+ abortSignal: new AbortController().signal,
186
+ context: new PipelabContext({
187
+ userDataPath: join(options.sandboxPath, "user-data"),
188
+ }),
189
+ // @ts-ignore - Mocking setMeta
190
+ setMeta: () => {},
191
+ meta: {} as any,
192
+ };
193
+
194
+ // Set environment variables for the test if provided
195
+ const originalEnv = { ...process.env };
196
+ if (options.extraEnv) {
197
+ Object.assign(process.env, options.extraEnv);
198
+ }
199
+
200
+ try {
201
+ await runner(context);
202
+ } finally {
203
+ // Restore original environment
204
+ if (options.extraEnv) {
205
+ // Remove keys that were added
206
+ for (const key in options.extraEnv) {
207
+ if (!(key in originalEnv)) {
208
+ delete process.env[key];
209
+ }
210
+ }
211
+ // Restore original values
212
+ Object.assign(process.env, originalEnv);
213
+ }
214
+ }
215
+
216
+ return { outputs };
217
+ };
218
+
219
+ /**
220
+ * Runs the packaged electron app (smoke test)
221
+ */
222
+ export const runElectronApp = async (app_path: string, options: { timeoutMs?: number } = {}) => {
223
+ const child = execa(app_path, [], {
224
+ cleanup: true,
225
+ timeout: options.timeoutMs || 120000,
226
+ });
227
+ return child;
228
+ };