@orkestrel/scaffold 0.0.128 → 0.0.130
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/bin/main.js +1 -1
- package/dist/host/agents/orchestration.md +1 -0
- package/dist/host/agents/skills/orkestrel-parallel/references/t3.md +1 -0
- package/dist/host/claude/agents/orkestrel.md +3 -3
- package/dist/host/claude/rules/workspace.md +14 -14
- package/dist/host/guides/capture.md +5 -5
- package/dist/host/guides/middleware.md +82 -64
- package/dist/host/guides/scaffold.md +15 -0
- package/dist/host/manifest.json +9 -9
- package/dist/host/tests/config.test.ts +96 -0
- package/dist/src/core/index.cjs +125 -14
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +20 -0
- package/dist/src/core/index.d.ts +20 -0
- package/dist/src/core/index.js +124 -15
- package/dist/src/core/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -139,6 +139,7 @@ Exported from `@orkestrel/scaffold`, and reachable from
|
|
|
139
139
|
| `ARTIFACT_GROUPS` | const | `readonly ArtifactGroup[]` | Lists the `ArtifactGroup` values in plan order, frozen. |
|
|
140
140
|
| `ARTIFACT_TEMPLATES` | const | `ArtifactTemplateSet` | Holds formatter-stable template text for source, test, document, guide, and service artifacts. |
|
|
141
141
|
| `AXES` | const | `readonly Axis[]` | Lists the axes a browser extension may occupy, frozen. |
|
|
142
|
+
| `BARREL_CONFIGS` | const | `readonly string[]` | Lists the configuration file a workspace with studies and a server application adds, frozen. |
|
|
142
143
|
| `BASE_DEV_DEPENDENCIES` | const | `Readonly<Record<string, string>>` | Holds the baseline tooling versions, before framework holds apply. |
|
|
143
144
|
| `BIN_CONFIGS` | const | `readonly string[]` | Lists the configuration files a workspace that ships its own executable adds, frozen. |
|
|
144
145
|
| `BIN_ENTRY_PATH` | const | `"src/bin/main.ts"` | Names the executable entry whose presence makes a workspace `bin`. |
|
|
@@ -297,6 +298,7 @@ Exported from `@orkestrel/scaffold`, and reachable from
|
|
|
297
298
|
| `manifestToDependencies` | function | `(manifest: string) => ManifestDependencySet` | Projects a package manifest's text to the `@orkestrel/*` packages each dependency section declares. |
|
|
298
299
|
| `manifestToName` | function | `(manifest: string) => string \| undefined` | Projects a package manifest's text to its own name. |
|
|
299
300
|
| `matchesArtifactDriftReachability` | function | `(ownership: Ownership, finding: ArtifactFinding) => boolean` | Tests whether `inferArtifactDrift` could have produced a finding for an ownership. |
|
|
301
|
+
| `matchesBarrel` | function | `(blueprint: Blueprint) => boolean` | Tests whether a workspace plans the application server barrel build. |
|
|
300
302
|
| `matchesEngines` | function | `(engines: string) => boolean` | Tests whether a declared engines floor is at or above the supported minimum. |
|
|
301
303
|
| `matchesOrchestrationPath` | function | `(path: string) => boolean` | Tests whether a path instructs or wires an agent rather than the toolchain. |
|
|
302
304
|
| `matchesPrintWidth` | function | `(line: string) => boolean` | Tests whether one emitted line fits the vendored formatter width. |
|
|
@@ -1687,6 +1689,19 @@ and splits it under a control. Scaffold's `tests/src/core/templates.test.ts` run
|
|
|
1687
1689
|
server root, builds explicit output lists through the factory parameter, and runs the vendored case
|
|
1688
1690
|
in staged server targets under a mutation of the factory and of the control.
|
|
1689
1691
|
|
|
1692
|
+
A workspace that selects `studies` and the `server` application also builds the server's barrel,
|
|
1693
|
+
`app/server/index.ts`, because `@orkestrel/study` loads the package under study as ES modules. The
|
|
1694
|
+
`appBarrel` factory, the content-owned `configs/app/vite.barrel.config.ts` wrapper, and the
|
|
1695
|
+
`build:app:barrel` script exist only under that condition, and `build:app` runs the script after
|
|
1696
|
+
`build:app:server`. The build emits the single file `dist/app/server/index.js` with `@app/*` and
|
|
1697
|
+
`@src/*` specifiers and relative imports inlined, and `node:` and every installed package specifier
|
|
1698
|
+
left external. It sets `emptyOutDir` to `false`, so `main.cjs` stays byte-identical. A workspace
|
|
1699
|
+
without both conditions plans none of the three. Scaffold's `tests/src/core/templates.test.ts` builds both entries in a
|
|
1700
|
+
staged root, compares the `main.cjs` digest across the barrel step, builds the barrel twice for one
|
|
1701
|
+
`index.js` digest, imports the file in Node, and holds each claim under a control. The vendored
|
|
1702
|
+
`tests/config.test.ts` repeats the externals, digest, and `main.cjs` readings in each target that
|
|
1703
|
+
plans the barrel.
|
|
1704
|
+
|
|
1690
1705
|
### The migration guard
|
|
1691
1706
|
|
|
1692
1707
|
Vue code belongs to the `vue` extension's faces. `repair` and `overwrite` refuse a target whose
|
package/dist/host/manifest.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"storage": "agents/orchestration.md",
|
|
17
17
|
"destination": ".agents/orchestration.md",
|
|
18
18
|
"executable": false,
|
|
19
|
-
"digest": "
|
|
19
|
+
"digest": "67e49a59459fba935c1948d26c9b9fa48001e96d3b0fe0cee194ed724ea96c35"
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
"storage": "agents/platforms/posix.md",
|
|
@@ -430,7 +430,7 @@
|
|
|
430
430
|
"storage": "agents/skills/orkestrel-parallel/references/t3.md",
|
|
431
431
|
"destination": ".agents/skills/orkestrel-parallel/references/t3.md",
|
|
432
432
|
"executable": false,
|
|
433
|
-
"digest": "
|
|
433
|
+
"digest": "1669a45b33f53b6b560a65e64c0a13929e2703c4c907b87789518edf4c1b9a95"
|
|
434
434
|
},
|
|
435
435
|
{
|
|
436
436
|
"storage": "agents/skills/orkestrel-parallel/scripts/cases.ts",
|
|
@@ -628,7 +628,7 @@
|
|
|
628
628
|
"storage": "claude/agents/orkestrel.md",
|
|
629
629
|
"destination": ".claude/agents/orkestrel.md",
|
|
630
630
|
"executable": false,
|
|
631
|
-
"digest": "
|
|
631
|
+
"digest": "e6f261104a09bb01690031878c76254a83428ce2686b502b4a3d4cedaf4ec938"
|
|
632
632
|
},
|
|
633
633
|
{
|
|
634
634
|
"storage": "claude/agents/planner.md",
|
|
@@ -736,7 +736,7 @@
|
|
|
736
736
|
"storage": "claude/rules/workspace.md",
|
|
737
737
|
"destination": ".claude/rules/workspace.md",
|
|
738
738
|
"executable": false,
|
|
739
|
-
"digest": "
|
|
739
|
+
"digest": "0a5a7b0278de5ab0c7ef8633e74729af393fff366003f031d97ae8d63fbd0d38"
|
|
740
740
|
},
|
|
741
741
|
{
|
|
742
742
|
"storage": "claude/rules/writing.md",
|
|
@@ -1018,7 +1018,7 @@
|
|
|
1018
1018
|
"storage": "guides/capture.md",
|
|
1019
1019
|
"destination": "guides/capture.md",
|
|
1020
1020
|
"executable": false,
|
|
1021
|
-
"digest": "
|
|
1021
|
+
"digest": "07c53b0e17c49a01d9d71546bebf0890f3d340f6cb3a86f8c99a7eafe8edb2bf"
|
|
1022
1022
|
},
|
|
1023
1023
|
{
|
|
1024
1024
|
"storage": "guides/codec.md",
|
|
@@ -1114,7 +1114,7 @@
|
|
|
1114
1114
|
"storage": "guides/middleware.md",
|
|
1115
1115
|
"destination": "guides/middleware.md",
|
|
1116
1116
|
"executable": false,
|
|
1117
|
-
"digest": "
|
|
1117
|
+
"digest": "dad75159938cd6179cc542a480b85e758043ba36d3f94a966f2bb42c3adb4049"
|
|
1118
1118
|
},
|
|
1119
1119
|
{
|
|
1120
1120
|
"storage": "guides/msg.md",
|
|
@@ -1198,7 +1198,7 @@
|
|
|
1198
1198
|
"storage": "guides/scaffold.md",
|
|
1199
1199
|
"destination": "guides/scaffold.md",
|
|
1200
1200
|
"executable": false,
|
|
1201
|
-
"digest": "
|
|
1201
|
+
"digest": "655087dbab9aa83f336b353ebbc1faf23eeea3454c184cc3292753ae0901555b"
|
|
1202
1202
|
},
|
|
1203
1203
|
{
|
|
1204
1204
|
"storage": "guides/sea.md",
|
|
@@ -1336,7 +1336,7 @@
|
|
|
1336
1336
|
"storage": "tests/config.test.ts",
|
|
1337
1337
|
"destination": "tests/config.test.ts",
|
|
1338
1338
|
"executable": false,
|
|
1339
|
-
"digest": "
|
|
1339
|
+
"digest": "5f0feb333edeb7269b433fc1ea573a153aa35b47107f9ca0ffef48204d8f8986"
|
|
1340
1340
|
},
|
|
1341
1341
|
{
|
|
1342
1342
|
"storage": "tests/policy.test.ts",
|
|
@@ -1417,5 +1417,5 @@
|
|
|
1417
1417
|
"scripts"
|
|
1418
1418
|
],
|
|
1419
1419
|
"surface": [],
|
|
1420
|
-
"digest": "
|
|
1420
|
+
"digest": "330a0fb610a98e81c08d3eec813975d3fd59ee6a22db45d3381df695245e0079"
|
|
1421
1421
|
}
|
|
@@ -5,6 +5,7 @@ import type { InlineConfig, UserConfig } from 'vite'
|
|
|
5
5
|
import type { PolicyComment, PolicyDiagnostic, PolicyExpression } from '../configs/policy.js'
|
|
6
6
|
import type { PolicyProject } from './setupPolicy.js'
|
|
7
7
|
import { spawnSync } from 'node:child_process'
|
|
8
|
+
import { createHash } from 'node:crypto'
|
|
8
9
|
import {
|
|
9
10
|
closeSync,
|
|
10
11
|
existsSync,
|
|
@@ -1451,6 +1452,101 @@ describe('root configuration', () => {
|
|
|
1451
1452
|
}
|
|
1452
1453
|
})
|
|
1453
1454
|
|
|
1455
|
+
// A workspace with studies and an `app/server` also builds the server's barrel to the
|
|
1456
|
+
// single ES file `index.js` beside `main.cjs`, which a study loads as ESM. The real
|
|
1457
|
+
// wrapper's configuration builds a scratch entry into a scratch output directory that
|
|
1458
|
+
// already holds a `main.cjs`, four times: as declared twice, with an `external` that
|
|
1459
|
+
// inlines bare packages, and with `emptyOutDir` on. The first build keeps `main.cjs` and
|
|
1460
|
+
// leaves the bare import in place, the second repeats its digest, and the two controls
|
|
1461
|
+
// show the declared options carry the result: the inlined build drops the bare import
|
|
1462
|
+
// and the emptying build deletes `main.cjs`. A workspace without the conditions has no
|
|
1463
|
+
// wrapper, and the assertion classifies the absence.
|
|
1464
|
+
it('builds the application server barrel to bare externals beside main.cjs', async () => {
|
|
1465
|
+
const wrapper = resolve(POLICY_ROOT, 'configs/app/vite.barrel.config.ts')
|
|
1466
|
+
const planned =
|
|
1467
|
+
collectStudies(POLICY_ROOT).length > 0 && existsSync(resolve(POLICY_ROOT, 'app/server'))
|
|
1468
|
+
expect(existsSync(wrapper)).toBe(planned)
|
|
1469
|
+
if (!planned) return
|
|
1470
|
+
const scratch = createPolicyScratch({
|
|
1471
|
+
parent: resolve(POLICY_ROOT, 'app/server'),
|
|
1472
|
+
prefix: 'config-barrel-entry-',
|
|
1473
|
+
})
|
|
1474
|
+
const out = createPolicyScratch({ prefix: 'config-barrel-out-' })
|
|
1475
|
+
try {
|
|
1476
|
+
scratch.write(
|
|
1477
|
+
'index.ts',
|
|
1478
|
+
"import { join } from 'node:path'\nimport { peer } from 'barrel-peer'\nexport const served: string = join(peer, 'x')\n",
|
|
1479
|
+
)
|
|
1480
|
+
scratch.write(
|
|
1481
|
+
'node_modules/barrel-peer/package.json',
|
|
1482
|
+
'{ "name": "barrel-peer", "version": "1.0.0", "type": "module", "main": "index.js" }\n',
|
|
1483
|
+
)
|
|
1484
|
+
scratch.write('node_modules/barrel-peer/index.js', "export const peer = 'peer'\n")
|
|
1485
|
+
const readings: Array<{
|
|
1486
|
+
readonly variant: string
|
|
1487
|
+
readonly kept: boolean
|
|
1488
|
+
readonly bare: boolean
|
|
1489
|
+
readonly digest: string
|
|
1490
|
+
}> = []
|
|
1491
|
+
for (const variant of ['declared', 'repeated', 'inlined', 'emptying']) {
|
|
1492
|
+
out.write('main.cjs', 'main\n')
|
|
1493
|
+
const loaded = await loadConfigFromFile(
|
|
1494
|
+
{ command: 'build', mode: 'production', isSsrBuild: false, isPreview: false },
|
|
1495
|
+
wrapper,
|
|
1496
|
+
POLICY_ROOT,
|
|
1497
|
+
'silent',
|
|
1498
|
+
)
|
|
1499
|
+
if (loaded === null) throw new Error('The barrel wrapper did not load')
|
|
1500
|
+
const rolldown = loaded.config.build?.rolldownOptions
|
|
1501
|
+
expect(loaded.config.build?.emptyOutDir).toBe(false)
|
|
1502
|
+
await build({
|
|
1503
|
+
...loaded.config,
|
|
1504
|
+
root: POLICY_ROOT,
|
|
1505
|
+
configFile: false,
|
|
1506
|
+
logLevel: 'silent',
|
|
1507
|
+
// The output boundary pins the real output directory, which the scratch directory replaces.
|
|
1508
|
+
plugins: (loaded.config.plugins ?? []).filter(
|
|
1509
|
+
(plugin) =>
|
|
1510
|
+
typeof plugin !== 'object' ||
|
|
1511
|
+
plugin === null ||
|
|
1512
|
+
Object.getOwnPropertyDescriptor(plugin, 'name')?.value !==
|
|
1513
|
+
'orkestrel-output-boundary',
|
|
1514
|
+
),
|
|
1515
|
+
build: {
|
|
1516
|
+
...loaded.config.build,
|
|
1517
|
+
outDir: out.path,
|
|
1518
|
+
...(variant === 'emptying' ? { emptyOutDir: true } : {}),
|
|
1519
|
+
lib: {
|
|
1520
|
+
entry: resolve(scratch.path, 'index.ts'),
|
|
1521
|
+
formats: ['es'],
|
|
1522
|
+
fileName: () => 'index.js',
|
|
1523
|
+
},
|
|
1524
|
+
rolldownOptions: {
|
|
1525
|
+
...rolldown,
|
|
1526
|
+
...(variant === 'inlined' ? { external: /^node:/u } : {}),
|
|
1527
|
+
},
|
|
1528
|
+
},
|
|
1529
|
+
})
|
|
1530
|
+
const text = readFileSync(resolve(out.path, 'index.js'), 'utf8')
|
|
1531
|
+
readings.push({
|
|
1532
|
+
variant,
|
|
1533
|
+
kept: existsSync(resolve(out.path, 'main.cjs')),
|
|
1534
|
+
bare: /from ["']barrel-peer["']/u.test(text),
|
|
1535
|
+
digest: createHash('sha256').update(text).digest('hex'),
|
|
1536
|
+
})
|
|
1537
|
+
}
|
|
1538
|
+
const [declared, repeated, inlined, emptying] = readings
|
|
1539
|
+
expect(declared).toMatchObject({ kept: true, bare: true })
|
|
1540
|
+
expect(repeated?.digest).toBe(declared?.digest)
|
|
1541
|
+
expect(inlined).toMatchObject({ kept: true, bare: false })
|
|
1542
|
+
expect(inlined?.digest).not.toBe(declared?.digest)
|
|
1543
|
+
expect(emptying).toMatchObject({ kept: false, bare: true })
|
|
1544
|
+
} finally {
|
|
1545
|
+
out.destroy()
|
|
1546
|
+
scratch.destroy()
|
|
1547
|
+
}
|
|
1548
|
+
})
|
|
1549
|
+
|
|
1454
1550
|
it('registers proof scripts in the correct gate', () => {
|
|
1455
1551
|
const manifest: unknown = JSON.parse(readFileSync(resolve(POLICY_ROOT, 'package.json'), 'utf8'))
|
|
1456
1552
|
if (typeof manifest !== 'object' || manifest === null) {
|
package/dist/src/core/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ let _orkestrel_template = require("@orkestrel/template");
|
|
|
4
4
|
let _orkestrel_emitter = require("@orkestrel/emitter");
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "@orkestrel/scaffold",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.130",
|
|
8
8
|
description: "Scaffold workspaces with commands: new, audit, surface, repair, catalog, and overwrite.",
|
|
9
9
|
keywords: [
|
|
10
10
|
"audit",
|
|
@@ -248,6 +248,8 @@ var APP_MATRIX = Object.freeze({
|
|
|
248
248
|
});
|
|
249
249
|
/** Lists the configuration files a workspace that ships its own executable adds, frozen. */
|
|
250
250
|
var BIN_CONFIGS = Object.freeze(["configs/src/vite.bin.config.ts", "configs/src/tsconfig.bin.json"]);
|
|
251
|
+
/** Lists the configuration file a workspace with studies and a server application adds, frozen. */
|
|
252
|
+
var BARREL_CONFIGS = Object.freeze(["configs/app/vite.barrel.config.ts"]);
|
|
251
253
|
/** Names the executable entry whose presence makes a workspace `bin`. */
|
|
252
254
|
var BIN_ENTRY_PATH = "src/bin/main.ts";
|
|
253
255
|
/** Names the built executable a bin workspace's manifest command runs. */
|
|
@@ -1495,6 +1497,37 @@ export function appServer(override?: UserConfig): UserConfig {
|
|
|
1495
1497
|
},
|
|
1496
1498
|
}
|
|
1497
1499
|
}
|
|
1500
|
+
`,
|
|
1501
|
+
barrel: `function resolveBarrelExternal(id: string): boolean {
|
|
1502
|
+
if (id.startsWith('node:')) return true
|
|
1503
|
+
if (id.startsWith('@app/') || id.startsWith('@src/') || id.startsWith('.') || id.startsWith('/'))
|
|
1504
|
+
return false
|
|
1505
|
+
return /^(?:@[\\w.~-]+\\/)?[\\w.~-]+(?:\\/|$)/u.test(id)
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
export function appBarrel(override?: UserConfig): UserConfig {
|
|
1509
|
+
const project: UserConfig = {
|
|
1510
|
+
resolve,
|
|
1511
|
+
publicDir: false,
|
|
1512
|
+
plugins: [outputBoundary('dist/app/server'), environmentBoundary('app/server')],
|
|
1513
|
+
build: {
|
|
1514
|
+
emptyOutDir: false,
|
|
1515
|
+
lib: {
|
|
1516
|
+
entry: resolveWorkspacePath('app/server/index.ts'),
|
|
1517
|
+
formats: ['es'],
|
|
1518
|
+
fileName: () => 'index.js',
|
|
1519
|
+
},
|
|
1520
|
+
outDir: resolveWorkspacePath('dist/app/server'),
|
|
1521
|
+
target: 'node22',
|
|
1522
|
+
rolldownOptions: {
|
|
1523
|
+
onLog: enforceBuildLog,
|
|
1524
|
+
external: resolveBarrelExternal,
|
|
1525
|
+
output: { codeSplitting: false },
|
|
1526
|
+
},
|
|
1527
|
+
},
|
|
1528
|
+
}
|
|
1529
|
+
return mergeOverride(project, override)
|
|
1530
|
+
}
|
|
1498
1531
|
`
|
|
1499
1532
|
}),
|
|
1500
1533
|
policy: `export function policy(override?: UserConfig): UserConfig {
|
|
@@ -2085,6 +2118,11 @@ export default defineConfig(appBrowser())
|
|
|
2085
2118
|
import { appServer } from '../../vite.config.ts'
|
|
2086
2119
|
|
|
2087
2120
|
export default defineConfig(appServer())
|
|
2121
|
+
`,
|
|
2122
|
+
barrel: `import { defineConfig } from 'vite'
|
|
2123
|
+
import { appBarrel } from '../../vite.config.ts'
|
|
2124
|
+
|
|
2125
|
+
export default defineConfig(appBarrel())
|
|
2088
2126
|
`,
|
|
2089
2127
|
showcase: `import { defineConfig } from 'vite'
|
|
2090
2128
|
import { appShowcase } from '../../vite.config.ts'
|
|
@@ -2717,10 +2755,15 @@ export interface DistributionClassification {
|
|
|
2717
2755
|
readonly targets: readonly string[]
|
|
2718
2756
|
}
|
|
2719
2757
|
|
|
2758
|
+
/** Holds the file, leading arguments, and shell route an npm run spawns with. */
|
|
2759
|
+
export interface DistributionNpmCommand {
|
|
2760
|
+
readonly file: string
|
|
2761
|
+
readonly prefix: readonly string[]
|
|
2762
|
+
readonly shell: boolean
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2720
2765
|
/** Names the workspace whose packed artifact the proof consumes. */
|
|
2721
2766
|
export const DISTRIBUTION_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
2722
|
-
/** Names the npm executable on the running host. */
|
|
2723
|
-
export const DISTRIBUTION_NPM = process.platform === 'win32' ? 'npm.cmd' : 'npm'
|
|
2724
2767
|
// The compiler this workspace installs, run as a command rather than called in
|
|
2725
2768
|
// process: the command and its plain-text diagnostics are the same across the
|
|
2726
2769
|
// compiler majors this toolchain supports, and its in-process API is not. It is
|
|
@@ -2733,12 +2776,6 @@ export const DISTRIBUTION_TYPESCRIPT = createRequire(
|
|
|
2733
2776
|
).resolve('typescript/package.json')
|
|
2734
2777
|
/** Names the compiler installed by the workspace under proof. */
|
|
2735
2778
|
export const DISTRIBUTION_COMPILER = join(dirname(DISTRIBUTION_TYPESCRIPT), 'bin', 'tsc')
|
|
2736
|
-
// Windows needs a shell to launch a \`.cmd\`: Node refuses one directly since the
|
|
2737
|
-
// batch-argument hardening, and \`spawnSync\` returns \`EINVAL\` with a null status
|
|
2738
|
-
// rather than an exit code a caller can read. Every following argument is a literal or
|
|
2739
|
-
// a path this file built, so the shell has nothing to escape.
|
|
2740
|
-
/** Selects the Windows command-shell route required by the npm shim. */
|
|
2741
|
-
export const DISTRIBUTION_SHELL = process.platform === 'win32'
|
|
2742
2779
|
// \`prepublishOnly\` runs this proof as \`npm run test:distribution -- --mode release\`,
|
|
2743
2780
|
// and the root configuration's project factories carry that mode into this project.
|
|
2744
2781
|
// Release is the publish gate, so evidence it cannot obtain fails there and skips
|
|
@@ -3065,6 +3102,50 @@ export function readDistributionOutput(result: SpawnSyncReturns<string>): string
|
|
|
3065
3102
|
return \`\${result.stdout ?? ''}\${result.stderr ?? ''}\`.trim()
|
|
3066
3103
|
}
|
|
3067
3104
|
|
|
3105
|
+
/**
|
|
3106
|
+
* Resolves the npm command for the running host.
|
|
3107
|
+
*
|
|
3108
|
+
* @remarks
|
|
3109
|
+
* npm's JavaScript entry beside the running Node binary spawns without a shell on every host. The
|
|
3110
|
+
* shim is the fallback where none sits there, and Windows needs a shell to launch its \`.cmd\`: Node
|
|
3111
|
+
* refuses one directly since the batch-argument hardening, and \`spawnSync\` returns \`EINVAL\` with a
|
|
3112
|
+
* null status rather than an exit code a caller can read. Every argument this file passes is a
|
|
3113
|
+
* literal or a path it built, so the shell has nothing to escape.
|
|
3114
|
+
*
|
|
3115
|
+
* @returns The file to spawn, the arguments that precede npm's own, and whether it needs a shell.
|
|
3116
|
+
*/
|
|
3117
|
+
export function resolveDistributionNpm(): DistributionNpmCommand {
|
|
3118
|
+
const cli = join(dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js')
|
|
3119
|
+
if (existsSync(cli)) return { file: process.execPath, prefix: [cli], shell: false }
|
|
3120
|
+
const windows = process.platform === 'win32'
|
|
3121
|
+
return { file: windows ? 'npm.cmd' : 'npm', prefix: [], shell: windows }
|
|
3122
|
+
}
|
|
3123
|
+
|
|
3124
|
+
/**
|
|
3125
|
+
* Merges added variables over an inherited environment by case-folded name.
|
|
3126
|
+
*
|
|
3127
|
+
* @remarks
|
|
3128
|
+
* A Windows environment block folds names by case, and npm reads its \`npm_config_\` variables
|
|
3129
|
+
* case-insensitively on every host, so every inherited name an added name claims is dropped first:
|
|
3130
|
+
* an inherited \`NPM_CONFIG_CACHE\` would otherwise outrank an added \`npm_config_cache\`.
|
|
3131
|
+
*
|
|
3132
|
+
* @param inherited - The environment the child would inherit.
|
|
3133
|
+
* @param added - The variables the call sets.
|
|
3134
|
+
* @returns The merged environment.
|
|
3135
|
+
*/
|
|
3136
|
+
export function mergeDistributionEnvironment(
|
|
3137
|
+
inherited: Readonly<Record<string, string | undefined>>,
|
|
3138
|
+
added: Readonly<Record<string, string>>,
|
|
3139
|
+
): Readonly<Record<string, string | undefined>> {
|
|
3140
|
+
const claimed = new Set(Object.keys(added).map((name) => name.toLowerCase()))
|
|
3141
|
+
return {
|
|
3142
|
+
...Object.fromEntries(
|
|
3143
|
+
Object.entries(inherited).filter(([name]) => !claimed.has(name.toLowerCase())),
|
|
3144
|
+
),
|
|
3145
|
+
...added,
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3068
3149
|
/**
|
|
3069
3150
|
* Runs npm with a cache inside the owned scratch directory.
|
|
3070
3151
|
*
|
|
@@ -3078,11 +3159,12 @@ export function runDistributionNpm(
|
|
|
3078
3159
|
cwd: string,
|
|
3079
3160
|
scratch: string,
|
|
3080
3161
|
): SpawnSyncReturns<string> {
|
|
3081
|
-
|
|
3162
|
+
const npm = resolveDistributionNpm()
|
|
3163
|
+
return spawnSync(npm.file, [...npm.prefix, ...args], {
|
|
3082
3164
|
cwd,
|
|
3083
3165
|
encoding: 'utf8',
|
|
3084
|
-
env:
|
|
3085
|
-
shell:
|
|
3166
|
+
env: mergeDistributionEnvironment(process.env, { npm_config_cache: join(scratch, 'cache') }),
|
|
3167
|
+
shell: npm.shell,
|
|
3086
3168
|
windowsHide: true,
|
|
3087
3169
|
})
|
|
3088
3170
|
}
|
|
@@ -6163,6 +6245,22 @@ function matchesPrintWidth(line) {
|
|
|
6163
6245
|
return line.replaceAll(" ", " ".repeat(2)).length <= 100;
|
|
6164
6246
|
}
|
|
6165
6247
|
/**
|
|
6248
|
+
* Tests whether a workspace plans the application server barrel build.
|
|
6249
|
+
*
|
|
6250
|
+
* @param blueprint - The workspace specification.
|
|
6251
|
+
* @returns True if the workspace selects `studies` and the `server` application; false otherwise.
|
|
6252
|
+
*
|
|
6253
|
+
* @example
|
|
6254
|
+
* ```ts
|
|
6255
|
+
* import { createBlueprint, matchesBarrel } from '@orkestrel/scaffold'
|
|
6256
|
+
*
|
|
6257
|
+
* matchesBarrel(createBlueprint('crm', { app: ['core', 'server'], studies: true })) // true
|
|
6258
|
+
* ```
|
|
6259
|
+
*/
|
|
6260
|
+
function matchesBarrel(blueprint) {
|
|
6261
|
+
return blueprint.studies && blueprint.app.includes("server");
|
|
6262
|
+
}
|
|
6263
|
+
/**
|
|
6166
6264
|
* Selects the single published environment a package root points at.
|
|
6167
6265
|
*
|
|
6168
6266
|
* @param src - The declared published environments.
|
|
@@ -7244,6 +7342,7 @@ function blueprintToScripts(blueprint) {
|
|
|
7244
7342
|
const compiles = publishes || blueprint.bin;
|
|
7245
7343
|
const runtime = blueprint.app.filter((environment) => environment !== "core" && (environment !== "browser" || base));
|
|
7246
7344
|
const vitest = "vitest run --config vite.config.ts --no-cache --reporter=dot";
|
|
7345
|
+
const built = [...runtime, ...application].flatMap((environment) => environment === "server" && matchesBarrel(blueprint) ? [environment, "barrel"] : [environment]);
|
|
7247
7346
|
const checks = [
|
|
7248
7347
|
...blueprint.src,
|
|
7249
7348
|
...source,
|
|
@@ -7356,8 +7455,8 @@ function blueprintToScripts(blueprint) {
|
|
|
7356
7455
|
...Object.fromEntries(targets.map((name) => [`build:src:${name}`, [`vite build --config configs/src/vite.${name}.config.ts`, ...name === "styles" && blueprint.themes ? ["vite build --config configs/src/vite.themes.config.ts"] : []].join(" && ")]))
|
|
7357
7456
|
} : {},
|
|
7358
7457
|
...blueprint.app.length > 0 ? {
|
|
7359
|
-
"build:app": runtime.length + application.length > 0 ?
|
|
7360
|
-
...Object.fromEntries(
|
|
7458
|
+
"build:app": runtime.length + application.length > 0 ? built.map((environment) => `npm run build:app:${environment}`).join(" && ") : `npm run check:app:${blueprint.app.includes("core") ? "core" : "browser"}`,
|
|
7459
|
+
...Object.fromEntries(built.map((environment) => [`build:app:${environment}`, `vite build --config configs/app/vite.${environment}.config.ts`]))
|
|
7361
7460
|
} : {},
|
|
7362
7461
|
...base ? {
|
|
7363
7462
|
dev: "vite --config configs/app/vite.browser.config.ts",
|
|
@@ -7813,6 +7912,7 @@ function blueprintToRootVite(blueprint) {
|
|
|
7813
7912
|
})] : [],
|
|
7814
7913
|
...planned.has("app:vue") ? [(0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.factories.app.vue, { journeyExclude: journeyed ? " exclude: ['tests/app/vue/integration.test.ts'],\n" : " exclude: [],\n" })] : [],
|
|
7815
7914
|
...planned.has("app:server") ? [CONFIG_TEMPLATES.factories.app.server] : [],
|
|
7915
|
+
...matchesBarrel(blueprint) ? [CONFIG_TEMPLATES.factories.app.barrel] : [],
|
|
7816
7916
|
CONFIG_TEMPLATES.factories.policy,
|
|
7817
7917
|
CONFIG_TEMPLATES.factories.config,
|
|
7818
7918
|
...planned.has("setup") ? [CONFIG_TEMPLATES.factories.setup] : [],
|
|
@@ -7962,6 +8062,14 @@ ${paths.join("\n")}
|
|
|
7962
8062
|
origin: "template",
|
|
7963
8063
|
content: path === "configs/src/tsconfig.bin.json" ? CONFIG_TEMPLATES.tsconfigs.bin : (0, _orkestrel_template.fillTemplate)(CONFIG_TEMPLATES.vites.bin, { paths: renderedPaths })
|
|
7964
8064
|
})) : [];
|
|
8065
|
+
const barrels = matchesBarrel(blueprint) ? BARREL_CONFIGS.map((path) => ({
|
|
8066
|
+
path,
|
|
8067
|
+
group: "configs",
|
|
8068
|
+
ownership: "content",
|
|
8069
|
+
origin: "template",
|
|
8070
|
+
environment: "server",
|
|
8071
|
+
content: CONFIG_TEMPLATES.vites.app.barrel
|
|
8072
|
+
})) : [];
|
|
7965
8073
|
const includeSuffixes = [
|
|
7966
8074
|
"cts",
|
|
7967
8075
|
"mts",
|
|
@@ -8067,6 +8175,7 @@ ${paths.join("\n")}
|
|
|
8067
8175
|
...sources,
|
|
8068
8176
|
...bins,
|
|
8069
8177
|
...applications,
|
|
8178
|
+
...barrels,
|
|
8070
8179
|
...faces,
|
|
8071
8180
|
...showcase,
|
|
8072
8181
|
...journey,
|
|
@@ -9903,6 +10012,7 @@ exports.APP_SERVER_DEV_DEPENDENCIES = APP_SERVER_DEV_DEPENDENCIES;
|
|
|
9903
10012
|
exports.ARTIFACT_GROUPS = ARTIFACT_GROUPS;
|
|
9904
10013
|
exports.ARTIFACT_TEMPLATES = ARTIFACT_TEMPLATES;
|
|
9905
10014
|
exports.AXES = AXES;
|
|
10015
|
+
exports.BARREL_CONFIGS = BARREL_CONFIGS;
|
|
9906
10016
|
exports.BASE_DEV_DEPENDENCIES = BASE_DEV_DEPENDENCIES;
|
|
9907
10017
|
exports.BIN_CONFIGS = BIN_CONFIGS;
|
|
9908
10018
|
exports.BIN_ENTRY_PATH = BIN_ENTRY_PATH;
|
|
@@ -10076,6 +10186,7 @@ exports.iterateAnswers = iterateAnswers;
|
|
|
10076
10186
|
exports.manifestToDependencies = manifestToDependencies;
|
|
10077
10187
|
exports.manifestToName = manifestToName;
|
|
10078
10188
|
exports.matchesArtifactDriftReachability = matchesArtifactDriftReachability;
|
|
10189
|
+
exports.matchesBarrel = matchesBarrel;
|
|
10079
10190
|
exports.matchesEngines = matchesEngines;
|
|
10080
10191
|
exports.matchesGuideRefusal = matchesGuideRefusal;
|
|
10081
10192
|
exports.matchesOrchestrationPath = matchesOrchestrationPath;
|