@vzn/vx 0.0.584 → 0.0.585

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vzn/vx",
3
- "version": "0.0.584",
3
+ "version": "0.0.585",
4
4
  "description": "The fastest task runner and build cache for JavaScript monorepos.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -21,10 +21,10 @@
21
21
  "node": ">=18"
22
22
  },
23
23
  "optionalDependencies": {
24
- "@vzn/vx-linux-x64": "0.0.584",
25
- "@vzn/vx-linux-arm64": "0.0.584",
26
- "@vzn/vx-darwin-x64": "0.0.584",
27
- "@vzn/vx-darwin-arm64": "0.0.584"
24
+ "@vzn/vx-linux-x64": "0.0.585",
25
+ "@vzn/vx-linux-arm64": "0.0.585",
26
+ "@vzn/vx-darwin-x64": "0.0.585",
27
+ "@vzn/vx-darwin-arm64": "0.0.585"
28
28
  },
29
29
  "dependencies": {
30
30
  "@anthropic-ai/sandbox-runtime": "^0.0.76"
@@ -240,12 +240,18 @@ export async function sandboxRequestFor(
240
240
  ? [cacheDir]
241
241
  : []),
242
242
  ].map(toRealPath)
243
- const config = wallOff(
244
- resolveSandboxConfig(sandbox, node.projectDir, walls),
245
- workspaceRoot,
246
- walls,
247
- )
243
+ const resolved = resolveSandboxConfig(sandbox, node.projectDir, walls)
244
+ // Made before the walls judge the binds: a directory grant naming nothing
245
+ // yet (`dist/`, `dist/**`) was judged as a file, its bind its parent, and
246
+ // a root project's was refused for `.git`.
248
247
  const placeholders = await prepareOutputsForBind(node.projectDir, sandbox.allow?.write ?? [])
248
+ let config: ResolvedSandboxConfig
249
+ try {
250
+ config = wallOff(resolved, workspaceRoot, walls)
251
+ } catch (err) {
252
+ await sweepPlaceholders(placeholders)
253
+ throw err
254
+ }
249
255
  const request: NonNullable<ExecuteRequest['sandbox']> = {
250
256
  // Only what the task declared, plus node_modules. Write paths are
251
257
  // readable too: a task that writes `dist/x` expects to read it back
@@ -50,9 +50,13 @@ export const PERSISTENT_TASK_NAMES: ReadonlySet<string> = new Set([
50
50
  * forwarded `--` args are appended to, and only the body takes them, as
51
51
  * npm appends them to the script and never to its hooks. A plain ` && `
52
52
  * join handed them to the post hook, and `test -f x && echo A; echo B` ran
53
- * `echo B` after a failed pre hook and went green (item 905). Each part
54
- * ends on its own line, so a trailing `# comment` cannot swallow the
55
- * paren. A script with no hooks is its body, verbatim.
53
+ * `echo B` after a failed pre hook and went green (item 905). npm appends
54
+ * them as TEXT: no part sees them as `$1`…, so the function quotes them
55
+ * into `vx_a`, clears its positional parameters, and evals the body with
56
+ * `vx_a` after it; `"$@"` on the body made a script's `$1` the first
57
+ * forwarded arg and its `$*` print them twice. Each part ends on its own
58
+ * line, so a trailing `# comment` cannot swallow the paren. A script with
59
+ * no hooks is its body, verbatim.
56
60
  */
57
61
  export function foldScriptHooks(
58
62
  pre: string | undefined,
@@ -60,14 +64,22 @@ export function foldScriptHooks(
60
64
  post: string | undefined,
61
65
  ): string {
62
66
  if (pre === undefined && post === undefined) return body
67
+ const quoted = `'${body.replaceAll("'", `'\\''`)}'`
63
68
  const parts = [
64
69
  ...(pre === undefined ? [] : [`(${pre}\n)`]),
65
- `(${body} "$@"\n)`,
70
+ `(eval ${quoted}"$vx_a"\n)`,
66
71
  ...(post === undefined ? [] : [`(${post}\n)`]),
67
72
  ]
68
- return `vx_script() {\n${parts.join(' && ')}\n}\nvx_script`
73
+ return `vx_script() {\n${QUOTE_ARGS}\nset --\n${parts.join(' && ')}\n}\nvx_script`
69
74
  }
70
75
 
76
+ /** Each argument single-quoted into `vx_a`, in sh alone (no spawn per arg). */
77
+ const QUOTE_ARGS =
78
+ `vx_q="'" vx_a=\n` +
79
+ `for vx_s in "$@"; do vx_r=; while :; do case $vx_s in *"$vx_q"*) ` +
80
+ `vx_r="$vx_r\${vx_s%%"$vx_q"*}'\\''"; vx_s=\${vx_s#*"$vx_q"};; *) break;; esac; done; ` +
81
+ `vx_a="$vx_a '$vx_r$vx_s'"; done`
82
+
71
83
  /**
72
84
  * Where a framework's build writes by default, for the cache TODO: the
73
85
  * hint said `dist/**` to every build, `next build` included, which writes