@orkestrel/scaffold 0.0.9 → 0.0.11
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 +47 -21
- 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 +78 -54
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +51 -21
- package/dist/src/core/index.d.ts +51 -21
- package/dist/src/core/index.js +77 -55
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +9 -3
- 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 +11 -5
- package/dist/src/server/index.js.map +1 -1
- package/package.json +1 -1
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,7 +227,7 @@ 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.11";
|
|
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",
|
|
@@ -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,
|
|
@@ -1599,6 +1602,22 @@ function computeColumnWidth(text) {
|
|
|
1599
1602
|
return width;
|
|
1600
1603
|
}
|
|
1601
1604
|
/**
|
|
1605
|
+
* Test whether a complete rendered line fits the fleet formatter's print width.
|
|
1606
|
+
*
|
|
1607
|
+
* @param text - The complete rendered line, including indentation and trailing punctuation.
|
|
1608
|
+
* @returns Whether the line fits within `JSON_PRINT_WIDTH`.
|
|
1609
|
+
*
|
|
1610
|
+
* @example
|
|
1611
|
+
* ```ts
|
|
1612
|
+
* import { fitsPrintWidth } from '@orkestrel/scaffold'
|
|
1613
|
+
*
|
|
1614
|
+
* fitsPrintWidth('\t["ESNext"],') // true
|
|
1615
|
+
* ```
|
|
1616
|
+
*/
|
|
1617
|
+
function fitsPrintWidth(text) {
|
|
1618
|
+
return computeColumnWidth(text) <= 100;
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1602
1621
|
* Render a JSON array through `formatJson`'s inline-or-broken rule — inline
|
|
1603
1622
|
* when the rendered width (via `computeColumnWidth`) fits `JSON_PRINT_WIDTH`, one
|
|
1604
1623
|
* item per line otherwise.
|
|
@@ -1620,7 +1639,7 @@ function renderArray(entries, indent, prefix, suffix) {
|
|
|
1620
1639
|
if (entries.length === 0) return "[]";
|
|
1621
1640
|
const items = entries.map((entry) => renderValue(entry, indent, "", ""));
|
|
1622
1641
|
const inline = `[${items.join(", ")}]`;
|
|
1623
|
-
if (
|
|
1642
|
+
if (fitsPrintWidth(`${prefix}${inline}${suffix}`)) return inline;
|
|
1624
1643
|
const childIndent = `${indent}\t`;
|
|
1625
1644
|
return `[\n${items.map((item) => `${childIndent}${item}`).join(",\n")}\n${indent}]`;
|
|
1626
1645
|
}
|
|
@@ -1803,7 +1822,8 @@ function blueprintShape() {
|
|
|
1803
1822
|
overrides: (0, _orkestrel_contract.arrayShape)(overrideShape(), { max: MAX_COLLECTION_ITEMS }),
|
|
1804
1823
|
bin: (0, _orkestrel_contract.booleanShape)(),
|
|
1805
1824
|
integration: (0, _orkestrel_contract.booleanShape)(),
|
|
1806
|
-
service: (0, _orkestrel_contract.booleanShape)()
|
|
1825
|
+
service: (0, _orkestrel_contract.booleanShape)(),
|
|
1826
|
+
global: (0, _orkestrel_contract.booleanShape)()
|
|
1807
1827
|
});
|
|
1808
1828
|
}
|
|
1809
1829
|
/**
|
|
@@ -5773,7 +5793,7 @@ function viteMachinery(src, app = [], bin = false) {
|
|
|
5773
5793
|
*
|
|
5774
5794
|
* @param src - The declared published environments.
|
|
5775
5795
|
* @param app - The declared application environments.
|
|
5776
|
-
* @param
|
|
5796
|
+
* @param facts - Optional structural facts.
|
|
5777
5797
|
* @returns Source projects, application projects, proof projects, then optional axis projects.
|
|
5778
5798
|
*
|
|
5779
5799
|
* @example
|
|
@@ -5782,7 +5802,7 @@ function viteMachinery(src, app = [], bin = false) {
|
|
|
5782
5802
|
* // [{ project: 'srcCore' }, { project: 'policy' }, { project: 'guides' }, { project: 'integration' }]
|
|
5783
5803
|
* ```
|
|
5784
5804
|
*/
|
|
5785
|
-
function viteProjectRegistrations(src, app = [],
|
|
5805
|
+
function viteProjectRegistrations(src, app = [], facts = {}) {
|
|
5786
5806
|
const registrations = [];
|
|
5787
5807
|
for (const environment of ENVIRONMENTS) {
|
|
5788
5808
|
if (!src.includes(environment)) continue;
|
|
@@ -5803,15 +5823,15 @@ function viteProjectRegistrations(src, app = [], axes = {}) {
|
|
|
5803
5823
|
if (environment === "server") registrations.push({ project: "appServer" });
|
|
5804
5824
|
}
|
|
5805
5825
|
registrations.push({ project: "policy" }, { project: "guides" });
|
|
5806
|
-
if (
|
|
5807
|
-
if (
|
|
5808
|
-
if (
|
|
5826
|
+
if (facts.bin === true) registrations.push({ project: "srcBin" });
|
|
5827
|
+
if (facts.integration === true) registrations.push({ project: "integration" });
|
|
5828
|
+
if (facts.service === true) registrations.push({ project: "service" });
|
|
5809
5829
|
return registrations;
|
|
5810
5830
|
}
|
|
5811
5831
|
/**
|
|
5812
5832
|
* Render the one ordered proof and structural-axis project definition block.
|
|
5813
5833
|
*
|
|
5814
|
-
* @param
|
|
5834
|
+
* @param facts - Optional structural facts.
|
|
5815
5835
|
* @returns Policy, guides, then selected axis project definitions, separated by one blank line.
|
|
5816
5836
|
*
|
|
5817
5837
|
* @example
|
|
@@ -5819,11 +5839,11 @@ function viteProjectRegistrations(src, app = [], axes = {}) {
|
|
|
5819
5839
|
* viteProjectDefinitions({ bin: true }).includes('export const srcBin =') // true
|
|
5820
5840
|
* ```
|
|
5821
5841
|
*/
|
|
5822
|
-
function viteProjectDefinitions(
|
|
5842
|
+
function viteProjectDefinitions(facts = {}) {
|
|
5823
5843
|
const definitions = [policyViteProject(), guidesViteProject()];
|
|
5824
|
-
if (
|
|
5825
|
-
if (
|
|
5826
|
-
if (
|
|
5844
|
+
if (facts.bin === true) definitions.push(binViteProject());
|
|
5845
|
+
if (facts.integration === true) definitions.push(integrationViteProject(facts));
|
|
5846
|
+
if (facts.service === true) definitions.push(serviceViteProject());
|
|
5827
5847
|
return definitions.join("\n");
|
|
5828
5848
|
}
|
|
5829
5849
|
/**
|
|
@@ -5843,16 +5863,18 @@ function viteProjectDefinitions(axes = {}) {
|
|
|
5843
5863
|
function renderViteTest(registrations, browser) {
|
|
5844
5864
|
const projects = registrations.map((registration) => registration.project);
|
|
5845
5865
|
const inlineProjects = ` projects: [${projects.join(", ")}],`;
|
|
5846
|
-
const renderedProjects =
|
|
5866
|
+
const renderedProjects = fitsPrintWidth(inlineProjects) ? inlineProjects : ` projects: [
|
|
5847
5867
|
${projects.map((project) => ` ${project},`).join("\n")}
|
|
5848
5868
|
],`;
|
|
5849
5869
|
if (!browser) return ` test: {
|
|
5850
5870
|
${renderedProjects}
|
|
5851
5871
|
},`;
|
|
5872
|
+
const renderedRegistrations = registrations.map((registration) => registration.browser === void 0 ? `{ project: ${registration.project} }` : `{ project: ${registration.project}, browser: ${serializeTypeScriptString(registration.browser)} }`);
|
|
5873
|
+
const inlineRegistrations = ` [${renderedRegistrations.join(", ")}],`;
|
|
5852
5874
|
return ` test: gateBrowserProjects(
|
|
5853
|
-
[
|
|
5854
|
-
${
|
|
5855
|
-
]
|
|
5875
|
+
${fitsPrintWidth(inlineRegistrations) ? inlineRegistrations : ` [
|
|
5876
|
+
${renderedRegistrations.map((registration) => ` ${registration},`).join("\n")}
|
|
5877
|
+
],`}
|
|
5856
5878
|
hasChromium,
|
|
5857
5879
|
process.argv,
|
|
5858
5880
|
),`;
|
|
@@ -7449,17 +7471,17 @@ function binViteProject() {
|
|
|
7449
7471
|
/**
|
|
7450
7472
|
* Build the standalone Node-only installed-consumer integration proof project.
|
|
7451
7473
|
*
|
|
7452
|
-
* @param
|
|
7474
|
+
* @param facts - Optional structural facts controlling the shared global setup.
|
|
7453
7475
|
* @returns The emitted `integration` project definition.
|
|
7454
7476
|
*
|
|
7455
7477
|
* @example
|
|
7456
7478
|
* ```ts
|
|
7457
|
-
* integrationViteProject({ bin: true, integration: true }).includes(
|
|
7458
|
-
* "globalSetup: ['./tests/
|
|
7479
|
+
* integrationViteProject({ bin: true, integration: true, global: true }).includes(
|
|
7480
|
+
* "globalSetup: ['./tests/setupGlobal.ts']",
|
|
7459
7481
|
* ) // true
|
|
7460
7482
|
* ```
|
|
7461
7483
|
*/
|
|
7462
|
-
function integrationViteProject(
|
|
7484
|
+
function integrationViteProject(facts = {}) {
|
|
7463
7485
|
return `${EXPORT_KEYWORD} const integration = (config?: UserConfig): UserConfig =>
|
|
7464
7486
|
mergeConfig(
|
|
7465
7487
|
{
|
|
@@ -7468,8 +7490,8 @@ function integrationViteProject(axes = {}) {
|
|
|
7468
7490
|
name: { label: 'integration', color: 'blue' },
|
|
7469
7491
|
include: ['tests/integration/**/*.test.ts'],
|
|
7470
7492
|
setupFiles: ['./tests/setup.ts'],
|
|
7471
|
-
${
|
|
7472
|
-
globalSetup: ['
|
|
7493
|
+
${facts.bin === true && facts.integration === true && facts.global === true ? ` // Wire the template registry for the generated-consumer proof.
|
|
7494
|
+
globalSetup: ['./${GLOBAL_SETUP_PATH}'],
|
|
7473
7495
|
` : ""} environment: 'node',
|
|
7474
7496
|
browser: { enabled: false },
|
|
7475
7497
|
testTimeout: 120_000,
|
|
@@ -7520,7 +7542,7 @@ function serviceViteProject() {
|
|
|
7520
7542
|
* projects.
|
|
7521
7543
|
*
|
|
7522
7544
|
* @param environment - The sole declared non-`core` environment.
|
|
7523
|
-
* @param
|
|
7545
|
+
* @param facts - Optional structural facts.
|
|
7524
7546
|
* @returns The root `vite.config.ts` file content for a single non-`core` environment, newline-terminated.
|
|
7525
7547
|
*
|
|
7526
7548
|
* @example
|
|
@@ -7528,11 +7550,11 @@ function serviceViteProject() {
|
|
|
7528
7550
|
* singleSrcViteConfig('server').includes('srcServer') // true
|
|
7529
7551
|
* ```
|
|
7530
7552
|
*/
|
|
7531
|
-
function singleSrcViteConfig(environment,
|
|
7553
|
+
function singleSrcViteConfig(environment, facts = {}) {
|
|
7532
7554
|
const machinery = viteMachinery([environment]);
|
|
7533
7555
|
const header = viteHeader(machinery);
|
|
7534
|
-
const renderedTest = renderViteTest(viteProjectRegistrations([environment], [],
|
|
7535
|
-
const definitions = viteProjectDefinitions(
|
|
7556
|
+
const renderedTest = renderViteTest(viteProjectRegistrations([environment], [], facts), machinery.browser);
|
|
7557
|
+
const definitions = viteProjectDefinitions(facts);
|
|
7536
7558
|
if (environment === "browser") return `${header}
|
|
7537
7559
|
${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
|
|
7538
7560
|
mergeConfig(
|
|
@@ -7559,7 +7581,7 @@ ${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
|
|
|
7559
7581
|
test: {
|
|
7560
7582
|
name: { label: 'src:browser', color: 'yellow' },
|
|
7561
7583
|
include: ['tests/src/browser/**/*.test.ts'],
|
|
7562
|
-
setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
|
|
7584
|
+
${facts.global === true ? `globalSetup: ['./${GLOBAL_SETUP_PATH}'],\n\t\t\t\t` : ""}setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
|
|
7563
7585
|
...(config?.test?.browser?.enabled === false
|
|
7564
7586
|
? {}
|
|
7565
7587
|
: {
|
|
@@ -7648,9 +7670,9 @@ ${renderedTest}
|
|
|
7648
7670
|
* environment is `browser` (it must run its own tests in a real browser).
|
|
7649
7671
|
*
|
|
7650
7672
|
* @param src - The declared `Environment[]`.
|
|
7651
|
-
* @param
|
|
7652
|
-
*
|
|
7653
|
-
*
|
|
7673
|
+
* @param facts - Optional structural facts. `bin` appends the standalone executable
|
|
7674
|
+
* build-and-test project; `integration` and `service` append their standalone
|
|
7675
|
+
* proof projects; `global` wires the shared global-setup module.
|
|
7654
7676
|
* @returns The root `vite.config.ts` file content, newline-terminated.
|
|
7655
7677
|
*
|
|
7656
7678
|
* @example
|
|
@@ -7658,14 +7680,14 @@ ${renderedTest}
|
|
|
7658
7680
|
* rootViteConfig(['core']).includes('srcCore') // true
|
|
7659
7681
|
* ```
|
|
7660
7682
|
*/
|
|
7661
|
-
function rootViteConfig(src,
|
|
7683
|
+
function rootViteConfig(src, facts = {}) {
|
|
7662
7684
|
const hasCore = src.includes("core");
|
|
7663
7685
|
const nonCore = ENVIRONMENTS.filter((environment) => environment !== "core" && src.includes(environment));
|
|
7664
7686
|
const machinery = viteMachinery(src);
|
|
7665
7687
|
const header = viteHeader(machinery);
|
|
7666
7688
|
if (!hasCore) {
|
|
7667
7689
|
const [onlyEnvironment] = nonCore;
|
|
7668
|
-
if (onlyEnvironment === "browser" || onlyEnvironment === "server") return singleSrcViteConfig(onlyEnvironment,
|
|
7690
|
+
if (onlyEnvironment === "browser" || onlyEnvironment === "server") return singleSrcViteConfig(onlyEnvironment, facts);
|
|
7669
7691
|
}
|
|
7670
7692
|
const browserBlock = `
|
|
7671
7693
|
${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
|
|
@@ -7692,7 +7714,7 @@ ${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
|
|
|
7692
7714
|
name: { label: 'src:browser', color: 'yellow' },
|
|
7693
7715
|
include: ['tests/src/browser/**/*.test.ts'],
|
|
7694
7716
|
exclude: ['tests/src/core/**/*.test.ts'],
|
|
7695
|
-
setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
|
|
7717
|
+
${facts.global === true ? `globalSetup: ['./${GLOBAL_SETUP_PATH}'],\n\t\t\t\t\t` : ""}setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
|
|
7696
7718
|
...(config?.test?.browser?.enabled === false
|
|
7697
7719
|
? {}
|
|
7698
7720
|
: {
|
|
@@ -7760,7 +7782,7 @@ ${EXPORT_KEYWORD} const srcServer = (config?: UserConfig): UserConfig =>
|
|
|
7760
7782
|
)
|
|
7761
7783
|
`;
|
|
7762
7784
|
const blocks = nonCore.map((environment) => environment === "browser" ? browserBlock : serverBlock).join("");
|
|
7763
|
-
const renderedTest = renderViteTest(viteProjectRegistrations(src, [],
|
|
7785
|
+
const renderedTest = renderViteTest(viteProjectRegistrations(src, [], facts), machinery.browser);
|
|
7764
7786
|
return `${header}
|
|
7765
7787
|
${EXPORT_KEYWORD} const srcCore = (config?: UserConfig): UserConfig =>
|
|
7766
7788
|
mergeConfig(
|
|
@@ -7783,7 +7805,7 @@ ${EXPORT_KEYWORD} const srcCore = (config?: UserConfig): UserConfig =>
|
|
|
7783
7805
|
config ?? {},
|
|
7784
7806
|
)
|
|
7785
7807
|
${blocks}
|
|
7786
|
-
${viteProjectDefinitions(
|
|
7808
|
+
${viteProjectDefinitions(facts)}
|
|
7787
7809
|
export default defineConfig({
|
|
7788
7810
|
resolve,
|
|
7789
7811
|
${renderedTest}
|
|
@@ -7796,7 +7818,7 @@ ${renderedTest}
|
|
|
7796
7818
|
*
|
|
7797
7819
|
* @param src - Published src environments.
|
|
7798
7820
|
* @param app - Private app environments.
|
|
7799
|
-
* @param
|
|
7821
|
+
* @param facts - Optional structural facts.
|
|
7800
7822
|
* @returns The root `vite.config.ts` content.
|
|
7801
7823
|
*
|
|
7802
7824
|
* @example
|
|
@@ -7804,9 +7826,9 @@ ${renderedTest}
|
|
|
7804
7826
|
* applicationViteConfig([], ['core', 'server']).includes('appServer') // true
|
|
7805
7827
|
* ```
|
|
7806
7828
|
*/
|
|
7807
|
-
function applicationViteConfig(src, app,
|
|
7829
|
+
function applicationViteConfig(src, app, facts = {}) {
|
|
7808
7830
|
const hasSourceCore = src.includes("core");
|
|
7809
|
-
const machinery = viteMachinery(src, app,
|
|
7831
|
+
const machinery = viteMachinery(src, app, facts.bin === true);
|
|
7810
7832
|
const header = viteHeader(machinery);
|
|
7811
7833
|
const blocks = [];
|
|
7812
7834
|
if (src.includes("core")) blocks.push(`
|
|
@@ -7858,7 +7880,7 @@ ${EXPORT_KEYWORD} const srcBrowser = (config?: UserConfig): UserConfig =>
|
|
|
7858
7880
|
test: {
|
|
7859
7881
|
name: { label: 'src:browser', color: 'yellow' },
|
|
7860
7882
|
include: ['tests/src/browser/**/*.test.ts'],
|
|
7861
|
-
${hasSourceCore ? "exclude: ['tests/src/core/**/*.test.ts'],\n " : ""}setupFiles: ['./tests/setup.ts', './tests/setupBrowser.ts'],
|
|
7883
|
+
${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
7884
|
...(config?.test?.browser?.enabled === false
|
|
7863
7885
|
? {}
|
|
7864
7886
|
: {
|
|
@@ -8041,8 +8063,8 @@ ${EXPORT_KEYWORD} const appServer = (config?: UserConfig): UserConfig =>
|
|
|
8041
8063
|
config ?? {},
|
|
8042
8064
|
)
|
|
8043
8065
|
`);
|
|
8044
|
-
const renderedTest = renderViteTest(viteProjectRegistrations(src, app,
|
|
8045
|
-
const definitions = viteProjectDefinitions(
|
|
8066
|
+
const renderedTest = renderViteTest(viteProjectRegistrations(src, app, facts), machinery.browser);
|
|
8067
|
+
const definitions = viteProjectDefinitions(facts);
|
|
8046
8068
|
return `${header}${blocks.join("")}
|
|
8047
8069
|
${definitions}
|
|
8048
8070
|
export default defineConfig({
|
|
@@ -8455,7 +8477,7 @@ function configArtifacts(spec) {
|
|
|
8455
8477
|
*/
|
|
8456
8478
|
function sourceArtifacts(spec, pascal) {
|
|
8457
8479
|
const inlineTypeImport = `import type { ${pascal}Interface, ${pascal}Options } from './types.js'`;
|
|
8458
|
-
const typeImport =
|
|
8480
|
+
const typeImport = fitsPrintWidth(inlineTypeImport) ? inlineTypeImport : `import type {
|
|
8459
8481
|
${pascal}Interface,
|
|
8460
8482
|
${pascal}Options,
|
|
8461
8483
|
} from './types.js'`;
|
|
@@ -8463,7 +8485,7 @@ function sourceArtifacts(spec, pascal) {
|
|
|
8463
8485
|
const inlineSignature = `function create${pascal}(options: ${pascal}Options): ${pascal}Interface`;
|
|
8464
8486
|
const values = {
|
|
8465
8487
|
pascal,
|
|
8466
|
-
signature:
|
|
8488
|
+
signature: fitsPrintWidth(`export ${inlineSignature} {`) ? inlineSignature : `function create${pascal}(
|
|
8467
8489
|
options: ${pascal}Options,
|
|
8468
8490
|
): ${pascal}Interface`,
|
|
8469
8491
|
typeImport,
|
|
@@ -8537,7 +8559,7 @@ function paritySpecifiers(spec) {
|
|
|
8537
8559
|
for (const environment of spec.app) modules[`@app/${environment}`] = `app/${environment}`;
|
|
8538
8560
|
const specifierItems = selfSpecifiers.map((specifier) => `'${specifier}'`);
|
|
8539
8561
|
const inlineSpecifierList = `[${specifierItems.join(", ")}]`;
|
|
8540
|
-
return `${EXPORT_KEYWORD} ${CONST_KEYWORD} SELF_SPECIFIERS = ${
|
|
8562
|
+
return `${EXPORT_KEYWORD} ${CONST_KEYWORD} SELF_SPECIFIERS = ${fitsPrintWidth(`const SELF_SPECIFIERS = ${inlineSpecifierList}`) ? inlineSpecifierList : `[
|
|
8541
8563
|
${specifierItems.map((specifier) => `\t${specifier},`).join("\n")}
|
|
8542
8564
|
]`}
|
|
8543
8565
|
|
|
@@ -8616,25 +8638,25 @@ function testArtifacts(spec, pascal) {
|
|
|
8616
8638
|
const multilineExplicitInstance = `instance: ${pascal}Interface = new ${pascal}({
|
|
8617
8639
|
id: 'example',
|
|
8618
8640
|
})`;
|
|
8619
|
-
const explicitInstance =
|
|
8641
|
+
const explicitInstance = fitsPrintWidth(`\t\tconst ${inlineExplicitInstance}`) ? inlineExplicitInstance : fitsPrintWidth(`\t\tconst instance: ${pascal}Interface = new ${pascal}({`) ? multilineExplicitInstance : `instance: ${pascal}Interface =
|
|
8620
8642
|
new ${pascal}({
|
|
8621
8643
|
id: 'example',
|
|
8622
8644
|
})`;
|
|
8623
8645
|
const inlineValueImport = `import { create${pascal}, ${pascal} } from '@src/core'`;
|
|
8624
|
-
const valueImport =
|
|
8646
|
+
const valueImport = fitsPrintWidth(inlineValueImport) ? inlineValueImport : `import {
|
|
8625
8647
|
create${pascal},
|
|
8626
8648
|
${pascal},
|
|
8627
8649
|
} from '@src/core'`;
|
|
8628
8650
|
const inlineTestTypeImport = `import type { ${pascal}Interface } from '@src/core'`;
|
|
8629
|
-
const testTypeImport =
|
|
8651
|
+
const testTypeImport = fitsPrintWidth(inlineTestTypeImport) ? inlineTestTypeImport : `import type {
|
|
8630
8652
|
${pascal}Interface,
|
|
8631
8653
|
} from '@src/core'`;
|
|
8632
8654
|
const inlineFactoryInstance = `instance = create${pascal}({ id: 'example' })`;
|
|
8633
|
-
const factoryInstance =
|
|
8655
|
+
const factoryInstance = fitsPrintWidth(`\t\tconst ${inlineFactoryInstance}`) ? inlineFactoryInstance : `instance = create${pascal}({
|
|
8634
8656
|
id: 'example',
|
|
8635
8657
|
})`;
|
|
8636
8658
|
const inlineTypeExpectation = `expectTypeOf(create${pascal}({ id: 'example' })).toEqualTypeOf<${pascal}Interface>()`;
|
|
8637
|
-
const typeExpectation =
|
|
8659
|
+
const typeExpectation = fitsPrintWidth(`\t\t${inlineTypeExpectation}`) ? inlineTypeExpectation : `expectTypeOf(
|
|
8638
8660
|
create${pascal}({ id: 'example' }),
|
|
8639
8661
|
).toEqualTypeOf<${pascal}Interface>()`;
|
|
8640
8662
|
for (const environment of spec.src) {
|
|
@@ -9587,6 +9609,7 @@ exports.EXTRA_NAME_PATTERN = EXTRA_NAME_PATTERN;
|
|
|
9587
9609
|
exports.EXTRA_RANGE_PATTERN = EXTRA_RANGE_PATTERN;
|
|
9588
9610
|
exports.FRESHNESS = FRESHNESS;
|
|
9589
9611
|
exports.FUNCTION_KEYWORD = FUNCTION_KEYWORD;
|
|
9612
|
+
exports.GLOBAL_SETUP_PATH = GLOBAL_SETUP_PATH;
|
|
9590
9613
|
exports.GROUPS = GROUPS;
|
|
9591
9614
|
exports.HEX_PATTERN = HEX_PATTERN;
|
|
9592
9615
|
exports.HOST_PATHS = HOST_PATHS;
|
|
@@ -9665,6 +9688,7 @@ exports.exportsMap = exportsMap;
|
|
|
9665
9688
|
exports.fillArtifact = fillArtifact;
|
|
9666
9689
|
exports.findFileConflict = findFileConflict;
|
|
9667
9690
|
exports.findPathConflict = findPathConflict;
|
|
9691
|
+
exports.fitsPrintWidth = fitsPrintWidth;
|
|
9668
9692
|
exports.formatJson = formatJson;
|
|
9669
9693
|
exports.guideArtifacts = guideArtifacts;
|
|
9670
9694
|
exports.guideMemberTable = guideMemberTable;
|