create-forgeon 0.2.0 → 0.2.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/package.json +1 -1
- package/src/modules/db-prisma.mjs +26 -1
- package/src/modules/i18n.mjs +7 -7
package/package.json
CHANGED
|
@@ -84,6 +84,26 @@ function ensureLineBefore(content, anchorLine, lineToInsert) {
|
|
|
84
84
|
return `${content.slice(0, index)}${lineToInsert}\n${content.slice(index)}`;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
function ensureNestCommonImport(content, importName) {
|
|
88
|
+
const pattern = /import\s*\{([^}]*)\}\s*from '@nestjs\/common';/m;
|
|
89
|
+
const match = content.match(pattern);
|
|
90
|
+
if (!match) {
|
|
91
|
+
return `import { ${importName} } from '@nestjs/common';\n${content}`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const names = match[1]
|
|
95
|
+
.split(',')
|
|
96
|
+
.map((item) => item.trim())
|
|
97
|
+
.filter(Boolean);
|
|
98
|
+
|
|
99
|
+
if (!names.includes(importName)) {
|
|
100
|
+
names.push(importName);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const replacement = `import { ${names.join(', ')} } from '@nestjs/common';`;
|
|
104
|
+
return content.replace(pattern, replacement);
|
|
105
|
+
}
|
|
106
|
+
|
|
87
107
|
function upsertEnvLines(filePath, lines) {
|
|
88
108
|
let content = '';
|
|
89
109
|
if (fs.existsSync(filePath)) {
|
|
@@ -244,10 +264,13 @@ function patchHealthController(targetRoot) {
|
|
|
244
264
|
}
|
|
245
265
|
|
|
246
266
|
let content = fs.readFileSync(filePath, 'utf8').replace(/\r\n/g, '\n');
|
|
267
|
+
content = ensureNestCommonImport(content, 'Post');
|
|
268
|
+
|
|
247
269
|
if (!content.includes("from '@forgeon/db-prisma';")) {
|
|
270
|
+
const nestCommonImport = content.match(/import\s*\{[^}]*\}\s*from '@nestjs\/common';/m)?.[0];
|
|
248
271
|
const anchor = content.includes("import { I18nService } from 'nestjs-i18n';")
|
|
249
272
|
? "import { I18nService } from 'nestjs-i18n';"
|
|
250
|
-
:
|
|
273
|
+
: nestCommonImport;
|
|
251
274
|
content = ensureLineAfter(content, anchor, "import { PrismaService } from '@forgeon/db-prisma';");
|
|
252
275
|
}
|
|
253
276
|
|
|
@@ -350,6 +373,7 @@ function patchApiDockerfile(targetRoot) {
|
|
|
350
373
|
|
|
351
374
|
content = content
|
|
352
375
|
.replace(/^RUN pnpm --filter @forgeon\/db-prisma build\r?\n?/gm, '')
|
|
376
|
+
.replace(/^RUN pnpm --filter @forgeon\/core build\r?\n?/gm, '')
|
|
353
377
|
.replace(/^RUN pnpm --filter @forgeon\/api prisma:generate\r?\n?/gm, '')
|
|
354
378
|
.replace(/^CMD \["node", "apps\/api\/dist\/main\.js"\]\r?\n?/gm, '')
|
|
355
379
|
.replace(
|
|
@@ -357,6 +381,7 @@ function patchApiDockerfile(targetRoot) {
|
|
|
357
381
|
'',
|
|
358
382
|
);
|
|
359
383
|
|
|
384
|
+
content = ensureLineBefore(content, 'RUN pnpm --filter @forgeon/api build', 'RUN pnpm --filter @forgeon/core build');
|
|
360
385
|
content = ensureLineBefore(content, 'RUN pnpm --filter @forgeon/api build', 'RUN pnpm --filter @forgeon/db-prisma build');
|
|
361
386
|
content = ensureLineBefore(content, 'RUN pnpm --filter @forgeon/api build', 'RUN pnpm --filter @forgeon/api prisma:generate');
|
|
362
387
|
content = `${content.trimEnd()}\nCMD ["sh", "-c", "pnpm --filter @forgeon/api prisma:migrate:deploy && node apps/api/dist/main.js"]\n`;
|
package/src/modules/i18n.mjs
CHANGED
|
@@ -188,23 +188,23 @@ function patchApiDockerfile(targetRoot) {
|
|
|
188
188
|
.replace(/^RUN pnpm --filter @forgeon\/i18n-contracts build\r?\n?/gm, '')
|
|
189
189
|
.replace(/^RUN pnpm --filter @forgeon\/i18n build\r?\n?/gm, '');
|
|
190
190
|
|
|
191
|
+
const apiBuildAnchor = content.includes('RUN pnpm --filter @forgeon/api prisma:generate')
|
|
192
|
+
? 'RUN pnpm --filter @forgeon/api prisma:generate'
|
|
193
|
+
: 'RUN pnpm --filter @forgeon/api build';
|
|
194
|
+
|
|
191
195
|
content = ensureLineBefore(
|
|
192
196
|
content,
|
|
193
|
-
|
|
197
|
+
apiBuildAnchor,
|
|
194
198
|
'RUN pnpm --filter @forgeon/core build',
|
|
195
199
|
);
|
|
196
200
|
content = ensureLineBefore(
|
|
197
201
|
content,
|
|
198
|
-
|
|
199
|
-
? 'RUN pnpm --filter @forgeon/api prisma:generate'
|
|
200
|
-
: 'RUN pnpm --filter @forgeon/api build',
|
|
202
|
+
apiBuildAnchor,
|
|
201
203
|
'RUN pnpm --filter @forgeon/i18n-contracts build',
|
|
202
204
|
);
|
|
203
205
|
content = ensureLineBefore(
|
|
204
206
|
content,
|
|
205
|
-
|
|
206
|
-
? 'RUN pnpm --filter @forgeon/api prisma:generate'
|
|
207
|
-
: 'RUN pnpm --filter @forgeon/api build',
|
|
207
|
+
apiBuildAnchor,
|
|
208
208
|
'RUN pnpm --filter @forgeon/i18n build',
|
|
209
209
|
);
|
|
210
210
|
|