@orkestrel/scaffold 0.0.10 → 0.0.12
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/scaffold.js +63 -28
- package/dist/bin/scaffold.js.map +1 -1
- package/dist/host/guides/src/scaffold.md +64 -29
- package/dist/host/tests/setupPolicy.ts +87 -2
- package/dist/src/core/index.cjs +86 -61
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +56 -26
- package/dist/src/core/index.d.ts +56 -26
- package/dist/src/core/index.js +85 -62
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +21 -9
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +2 -1
- package/dist/src/server/index.d.ts +2 -1
- package/dist/src/server/index.js +23 -11
- package/dist/src/server/index.js.map +1 -1
- package/package.json +5 -5
package/dist/src/core/index.cjs
CHANGED
|
@@ -143,6 +143,8 @@ var HOST_PATHS = Object.freeze([
|
|
|
143
143
|
]);
|
|
144
144
|
/** The consumer-owned live-service provisioner expected only by service workspaces. */
|
|
145
145
|
var SERVICE_SCRIPT_PATH = "scripts/service.sh";
|
|
146
|
+
/** The consumer-owned Vitest global-setup module shared by its independently selected projects. */
|
|
147
|
+
var GLOBAL_SETUP_PATH = "tests/setupGlobal.ts";
|
|
146
148
|
/** The package-name RegExp — lowercase alphanumeric-with-hyphens, letter-first. */
|
|
147
149
|
var NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
148
150
|
/** Maximum bare workspace name length beneath the generated `@orkestrel/` scope. */
|
|
@@ -225,11 +227,11 @@ var DEFAULT_VERSION = "0.0.1";
|
|
|
225
227
|
/** The `engines.node` range the `blueprint` builder fills. */
|
|
226
228
|
var DEFAULT_ENGINES = `>=${MINIMUM_NODE_VERSION}`;
|
|
227
229
|
/** The devDependency range generated packages pin `@orkestrel/scaffold` at. */
|
|
228
|
-
var SCAFFOLD_RANGE = "^0.0.
|
|
230
|
+
var SCAFFOLD_RANGE = "^0.0.12";
|
|
229
231
|
/** Tooling versions shared by scaffold and every generated workspace. */
|
|
230
232
|
var BASE_DEV_DEPENDENCIES = Object.freeze({
|
|
231
233
|
"@microsoft/api-extractor": "^7.58.12",
|
|
232
|
-
"@orkestrel/guide": "^0.0.
|
|
234
|
+
"@orkestrel/guide": "^0.0.8",
|
|
233
235
|
"@orkestrel/scaffold": SCAFFOLD_RANGE,
|
|
234
236
|
"@types/node": "^26.1.2",
|
|
235
237
|
oxfmt: "^0.61.0",
|
|
@@ -242,7 +244,7 @@ var BASE_DEV_DEPENDENCIES = Object.freeze({
|
|
|
242
244
|
/** Additional development dependency required by a published browser source environment. */
|
|
243
245
|
var SOURCE_BROWSER_DEV_DEPENDENCIES = Object.freeze({
|
|
244
246
|
"@vitest/browser-playwright": "^4.1.10",
|
|
245
|
-
playwright: "^1.
|
|
247
|
+
playwright: "^1.62.0"
|
|
246
248
|
});
|
|
247
249
|
/** Additional development dependencies required by a private Vue browser application. */
|
|
248
250
|
var APP_BROWSER_DEV_DEPENDENCIES = Object.freeze({
|
|
@@ -425,8 +427,8 @@ function member(name, category, summary, environment = "core") {
|
|
|
425
427
|
* `version` / `engines` default `DEFAULT_VERSION` / `DEFAULT_ENGINES`,
|
|
426
428
|
* `src` defaults `['core']`, and `app` / `keywords` / `dependencies` /
|
|
427
429
|
* `peers` / `extras` / `overrides` default `[]`, and `bin` / `integration` /
|
|
428
|
-
* `service` default `false`. `description` is OMITTED entirely
|
|
429
|
-
* the result round-trips the exact-record `Blueprint` guard.
|
|
430
|
+
* `service` / `global` default `false`. `description` is OMITTED entirely
|
|
431
|
+
* when absent, so the result round-trips the exact-record `Blueprint` guard.
|
|
430
432
|
* @returns A complete `Blueprint`.
|
|
431
433
|
*
|
|
432
434
|
* @example
|
|
@@ -450,7 +452,8 @@ function blueprint(name, options) {
|
|
|
450
452
|
overrides: options?.overrides ?? [],
|
|
451
453
|
bin: options?.bin ?? false,
|
|
452
454
|
integration: options?.integration ?? false,
|
|
453
|
-
service: options?.service ?? false
|
|
455
|
+
service: options?.service ?? false,
|
|
456
|
+
global: options?.global ?? false
|
|
454
457
|
};
|
|
455
458
|
return options?.description === void 0 ? base : {
|
|
456
459
|
...base,
|
|
@@ -607,7 +610,7 @@ function catalogNames(text) {
|
|
|
607
610
|
*
|
|
608
611
|
* @param header - The header cell strings, in column order.
|
|
609
612
|
* @param rows - The body rows, each a list of cell strings matching `header`'s column count.
|
|
610
|
-
* @param align - Optional per-column alignment; defaults every column to `
|
|
613
|
+
* @param align - Optional per-column alignment; defaults every column to `null` (no alignment).
|
|
611
614
|
* @remarks
|
|
612
615
|
* Builds a `TableNode` (each cell parsed with `parseInline`) and serializes it
|
|
613
616
|
* through `renderMarkdown`, which contributes the structure — `\|`-escaping any
|
|
@@ -626,13 +629,14 @@ function catalogNames(text) {
|
|
|
626
629
|
*/
|
|
627
630
|
function alignTable(header, rows, align) {
|
|
628
631
|
const columns = header.length;
|
|
629
|
-
const alignment = align ?? header.map(() =>
|
|
630
|
-
const
|
|
632
|
+
const alignment = align ?? header.map(() => null);
|
|
633
|
+
const node = {
|
|
631
634
|
element: "table",
|
|
632
635
|
header: header.map((cell) => (0, _orkestrel_markdown.parseInline)(cell)),
|
|
633
636
|
rows: rows.map((row) => row.map((cell) => (0, _orkestrel_markdown.parseInline)(cell))),
|
|
634
637
|
align: alignment
|
|
635
|
-
}
|
|
638
|
+
};
|
|
639
|
+
const lines = (0, _orkestrel_markdown.renderMarkdown)(node).split("\n");
|
|
636
640
|
const headerCells = splitTableRow(lines[0] ?? "");
|
|
637
641
|
const bodyCells = lines.slice(2).map((line) => splitTableRow(line));
|
|
638
642
|
const widths = [];
|
|
@@ -695,11 +699,11 @@ function padCell(text, width) {
|
|
|
695
699
|
/**
|
|
696
700
|
* Build one delimiter-row cell for a GFM table column.
|
|
697
701
|
*
|
|
698
|
-
* @param columnAlign - The column's `TableAlign
|
|
702
|
+
* @param columnAlign - The column's `TableAlign`, or `null` for no alignment.
|
|
699
703
|
* @param width - The column's codepoint width.
|
|
700
704
|
* @remarks
|
|
701
705
|
* `'left'` prefixes `:`, `'right'` suffixes `:`, `'center'` wraps both ends,
|
|
702
|
-
* `
|
|
706
|
+
* `null` is plain dashes — one dash per width unit, `:` markers consuming
|
|
703
707
|
* a dash slot rather than adding to `width`.
|
|
704
708
|
* @returns The delimiter cell string for this column.
|
|
705
709
|
*
|
|
@@ -1599,6 +1603,22 @@ function computeColumnWidth(text) {
|
|
|
1599
1603
|
return width;
|
|
1600
1604
|
}
|
|
1601
1605
|
/**
|
|
1606
|
+
* Test whether a complete rendered line fits the fleet formatter's print width.
|
|
1607
|
+
*
|
|
1608
|
+
* @param text - The complete rendered line, including indentation and trailing punctuation.
|
|
1609
|
+
* @returns Whether the line fits within `JSON_PRINT_WIDTH`.
|
|
1610
|
+
*
|
|
1611
|
+
* @example
|
|
1612
|
+
* ```ts
|
|
1613
|
+
* import { fitsPrintWidth } from '@orkestrel/scaffold'
|
|
1614
|
+
*
|
|
1615
|
+
* fitsPrintWidth('\t["ESNext"],') // true
|
|
1616
|
+
* ```
|
|
1617
|
+
*/
|
|
1618
|
+
function fitsPrintWidth(text) {
|
|
1619
|
+
return computeColumnWidth(text) <= 100;
|
|
1620
|
+
}
|
|
1621
|
+
/**
|
|
1602
1622
|
* Render a JSON array through `formatJson`'s inline-or-broken rule — inline
|
|
1603
1623
|
* when the rendered width (via `computeColumnWidth`) fits `JSON_PRINT_WIDTH`, one
|
|
1604
1624
|
* item per line otherwise.
|
|
@@ -1620,7 +1640,7 @@ function renderArray(entries, indent, prefix, suffix) {
|
|
|
1620
1640
|
if (entries.length === 0) return "[]";
|
|
1621
1641
|
const items = entries.map((entry) => renderValue(entry, indent, "", ""));
|
|
1622
1642
|
const inline = `[${items.join(", ")}]`;
|
|
1623
|
-
if (
|
|
1643
|
+
if (fitsPrintWidth(`${prefix}${inline}${suffix}`)) return inline;
|
|
1624
1644
|
const childIndent = `${indent}\t`;
|
|
1625
1645
|
return `[\n${items.map((item) => `${childIndent}${item}`).join(",\n")}\n${indent}]`;
|
|
1626
1646
|
}
|
|
@@ -1803,7 +1823,8 @@ function blueprintShape() {
|
|
|
1803
1823
|
overrides: (0, _orkestrel_contract.arrayShape)(overrideShape(), { max: MAX_COLLECTION_ITEMS }),
|
|
1804
1824
|
bin: (0, _orkestrel_contract.booleanShape)(),
|
|
1805
1825
|
integration: (0, _orkestrel_contract.booleanShape)(),
|
|
1806
|
-
service: (0, _orkestrel_contract.booleanShape)()
|
|
1826
|
+
service: (0, _orkestrel_contract.booleanShape)(),
|
|
1827
|
+
global: (0, _orkestrel_contract.booleanShape)()
|
|
1807
1828
|
});
|
|
1808
1829
|
}
|
|
1809
1830
|
/**
|
|
@@ -5773,7 +5794,7 @@ function viteMachinery(src, app = [], bin = false) {
|
|
|
5773
5794
|
*
|
|
5774
5795
|
* @param src - The declared published environments.
|
|
5775
5796
|
* @param app - The declared application environments.
|
|
5776
|
-
* @param
|
|
5797
|
+
* @param facts - Optional structural facts.
|
|
5777
5798
|
* @returns Source projects, application projects, proof projects, then optional axis projects.
|
|
5778
5799
|
*
|
|
5779
5800
|
* @example
|
|
@@ -5782,7 +5803,7 @@ function viteMachinery(src, app = [], bin = false) {
|
|
|
5782
5803
|
* // [{ project: 'srcCore' }, { project: 'policy' }, { project: 'guides' }, { project: 'integration' }]
|
|
5783
5804
|
* ```
|
|
5784
5805
|
*/
|
|
5785
|
-
function viteProjectRegistrations(src, app = [],
|
|
5806
|
+
function viteProjectRegistrations(src, app = [], facts = {}) {
|
|
5786
5807
|
const registrations = [];
|
|
5787
5808
|
for (const environment of ENVIRONMENTS) {
|
|
5788
5809
|
if (!src.includes(environment)) continue;
|
|
@@ -5803,15 +5824,15 @@ function viteProjectRegistrations(src, app = [], axes = {}) {
|
|
|
5803
5824
|
if (environment === "server") registrations.push({ project: "appServer" });
|
|
5804
5825
|
}
|
|
5805
5826
|
registrations.push({ project: "policy" }, { project: "guides" });
|
|
5806
|
-
if (
|
|
5807
|
-
if (
|
|
5808
|
-
if (
|
|
5827
|
+
if (facts.bin === true) registrations.push({ project: "srcBin" });
|
|
5828
|
+
if (facts.integration === true) registrations.push({ project: "integration" });
|
|
5829
|
+
if (facts.service === true) registrations.push({ project: "service" });
|
|
5809
5830
|
return registrations;
|
|
5810
5831
|
}
|
|
5811
5832
|
/**
|
|
5812
5833
|
* Render the one ordered proof and structural-axis project definition block.
|
|
5813
5834
|
*
|
|
5814
|
-
* @param
|
|
5835
|
+
* @param facts - Optional structural facts.
|
|
5815
5836
|
* @returns Policy, guides, then selected axis project definitions, separated by one blank line.
|
|
5816
5837
|
*
|
|
5817
5838
|
* @example
|
|
@@ -5819,11 +5840,11 @@ function viteProjectRegistrations(src, app = [], axes = {}) {
|
|
|
5819
5840
|
* viteProjectDefinitions({ bin: true }).includes('export const srcBin =') // true
|
|
5820
5841
|
* ```
|
|
5821
5842
|
*/
|
|
5822
|
-
function viteProjectDefinitions(
|
|
5843
|
+
function viteProjectDefinitions(facts = {}) {
|
|
5823
5844
|
const definitions = [policyViteProject(), guidesViteProject()];
|
|
5824
|
-
if (
|
|
5825
|
-
if (
|
|
5826
|
-
if (
|
|
5845
|
+
if (facts.bin === true) definitions.push(binViteProject());
|
|
5846
|
+
if (facts.integration === true) definitions.push(integrationViteProject(facts));
|
|
5847
|
+
if (facts.service === true) definitions.push(serviceViteProject());
|
|
5827
5848
|
return definitions.join("\n");
|
|
5828
5849
|
}
|
|
5829
5850
|
/**
|
|
@@ -5843,16 +5864,18 @@ function viteProjectDefinitions(axes = {}) {
|
|
|
5843
5864
|
function renderViteTest(registrations, browser) {
|
|
5844
5865
|
const projects = registrations.map((registration) => registration.project);
|
|
5845
5866
|
const inlineProjects = ` projects: [${projects.join(", ")}],`;
|
|
5846
|
-
const renderedProjects =
|
|
5867
|
+
const renderedProjects = fitsPrintWidth(inlineProjects) ? inlineProjects : ` projects: [
|
|
5847
5868
|
${projects.map((project) => ` ${project},`).join("\n")}
|
|
5848
5869
|
],`;
|
|
5849
5870
|
if (!browser) return ` test: {
|
|
5850
5871
|
${renderedProjects}
|
|
5851
5872
|
},`;
|
|
5873
|
+
const renderedRegistrations = registrations.map((registration) => registration.browser === void 0 ? `{ project: ${registration.project} }` : `{ project: ${registration.project}, browser: ${serializeTypeScriptString(registration.browser)} }`);
|
|
5874
|
+
const inlineRegistrations = ` [${renderedRegistrations.join(", ")}],`;
|
|
5852
5875
|
return ` test: gateBrowserProjects(
|
|
5853
|
-
[
|
|
5854
|
-
${
|
|
5855
|
-
]
|
|
5876
|
+
${fitsPrintWidth(inlineRegistrations) ? inlineRegistrations : ` [
|
|
5877
|
+
${renderedRegistrations.map((registration) => ` ${registration},`).join("\n")}
|
|
5878
|
+
],`}
|
|
5856
5879
|
hasChromium,
|
|
5857
5880
|
process.argv,
|
|
5858
5881
|
),`;
|
|
@@ -7449,17 +7472,17 @@ function binViteProject() {
|
|
|
7449
7472
|
/**
|
|
7450
7473
|
* Build the standalone Node-only installed-consumer integration proof project.
|
|
7451
7474
|
*
|
|
7452
|
-
* @param
|
|
7475
|
+
* @param facts - Optional structural facts controlling the shared global setup.
|
|
7453
7476
|
* @returns The emitted `integration` project definition.
|
|
7454
7477
|
*
|
|
7455
7478
|
* @example
|
|
7456
7479
|
* ```ts
|
|
7457
|
-
* integrationViteProject({ bin: true, integration: true }).includes(
|
|
7458
|
-
* "globalSetup: ['./tests/
|
|
7480
|
+
* integrationViteProject({ bin: true, integration: true, global: true }).includes(
|
|
7481
|
+
* "globalSetup: ['./tests/setupGlobal.ts']",
|
|
7459
7482
|
* ) // true
|
|
7460
7483
|
* ```
|
|
7461
7484
|
*/
|
|
7462
|
-
function integrationViteProject(
|
|
7485
|
+
function integrationViteProject(facts = {}) {
|
|
7463
7486
|
return `${EXPORT_KEYWORD} const integration = (config?: UserConfig): UserConfig =>
|
|
7464
7487
|
mergeConfig(
|
|
7465
7488
|
{
|
|
@@ -7468,8 +7491,8 @@ function integrationViteProject(axes = {}) {
|
|
|
7468
7491
|
name: { label: 'integration', color: 'blue' },
|
|
7469
7492
|
include: ['tests/integration/**/*.test.ts'],
|
|
7470
7493
|
setupFiles: ['./tests/setup.ts'],
|
|
7471
|
-
${
|
|
7472
|
-
globalSetup: ['
|
|
7494
|
+
${facts.bin === true && facts.integration === true && facts.global === true ? ` // Wire the template registry for the generated-consumer proof.
|
|
7495
|
+
globalSetup: ['./${GLOBAL_SETUP_PATH}'],
|
|
7473
7496
|
` : ""} environment: 'node',
|
|
7474
7497
|
browser: { enabled: false },
|
|
7475
7498
|
testTimeout: 120_000,
|
|
@@ -7520,7 +7543,7 @@ function serviceViteProject() {
|
|
|
7520
7543
|
* projects.
|
|
7521
7544
|
*
|
|
7522
7545
|
* @param environment - The sole declared non-`core` environment.
|
|
7523
|
-
* @param
|
|
7546
|
+
* @param facts - Optional structural facts.
|
|
7524
7547
|
* @returns The root `vite.config.ts` file content for a single non-`core` environment, newline-terminated.
|
|
7525
7548
|
*
|
|
7526
7549
|
* @example
|
|
@@ -7528,11 +7551,11 @@ function serviceViteProject() {
|
|
|
7528
7551
|
* singleSrcViteConfig('server').includes('srcServer') // true
|
|
7529
7552
|
* ```
|
|
7530
7553
|
*/
|
|
7531
|
-
function singleSrcViteConfig(environment,
|
|
7554
|
+
function singleSrcViteConfig(environment, facts = {}) {
|
|
7532
7555
|
const machinery = viteMachinery([environment]);
|
|
7533
7556
|
const header = viteHeader(machinery);
|
|
7534
|
-
const renderedTest = renderViteTest(viteProjectRegistrations([environment], [],
|
|
7535
|
-
const definitions = viteProjectDefinitions(
|
|
7557
|
+
const renderedTest = renderViteTest(viteProjectRegistrations([environment], [], facts), machinery.browser);
|
|
7558
|
+
const definitions = viteProjectDefinitions(facts);
|
|
7536
7559
|
if (environment === "browser") return `${header}
|
|
7537
7560
|
${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
|
|
7538
7561
|
mergeConfig(
|
|
@@ -7559,7 +7582,7 @@ ${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
|
|
|
7559
7582
|
test: {
|
|
7560
7583
|
name: { label: 'src:browser', color: 'yellow' },
|
|
7561
7584
|
include: ['tests/src/browser/**/*.test.ts'],
|
|
7562
|
-
setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
|
|
7585
|
+
${facts.global === true ? `globalSetup: ['./${GLOBAL_SETUP_PATH}'],\n\t\t\t\t` : ""}setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
|
|
7563
7586
|
...(config?.test?.browser?.enabled === false
|
|
7564
7587
|
? {}
|
|
7565
7588
|
: {
|
|
@@ -7648,9 +7671,9 @@ ${renderedTest}
|
|
|
7648
7671
|
* environment is `browser` (it must run its own tests in a real browser).
|
|
7649
7672
|
*
|
|
7650
7673
|
* @param src - The declared `Environment[]`.
|
|
7651
|
-
* @param
|
|
7652
|
-
*
|
|
7653
|
-
*
|
|
7674
|
+
* @param facts - Optional structural facts. `bin` appends the standalone executable
|
|
7675
|
+
* build-and-test project; `integration` and `service` append their standalone
|
|
7676
|
+
* proof projects; `global` wires the shared global-setup module.
|
|
7654
7677
|
* @returns The root `vite.config.ts` file content, newline-terminated.
|
|
7655
7678
|
*
|
|
7656
7679
|
* @example
|
|
@@ -7658,14 +7681,14 @@ ${renderedTest}
|
|
|
7658
7681
|
* rootViteConfig(['core']).includes('srcCore') // true
|
|
7659
7682
|
* ```
|
|
7660
7683
|
*/
|
|
7661
|
-
function rootViteConfig(src,
|
|
7684
|
+
function rootViteConfig(src, facts = {}) {
|
|
7662
7685
|
const hasCore = src.includes("core");
|
|
7663
7686
|
const nonCore = ENVIRONMENTS.filter((environment) => environment !== "core" && src.includes(environment));
|
|
7664
7687
|
const machinery = viteMachinery(src);
|
|
7665
7688
|
const header = viteHeader(machinery);
|
|
7666
7689
|
if (!hasCore) {
|
|
7667
7690
|
const [onlyEnvironment] = nonCore;
|
|
7668
|
-
if (onlyEnvironment === "browser" || onlyEnvironment === "server") return singleSrcViteConfig(onlyEnvironment,
|
|
7691
|
+
if (onlyEnvironment === "browser" || onlyEnvironment === "server") return singleSrcViteConfig(onlyEnvironment, facts);
|
|
7669
7692
|
}
|
|
7670
7693
|
const browserBlock = `
|
|
7671
7694
|
${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
|
|
@@ -7692,7 +7715,7 @@ ${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
|
|
|
7692
7715
|
name: { label: 'src:browser', color: 'yellow' },
|
|
7693
7716
|
include: ['tests/src/browser/**/*.test.ts'],
|
|
7694
7717
|
exclude: ['tests/src/core/**/*.test.ts'],
|
|
7695
|
-
setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
|
|
7718
|
+
${facts.global === true ? `globalSetup: ['./${GLOBAL_SETUP_PATH}'],\n\t\t\t\t\t` : ""}setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
|
|
7696
7719
|
...(config?.test?.browser?.enabled === false
|
|
7697
7720
|
? {}
|
|
7698
7721
|
: {
|
|
@@ -7760,7 +7783,7 @@ ${EXPORT_KEYWORD} const srcServer = (config?: UserConfig): UserConfig =>
|
|
|
7760
7783
|
)
|
|
7761
7784
|
`;
|
|
7762
7785
|
const blocks = nonCore.map((environment) => environment === "browser" ? browserBlock : serverBlock).join("");
|
|
7763
|
-
const renderedTest = renderViteTest(viteProjectRegistrations(src, [],
|
|
7786
|
+
const renderedTest = renderViteTest(viteProjectRegistrations(src, [], facts), machinery.browser);
|
|
7764
7787
|
return `${header}
|
|
7765
7788
|
${EXPORT_KEYWORD} const srcCore = (config?: UserConfig): UserConfig =>
|
|
7766
7789
|
mergeConfig(
|
|
@@ -7783,7 +7806,7 @@ ${EXPORT_KEYWORD} const srcCore = (config?: UserConfig): UserConfig =>
|
|
|
7783
7806
|
config ?? {},
|
|
7784
7807
|
)
|
|
7785
7808
|
${blocks}
|
|
7786
|
-
${viteProjectDefinitions(
|
|
7809
|
+
${viteProjectDefinitions(facts)}
|
|
7787
7810
|
export default defineConfig({
|
|
7788
7811
|
resolve,
|
|
7789
7812
|
${renderedTest}
|
|
@@ -7796,7 +7819,7 @@ ${renderedTest}
|
|
|
7796
7819
|
*
|
|
7797
7820
|
* @param src - Published src environments.
|
|
7798
7821
|
* @param app - Private app environments.
|
|
7799
|
-
* @param
|
|
7822
|
+
* @param facts - Optional structural facts.
|
|
7800
7823
|
* @returns The root `vite.config.ts` content.
|
|
7801
7824
|
*
|
|
7802
7825
|
* @example
|
|
@@ -7804,9 +7827,9 @@ ${renderedTest}
|
|
|
7804
7827
|
* applicationViteConfig([], ['core', 'server']).includes('appServer') // true
|
|
7805
7828
|
* ```
|
|
7806
7829
|
*/
|
|
7807
|
-
function applicationViteConfig(src, app,
|
|
7830
|
+
function applicationViteConfig(src, app, facts = {}) {
|
|
7808
7831
|
const hasSourceCore = src.includes("core");
|
|
7809
|
-
const machinery = viteMachinery(src, app,
|
|
7832
|
+
const machinery = viteMachinery(src, app, facts.bin === true);
|
|
7810
7833
|
const header = viteHeader(machinery);
|
|
7811
7834
|
const blocks = [];
|
|
7812
7835
|
if (src.includes("core")) blocks.push(`
|
|
@@ -7858,7 +7881,7 @@ ${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
|
|
|
7858
7881
|
test: {
|
|
7859
7882
|
name: { label: 'src:browser', color: 'yellow' },
|
|
7860
7883
|
include: ['tests/src/browser/**/*.test.ts'],
|
|
7861
|
-
${hasSourceCore ? "exclude: ['tests/src/core/**/*.test.ts'],\n " : ""}setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
|
|
7884
|
+
${hasSourceCore ? "exclude: ['tests/src/core/**/*.test.ts'],\n " : ""}${facts.global === true ? `globalSetup: ['./${GLOBAL_SETUP_PATH}'],\n\t\t\t\t` : ""}setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
|
|
7862
7885
|
...(config?.test?.browser?.enabled === false
|
|
7863
7886
|
? {}
|
|
7864
7887
|
: {
|
|
@@ -8041,8 +8064,8 @@ ${EXPORT_KEYWORD} const appServer = (config?: UserConfig): UserConfig =>
|
|
|
8041
8064
|
config ?? {},
|
|
8042
8065
|
)
|
|
8043
8066
|
`);
|
|
8044
|
-
const renderedTest = renderViteTest(viteProjectRegistrations(src, app,
|
|
8045
|
-
const definitions = viteProjectDefinitions(
|
|
8067
|
+
const renderedTest = renderViteTest(viteProjectRegistrations(src, app, facts), machinery.browser);
|
|
8068
|
+
const definitions = viteProjectDefinitions(facts);
|
|
8046
8069
|
return `${header}${blocks.join("")}
|
|
8047
8070
|
${definitions}
|
|
8048
8071
|
export default defineConfig({
|
|
@@ -8455,7 +8478,7 @@ function configArtifacts(spec) {
|
|
|
8455
8478
|
*/
|
|
8456
8479
|
function sourceArtifacts(spec, pascal) {
|
|
8457
8480
|
const inlineTypeImport = `import type { ${pascal}Interface, ${pascal}Options } from './types.js'`;
|
|
8458
|
-
const typeImport =
|
|
8481
|
+
const typeImport = fitsPrintWidth(inlineTypeImport) ? inlineTypeImport : `import type {
|
|
8459
8482
|
${pascal}Interface,
|
|
8460
8483
|
${pascal}Options,
|
|
8461
8484
|
} from './types.js'`;
|
|
@@ -8463,7 +8486,7 @@ function sourceArtifacts(spec, pascal) {
|
|
|
8463
8486
|
const inlineSignature = `function create${pascal}(options: ${pascal}Options): ${pascal}Interface`;
|
|
8464
8487
|
const values = {
|
|
8465
8488
|
pascal,
|
|
8466
|
-
signature:
|
|
8489
|
+
signature: fitsPrintWidth(`export ${inlineSignature} {`) ? inlineSignature : `function create${pascal}(
|
|
8467
8490
|
options: ${pascal}Options,
|
|
8468
8491
|
): ${pascal}Interface`,
|
|
8469
8492
|
typeImport,
|
|
@@ -8537,7 +8560,7 @@ function paritySpecifiers(spec) {
|
|
|
8537
8560
|
for (const environment of spec.app) modules[`@app/${environment}`] = `app/${environment}`;
|
|
8538
8561
|
const specifierItems = selfSpecifiers.map((specifier) => `'${specifier}'`);
|
|
8539
8562
|
const inlineSpecifierList = `[${specifierItems.join(", ")}]`;
|
|
8540
|
-
return `${EXPORT_KEYWORD} ${CONST_KEYWORD} SELF_SPECIFIERS = ${
|
|
8563
|
+
return `${EXPORT_KEYWORD} ${CONST_KEYWORD} SELF_SPECIFIERS = ${fitsPrintWidth(`const SELF_SPECIFIERS = ${inlineSpecifierList}`) ? inlineSpecifierList : `[
|
|
8541
8564
|
${specifierItems.map((specifier) => `\t${specifier},`).join("\n")}
|
|
8542
8565
|
]`}
|
|
8543
8566
|
|
|
@@ -8616,25 +8639,25 @@ function testArtifacts(spec, pascal) {
|
|
|
8616
8639
|
const multilineExplicitInstance = `instance: ${pascal}Interface = new ${pascal}({
|
|
8617
8640
|
id: 'example',
|
|
8618
8641
|
})`;
|
|
8619
|
-
const explicitInstance =
|
|
8642
|
+
const explicitInstance = fitsPrintWidth(`\t\tconst ${inlineExplicitInstance}`) ? inlineExplicitInstance : fitsPrintWidth(`\t\tconst instance: ${pascal}Interface = new ${pascal}({`) ? multilineExplicitInstance : `instance: ${pascal}Interface =
|
|
8620
8643
|
new ${pascal}({
|
|
8621
8644
|
id: 'example',
|
|
8622
8645
|
})`;
|
|
8623
8646
|
const inlineValueImport = `import { create${pascal}, ${pascal} } from '@src/core'`;
|
|
8624
|
-
const valueImport =
|
|
8647
|
+
const valueImport = fitsPrintWidth(inlineValueImport) ? inlineValueImport : `import {
|
|
8625
8648
|
create${pascal},
|
|
8626
8649
|
${pascal},
|
|
8627
8650
|
} from '@src/core'`;
|
|
8628
8651
|
const inlineTestTypeImport = `import type { ${pascal}Interface } from '@src/core'`;
|
|
8629
|
-
const testTypeImport =
|
|
8652
|
+
const testTypeImport = fitsPrintWidth(inlineTestTypeImport) ? inlineTestTypeImport : `import type {
|
|
8630
8653
|
${pascal}Interface,
|
|
8631
8654
|
} from '@src/core'`;
|
|
8632
8655
|
const inlineFactoryInstance = `instance = create${pascal}({ id: 'example' })`;
|
|
8633
|
-
const factoryInstance =
|
|
8656
|
+
const factoryInstance = fitsPrintWidth(`\t\tconst ${inlineFactoryInstance}`) ? inlineFactoryInstance : `instance = create${pascal}({
|
|
8634
8657
|
id: 'example',
|
|
8635
8658
|
})`;
|
|
8636
8659
|
const inlineTypeExpectation = `expectTypeOf(create${pascal}({ id: 'example' })).toEqualTypeOf<${pascal}Interface>()`;
|
|
8637
|
-
const typeExpectation =
|
|
8660
|
+
const typeExpectation = fitsPrintWidth(`\t\t${inlineTypeExpectation}`) ? inlineTypeExpectation : `expectTypeOf(
|
|
8638
8661
|
create${pascal}({ id: 'example' }),
|
|
8639
8662
|
).toEqualTypeOf<${pascal}Interface>()`;
|
|
8640
8663
|
for (const environment of spec.src) {
|
|
@@ -9587,6 +9610,7 @@ exports.EXTRA_NAME_PATTERN = EXTRA_NAME_PATTERN;
|
|
|
9587
9610
|
exports.EXTRA_RANGE_PATTERN = EXTRA_RANGE_PATTERN;
|
|
9588
9611
|
exports.FRESHNESS = FRESHNESS;
|
|
9589
9612
|
exports.FUNCTION_KEYWORD = FUNCTION_KEYWORD;
|
|
9613
|
+
exports.GLOBAL_SETUP_PATH = GLOBAL_SETUP_PATH;
|
|
9590
9614
|
exports.GROUPS = GROUPS;
|
|
9591
9615
|
exports.HEX_PATTERN = HEX_PATTERN;
|
|
9592
9616
|
exports.HOST_PATHS = HOST_PATHS;
|
|
@@ -9665,6 +9689,7 @@ exports.exportsMap = exportsMap;
|
|
|
9665
9689
|
exports.fillArtifact = fillArtifact;
|
|
9666
9690
|
exports.findFileConflict = findFileConflict;
|
|
9667
9691
|
exports.findPathConflict = findPathConflict;
|
|
9692
|
+
exports.fitsPrintWidth = fitsPrintWidth;
|
|
9668
9693
|
exports.formatJson = formatJson;
|
|
9669
9694
|
exports.guideArtifacts = guideArtifacts;
|
|
9670
9695
|
exports.guideMemberTable = guideMemberTable;
|