@domain-first/project-structure 8.6.0 → 8.6.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/780.js CHANGED
@@ -293,7 +293,8 @@ class File extends FileSystemItem {
293
293
  });
294
294
  };
295
295
  addLineIfMissing = (newLine, separator = '\n')=>{
296
- const alreadyAdded = this.exists && this.data.split('\n').some((line)=>line.trim() === newLine.trim());
296
+ const normalized = (line)=>line.trim().replace(/;$/, '');
297
+ const alreadyAdded = this.exists && this.data.split('\n').some((line)=>normalized(line) === normalized(newLine));
297
298
  if (!alreadyAdded) this.addLine(newLine, separator);
298
299
  };
299
300
  }
@@ -54,7 +54,8 @@ export declare class File extends FileSystemItem {
54
54
  update: (content: string) => void;
55
55
  addLine: (newLine: string, separator?: string) => void;
56
56
  /**
57
- * Re-running a generator for the same name must not duplicate the line.
57
+ * Re-running a generator for the same name must not duplicate the line,
58
+ * also after a formatter added the semicolon.
58
59
  */
59
60
  addLineIfMissing: (newLine: string, separator?: string) => void;
60
61
  }
package/dist/graph.cjs CHANGED
@@ -180,7 +180,8 @@ class file_system_File extends FileSystemItem {
180
180
  });
181
181
  };
182
182
  addLineIfMissing = (newLine, separator = '\n')=>{
183
- const alreadyAdded = this.exists && this.data.split('\n').some((line)=>line.trim() === newLine.trim());
183
+ const normalized = (line)=>line.trim().replace(/;$/, '');
184
+ const alreadyAdded = this.exists && this.data.split('\n').some((line)=>normalized(line) === normalized(newLine));
184
185
  if (!alreadyAdded) this.addLine(newLine, separator);
185
186
  };
186
187
  }
package/dist/index.cjs CHANGED
@@ -346,7 +346,8 @@ class file_system_File extends FileSystemItem {
346
346
  });
347
347
  };
348
348
  addLineIfMissing = (newLine, separator = '\n')=>{
349
- const alreadyAdded = this.exists && this.data.split('\n').some((line)=>line.trim() === newLine.trim());
349
+ const normalized = (line)=>line.trim().replace(/;$/, '');
350
+ const alreadyAdded = this.exists && this.data.split('\n').some((line)=>normalized(line) === normalized(newLine));
350
351
  if (!alreadyAdded) this.addLine(newLine, separator);
351
352
  };
352
353
  }
package/dist/init.cjs CHANGED
@@ -263,7 +263,8 @@ class file_system_File extends FileSystemItem {
263
263
  });
264
264
  };
265
265
  addLineIfMissing = (newLine, separator = '\n')=>{
266
- const alreadyAdded = this.exists && this.data.split('\n').some((line)=>line.trim() === newLine.trim());
266
+ const normalized = (line)=>line.trim().replace(/;$/, '');
267
+ const alreadyAdded = this.exists && this.data.split('\n').some((line)=>normalized(line) === normalized(newLine));
267
268
  if (!alreadyAdded) this.addLine(newLine, separator);
268
269
  };
269
270
  }
@@ -345,7 +345,8 @@ class file_system_File extends FileSystemItem {
345
345
  });
346
346
  };
347
347
  addLineIfMissing = (newLine, separator = '\n')=>{
348
- const alreadyAdded = this.exists && this.data.split('\n').some((line)=>line.trim() === newLine.trim());
348
+ const normalized = (line)=>line.trim().replace(/;$/, '');
349
+ const alreadyAdded = this.exists && this.data.split('\n').some((line)=>normalized(line) === normalized(newLine));
349
350
  if (!alreadyAdded) this.addLine(newLine, separator);
350
351
  };
351
352
  }
package/dist/lint.cjs CHANGED
@@ -203,7 +203,8 @@ class file_system_File extends FileSystemItem {
203
203
  });
204
204
  };
205
205
  addLineIfMissing = (newLine, separator = '\n')=>{
206
- const alreadyAdded = this.exists && this.data.split('\n').some((line)=>line.trim() === newLine.trim());
206
+ const normalized = (line)=>line.trim().replace(/;$/, '');
207
+ const alreadyAdded = this.exists && this.data.split('\n').some((line)=>normalized(line) === normalized(newLine));
207
208
  if (!alreadyAdded) this.addLine(newLine, separator);
208
209
  };
209
210
  }
package/dist/react.cjs CHANGED
@@ -346,7 +346,8 @@ class file_system_File extends FileSystemItem {
346
346
  });
347
347
  };
348
348
  addLineIfMissing = (newLine, separator = '\n')=>{
349
- const alreadyAdded = this.exists && this.data.split('\n').some((line)=>line.trim() === newLine.trim());
349
+ const normalized = (line)=>line.trim().replace(/;$/, '');
350
+ const alreadyAdded = this.exists && this.data.split('\n').some((line)=>normalized(line) === normalized(newLine));
350
351
  if (!alreadyAdded) this.addLine(newLine, separator);
351
352
  };
352
353
  }
package/dist/upgrade.cjs CHANGED
@@ -214,7 +214,8 @@ class File extends FileSystemItem {
214
214
  });
215
215
  };
216
216
  addLineIfMissing = (newLine, separator = '\n')=>{
217
- const alreadyAdded = this.exists && this.data.split('\n').some((line)=>line.trim() === newLine.trim());
217
+ const normalized = (line)=>line.trim().replace(/;$/, '');
218
+ const alreadyAdded = this.exists && this.data.split('\n').some((line)=>normalized(line) === normalized(newLine));
218
219
  if (!alreadyAdded) this.addLine(newLine, separator);
219
220
  };
220
221
  }
@@ -612,17 +613,18 @@ const rootMoves = (contextFolder)=>{
612
613
  };
613
614
  };
614
615
  const exportPattern = /^export\s+\*\s+from\s+(['"])([^'"]+)\1;?\s*$/;
615
- const regroupExports = (file, isRootWire, groupLine)=>{
616
- if (!file.exists) return [];
617
- const lines = file.data.split('\n');
616
+ const exportedSpecifier = (line)=>line.trim().match(exportPattern)?.[2];
617
+ const regroupExports = (file, isRootWire, groupSpecifier)=>{
618
+ const lines = file.exists ? file.data.split('\n') : [];
618
619
  const rootWires = lines.filter((line)=>{
619
- const specifier = line.trim().match(exportPattern)?.[2];
620
+ const specifier = exportedSpecifier(line);
620
621
  return !!specifier && isRootWire(specifier);
621
622
  });
622
- if (!rootWires.length) return [];
623
- const first = lines.indexOf(rootWires[0]);
623
+ const first = rootWires.length ? lines.indexOf(rootWires[0]) : lines.length - [
624
+ ...lines
625
+ ].reverse().findIndex((line)=>!!line.trim());
624
626
  const kept = lines.filter((line)=>!rootWires.includes(line));
625
- if (!kept.some((line)=>line.trim() === groupLine)) kept.splice(first, 0, groupLine);
627
+ if (!kept.some((line)=>exportedSpecifier(line) === groupSpecifier)) kept.splice(first, 0, `export * from '${groupSpecifier}'`);
626
628
  file.update(kept.join('\n'));
627
629
  return rootWires;
628
630
  };
@@ -639,8 +641,8 @@ const restRootControllerStep = {
639
641
  return [
640
642
  ...files.map(([from, to])=>`${upgrade_rest_root_relative(from)} → ${upgrade_rest_root_relative(to)}`),
641
643
  ...wired ? [
642
- `${upgrade_rest_root_relative(external_node_path_default().join(wiring, 'index.ts'))}: one line for ./(root)`,
643
- `${upgrade_rest_root_relative(external_node_path_default().join(new ProjectRoot().path, rootFolderOf(context), 'presentation', 'rest', 'wires.ts'))}: the ${name} context-root lines → one line for (root)`
644
+ `${upgrade_rest_root_relative(external_node_path_default().join(wiring, 'index.ts'))}: the context-root lines → one line for ./(root)`,
645
+ `${upgrade_rest_root_relative(external_node_path_default().join(new ProjectRoot().path, rootFolderOf(context), 'presentation', 'rest', 'wires.ts'))}: the ${name} context-root lines → one line for (root), added if missing`
644
646
  ] : [],
645
647
  'Imports of the moved files are rewritten'
646
648
  ];
@@ -681,10 +683,16 @@ const restRootControllerStep = {
681
683
  for (const contextFolder of contexts){
682
684
  const name = external_node_path_default().basename(contextFolder);
683
685
  const { wiring } = restFolders(contextFolder);
684
- const rootWires = regroupExports(new File(external_node_path_default().join(wiring, 'index.ts')), (specifier)=>specifier.startsWith("./(root)/"), "export * from './(root)'");
685
- if (rootWires.length) new File(external_node_path_default().join(wiring, "(root)", 'index.ts')).data = rootWires.map((line)=>line.replace("./(root)/", './')).join('\n');
686
+ const movedWires = legacyRootEndpoints(contextFolder).wireFiles;
687
+ if (!movedWires.length) continue;
688
+ const listed = regroupExports(new File(external_node_path_default().join(wiring, 'index.ts')), (specifier)=>specifier.startsWith("./(root)/"), "./(root)").map((line)=>line.replace("./(root)/", './'));
689
+ const unlisted = movedWires.map((file)=>`./${external_node_path_default().basename(file, '.ts')}`).filter((specifier)=>!listed.some((line)=>exportedSpecifier(line) === specifier)).map((specifier)=>`export * from '${specifier}'`);
690
+ new File(external_node_path_default().join(wiring, "(root)", 'index.ts')).data = [
691
+ ...listed,
692
+ ...unlisted
693
+ ].join('\n');
686
694
  const wiringPath = `bounded-contexts/${name}/wiring/presentation/rest/(root)`;
687
- regroupExports(sharedWires, (specifier)=>specifier.includes(`${wiringPath}/`), `export * from '../../${wiringPath}'`);
695
+ regroupExports(sharedWires, (specifier)=>specifier.includes(`${wiringPath}/`), `../../${wiringPath}`);
688
696
  }
689
697
  }
690
698
  };
package/dist/upgrade.js CHANGED
@@ -46,17 +46,18 @@ const rootMoves = (contextFolder)=>{
46
46
  };
47
47
  };
48
48
  const exportPattern = /^export\s+\*\s+from\s+(['"])([^'"]+)\1;?\s*$/;
49
- const regroupExports = (file, isRootWire, groupLine)=>{
50
- if (!file.exists) return [];
51
- const lines = file.data.split('\n');
49
+ const exportedSpecifier = (line)=>line.trim().match(exportPattern)?.[2];
50
+ const regroupExports = (file, isRootWire, groupSpecifier)=>{
51
+ const lines = file.exists ? file.data.split('\n') : [];
52
52
  const rootWires = lines.filter((line)=>{
53
- const specifier = line.trim().match(exportPattern)?.[2];
53
+ const specifier = exportedSpecifier(line);
54
54
  return !!specifier && isRootWire(specifier);
55
55
  });
56
- if (!rootWires.length) return [];
57
- const first = lines.indexOf(rootWires[0]);
56
+ const first = rootWires.length ? lines.indexOf(rootWires[0]) : lines.length - [
57
+ ...lines
58
+ ].reverse().findIndex((line)=>!!line.trim());
58
59
  const kept = lines.filter((line)=>!rootWires.includes(line));
59
- if (!kept.some((line)=>line.trim() === groupLine)) kept.splice(first, 0, groupLine);
60
+ if (!kept.some((line)=>exportedSpecifier(line) === groupSpecifier)) kept.splice(first, 0, `export * from '${groupSpecifier}'`);
60
61
  file.update(kept.join('\n'));
61
62
  return rootWires;
62
63
  };
@@ -73,8 +74,8 @@ const restRootControllerStep = {
73
74
  return [
74
75
  ...files.map(([from, to])=>`${relative(from)} → ${relative(to)}`),
75
76
  ...wired ? [
76
- `${relative(node_path.join(wiring, 'index.ts'))}: one line for ./(root)`,
77
- `${relative(node_path.join(new ProjectRoot().path, rootFolderOf(context), 'presentation', 'rest', 'wires.ts'))}: the ${name} context-root lines → one line for (root)`
77
+ `${relative(node_path.join(wiring, 'index.ts'))}: the context-root lines → one line for ./(root)`,
78
+ `${relative(node_path.join(new ProjectRoot().path, rootFolderOf(context), 'presentation', 'rest', 'wires.ts'))}: the ${name} context-root lines → one line for (root), added if missing`
78
79
  ] : [],
79
80
  'Imports of the moved files are rewritten'
80
81
  ];
@@ -115,10 +116,16 @@ const restRootControllerStep = {
115
116
  for (const contextFolder of contexts){
116
117
  const name = node_path.basename(contextFolder);
117
118
  const { wiring } = restFolders(contextFolder);
118
- const rootWires = regroupExports(new File(node_path.join(wiring, 'index.ts')), (specifier)=>specifier.startsWith("./(root)/"), "export * from './(root)'");
119
- if (rootWires.length) new File(node_path.join(wiring, "(root)", 'index.ts')).data = rootWires.map((line)=>line.replace("./(root)/", './')).join('\n');
119
+ const movedWires = legacyRootEndpoints(contextFolder).wireFiles;
120
+ if (!movedWires.length) continue;
121
+ const listed = regroupExports(new File(node_path.join(wiring, 'index.ts')), (specifier)=>specifier.startsWith("./(root)/"), "./(root)").map((line)=>line.replace("./(root)/", './'));
122
+ const unlisted = movedWires.map((file)=>`./${node_path.basename(file, '.ts')}`).filter((specifier)=>!listed.some((line)=>exportedSpecifier(line) === specifier)).map((specifier)=>`export * from '${specifier}'`);
123
+ new File(node_path.join(wiring, "(root)", 'index.ts')).data = [
124
+ ...listed,
125
+ ...unlisted
126
+ ].join('\n');
120
127
  const wiringPath = `bounded-contexts/${name}/wiring/presentation/rest/(root)`;
121
- regroupExports(sharedWires, (specifier)=>specifier.includes(`${wiringPath}/`), `export * from '../../${wiringPath}'`);
128
+ regroupExports(sharedWires, (specifier)=>specifier.includes(`${wiringPath}/`), `../../${wiringPath}`);
122
129
  }
123
130
  }
124
131
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@domain-first/project-structure",
3
3
  "description": "Build and manage your Domain-First project structure with CLI",
4
- "version": "8.6.0",
4
+ "version": "8.6.1",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",