@domain-first/project-structure 5.1.2 → 7.0.0

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.
Files changed (49) hide show
  1. package/README.md +18 -21
  2. package/dist/201.js +46 -35
  3. package/dist/287.js +3290 -0
  4. package/dist/config-file.d.ts +2 -2
  5. package/dist/dependency-rules.d.ts +1 -1
  6. package/dist/file-system.d.ts +5 -0
  7. package/dist/in-memory-db.d.ts +5 -0
  8. package/dist/index.cjs +195 -2156
  9. package/dist/index.js +9 -3169
  10. package/dist/init.cjs +868 -0
  11. package/dist/init.d.ts +2 -0
  12. package/dist/init.js +36 -0
  13. package/dist/integration.cjs +2063 -0
  14. package/dist/integration.d.ts +2 -0
  15. package/dist/integration.js +31 -0
  16. package/dist/integrations/in-memory-db.d.ts +6 -0
  17. package/dist/integrations/index.d.ts +2 -0
  18. package/dist/integrations/missing-domain-first-packages.d.ts +8 -0
  19. package/dist/integrations/orval.d.ts +7 -4
  20. package/dist/integrations/rest-endpoint-generator.d.ts +18 -0
  21. package/dist/integrations/rest-endpoint-generator.spec.d.ts +1 -0
  22. package/dist/lint.cjs +8 -8
  23. package/dist/lint.js +7 -7
  24. package/dist/print-next-steps.d.ts +9 -2
  25. package/dist/react.cjs +915 -0
  26. package/dist/react.d.ts +2 -0
  27. package/dist/react.js +73 -0
  28. package/dist/use-cases/add-integration-order.spec.d.ts +1 -0
  29. package/dist/use-cases/rest-endpoint-generator.d.ts +1 -1
  30. package/package.json +5 -2
  31. package/skills/df-ps-implement/SKILL.md +12 -57
  32. package/skills/df-ps-plan-feature/SKILL.md +7 -7
  33. package/skills/df-ps-project-scripts/SKILL.md +1 -1
  34. package/skills/df-ps-react/SKILL.md +82 -0
  35. package/skills/df-ps-react/references/generators.md +80 -0
  36. package/skills/df-ps-scaffold/SKILL.md +46 -28
  37. package/skills/df-ps-scaffold/references/choosing-components.md +7 -28
  38. package/skills/df-ps-scaffold/references/generators.md +6 -179
  39. package/skills/df-ps-scaffold/references/units/aggregate.md +47 -0
  40. package/skills/df-ps-scaffold/references/units/bounded-context.md +13 -0
  41. package/skills/df-ps-scaffold/references/units/command-query.md +32 -0
  42. package/skills/df-ps-scaffold/references/units/endpoint.md +28 -0
  43. package/skills/df-ps-scaffold/references/units/entity-value-object.md +27 -0
  44. package/skills/df-ps-scaffold/references/units/errors.md +26 -0
  45. package/skills/df-ps-scaffold/references/units/port.md +23 -0
  46. package/skills/df-ps-scaffold/references/units/services.md +28 -0
  47. package/skills/df-ps-scaffold/references/units/use-case.md +25 -0
  48. package/skills/df-ps-scaffold/references/units/wire-dependency.md +15 -0
  49. package/skills/df-ps-scaffold/scripts/drive.mjs +12 -4
package/dist/index.cjs CHANGED
@@ -130,7 +130,7 @@ const pendingDeletions = new Map();
130
130
  const filesToOverwrite = ()=>[
131
131
  ...pendingFiles
132
132
  ].filter(([filePath, { replacesFile }])=>replacesFile && external_node_fs_default().existsSync(filePath)).map(([filePath])=>filePath);
133
- const discardPendingChanges = ()=>{
133
+ const file_system_discardPendingChanges = ()=>{
134
134
  pendingFolders.clear();
135
135
  pendingFiles.clear();
136
136
  pendingMoves.clear();
@@ -164,7 +164,7 @@ const writePendingChanges = ()=>{
164
164
  });
165
165
  for (const [filePath, stopAt] of pendingDeletions)removeEmptyFolders(external_node_path_default().dirname(filePath), stopAt);
166
166
  for (const { sourcePath, stopAt } of pendingMoves.values())removeEmptyFolders(external_node_path_default().dirname(sourcePath), stopAt);
167
- discardPendingChanges();
167
+ file_system_discardPendingChanges();
168
168
  };
169
169
  class FileSystemItem {
170
170
  path;
@@ -176,7 +176,7 @@ class FileSystemItem {
176
176
  return external_node_fs_default().existsSync(this.path);
177
177
  }
178
178
  }
179
- class Folder extends FileSystemItem {
179
+ class file_system_Folder extends FileSystemItem {
180
180
  createIfNotExisted = ()=>{
181
181
  pendingFolders.add(this.path);
182
182
  };
@@ -198,7 +198,7 @@ class Folder extends FileSystemItem {
198
198
  }
199
199
  createFile = (name, content)=>{
200
200
  this.createIfNotExisted();
201
- const file = new File(this.path).subitem([
201
+ const file = new file_system_File(this.path).subitem([
202
202
  name
203
203
  ]);
204
204
  file.data = content;
@@ -206,13 +206,13 @@ class Folder extends FileSystemItem {
206
206
  };
207
207
  file = (name)=>{
208
208
  this.createIfNotExisted();
209
- const file = new File(this.path).subitem([
209
+ const file = new file_system_File(this.path).subitem([
210
210
  name
211
211
  ]);
212
212
  return file;
213
213
  };
214
214
  }
215
- class File extends FileSystemItem {
215
+ class file_system_File extends FileSystemItem {
216
216
  get exists() {
217
217
  return pendingFiles.has(this.path) || pendingMoves.has(this.path) || external_node_fs_default().existsSync(this.path) && !pendingDeletions.has(this.path);
218
218
  }
@@ -258,7 +258,7 @@ class File extends FileSystemItem {
258
258
  if (!alreadyAdded) this.addLine(newLine, separator);
259
259
  };
260
260
  }
261
- class ProjectRoot {
261
+ class project_root_ProjectRoot {
262
262
  path;
263
263
  constructor(){
264
264
  let dir = process.cwd();
@@ -274,7 +274,7 @@ class ProjectRoot {
274
274
  }
275
275
  const lintChecks = [
276
276
  'context-isolation',
277
- 'shared-layer',
277
+ 'shared-kernel',
278
278
  'layers',
279
279
  'dependencies',
280
280
  'react',
@@ -300,55 +300,33 @@ const configSchema = external_zod_default().object({
300
300
  lint: external_zod_default().partialRecord(external_zod_default()["enum"](lintChecks), external_zod_default().boolean()).optional()
301
301
  }).optional()
302
302
  });
303
- class ConfigFile {
303
+ class config_file_ConfigFile {
304
304
  data;
305
305
  constructor(){
306
- const filePath = ConfigFile.path;
307
- const file = new File(filePath);
306
+ const filePath = config_file_ConfigFile.path;
307
+ const file = new file_system_File(filePath);
308
308
  const configObject = JSON.parse(file.data);
309
309
  this.data = configSchema.parse(configObject);
310
310
  }
311
311
  static get Instance() {
312
- return new ConfigFile();
312
+ return new config_file_ConfigFile();
313
313
  }
314
314
  static get path() {
315
- const { path: root } = new ProjectRoot();
315
+ const { path: root } = new project_root_ProjectRoot();
316
316
  return external_node_path_default().resolve(root, configFileName);
317
317
  }
318
318
  static get exists() {
319
- return new File(ConfigFile.path).exists;
319
+ return new file_system_File(config_file_ConfigFile.path).exists;
320
320
  }
321
321
  static write = (config)=>{
322
- new File(ConfigFile.path).data = JSON.stringify(config, null, '\t');
322
+ new file_system_File(config_file_ConfigFile.path).data = JSON.stringify(config, null, '\t');
323
323
  };
324
324
  }
325
- const configuredDependencyRules = ()=>resolveDependencyRules(ConfigFile.exists ? ConfigFile.Instance.data.rules?.dependencies : void 0);
326
- const external_node_util_namespaceObject = require("node:util");
327
- const printNextSteps = (nextSteps)=>{
328
- const isCommand = (line)=>/^\s*(?:npm (?:i|install)|npx playwright install)\b/.test(line);
329
- const commands = nextSteps.filter(isCommand);
330
- const notes = nextSteps.filter((line)=>!isCommand(line));
331
- const sections = [];
332
- if (commands.length) sections.push([
333
- 'Run these commands to install the required dependencies:',
334
- ...commands.map((line)=>(0, external_node_util_namespaceObject.styleText)([
335
- 'bold',
336
- 'cyan'
337
- ], line))
338
- ].join('\n'));
339
- if (notes.length) sections.push([
340
- 'Additional information:',
341
- ...notes.map((line)=>line.replace(/^(\s*Add )(!\S+)/, (_, prefix, path)=>prefix + (0, external_node_util_namespaceObject.styleText)([
342
- 'bold',
343
- 'cyan'
344
- ], path)))
345
- ].join('\n'));
346
- if (sections.length) console.log(sections.join('\n\n'));
347
- };
348
- const savePendingChanges = async ()=>{
325
+ const configuredDependencyRules = ()=>resolveDependencyRules(config_file_ConfigFile.exists ? config_file_ConfigFile.Instance.data.rules?.dependencies : void 0);
326
+ const save_pending_changes_savePendingChanges = async ()=>{
349
327
  const overwrittenFiles = filesToOverwrite();
350
328
  if (overwrittenFiles.length) {
351
- const root = new ProjectRoot().path;
329
+ const root = new project_root_ProjectRoot().path;
352
330
  console.log('These files already exist and will be overwritten:');
353
331
  for (const filePath of overwrittenFiles)console.log(` ${external_node_path_default().relative(root, filePath)}`);
354
332
  const overwrite = await (0, prompts_namespaceObject.confirm)({
@@ -356,7 +334,7 @@ const savePendingChanges = async ()=>{
356
334
  default: false
357
335
  });
358
336
  if (!overwrite) {
359
- discardPendingChanges();
337
+ file_system_discardPendingChanges();
360
338
  console.log('Cancelled: nothing was written.');
361
339
  return false;
362
340
  }
@@ -364,56 +342,7 @@ const savePendingChanges = async ()=>{
364
342
  writePendingChanges();
365
343
  return true;
366
344
  };
367
- const missingDomainFirstPackages = ()=>{
368
- const packages = ConfigFile.Instance.data.domainFirstPackages;
369
- const manifest = JSON.parse(new File(external_node_path_default().join(new ProjectRoot().path, 'package.json')).data);
370
- const dependencies = {
371
- ...manifest.dependencies,
372
- ...manifest.devDependencies,
373
- ...manifest.optionalDependencies
374
- };
375
- const missing = [
376
- ...new Set(packages)
377
- ].filter((name)=>!Object.hasOwn(dependencies, name));
378
- return missing.length ? [
379
- `npm i ${missing.join(' ')}`
380
- ] : [];
381
- };
382
- const external_node_module_namespaceObject = require("node:module");
383
- const stripJsonComments = (source)=>source.replace(/("(?:\\.|[^"\\])*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (_, text)=>text ? text : '').replace(/,(\s*[}\]])/g, '$1');
384
- const resolveExtends = (fromFile, target)=>{
385
- if (target.startsWith('.') || external_node_path_default().isAbsolute(target)) {
386
- const resolved = external_node_path_default().resolve(external_node_path_default().dirname(fromFile), target);
387
- return resolved.endsWith('.json') ? resolved : `${resolved}.json`;
388
- }
389
- const require1 = (0, external_node_module_namespaceObject.createRequire)(fromFile);
390
- for (const candidate of [
391
- target,
392
- `${target}/tsconfig.json`
393
- ])try {
394
- return require1.resolve(candidate);
395
- } catch {}
396
- };
397
- const compilerOption = (configFile, name, seen = new Set())=>{
398
- if (seen.has(configFile) || !external_node_fs_default().existsSync(configFile)) return null;
399
- seen.add(configFile);
400
- let config;
401
- try {
402
- config = JSON.parse(stripJsonComments(external_node_fs_default().readFileSync(configFile, 'utf8')));
403
- } catch {
404
- return null;
405
- }
406
- if (config.compilerOptions && name in config.compilerOptions) return config.compilerOptions[name];
407
- const parents = [
408
- config.extends ?? []
409
- ].flat().reverse();
410
- for (const parent of parents){
411
- const parentFile = resolveExtends(configFile, parent);
412
- const value = parentFile ? compilerOption(parentFile, name, seen) : null;
413
- if (void 0 !== value) return value;
414
- }
415
- };
416
- class UnknownFormatNaming {
345
+ class unknown_format_naming_UnknownFormatNaming {
417
346
  rawSource;
418
347
  camelCase;
419
348
  PascalCase;
@@ -441,1171 +370,6 @@ class UnknownFormatNaming {
441
370
  return this.fileName.replaceAll('-', ' ');
442
371
  }
443
372
  }
444
- const splitSegments = (rawSource)=>rawSource.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment);
445
- class NestedName {
446
- folders;
447
- folderName;
448
- fileName;
449
- ClassName;
450
- classNameSegments;
451
- constructor(rawSource){
452
- const segments = splitSegments(rawSource);
453
- this.folders = segments.slice(0, -1);
454
- this.folderName = new UnknownFormatNaming(segments.at(-1) ?? '').fileName;
455
- this.fileName = segments.map((segment)=>new UnknownFormatNaming(segment).fileName).join('-');
456
- this.classNameSegments = segments.map((segment)=>new UnknownFormatNaming(segment).ClassName);
457
- this.ClassName = this.classNameSegments.join('');
458
- }
459
- static validate = (rawSource)=>{
460
- const segments = splitSegments(rawSource);
461
- if (!segments.length) return 'Name is required';
462
- if (segments.some((segment)=>'.' === segment || '..' === segment)) return 'Use a path relative to the folder, without "." or ".."';
463
- return true;
464
- };
465
- }
466
- const reactPageContent = (ClassName, { imports = [], body = '<></>' } = {})=>`
467
- ${[
468
- ...imports,
469
- "import { type FC } from 'react'"
470
- ].join('\n')}
471
-
472
- export type ${ClassName}PageProps = {}
473
-
474
- export const ${ClassName}Page: FC<${ClassName}PageProps> = (props) => {
475
- return ${body}
476
- }
477
- `.trim();
478
- const scaffoldReactPage = async (presentationReactFolder)=>{
479
- const name = await (0, prompts_namespaceObject.input)({
480
- message: 'Provide name (folders split by "/"):',
481
- validate: NestedName.validate
482
- });
483
- const { folders, ClassName, fileName } = new NestedName(name);
484
- presentationReactFolder.subitem([
485
- 'pages',
486
- ...folders
487
- ]).createFile(`${fileName}-page.tsx`, reactPageContent(ClassName));
488
- };
489
- const openapiExtractorPath = "scripts/extract-open-api-data-from-endpoint.ts";
490
- const rootFolderSegments = (rootFolder)=>rootFolder.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment && '.' !== segment).map((segment)=>`'${segment}',\n `).join('');
491
- const openapiExtractor = (rootFolder)=>`import path from 'node:path';
492
- import {
493
- type DocNode,
494
- DocPlainText,
495
- TSDocConfiguration,
496
- TSDocParser,
497
- TSDocTagDefinition,
498
- TSDocTagSyntaxKind
499
- } from '@microsoft/tsdoc';
500
- import { Node, Project, type SourceFile, SyntaxKind } from 'ts-morph';
501
-
502
- type BlockTag = \`@\${string}\`;
503
-
504
- type OpenApiDataTags = {
505
- /** Omit to take the summary from the comment text before the first tag. */
506
- summary?: BlockTag;
507
- description?: BlockTag;
508
- };
509
-
510
- type OpenApiData = Partial<{
511
- summary: string;
512
- description: string;
513
- operationId: string;
514
- }>;
515
-
516
- const project = new Project({
517
- tsConfigFilePath: 'tsconfig.json'
518
- });
519
-
520
- const getText = (node: DocNode): string =>
521
- node
522
- .getChildNodes()
523
- .map((child) => {
524
- if (child instanceof DocPlainText) {
525
- return child.text;
526
- }
527
-
528
- return getText(child);
529
- })
530
- .join('');
531
-
532
- const getRawCommentText = (comment: string): string =>
533
- comment
534
- .replace(/^\\/\\*\\*/, '')
535
- .replace(/\\*\\/$/, '')
536
- .split(/\\r?\\n/)
537
- .map((line) => line.replace(/^\\s*\\*\\s?/, ''))
538
- .join('\\n');
539
-
540
- // TSDoc treats an unknown tag as summary content, so every block tag of the
541
- // comment has to be registered for the summary section to end before it.
542
- const parseSummary = (comment: string): string | undefined => {
543
- const configuration = new TSDocConfiguration();
544
- const tagNames = getRawCommentText(comment).matchAll(/(?:^|\\n)\\s*(@\\w+)/g);
545
-
546
- for (const [, tagName] of tagNames) {
547
- if (!configuration.tryGetTagDefinition(tagName)) {
548
- configuration.addTagDefinition(
549
- new TSDocTagDefinition({
550
- tagName,
551
- syntaxKind: TSDocTagSyntaxKind.BlockTag
552
- })
553
- );
554
- }
555
- }
556
-
557
- const { docComment } = new TSDocParser(configuration).parseString(comment);
558
-
559
- return getText(docComment.summarySection).trim() || undefined;
560
- };
561
-
562
- // Parsed by hand rather than through TSDoc, which drops the line breaks.
563
- const getTagText = (comment: string, tag: BlockTag): string | undefined => {
564
- const tagMatch = getRawCommentText(comment).match(
565
- new RegExp(
566
- \`(?:^|\\\\n)\\\\s*\${tag}(?:[ \\\\t]*\\\\n|[ \\\\t]+)([\\\\s\\\\S]*?)(?=\\\\n\\\\s*@\\\\w+|\\\\s*$)\`
567
- )
568
- );
569
-
570
- return tagMatch?.[1].trim() || undefined;
571
- };
572
-
573
- // Endpoints pass their logic as the generator's first argument
574
- // (\`this.endpointGenerator(this.handler.handle, ...)\`), while other injected
575
- // queries only serve as helpers, e.g. guest checks.
576
- const findHandlerClass = (endpointFile: SourceFile) =>
577
- endpointFile
578
- .getDescendantsOfKind(SyntaxKind.CallExpression)
579
- .map((call) => call.getArguments()[0])
580
- .filter(Node.isPropertyAccessExpression)
581
- .find((argument) => argument.getName() === 'handle')
582
- ?.getExpression()
583
- .getType()
584
- .getSymbol()
585
- ?.getDeclarations()
586
- .find(Node.isClassDeclaration);
587
-
588
- // Path parameters (\`:id\`) can't be part of file and folder names
589
- // everywhere (Windows), so endpoints name them \`_id_\` there.
590
- const pathParameterAsName = (segment: string) =>
591
- segment.startsWith(':') ? \`_\${segment.slice(1)}_\` : segment;
592
-
593
- export const createOpenApiDataFromEndpointLogicExtractor = ({
594
- summary: summaryTag,
595
- description: descriptionTag = '@description'
596
- }: OpenApiDataTags = {}) => {
597
- return (routeMetadata: {
598
- method: string;
599
- path: readonly string[];
600
- }): OpenApiData | undefined => {
601
- try {
602
- const [currentBoundedContext, controller, ...relativePath] =
603
- routeMetadata.path;
604
-
605
- if (!currentBoundedContext || !controller) {
606
- return undefined;
607
- }
608
-
609
- const endpointFile = project.getSourceFile(
610
- path.join(
611
- ${rootFolderSegments(rootFolder)}'bounded-contexts',
612
- currentBoundedContext,
613
- 'presentation',
614
- 'rest',
615
- controller,
616
- ...relativePath.map(pathParameterAsName),
617
- \`\${routeMetadata.method.toUpperCase()}.ts\`
618
- )
619
- );
620
-
621
- if (!endpointFile) {
622
- return undefined;
623
- }
624
-
625
- const declaration = findHandlerClass(endpointFile);
626
- const operationId = declaration?.getName();
627
- const comment = declaration?.getJsDocs().at(-1)?.getText();
628
-
629
- if (!comment) {
630
- return { operationId };
631
- }
632
-
633
- return {
634
- summary: summaryTag
635
- ? getTagText(comment, summaryTag)
636
- : parseSummary(comment),
637
- description: getTagText(comment, descriptionTag),
638
- operationId
639
- };
640
- } catch (e: unknown) {
641
- console.error(e);
642
- return undefined;
643
- }
644
- };
645
- };
646
- `;
647
- const addPackageScripts = async (file, additions)=>{
648
- const original = file.data;
649
- const manifest = JSON.parse(original);
650
- const scripts = {
651
- ...manifest.scripts
652
- };
653
- const selected = {};
654
- for (const [name, command] of Object.entries(additions)){
655
- let target = name;
656
- if (Object.hasOwn(scripts, name) && scripts[name] !== command) {
657
- const action = await (0, prompts_namespaceObject.select)({
658
- message: `Script "${name}" already exists: ${scripts[name]}`,
659
- choices: [
660
- 'Keep existing',
661
- 'Replace',
662
- 'Use another name'
663
- ]
664
- });
665
- if ('Keep existing' === action) continue;
666
- if ('Use another name' === action) target = await (0, prompts_namespaceObject.input)({
667
- message: "New script name:",
668
- validate: (value)=>!/^[a-zA-Z0-9:_-]+$/.test(value) || Object.hasOwn(scripts, value) || Object.hasOwn(additions, value) ? "Enter an unused script name (letters, numbers, :, _, -)." : true
669
- });
670
- }
671
- scripts[target] = command;
672
- selected[name] = target;
673
- }
674
- if (JSON.stringify(manifest.scripts) !== JSON.stringify(scripts)) {
675
- manifest.scripts = scripts;
676
- const indent = original.match(/\n([\t ]+)"/)?.[1] ?? ' ';
677
- file.update(`${JSON.stringify(manifest, null, indent)}\n`);
678
- }
679
- return selected;
680
- };
681
- const describeScripts = (selected, descriptions)=>Object.entries(descriptions).filter(([name])=>selected[name]).map(([name, description])=>`npm run ${selected[name]} — ${description}`);
682
- const openapiScriptPath = "scripts/generate-openapi.ts";
683
- const defaultOpenapiPath = (withNext)=>withNext ? 'public/openapi.json' : 'openapi.json';
684
- const extractorPackages = [
685
- 'ts-morph',
686
- '@microsoft/tsdoc'
687
- ];
688
- const swaggerPagePath = (rootFolder)=>external_node_path_default().posix.join(rootFolder.replaceAll('\\', '/'), 'presentation/react/pages/swagger-page.tsx');
689
- const swaggerPage = (rootFolder, outputPath)=>{
690
- const specImport = external_node_path_default().posix.relative(external_node_path_default().posix.dirname(swaggerPagePath(rootFolder)), outputPath);
691
- return reactPageContent('Swagger', {
692
- imports: [
693
- "import 'swagger-ui-react/swagger-ui.css'",
694
- "import SwaggerUI from 'swagger-ui-react'",
695
- `import spec from '${specImport.startsWith('.') ? specImport : `./${specImport}`}' with { type: 'json' }`
696
- ],
697
- body: '<SwaggerUI displayOperationId spec={spec} />'
698
- });
699
- };
700
- const openapiScripts = {
701
- openapi: `tsx --env-file-if-exists=.env ${openapiScriptPath}`
702
- };
703
- const splitPath = (value)=>value.split(/[\\/]/).map((segment)=>segment.trim()).filter((segment)=>!!segment);
704
- const apiTitle = (packageName)=>{
705
- const words = String(packageName ?? '').replace(/^@[^/]*\//, '').split(/[^a-zA-Z0-9]+/).filter((word)=>!!word).map((word)=>word[0].toUpperCase() + word.slice(1));
706
- return [
707
- ...words,
708
- 'API'
709
- ].join(' ');
710
- };
711
- const openapiGenerator = (rootFolder, title, routePrefix, outputPath, withExtractor = false)=>{
712
- const restFolder = external_node_path_default().posix.join(rootFolder.replaceAll('\\', '/'), 'presentation/rest');
713
- const restImport = external_node_path_default().posix.relative(external_node_path_default().posix.dirname(openapiScriptPath), restFolder);
714
- const prefixSegments = splitPath(routePrefix);
715
- const apiRoutePrefix = prefixSegments.length ? `\n apiRoutePrefix: [${prefixSegments.map((segment)=>`'${segment}'`).join(', ')}],` : '';
716
- const extractorImport = `./${external_node_path_default().posix.relative(external_node_path_default().posix.dirname(openapiScriptPath), openapiExtractorPath.replace(/\.ts$/, ''))}`;
717
- const handlers = withExtractor ? `
718
- const extractOpenApiDataFromEndpointLogic =
719
- createOpenApiDataFromEndpointLogicExtractor();
720
-
721
- const handlers = restHandlers.map((x) => ({
722
- ...x,
723
- metadata: {
724
- ...x.metadata,
725
- openApiMetadata: {
726
- ...extractOpenApiDataFromEndpointLogic(x.metadata.route),
727
- ...(x.metadata.openApiMetadata ?? {})
728
- }
729
- }
730
- }));
731
- ` : '';
732
- return `import { generateOpenAPI } from '@domain-first/handlers-rest';
733
- import { restHandlers } from '${restImport.startsWith('.') ? restImport : `./${restImport}`}';${withExtractor ? `\nimport { createOpenApiDataFromEndpointLogicExtractor } from '${extractorImport}';` : ''}
734
- ${handlers}
735
- generateOpenAPI(${withExtractor ? 'handlers' : 'restHandlers'}, {
736
- document: { info: { title: '${title}', version: '1.0.0' } },${apiRoutePrefix}
737
- outputFile: { path: '${outputPath}' }
738
- });
739
- `;
740
- };
741
- const addOpenapi = async ()=>{
742
- const { rootFolder } = ConfigFile.Instance.data;
743
- const root = new ProjectRoot().path;
744
- const manifestFile = new File(external_node_path_default().join(root, 'package.json'));
745
- const manifest = JSON.parse(manifestFile.data);
746
- const dependencies = {
747
- ...manifest.dependencies,
748
- ...manifest.devDependencies
749
- };
750
- const routePrefix = await (0, prompts_namespaceObject.input)({
751
- message: 'Route prefix the REST handlers are served under:',
752
- default: '/api'
753
- });
754
- const outputPath = await (0, prompts_namespaceObject.input)({
755
- message: 'OpenAPI document path:',
756
- default: defaultOpenapiPath(Boolean(dependencies.next)),
757
- validate: (value)=>splitPath(value).length ? true : 'Path is required'
758
- });
759
- const withExtractor = await (0, prompts_namespaceObject.confirm)({
760
- message: "Fill operationId, summary and description from the endpoint logic TSDoc?",
761
- default: true
762
- });
763
- const withSwaggerPage = ConfigFile.Instance.data.useReact && await (0, prompts_namespaceObject.confirm)({
764
- message: 'Add a Swagger UI page?',
765
- default: true
766
- });
767
- const selected = await addPackageScripts(manifestFile, openapiScripts);
768
- if (withExtractor) {
769
- const extractorFile = new File(external_node_path_default().join(root, openapiExtractorPath));
770
- const extractor = openapiExtractor(rootFolder);
771
- if (!extractorFile.exists || extractorFile.data !== extractor) extractorFile.data = extractor;
772
- }
773
- const generatorFile = new File(external_node_path_default().join(root, openapiScriptPath));
774
- const content = openapiGenerator(rootFolder, apiTitle(manifest.name), routePrefix, splitPath(outputPath).join('/'), withExtractor);
775
- if (!generatorFile.exists || generatorFile.data !== content) generatorFile.data = content;
776
- if (withSwaggerPage) {
777
- const pageFile = new File(external_node_path_default().join(root, swaggerPagePath(rootFolder)));
778
- const page = swaggerPage(rootFolder, splitPath(outputPath).join('/'));
779
- if (!pageFile.exists || pageFile.data !== page) pageFile.data = page;
780
- }
781
- const resolveJsonModule = withSwaggerPage ? compilerOption(external_node_path_default().join(root, 'tsconfig.json'), 'resolveJsonModule') : true;
782
- const hasRestHandlers = new File(external_node_path_default().join(root, rootFolder, 'presentation', 'rest', 'index.ts')).exists;
783
- const missingExtractorPackages = withExtractor ? extractorPackages.filter((name)=>!dependencies[name]) : [];
784
- return [
785
- ...dependencies['@domain-first/handlers-rest'] ? [] : [
786
- 'npm install @domain-first/handlers-rest'
787
- ],
788
- ...dependencies.tsx ? [] : [
789
- 'npm install --save-dev tsx'
790
- ],
791
- ...missingExtractorPackages.length ? [
792
- `npm install --save-dev ${missingExtractorPackages.join(' ')}`
793
- ] : [],
794
- ...withSwaggerPage && !dependencies['swagger-ui-react'] ? [
795
- 'npm install swagger-ui-react'
796
- ] : [],
797
- ...withSwaggerPage && !dependencies['@types/swagger-ui-react'] ? [
798
- 'npm install --save-dev @types/swagger-ui-react'
799
- ] : [],
800
- ...true === resolveJsonModule || null === resolveJsonModule ? [] : [
801
- 'set "resolveJsonModule": true in compilerOptions of tsconfig.json — the Swagger UI page imports the OpenAPI document as JSON'
802
- ],
803
- ...describeScripts(selected, {
804
- openapi: `generate the OpenAPI document from restHandlers in ${splitPath(outputPath).join('/')}`
805
- }),
806
- ...withSwaggerPage ? [
807
- `SwaggerPage from ${swaggerPagePath(rootFolder)} shows ${splitPath(outputPath).join('/')} once it is generated — render it on a route of your app`
808
- ] : [],
809
- ...hasRestHandlers ? [] : [
810
- `restHandlers appear in ${external_node_path_default().posix.join(rootFolder, 'presentation/rest/index.ts')} with the first REST endpoint generated with @domain-first/wire`
811
- ]
812
- ];
813
- };
814
- const addGitignoreEntry = (root, entry)=>{
815
- const gitignore = new File(external_node_path_default().join(root, '.gitignore'));
816
- const ignored = gitignore.exists ? gitignore.data : '';
817
- if (ignored.split(/\r?\n/).includes(entry)) return;
818
- const newline = ignored.includes('\r\n') ? '\r\n' : '\n';
819
- gitignore.update(`${ignored}${ignored && !ignored.endsWith('\n') ? newline : ''}${entry}${newline}`);
820
- };
821
- const dataLayerFolder = (rootFolder)=>external_node_path_default().posix.join(rootFolder.replaceAll('\\', '/'), 'presentation/react/data-layer');
822
- const orvalScripts = (rootFolder)=>({
823
- 'client:orval': `orval --config ${JSON.stringify(`${dataLayerFolder(rootFolder)}/orval.config.ts`)}`
824
- });
825
- const orvalConfig = (rootFolder, openapiPath, withNext)=>{
826
- const inputPath = external_node_path_default().posix.relative(dataLayerFolder(rootFolder), openapiPath);
827
- const baseUrl = withNext ? `
828
- baseUrl: {
829
- runtime: 'process.env.NEXT_PUBLIC_API_BASE_URL ?? ""'
830
- },` : '';
831
- return `import { defineConfig } from 'orval';
832
-
833
- export default defineConfig({
834
- api: {
835
- input: '${inputPath.startsWith('.') ? inputPath : `./${inputPath}`}',
836
- output: {
837
- mode: 'tags-split',
838
- target: './orval',
839
- schemas: './orval/model',
840
- client: 'react-query',
841
- httpClient: 'fetch',${baseUrl}
842
- clean: true,
843
- override: {
844
- mutator: {
845
- path: './api-client/mutator.ts',
846
- name: 'customInstance'
847
- },
848
- fetch: {
849
- includeHttpResponseReturnType: false
850
- },
851
- query: {
852
- version: 5
853
- }
854
- }
855
- }
856
- }
857
- });
858
- `;
859
- };
860
- const orvalMutator = `/** Error of the generated hooks, with the parsed response body. */
861
- export class ApiError<Body = unknown> extends Error {
862
- constructor(
863
- public readonly status: number,
864
- public readonly body: Body
865
- ) {
866
- super(\`API error \${status}\`);
867
- this.name = 'ApiError';
868
- }
869
- }
870
-
871
- /** Error type of the generated hooks, typed per endpoint by Orval. */
872
- export type ErrorType<Body> = ApiError<Body>;
873
-
874
- /** Every generated request goes through here: add auth headers, token refresh, logging. */
875
- export const customInstance = async <T>(
876
- url: string,
877
- init?: RequestInit
878
- ): Promise<T> => {
879
- const response = await fetch(url, init);
880
- const text = await response.text();
881
- const body = text ? JSON.parse(text) : undefined;
882
-
883
- if (!response.ok) {
884
- throw new ApiError(response.status, body);
885
- }
886
-
887
- return body as T;
888
- };
889
- `;
890
- const queryProvider = `'use client';
891
-
892
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
893
- import { type FC, type ReactNode, useState } from 'react';
894
-
895
- export const QueryProvider: FC<{ children: ReactNode }> = ({ children }) => {
896
- // One client per browser session; a module-level client would be shared between requests on the server
897
- const [queryClient] = useState(() => new QueryClient());
898
-
899
- return (
900
- <QueryClientProvider client={queryClient}>
901
- {children}
902
- </QueryClientProvider>
903
- );
904
- };
905
- `;
906
- const openapiOutputPath = (root)=>{
907
- const generator = new File(external_node_path_default().join(root, openapiScriptPath));
908
- if (!generator.exists) return;
909
- return generator.data.match(/outputFile:\s*{\s*path:\s*'([^']+)'/)?.[1];
910
- };
911
- const addOrval = async ()=>{
912
- const { rootFolder } = ConfigFile.Instance.data;
913
- const root = new ProjectRoot().path;
914
- const manifestFile = new File(external_node_path_default().join(root, 'package.json'));
915
- const manifest = JSON.parse(manifestFile.data);
916
- const dependencies = {
917
- ...manifest.dependencies,
918
- ...manifest.devDependencies
919
- };
920
- const withNext = Boolean(dependencies.next);
921
- const generatedOpenapiPath = openapiOutputPath(root);
922
- const openapiPath = await (0, prompts_namespaceObject.input)({
923
- message: 'OpenAPI document path:',
924
- default: generatedOpenapiPath ?? defaultOpenapiPath(withNext),
925
- validate: (value)=>value.trim() ? true : 'Path is required'
926
- });
927
- const selected = await addPackageScripts(manifestFile, orvalScripts(rootFolder));
928
- const dataLayer = dataLayerFolder(rootFolder);
929
- const configFile = new File(external_node_path_default().join(root, dataLayer, 'orval.config.ts'));
930
- const content = orvalConfig(rootFolder, external_node_path_default().posix.normalize(openapiPath.trim().replaceAll('\\', '/')), withNext);
931
- if (!configFile.exists || configFile.data !== content) configFile.data = content;
932
- for (const [name, fileContent] of [
933
- [
934
- 'api-client/mutator.ts',
935
- orvalMutator
936
- ],
937
- [
938
- 'query-provider.tsx',
939
- queryProvider
940
- ]
941
- ]){
942
- const file = new File(external_node_path_default().join(root, dataLayer, name));
943
- if (!file.exists) file.data = fileContent;
944
- }
945
- addGitignoreEntry(root, `/${dataLayer}/orval/`);
946
- const missing = (names)=>names.filter((name)=>!dependencies[name]);
947
- const runtime = missing([
948
- '@tanstack/react-query'
949
- ]);
950
- const development = missing([
951
- 'orval'
952
- ]);
953
- return [
954
- ...runtime.length ? [
955
- `npm install ${runtime.join(' ')}`
956
- ] : [],
957
- ...development.length ? [
958
- `npm install --save-dev ${development.join(' ')}`
959
- ] : [],
960
- ...describeScripts(selected, {
961
- 'client:orval': `generate React Query hooks from ${openapiPath.trim()} in ${dataLayer}/orval`
962
- }),
963
- `Wrap your app in QueryProvider from ${dataLayer}/query-provider.tsx`,
964
- ...generatedOpenapiPath ? [] : [
965
- 'Add integration → OpenAPI generates the OpenAPI document the client is built from'
966
- ]
967
- ];
968
- };
969
- const playwrightScripts = {
970
- 'test:e2e': 'playwright test'
971
- };
972
- const playwrightConfig = `import { defineConfig, devices } from '@playwright/test';
973
-
974
- export default defineConfig({
975
- testDir: './specs/e2e',
976
- fullyParallel: true,
977
- forbidOnly: !!process.env.CI,
978
- retries: process.env.CI ? 2 : 0,
979
- workers: process.env.CI ? 1 : undefined,
980
- reporter: 'html',
981
- use: {
982
- baseURL: 'http://localhost:3000',
983
- trace: 'on-first-retry',
984
- screenshot: 'only-on-failure',
985
- video: 'retain-on-failure'
986
- },
987
-
988
- projects: [
989
- {
990
- name: 'chromium',
991
- use: { ...devices['Desktop Chrome'] }
992
- },
993
- {
994
- name: 'firefox',
995
- use: { ...devices['Desktop Firefox'] }
996
- },
997
- {
998
- name: 'webkit',
999
- use: { ...devices['Desktop Safari'] }
1000
- },
1001
- {
1002
- name: 'Mobile Chrome',
1003
- use: { ...devices['Pixel 5'] }
1004
- },
1005
- {
1006
- name: 'Mobile Safari',
1007
- use: { ...devices['iPhone 12'] }
1008
- }
1009
- ],
1010
-
1011
- webServer: {
1012
- // Playwright only stops the dev server on a clean shutdown. If its process dies any other
1013
- // way (SIGHUP, SIGKILL), the dev server lives on in its own process group, so it is killed
1014
- // as soon as Playwright is gone.
1015
- command:
1016
- process.platform === 'win32'
1017
- ? 'npm run dev'
1018
- : \`npm run dev & while kill -0 \${process.pid} 2>/dev/null && kill -0 $! 2>/dev/null; do sleep 1; done; kill 0\`,
1019
- url: 'http://localhost:3000',
1020
- timeout: 120000,
1021
- reuseExistingServer: !process.env.CI
1022
- }
1023
- });
1024
- `;
1025
- const exampleSpec = `import { expect, test } from '@playwright/test';
1026
-
1027
- test.describe('home page', () => {
1028
- test('opens the home page', async ({ page, baseURL }) => {
1029
- await page.goto('/');
1030
- await expect(page).toHaveURL(\`\${baseURL}/\`);
1031
- });
1032
- });
1033
- `;
1034
- const exampleReadme = `# Home page e2e cases
1035
-
1036
- ## User Stories
1037
-
1038
- 1. Guest opens \`/\` and stays on the home page.
1039
- `;
1040
- const gitignoreEntries = [
1041
- '/test-results/',
1042
- '/playwright-report/',
1043
- '/blob-report/',
1044
- '/playwright/.cache/',
1045
- '/playwright/.auth/'
1046
- ];
1047
- const addPlaywright = async ()=>{
1048
- const root = new ProjectRoot().path;
1049
- const manifestFile = new File(external_node_path_default().join(root, 'package.json'));
1050
- const manifest = JSON.parse(manifestFile.data);
1051
- const dependencies = {
1052
- ...manifest.dependencies,
1053
- ...manifest.devDependencies
1054
- };
1055
- const selected = await addPackageScripts(manifestFile, playwrightScripts);
1056
- const configFile = new File(external_node_path_default().join(root, 'playwright.config.ts'));
1057
- if (!configFile.exists || configFile.data !== playwrightConfig) configFile.data = playwrightConfig;
1058
- const exampleFolder = external_node_path_default().join(root, 'specs/e2e/home');
1059
- for (const [name, content] of [
1060
- [
1061
- 'home.e2e.spec.ts',
1062
- exampleSpec
1063
- ],
1064
- [
1065
- 'README.MD',
1066
- exampleReadme
1067
- ]
1068
- ]){
1069
- const file = new File(external_node_path_default().join(exampleFolder, name));
1070
- if (!file.exists) file.data = content;
1071
- }
1072
- for (const entry of gitignoreEntries)addGitignoreEntry(root, entry);
1073
- return [
1074
- ...dependencies['@playwright/test'] ? [] : [
1075
- 'npm install --save-dev @playwright/test'
1076
- ],
1077
- 'npx playwright install --with-deps',
1078
- ...describeScripts(selected, {
1079
- 'test:e2e': 'start the dev server and run end-to-end specs from specs/e2e'
1080
- })
1081
- ];
1082
- };
1083
- const runtimePackages = [
1084
- '@prisma/orm-postgres',
1085
- 'temporal-polyfill',
1086
- 'dotenv'
1087
- ];
1088
- const developmentPackages = [
1089
- 'prisma',
1090
- '@prisma/cli-engine'
1091
- ];
1092
- const prismaScripts = (rootFolder)=>{
1093
- const config = JSON.stringify(external_node_path_default().posix.join(rootFolder.replaceAll('\\', '/'), 'shared/infrastructure/prisma/prisma.config.ts'));
1094
- const emit = `prisma contract emit --config ${config}`;
1095
- return {
1096
- 'prisma:emit': emit,
1097
- 'prisma:migration:plan': `${emit} && prisma migration plan --config ${config}`,
1098
- 'prisma:migration:apply': `prisma db migrate --advance-ref db --config ${config}`
1099
- };
1100
- };
1101
- const prismaConfig = `import 'dotenv/config';
1102
- import { definePrismaConfig } from '@prisma/cli-engine';
1103
- import { defineConfig as ormConfig } from '@prisma/orm-postgres/config';
1104
-
1105
- export default definePrismaConfig({
1106
- orm: ormConfig({
1107
- contract: './contract.prisma',
1108
- migrations: { dir: './migrations' },
1109
- db: {
1110
- connection: process.env.DATABASE_URL
1111
- }
1112
- })
1113
- });
1114
- `;
1115
- const prismaService = `import 'temporal-polyfill/global';
1116
- import postgres from '@prisma/orm-postgres/runtime';
1117
- import type {} from 'temporal-polyfill/types/global';
1118
- import type { Contract } from '../prisma/contract.d';
1119
- import contractJson from '../prisma/contract.json' with { type: 'json' };
1120
-
1121
- type PrismaClient = ReturnType<typeof postgres<Contract>>;
1122
-
1123
- const globalForPrisma = globalThis as typeof globalThis & {
1124
- prismaClient?: PrismaClient;
1125
- };
1126
-
1127
- // Reuse the client across development hot reloads.
1128
- const prismaClient = globalForPrisma.prismaClient ??
1129
- postgres<Contract>({ contractJson, url: process.env.DATABASE_URL });
1130
-
1131
- if (process.env.NODE_ENV !== 'production') {
1132
- globalForPrisma.prismaClient = prismaClient;
1133
- }
1134
-
1135
- export class PrismaInfrastructureService {
1136
- readonly orm = prismaClient.orm.public;
1137
- }
1138
- `;
1139
- const prismaWiring = `import { wireClass } from '@domain-first/wire';
1140
- import { PrismaInfrastructureService } from '../../infrastructure/services/prisma-infrastructure-service';
1141
-
1142
- export const wirePrismaInfrastructureService = wireClass(
1143
- PrismaInfrastructureService,
1144
- []
1145
- );
1146
- `;
1147
- const stageFile = (filePath, content)=>{
1148
- const file = new File(filePath);
1149
- if (!file.exists || file.data !== content) file.data = content;
1150
- };
1151
- const addPrisma = async ()=>{
1152
- const config = ConfigFile.Instance.data;
1153
- const root = new ProjectRoot().path;
1154
- const manifestFile = new File(external_node_path_default().join(root, 'package.json'));
1155
- const manifest = JSON.parse(manifestFile.data);
1156
- const dependencies = {
1157
- ...manifest.dependencies,
1158
- ...manifest.devDependencies
1159
- };
1160
- const shared = external_node_path_default().resolve(root, config.rootFolder, 'shared');
1161
- const prismaFolder = external_node_path_default().join(shared, 'infrastructure/prisma');
1162
- if (dependencies['@prisma/client'] || dependencies.prisma && !/^[~^]?8\./.test(dependencies.prisma) || dependencies['@prisma/orm-mongo'] || dependencies['@prisma/orm-sqlite'] || [
1163
- external_node_path_default().join(root, 'prisma/schema.prisma'),
1164
- external_node_path_default().join(prismaFolder, 'schema.prisma')
1165
- ].some((filePath)=>new File(filePath).exists)) throw new Error('This preset adds Prisma 8 for PostgreSQL. Migrate the existing Prisma setup separately before using it.');
1166
- const withService = await (0, prompts_namespaceObject.confirm)({
1167
- message: 'Create shared Prisma infrastructure service?',
1168
- default: true
1169
- });
1170
- const useByDefault = 'prisma' !== config.defaultPersistenceLayerImplementation && await (0, prompts_namespaceObject.confirm)({
1171
- message: 'Use prisma as the default persistence implementation?',
1172
- default: false
1173
- });
1174
- const selected = await addPackageScripts(manifestFile, prismaScripts(config.rootFolder));
1175
- stageFile(external_node_path_default().join(prismaFolder, 'prisma.config.ts'), prismaConfig);
1176
- const contract = new File(external_node_path_default().join(prismaFolder, 'contract.prisma'));
1177
- if (!contract.exists) contract.data = '// use prisma-8\n\n// Add your application models here before running prisma:emit.\n';
1178
- if (withService) {
1179
- stageFile(external_node_path_default().join(shared, 'infrastructure/services/prisma-infrastructure-service.ts'), prismaService);
1180
- if (config.domainFirstPackages.includes('@domain-first/wire')) stageFile(external_node_path_default().join(shared, 'wiring/infrastructure-services/wire-prisma-infrastructure-service.ts'), prismaWiring);
1181
- }
1182
- if (useByDefault) ConfigFile.write({
1183
- ...config,
1184
- defaultPersistenceLayerImplementation: 'prisma'
1185
- });
1186
- const install = (packages, dev)=>{
1187
- const missing = packages.filter((name)=>!dependencies[name]);
1188
- return missing.length ? [
1189
- `npm install${dev ? ' --save-dev' : ''} ${missing.join(' ')}`
1190
- ] : [];
1191
- };
1192
- const relativeFolder = external_node_path_default().relative(root, prismaFolder).split(external_node_path_default().sep).join('/');
1193
- return [
1194
- ...install(runtimePackages, false),
1195
- ...install(developmentPackages, true),
1196
- `Add !${relativeFolder} in your linter, to ignore prisma files.`,
1197
- ...describeScripts(selected, {
1198
- 'prisma:emit': 'emit contract.json and contract.d.ts from contract.prisma',
1199
- 'prisma:migration:plan': 'emit the contract and plan a migration',
1200
- 'prisma:migration:apply': 'apply planned migrations to the database in DATABASE_URL'
1201
- })
1202
- ];
1203
- };
1204
- const storybookFiles = (relativeProjectRoot)=>({
1205
- 'main.ts': `import { resolve } from 'node:path';
1206
- import react from '@vitejs/plugin-react';
1207
- import type { StorybookConfig } from '@storybook/react-vite';
1208
-
1209
- const projectRoot = resolve(import.meta.dirname, ${JSON.stringify(relativeProjectRoot)});
1210
-
1211
- const config: StorybookConfig = {
1212
- stories: ['../**/*.mdx', '../**/*.stories.@(ts|tsx)'],
1213
- framework: {
1214
- name: '@storybook/react-vite',
1215
- options: {}
1216
- },
1217
- core: {
1218
- disableTelemetry: true
1219
- },
1220
- async viteFinal(viteConfig) {
1221
- const { mergeConfig } = await import('vite');
1222
-
1223
- return mergeConfig(viteConfig, {
1224
- plugins: [react()],
1225
- resolve: {
1226
- alias: {
1227
- '@': projectRoot
1228
- }
1229
- }
1230
- });
1231
- }
1232
- };
1233
-
1234
- export default config;
1235
- `,
1236
- 'preview.ts': `import type { Preview } from '@storybook/react-vite';
1237
-
1238
- const preview: Preview = {
1239
- parameters: {
1240
- controls: {
1241
- matchers: {
1242
- color: /(background|color)$/i,
1243
- date: /Date$/i
1244
- }
1245
- }
1246
- }
1247
- };
1248
-
1249
- export default preview;
1250
- `
1251
- });
1252
- const storybookScripts = (rootFolder)=>{
1253
- const folder = external_node_path_default().posix.join(rootFolder.replaceAll('\\', '/'), 'presentation/react');
1254
- const quote = (value)=>JSON.stringify(value);
1255
- return {
1256
- storybook: `storybook dev -p 6006 -c ${quote(`${folder}/.storybook`)}`,
1257
- 'build-storybook': `storybook build -c ${quote(`${folder}/.storybook`)} -o ${quote(`${folder}/storybook-static`)}`
1258
- };
1259
- };
1260
- const addStorybook = async ()=>{
1261
- const config = ConfigFile.Instance.data;
1262
- if ((!config.useReact || config.storybookFramework && '@storybook/react-vite' !== config.storybookFramework) && !await (0, prompts_namespaceObject.confirm)({
1263
- message: 'Configure React scaffolding with @storybook/react-vite?',
1264
- default: false
1265
- })) return [];
1266
- const root = new ProjectRoot().path;
1267
- const manifestFile = new File(external_node_path_default().join(root, 'package.json'));
1268
- const manifest = JSON.parse(manifestFile.data);
1269
- const selected = await addPackageScripts(manifestFile, storybookScripts(config.rootFolder));
1270
- const folder = new Folder(root).subitem([
1271
- config.rootFolder,
1272
- 'presentation',
1273
- 'react',
1274
- '.storybook'
1275
- ]);
1276
- for (const [name, content] of Object.entries(storybookFiles(external_node_path_default().relative(folder.path, root).split(external_node_path_default().sep).join('/')))){
1277
- const file = new File(external_node_path_default().join(folder.path, name));
1278
- if (!file.exists || file.data !== content) file.data = content;
1279
- }
1280
- if (!config.useReact || '@storybook/react-vite' !== config.storybookFramework) ConfigFile.write({
1281
- ...config,
1282
- useReact: true,
1283
- storybookFramework: '@storybook/react-vite'
1284
- });
1285
- const buildFolder = external_node_path_default().posix.join(config.rootFolder.replaceAll('\\', '/'), 'presentation/react/storybook-static');
1286
- addGitignoreEntry(root, `/${buildFolder}/`);
1287
- const dependencies = {
1288
- ...manifest.dependencies,
1289
- ...manifest.devDependencies
1290
- };
1291
- const missing = [
1292
- 'storybook',
1293
- '@storybook/react-vite',
1294
- 'vite',
1295
- '@vitejs/plugin-react'
1296
- ].filter((name)=>!dependencies[name]);
1297
- const missingReact = [
1298
- 'react',
1299
- 'react-dom'
1300
- ].filter((name)=>!dependencies[name]);
1301
- return [
1302
- ...missing.length ? [
1303
- `npm install --save-dev ${missing.join(' ')}`
1304
- ] : [],
1305
- ...missingReact.length ? [
1306
- `npm install ${missingReact.join(' ')}`
1307
- ] : [],
1308
- ...describeScripts(selected, {
1309
- storybook: 'start Storybook on http://localhost:6006',
1310
- 'build-storybook': `build static Storybook into ${buildFolder}`
1311
- })
1312
- ];
1313
- };
1314
- const integrationFolder = 'specs/integration';
1315
- const testcontainersScripts = {
1316
- 'test:integration': `vitest run --config ${integrationFolder}/vitest.config.ts --reporter=dot --silent=passed-only`
1317
- };
1318
- const testcontainersVitestConfig = (inlineHandlersNext)=>{
1319
- const server = inlineHandlersNext ? `,
1320
- server: {
1321
- deps: {
1322
- // Imports \`next/headers\` without an extension, which only a bundler can resolve
1323
- inline: ['@domain-first/handlers-next']
1324
- }
1325
- }` : '';
1326
- return `import { fileURLToPath } from 'node:url';
1327
- import { defineConfig } from 'vitest/config';
1328
-
1329
- // Runs specs from this folder against PostgreSQL in a container, see global-setup.ts.
1330
- export default defineConfig({
1331
- // Paths below are relative to the project root, not this folder
1332
- root: fileURLToPath(new URL('../..', import.meta.url)),
1333
- resolve: {
1334
- tsconfigPaths: true
1335
- },
1336
- test: {
1337
- include: ['${integrationFolder}/**/*.spec.ts'],
1338
- // Development implementations work with the real database
1339
- env: { NODE_ENV: 'development' },
1340
- globalSetup: ['${integrationFolder}/global-setup.ts'],
1341
- setupFiles: ['${integrationFolder}/setup-env.ts'],
1342
- // Pulling the image on the first run takes a while
1343
- hookTimeout: 120_000${server}
1344
- }
1345
- });
1346
- `;
1347
- };
1348
- const testcontainersGlobalSetup = (migrationCommand)=>{
1349
- const migrations = migrationCommand ? `
1350
- // dotenv in the Prisma config does not override an already set variable
1351
- execSync(${JSON.stringify(migrationCommand)}, {
1352
- cwd: project.config.root,
1353
- env: { ...process.env, DATABASE_URL: databaseUrl },
1354
- // On failure the error carries the command's output
1355
- stdio: 'pipe'
1356
- });
1357
- ` : `
1358
- // Apply your migrations to databaseUrl here.
1359
- `;
1360
- return `${migrationCommand ? "import { execSync } from 'node:child_process';\n" : ''}import { GenericContainer, Wait } from 'testcontainers';
1361
- import type { TestProject } from 'vitest/node';
1362
-
1363
- declare module 'vitest' {
1364
- export interface ProvidedContext {
1365
- databaseUrl: string;
1366
- }
1367
- }
1368
-
1369
- const POSTGRES_IMAGE = 'postgres:15';
1370
- const POSTGRES_PORT = 5432;
1371
- const POSTGRES_USER = 'test';
1372
- const POSTGRES_PASSWORD = 'test';
1373
- const POSTGRES_DB = 'test';
1374
-
1375
- export default async function setup(project: TestProject) {
1376
- const container = await new GenericContainer(POSTGRES_IMAGE)
1377
- .withEnvironment({ POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB })
1378
- .withExposedPorts(POSTGRES_PORT)
1379
- // During init PostgreSQL listens on a unix socket only and restarts,
1380
- // so checking over TCP passes once the final server is up
1381
- .withHealthCheck({
1382
- test: [
1383
- 'CMD-SHELL',
1384
- \`pg_isready --host localhost --username \${POSTGRES_USER} --dbname \${POSTGRES_DB}\`
1385
- ],
1386
- interval: 250,
1387
- timeout: 1000,
1388
- retries: 1000
1389
- })
1390
- .withWaitStrategy(Wait.forHealthCheck())
1391
- .withStartupTimeout(120_000)
1392
- .start();
1393
-
1394
- const databaseUrl = \`postgresql://\${POSTGRES_USER}:\${POSTGRES_PASSWORD}@\${container.getHost()}:\${container.getMappedPort(POSTGRES_PORT)}/\${POSTGRES_DB}\`;
1395
- ${migrations}
1396
- project.provide('databaseUrl', databaseUrl);
1397
-
1398
- return async () => {
1399
- await container.stop();
1400
- };
1401
- }
1402
- `;
1403
- };
1404
- const testcontainersSetupEnv = `import 'dotenv/config';
1405
- import { inject } from 'vitest';
1406
-
1407
- // Runs before each spec's imports: development implementations get the .env
1408
- // config, and DATABASE_URL points to the container instead of the one from .env.
1409
- if (process.env.NODE_ENV !== 'development') {
1410
- throw new Error(
1411
- \`Integration specs need NODE_ENV=development to wire development implementations, got "\${process.env.NODE_ENV}"\`
1412
- );
1413
- }
1414
-
1415
- process.env.DATABASE_URL = inject('databaseUrl');
1416
- `;
1417
- const testcontainers_exampleSpec = `import { expect, inject, test } from 'vitest';
1418
-
1419
- test('connects to the database in the container', () => {
1420
- expect(process.env.DATABASE_URL).toBe(inject('databaseUrl'));
1421
- });
1422
- `;
1423
- const excludeFromUnitTests = (content)=>{
1424
- const exclude = /(exclude:\s*\[\s*\.\.\.configDefaults\.exclude\b[^\]]*?)(,?)(\s*)\]/;
1425
- if (!exclude.test(content)) return;
1426
- const entry = `'${integrationFolder}/**'`;
1427
- return content.replace(exclude, (_, items, comma, whitespace)=>{
1428
- const indent = whitespace.includes('\n') ? /\n([ \t]*)[^\n]*$/.exec(items)?.[1] : void 0;
1429
- const separator = void 0 === indent ? ', ' : `,\n${indent}`;
1430
- return `${items}${separator}${entry}${comma}${whitespace}]`;
1431
- }).replace('// Playwright runs end-to-end specs\n', '// Playwright runs end-to-end specs, test:integration runs integration ones\n');
1432
- };
1433
- const testcontainers_stageFile = (filePath, content)=>{
1434
- const file = new File(filePath);
1435
- if (!file.exists || file.data !== content) file.data = content;
1436
- };
1437
- const addTestcontainers = async ()=>{
1438
- const config = ConfigFile.Instance.data;
1439
- const root = new ProjectRoot().path;
1440
- const manifestFile = new File(external_node_path_default().join(root, 'package.json'));
1441
- const manifest = JSON.parse(manifestFile.data);
1442
- const dependencies = {
1443
- ...manifest.dependencies,
1444
- ...manifest.devDependencies
1445
- };
1446
- const selected = await addPackageScripts(manifestFile, testcontainersScripts);
1447
- const withPrisma = new File(external_node_path_default().resolve(root, config.rootFolder, 'shared/infrastructure/prisma/prisma.config.ts')).exists;
1448
- const migrationCommand = withPrisma ? `npx ${prismaScripts(config.rootFolder)['prisma:migration:apply'].replace(' --advance-ref db', '')}` : void 0;
1449
- const folder = external_node_path_default().join(root, integrationFolder);
1450
- testcontainers_stageFile(external_node_path_default().join(folder, 'vitest.config.ts'), testcontainersVitestConfig(Boolean(dependencies['@domain-first/handlers-next'])));
1451
- testcontainers_stageFile(external_node_path_default().join(folder, 'global-setup.ts'), testcontainersGlobalSetup(migrationCommand));
1452
- testcontainers_stageFile(external_node_path_default().join(folder, 'setup-env.ts'), testcontainersSetupEnv);
1453
- const example = new File(external_node_path_default().join(folder, 'database/database.spec.ts'));
1454
- if (!example.exists) example.data = testcontainers_exampleSpec;
1455
- const unitConfig = new File(external_node_path_default().join(root, 'vitest.config.ts'));
1456
- let excludedFromUnitTests = !unitConfig.exists || unitConfig.data.includes(integrationFolder);
1457
- if (!excludedFromUnitTests) {
1458
- const excluded = excludeFromUnitTests(unitConfig.data);
1459
- if (excluded) {
1460
- unitConfig.update(excluded);
1461
- excludedFromUnitTests = true;
1462
- }
1463
- }
1464
- const missing = [
1465
- 'vitest',
1466
- 'testcontainers',
1467
- 'dotenv'
1468
- ].filter((name)=>!dependencies[name]);
1469
- return [
1470
- ...missing.length ? [
1471
- `npm install --save-dev ${missing.join(' ')}`
1472
- ] : [],
1473
- `Integration specs run against postgres:15 and get its address in DATABASE_URL. Change the image, credentials and connection string in ${integrationFolder}/global-setup.ts, and the variable name in ${integrationFolder}/setup-env.ts.`,
1474
- ...migrationCommand ? [] : [
1475
- `Apply your migrations in ${integrationFolder}/global-setup.ts.`
1476
- ],
1477
- ...excludedFromUnitTests ? [] : [
1478
- `Add '${integrationFolder}/**' to test.exclude in vitest.config.ts, so unit tests skip integration specs.`
1479
- ],
1480
- 'Docker must be running for integration specs.',
1481
- ...describeScripts(selected, {
1482
- 'test:integration': `run integration specs from ${integrationFolder} against PostgreSQL in a container`
1483
- })
1484
- ];
1485
- };
1486
- const vitestScripts = {
1487
- test: 'vitest run --reporter=dot --silent=passed-only',
1488
- 'test:coverage': 'vitest run --coverage --reporter=dot --silent=passed-only'
1489
- };
1490
- const vitestConfig = (rootFolder, inlineHandlersNext)=>{
1491
- const folder = (subpath)=>JSON.stringify(external_node_path_default().posix.join(rootFolder.replaceAll('\\', '/'), subpath));
1492
- const server = inlineHandlersNext ? `,
1493
- server: {
1494
- deps: {
1495
- // Imports \`next/headers\` without an extension, which only a bundler can resolve
1496
- inline: ['@domain-first/handlers-next']
1497
- }
1498
- }` : '';
1499
- return `import { configDefaults, defineConfig } from 'vitest/config';
1500
-
1501
- export default defineConfig({
1502
- resolve: {
1503
- tsconfigPaths: true
1504
- },
1505
- test: {
1506
- // Playwright runs end-to-end specs, test:integration runs integration ones
1507
- exclude: [...configDefaults.exclude, 'specs/e2e/**', 'specs/integration/**'],
1508
- coverage: {
1509
- provider: 'v8',
1510
- include: [${folder('bounded-contexts/**/*.ts')}, ${folder('shared/**/*.ts')}],
1511
- exclude: [
1512
- '**/*.spec.ts',
1513
- ${folder('shared/infrastructure/**')},
1514
- ${folder('bounded-contexts/*/infrastructure/**')},
1515
- ${folder('bounded-contexts/*/presentation/rest/**')},
1516
- ${folder('shared/wiring/**')},
1517
- ${folder('bounded-contexts/*/wiring/**')}
1518
- ],
1519
- reporter: [['text', { skipFull: true }], 'html']
1520
- }${server}
1521
- }
1522
- });
1523
- `;
1524
- };
1525
- const addVitest = async ()=>{
1526
- const config = ConfigFile.Instance.data;
1527
- if (config.testingLibrary && 'vitest' !== config.testingLibrary && !await (0, prompts_namespaceObject.confirm)({
1528
- message: `Replace testing library "${config.testingLibrary}" with vitest for generated tests?`,
1529
- default: false
1530
- })) return [];
1531
- const root = new ProjectRoot().path;
1532
- const manifestFile = new File(external_node_path_default().join(root, 'package.json'));
1533
- const manifest = JSON.parse(manifestFile.data);
1534
- const dependencies = {
1535
- ...manifest.dependencies,
1536
- ...manifest.devDependencies
1537
- };
1538
- const selected = await addPackageScripts(manifestFile, vitestScripts);
1539
- const configFile = new File(external_node_path_default().join(root, 'vitest.config.ts'));
1540
- const content = vitestConfig(config.rootFolder, Boolean(dependencies['@domain-first/handlers-next']));
1541
- if (!configFile.exists || configFile.data !== content) configFile.data = content;
1542
- if ('vitest' !== config.testingLibrary) ConfigFile.write({
1543
- ...config,
1544
- testingLibrary: 'vitest'
1545
- });
1546
- addGitignoreEntry(root, '/coverage/');
1547
- const missing = [
1548
- 'vitest',
1549
- '@vitest/coverage-v8'
1550
- ].filter((name)=>!dependencies[name]);
1551
- return [
1552
- ...missing.length ? [
1553
- `npm install --save-dev ${missing.join(' ')}`
1554
- ] : [],
1555
- ...describeScripts(selected, {
1556
- test: 'run unit tests',
1557
- 'test:coverage': 'run unit tests with a V8 coverage report in coverage/'
1558
- })
1559
- ];
1560
- };
1561
- const withHandlersRest = ()=>ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers-rest');
1562
- const integrations = [
1563
- {
1564
- name: 'Storybook (React + Vite)',
1565
- run: addStorybook
1566
- },
1567
- {
1568
- name: 'Prisma 8 (PostgreSQL, RC)',
1569
- run: addPrisma
1570
- },
1571
- {
1572
- name: 'Vitest',
1573
- run: addVitest
1574
- },
1575
- {
1576
- name: 'Playwright',
1577
- run: addPlaywright
1578
- },
1579
- {
1580
- name: 'Integration tests (Testcontainers, PostgreSQL)',
1581
- run: addTestcontainers
1582
- },
1583
- {
1584
- name: 'OpenAPI',
1585
- run: addOpenapi,
1586
- available: ()=>withHandlersRest()
1587
- },
1588
- {
1589
- name: 'Orval (React Query client)',
1590
- run: addOrval,
1591
- available: ()=>withHandlersRest() && ConfigFile.Instance.data.useReact
1592
- },
1593
- {
1594
- name: 'Missing domain-first packages',
1595
- run: missingDomainFirstPackages
1596
- }
1597
- ];
1598
- const addIntegration = async ()=>{
1599
- const integration = await (0, prompts_namespaceObject.select)({
1600
- message: 'Integration:',
1601
- choices: integrations.filter(({ available })=>available?.() ?? true).map((value)=>({
1602
- name: value.name,
1603
- value
1604
- }))
1605
- });
1606
- const nextSteps = await integration.run();
1607
- if (await savePendingChanges()) printNextSteps(nextSteps);
1608
- };
1609
373
  const wiring_layers = [
1610
374
  'domain',
1611
375
  'application',
@@ -1686,8 +450,8 @@ const wiredClassNames = (source, wireName, initializerStart, branched)=>{
1686
450
  const readWiredModule = (wireFile, contextPath)=>{
1687
451
  const wiringRelativePath = external_node_path_default().relative(external_node_path_default().join(contextPath, 'wiring'), wireFile);
1688
452
  if (isEndpointWire(wiringRelativePath)) return;
1689
- const source = new File(wireFile).data;
1690
- const wireName = `wire${new UnknownFormatNaming(external_node_path_default().basename(wireFile, '.ts').replace(/^wire-/, '')).ClassName}`;
453
+ const source = new file_system_File(wireFile).data;
454
+ const wireName = `wire${new unknown_format_naming_UnknownFormatNaming(external_node_path_default().basename(wireFile, '.ts').replace(/^wire-/, '')).ClassName}`;
1691
455
  const exportMatch = new RegExp(`export\\s+const\\s+${wireName}\\s*=\\s*`).exec(source);
1692
456
  if (!exportMatch) return;
1693
457
  const branched = source.slice(exportMatch.index + exportMatch[0].length).startsWith('envBranchedWire(');
@@ -1749,10 +513,10 @@ const canDependOn = (consumer, candidate, rules = defaultDependencyRules)=>{
1749
513
  return consumerKind && candidateKind ? rules[consumerKind].has(candidateKind) : layerRule(consumer, candidate);
1750
514
  };
1751
515
  const availableDependencies = (consumer, implementation, candidates, rules = configuredDependencyRules())=>{
1752
- const wired = wiredDependencyNames(new File(consumer.wireFile).data, implementation.className);
516
+ const wired = wiredDependencyNames(new file_system_File(consumer.wireFile).data, implementation.className);
1753
517
  return candidates.filter((candidate)=>candidate.wireFile !== consumer.wireFile && canDependOn(consumer, candidate, rules) && !wired.includes(candidate.wireName));
1754
518
  };
1755
- const relativeImport = (fromFile, toFile)=>{
519
+ const wiring_relativeImport = (fromFile, toFile)=>{
1756
520
  const relativePath = external_node_path_default().relative(external_node_path_default().dirname(fromFile), toFile).replace(/\.ts$/, '').split(external_node_path_default().sep).join('/');
1757
521
  return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
1758
522
  };
@@ -1904,180 +668,36 @@ const addWireDependencies = (source, className, wireNames)=>{
1904
668
  };
1905
669
  const parameterName = (typeName)=>typeName.substring(0, 1).toLowerCase() + typeName.substring(1);
1906
670
  const wireDependencies = (consumer, implementation, dependencies)=>{
1907
- const wireFile = new File(consumer.wireFile);
671
+ const wireFile = new file_system_File(consumer.wireFile);
1908
672
  let wireSource = wireFile.data;
1909
- for (const dependency of dependencies)wireSource = addImport(wireSource, `import { ${dependency.wireName} } from '${relativeImport(consumer.wireFile, dependency.wireFile)}'`);
673
+ for (const dependency of dependencies)wireSource = addImport(wireSource, `import { ${dependency.wireName} } from '${wiring_relativeImport(consumer.wireFile, dependency.wireFile)}'`);
1910
674
  wireFile.update(addWireDependencies(wireSource, implementation.className, dependencies.map((x)=>x.wireName)));
1911
- const classFile = new File(implementation.file);
675
+ const classFile = new file_system_File(implementation.file);
1912
676
  let classSource = classFile.data;
1913
- for (const dependency of dependencies)classSource = addImport(classSource, `import type { ${dependency.typeName} } from '${relativeImport(implementation.file, dependency.typeFile)}'`);
677
+ for (const dependency of dependencies)classSource = addImport(classSource, `import type { ${dependency.typeName} } from '${wiring_relativeImport(implementation.file, dependency.typeFile)}'`);
1914
678
  classFile.update(addConstructorParameters(classSource, implementation.className, dependencies.map((x)=>`private readonly ${parameterName(x.typeName)}: ${x.typeName}`)));
1915
679
  };
1916
680
  const inMemoryImplementationType = 'in-memory';
1917
681
  const in_memory_db_className = 'InMemoryDbInfrastructureService';
1918
682
  const in_memory_db_wireName = 'wireInMemoryDbInfrastructureService';
1919
683
  const in_memory_db_parameterName = 'inMemoryDbInfrastructureService';
1920
- const inMemoryDbService = `type Entry = {
1921
- id: unknown;
1922
- item: any;
1923
- };
1924
-
1925
- declare global {
1926
- var ___SHARED_IN_MEMORY_DB___: Record<string, Array<Entry>> | undefined;
1927
- }
1928
-
1929
- type Section<T, TId> = {
1930
- all: (predicate?: (x: T) => boolean) => T[];
1931
- first: (predicate: (x: T) => boolean) => T | null;
1932
- withId: (id: TId) => T | null;
1933
- lastAddedItem: () => T | null;
1934
- save: (payload: T extends { id: TId } ? T : [TId, T]) => void;
1935
- deleteById: (id: TId) => void;
1936
- delete: (predicate: (x: T) => boolean) => void;
1937
- };
1938
-
1939
- type IdsAreEqual<TId> = (a: TId, b: TId) => boolean;
1940
-
1941
- const comparisonMethodNames = ['equals', 'same', 'isSame', 'isEqual'] as const;
1942
-
1943
- const defaultIdsAreEqual = (a: unknown, b: unknown): boolean => {
1944
- if (typeof a !== 'object' || a === null) {
1945
- return Object.is(a, b);
1946
- }
1947
-
1948
- for (const methodName of comparisonMethodNames) {
1949
- const method: unknown = (a as Record<string, unknown>)[methodName];
1950
- if (typeof method === 'function') {
1951
- return Boolean(method.call(a, b));
1952
- }
1953
- }
1954
-
1955
- return Object.is(a, b);
1956
- };
1957
-
1958
- const hasId = (x: unknown): x is { id: unknown } =>
1959
- typeof x === 'object' && x !== null && 'id' in x;
1960
-
1961
- export class InMemoryDbInfrastructureService {
1962
- protected section<T extends { id: unknown }>(
1963
- key: string,
1964
- idsAreEqual?: IdsAreEqual<T['id']>
1965
- ): Section<T, T['id']>;
1966
- protected section<T, TId>(
1967
- key: string,
1968
- idsAreEqual?: IdsAreEqual<TId>
1969
- ): Section<T, TId>;
1970
- protected section<T, TId>(
1971
- key: string,
1972
- idsAreEqual: IdsAreEqual<TId> = defaultIdsAreEqual
1973
- ): Section<T, TId> {
1974
- if (!globalThis.___SHARED_IN_MEMORY_DB___) {
1975
- globalThis.___SHARED_IN_MEMORY_DB___ = {};
1976
- }
1977
-
1978
- if (!globalThis.___SHARED_IN_MEMORY_DB___[key]) {
1979
- globalThis.___SHARED_IN_MEMORY_DB___[key] = [];
1980
- }
1981
-
1982
- const items = (): T[] =>
1983
- globalThis.___SHARED_IN_MEMORY_DB___![key].map(
1984
- (entry) => entry.item
1985
- );
1986
-
1987
- return {
1988
- all: (predicate: (x: T) => boolean = () => true): T[] =>
1989
- items().filter(predicate),
1990
- first: (predicate: (x: T) => boolean): T | null =>
1991
- items().find(predicate) ?? null,
1992
- withId: (id: TId): T | null =>
1993
- items().find(
1994
- (x: T) => hasId(x) && idsAreEqual(x.id as TId, id)
1995
- ) ?? null,
1996
- lastAddedItem: (): T | null =>
1997
- globalThis.___SHARED_IN_MEMORY_DB___![key].at(-1)?.item ?? null,
1998
- save: (payload: T extends { id: TId } ? T : [TId, T]) => {
1999
- const id = Array.isArray(payload) ? payload[0] : payload.id;
2000
- const item = Array.isArray(payload) ? payload[1] : payload;
2001
- const entries = globalThis.___SHARED_IN_MEMORY_DB___![key];
2002
- const existing = entries.find((entry) =>
2003
- idsAreEqual(entry.id as TId, id)
2004
- );
2005
- if (existing) {
2006
- existing.item = item;
2007
- return;
2008
- }
2009
- entries.push({ id, item });
2010
- },
2011
- deleteById: (id: TId) => {
2012
- globalThis.___SHARED_IN_MEMORY_DB___![key] =
2013
- globalThis.___SHARED_IN_MEMORY_DB___![key].filter(
2014
- (entry) => !idsAreEqual(entry.id as TId, id)
2015
- );
2016
- },
2017
- delete: (predicate: (x: T) => boolean) => {
2018
- globalThis.___SHARED_IN_MEMORY_DB___![key] =
2019
- globalThis.___SHARED_IN_MEMORY_DB___![key].filter(
2020
- (entry) => !predicate(entry.item)
2021
- );
2022
- }
2023
- };
2024
- }
2025
- }
2026
- `;
2027
- const inMemoryDbWiring = `import { wireClass } from '@domain-first/wire';
2028
- import { InMemoryDbInfrastructureService } from '../../infrastructure/services/in-memory-db-infrastructure-service';
2029
-
2030
- export const wireInMemoryDbInfrastructureService = wireClass(
2031
- InMemoryDbInfrastructureService,
2032
- []
2033
- );
2034
- `;
2035
- const inMemoryDbSpec = (testingLibrary, withWiring)=>`
2036
- import { describe, test, expect, beforeEach } from '${testingLibrary}'
2037
- ${withWiring ? `import { type InMemoryDbInfrastructureService } from './in-memory-db-infrastructure-service'
2038
- import { wireInMemoryDbInfrastructureService } from '../../wiring/infrastructure-services/wire-in-memory-db-infrastructure-service'` : "import { InMemoryDbInfrastructureService } from './in-memory-db-infrastructure-service'"}
2039
-
2040
- let inMemoryDbInfrastructureService: InMemoryDbInfrastructureService
2041
-
2042
- beforeEach(() => {
2043
- inMemoryDbInfrastructureService = ${withWiring ? 'wireInMemoryDbInfrastructureService()' : 'new InMemoryDbInfrastructureService()'}
2044
- })
2045
-
2046
- describe('in memory db', () => {
2047
- test('can be ${withWiring ? 'wired' : 'created'}', () => {
2048
- expect(inMemoryDbInfrastructureService).toBeDefined()
2049
- })
2050
- })
2051
- `.trim();
2052
- const in_memory_db_withWiring = ()=>ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
2053
- const in_memory_db_sharedFolder = ()=>new Folder(new ProjectRoot().path).subitem([
2054
- ConfigFile.Instance.data.rootFolder,
2055
- 'shared'
684
+ const in_memory_db_withWiring = ()=>config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
685
+ const in_memory_db_sharedFolder = ()=>new file_system_Folder(new project_root_ProjectRoot().path).subitem([
686
+ config_file_ConfigFile.Instance.data.rootFolder,
687
+ 'shared-kernel'
2056
688
  ]);
2057
- const serviceFile = ()=>new File(in_memory_db_sharedFolder().path).subitem([
689
+ const serviceFile = ()=>new file_system_File(in_memory_db_sharedFolder().path).subitem([
2058
690
  'infrastructure',
2059
691
  'services',
2060
692
  'in-memory-db-infrastructure-service.ts'
2061
693
  ]);
2062
- const in_memory_db_wireFile = ()=>new File(in_memory_db_sharedFolder().path).subitem([
694
+ const in_memory_db_wireFile = ()=>new file_system_File(in_memory_db_sharedFolder().path).subitem([
2063
695
  'wiring',
2064
696
  'infrastructure-services',
2065
697
  'wire-in-memory-db-infrastructure-service.ts'
2066
698
  ]);
2067
- const scaffoldInMemoryDb = (shared)=>{
2068
- const { testingLibrary } = ConfigFile.Instance.data;
2069
- const servicesFolder = shared.subitem([
2070
- 'infrastructure',
2071
- 'services'
2072
- ]);
2073
- servicesFolder.createFile('in-memory-db-infrastructure-service.ts', inMemoryDbService);
2074
- if (testingLibrary) servicesFolder.createFile('in-memory-db-infrastructure-service.spec.ts', inMemoryDbSpec(testingLibrary, in_memory_db_withWiring()));
2075
- if (in_memory_db_withWiring()) shared.subitem([
2076
- 'wiring',
2077
- 'infrastructure-services'
2078
- ]).createFile('wire-in-memory-db-infrastructure-service.ts', inMemoryDbWiring);
2079
- };
2080
- const usesInMemoryDb = (implementationType)=>Boolean(ConfigFile.Instance.data.withInMemoryDb) && new UnknownFormatNaming(implementationType).fileName === inMemoryImplementationType && serviceFile().exists && (!in_memory_db_withWiring() || in_memory_db_wireFile().exists);
699
+ const in_memory_db_inMemoryDbScaffolded = ()=>serviceFile().exists && (!in_memory_db_withWiring() || in_memory_db_wireFile().exists);
700
+ const usesInMemoryDb = (implementationType)=>Boolean(config_file_ConfigFile.Instance.data.withInMemoryDb) && new unknown_format_naming_UnknownFormatNaming(implementationType).fileName === inMemoryImplementationType && in_memory_db_inMemoryDbScaffolded();
2081
701
  const plural = (word)=>{
2082
702
  if (/[^aeiou]y$/i.test(word)) return `${word.slice(0, -1)}ies`;
2083
703
  if (/(s|x|z|ch|sh)$/i.test(word)) return `${word}es`;
@@ -2085,14 +705,14 @@ const plural = (word)=>{
2085
705
  };
2086
706
  const addInMemoryDbSection = (typeNaming, typeImportTarget)=>{
2087
707
  const file = serviceFile();
2088
- const sectionNaming = new UnknownFormatNaming(plural(typeNaming.fileName));
708
+ const sectionNaming = new unknown_format_naming_UnknownFormatNaming(plural(typeNaming.fileName));
2089
709
  const field = sectionNaming.variableName;
2090
710
  if (new RegExp(`\\b${field}\\s*=\\s*this\\.section\\b`).test(file.data)) return field;
2091
- const withImport = addImport(file.data, `import type { ${typeNaming.ClassName} } from '${relativeImport(file.path, typeImportTarget)}';`);
711
+ const withImport = addImport(file.data, `import type { ${typeNaming.ClassName} } from '${wiring_relativeImport(file.path, typeImportTarget)}';`);
2092
712
  file.update(addClassMember(withImport, in_memory_db_className, `${field} = this.section<${typeNaming.ClassName}>('${sectionNaming.fileName.toUpperCase()}');`));
2093
713
  return field;
2094
714
  };
2095
- const inMemoryDbTypeImport = (fromFile)=>`import type { ${in_memory_db_className} } from '${relativeImport(fromFile, serviceFile().path)}'`;
715
+ const inMemoryDbTypeImport = (fromFile)=>`import type { ${in_memory_db_className} } from '${wiring_relativeImport(fromFile, serviceFile().path)}'`;
2096
716
  const inMemoryDbSectionMembers = (field, derived)=>`
2097
717
  private readonly data: ${in_memory_db_className}['${field}']
2098
718
 
@@ -2110,13 +730,14 @@ const injectInMemoryDb = (classFile, implementationName)=>{
2110
730
  ]));
2111
731
  };
2112
732
  const wireInMemoryDb = (consumerWireFile, implementationName)=>{
2113
- consumerWireFile.update(addWireDependencies(addImport(consumerWireFile.data, `import { ${in_memory_db_wireName} } from '${relativeImport(consumerWireFile.path, in_memory_db_wireFile().path)}'`), implementationName, [
733
+ consumerWireFile.update(addWireDependencies(addImport(consumerWireFile.data, `import { ${in_memory_db_wireName} } from '${wiring_relativeImport(consumerWireFile.path, in_memory_db_wireFile().path)}'`), implementationName, [
2114
734
  in_memory_db_wireName
2115
735
  ]));
2116
736
  };
2117
737
  const passInMemoryDb = (specFile, implementationName)=>{
2118
- specFile.update(addImport(specFile.data, `import { ${in_memory_db_className} } from '${relativeImport(specFile.path, serviceFile().path)}'`).replace(`new ${implementationName}()`, `new ${implementationName}(new ${in_memory_db_className}())`));
738
+ specFile.update(addImport(specFile.data, `import { ${in_memory_db_className} } from '${wiring_relativeImport(specFile.path, serviceFile().path)}'`).replace(`new ${implementationName}()`, `new ${implementationName}(new ${in_memory_db_className}())`));
2119
739
  };
740
+ require("node:module");
2120
741
  const kindTitles = {
2121
742
  repositories: 'Repositories',
2122
743
  'domain-services': 'Domain services',
@@ -2159,9 +780,9 @@ const groupedChoices = (items, suggested = [])=>{
2159
780
  };
2160
781
  const groupedPageSize = 20;
2161
782
  const contextAndSharedModules = (boundedContextFolder)=>{
2162
- const sharedFolder = new Folder(new ProjectRoot().path).subitem([
2163
- ConfigFile.Instance.data.rootFolder,
2164
- 'shared'
783
+ const sharedFolder = new file_system_Folder(new project_root_ProjectRoot().path).subitem([
784
+ config_file_ConfigFile.Instance.data.rootFolder,
785
+ 'shared-kernel'
2165
786
  ]);
2166
787
  const isShared = sharedFolder.path === boundedContextFolder.path;
2167
788
  return [
@@ -2171,7 +792,7 @@ const contextAndSharedModules = (boundedContextFolder)=>{
2171
792
  })),
2172
793
  ...isShared ? [] : findWiredModules(sharedFolder.path).map((x)=>({
2173
794
  module: x,
2174
- label: `${x.typeName} (shared)`
795
+ label: `${x.typeName} (shared-kernel)`
2175
796
  }))
2176
797
  ];
2177
798
  };
@@ -2236,11 +857,11 @@ const promptEndpointHandler = async (boundedContextFolder)=>{
2236
857
  loop: false
2237
858
  })).module : void 0;
2238
859
  };
2239
- const createPresentationService = (boundedContextFolder, name, classFile)=>{
2240
- const naming = new UnknownFormatNaming(name);
860
+ const scaffold_new_presentation_service_createPresentationService = (boundedContextFolder, name, classFile)=>{
861
+ const naming = new unknown_format_naming_UnknownFormatNaming(name);
2241
862
  const className = `${naming.ClassName}PresentationService`;
2242
- const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
2243
- const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
863
+ const scaffoldUnitTests = Boolean(config_file_ConfigFile.Instance.data.testingLibrary);
864
+ const withWiring = config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
2244
865
  const wiringFolder = boundedContextFolder.subitem([
2245
866
  'wiring',
2246
867
  'presentation-services'
@@ -2255,7 +876,7 @@ export class ${className} {
2255
876
  }
2256
877
  `.trim());
2257
878
  if (scaffoldUnitTests) presentationServicesFolder.createFile(`${naming.fileName}-presentation-service.spec.ts`, `
2258
- import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
879
+ import { describe, test, expect, beforeEach } from '${config_file_ConfigFile.Instance.data.testingLibrary}'
2259
880
  ${withWiring ? `import { type ${naming.ClassName}PresentationService } from './${naming.fileName}-presentation-service'
2260
881
  import { wire${naming.ClassName}PresentationService } from '../../wiring/presentation-services/wire-${naming.fileName}-presentation-service'` : `import { ${naming.ClassName}PresentationService } from './${naming.fileName}-presentation-service'`}
2261
882
 
@@ -2285,36 +906,13 @@ const scaffoldNewPresentationService = async (boundedContextFolder)=>{
2285
906
  const name = await (0, prompts_namespaceObject.input)({
2286
907
  message: 'Name: '
2287
908
  });
2288
- const wireFile = createPresentationService(boundedContextFolder, name);
909
+ const wireFile = scaffold_new_presentation_service_createPresentationService(boundedContextFolder, name);
2289
910
  if (wireFile) await wireNewModuleDependencies(boundedContextFolder, wireFile);
2290
911
  };
2291
912
  const rest_endpoint_generator_name = 'rest-endpoint-generator';
2292
- const scaffoldRestEndpointGenerator = (sharedFolder, { withNextAdapter = false } = {})=>createPresentationService(sharedFolder, rest_endpoint_generator_name, (className)=>{
2293
- const adapter = withNextAdapter ? 'nextAdapter' : 'adapter';
2294
- return `
2295
- import {
2296
- ${withNextAdapter ? '' : ' type Adapter,\n'} type EndpointGenerator,
2297
- createEndpoint,
2298
- invalidRequest
2299
- } from '@domain-first/handlers-rest'
2300
- ${withNextAdapter ? "import { nextAdapter } from '@domain-first/handlers-next'" : `
2301
- /**
2302
- * The adapter of your HTTP framework.
2303
- */
2304
- const adapter = undefined as unknown as Adapter<any[], any>`}
2305
-
2306
- export class ${className} {
2307
- get withoutGuards(): EndpointGenerator {
2308
- return createEndpoint({
2309
- errors: [invalidRequest()]
2310
- })(${adapter}) as EndpointGenerator
2311
- }
2312
- }
2313
- `.trim();
2314
- });
2315
- const findRestEndpointGenerator = (sharedFolder)=>{
913
+ const rest_endpoint_generator_findRestEndpointGenerator = (sharedFolder)=>{
2316
914
  const typeFile = external_node_path_default().join(sharedFolder.path, 'presentation', 'services', `${rest_endpoint_generator_name}-presentation-service.ts`);
2317
- if (!new File(typeFile).exists) return;
915
+ if (!new file_system_File(typeFile).exists) return;
2318
916
  return {
2319
917
  typeName: 'RestEndpointGeneratorPresentationService',
2320
918
  typeFile,
@@ -2322,109 +920,8 @@ const findRestEndpointGenerator = (sharedFolder)=>{
2322
920
  wireFile: external_node_path_default().join(sharedFolder.path, 'wiring', 'presentation-services', `wire-${rest_endpoint_generator_name}-presentation-service.ts`)
2323
921
  };
2324
922
  };
2325
- const hasDependency = (root, name)=>{
2326
- const manifestFile = new File(external_node_path_default().join(root, 'package.json'));
2327
- if (!manifestFile.exists) return false;
2328
- const manifest = JSON.parse(manifestFile.data);
2329
- return [
2330
- manifest.dependencies,
2331
- manifest.devDependencies,
2332
- manifest.optionalDependencies
2333
- ].some((dependencies)=>dependencies && Object.hasOwn(dependencies, name));
2334
- };
2335
- const initializeUseCase = async ()=>{
2336
- const nextSteps = [];
2337
- const rootFolderName = await (0, prompts_namespaceObject.input)({
2338
- message: 'Root folder (use "/" for inner folders):',
2339
- default: 'src'
2340
- });
2341
- const domainFirstPackages = await (0, prompts_namespaceObject.checkbox)({
2342
- message: '@domain-first packages',
2343
- choices: [
2344
- '@domain-first/types',
2345
- '@domain-first/errors',
2346
- '@domain-first/handlers',
2347
- '@domain-first/wire',
2348
- '@domain-first/handlers-rest'
2349
- ]
2350
- });
2351
- const withNextAdapter = domainFirstPackages.includes('@domain-first/handlers-rest') && hasDependency(new ProjectRoot().path, 'next') && await (0, prompts_namespaceObject.confirm)({
2352
- message: 'Use Next adapter for REST endpoints'
2353
- });
2354
- const defaultPersistenceLayerImplementation = await (0, prompts_namespaceObject.input)({
2355
- message: 'Default persistence layer implementation:'
2356
- });
2357
- const withInMemoryDb = await (0, prompts_namespaceObject.confirm)({
2358
- message: 'Scaffold in-memory DB for test implementations'
2359
- });
2360
- const useReact = await (0, prompts_namespaceObject.confirm)({
2361
- message: 'Use React'
2362
- });
2363
- let storybookFramework;
2364
- const withStorybook = useReact ? await (0, prompts_namespaceObject.confirm)({
2365
- message: 'Use Storybook'
2366
- }) : false;
2367
- if (withStorybook) storybookFramework = await (0, prompts_namespaceObject.input)({
2368
- message: 'Storybook framework package:',
2369
- default: '@storybook/react-vite'
2370
- });
2371
- let testingLibrary;
2372
- const withTests = await (0, prompts_namespaceObject.confirm)({
2373
- message: 'Scaffold unit tests'
2374
- });
2375
- if (withTests) testingLibrary = await (0, prompts_namespaceObject.input)({
2376
- message: 'Unit testing library:',
2377
- default: 'vitest'
2378
- });
2379
- ConfigFile.write({
2380
- rootFolder: rootFolderName,
2381
- domainFirstPackages,
2382
- defaultPersistenceLayerImplementation,
2383
- withInMemoryDb,
2384
- useReact,
2385
- storybookFramework,
2386
- testingLibrary
2387
- });
2388
- const { path } = new ProjectRoot();
2389
- const rootFolder = new Folder(path);
2390
- if (domainFirstPackages.includes('@domain-first/wire')) rootFolder.subitem([
2391
- rootFolderName,
2392
- 'shared',
2393
- 'wiring'
2394
- ]).createFile('env-branched-wire.ts', `
2395
- import { branchedWire } from '@domain-first/wire'
2396
-
2397
- export const envBranchedWire = branchedWire(() => {
2398
- return process.env.NODE_ENV ?? 'development' as 'test' | 'development' | 'production'
2399
- });
2400
- `.trim());
2401
- if (withInMemoryDb) scaffoldInMemoryDb(rootFolder.subitem([
2402
- rootFolderName,
2403
- 'shared'
2404
- ]));
2405
- if (domainFirstPackages.includes('@domain-first/errors')) rootFolder.subitem([
2406
- rootFolderName,
2407
- 'shared'
2408
- ]).subitem([
2409
- 'domain',
2410
- 'errors'
2411
- ]).createFile('index.ts', `
2412
- import { errorNamespace } from '@domain-first/errors'
2413
-
2414
- export const SharedErrors = errorNamespace('shared')
2415
- `.trim());
2416
- if (domainFirstPackages.includes('@domain-first/handlers-rest')) {
2417
- scaffoldRestEndpointGenerator(rootFolder.subitem([
2418
- rootFolderName,
2419
- 'shared'
2420
- ]), {
2421
- withNextAdapter
2422
- });
2423
- if (withNextAdapter && !hasDependency(path, '@domain-first/handlers-next')) nextSteps.push('npm i @domain-first/handlers-next');
2424
- }
2425
- return nextSteps;
2426
- };
2427
- const ignoredFolders = new Set([
923
+ require("node:util");
924
+ new Set([
2428
925
  'node_modules',
2429
926
  '.git',
2430
927
  '.next',
@@ -2434,242 +931,12 @@ const ignoredFolders = new Set([
2434
931
  'coverage',
2435
932
  'storybook-static'
2436
933
  ]);
2437
- const codeExtension = /\.(?:tsx?|mts|cts|jsx?|mjs|cjs|mdx)$/;
2438
- const escapeRegExp = (value)=>value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2439
- const react_module_move_walk = (folder)=>{
2440
- if (!external_node_fs_default().existsSync(folder)) return [];
2441
- return external_node_fs_default().readdirSync(folder, {
2442
- withFileTypes: true
2443
- }).flatMap((entry)=>{
2444
- const entryPath = external_node_path_default().join(folder, entry.name);
2445
- if (entry.isDirectory()) return ignoredFolders.has(entry.name) ? [] : react_module_move_walk(entryPath);
2446
- return entry.isFile() ? [
2447
- entryPath
2448
- ] : [];
2449
- });
2450
- };
2451
- const toPosix = (value)=>value.split(external_node_path_default().sep).join('/');
2452
- const nestedName = (folders, fileBase)=>{
2453
- const prefix = `${folders.join('-')}-`;
2454
- const last = folders.length && fileBase.startsWith(prefix) ? fileBase.slice(prefix.length) : fileBase;
2455
- return [
2456
- ...folders,
2457
- last
2458
- ].join('/');
2459
- };
2460
- const declaredClassName = (filePath, suffix, name)=>{
2461
- const content = external_node_fs_default().readFileSync(filePath, 'utf8');
2462
- const declared = content.match(new RegExp(`export\\s+(?:const|function)\\s+(\\w+)${suffix}\\b`))?.[1];
2463
- return declared ?? new NestedName(name).ClassName;
2464
- };
2465
- const findReactModules = (reactFolder, kind)=>{
2466
- const modules = 'page' === kind ? react_module_move_walk(external_node_path_default().join(reactFolder, 'pages')).filter((file)=>file.endsWith('-page.tsx')).map((file)=>{
2467
- const folders = external_node_path_default().relative(external_node_path_default().join(reactFolder, 'pages'), external_node_path_default().dirname(file)).split(external_node_path_default().sep).filter((segment)=>!!segment);
2468
- const fileBase = external_node_path_default().basename(file, '-page.tsx');
2469
- const name = nestedName(folders, fileBase);
2470
- return {
2471
- kind,
2472
- name,
2473
- path: file,
2474
- fileBase,
2475
- ClassName: declaredClassName(file, 'Page', name)
2476
- };
2477
- }) : react_module_move_walk(external_node_path_default().join(reactFolder, 'widgets')).filter((file)=>file.endsWith('-widget.tsx')).map((file)=>{
2478
- const folder = external_node_path_default().dirname(file);
2479
- const name = toPosix(external_node_path_default().relative(external_node_path_default().join(reactFolder, 'widgets'), folder));
2480
- return {
2481
- kind,
2482
- name,
2483
- path: folder,
2484
- fileBase: external_node_path_default().basename(file, '-widget.tsx'),
2485
- ClassName: declaredClassName(file, 'Widget', name)
2486
- };
2487
- });
2488
- return modules.sort((a, b)=>a.name.localeCompare(b.name));
2489
- };
2490
- const react_module_move_targetPath = (reactFolder, module, rawName)=>{
2491
- const { folders, folderName, fileName } = new NestedName(rawName);
2492
- return 'page' === module.kind ? external_node_path_default().join(reactFolder, 'pages', ...folders, `${fileName}-page.tsx`) : external_node_path_default().join(reactFolder, 'widgets', ...folders, folderName);
2493
- };
2494
- const validateMove = (reactFolder, module, rawName)=>{
2495
- const nameError = NestedName.validate(rawName);
2496
- if (true !== nameError) return nameError;
2497
- const target = react_module_move_targetPath(reactFolder, module, rawName);
2498
- if (target !== module.path && external_node_fs_default().existsSync(target)) return `${external_node_path_default().relative(reactFolder, target)} already exists`;
2499
- if (target.startsWith(`${module.path}${external_node_path_default().sep}`)) return 'A widget cannot be moved into itself';
2500
- return true;
2501
- };
2502
- const readAliases = (projectRoot)=>{
2503
- const tsconfig = external_node_path_default().join(projectRoot, 'tsconfig.json');
2504
- if (!external_node_fs_default().existsSync(tsconfig)) return [];
2505
- try {
2506
- const { compilerOptions = {} } = JSON.parse(stripJsonComments(external_node_fs_default().readFileSync(tsconfig, 'utf8')));
2507
- const base = external_node_path_default().resolve(projectRoot, compilerOptions.baseUrl ?? '.');
2508
- return Object.entries(compilerOptions.paths ?? {}).filter(([pattern, targets])=>pattern.endsWith('*') && targets[0]?.endsWith('*')).map(([pattern, [target]])=>({
2509
- prefix: pattern.slice(0, -1),
2510
- target: external_node_path_default().resolve(base, target.slice(0, -1))
2511
- }));
2512
- } catch {
2513
- return [];
2514
- }
2515
- };
2516
- const specifierPattern = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*|\bmock\s*\(\s*)(['"])([^'"\n]+)\2/g;
2517
- const reExportPattern = /\bexport\s+(?:type\s+)?(?:\*(?:\s+as\s+[\w$]+)?|\{[^}]*\})\s*from\s*(['"])([^'"\n]+)\1/g;
2518
- const importPaths = (file)=>{
2519
- const withoutExtension = file.replace(codeExtension, '');
2520
- return 'index' === external_node_path_default().basename(withoutExtension) ? [
2521
- withoutExtension,
2522
- external_node_path_default().dirname(withoutExtension)
2523
- ] : [
2524
- withoutExtension
2525
- ];
2526
- };
2527
- const moveReactModule = (projectRoot, reactFolder, module, rawName)=>{
2528
- const newName = new NestedName(rawName);
2529
- const target = react_module_move_targetPath(reactFolder, module, rawName);
2530
- const newClassName = newName.ClassName;
2531
- const renameFile = (name)=>name.replace(new RegExp(`^(use-)?${escapeRegExp(module.fileBase)}(?=[-.])`), (_, use = '')=>`${use}${newName.fileName}`);
2532
- const oldFolder = 'page' === module.kind ? external_node_path_default().dirname(module.path) : module.path;
2533
- const newFolder = 'page' === module.kind ? external_node_path_default().dirname(target) : target;
2534
- const ownsPath = (candidate)=>'page' === module.kind ? external_node_path_default().dirname(candidate) === oldFolder && new RegExp(`^${escapeRegExp(module.fileBase)}-page(?:\\.|$)`).test(external_node_path_default().basename(candidate)) : candidate === oldFolder || candidate.startsWith(`${oldFolder}${external_node_path_default().sep}`);
2535
- const movedPath = (candidate)=>{
2536
- if (!ownsPath(candidate)) return;
2537
- const segments = external_node_path_default().relative(oldFolder, candidate).split(external_node_path_default().sep);
2538
- const last = segments.length - 1;
2539
- segments[last] = renameFile(segments[last]);
2540
- return external_node_path_default().join(newFolder, ...segments);
2541
- };
2542
- const moduleFiles = 'page' === module.kind ? external_node_fs_default().readdirSync(oldFolder).map((name)=>external_node_path_default().join(oldFolder, name)).filter((file)=>external_node_fs_default().statSync(file).isFile() && ownsPath(file)) : react_module_move_walk(oldFolder);
2543
- const moves = new Map(moduleFiles.map((file)=>[
2544
- file,
2545
- movedPath(file) ?? file
2546
- ]));
2547
- const aliases = readAliases(projectRoot);
2548
- const resolve = (specifier, fromFile)=>{
2549
- if (specifier.startsWith('.')) return {
2550
- resolved: external_node_path_default().resolve(external_node_path_default().dirname(fromFile), specifier),
2551
- alias: void 0
2552
- };
2553
- const alias = aliases.find(({ prefix })=>specifier.startsWith(prefix));
2554
- return alias ? {
2555
- resolved: external_node_path_default().resolve(alias.target, specifier.slice(alias.prefix.length)),
2556
- alias
2557
- } : void 0;
2558
- };
2559
- const specifierFor = (fromFile, toPath, alias)=>{
2560
- const aliased = alias && toPosix(external_node_path_default().relative(alias.target, toPath));
2561
- if (aliased && !aliased.startsWith('..')) return `${alias.prefix}${aliased}`;
2562
- const relative = toPosix(external_node_path_default().relative(external_node_path_default().dirname(fromFile), toPath));
2563
- return relative.startsWith('.') ? relative : `./${relative}`;
2564
- };
2565
- const suffixes = 'page' === module.kind ? 'Page' : 'Widget|UIModel';
2566
- const classPattern = new RegExp(`(?<![\\w$])(use)?${escapeRegExp(module.ClassName)}(?=${suffixes})`, 'g');
2567
- const oldTitle = `Widgets/${module.name.split('/').map((segment)=>new NestedName(segment).ClassName).join('/')}`;
2568
- const titlePattern = new RegExp(`(['"\`])${escapeRegExp(oldTitle)}\\1`, 'g');
2569
- const newTitle = [
2570
- 'Widgets',
2571
- ...newName.classNameSegments
2572
- ].join('/');
2573
- const codeFiles = new Map(react_module_move_walk(projectRoot).filter((file)=>codeExtension.test(file)).map((file)=>[
2574
- file,
2575
- external_node_fs_default().readFileSync(file, 'utf8')
2576
- ]));
2577
- const barrels = new Set();
2578
- const isBarrel = (resolved)=>barrels.has(resolved.replace(codeExtension, ''));
2579
- for(let found = true; found;){
2580
- found = false;
2581
- for (const [file, content] of codeFiles){
2582
- if (moves.has(file) || isBarrel(file)) continue;
2583
- const reExportsModule = [
2584
- ...content.matchAll(reExportPattern)
2585
- ].some(([, , specifier])=>{
2586
- const resolution = resolve(specifier, file);
2587
- return !!resolution && (!!movedPath(resolution.resolved) || isBarrel(resolution.resolved));
2588
- });
2589
- if (reExportsModule) {
2590
- for (const importPath of importPaths(file))barrels.add(importPath);
2591
- found = true;
2592
- }
2593
- }
2594
- }
2595
- const rewrite = (content, oldFile, newFile)=>{
2596
- let referencesModule = false;
2597
- const rewritten = content.replace(specifierPattern, (match, keyword, quote, specifier)=>{
2598
- const resolution = resolve(specifier, oldFile);
2599
- if (!resolution) return match;
2600
- const moved = movedPath(resolution.resolved);
2601
- if (moved || isBarrel(resolution.resolved)) referencesModule = true;
2602
- if (!moved && oldFile === newFile) return match;
2603
- const next = specifierFor(newFile, moved ?? resolution.resolved, resolution.alias);
2604
- return `${keyword}${quote}${next}${quote}`;
2605
- });
2606
- if (!referencesModule && !moves.has(oldFile)) return content;
2607
- const renamed = rewritten.replace(classPattern, (_, use = '')=>`${use}${newClassName}`);
2608
- return moves.has(oldFile) && 'widget' === module.kind ? renamed.replace(titlePattern, (_, quote)=>`${quote}${newTitle}${quote}`) : renamed;
2609
- };
2610
- for (const [file, newFile] of moves)if (!codeFiles.has(file) && newFile !== file) new File(file).moveTo(newFile, reactFolder);
2611
- const updated = [];
2612
- for (const [file, content] of codeFiles){
2613
- const newFile = moves.get(file);
2614
- const next = rewrite(content, file, newFile ?? file);
2615
- if (newFile && newFile !== file) {
2616
- new File(newFile).data = next;
2617
- new File(file).delete(reactFolder);
2618
- } else if (next !== content) {
2619
- new File(file).update(next);
2620
- if (!newFile) updated.push(file);
2621
- }
2622
- }
2623
- return {
2624
- moves: [
2625
- ...moves
2626
- ].filter(([from, to])=>from !== to),
2627
- updated
2628
- };
2629
- };
2630
- const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
2631
- const reactFolder = presentationReactFolder.path;
2632
- const modules = findReactModules(reactFolder, kind);
2633
- if (!modules.length) return void console.log(`No ${kind}s generated by df-ps were found.`);
2634
- const module = await (0, prompts_namespaceObject.select)({
2635
- message: 'page' === kind ? 'Page:' : 'Widget:',
2636
- choices: modules.map((value)=>({
2637
- name: value.name,
2638
- value,
2639
- description: external_node_path_default().relative(reactFolder, value.path)
2640
- }))
2641
- });
2642
- const name = await (0, prompts_namespaceObject.input)({
2643
- message: 'New name (folders split by "/"):',
2644
- default: module.name,
2645
- validate: (value)=>validateMove(reactFolder, module, value)
2646
- });
2647
- const root = new ProjectRoot().path;
2648
- const { moves, updated } = moveReactModule(root, reactFolder, module, name);
2649
- if (!moves.length && !updated.length) return void console.log('Nothing to change.');
2650
- const relative = (file)=>external_node_path_default().relative(root, file);
2651
- console.log([
2652
- 'Files to move:',
2653
- ...moves.map(([from, to])=>` ${relative(from)} → ${relative(to)}`),
2654
- ...updated.length ? [
2655
- 'Files with updated imports:',
2656
- ...updated.map((file)=>` ${relative(file)}`)
2657
- ] : []
2658
- ].join('\n'));
2659
- if (!await (0, prompts_namespaceObject.confirm)({
2660
- message: 'Apply?',
2661
- default: true
2662
- })) {
2663
- discardPendingChanges();
2664
- console.log('Cancelled: nothing was written.');
2665
- }
2666
- };
2667
934
  const scaffoldNewAggregateUseCase = async (boundedContextFolder)=>{
2668
935
  const aggregateName = await (0, prompts_namespaceObject.input)({
2669
936
  message: 'Aggregate name:'
2670
937
  });
2671
- const aggregateNaming = new UnknownFormatNaming(aggregateName);
2672
- const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
938
+ const aggregateNaming = new unknown_format_naming_UnknownFormatNaming(aggregateName);
939
+ const scaffoldUnitTests = Boolean(config_file_ConfigFile.Instance.data.testingLibrary);
2673
940
  const withRepository = await (0, prompts_namespaceObject.confirm)({
2674
941
  message: 'With Repository'
2675
942
  });
@@ -2678,7 +945,7 @@ const scaffoldNewAggregateUseCase = async (boundedContextFolder)=>{
2678
945
  'aggregates',
2679
946
  aggregateName
2680
947
  ]);
2681
- const withTypes = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types');
948
+ const withTypes = config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types');
2682
949
  aggregatesFolder.createFile(`${aggregateNaming.fileName}.aggregate-root.ts`, withTypes ? `
2683
950
  import { domainType } from '@domain-first/types'
2684
951
 
@@ -2687,7 +954,7 @@ export class ${aggregateNaming.ClassName} extends domainType() {
2687
954
  }`.trim() : `export class ${aggregateNaming.ClassName} {}`);
2688
955
  const barrelFile = aggregatesFolder.createFile("index.ts", `export * from './${aggregateNaming.fileName}.aggregate-root'`);
2689
956
  if (scaffoldUnitTests) aggregatesFolder.createFile(`${aggregateNaming.fileName}.aggregate-root.spec.ts`, `
2690
- import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
957
+ import { describe, test, expect, beforeEach } from '${config_file_ConfigFile.Instance.data.testingLibrary}'
2691
958
  import { ${aggregateNaming.ClassName} } from './${aggregateNaming.fileName}.aggregate-root'
2692
959
 
2693
960
  let ${aggregateNaming.variableName}: ${aggregateNaming.ClassName}
@@ -2707,7 +974,7 @@ describe('${aggregateNaming.withSpaces}', () => {
2707
974
  barrelFile.addLine(`export * from './${aggregateNaming.fileName}-repository'`);
2708
975
  const infrastructureImplementationType = await (0, prompts_namespaceObject.input)({
2709
976
  message: 'Repository infrastructure implementation type:',
2710
- default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
977
+ default: config_file_ConfigFile.Instance.data.defaultPersistenceLayerImplementation
2711
978
  });
2712
979
  let addTestImplementation = false;
2713
980
  let testImplementationType = '';
@@ -2727,12 +994,12 @@ describe('${aggregateNaming.withSpaces}', () => {
2727
994
  testImplementationType
2728
995
  ].filter((x)=>!!x);
2729
996
  for (const implementation of implementationTypes){
2730
- const naming = new UnknownFormatNaming(implementation);
997
+ const naming = new unknown_format_naming_UnknownFormatNaming(implementation);
2731
998
  const repositoryFolder = infrastructureRepositoriesFolder.subitem([
2732
999
  naming.fileName
2733
1000
  ]);
2734
1001
  const repositoryFileName = `${naming.fileName}-${aggregateName}-repository.ts`;
2735
- if (usesInMemoryDb(implementation) && !ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
1002
+ if (usesInMemoryDb(implementation) && !config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
2736
1003
  const section = addInMemoryDbSection(aggregateNaming, aggregatesFolder.path);
2737
1004
  repositoryFolder.createFile(repositoryFileName, `
2738
1005
  ${inMemoryDbTypeImport(repositoryFolder.subitem([
@@ -2756,10 +1023,10 @@ export class ${naming.ClassName}${aggregateNaming.ClassName}Repository implement
2756
1023
  `.trim());
2757
1024
  }
2758
1025
  if (scaffoldUnitTests) {
2759
- const implementationNaming = new UnknownFormatNaming(infrastructureImplementationType);
1026
+ const implementationNaming = new unknown_format_naming_UnknownFormatNaming(infrastructureImplementationType);
2760
1027
  const specFile = aggregatesFolder.createFile(`${aggregateNaming.fileName}-repository.spec.ts`, `
2761
- import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
2762
- ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `import { wire${aggregateNaming.ClassName}Repository } from '../../../wiring/repositories/wire-${aggregateNaming.fileName}-repository'
1028
+ import { describe, test, expect, beforeEach } from '${config_file_ConfigFile.Instance.data.testingLibrary}'
1029
+ ${config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `import { wire${aggregateNaming.ClassName}Repository } from '../../../wiring/repositories/wire-${aggregateNaming.fileName}-repository'
2763
1030
  import type { ${aggregateNaming.ClassName}Repository } from './${aggregateNaming.fileName}-repository'` : `import { ${implementationNaming.ClassName}${aggregateNaming.ClassName}Repository } from '../../../infrastructure/repositories/${implementationNaming.fileName}/${implementationNaming.fileName}-${aggregateNaming.fileName}-repository'
2764
1031
 
2765
1032
  type ${aggregateNaming.ClassName}Repository = ${implementationNaming.ClassName}${aggregateNaming.ClassName}Repository`}
@@ -2767,29 +1034,29 @@ type ${aggregateNaming.ClassName}Repository = ${implementationNaming.ClassName}$
2767
1034
  let ${aggregateNaming.variableName}Repository: ${aggregateNaming.ClassName}Repository
2768
1035
 
2769
1036
  beforeEach(() => {
2770
- ${aggregateNaming.variableName}Repository = ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `wire${aggregateNaming.ClassName}Repository()` : `new ${implementationNaming.ClassName}${aggregateNaming.ClassName}Repository()`}
1037
+ ${aggregateNaming.variableName}Repository = ${config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `wire${aggregateNaming.ClassName}Repository()` : `new ${implementationNaming.ClassName}${aggregateNaming.ClassName}Repository()`}
2771
1038
  })
2772
1039
 
2773
1040
  describe('${aggregateNaming.withSpaces} repository', () => {
2774
- test('can be ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? 'wired' : 'created via constructor'}', () => {
1041
+ test('can be ${config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? 'wired' : 'created via constructor'}', () => {
2775
1042
  expect(${aggregateNaming.variableName}Repository).toBeDefined()
2776
1043
  })
2777
1044
  })
2778
1045
  `.trim());
2779
- if (!ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') && usesInMemoryDb(infrastructureImplementationType)) passInMemoryDb(specFile, `${implementationNaming.ClassName}${aggregateNaming.ClassName}Repository`);
1046
+ if (!config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') && usesInMemoryDb(infrastructureImplementationType)) passInMemoryDb(specFile, `${implementationNaming.ClassName}${aggregateNaming.ClassName}Repository`);
2780
1047
  }
2781
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
2782
- const implementationNaming = new UnknownFormatNaming(infrastructureImplementationType);
2783
- const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
1048
+ if (config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
1049
+ const implementationNaming = new unknown_format_naming_UnknownFormatNaming(infrastructureImplementationType);
1050
+ const testImplementationNaming = new unknown_format_naming_UnknownFormatNaming(testImplementationType);
2784
1051
  const wireFile = boundedContextFolder.subitem([
2785
1052
  'wiring',
2786
1053
  'repositories'
2787
1054
  ]).createFile(`wire-${aggregateNaming.fileName}-repository.ts`, `
2788
1055
  import { wireClass } from '@domain-first/wire'
2789
- import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
2790
- ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${aggregateNaming.ClassName}Repository } from '../../infrastructure/repositories/${fileName}/${fileName}-${aggregateNaming.fileName}-repository'`).join('\n')}
1056
+ import { envBranchedWire } from '../../../../shared-kernel/wiring/env-branched-wire'
1057
+ ${implementationTypes.map((x)=>new unknown_format_naming_UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${aggregateNaming.ClassName}Repository } from '../../infrastructure/repositories/${fileName}/${fileName}-${aggregateNaming.fileName}-repository'`).join('\n')}
2791
1058
 
2792
- ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${aggregateNaming.ClassName}Repository, [])`).join('\n\n')}
1059
+ ${implementationTypes.map((x)=>new unknown_format_naming_UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${aggregateNaming.ClassName}Repository, [])`).join('\n\n')}
2793
1060
 
2794
1061
  export const wire${aggregateNaming.ClassName}Repository = envBranchedWire({
2795
1062
  test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}Implementation,
@@ -2799,7 +1066,7 @@ export const wire${aggregateNaming.ClassName}Repository = envBranchedWire({
2799
1066
  `.trim());
2800
1067
  await wireNewModuleDependencies(boundedContextFolder, wireFile, (implementation, dependency)=>{
2801
1068
  if (!isInMemoryDb(dependency)) return false;
2802
- keepInMemoryDbSection(new File(implementation.file), addInMemoryDbSection(aggregateNaming, aggregatesFolder.path));
1069
+ keepInMemoryDbSection(new file_system_File(implementation.file), addInMemoryDbSection(aggregateNaming, aggregatesFolder.path));
2803
1070
  wireInMemoryDb(wireFile, implementation.className);
2804
1071
  return true;
2805
1072
  });
@@ -2810,8 +1077,8 @@ const scaffoldNewApplicationPort = async (boundedContextFolder)=>{
2810
1077
  const name = await (0, prompts_namespaceObject.input)({
2811
1078
  message: 'Name: '
2812
1079
  });
2813
- const naming = new UnknownFormatNaming(name);
2814
- const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
1080
+ const naming = new unknown_format_naming_UnknownFormatNaming(name);
1081
+ const scaffoldUnitTests = Boolean(config_file_ConfigFile.Instance.data.testingLibrary);
2815
1082
  const wiringFolder = boundedContextFolder.subitem([
2816
1083
  'wiring',
2817
1084
  'application-ports'
@@ -2846,7 +1113,7 @@ export abstract class ${naming.ClassName} {
2846
1113
  testImplementationType
2847
1114
  ].filter((x)=>!!x);
2848
1115
  for (const implementation of implementationTypes){
2849
- const currentNaming = new UnknownFormatNaming(`${implementation}-${naming.fileName}`);
1116
+ const currentNaming = new unknown_format_naming_UnknownFormatNaming(`${implementation}-${naming.fileName}`);
2850
1117
  infrastructureFolder.subitem([
2851
1118
  implementation
2852
1119
  ]).createFile(`${currentNaming.fileName}.ts`, `
@@ -2858,10 +1125,10 @@ export class ${currentNaming.ClassName} extends ${naming.ClassName} {
2858
1125
  `.trim());
2859
1126
  }
2860
1127
  if (scaffoldUnitTests) {
2861
- const implementationNaming = new UnknownFormatNaming(implementationType);
1128
+ const implementationNaming = new unknown_format_naming_UnknownFormatNaming(implementationType);
2862
1129
  applicationPortsFolder.createFile(`${naming.fileName}.spec.ts`, `
2863
- import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
2864
- ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `import { type ${naming.ClassName} } from './${naming.fileName}'
1130
+ import { describe, test, expect, beforeEach } from '${config_file_ConfigFile.Instance.data.testingLibrary}'
1131
+ ${config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `import { type ${naming.ClassName} } from './${naming.fileName}'
2865
1132
  import { wire${naming.ClassName} } from '../../wiring/application-ports/wire-${naming.fileName}'` : `import { ${implementationNaming.ClassName}${naming.ClassName} } from '../../infrastructure/application-adapters/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}'
2866
1133
 
2867
1134
  type ${naming.ClassName} = ${implementationNaming.ClassName}${naming.ClassName}`}
@@ -2869,34 +1136,34 @@ type ${naming.ClassName} = ${implementationNaming.ClassName}${naming.ClassName}`
2869
1136
  let ${naming.variableName}: ${naming.ClassName}
2870
1137
 
2871
1138
  beforeEach(() => {
2872
- ${naming.variableName} = ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `wire${naming.ClassName}()` : `new ${implementationNaming.ClassName}${naming.ClassName}()`}
1139
+ ${naming.variableName} = ${config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? `wire${naming.ClassName}()` : `new ${implementationNaming.ClassName}${naming.ClassName}()`}
2873
1140
  })
2874
1141
 
2875
1142
  describe('${naming.withSpaces}', () => {
2876
- test('can be ${ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? 'wired' : 'created via constructor'}', () => {
1143
+ test('can be ${config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? 'wired' : 'created via constructor'}', () => {
2877
1144
  expect(${naming.variableName}).toBeDefined()
2878
1145
  })
2879
1146
  })
2880
1147
  `.trim());
2881
1148
  }
2882
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
1149
+ if (config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
2883
1150
  const wireFile = wiringFolder.createFile(`wire-${naming.fileName}.ts`, `
2884
1151
  import { wireClass } from '@domain-first/wire'
2885
- import { envBranchedWire } from '../../../${'shared' === boundedContextFolder.name ? '' : '../'}shared/wiring/env-branched-wire'
1152
+ import { envBranchedWire } from '../../../${'shared-kernel' === boundedContextFolder.name ? '' : '../'}shared-kernel/wiring/env-branched-wire'
2886
1153
  ${implementationTypes.map((x)=>({
2887
- naming: new UnknownFormatNaming(`${x}-${naming.fileName}`),
1154
+ naming: new unknown_format_naming_UnknownFormatNaming(`${x}-${naming.fileName}`),
2888
1155
  implementation: x
2889
1156
  })).map(({ naming: { ClassName, fileName }, implementation })=>`import { ${ClassName} } from '../../infrastructure/application-adapters/${implementation}/${fileName}'`).join('\n')}
2890
1157
 
2891
1158
  ${implementationTypes.map((x)=>({
2892
- naming: new UnknownFormatNaming(`${x}-${naming.fileName}`),
1159
+ naming: new unknown_format_naming_UnknownFormatNaming(`${x}-${naming.fileName}`),
2893
1160
  implementation: x
2894
- })).map(({ naming: { ClassName }, implementation })=>`const wire${new UnknownFormatNaming(implementation).ClassName}Implementation = wireClass(${ClassName}, [])`).join('\n\n')}
1161
+ })).map(({ naming: { ClassName }, implementation })=>`const wire${new unknown_format_naming_UnknownFormatNaming(implementation).ClassName}Implementation = wireClass(${ClassName}, [])`).join('\n\n')}
2895
1162
 
2896
1163
  export const wire${naming.ClassName} = envBranchedWire({
2897
- test: wire${new UnknownFormatNaming(`${implementationTypes.at(-1)}-implementation`).ClassName},
2898
- development: wire${new UnknownFormatNaming(`${implementationTypes.at(0)}-implementation`).ClassName},
2899
- production: wire${new UnknownFormatNaming(`${implementationTypes.at(0)}-implementation`).ClassName}
1164
+ test: wire${new unknown_format_naming_UnknownFormatNaming(`${implementationTypes.at(-1)}-implementation`).ClassName},
1165
+ development: wire${new unknown_format_naming_UnknownFormatNaming(`${implementationTypes.at(0)}-implementation`).ClassName},
1166
+ production: wire${new unknown_format_naming_UnknownFormatNaming(`${implementationTypes.at(0)}-implementation`).ClassName}
2900
1167
  })
2901
1168
 
2902
1169
  `.trim());
@@ -2907,9 +1174,9 @@ const scaffoldNewApplicationService = async (boundedContextFolder)=>{
2907
1174
  const name = await (0, prompts_namespaceObject.input)({
2908
1175
  message: 'Name: '
2909
1176
  });
2910
- const naming = new UnknownFormatNaming(name);
2911
- const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
2912
- const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
1177
+ const naming = new unknown_format_naming_UnknownFormatNaming(name);
1178
+ const scaffoldUnitTests = Boolean(config_file_ConfigFile.Instance.data.testingLibrary);
1179
+ const withWiring = config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
2913
1180
  const wiringFolder = boundedContextFolder.subitem([
2914
1181
  'wiring',
2915
1182
  'application-services'
@@ -2924,7 +1191,7 @@ export class ${naming.ClassName}ApplicationService {
2924
1191
  }
2925
1192
  `.trim());
2926
1193
  if (scaffoldUnitTests) applicationServicesFolder.createFile(`${naming.fileName}-application-service.spec.ts`, `
2927
- import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
1194
+ import { describe, test, expect, beforeEach } from '${config_file_ConfigFile.Instance.data.testingLibrary}'
2928
1195
  ${withWiring ? `import { type ${naming.ClassName}ApplicationService } from './${naming.fileName}-application-service'
2929
1196
  import { wire${naming.ClassName}ApplicationService } from '../../wiring/application-services/wire-${naming.fileName}-application-service'` : `import { ${naming.ClassName}ApplicationService } from './${naming.fileName}-application-service'`}
2930
1197
 
@@ -2958,21 +1225,13 @@ const scaffoldNewBoundedContextUseCase = async ()=>{
2958
1225
  message: 'Name:',
2959
1226
  validate: (x)=>!!x.length
2960
1227
  });
2961
- const { path } = new ProjectRoot();
2962
- const rootFolder = new Folder(path);
1228
+ const { path } = new project_root_ProjectRoot();
1229
+ const rootFolder = new file_system_Folder(path);
2963
1230
  const folder = rootFolder.subitem([
2964
- ConfigFile.Instance.data.rootFolder,
1231
+ config_file_ConfigFile.Instance.data.rootFolder,
2965
1232
  'bounded-contexts',
2966
1233
  name
2967
1234
  ]);
2968
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/errors')) folder.subitem([
2969
- 'domain',
2970
- 'errors'
2971
- ]).createFile('index.ts', `
2972
- import { errorNamespace } from '@domain-first/errors'
2973
-
2974
- export const ${new UnknownFormatNaming(name).ClassName}Errors = errorNamespace('${name}')
2975
- `.trim());
2976
1235
  folder.createIfNotExisted();
2977
1236
  };
2978
1237
  const scaffoldNewCommand = async (boundedContextFolder)=>{
@@ -2987,12 +1246,12 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
2987
1246
  const commandName = await (0, prompts_namespaceObject.input)({
2988
1247
  message: 'Name: '
2989
1248
  });
2990
- const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
2991
- const naming = new UnknownFormatNaming(commandName);
2992
- const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
1249
+ const scaffoldUnitTests = Boolean(config_file_ConfigFile.Instance.data.testingLibrary);
1250
+ const naming = new unknown_format_naming_UnknownFormatNaming(commandName);
1251
+ const withWiring = config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
2993
1252
  const implementationType = await (0, prompts_namespaceObject.input)({
2994
1253
  message: 'Command infrastructure implementation type:',
2995
- default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
1254
+ default: config_file_ConfigFile.Instance.data.defaultPersistenceLayerImplementation
2996
1255
  });
2997
1256
  let addTestImplementation = false;
2998
1257
  let testImplementationType = '';
@@ -3008,10 +1267,10 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
3008
1267
  testImplementationType
3009
1268
  ].filter((x)=>!!x);
3010
1269
  for (const implementation of implementationTypes){
3011
- const formatNaming = new UnknownFormatNaming(implementation);
1270
+ const formatNaming = new unknown_format_naming_UnknownFormatNaming(implementation);
3012
1271
  const implementationFile = infrastructureFolder.subitem([
3013
1272
  formatNaming.fileName
3014
- ]).createFile(`${formatNaming.fileName}-${naming.fileName}-command.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
1273
+ ]).createFile(`${formatNaming.fileName}-${naming.fileName}-command.ts`, config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
3015
1274
  import { defineHandler } from '@domain-first/handlers'
3016
1275
  import { ${naming.ClassName}Command } from '../../../application/commands/${naming.fileName}-command'
3017
1276
 
@@ -3039,7 +1298,7 @@ export class ${formatNaming.ClassName}${naming.ClassName}Command extends ${namin
3039
1298
  `.trim());
3040
1299
  if (!withWiring && usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Command`);
3041
1300
  }
3042
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.createFile(`${naming.fileName}-command.ts`, `
1301
+ if (config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) commandsFolder.createFile(`${naming.fileName}-command.ts`, `
3043
1302
  import type { Handler } from '@domain-first/handlers'
3044
1303
 
3045
1304
  export abstract class ${naming.ClassName}Command {
@@ -3054,9 +1313,9 @@ export abstract class ${naming.ClassName}Command {
3054
1313
 
3055
1314
  }`.trim());
3056
1315
  if (scaffoldUnitTests) {
3057
- const implementationNaming = new UnknownFormatNaming(implementationType);
1316
+ const implementationNaming = new unknown_format_naming_UnknownFormatNaming(implementationType);
3058
1317
  const specFile = commandsFolder.createFile(`${naming.fileName}-command.spec.ts`, `
3059
- import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
1318
+ import { describe, test, expect, beforeEach } from '${config_file_ConfigFile.Instance.data.testingLibrary}'
3060
1319
  ${withWiring ? `import { type ${naming.ClassName}Command } from './${naming.fileName}-command'
3061
1320
  import { wire${naming.ClassName}Command } from '../../wiring/commands/wire-${naming.fileName}-command'` : `import { ${implementationNaming.ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}-command'
3062
1321
 
@@ -3076,18 +1335,18 @@ describe('${naming.withSpaces} command', () => {
3076
1335
  `.trim());
3077
1336
  if (!withWiring && usesInMemoryDb(implementationType)) passInMemoryDb(specFile, `${implementationNaming.ClassName}${naming.ClassName}Command`);
3078
1337
  }
3079
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
3080
- const implementationNaming = new UnknownFormatNaming(implementationType);
3081
- const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
1338
+ if (config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
1339
+ const implementationNaming = new unknown_format_naming_UnknownFormatNaming(implementationType);
1340
+ const testImplementationNaming = new unknown_format_naming_UnknownFormatNaming(testImplementationType);
3082
1341
  const wireFile = boundedContextFolder.subitem([
3083
1342
  'wiring',
3084
1343
  'commands'
3085
1344
  ]).createFile(`wire-${naming.fileName}-command.ts`, `
3086
1345
  import { wireClass } from '@domain-first/wire'
3087
- import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
3088
- ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${fileName}/${fileName}-${naming.fileName}-command'`).join('\n')}
1346
+ import { envBranchedWire } from '../../../../shared-kernel/wiring/env-branched-wire'
1347
+ ${implementationTypes.map((x)=>new unknown_format_naming_UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Command } from '../../infrastructure/commands/${fileName}/${fileName}-${naming.fileName}-command'`).join('\n')}
3089
1348
 
3090
- ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${naming.ClassName}Command, [])`).join('\n\n')}
1349
+ ${implementationTypes.map((x)=>new unknown_format_naming_UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${naming.ClassName}Command, [])`).join('\n\n')}
3091
1350
 
3092
1351
  export const wire${naming.ClassName}Command = envBranchedWire({
3093
1352
  test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}Implementation,
@@ -3103,7 +1362,7 @@ const scaffoldNewDomainObject = async (boundedContextFolder, kind)=>{
3103
1362
  const name = await (0, prompts_namespaceObject.input)({
3104
1363
  message: 'Name: '
3105
1364
  });
3106
- const naming = new UnknownFormatNaming(name);
1365
+ const naming = new unknown_format_naming_UnknownFormatNaming(name);
3107
1366
  const aggregatesFolder = boundedContextFolder.subitem([
3108
1367
  'domain',
3109
1368
  'aggregates'
@@ -3125,7 +1384,7 @@ const scaffoldNewDomainObject = async (boundedContextFolder, kind)=>{
3125
1384
  kindFolderName
3126
1385
  ]);
3127
1386
  const fileName = `${naming.fileName}.${kind}`;
3128
- const withTypes = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types');
1387
+ const withTypes = config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/types');
3129
1388
  folder.createFile(`${fileName}.ts`, withTypes ? `
3130
1389
  import { domainType } from '@domain-first/types'
3131
1390
 
@@ -3135,7 +1394,7 @@ export class ${naming.ClassName} extends domainType() {
3135
1394
  if (aggregate !== noAggregate) aggregatesFolder.subitem([
3136
1395
  aggregate
3137
1396
  ]).file('index.ts').addLineIfMissing(`export * from './${kindFolderName}/${fileName}'`);
3138
- const { testingLibrary } = ConfigFile.Instance.data;
1397
+ const { testingLibrary } = config_file_ConfigFile.Instance.data;
3139
1398
  if (testingLibrary) folder.createFile(`${fileName}.spec.ts`, `
3140
1399
  import { describe, test, expect, beforeEach } from '${testingLibrary}'
3141
1400
  import { ${naming.ClassName} } from './${fileName}'
@@ -3157,9 +1416,9 @@ const scaffoldNewDomainService = async (boundedContextFolder)=>{
3157
1416
  const portName = await (0, prompts_namespaceObject.input)({
3158
1417
  message: 'Name:'
3159
1418
  });
3160
- const naming = new UnknownFormatNaming(portName);
3161
- const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
3162
- const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
1419
+ const naming = new unknown_format_naming_UnknownFormatNaming(portName);
1420
+ const scaffoldUnitTests = Boolean(config_file_ConfigFile.Instance.data.testingLibrary);
1421
+ const withWiring = config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
3163
1422
  const domainServicesFolder = boundedContextFolder.subitem([
3164
1423
  'domain',
3165
1424
  'services'
@@ -3170,7 +1429,7 @@ export class ${naming.ClassName}DomainService {
3170
1429
  }
3171
1430
  `.trim());
3172
1431
  if (scaffoldUnitTests) domainServicesFolder.createFile(`${naming.fileName}-domain-service.spec.ts`, `
3173
- import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
1432
+ import { describe, test, expect, beforeEach } from '${config_file_ConfigFile.Instance.data.testingLibrary}'
3174
1433
  ${withWiring ? `import { type ${naming.ClassName}DomainService } from './${naming.fileName}-domain-service'
3175
1434
  import { wire${naming.ClassName}DomainService } from '../../wiring/domain-services/wire-${naming.fileName}-domain-service'` : `import { ${naming.ClassName}DomainService } from './${naming.fileName}-domain-service'`}
3176
1435
 
@@ -3203,16 +1462,28 @@ export const wire${naming.ClassName}DomainService = wireClass(
3203
1462
  }
3204
1463
  };
3205
1464
  const errorNames = (boundedContextFolder)=>{
3206
- const isShared = boundedContextFolder.path === new Folder(new ProjectRoot().path).subitem([
3207
- ConfigFile.Instance.data.rootFolder,
3208
- 'shared'
1465
+ const isShared = boundedContextFolder.path === new file_system_Folder(new project_root_ProjectRoot().path).subitem([
1466
+ config_file_ConfigFile.Instance.data.rootFolder,
1467
+ 'shared-kernel'
3209
1468
  ]).path;
3210
1469
  return {
3211
- namespace: (namespaceName)=>`${namespaceName}${isShared ? 'Shared' : ''}Errors`,
3212
- error: (errorName)=>`${errorName}${isShared ? 'SharedError' : ''}`
1470
+ namespace: (namespaceName)=>`${namespaceName}${isShared ? 'SharedKernel' : ''}Errors`,
1471
+ error: (errorName)=>`${errorName}${isShared ? 'SharedKernelError' : ''}`
3213
1472
  };
3214
1473
  };
3215
- const exportedNamespace = (file, fallback)=>/export\s+const\s+(\w+)\s*=\s*errorNamespace\b/.exec(file.data)?.[1] ?? fallback;
1474
+ const namespacePattern = /export\s+const\s+(\w+)\s*=\s*errorNamespace\b/;
1475
+ const exportedNamespace = (file, fallback)=>namespacePattern.exec(file.data)?.[1] ?? fallback;
1476
+ const rootNamespace = (indexFile, namespace, code)=>{
1477
+ const content = indexFile.exists ? indexFile.data.trim() : '';
1478
+ const existing = namespacePattern.exec(content)?.[1];
1479
+ if (existing) return existing;
1480
+ indexFile.update([
1481
+ "import { errorNamespace } from '@domain-first/errors'",
1482
+ `export const ${namespace} = errorNamespace('${code}')`,
1483
+ content
1484
+ ].filter((x)=>!!x).join('\n\n'));
1485
+ return namespace;
1486
+ };
3216
1487
  const errorClass = (className, namespace, code)=>`export class ${className} extends ${namespace}.define('${code}') {}`;
3217
1488
  const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
3218
1489
  const currentErrorFolder = boundedContextFolder.subitem([
@@ -3220,7 +1491,7 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
3220
1491
  'errors'
3221
1492
  ]);
3222
1493
  const names = errorNames(boundedContextFolder);
3223
- const contextNaming = new UnknownFormatNaming(boundedContextFolder.name);
1494
+ const contextNaming = new unknown_format_naming_UnknownFormatNaming(boundedContextFolder.name);
3224
1495
  const currentErrorNamespaces = currentErrorFolder.content.fileNames.filter((x)=>'index' !== x);
3225
1496
  const variants = [
3226
1497
  'New error without namespace',
@@ -3235,16 +1506,16 @@ const scaffoldNewErrorUseCase = async (boundedContextFolder)=>{
3235
1506
  const errorName = await (0, prompts_namespaceObject.input)({
3236
1507
  message: 'Error name:'
3237
1508
  });
3238
- const naming = new UnknownFormatNaming(errorName);
1509
+ const naming = new unknown_format_naming_UnknownFormatNaming(errorName);
3239
1510
  const indexFile = currentErrorFolder.file('index.ts');
3240
- indexFile.addLineIfMissing(errorClass(names.error(naming.ClassName), exportedNamespace(indexFile, `${contextNaming.ClassName}Errors`), naming.fileName), '\n\n');
1511
+ indexFile.addLineIfMissing(errorClass(names.error(naming.ClassName), rootNamespace(indexFile, `${contextNaming.ClassName}Errors`, boundedContextFolder.name), naming.fileName), '\n\n');
3241
1512
  return;
3242
1513
  }
3243
1514
  if ('New namespace' === selectedVariant) {
3244
1515
  const namespaceName = await (0, prompts_namespaceObject.input)({
3245
1516
  message: 'Namespace name:'
3246
1517
  });
3247
- const { ClassName, fileName } = new UnknownFormatNaming(namespaceName);
1518
+ const { ClassName, fileName } = new unknown_format_naming_UnknownFormatNaming(namespaceName);
3248
1519
  if (!currentErrorFolder.file(`${fileName}.ts`).exists) currentErrorFolder.createFile(`${fileName}.ts`, `
3249
1520
  import { errorNamespace } from '@domain-first/errors'
3250
1521
 
@@ -3254,11 +1525,11 @@ export const ${names.namespace(ClassName)} = errorNamespace('${boundedContextFol
3254
1525
  return;
3255
1526
  }
3256
1527
  const namespace = selectedVariant.substring(23);
3257
- const namespaceNaming = new UnknownFormatNaming(namespace);
1528
+ const namespaceNaming = new unknown_format_naming_UnknownFormatNaming(namespace);
3258
1529
  const errorName = await (0, prompts_namespaceObject.input)({
3259
1530
  message: 'Error name:'
3260
1531
  });
3261
- const { ClassName, fileName } = new UnknownFormatNaming(errorName);
1532
+ const { ClassName, fileName } = new unknown_format_naming_UnknownFormatNaming(errorName);
3262
1533
  const namespaceFile = currentErrorFolder.file(`${namespace}.ts`);
3263
1534
  namespaceFile.addLineIfMissing(errorClass(names.error(`${namespaceNaming.ClassName}${ClassName}`), exportedNamespace(namespaceFile, names.namespace(namespaceNaming.ClassName)), fileName), '\n\n');
3264
1535
  };
@@ -3279,7 +1550,7 @@ const scaffoldNewHandlersRestEndpoint = async (boundedContextFolder)=>{
3279
1550
  controller = await (0, prompts_namespaceObject.input)({
3280
1551
  message: 'Name: '
3281
1552
  });
3282
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
1553
+ if (config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
3283
1554
  boundedContextFolder.subitem([
3284
1555
  'wiring',
3285
1556
  'presentation',
@@ -3325,18 +1596,18 @@ export const restHandlers = restWires.map(x => x().handle)
3325
1596
  ...routeSegments,
3326
1597
  method,
3327
1598
  'endpoint'
3328
- ].map((segment)=>segment.startsWith(':') ? pathParameterAsName(segment) : new UnknownFormatNaming(segment).ClassName).join('');
3329
- const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
3330
- const endpointGenerator = findRestEndpointGenerator(boundedContextFolder.subitem([
1599
+ ].map((segment)=>segment.startsWith(':') ? pathParameterAsName(segment) : new unknown_format_naming_UnknownFormatNaming(segment).ClassName).join('');
1600
+ const withWiring = config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
1601
+ const endpointGenerator = rest_endpoint_generator_findRestEndpointGenerator(boundedContextFolder.subitem([
3331
1602
  '..',
3332
1603
  '..',
3333
- 'shared'
1604
+ 'shared-kernel'
3334
1605
  ]));
3335
1606
  const handler = withWiring ? await promptEndpointHandler(boundedContextFolder) : void 0;
3336
1607
  const endpointFile = external_node_path_default().join(endpointFolder.path, `${method.toUpperCase()}.ts`);
3337
1608
  endpointFolder.createFile(`${method.toUpperCase()}.ts`, `
3338
- ${endpointGenerator ? `import type { ${endpointGenerator.typeName} } from '${relativeImport(endpointFile, endpointGenerator.typeFile)}'` : "import { EndpointGenerator } from '@domain-first/handlers-rest'"}${handler ? `
3339
- import type { ${handler.typeName} } from '${relativeImport(endpointFile, handler.typeFile)}'` : ''}
1609
+ ${endpointGenerator ? `import type { ${endpointGenerator.typeName} } from '${wiring_relativeImport(endpointFile, endpointGenerator.typeFile)}'` : "import { EndpointGenerator } from '@domain-first/handlers-rest'"}${handler ? `
1610
+ import type { ${handler.typeName} } from '${wiring_relativeImport(endpointFile, handler.typeFile)}'` : ''}
3340
1611
 
3341
1612
  export class ${endpointClassName} {
3342
1613
  constructor(
@@ -3360,7 +1631,7 @@ export class ${endpointClassName} {
3360
1631
  controller
3361
1632
  ]);
3362
1633
  const wireNameBase = `wire-${nameBase}`;
3363
- const wireNaming = new UnknownFormatNaming(wireNameBase);
1634
+ const wireNaming = new unknown_format_naming_UnknownFormatNaming(wireNameBase);
3364
1635
  const wireFile = external_node_path_default().join(wiringFolder.path, `${wireNaming.fileName}.ts`);
3365
1636
  const dependencies = endpointGenerator ? [
3366
1637
  endpointGenerator,
@@ -3368,8 +1639,8 @@ export class ${endpointClassName} {
3368
1639
  ].filter((x)=>!!x) : [];
3369
1640
  wiringFolder.createFile(`${wireNaming.fileName}.ts`, `
3370
1641
  import { wireClass } from '@domain-first/wire'
3371
- import { ${endpointClassName} } from '${relativeImport(wireFile, endpointFile)}'
3372
- ${dependencies.map((x)=>`import { ${x.wireName} } from '${relativeImport(wireFile, x.wireFile)}'`).join('\n')}
1642
+ import { ${endpointClassName} } from '${wiring_relativeImport(wireFile, endpointFile)}'
1643
+ ${dependencies.map((x)=>`import { ${x.wireName} } from '${wiring_relativeImport(wireFile, x.wireFile)}'`).join('\n')}
3373
1644
 
3374
1645
  export const wire${endpointClassName} = wireClass(
3375
1646
  ${endpointClassName},
@@ -3383,9 +1654,9 @@ const scaffoldNewInfrastructureService = async (boundedContextFolder)=>{
3383
1654
  const name = await (0, prompts_namespaceObject.input)({
3384
1655
  message: 'Name: '
3385
1656
  });
3386
- const naming = new UnknownFormatNaming(name);
3387
- const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
3388
- const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
1657
+ const naming = new unknown_format_naming_UnknownFormatNaming(name);
1658
+ const scaffoldUnitTests = Boolean(config_file_ConfigFile.Instance.data.testingLibrary);
1659
+ const withWiring = config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
3389
1660
  const wiringFolder = boundedContextFolder.subitem([
3390
1661
  'wiring',
3391
1662
  'infrastructure-services'
@@ -3400,7 +1671,7 @@ export class ${naming.ClassName}InfrastructureService {
3400
1671
  }
3401
1672
  `.trim());
3402
1673
  if (scaffoldUnitTests) infrastructureServicesFolder.createFile(`${naming.fileName}-infrastructure-service.spec.ts`, `
3403
- import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
1674
+ import { describe, test, expect, beforeEach } from '${config_file_ConfigFile.Instance.data.testingLibrary}'
3404
1675
  ${withWiring ? `import { type ${naming.ClassName}InfrastructureService } from './${naming.fileName}-infrastructure-service'
3405
1676
  import { wire${naming.ClassName}InfrastructureService } from '../../wiring/infrastructure-services/wire-${naming.fileName}-infrastructure-service'` : `import { ${naming.ClassName}InfrastructureService } from './${naming.fileName}-infrastructure-service'`}
3406
1677
 
@@ -3441,12 +1712,12 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
3441
1712
  const queryName = await (0, prompts_namespaceObject.input)({
3442
1713
  message: 'Name: '
3443
1714
  });
3444
- const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
3445
- const naming = new UnknownFormatNaming(queryName);
3446
- const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
1715
+ const scaffoldUnitTests = Boolean(config_file_ConfigFile.Instance.data.testingLibrary);
1716
+ const naming = new unknown_format_naming_UnknownFormatNaming(queryName);
1717
+ const withWiring = config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
3447
1718
  const implementationType = await (0, prompts_namespaceObject.input)({
3448
1719
  message: 'Query infrastructure implementation type:',
3449
- default: ConfigFile.Instance.data.defaultPersistenceLayerImplementation
1720
+ default: config_file_ConfigFile.Instance.data.defaultPersistenceLayerImplementation
3450
1721
  });
3451
1722
  let addTestImplementation = false;
3452
1723
  let testImplementationType = '';
@@ -3462,10 +1733,10 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
3462
1733
  testImplementationType
3463
1734
  ].filter((x)=>!!x);
3464
1735
  for (const implementation of implementationTypes){
3465
- const formatNaming = new UnknownFormatNaming(implementation);
1736
+ const formatNaming = new unknown_format_naming_UnknownFormatNaming(implementation);
3466
1737
  const implementationFile = infrastructureFolder.subitem([
3467
1738
  formatNaming.fileName
3468
- ]).createFile(`${formatNaming.fileName}-${naming.fileName}-query.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
1739
+ ]).createFile(`${formatNaming.fileName}-${naming.fileName}-query.ts`, config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
3469
1740
  import { defineHandler } from '@domain-first/handlers'
3470
1741
  import { ${naming.ClassName}Query } from '../../../application/queries/${naming.fileName}-query'
3471
1742
 
@@ -3493,7 +1764,7 @@ export class ${formatNaming.ClassName}${naming.ClassName}Query extends ${naming.
3493
1764
  `.trim());
3494
1765
  if (!withWiring && usesInMemoryDb(implementation)) injectInMemoryDb(implementationFile, `${formatNaming.ClassName}${naming.ClassName}Query`);
3495
1766
  }
3496
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.createFile(`${naming.fileName}-query.ts`, `
1767
+ if (config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers')) queriesFolder.createFile(`${naming.fileName}-query.ts`, `
3497
1768
  import type { Handler } from '@domain-first/handlers'
3498
1769
 
3499
1770
  export abstract class ${naming.ClassName}Query {
@@ -3508,9 +1779,9 @@ export abstract class ${naming.ClassName}Query {
3508
1779
 
3509
1780
  }`.trim());
3510
1781
  if (scaffoldUnitTests) {
3511
- const implementationNaming = new UnknownFormatNaming(implementationType);
1782
+ const implementationNaming = new unknown_format_naming_UnknownFormatNaming(implementationType);
3512
1783
  const specFile = queriesFolder.createFile(`${naming.fileName}-query.spec.ts`, `
3513
- import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
1784
+ import { describe, test, expect, beforeEach } from '${config_file_ConfigFile.Instance.data.testingLibrary}'
3514
1785
  ${withWiring ? `import { type ${naming.ClassName}Query } from './${naming.fileName}-query'
3515
1786
  import { wire${naming.ClassName}Query } from '../../wiring/queries/wire-${naming.fileName}-query'` : `import { ${implementationNaming.ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${implementationNaming.fileName}/${implementationNaming.fileName}-${naming.fileName}-query'
3516
1787
 
@@ -3530,18 +1801,18 @@ describe('${naming.withSpaces} query', () => {
3530
1801
  `.trim());
3531
1802
  if (!withWiring && usesInMemoryDb(implementationType)) passInMemoryDb(specFile, `${implementationNaming.ClassName}${naming.ClassName}Query`);
3532
1803
  }
3533
- if (ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
3534
- const implementationNaming = new UnknownFormatNaming(implementationType);
3535
- const testImplementationNaming = new UnknownFormatNaming(testImplementationType);
1804
+ if (config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire')) {
1805
+ const implementationNaming = new unknown_format_naming_UnknownFormatNaming(implementationType);
1806
+ const testImplementationNaming = new unknown_format_naming_UnknownFormatNaming(testImplementationType);
3536
1807
  const wireFile = boundedContextFolder.subitem([
3537
1808
  'wiring',
3538
1809
  'queries'
3539
1810
  ]).createFile(`wire-${naming.fileName}-query.ts`, `
3540
1811
  import { wireClass } from '@domain-first/wire'
3541
- import { envBranchedWire } from '../../../../shared/wiring/env-branched-wire'
3542
- ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${fileName}/${fileName}-${naming.fileName}-query'`).join('\n')}
1812
+ import { envBranchedWire } from '../../../../shared-kernel/wiring/env-branched-wire'
1813
+ ${implementationTypes.map((x)=>new unknown_format_naming_UnknownFormatNaming(x)).map(({ ClassName, fileName })=>`import { ${ClassName}${naming.ClassName}Query } from '../../infrastructure/queries/${fileName}/${fileName}-${naming.fileName}-query'`).join('\n')}
3543
1814
 
3544
- ${implementationTypes.map((x)=>new UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${naming.ClassName}Query, [])`).join('\n\n')}
1815
+ ${implementationTypes.map((x)=>new unknown_format_naming_UnknownFormatNaming(x)).map(({ ClassName })=>`const wire${ClassName}Implementation = wireClass(${ClassName}${naming.ClassName}Query, [])`).join('\n\n')}
3545
1816
 
3546
1817
  export const wire${naming.ClassName}Query = envBranchedWire({
3547
1818
  test: wire${addTestImplementation ? testImplementationNaming.ClassName : implementationNaming.ClassName}Implementation,
@@ -3560,10 +1831,10 @@ const scaffoldNewUseCase = async (boundedContextFolder)=>{
3560
1831
  const useCaseName = await (0, prompts_namespaceObject.input)({
3561
1832
  message: 'Name: '
3562
1833
  });
3563
- const naming = new UnknownFormatNaming(useCaseName);
3564
- const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
3565
- const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
3566
- useCasesFolder.createFile(`${naming.fileName}-use-case.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
1834
+ const naming = new unknown_format_naming_UnknownFormatNaming(useCaseName);
1835
+ const scaffoldUnitTests = Boolean(config_file_ConfigFile.Instance.data.testingLibrary);
1836
+ const withWiring = config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
1837
+ useCasesFolder.createFile(`${naming.fileName}-use-case.ts`, config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
3567
1838
  import { defineHandler } from '@domain-first/handlers'
3568
1839
 
3569
1840
  export class ${naming.ClassName}UseCase {
@@ -3586,7 +1857,7 @@ export class ${naming.ClassName}UseCase {
3586
1857
  }
3587
1858
  `.trim());
3588
1859
  if (scaffoldUnitTests) useCasesFolder.createFile(`${naming.fileName}-use-case.spec.ts`, `
3589
- import { describe, test, expect, beforeEach } from '${ConfigFile.Instance.data.testingLibrary}'
1860
+ import { describe, test, expect, beforeEach } from '${config_file_ConfigFile.Instance.data.testingLibrary}'
3590
1861
  ${withWiring ? `import { type ${naming.ClassName}UseCase } from './${naming.fileName}-use-case'
3591
1862
  import { wire${naming.ClassName}UseCase } from '../../wiring/use-cases/wire-${naming.fileName}-use-case'` : `import { ${naming.ClassName}UseCase } from './${naming.fileName}-use-case'`}
3592
1863
 
@@ -3619,201 +1890,14 @@ export const wire${naming.ClassName}UseCase = wireClass(
3619
1890
  await wireNewModuleDependencies(boundedContextFolder, wireFile);
3620
1891
  }
3621
1892
  };
3622
- const scaffoldReactSharedHook = async (presentationReactFolder)=>{
3623
- const name = await (0, prompts_namespaceObject.input)({
3624
- message: 'Name without "use" (e.g. debounce): '
3625
- });
3626
- const { ClassName, fileName } = new UnknownFormatNaming(name.trim().replace(/^use-/, ''));
3627
- presentationReactFolder.subitem([
3628
- 'hooks'
3629
- ]).createFile(`use-${fileName}.ts`, `
3630
- export const use${ClassName} = () => {
3631
- return {}
3632
- }
3633
- `.trim());
3634
- };
3635
- const scaffoldReactUIKitComponent = async (presentationReactFolder)=>{
3636
- const name = await (0, prompts_namespaceObject.input)({
3637
- message: 'Name: '
3638
- });
3639
- const { ClassName, fileName } = new UnknownFormatNaming(name);
3640
- const componentFolder = presentationReactFolder.subitem([
3641
- 'ui-kit',
3642
- fileName
3643
- ]);
3644
- componentFolder.createFile('index.ts', `export * from './${fileName}'`);
3645
- componentFolder.createFile(`${fileName}.tsx`, `
3646
- import { type FC } from 'react'
3647
-
3648
- export type ${ClassName}Props = {}
3649
-
3650
- export const ${ClassName}: FC<${ClassName}Props> = (props) => {
3651
- return <></>
3652
- }
3653
- `.trim());
3654
- const { storybookFramework } = ConfigFile.Instance.data;
3655
- if (storybookFramework) componentFolder.createFile(`${fileName}.stories.tsx`, `
3656
- import type { Meta, StoryObj } from '${storybookFramework}'
3657
- import { ${ClassName} } from './${fileName}'
3658
-
3659
- const meta = {
3660
- title: 'UI-kit/${ClassName}',
3661
- component: ${ClassName}
3662
- } satisfies Meta<typeof ${ClassName}>
3663
-
3664
- export default meta
3665
-
3666
- type Story = StoryObj<typeof meta>
3667
-
3668
- export const Default: Story = {
3669
- args: {}
3670
- }
3671
- `.trim());
3672
- };
3673
- const scaffoldReactWidget = async (presentationReactFolder)=>{
3674
- const widgetName = await (0, prompts_namespaceObject.input)({
3675
- message: 'Name (folders split by "/"): ',
3676
- validate: NestedName.validate
3677
- });
3678
- const widgetType = await (0, prompts_namespaceObject.select)({
3679
- choices: [
3680
- 'monolithic',
3681
- 'with separated ui',
3682
- 'headless'
3683
- ],
3684
- message: 'Type: '
3685
- });
3686
- const { folders, folderName, ClassName, fileName, classNameSegments } = new NestedName(widgetName);
3687
- const folder = presentationReactFolder.subitem([
3688
- 'widgets',
3689
- ...folders,
3690
- folderName
3691
- ]);
3692
- const storyTitle = [
3693
- 'Widgets',
3694
- ...classNameSegments
3695
- ].join('/');
3696
- const widgetFileName = `${fileName}-widget`;
3697
- const uiFileName = `${fileName}-widget-ui`;
3698
- const uiModelFileName = `use-${fileName}-ui-model`;
3699
- folder.createFile('index.ts', `export * from './${widgetFileName}'`);
3700
- switch(widgetType){
3701
- case 'monolithic':
3702
- folder.createFile(`${widgetFileName}.tsx`, `
3703
- import { type FC } from 'react'
3704
-
3705
- export type ${ClassName}WidgetProps = {}
3706
-
3707
- export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
3708
- return <></>
3709
- }
3710
- `.trim());
3711
- break;
3712
- case 'with separated ui':
3713
- {
3714
- folder.createFile('types.ts', `
3715
- export type ${ClassName}WidgetProps = { }
3716
-
3717
- export type ${ClassName}WidgetUIProps = { }
3718
- `.trim());
3719
- folder.createFile(`${widgetFileName}.tsx`, `
3720
- import { type FC } from 'react'
3721
- import type { ${ClassName}WidgetProps } from './types'
3722
- import { ${ClassName}WidgetUI } from './ui/${uiFileName}'
3723
- import { use${ClassName}UIModel } from './hooks/${uiModelFileName}'
3724
-
3725
- export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
3726
- const uiModel = use${ClassName}UIModel(props)
3727
- return <${ClassName}WidgetUI {...uiModel} />
3728
- }
3729
-
3730
- export type { ${ClassName}WidgetProps }
3731
- `.trim());
3732
- folder.subitem([
3733
- 'ui'
3734
- ]).createFile(`${uiFileName}.tsx`, `
3735
- import { FC } from 'react'
3736
- import type { ${ClassName}WidgetUIProps } from '../types'
3737
-
3738
- export const ${ClassName}WidgetUI: FC<${ClassName}WidgetUIProps> = (props) => {
3739
- return <></>
3740
- }
3741
- `.trim());
3742
- const { storybookFramework } = ConfigFile.Instance.data;
3743
- if (storybookFramework) folder.subitem([
3744
- 'ui'
3745
- ]).createFile(`${uiFileName}.stories.tsx`, `
3746
- import type { Meta, StoryObj } from '${storybookFramework}'
3747
- import { ${ClassName}WidgetUI } from './${uiFileName}'
3748
-
3749
- const meta = {
3750
- title: '${storyTitle}',
3751
- component: ${ClassName}WidgetUI
3752
- } satisfies Meta<typeof ${ClassName}WidgetUI>
3753
-
3754
- export default meta
3755
-
3756
- type Story = StoryObj<typeof meta>
3757
-
3758
- export const Default: Story = {
3759
- args: {}
3760
- }
3761
- `.trim());
3762
- folder.subitem([
3763
- 'hooks'
3764
- ]).createFile(`${uiModelFileName}.ts`, `
3765
- import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
3766
-
3767
- export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
3768
- return {}
3769
- }
3770
- `.trim());
3771
- break;
3772
- }
3773
- case 'headless':
3774
- folder.createFile('types.ts', `
3775
- import { type FC } from 'react'
3776
-
3777
- export type ${ClassName}WidgetUIProps = { }
3778
-
3779
- export type ${ClassName}WidgetProps = {
3780
- UI: FC<${ClassName}WidgetUIProps>
3781
- }
3782
-
3783
- `.trim());
3784
- folder.createFile(`${widgetFileName}.tsx`, `
3785
- import { type FC } from 'react'
3786
- import type { ${ClassName}WidgetProps } from './types'
3787
- import { use${ClassName}UIModel } from './hooks/${uiModelFileName}'
3788
-
3789
- export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
3790
- const uiModel = use${ClassName}UIModel(props)
3791
- return <props.UI {...uiModel} />
3792
- }
3793
-
3794
- export type { ${ClassName}WidgetProps }
3795
- `.trim());
3796
- folder.subitem([
3797
- 'hooks'
3798
- ]).createFile(`${uiModelFileName}.ts`, `
3799
- import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
3800
-
3801
- export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps, 'UI'>): ${ClassName}WidgetUIProps => {
3802
- return {}
3803
- }
3804
- `.trim());
3805
- break;
3806
- }
3807
- };
3808
1893
  const main = async ()=>{
3809
- if (!ConfigFile.exists) {
3810
- const nextSteps = await initializeUseCase();
3811
- if (await savePendingChanges()) printNextSteps(nextSteps);
3812
- return;
1894
+ if (!config_file_ConfigFile.exists) {
1895
+ console.log('No domain-first.project-structure.config.json found: run df-init first to initialize the project.');
1896
+ process.exit(1);
3813
1897
  }
3814
- const rootPath = new ProjectRoot().path;
3815
- const currentBoundedContextOptions = new Folder(rootPath).subitem([
3816
- ConfigFile.Instance.data.rootFolder,
1898
+ const rootPath = new project_root_ProjectRoot().path;
1899
+ const currentBoundedContextOptions = new file_system_Folder(rootPath).subitem([
1900
+ config_file_ConfigFile.Instance.data.rootFolder,
3817
1901
  'bounded-contexts'
3818
1902
  ]).content.subfolderNames.map((name)=>({
3819
1903
  name: `Bounded Context: ${name}`,
@@ -3825,75 +1909,30 @@ const main = async ()=>{
3825
1909
  };
3826
1910
  const options = [
3827
1911
  ...currentBoundedContextOptions,
3828
- ConfigFile.Instance.data.useReact ? {
3829
- name: 'Scaffold React module',
3830
- action: 'Scaffold React module'
3831
- } : void 0,
3832
1912
  {
3833
- name: 'Shared Layer',
1913
+ name: 'Shared Kernel',
3834
1914
  action: 'Scaffold in bounded context'
3835
1915
  },
3836
- scaffoldNewBoundedContext,
3837
- {
3838
- name: 'Add integration',
3839
- action: 'Add integration'
3840
- }
3841
- ].filter((x)=>!!x);
1916
+ scaffoldNewBoundedContext
1917
+ ];
3842
1918
  const result = await (0, prompts_namespaceObject.select)({
3843
1919
  message: '@domain-first/project-structure',
3844
1920
  choices: options.map((x)=>x.name)
3845
1921
  });
3846
1922
  const { action, name } = options.find((x)=>x.name === result);
3847
1923
  switch(action){
3848
- case 'Add integration':
3849
- return void await addIntegration();
3850
- case 'Scaffold React module':
3851
- {
3852
- const reactFolder = new Folder(rootPath).subitem([
3853
- ConfigFile.Instance.data.rootFolder,
3854
- 'presentation',
3855
- 'react'
3856
- ]);
3857
- const action = await (0, prompts_namespaceObject.select)({
3858
- message: 'Module: ',
3859
- choices: [
3860
- 'New widget',
3861
- 'New page',
3862
- 'New UI-kit component',
3863
- 'New shared hook',
3864
- 'Move or rename widget',
3865
- 'Move or rename page'
3866
- ]
3867
- });
3868
- switch(action){
3869
- case 'New widget':
3870
- return void await scaffoldReactWidget(reactFolder);
3871
- case 'New page':
3872
- return void await scaffoldReactPage(reactFolder);
3873
- case 'New UI-kit component':
3874
- return void await scaffoldReactUIKitComponent(reactFolder);
3875
- case 'New shared hook':
3876
- return void await scaffoldReactSharedHook(reactFolder);
3877
- case 'Move or rename widget':
3878
- return void await moveReactModuleUseCase(reactFolder, 'widget');
3879
- case 'Move or rename page':
3880
- return void await moveReactModuleUseCase(reactFolder, 'page');
3881
- default:
3882
- return;
3883
- }
3884
- }
3885
1924
  case 'Scaffold new bounded context':
3886
1925
  return void await scaffoldNewBoundedContextUseCase();
3887
1926
  case 'Scaffold in bounded context':
3888
1927
  {
3889
1928
  const specificContext = name.startsWith('Bounded');
3890
- const boundedContextFolder = new Folder(new ProjectRoot().path).subitem(specificContext ? [
3891
- ConfigFile.Instance.data.rootFolder,
1929
+ const boundedContextFolder = new file_system_Folder(new project_root_ProjectRoot().path).subitem(specificContext ? [
1930
+ config_file_ConfigFile.Instance.data.rootFolder,
3892
1931
  'bounded-contexts',
3893
1932
  name.substring(17)
3894
1933
  ] : [
3895
- ConfigFile.Instance.data.rootFolder,
3896
- 'shared'
1934
+ config_file_ConfigFile.Instance.data.rootFolder,
1935
+ 'shared-kernel'
3897
1936
  ]);
3898
1937
  const layer = await (0, prompts_namespaceObject.select)({
3899
1938
  message: 'Layer:',
@@ -3902,7 +1941,7 @@ const main = async ()=>{
3902
1941
  'Application',
3903
1942
  'Infrastructure',
3904
1943
  'Presentation',
3905
- ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? 'Wire dependency' : void 0
1944
+ config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire') ? 'Wire dependency' : void 0
3906
1945
  ].filter((x)=>!!x)
3907
1946
  });
3908
1947
  if ('Wire dependency' === layer) return void await wireDependency(boundedContextFolder);
@@ -3978,7 +2017,7 @@ const main = async ()=>{
3978
2017
  const action = await (0, prompts_namespaceObject.select)({
3979
2018
  message: 'Presentation layer operation:',
3980
2019
  choices: specificContext ? [
3981
- ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers-rest') ? 'New Handlers-REST Endpoint' : void 0,
2020
+ config_file_ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers-rest') ? 'New Handlers-REST Endpoint' : void 0,
3982
2021
  'New Service'
3983
2022
  ].filter((x)=>x) : [
3984
2023
  'New Service'
@@ -3999,7 +2038,7 @@ const main = async ()=>{
3999
2038
  };
4000
2039
  const run = async ()=>{
4001
2040
  await main();
4002
- await savePendingChanges();
2041
+ await save_pending_changes_savePendingChanges();
4003
2042
  };
4004
2043
  run();
4005
2044
  for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];