@vzn/vx 0.0.286 → 0.0.287
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 +5 -5
- package/src/cli/init.ts +14 -1
- package/src/workspace/migrate-scripts.ts +23 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vzn/vx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.287",
|
|
4
4
|
"description": "A fast, correct task runner and build cache for JavaScript monorepos.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"node": ">=18"
|
|
18
18
|
},
|
|
19
19
|
"optionalDependencies": {
|
|
20
|
-
"@vzn/vx-linux-x64": "0.0.
|
|
21
|
-
"@vzn/vx-linux-arm64": "0.0.
|
|
22
|
-
"@vzn/vx-darwin-x64": "0.0.
|
|
23
|
-
"@vzn/vx-darwin-arm64": "0.0.
|
|
20
|
+
"@vzn/vx-linux-x64": "0.0.287",
|
|
21
|
+
"@vzn/vx-linux-arm64": "0.0.287",
|
|
22
|
+
"@vzn/vx-darwin-x64": "0.0.287",
|
|
23
|
+
"@vzn/vx-darwin-arm64": "0.0.287"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@anthropic-ai/sandbox-runtime": "^0.0.76"
|
package/src/cli/init.ts
CHANGED
|
@@ -99,7 +99,10 @@ export async function initCmd(args: readonly string[]): Promise<number> {
|
|
|
99
99
|
return applyMigration({
|
|
100
100
|
root,
|
|
101
101
|
metas,
|
|
102
|
-
plan: migrateScripts(
|
|
102
|
+
plan: migrateScripts(
|
|
103
|
+
metas,
|
|
104
|
+
metas.some((m) => m.dir === root) ? undefined : await readRootManifest(root),
|
|
105
|
+
),
|
|
103
106
|
source: 'package.json scripts',
|
|
104
107
|
verb: 'vx init',
|
|
105
108
|
dry: parsed.dry,
|
|
@@ -343,3 +346,13 @@ function firstTask(file: string, runner: 'turbo' | 'nx'): string {
|
|
|
343
346
|
const first = new RegExp(`"${field}"\\s*:\\s*\\{\\s*"([^"]+)"`).exec(text)?.[1]
|
|
344
347
|
return first ?? 'build'
|
|
345
348
|
}
|
|
349
|
+
|
|
350
|
+
/** The root package.json as an object, `{}` when unreadable or not one. */
|
|
351
|
+
async function readRootManifest(root: string): Promise<Record<string, unknown>> {
|
|
352
|
+
const pj: unknown = await Bun.file(path.join(root, 'package.json'))
|
|
353
|
+
.json()
|
|
354
|
+
.catch(() => ({}))
|
|
355
|
+
return typeof pj === 'object' && pj !== null && !Array.isArray(pj)
|
|
356
|
+
? (pj as Record<string, unknown>)
|
|
357
|
+
: {}
|
|
358
|
+
}
|
|
@@ -242,7 +242,15 @@ function upstreamBuildOnWorker(tasks: GeneratedTask[]): void {
|
|
|
242
242
|
if (!at.todos.includes(todo)) at.todos.push(todo)
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
/**
|
|
246
|
+
* `outside`: the root manifest when the root is no member (pnpm's and
|
|
247
|
+
* Yarn's default), whose own scripts (`lint: eslint .`) went unmapped
|
|
248
|
+
* without a word.
|
|
249
|
+
*/
|
|
250
|
+
export function migrateScripts(
|
|
251
|
+
metas: readonly ProjectMeta[],
|
|
252
|
+
outside?: Readonly<Record<string, unknown>>,
|
|
253
|
+
): MigrationPlan {
|
|
246
254
|
const projects: GeneratedProject[] = []
|
|
247
255
|
const hookMemo = new Map<string, string | null>()
|
|
248
256
|
// The workspace root among members: its scripts run the workspace
|
|
@@ -252,9 +260,21 @@ export function migrateScripts(metas: readonly ProjectMeta[]): MigrationPlan {
|
|
|
252
260
|
// replaced it so (D-45). A lone package is its repo's project and maps.
|
|
253
261
|
const root = metas.length > 1 ? workspaceRootOf(metas) : undefined
|
|
254
262
|
const notes: string[] = []
|
|
255
|
-
|
|
263
|
+
const outsideScripts = outside?.['scripts']
|
|
264
|
+
const outsideRuns =
|
|
265
|
+
typeof outsideScripts === 'object' &&
|
|
266
|
+
outsideScripts !== null &&
|
|
267
|
+
Object.values(outsideScripts).some((v) => typeof v === 'string' && v !== '')
|
|
268
|
+
const rootName =
|
|
269
|
+
root?.name ??
|
|
270
|
+
(outsideRuns
|
|
271
|
+
? typeof outside?.['name'] === 'string'
|
|
272
|
+
? outside['name']
|
|
273
|
+
: 'package.json'
|
|
274
|
+
: undefined)
|
|
275
|
+
if (rootName !== undefined) {
|
|
256
276
|
notes.push(
|
|
257
|
-
`${
|
|
277
|
+
`${rootName} (the workspace root) not mapped: its scripts run the workspace; declare its own tasks in its vx.config by hand`,
|
|
258
278
|
)
|
|
259
279
|
}
|
|
260
280
|
for (const meta of metas) {
|