create-epinoetics-app 1.0.3 → 1.0.5

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/cloner.js +68 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-epinoetics-app",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Scaffold a new project from your boilerplate repos",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cloner.js CHANGED
@@ -64,18 +64,25 @@ export async function cloneAndMergeNest({ projectName, database, selectedFeature
64
64
  );
65
65
  }
66
66
 
67
- // 3. Prune schema.tsremove export lines for deleted features
68
- pruneSchema({ dest, toRemove });
67
+ // 3. Prune schema — Drizzle or Prisma depending on db choice
68
+ if (database.id === 'drizzle') {
69
+ pruneDrizzleSchema({ dest, toRemove });
70
+ } else if (database.id === 'prisma') {
71
+ prunePrismaSchema({ dest, toRemove });
72
+ }
69
73
 
70
74
  // 4. Prune app.module.ts — remove imports and module references
71
75
  pruneAppModule({ dest, toRemove });
72
76
 
73
- // 5. Strip .git
77
+ // 5. Remove migrations directory
78
+ pruneMigrations({ dest, database });
79
+
80
+ // 6. Strip .git
74
81
  fs.rmSync(join(dest, '.git'), { recursive: true, force: true });
75
82
  }
76
83
 
77
- // ── Remove export * lines from schema.ts for deleted features ─────
78
- function pruneSchema({ dest, toRemove }) {
84
+ // ── Drizzle: remove export * lines from schema.ts ─────────────────
85
+ function pruneDrizzleSchema({ dest, toRemove }) {
79
86
  if (toRemove.length === 0) return;
80
87
 
81
88
  const candidates = [
@@ -108,6 +115,47 @@ function pruneSchema({ dest, toRemove }) {
108
115
  }
109
116
  }
110
117
 
118
+ // ── Prisma: remove model blocks from schema.prisma ────────────────
119
+ //
120
+ // Convention in schema.prisma:
121
+ //
122
+ // // @feature:posts
123
+ // model Post { ... }
124
+ // model PostTag { ... }
125
+ // // @end:posts
126
+ //
127
+ function prunePrismaSchema({ dest, toRemove }) {
128
+ if (toRemove.length === 0) return;
129
+
130
+ const candidates = [
131
+ join(dest, 'prisma', 'schema.prisma'),
132
+ join(dest, 'schema.prisma'),
133
+ ];
134
+
135
+ const schemaPath = candidates.find(f => fs.existsSync(f));
136
+ if (!schemaPath) {
137
+ p.log.warn('Could not find schema.prisma — remove unused models manually.');
138
+ return;
139
+ }
140
+
141
+ let content = fs.readFileSync(schemaPath, 'utf8');
142
+ const before = content;
143
+
144
+ for (const feature of toRemove) {
145
+ // Removes everything between // @feature:posts and // @end:posts (inclusive)
146
+ const pattern = new RegExp(
147
+ `\\/\\/ @feature:${feature.id}\\n[\\s\\S]*?\\/\\/ @end:${feature.id}\\n?`,
148
+ 'g'
149
+ );
150
+ content = content.replace(pattern, '');
151
+ }
152
+
153
+ if (content !== before) {
154
+ fs.writeFileSync(schemaPath, content, 'utf8');
155
+ p.log.step(`Pruned schema.prisma ${chalk.dim(`(removed ${toRemove.length} model block(s))`)}`);
156
+ }
157
+ }
158
+
111
159
  // ── Remove import + Module reference from app.module.ts ───────────
112
160
  function pruneAppModule({ dest, toRemove }) {
113
161
  if (toRemove.length === 0) return;
@@ -122,7 +170,6 @@ function pruneAppModule({ dest, toRemove }) {
122
170
  const before = content;
123
171
 
124
172
  for (const feature of toRemove) {
125
- // Derive the module class name from the feature id:
126
173
  // e.g. posts → PostsModule, seo → SeoModule
127
174
  const moduleName = feature.id.charAt(0).toUpperCase() + feature.id.slice(1) + 'Module';
128
175
 
@@ -134,9 +181,7 @@ function pruneAppModule({ dest, toRemove }) {
134
181
  );
135
182
  content = content.replace(importPattern, '');
136
183
 
137
- // Remove the module from the imports array:
138
- // PostsModule, (with optional trailing comma + whitespace/newline)
139
- // or ,PostsModule (preceded by comma)
184
+ // Remove the module from the imports array
140
185
  const refPattern = new RegExp(
141
186
  `\\n?\\s*${moduleName},?|,?\\s*${moduleName}`,
142
187
  'g'
@@ -148,4 +193,18 @@ function pruneAppModule({ dest, toRemove }) {
148
193
  fs.writeFileSync(appModulePath, content, 'utf8');
149
194
  p.log.step(`Pruned app.module.ts ${chalk.dim(`(removed ${toRemove.length} module(s))`)}`);
150
195
  }
196
+ }
197
+
198
+ // ── Remove migrations directory ───────────────────────────────────
199
+ function pruneMigrations({ dest, database }) {
200
+ const candidates = database.id === 'drizzle'
201
+ ? [join(dest, 'migrations'), join(dest, 'drizzle')]
202
+ : [join(dest, 'prisma', 'migrations')];
203
+
204
+ for (const dir of candidates) {
205
+ if (fs.existsSync(dir)) {
206
+ fs.rmSync(dir, { recursive: true, force: true });
207
+ p.log.step(`Removed migrations ${chalk.dim(dir.replace(dest, ''))}`);
208
+ }
209
+ }
151
210
  }