@atolis-hq/wake 0.3.92 → 0.3.93
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.
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { execFile as nodeExecFile } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
2
4
|
import { promisify } from 'node:util';
|
|
3
5
|
const execFile = promisify(nodeExecFile);
|
|
4
6
|
export function createSourceUpdatePort(input) {
|
|
@@ -18,14 +20,17 @@ export function createSourceUpdatePort(input) {
|
|
|
18
20
|
},
|
|
19
21
|
async checkout(tag) {
|
|
20
22
|
await execute('git', ['checkout', tag], input.repoRoot);
|
|
23
|
+
// Dependencies are part of what a tag means; without refreshing them,
|
|
24
|
+
// node_modules can silently drift from the checked-out
|
|
25
|
+
// package-lock.json and the health check below only ever proves the
|
|
26
|
+
// previously-installed dependencies still compile, not this tag's own.
|
|
27
|
+
await execute('npm', npmInstallArgs(input.repoRoot), input.repoRoot);
|
|
21
28
|
},
|
|
22
29
|
async healthy() {
|
|
23
30
|
try {
|
|
24
31
|
// Verify the checked-out code can be built (TypeScript compiles).
|
|
25
32
|
// This is the minimal meaningful health check: the code must at least compile.
|
|
26
|
-
|
|
27
|
-
const buildArgs = ['exec', 'tsc', '--'];
|
|
28
|
-
await execute(buildCommand, [...buildArgs], input.repoRoot);
|
|
33
|
+
await execute('npm', ['exec', 'tsc', '--'], input.repoRoot);
|
|
29
34
|
return true;
|
|
30
35
|
}
|
|
31
36
|
catch {
|
|
@@ -34,6 +39,9 @@ export function createSourceUpdatePort(input) {
|
|
|
34
39
|
},
|
|
35
40
|
};
|
|
36
41
|
}
|
|
42
|
+
function npmInstallArgs(repoRoot) {
|
|
43
|
+
return existsSync(join(repoRoot, 'package-lock.json')) ? ['ci', '--include=dev'] : ['install'];
|
|
44
|
+
}
|
|
37
45
|
async function candidateTags(execute, repoRoot) {
|
|
38
46
|
await execute('git', ['fetch', '--tags'], repoRoot);
|
|
39
47
|
const output = await execute('git', ['tag', '--list', 'v*', '--sort=-v:refname'], repoRoot);
|
|
@@ -43,6 +51,23 @@ async function candidateTags(execute, repoRoot) {
|
|
|
43
51
|
.filter((line) => line.length > 0);
|
|
44
52
|
}
|
|
45
53
|
async function runProcess(command, args, cwd) {
|
|
54
|
+
// On Windows, npm resolves to an `npm.cmd` shim: execFile can't spawn it
|
|
55
|
+
// directly (ENOENT, since it isn't a real executable) and refuses to spawn
|
|
56
|
+
// it with a separate argument array either (EINVAL, Node's own hardening
|
|
57
|
+
// after CVE-2024-27980). Routing the whole command through a shell as one
|
|
58
|
+
// string is the platform-sanctioned way to invoke it without the argument
|
|
59
|
+
// array's deprecated, unescaped shell concatenation (DEP0190). Every
|
|
60
|
+
// argument passed to npm here is a fixed literal, never external input, so
|
|
61
|
+
// that lack of escaping is not a code-injection concern. git is a real
|
|
62
|
+
// executable and needs none of this.
|
|
63
|
+
if (process.platform === 'win32' && command === 'npm') {
|
|
64
|
+
const result = await execFile([command, ...args].join(' '), [], {
|
|
65
|
+
cwd,
|
|
66
|
+
encoding: 'utf8',
|
|
67
|
+
shell: true,
|
|
68
|
+
});
|
|
69
|
+
return result.stdout;
|
|
70
|
+
}
|
|
46
71
|
const result = await execFile(command, args, { cwd, encoding: 'utf8' });
|
|
47
72
|
return result.stdout;
|
|
48
73
|
}
|
|
@@ -295,7 +295,12 @@ async function deploySandboxTag(root, docker, tag, image) {
|
|
|
295
295
|
await port.update();
|
|
296
296
|
const wakeInvocation = sandboxWakeInvocation(root);
|
|
297
297
|
await verifyResidentStart(docker, root.config.host.sandbox.containerName, [...wakeInvocation, 'start', '--wake-root', '/wake'].join(' '));
|
|
298
|
-
await port.exec([
|
|
298
|
+
await port.exec([
|
|
299
|
+
...wakeInvocation,
|
|
300
|
+
'tick',
|
|
301
|
+
'--wake-root',
|
|
302
|
+
`/tmp/wake-self-update-healthcheck-${tag}`,
|
|
303
|
+
]);
|
|
299
304
|
}
|
|
300
305
|
async function rollbackSandboxTag(root, docker, image) {
|
|
301
306
|
const port = createSandboxDockerPort(docker, sandboxDockerOptions(root, { image }));
|