@domain-first/project-structure 2.14.0 → 2.14.2
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/README.md +10 -9
- package/dist/index.cjs +48 -59
- package/dist/index.js +48 -59
- package/dist/integrations/package-scripts.d.ts +1 -0
- package/dist/nested-name.d.ts +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -201,7 +201,7 @@ Enable `useReact` and choose **Scaffold React module** from the main menu. Modul
|
|
|
201
201
|
| New UI-kit component | `ui-kit/<name>/<name>.tsx` with a typed props object and a component, re-exported from `index.ts`; with `storybookFramework`, also `<name>.stories.tsx`. |
|
|
202
202
|
| New shared hook | `hooks/use-<name>.ts` with an app-wide hook, such as `use-debounce`; a leading `use-` in the name is not repeated. |
|
|
203
203
|
|
|
204
|
-
Page and widget names can include folders split by `/`. For example, a page named `admin/panel/users` is created at `pages/admin/panel/users-page.tsx` as `AdminPanelUsersPage`, and a widget with the same name at `widgets/admin/panel/users
|
|
204
|
+
Page and widget names can include folders split by `/`. For example, a page named `admin/panel/users` is created at `pages/admin/panel/admin-panel-users-page.tsx` as `AdminPanelUsersPage`, and a widget with the same name at `widgets/admin/panel/users/admin-panel-users-widget.tsx` as `AdminPanelUsersWidget` with the story title `Widgets/Admin/Panel/Users`. The widget folder uses only the last segment; file names and code names use the whole path.
|
|
205
205
|
|
|
206
206
|
### Project integrations
|
|
207
207
|
|
|
@@ -229,8 +229,8 @@ name. Identical generated configs and scripts are skipped on subsequent runs;
|
|
|
229
229
|
changed config files use the usual overwrite confirmation. Cancelling before
|
|
230
230
|
writing leaves all files unchanged.
|
|
231
231
|
|
|
232
|
-
After writing, the CLI prints npm commands for missing dependencies
|
|
233
|
-
|
|
232
|
+
After writing, the CLI prints only npm commands for missing dependencies. It
|
|
233
|
+
does not install packages or execute scripts. Install commands omit version constraints for Storybook, its React + Vite
|
|
234
234
|
framework, Vite and the React plugin; existing dependency versions are preserved
|
|
235
235
|
and must be compatible with those packages. Generate a
|
|
236
236
|
UI-kit component or a widget with separated UI to add your first story. The
|
|
@@ -244,7 +244,7 @@ Choose **Add integration → Missing domain-first packages** to compare
|
|
|
244
244
|
`domainFirstPackages` in the configuration with `dependencies`, `devDependencies`
|
|
245
245
|
and `optionalDependencies` in the project's `package.json`. The CLI prints one
|
|
246
246
|
`npm i` command for missing packages, without version constraints. If none are
|
|
247
|
-
missing, it
|
|
247
|
+
missing, it prints nothing. This
|
|
248
248
|
checks declared dependencies, not the contents of `node_modules`, and does not
|
|
249
249
|
modify files or install packages.
|
|
250
250
|
|
|
@@ -271,7 +271,9 @@ are staged until overwrite confirmation; no packages are installed and no
|
|
|
271
271
|
commands connect to the database during scaffolding.
|
|
272
272
|
|
|
273
273
|
The printed install commands omit version constraints for `prisma`,
|
|
274
|
-
`@prisma/cli-engine`, `@prisma/orm-postgres`, `temporal-polyfill`, and `dotenv`. Already declared dependencies are kept.
|
|
274
|
+
`@prisma/cli-engine`, `@prisma/orm-postgres`, `temporal-polyfill`, and `dotenv`. Already declared dependencies are kept.
|
|
275
|
+
The CLI also reminds you to add `!<rootFolder>/shared/infrastructure/prisma` to
|
|
276
|
+
your linter ignores. This is a PostgreSQL
|
|
275
277
|
preset for Prisma 8 RC, not a Prisma 7 migration tool.
|
|
276
278
|
|
|
277
279
|
After installing dependencies, configure `DATABASE_URL` (the CLI loads `.env`;
|
|
@@ -323,10 +325,9 @@ integration adds a `test:e2e` script (`playwright test`) and ignores
|
|
|
323
325
|
`/test-results/`, `/playwright-report/`, `/blob-report/`, `/playwright/.cache/`
|
|
324
326
|
and `/playwright/.auth/` in `.gitignore`.
|
|
325
327
|
|
|
326
|
-
After writing, the CLI prints
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
`npx playwright show-report`.
|
|
328
|
+
After writing, the CLI prints `npm install --save-dev @playwright/test` if the
|
|
329
|
+
package is missing and `npx playwright install --with-deps` for the browsers and
|
|
330
|
+
their system dependencies. Then run `npm run test:e2e`.
|
|
330
331
|
|
|
331
332
|
## Configuration
|
|
332
333
|
|
package/dist/index.cjs
CHANGED
|
@@ -220,11 +220,8 @@ const missingDomainFirstPackages = ()=>{
|
|
|
220
220
|
...new Set(packages)
|
|
221
221
|
].filter((name)=>!Object.hasOwn(dependencies, name));
|
|
222
222
|
return missing.length ? [
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
] : [
|
|
226
|
-
'All configured domain-first packages are already declared in package.json.'
|
|
227
|
-
];
|
|
223
|
+
`npm i ${missing.join(' ')}`
|
|
224
|
+
] : [];
|
|
228
225
|
};
|
|
229
226
|
const addPackageScripts = async (file, additions)=>{
|
|
230
227
|
const original = file.data;
|
|
@@ -260,6 +257,7 @@ const addPackageScripts = async (file, additions)=>{
|
|
|
260
257
|
}
|
|
261
258
|
return selected;
|
|
262
259
|
};
|
|
260
|
+
const describeScripts = (selected, descriptions)=>Object.entries(descriptions).filter(([name])=>selected[name]).map(([name, description])=>`npm run ${selected[name]} — ${description}`);
|
|
263
261
|
const addGitignoreEntry = (root, entry)=>{
|
|
264
262
|
const gitignore = new File(external_node_path_default().join(root, '.gitignore'));
|
|
265
263
|
const ignored = gitignore.exists ? gitignore.data : '';
|
|
@@ -372,19 +370,13 @@ const addPlaywright = async ()=>{
|
|
|
372
370
|
}
|
|
373
371
|
for (const entry of gitignoreEntries)addGitignoreEntry(root, entry);
|
|
374
372
|
return [
|
|
375
|
-
'Playwright configuration saved.',
|
|
376
|
-
'Next steps (run from the project package directory):',
|
|
377
373
|
...dependencies['@playwright/test'] ? [] : [
|
|
378
|
-
'
|
|
379
|
-
],
|
|
380
|
-
' npx playwright install --with-deps',
|
|
381
|
-
' Existing dependency versions were kept.',
|
|
382
|
-
...manifest.scripts?.dev ? [] : [
|
|
383
|
-
' Add a "dev" script: Playwright starts it as the web server.'
|
|
374
|
+
'npm install --save-dev @playwright/test'
|
|
384
375
|
],
|
|
385
|
-
'
|
|
386
|
-
|
|
387
|
-
|
|
376
|
+
'npx playwright install --with-deps',
|
|
377
|
+
...describeScripts(selected, {
|
|
378
|
+
'test:e2e': 'start the dev server and run end-to-end specs from specs/e2e'
|
|
379
|
+
})
|
|
388
380
|
];
|
|
389
381
|
};
|
|
390
382
|
const runtimePackages = [
|
|
@@ -493,24 +485,19 @@ const addPrisma = async ()=>{
|
|
|
493
485
|
const install = (packages, dev)=>{
|
|
494
486
|
const missing = packages.filter((name)=>!dependencies[name]);
|
|
495
487
|
return missing.length ? [
|
|
496
|
-
`
|
|
488
|
+
`npm install${dev ? ' --save-dev' : ''} ${missing.join(' ')}`
|
|
497
489
|
] : [];
|
|
498
490
|
};
|
|
499
|
-
const scriptCommand = (name)=>selected[name] ? `npm run ${selected[name]}` : prismaScripts(config.rootFolder)[name];
|
|
500
491
|
const relativeFolder = external_node_path_default().relative(root, prismaFolder).split(external_node_path_default().sep).join('/');
|
|
501
492
|
return [
|
|
502
|
-
'Prisma 8 configuration saved (PostgreSQL, RC preset).',
|
|
503
|
-
'Next steps (run from the project package directory):',
|
|
504
493
|
...install(runtimePackages, false),
|
|
505
494
|
...install(developmentPackages, true),
|
|
506
|
-
`
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
` Plan migrations: ${scriptCommand('prisma:migration:plan')}`,
|
|
513
|
-
` Review the generated migrations, then apply: ${scriptCommand('prisma:migration:apply')}`
|
|
495
|
+
`Add !${relativeFolder} in your linter, to ignore prisma files.`,
|
|
496
|
+
...describeScripts(selected, {
|
|
497
|
+
'prisma:emit': 'emit contract.json and contract.d.ts from contract.prisma',
|
|
498
|
+
'prisma:migration:plan': 'emit the contract and plan a migration',
|
|
499
|
+
'prisma:migration:apply': 'apply planned migrations to the database in DATABASE_URL'
|
|
500
|
+
})
|
|
514
501
|
];
|
|
515
502
|
};
|
|
516
503
|
const storybookFiles = (relativeProjectRoot)=>({
|
|
@@ -611,23 +598,16 @@ const addStorybook = async ()=>{
|
|
|
611
598
|
'react-dom'
|
|
612
599
|
].filter((name)=>!dependencies[name]);
|
|
613
600
|
return [
|
|
614
|
-
'Storybook configuration saved (React + Vite).',
|
|
615
|
-
'Next steps (run from the project package directory):',
|
|
616
601
|
...missing.length ? [
|
|
617
|
-
`
|
|
602
|
+
`npm install --save-dev ${missing.join(' ')}`
|
|
618
603
|
] : [],
|
|
619
604
|
...missingReact.length ? [
|
|
620
|
-
`
|
|
605
|
+
`npm install ${missingReact.join(' ')}`
|
|
621
606
|
] : [],
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
` npm run ${selected.storybook}`
|
|
627
|
-
] : [],
|
|
628
|
-
...selected['build-storybook'] ? [
|
|
629
|
-
` npm run ${selected['build-storybook']}`
|
|
630
|
-
] : []
|
|
607
|
+
...describeScripts(selected, {
|
|
608
|
+
storybook: 'start Storybook on http://localhost:6006',
|
|
609
|
+
'build-storybook': `build static Storybook into ${buildFolder}`
|
|
610
|
+
})
|
|
631
611
|
];
|
|
632
612
|
};
|
|
633
613
|
const vitestScripts = {
|
|
@@ -696,18 +676,13 @@ const addVitest = async ()=>{
|
|
|
696
676
|
'@vitest/coverage-v8'
|
|
697
677
|
].filter((name)=>!dependencies[name]);
|
|
698
678
|
return [
|
|
699
|
-
'Vitest configuration saved.',
|
|
700
|
-
'Next steps (run from the project package directory):',
|
|
701
679
|
...missing.length ? [
|
|
702
|
-
`
|
|
703
|
-
] : [],
|
|
704
|
-
' Existing dependency versions were kept; resolve.tsconfigPaths requires Vite 8+.',
|
|
705
|
-
...selected.test ? [
|
|
706
|
-
` npm run ${selected.test}`
|
|
680
|
+
`npm install --save-dev ${missing.join(' ')}`
|
|
707
681
|
] : [],
|
|
708
|
-
...selected
|
|
709
|
-
|
|
710
|
-
|
|
682
|
+
...describeScripts(selected, {
|
|
683
|
+
test: 'run unit tests',
|
|
684
|
+
'test:coverage': 'run unit tests with a V8 coverage report in coverage/'
|
|
685
|
+
})
|
|
711
686
|
];
|
|
712
687
|
};
|
|
713
688
|
const integrations = [
|
|
@@ -742,13 +717,25 @@ const addIntegration = async ()=>{
|
|
|
742
717
|
});
|
|
743
718
|
const nextSteps = await integrations[index].run();
|
|
744
719
|
if (await savePendingChanges()) {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
720
|
+
const isCommand = (line)=>/^\s*(?:npm (?:i|install)|npx playwright install)\b/.test(line);
|
|
721
|
+
const commands = nextSteps.filter(isCommand);
|
|
722
|
+
const notes = nextSteps.filter((line)=>!isCommand(line));
|
|
723
|
+
const sections = [];
|
|
724
|
+
if (commands.length) sections.push([
|
|
725
|
+
'Run these commands to install the required dependencies:',
|
|
726
|
+
...commands.map((line)=>(0, external_node_util_namespaceObject.styleText)([
|
|
749
727
|
'bold',
|
|
750
728
|
'cyan'
|
|
751
|
-
],
|
|
729
|
+
], line))
|
|
730
|
+
].join('\n'));
|
|
731
|
+
if (notes.length) sections.push([
|
|
732
|
+
'Additional information:',
|
|
733
|
+
...notes.map((line)=>line.replace(/^(\s*Add )(!\S+)/, (_, prefix, path)=>prefix + (0, external_node_util_namespaceObject.styleText)([
|
|
734
|
+
'bold',
|
|
735
|
+
'cyan'
|
|
736
|
+
], path)))
|
|
737
|
+
].join('\n'));
|
|
738
|
+
if (sections.length) console.log(sections.join('\n\n'));
|
|
752
739
|
}
|
|
753
740
|
};
|
|
754
741
|
const initializeUseCase = async ()=>{
|
|
@@ -2388,13 +2375,15 @@ export const wire${naming.ClassName}UseCase = wireClass(
|
|
|
2388
2375
|
const splitSegments = (rawSource)=>rawSource.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment);
|
|
2389
2376
|
class NestedName {
|
|
2390
2377
|
folders;
|
|
2378
|
+
folderName;
|
|
2391
2379
|
fileName;
|
|
2392
2380
|
ClassName;
|
|
2393
2381
|
classNameSegments;
|
|
2394
2382
|
constructor(rawSource){
|
|
2395
2383
|
const segments = splitSegments(rawSource);
|
|
2396
2384
|
this.folders = segments.slice(0, -1);
|
|
2397
|
-
this.
|
|
2385
|
+
this.folderName = new UnknownFormatNaming(segments.at(-1) ?? '').fileName;
|
|
2386
|
+
this.fileName = segments.map((segment)=>new UnknownFormatNaming(segment).fileName).join('-');
|
|
2398
2387
|
this.classNameSegments = segments.map((segment)=>new UnknownFormatNaming(segment).ClassName);
|
|
2399
2388
|
this.ClassName = this.classNameSegments.join('');
|
|
2400
2389
|
}
|
|
@@ -2488,11 +2477,11 @@ const scaffoldReactWidget = async (presentationReactFolder)=>{
|
|
|
2488
2477
|
],
|
|
2489
2478
|
message: 'Type: '
|
|
2490
2479
|
});
|
|
2491
|
-
const { folders, ClassName, fileName, classNameSegments } = new NestedName(widgetName);
|
|
2480
|
+
const { folders, folderName, ClassName, fileName, classNameSegments } = new NestedName(widgetName);
|
|
2492
2481
|
const folder = presentationReactFolder.subitem([
|
|
2493
2482
|
'widgets',
|
|
2494
2483
|
...folders,
|
|
2495
|
-
|
|
2484
|
+
folderName
|
|
2496
2485
|
]);
|
|
2497
2486
|
const storyTitle = [
|
|
2498
2487
|
'Widgets',
|
package/dist/index.js
CHANGED
|
@@ -190,11 +190,8 @@ const missingDomainFirstPackages = ()=>{
|
|
|
190
190
|
...new Set(packages)
|
|
191
191
|
].filter((name)=>!Object.hasOwn(dependencies, name));
|
|
192
192
|
return missing.length ? [
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
] : [
|
|
196
|
-
'All configured domain-first packages are already declared in package.json.'
|
|
197
|
-
];
|
|
193
|
+
`npm i ${missing.join(' ')}`
|
|
194
|
+
] : [];
|
|
198
195
|
};
|
|
199
196
|
const addPackageScripts = async (file, additions)=>{
|
|
200
197
|
const original = file.data;
|
|
@@ -230,6 +227,7 @@ const addPackageScripts = async (file, additions)=>{
|
|
|
230
227
|
}
|
|
231
228
|
return selected;
|
|
232
229
|
};
|
|
230
|
+
const describeScripts = (selected, descriptions)=>Object.entries(descriptions).filter(([name])=>selected[name]).map(([name, description])=>`npm run ${selected[name]} — ${description}`);
|
|
233
231
|
const addGitignoreEntry = (root, entry)=>{
|
|
234
232
|
const gitignore = new File(node_path.join(root, '.gitignore'));
|
|
235
233
|
const ignored = gitignore.exists ? gitignore.data : '';
|
|
@@ -342,19 +340,13 @@ const addPlaywright = async ()=>{
|
|
|
342
340
|
}
|
|
343
341
|
for (const entry of gitignoreEntries)addGitignoreEntry(root, entry);
|
|
344
342
|
return [
|
|
345
|
-
'Playwright configuration saved.',
|
|
346
|
-
'Next steps (run from the project package directory):',
|
|
347
343
|
...dependencies['@playwright/test'] ? [] : [
|
|
348
|
-
'
|
|
349
|
-
],
|
|
350
|
-
' npx playwright install --with-deps',
|
|
351
|
-
' Existing dependency versions were kept.',
|
|
352
|
-
...manifest.scripts?.dev ? [] : [
|
|
353
|
-
' Add a "dev" script: Playwright starts it as the web server.'
|
|
344
|
+
'npm install --save-dev @playwright/test'
|
|
354
345
|
],
|
|
355
|
-
'
|
|
356
|
-
|
|
357
|
-
|
|
346
|
+
'npx playwright install --with-deps',
|
|
347
|
+
...describeScripts(selected, {
|
|
348
|
+
'test:e2e': 'start the dev server and run end-to-end specs from specs/e2e'
|
|
349
|
+
})
|
|
358
350
|
];
|
|
359
351
|
};
|
|
360
352
|
const runtimePackages = [
|
|
@@ -463,24 +455,19 @@ const addPrisma = async ()=>{
|
|
|
463
455
|
const install = (packages, dev)=>{
|
|
464
456
|
const missing = packages.filter((name)=>!dependencies[name]);
|
|
465
457
|
return missing.length ? [
|
|
466
|
-
`
|
|
458
|
+
`npm install${dev ? ' --save-dev' : ''} ${missing.join(' ')}`
|
|
467
459
|
] : [];
|
|
468
460
|
};
|
|
469
|
-
const scriptCommand = (name)=>selected[name] ? `npm run ${selected[name]}` : prismaScripts(config.rootFolder)[name];
|
|
470
461
|
const relativeFolder = node_path.relative(root, prismaFolder).split(node_path.sep).join('/');
|
|
471
462
|
return [
|
|
472
|
-
'Prisma 8 configuration saved (PostgreSQL, RC preset).',
|
|
473
|
-
'Next steps (run from the project package directory):',
|
|
474
463
|
...install(runtimePackages, false),
|
|
475
464
|
...install(developmentPackages, true),
|
|
476
|
-
`
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
` Plan migrations: ${scriptCommand('prisma:migration:plan')}`,
|
|
483
|
-
` Review the generated migrations, then apply: ${scriptCommand('prisma:migration:apply')}`
|
|
465
|
+
`Add !${relativeFolder} in your linter, to ignore prisma files.`,
|
|
466
|
+
...describeScripts(selected, {
|
|
467
|
+
'prisma:emit': 'emit contract.json and contract.d.ts from contract.prisma',
|
|
468
|
+
'prisma:migration:plan': 'emit the contract and plan a migration',
|
|
469
|
+
'prisma:migration:apply': 'apply planned migrations to the database in DATABASE_URL'
|
|
470
|
+
})
|
|
484
471
|
];
|
|
485
472
|
};
|
|
486
473
|
const storybookFiles = (relativeProjectRoot)=>({
|
|
@@ -581,23 +568,16 @@ const addStorybook = async ()=>{
|
|
|
581
568
|
'react-dom'
|
|
582
569
|
].filter((name)=>!dependencies[name]);
|
|
583
570
|
return [
|
|
584
|
-
'Storybook configuration saved (React + Vite).',
|
|
585
|
-
'Next steps (run from the project package directory):',
|
|
586
571
|
...missing.length ? [
|
|
587
|
-
`
|
|
572
|
+
`npm install --save-dev ${missing.join(' ')}`
|
|
588
573
|
] : [],
|
|
589
574
|
...missingReact.length ? [
|
|
590
|
-
`
|
|
575
|
+
`npm install ${missingReact.join(' ')}`
|
|
591
576
|
] : [],
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
` npm run ${selected.storybook}`
|
|
597
|
-
] : [],
|
|
598
|
-
...selected['build-storybook'] ? [
|
|
599
|
-
` npm run ${selected['build-storybook']}`
|
|
600
|
-
] : []
|
|
577
|
+
...describeScripts(selected, {
|
|
578
|
+
storybook: 'start Storybook on http://localhost:6006',
|
|
579
|
+
'build-storybook': `build static Storybook into ${buildFolder}`
|
|
580
|
+
})
|
|
601
581
|
];
|
|
602
582
|
};
|
|
603
583
|
const vitestScripts = {
|
|
@@ -666,18 +646,13 @@ const addVitest = async ()=>{
|
|
|
666
646
|
'@vitest/coverage-v8'
|
|
667
647
|
].filter((name)=>!dependencies[name]);
|
|
668
648
|
return [
|
|
669
|
-
'Vitest configuration saved.',
|
|
670
|
-
'Next steps (run from the project package directory):',
|
|
671
649
|
...missing.length ? [
|
|
672
|
-
`
|
|
673
|
-
] : [],
|
|
674
|
-
' Existing dependency versions were kept; resolve.tsconfigPaths requires Vite 8+.',
|
|
675
|
-
...selected.test ? [
|
|
676
|
-
` npm run ${selected.test}`
|
|
650
|
+
`npm install --save-dev ${missing.join(' ')}`
|
|
677
651
|
] : [],
|
|
678
|
-
...selected
|
|
679
|
-
|
|
680
|
-
|
|
652
|
+
...describeScripts(selected, {
|
|
653
|
+
test: 'run unit tests',
|
|
654
|
+
'test:coverage': 'run unit tests with a V8 coverage report in coverage/'
|
|
655
|
+
})
|
|
681
656
|
];
|
|
682
657
|
};
|
|
683
658
|
const integrations = [
|
|
@@ -712,13 +687,25 @@ const addIntegration = async ()=>{
|
|
|
712
687
|
});
|
|
713
688
|
const nextSteps = await integrations[index].run();
|
|
714
689
|
if (await savePendingChanges()) {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
690
|
+
const isCommand = (line)=>/^\s*(?:npm (?:i|install)|npx playwright install)\b/.test(line);
|
|
691
|
+
const commands = nextSteps.filter(isCommand);
|
|
692
|
+
const notes = nextSteps.filter((line)=>!isCommand(line));
|
|
693
|
+
const sections = [];
|
|
694
|
+
if (commands.length) sections.push([
|
|
695
|
+
'Run these commands to install the required dependencies:',
|
|
696
|
+
...commands.map((line)=>styleText([
|
|
719
697
|
'bold',
|
|
720
698
|
'cyan'
|
|
721
|
-
],
|
|
699
|
+
], line))
|
|
700
|
+
].join('\n'));
|
|
701
|
+
if (notes.length) sections.push([
|
|
702
|
+
'Additional information:',
|
|
703
|
+
...notes.map((line)=>line.replace(/^(\s*Add )(!\S+)/, (_, prefix, path)=>prefix + styleText([
|
|
704
|
+
'bold',
|
|
705
|
+
'cyan'
|
|
706
|
+
], path)))
|
|
707
|
+
].join('\n'));
|
|
708
|
+
if (sections.length) console.log(sections.join('\n\n'));
|
|
722
709
|
}
|
|
723
710
|
};
|
|
724
711
|
const initializeUseCase = async ()=>{
|
|
@@ -2358,13 +2345,15 @@ export const wire${naming.ClassName}UseCase = wireClass(
|
|
|
2358
2345
|
const splitSegments = (rawSource)=>rawSource.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment);
|
|
2359
2346
|
class NestedName {
|
|
2360
2347
|
folders;
|
|
2348
|
+
folderName;
|
|
2361
2349
|
fileName;
|
|
2362
2350
|
ClassName;
|
|
2363
2351
|
classNameSegments;
|
|
2364
2352
|
constructor(rawSource){
|
|
2365
2353
|
const segments = splitSegments(rawSource);
|
|
2366
2354
|
this.folders = segments.slice(0, -1);
|
|
2367
|
-
this.
|
|
2355
|
+
this.folderName = new UnknownFormatNaming(segments.at(-1) ?? '').fileName;
|
|
2356
|
+
this.fileName = segments.map((segment)=>new UnknownFormatNaming(segment).fileName).join('-');
|
|
2368
2357
|
this.classNameSegments = segments.map((segment)=>new UnknownFormatNaming(segment).ClassName);
|
|
2369
2358
|
this.ClassName = this.classNameSegments.join('');
|
|
2370
2359
|
}
|
|
@@ -2458,11 +2447,11 @@ const scaffoldReactWidget = async (presentationReactFolder)=>{
|
|
|
2458
2447
|
],
|
|
2459
2448
|
message: 'Type: '
|
|
2460
2449
|
});
|
|
2461
|
-
const { folders, ClassName, fileName, classNameSegments } = new NestedName(widgetName);
|
|
2450
|
+
const { folders, folderName, ClassName, fileName, classNameSegments } = new NestedName(widgetName);
|
|
2462
2451
|
const folder = presentationReactFolder.subitem([
|
|
2463
2452
|
'widgets',
|
|
2464
2453
|
...folders,
|
|
2465
|
-
|
|
2454
|
+
folderName
|
|
2466
2455
|
]);
|
|
2467
2456
|
const storyTitle = [
|
|
2468
2457
|
'Widgets',
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { File } from '../file-system';
|
|
2
2
|
export declare const addPackageScripts: (file: File, additions: Record<string, string>) => Promise<Record<string, string>>;
|
|
3
|
+
export declare const describeScripts: (selected: Record<string, string>, descriptions: Record<string, string>) => string[];
|
package/dist/nested-name.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A name with optional folders before it, e.g. `admin/panel/users`.
|
|
3
|
-
* The last segment names the
|
|
4
|
-
* (`AdminPanelUsers`), so equal names
|
|
3
|
+
* The last segment names the folder; the whole path names the files
|
|
4
|
+
* (`admin-panel-users`) and the code (`AdminPanelUsers`), so equal names
|
|
5
|
+
* in different folders don't clash.
|
|
5
6
|
*/
|
|
6
7
|
export declare class NestedName {
|
|
7
8
|
readonly folders: string[];
|
|
9
|
+
readonly folderName: string;
|
|
8
10
|
readonly fileName: string;
|
|
9
11
|
readonly ClassName: string;
|
|
10
12
|
/**
|