@domain-first/project-structure 8.8.0 → 8.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { select as prompts_select } from "@inquirer/prompts";
3
3
  import { runCLI } from "./561.js";
4
- import { outdatedConfigMessage, ProjectRoot, ConfigFile, Folder } from "./780.js";
4
+ import { outdatedConfigMessage, ProjectRoot, ConfigFile, Folder } from "./201.js";
5
5
  import { scaffoldNewDomainService, scaffoldNewErrorUseCase, scaffoldNewAggregateUseCase, scaffoldNewQuery, scaffoldNewInfrastructureService, scaffoldNewHandlersRestEndpoint, savePendingChanges, moveBackendUnitUseCase, scaffoldNewCommand, scaffoldNewPresentationService, scaffoldNewInfrastructureHelper, deleteBackendUnitUseCase, scaffoldNewApplicationService, scaffoldNewUseCase, scaffoldNewImplementation, wireDependency, scaffoldNewBoundedContextUseCase, scaffoldNewDomainObject, scaffoldNewApplicationPort } from "./287.js";
6
6
  const main = async ()=>{
7
7
  if (!ConfigFile.exists) {
package/dist/init.cjs CHANGED
@@ -638,12 +638,53 @@ const save_pending_changes_savePendingChanges = async ()=>{
638
638
  writePendingChanges();
639
639
  return true;
640
640
  };
641
+ const package_scripts_addPackageScripts = async (file, additions)=>{
642
+ const original = file.data;
643
+ const manifest = JSON.parse(original);
644
+ const scripts = {
645
+ ...manifest.scripts
646
+ };
647
+ const selected = {};
648
+ for (const [name, command] of Object.entries(additions)){
649
+ let target = name;
650
+ if (Object.hasOwn(scripts, name) && scripts[name] !== command) {
651
+ const action = await interaction_select({
652
+ key: `scriptConflicts.${name}`,
653
+ message: `Script "${name}" already exists: ${scripts[name]}`,
654
+ choices: [
655
+ 'Keep existing',
656
+ 'Replace',
657
+ 'Use another name'
658
+ ]
659
+ });
660
+ if ('Keep existing' === action) continue;
661
+ if ('Use another name' === action) target = await interaction_input({
662
+ key: `scriptNames.${name}`,
663
+ message: "New script name:",
664
+ validate: (value)=>!/^[a-zA-Z0-9:_-]+$/.test(value) || Object.hasOwn(scripts, value) || Object.hasOwn(additions, value) ? "Enter an unused script name (letters, numbers, :, _, -)." : true
665
+ });
666
+ }
667
+ scripts[target] = command;
668
+ selected[name] = target;
669
+ }
670
+ if (JSON.stringify(manifest.scripts) !== JSON.stringify(scripts)) {
671
+ manifest.scripts = scripts;
672
+ const indent = original.match(/\n([\t ]+)"/)?.[1] ?? ' ';
673
+ file.update(`${JSON.stringify(manifest, null, indent)}\n`);
674
+ }
675
+ return selected;
676
+ };
677
+ const package_scripts_describeScripts = (selected, descriptions)=>Object.entries(descriptions).filter(([name])=>selected[name]).map(([name, description])=>`npm run ${selected[name]} — ${description}`);
641
678
  const context_dependencies_crossContextImplementation = 'cross-context';
642
679
  new Map([
643
680
  [
644
681
  'prisma',
645
682
  'prisma-infrastructure-service'
646
683
  ],
684
+ [
685
+ 'drizzle',
686
+ 'drizzle-infrastructure-service'
687
+ ],
647
688
  [
648
689
  'in-memory',
649
690
  'in-memory-db-infrastructure-service'
@@ -654,6 +695,11 @@ const wiring_relativeImport = (fromFile, toFile)=>{
654
695
  return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
655
696
  };
656
697
  const inMemoryImplementationType = 'in-memory';
698
+ const withIdLookup = ` withId: (id: TId): T | null =>
699
+ globalThis.___SHARED_IN_MEMORY_DB___![key].find((entry) =>
700
+ idsAreEqual(entry.id as TId, id)
701
+ )?.item ?? null,
702
+ `;
657
703
  const inMemoryDbService = `type Entry = {
658
704
  id: unknown;
659
705
  item: any;
@@ -692,9 +738,6 @@ const defaultIdsAreEqual = (a: unknown, b: unknown): boolean => {
692
738
  return Object.is(a, b);
693
739
  };
694
740
 
695
- const hasId = (x: unknown): x is { id: unknown } =>
696
- typeof x === 'object' && x !== null && 'id' in x;
697
-
698
741
  export class InMemoryDbInfrastructureService {
699
742
  protected section<T extends { id: unknown }>(
700
743
  key: string,
@@ -726,11 +769,7 @@ export class InMemoryDbInfrastructureService {
726
769
  items().filter(predicate),
727
770
  first: (predicate: (x: T) => boolean): T | null =>
728
771
  items().find(predicate) ?? null,
729
- withId: (id: TId): T | null =>
730
- items().find(
731
- (x: T) => hasId(x) && idsAreEqual(x.id as TId, id)
732
- ) ?? null,
733
- lastAddedItem: (): T | null =>
772
+ ${withIdLookup} lastAddedItem: (): T | null =>
734
773
  globalThis.___SHARED_IN_MEMORY_DB___![key].at(-1)?.item ?? null,
735
774
  save: (payload: T extends { id: TId } ? T : [TId, T]) => {
736
775
  const id = Array.isArray(payload) ? payload[0] : payload.id;
@@ -822,43 +861,6 @@ const next_app_nextAppFolder = (root)=>[
822
861
  'src/app'
823
862
  ].find((folder)=>new file_system_Folder(external_node_path_default().join(root, folder)).exists) ?? 'app';
824
863
  require("node:module");
825
- const package_scripts_addPackageScripts = async (file, additions)=>{
826
- const original = file.data;
827
- const manifest = JSON.parse(original);
828
- const scripts = {
829
- ...manifest.scripts
830
- };
831
- const selected = {};
832
- for (const [name, command] of Object.entries(additions)){
833
- let target = name;
834
- if (Object.hasOwn(scripts, name) && scripts[name] !== command) {
835
- const action = await interaction_select({
836
- key: `scriptConflicts.${name}`,
837
- message: `Script "${name}" already exists: ${scripts[name]}`,
838
- choices: [
839
- 'Keep existing',
840
- 'Replace',
841
- 'Use another name'
842
- ]
843
- });
844
- if ('Keep existing' === action) continue;
845
- if ('Use another name' === action) target = await interaction_input({
846
- key: `scriptNames.${name}`,
847
- message: "New script name:",
848
- validate: (value)=>!/^[a-zA-Z0-9:_-]+$/.test(value) || Object.hasOwn(scripts, value) || Object.hasOwn(additions, value) ? "Enter an unused script name (letters, numbers, :, _, -)." : true
849
- });
850
- }
851
- scripts[target] = command;
852
- selected[name] = target;
853
- }
854
- if (JSON.stringify(manifest.scripts) !== JSON.stringify(scripts)) {
855
- manifest.scripts = scripts;
856
- const indent = original.match(/\n([\t ]+)"/)?.[1] ?? ' ';
857
- file.update(`${JSON.stringify(manifest, null, indent)}\n`);
858
- }
859
- return selected;
860
- };
861
- const package_scripts_describeScripts = (selected, descriptions)=>Object.entries(descriptions).filter(([name])=>selected[name]).map(([name, description])=>`npm run ${selected[name]} — ${description}`);
862
864
  const gitignore_addGitignoreEntry = (root, entry)=>{
863
865
  const gitignore = new file_system_File(external_node_path_default().join(root, '.gitignore'));
864
866
  const ignored = gitignore.exists ? gitignore.data : '';
package/dist/init.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { parseArgs } from "node:util";
3
- import { ConfigFile, outdatedConfigMessage } from "./780.js";
3
+ import { ConfigFile, outdatedConfigMessage } from "./201.js";
4
4
  import { printNextSteps, configurationSections, initializeUseCase, savePendingChanges } from "./287.js";
5
5
  const help = `Usage: df-init [--section project|backend|frontend]
6
6