create-epinoetics-app 1.0.2 → 1.0.3

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 (3) hide show
  1. package/README +2 -0
  2. package/package.json +1 -1
  3. package/src/cloner.js +49 -7
package/README CHANGED
@@ -0,0 +1,2 @@
1
+ ```shell
2
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-epinoetics-app",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Scaffold a new project from your boilerplate repos",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cloner.js CHANGED
@@ -65,17 +65,19 @@ export async function cloneAndMergeNest({ projectName, database, selectedFeature
65
65
  }
66
66
 
67
67
  // 3. Prune schema.ts — remove export lines for deleted features
68
- await pruneSchema({ dest, toRemove });
68
+ pruneSchema({ dest, toRemove });
69
69
 
70
- // 4. Strip .git
70
+ // 4. Prune app.module.ts — remove imports and module references
71
+ pruneAppModule({ dest, toRemove });
72
+
73
+ // 5. Strip .git
71
74
  fs.rmSync(join(dest, '.git'), { recursive: true, force: true });
72
75
  }
73
76
 
74
77
  // ── Remove export * lines from schema.ts for deleted features ─────
75
- async function pruneSchema({ dest, toRemove }) {
78
+ function pruneSchema({ dest, toRemove }) {
76
79
  if (toRemove.length === 0) return;
77
80
 
78
- // Check common schema.ts locations
79
81
  const candidates = [
80
82
  join(dest, 'src', 'database', 'schema.ts'),
81
83
  join(dest, 'src', 'db', 'schema.ts'),
@@ -92,9 +94,7 @@ async function pruneSchema({ dest, toRemove }) {
92
94
  const before = content;
93
95
 
94
96
  for (const feature of toRemove) {
95
- // Matches lines like:
96
- // export * from '../features/posts/post.schema';
97
- // export * from "../features/seo/seo.schema";
97
+ // Removes: export * from '../features/posts/post.schema';
98
98
  const pattern = new RegExp(
99
99
  `^export \\* from ['"].*features\\/${feature.id}\\/.*['"];?\\n?`,
100
100
  'gm'
@@ -106,4 +106,46 @@ async function pruneSchema({ dest, toRemove }) {
106
106
  fs.writeFileSync(schemaPath, content, 'utf8');
107
107
  p.log.step(`Pruned schema.ts ${chalk.dim(`(removed ${toRemove.length} export line(s))`)}`);
108
108
  }
109
+ }
110
+
111
+ // ── Remove import + Module reference from app.module.ts ───────────
112
+ function pruneAppModule({ dest, toRemove }) {
113
+ if (toRemove.length === 0) return;
114
+
115
+ const appModulePath = join(dest, 'src', 'app.module.ts');
116
+ if (!fs.existsSync(appModulePath)) {
117
+ p.log.warn('Could not find app.module.ts — remove unused imports manually.');
118
+ return;
119
+ }
120
+
121
+ let content = fs.readFileSync(appModulePath, 'utf8');
122
+ const before = content;
123
+
124
+ for (const feature of toRemove) {
125
+ // Derive the module class name from the feature id:
126
+ // e.g. posts → PostsModule, seo → SeoModule
127
+ const moduleName = feature.id.charAt(0).toUpperCase() + feature.id.slice(1) + 'Module';
128
+
129
+ // Remove the import line:
130
+ // import { PostsModule } from './features/posts/posts.module';
131
+ const importPattern = new RegExp(
132
+ `^import \\{[^}]*${moduleName}[^}]*\\} from ['"].*features\\/${feature.id}\\/.*['"];?\\n?`,
133
+ 'gm'
134
+ );
135
+ content = content.replace(importPattern, '');
136
+
137
+ // Remove the module from the imports array:
138
+ // PostsModule, (with optional trailing comma + whitespace/newline)
139
+ // or ,PostsModule (preceded by comma)
140
+ const refPattern = new RegExp(
141
+ `\\n?\\s*${moduleName},?|,?\\s*${moduleName}`,
142
+ 'g'
143
+ );
144
+ content = content.replace(refPattern, '');
145
+ }
146
+
147
+ if (content !== before) {
148
+ fs.writeFileSync(appModulePath, content, 'utf8');
149
+ p.log.step(`Pruned app.module.ts ${chalk.dim(`(removed ${toRemove.length} module(s))`)}`);
150
+ }
109
151
  }