@invarn/cibuild 2.4.1 → 2.4.2
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/cli.cjs +29 -15
- package/dist/src/yaml/steps/render-post-processor.d.ts +6 -0
- package/dist/src/yaml/steps/render-post-processor.d.ts.map +1 -1
- package/dist/src/yaml/steps/render-post-processor.js +19 -5
- package/dist/src/yaml/steps/render-post-processor.test.js +50 -0
- package/package.json +1 -1
|
@@ -52,6 +52,12 @@ export interface TrimDims {
|
|
|
52
52
|
export interface TrimHelperInvocation {
|
|
53
53
|
cmd: string;
|
|
54
54
|
args: string[];
|
|
55
|
+
/** Child environment override. Set only for the pkg self-exec, where the
|
|
56
|
+
* node-invoke sentinel (PKG_EXECPATH) must be stripped so the re-executed ci
|
|
57
|
+
* binary runs its baked cli entrypoint (dispatching `fidelity-trim`) instead
|
|
58
|
+
* of re-entering Node-emulation and treating it as a script path. Absent for
|
|
59
|
+
* the other homes, which spawn with the inherited environment unchanged. */
|
|
60
|
+
env?: Record<string, string>;
|
|
55
61
|
}
|
|
56
62
|
/**
|
|
57
63
|
* The platform-neutral helpers embedded in the trim-stage script.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-post-processor.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/render-post-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,wBAAwB,EAAE,
|
|
1
|
+
{"version":3,"file":"render-post-processor.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/render-post-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,wBAAwB,EAAE,MA6HtC,CAAC;AAEF,iFAAiF;AACjF,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5C,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,YAAY,CAAC;IACxB,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,EAAE,CAAC;IACf;;;;iFAI6E;IAC7E,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,oBAAoB,CAAC;IAC3D,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;QAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1F;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,CAAC,EAAE;IACpD,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,sBAAsB,CASzB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAqBhD"}
|
|
@@ -88,7 +88,22 @@ function trimHelperInvocation(args) {
|
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
if (process.pkg) {
|
|
91
|
-
|
|
91
|
+
// The runner spawns this script as 'node <script>', which the pkg binary
|
|
92
|
+
// intercepts and runs in Node-emulation mode -- so process.env carries
|
|
93
|
+
// pkg's node-invoke sentinel (PKG_EXECPATH). Re-execing process.execPath
|
|
94
|
+
// with it still set makes the child ci binary ALSO enter Node-emulation and
|
|
95
|
+
// treat 'fidelity-trim' as a main-module script path (Cannot find module
|
|
96
|
+
// '<cwd>/fidelity-trim'), never reaching the subcommand dispatch -- so the
|
|
97
|
+
// trim silently fails and untrimmed renders ship. Strip PKG_EXECPATH from
|
|
98
|
+
// the child env so the re-exec runs the baked cli entrypoint, which routes
|
|
99
|
+
// 'fidelity-trim' to the in-binary helper (with bundled pngjs).
|
|
100
|
+
var invocation = { cmd: process.execPath, args: ['fidelity-trim'].concat(args) };
|
|
101
|
+
if (process.env.PKG_EXECPATH !== undefined) {
|
|
102
|
+
var appEnv = Object.assign({}, process.env);
|
|
103
|
+
delete appEnv.PKG_EXECPATH;
|
|
104
|
+
invocation.env = appEnv;
|
|
105
|
+
}
|
|
106
|
+
return invocation;
|
|
92
107
|
}
|
|
93
108
|
return { cmd: 'ci', args: ['fidelity-trim'].concat(args) };
|
|
94
109
|
}
|
|
@@ -97,10 +112,9 @@ function trimHelperInvocation(args) {
|
|
|
97
112
|
// stdout line, and exit codes are the retired CoreGraphics helper's contract).
|
|
98
113
|
function runTrimHelper(args) {
|
|
99
114
|
var invocation = trimHelperInvocation(args);
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
});
|
|
115
|
+
var options = { encoding: 'utf-8', maxBuffer: 16 * 1024 * 1024 };
|
|
116
|
+
if (invocation.env !== undefined) options.env = invocation.env;
|
|
117
|
+
var result = cp.spawnSync(invocation.cmd, invocation.args, options);
|
|
104
118
|
if (result.stdout) process.stdout.write(result.stdout);
|
|
105
119
|
if (result.stderr) process.stderr.write(result.stderr);
|
|
106
120
|
if (result.error) {
|
|
@@ -97,6 +97,56 @@ describe('trim stage — helper invocation resolution', () => {
|
|
|
97
97
|
args: ['fidelity-trim', 'in.png', 'out.png'],
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
|
+
// The production runner spawns the render step as `node <script>`, which the
|
|
101
|
+
// pkg-built ci binary intercepts and runs in Node-emulation mode — so the
|
|
102
|
+
// running script's process.env carries pkg's node-invoke sentinel
|
|
103
|
+
// (PKG_EXECPATH). If the trim re-exec inherits it, the child ci binary ALSO
|
|
104
|
+
// enters Node-emulation and treats 'fidelity-trim' as a main-module script
|
|
105
|
+
// path ("Cannot find module '<cwd>/fidelity-trim'") instead of dispatching
|
|
106
|
+
// the subcommand — the exact failure observed in production, which silently
|
|
107
|
+
// ships untrimmed renders. The re-exec must clear PKG_EXECPATH so the binary
|
|
108
|
+
// runs its baked cli entrypoint.
|
|
109
|
+
test('under pkg node-emulation the re-exec clears PKG_EXECPATH so the binary runs its app entrypoint', () => {
|
|
110
|
+
const { trimHelperInvocation } = internalsWith({
|
|
111
|
+
env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS', PATH: '/usr/bin:/bin' },
|
|
112
|
+
pkg: {},
|
|
113
|
+
execPath: '/opt/homebrew/bin/ci',
|
|
114
|
+
});
|
|
115
|
+
const invocation = trimHelperInvocation(['in.png', 'out.png']);
|
|
116
|
+
expect(invocation.cmd).toBe('/opt/homebrew/bin/ci');
|
|
117
|
+
expect(invocation.args).toEqual(['fidelity-trim', 'in.png', 'out.png']);
|
|
118
|
+
// A child env is supplied with the node-invoke sentinel removed, but the
|
|
119
|
+
// rest of the environment (PATH, etc.) preserved.
|
|
120
|
+
expect(invocation.env).toBeDefined();
|
|
121
|
+
expect(invocation.env?.PKG_EXECPATH).toBeUndefined();
|
|
122
|
+
expect(invocation.env?.PATH).toBe('/usr/bin:/bin');
|
|
123
|
+
});
|
|
124
|
+
test('runTrimHelper spawns the pkg re-exec with a PKG_EXECPATH-cleared env', () => {
|
|
125
|
+
const calls = [];
|
|
126
|
+
const fakeCp = {
|
|
127
|
+
spawnSync: (...args) => {
|
|
128
|
+
calls.push(args);
|
|
129
|
+
return { status: 0, stdout: 'TRIMDIMS 10 10 0 0 10 10\n', stderr: '' };
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
const { runTrimHelper } = getPostProcessorInternals({
|
|
133
|
+
cp: fakeCp,
|
|
134
|
+
processRef: {
|
|
135
|
+
env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS', FOO: 'bar' },
|
|
136
|
+
pkg: {},
|
|
137
|
+
execPath: '/opt/homebrew/bin/ci',
|
|
138
|
+
stdout: { write: () => true },
|
|
139
|
+
stderr: { write: () => true },
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
runTrimHelper(['in.png', 'out.png']);
|
|
143
|
+
expect(calls).toHaveLength(1);
|
|
144
|
+
const [cmd, , options] = calls[0];
|
|
145
|
+
expect(cmd).toBe('/opt/homebrew/bin/ci');
|
|
146
|
+
expect(options.env).toBeDefined();
|
|
147
|
+
expect(options.env?.PKG_EXECPATH).toBeUndefined();
|
|
148
|
+
expect(options.env?.FOO).toBe('bar');
|
|
149
|
+
});
|
|
100
150
|
test('runTrimHelper reports a spawn error as status 127 with the message appended', () => {
|
|
101
151
|
const calls = [];
|
|
102
152
|
const fakeCp = {
|