@digitaldefiance/express-suite-starter 2.3.1 → 2.3.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.
- package/config/presets/standard.json +1 -1
- package/dist/src/core/interfaces/command-options.interface.d.ts +1 -0
- package/dist/src/core/interfaces/command-options.interface.d.ts.map +1 -1
- package/dist/src/core/project-generator.d.ts +1 -0
- package/dist/src/core/project-generator.d.ts.map +1 -1
- package/dist/src/core/project-generator.js +8 -7
- package/dist/src/core/project-generator.js.map +1 -1
- package/dist/src/generate-monorepo.d.ts.map +1 -1
- package/dist/src/generate-monorepo.js +371 -91
- package/dist/src/generate-monorepo.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts.map +1 -1
- package/dist/src/utils/shell-utils.js +2 -1
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/package.json +6 -5
- package/dist/src/i18n/translations-de.d.ts +0 -3
- package/dist/src/i18n/translations-de.d.ts.map +0 -1
- package/dist/src/i18n/translations-de.js +0 -171
- package/dist/src/i18n/translations-de.js.map +0 -1
- package/dist/src/i18n/translations-en-gb.d.ts +0 -167
- package/dist/src/i18n/translations-en-gb.d.ts.map +0 -1
- package/dist/src/i18n/translations-en-gb.js +0 -7
- package/dist/src/i18n/translations-en-gb.js.map +0 -1
- package/dist/src/i18n/translations-en-us.d.ts +0 -3
- package/dist/src/i18n/translations-en-us.d.ts.map +0 -1
- package/dist/src/i18n/translations-en-us.js +0 -195
- package/dist/src/i18n/translations-en-us.js.map +0 -1
- package/dist/src/i18n/translations-es.d.ts +0 -3
- package/dist/src/i18n/translations-es.d.ts.map +0 -1
- package/dist/src/i18n/translations-es.js +0 -171
- package/dist/src/i18n/translations-es.js.map +0 -1
- package/dist/src/i18n/translations-fr.d.ts +0 -3
- package/dist/src/i18n/translations-fr.d.ts.map +0 -1
- package/dist/src/i18n/translations-fr.js +0 -171
- package/dist/src/i18n/translations-fr.js.map +0 -1
- package/dist/src/i18n/translations-ja.d.ts +0 -3
- package/dist/src/i18n/translations-ja.d.ts.map +0 -1
- package/dist/src/i18n/translations-ja.js +0 -171
- package/dist/src/i18n/translations-ja.js.map +0 -1
- package/dist/src/i18n/translations-uk.d.ts +0 -3
- package/dist/src/i18n/translations-uk.d.ts.map +0 -1
- package/dist/src/i18n/translations-uk.js +0 -171
- package/dist/src/i18n/translations-uk.js.map +0 -1
- package/dist/src/i18n/translations-zh-cn.d.ts +0 -3
- package/dist/src/i18n/translations-zh-cn.d.ts.map +0 -1
- package/dist/src/i18n/translations-zh-cn.js +0 -171
- package/dist/src/i18n/translations-zh-cn.js.map +0 -1
|
@@ -106,17 +106,20 @@ async function main() {
|
|
|
106
106
|
const workspaceName = await (0, input_1.default)({
|
|
107
107
|
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_WORKSPACE_NAME),
|
|
108
108
|
default: 'example-project',
|
|
109
|
-
validate: (val) => config_schema_1.ConfigValidator.validateWorkspaceName(val) ||
|
|
109
|
+
validate: (val) => config_schema_1.ConfigValidator.validateWorkspaceName(val) ||
|
|
110
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.VALIDATION_INVALID_WORKSPACE_NAME),
|
|
110
111
|
});
|
|
111
112
|
const projectPrefix = await (0, input_1.default)({
|
|
112
113
|
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_PROJECT_PREFIX),
|
|
113
114
|
default: workspaceName,
|
|
114
|
-
validate: (val) => config_schema_1.ConfigValidator.validatePrefix(val) ||
|
|
115
|
+
validate: (val) => config_schema_1.ConfigValidator.validatePrefix(val) ||
|
|
116
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.VALIDATION_INVALID_PREFIX),
|
|
115
117
|
});
|
|
116
118
|
const namespaceRoot = await (0, input_1.default)({
|
|
117
119
|
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_NPM_NAMESPACE),
|
|
118
120
|
default: `@${projectPrefix}`,
|
|
119
|
-
validate: (val) => config_schema_1.ConfigValidator.validateNamespace(val) ||
|
|
121
|
+
validate: (val) => config_schema_1.ConfigValidator.validateNamespace(val) ||
|
|
122
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.VALIDATION_INVALID_NAMESPACE),
|
|
120
123
|
});
|
|
121
124
|
const parentDir = path.resolve(await (0, input_1.default)({
|
|
122
125
|
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_PARENT_DIRECTORY),
|
|
@@ -124,12 +127,14 @@ async function main() {
|
|
|
124
127
|
}));
|
|
125
128
|
const gitRepo = await (0, input_1.default)({
|
|
126
129
|
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_GIT_REPO),
|
|
127
|
-
validate: (val) => config_schema_1.ConfigValidator.validateGitRepo(val) ||
|
|
130
|
+
validate: (val) => config_schema_1.ConfigValidator.validateGitRepo(val) ||
|
|
131
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.VALIDATION_INVALID_GIT_REPO),
|
|
128
132
|
});
|
|
129
133
|
const hostname = await (0, input_1.default)({
|
|
130
134
|
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_HOSTNAME),
|
|
131
135
|
default: `${workspaceName}.local`,
|
|
132
|
-
validate: (val) => /^[a-z0-9-]+(\.[a-z0-9-]+)*$/.test(val) ||
|
|
136
|
+
validate: (val) => /^[a-z0-9-]+(\.[a-z0-9-]+)*$/.test(val) ||
|
|
137
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.VALIDATION_INVALID_HOSTNAME),
|
|
133
138
|
});
|
|
134
139
|
// Get default strings based on selected language
|
|
135
140
|
const defaultStrings = {
|
|
@@ -174,7 +179,8 @@ async function main() {
|
|
|
174
179
|
siteTagline: 'Ваш слоган тут',
|
|
175
180
|
},
|
|
176
181
|
};
|
|
177
|
-
const currentDefaults = defaultStrings[selectedLanguage] ||
|
|
182
|
+
const currentDefaults = defaultStrings[selectedLanguage] ||
|
|
183
|
+
defaultStrings[i18n_lib_2.LanguageCodes.EN_US];
|
|
178
184
|
const siteTitle = await (0, input_1.default)({
|
|
179
185
|
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_SITE_TITLE),
|
|
180
186
|
default: currentDefaults.siteTitle,
|
|
@@ -225,16 +231,27 @@ async function main() {
|
|
|
225
231
|
devcontainerChoice = await (0, select_1.default)({
|
|
226
232
|
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_DEVCONTAINER_CONFIG),
|
|
227
233
|
choices: [
|
|
228
|
-
{
|
|
229
|
-
|
|
230
|
-
|
|
234
|
+
{
|
|
235
|
+
name: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.DEVCONTAINER_SIMPLE),
|
|
236
|
+
value: 'simple',
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.DEVCONTAINER_MONGODB),
|
|
240
|
+
value: 'mongodb',
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.DEVCONTAINER_MONGODB_REPLICASET),
|
|
244
|
+
value: 'mongodb-replicaset',
|
|
245
|
+
},
|
|
231
246
|
],
|
|
232
247
|
default: 'mongodb-replicaset',
|
|
233
248
|
});
|
|
234
|
-
if (devcontainerChoice === 'mongodb' ||
|
|
249
|
+
if (devcontainerChoice === 'mongodb' ||
|
|
250
|
+
devcontainerChoice === 'mongodb-replicaset') {
|
|
235
251
|
mongoPassword = await (0, input_1.default)({
|
|
236
252
|
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_MONGO_PASSWORD),
|
|
237
|
-
validate: (val) => val.length > 0 ||
|
|
253
|
+
validate: (val) => val.length > 0 ||
|
|
254
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.VALIDATION_PASSWORD_REQUIRED),
|
|
238
255
|
});
|
|
239
256
|
}
|
|
240
257
|
}
|
|
@@ -248,7 +265,8 @@ async function main() {
|
|
|
248
265
|
devDatabaseName = await (0, input_1.default)({
|
|
249
266
|
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_DEV_DATABASE_NAME),
|
|
250
267
|
default: 'test',
|
|
251
|
-
validate: (val) => val.length > 0 ||
|
|
268
|
+
validate: (val) => val.length > 0 ||
|
|
269
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.VALIDATION_DATABASE_NAME_REQUIRED),
|
|
252
270
|
});
|
|
253
271
|
}
|
|
254
272
|
logger_1.Logger.section((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.SECTION_SECURITY_CONFIG));
|
|
@@ -256,7 +274,9 @@ async function main() {
|
|
|
256
274
|
const HEX_64_REGEX = /^[0-9a-f]{64}$/i;
|
|
257
275
|
const promptOrGenerateSecret = async (name) => {
|
|
258
276
|
const generate = await (0, confirm_1.default)({
|
|
259
|
-
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_GENERATE_SECRET, {
|
|
277
|
+
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_GENERATE_SECRET, {
|
|
278
|
+
name,
|
|
279
|
+
}),
|
|
260
280
|
default: true,
|
|
261
281
|
});
|
|
262
282
|
if (generate) {
|
|
@@ -266,8 +286,11 @@ async function main() {
|
|
|
266
286
|
}
|
|
267
287
|
else {
|
|
268
288
|
return await (0, input_1.default)({
|
|
269
|
-
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_ENTER_SECRET, {
|
|
270
|
-
|
|
289
|
+
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_ENTER_SECRET, {
|
|
290
|
+
name,
|
|
291
|
+
}),
|
|
292
|
+
validate: (val) => HEX_64_REGEX.test(val) ||
|
|
293
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.VALIDATION_MUST_BE_HEX_64),
|
|
271
294
|
});
|
|
272
295
|
}
|
|
273
296
|
};
|
|
@@ -300,7 +323,7 @@ async function main() {
|
|
|
300
323
|
// Validate configuration
|
|
301
324
|
const validation = config_schema_1.ConfigValidator.validate(config);
|
|
302
325
|
if (!validation.valid) {
|
|
303
|
-
validation.errors.forEach(err => logger_1.Logger.error(err));
|
|
326
|
+
validation.errors.forEach((err) => logger_1.Logger.error(err));
|
|
304
327
|
process.exit(1);
|
|
305
328
|
}
|
|
306
329
|
// Setup context with all project names
|
|
@@ -309,8 +332,11 @@ async function main() {
|
|
|
309
332
|
['templatesDir', path.resolve(__dirname, '../../templates')],
|
|
310
333
|
['scaffoldingDir', path.resolve(__dirname, '../../scaffolding')],
|
|
311
334
|
];
|
|
312
|
-
projects.forEach(project => {
|
|
313
|
-
stateEntries.push([
|
|
335
|
+
projects.forEach((project) => {
|
|
336
|
+
stateEntries.push([
|
|
337
|
+
project.type === 'lib' ? 'libName' : `${project.type}Name`,
|
|
338
|
+
project.name,
|
|
339
|
+
]);
|
|
314
340
|
});
|
|
315
341
|
const context = {
|
|
316
342
|
config,
|
|
@@ -346,7 +372,8 @@ async function main() {
|
|
|
346
372
|
name: 'checkTargetDir',
|
|
347
373
|
description: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.STEP_CHECK_TARGET_DIR),
|
|
348
374
|
execute: () => {
|
|
349
|
-
if (fs.existsSync(monorepoPath) &&
|
|
375
|
+
if (fs.existsSync(monorepoPath) &&
|
|
376
|
+
fs.readdirSync(monorepoPath).length > 0) {
|
|
350
377
|
throw new i18n_lib_1.TranslatableGenericError(i18n_1.StarterComponentId, i18n_1.StarterStringKey.ERROR_DIRECTORY_NOT_EMPTY, { path: monorepoPath });
|
|
351
378
|
}
|
|
352
379
|
},
|
|
@@ -370,6 +397,13 @@ async function main() {
|
|
|
370
397
|
tsconfigBase.compilerOptions.esModuleInterop = true;
|
|
371
398
|
tsconfigBase.compilerOptions.allowSyntheticDefaultImports = true;
|
|
372
399
|
tsconfigBase.compilerOptions.allowImportingTsExtensions = true;
|
|
400
|
+
// Set target to es2020 for BigInt support
|
|
401
|
+
tsconfigBase.compilerOptions.target = 'es2020';
|
|
402
|
+
// Enable skipLibCheck to avoid type errors in node_modules
|
|
403
|
+
tsconfigBase.compilerOptions.skipLibCheck = true;
|
|
404
|
+
tsconfigBase.compilerOptions.skipDefaultLibCheck = true;
|
|
405
|
+
// Disable noImplicitOverride to avoid override modifier errors
|
|
406
|
+
tsconfigBase.compilerOptions.noImplicitOverride = false;
|
|
373
407
|
fs.writeFileSync(tsconfigBasePath, JSON.stringify(tsconfigBase, null, 2) + '\n');
|
|
374
408
|
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.TSCONFIG_BASE_UPDATED));
|
|
375
409
|
}
|
|
@@ -380,15 +414,42 @@ async function main() {
|
|
|
380
414
|
description: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.STEP_SETUP_GIT_ORIGIN),
|
|
381
415
|
skip: () => !gitRepo,
|
|
382
416
|
execute: () => {
|
|
383
|
-
|
|
417
|
+
try {
|
|
418
|
+
// Try to add the remote
|
|
419
|
+
(0, shell_utils_1.runCommand)(`git remote add origin ${gitRepo}`, {
|
|
420
|
+
cwd: monorepoPath,
|
|
421
|
+
dryRun: context.dryRun,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
catch (error) {
|
|
425
|
+
// If remote already exists, update it instead
|
|
426
|
+
const errorMsg = error.message || error.stderr?.toString() || '';
|
|
427
|
+
if (errorMsg.includes('remote origin already exists') ||
|
|
428
|
+
error.status === 3) {
|
|
429
|
+
logger_1.Logger.info('Remote origin already exists, updating URL...');
|
|
430
|
+
(0, shell_utils_1.runCommand)(`git remote set-url origin ${gitRepo}`, {
|
|
431
|
+
cwd: monorepoPath,
|
|
432
|
+
dryRun: context.dryRun,
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
throw error;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
384
439
|
},
|
|
385
440
|
});
|
|
386
441
|
executor.addStep({
|
|
387
442
|
name: 'yarnBerrySetup',
|
|
388
443
|
description: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.STEP_YARN_BERRY_SETUP),
|
|
389
444
|
execute: () => {
|
|
390
|
-
(0, shell_utils_1.runCommand)('yarn set version berry', {
|
|
391
|
-
|
|
445
|
+
(0, shell_utils_1.runCommand)('yarn set version berry', {
|
|
446
|
+
cwd: monorepoPath,
|
|
447
|
+
dryRun: context.dryRun,
|
|
448
|
+
});
|
|
449
|
+
(0, shell_utils_1.runCommand)('yarn config set nodeLinker node-modules', {
|
|
450
|
+
cwd: monorepoPath,
|
|
451
|
+
dryRun: context.dryRun,
|
|
452
|
+
});
|
|
392
453
|
(0, shell_utils_1.runCommand)('yarn', { cwd: monorepoPath, dryRun: context.dryRun });
|
|
393
454
|
},
|
|
394
455
|
});
|
|
@@ -397,21 +458,36 @@ async function main() {
|
|
|
397
458
|
description: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.STEP_ADD_NX_PLUGINS),
|
|
398
459
|
execute: () => {
|
|
399
460
|
try {
|
|
400
|
-
(0, shell_utils_1.runCommand)('yarn add -D @nx/react @nx/node', {
|
|
461
|
+
(0, shell_utils_1.runCommand)('yarn add -D @nx/react @nx/node', {
|
|
462
|
+
cwd: monorepoPath,
|
|
463
|
+
dryRun: context.dryRun,
|
|
464
|
+
});
|
|
401
465
|
}
|
|
402
466
|
catch (error) {
|
|
403
467
|
if (error.status === 1) {
|
|
404
|
-
logger_1.Logger.error('\n' +
|
|
468
|
+
logger_1.Logger.error('\n' +
|
|
469
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PACKAGE_INSTALLATION_FAILED));
|
|
405
470
|
logger_1.Logger.section((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PACKAGE_INSTALL_BUILD_TOOLS));
|
|
406
|
-
logger_1.Logger.dim(' ' +
|
|
407
|
-
|
|
471
|
+
logger_1.Logger.dim(' ' +
|
|
472
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.SYSTEM_CHECK_UBUNTU_DEBIAN));
|
|
473
|
+
logger_1.Logger.dim(' ' +
|
|
474
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.SYSTEM_CHECK_FEDORA_RHEL));
|
|
408
475
|
logger_1.Logger.dim(' ' + (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.SYSTEM_CHECK_MACOS));
|
|
409
|
-
logger_1.Logger.section('\n' +
|
|
476
|
+
logger_1.Logger.section('\n' +
|
|
477
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PACKAGE_RETRY_OR_SKIP));
|
|
410
478
|
}
|
|
411
479
|
throw error;
|
|
412
480
|
}
|
|
413
481
|
},
|
|
414
482
|
});
|
|
483
|
+
executor.addStep({
|
|
484
|
+
name: 'resetNxDaemon',
|
|
485
|
+
description: 'Resetting Nx daemon',
|
|
486
|
+
execute: () => {
|
|
487
|
+
// Reset Nx daemon to avoid plugin worker issues
|
|
488
|
+
(0, shell_utils_1.runCommand)('npx nx reset', { cwd: monorepoPath, dryRun: context.dryRun });
|
|
489
|
+
},
|
|
490
|
+
});
|
|
415
491
|
executor.addStep({
|
|
416
492
|
name: 'addYarnPackages',
|
|
417
493
|
description: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.STEP_ADD_YARN_PACKAGES),
|
|
@@ -419,10 +495,16 @@ async function main() {
|
|
|
419
495
|
const devPkgs = config.packages?.dev || [];
|
|
420
496
|
const prodPkgs = config.packages?.prod || [];
|
|
421
497
|
if (devPkgs.length > 0) {
|
|
422
|
-
(0, shell_utils_1.runCommand)(`yarn add -D ${devPkgs.join(' ')}`, {
|
|
498
|
+
(0, shell_utils_1.runCommand)(`yarn add -D ${devPkgs.join(' ')}`, {
|
|
499
|
+
cwd: monorepoPath,
|
|
500
|
+
dryRun: context.dryRun,
|
|
501
|
+
});
|
|
423
502
|
}
|
|
424
503
|
if (prodPkgs.length > 0) {
|
|
425
|
-
(0, shell_utils_1.runCommand)(`yarn add ${prodPkgs.join(' ')}`, {
|
|
504
|
+
(0, shell_utils_1.runCommand)(`yarn add ${prodPkgs.join(' ')}`, {
|
|
505
|
+
cwd: monorepoPath,
|
|
506
|
+
dryRun: context.dryRun,
|
|
507
|
+
});
|
|
426
508
|
}
|
|
427
509
|
},
|
|
428
510
|
});
|
|
@@ -430,10 +512,13 @@ async function main() {
|
|
|
430
512
|
name: 'generateProjects',
|
|
431
513
|
description: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.STEP_GENERATE_PROJECTS),
|
|
432
514
|
execute: () => {
|
|
433
|
-
projects.forEach(project => {
|
|
515
|
+
projects.forEach((project) => {
|
|
434
516
|
if (!project.enabled)
|
|
435
517
|
return;
|
|
436
|
-
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROJECT_GENERATING, {
|
|
518
|
+
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROJECT_GENERATING, {
|
|
519
|
+
type: project.type,
|
|
520
|
+
name: project.name,
|
|
521
|
+
}));
|
|
437
522
|
switch (project.type) {
|
|
438
523
|
case 'react':
|
|
439
524
|
project_generator_1.ProjectGenerator.generateReact(project, monorepoPath, config.nx, context.dryRun);
|
|
@@ -456,14 +541,18 @@ async function main() {
|
|
|
456
541
|
}
|
|
457
542
|
});
|
|
458
543
|
// Add copy-env and post-build targets to api and inituserdb project.json
|
|
459
|
-
const apiProject = projects.find(p => p.type === 'api' && p.enabled);
|
|
460
|
-
const initUserDbProject = projects.find(p => p.type === 'inituserdb' && p.enabled);
|
|
544
|
+
const apiProject = projects.find((p) => p.type === 'api' && p.enabled);
|
|
545
|
+
const initUserDbProject = projects.find((p) => p.type === 'inituserdb' && p.enabled);
|
|
461
546
|
if (apiProject) {
|
|
462
547
|
const projectJsonPath = path.join(monorepoPath, apiProject.name, 'project.json');
|
|
463
548
|
if (fs.existsSync(projectJsonPath)) {
|
|
464
549
|
const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, 'utf-8'));
|
|
465
550
|
// Configure assets with proper object notation for esbuild executor
|
|
466
551
|
if (projectJson.targets?.build?.options) {
|
|
552
|
+
// Add skipTypeCheck to avoid type errors in node_modules
|
|
553
|
+
projectJson.targets.build.options.skipTypeCheck = true;
|
|
554
|
+
// Set bundle to true to properly resolve dependencies
|
|
555
|
+
projectJson.targets.build.options.bundle = true;
|
|
467
556
|
// Convert any existing string-format assets to object notation
|
|
468
557
|
const existingAssets = projectJson.targets.build.options.assets || [];
|
|
469
558
|
const newAssets = [];
|
|
@@ -474,25 +563,26 @@ async function main() {
|
|
|
474
563
|
newAssets.push({
|
|
475
564
|
input: `${apiProject.name}/src/assets`,
|
|
476
565
|
glob: '**/*',
|
|
477
|
-
output: 'assets'
|
|
566
|
+
output: 'assets',
|
|
478
567
|
});
|
|
479
568
|
// Add views directory with proper object notation
|
|
480
569
|
newAssets.push({
|
|
481
570
|
input: `${apiProject.name}/src/views`,
|
|
482
571
|
glob: '**/*',
|
|
483
|
-
output: 'views'
|
|
572
|
+
output: 'views',
|
|
484
573
|
});
|
|
485
574
|
projectJson.targets.build.options.assets = newAssets;
|
|
486
575
|
}
|
|
487
576
|
else {
|
|
488
577
|
// Check if views is already configured
|
|
489
578
|
const hasViews = existingAssets.some((asset) => (typeof asset === 'string' && asset.includes('/views')) ||
|
|
490
|
-
(typeof asset === 'object' &&
|
|
579
|
+
(typeof asset === 'object' &&
|
|
580
|
+
asset.input?.includes('/views')));
|
|
491
581
|
if (!hasViews) {
|
|
492
582
|
existingAssets.push({
|
|
493
583
|
input: `${apiProject.name}/src/views`,
|
|
494
584
|
glob: '**/*',
|
|
495
|
-
output: 'views'
|
|
585
|
+
output: 'views',
|
|
496
586
|
});
|
|
497
587
|
}
|
|
498
588
|
}
|
|
@@ -500,39 +590,48 @@ async function main() {
|
|
|
500
590
|
projectJson.targets['copy-env'] = {
|
|
501
591
|
executor: 'nx:run-commands',
|
|
502
592
|
options: {
|
|
503
|
-
command: `cp ${apiProject.name}/.env dist/${apiProject.name}/.env
|
|
504
|
-
}
|
|
593
|
+
command: `cp ${apiProject.name}/.env dist/${apiProject.name}/.env`,
|
|
594
|
+
},
|
|
505
595
|
};
|
|
506
596
|
projectJson.targets['post-build'] = {
|
|
507
597
|
executor: 'nx:run-commands',
|
|
508
598
|
dependsOn: ['build'],
|
|
509
599
|
options: {
|
|
510
|
-
command: `cp ${apiProject.name}/.env dist/${apiProject.name}/.env
|
|
511
|
-
}
|
|
600
|
+
command: `cp ${apiProject.name}/.env dist/${apiProject.name}/.env`,
|
|
601
|
+
},
|
|
512
602
|
};
|
|
513
603
|
// Update serve to depend on post-build instead of build
|
|
514
604
|
if (projectJson.targets.serve) {
|
|
515
605
|
projectJson.targets.serve.dependsOn = ['post-build'];
|
|
516
606
|
projectJson.targets.serve.options.buildTarget = `${apiProject.name}:post-build`;
|
|
517
607
|
if (projectJson.targets.serve.configurations) {
|
|
518
|
-
Object.keys(projectJson.targets.serve.configurations).forEach(config => {
|
|
519
|
-
projectJson.targets.serve.configurations[config].buildTarget =
|
|
608
|
+
Object.keys(projectJson.targets.serve.configurations).forEach((config) => {
|
|
609
|
+
projectJson.targets.serve.configurations[config].buildTarget =
|
|
610
|
+
`${apiProject.name}:post-build`;
|
|
520
611
|
});
|
|
521
612
|
}
|
|
522
613
|
}
|
|
523
614
|
fs.writeFileSync(projectJsonPath, JSON.stringify(projectJson, null, 2) + '\n');
|
|
524
|
-
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROJECT_ADDED_TARGETS, {
|
|
615
|
+
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROJECT_ADDED_TARGETS, {
|
|
616
|
+
name: apiProject.name,
|
|
617
|
+
}));
|
|
525
618
|
}
|
|
526
619
|
}
|
|
527
620
|
if (initUserDbProject) {
|
|
528
621
|
const projectJsonPath = path.join(monorepoPath, initUserDbProject.name, 'project.json');
|
|
529
622
|
if (fs.existsSync(projectJsonPath)) {
|
|
530
623
|
const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, 'utf-8'));
|
|
624
|
+
// Add skipTypeCheck to avoid type errors in node_modules
|
|
625
|
+
if (projectJson.targets?.build?.options) {
|
|
626
|
+
projectJson.targets.build.options.skipTypeCheck = true;
|
|
627
|
+
// Set bundle to true to properly resolve dependencies
|
|
628
|
+
projectJson.targets.build.options.bundle = true;
|
|
629
|
+
}
|
|
531
630
|
projectJson.targets['copy-env'] = {
|
|
532
631
|
executor: 'nx:run-commands',
|
|
533
632
|
options: {
|
|
534
|
-
command: `cp ${initUserDbProject.name}/.env dist/${initUserDbProject.name}/.env
|
|
535
|
-
}
|
|
633
|
+
command: `cp ${initUserDbProject.name}/.env dist/${initUserDbProject.name}/.env`,
|
|
634
|
+
},
|
|
536
635
|
};
|
|
537
636
|
projectJson.targets['post-build'] = {
|
|
538
637
|
executor: 'nx:run-commands',
|
|
@@ -540,27 +639,30 @@ async function main() {
|
|
|
540
639
|
options: {
|
|
541
640
|
commands: [
|
|
542
641
|
`cp ${initUserDbProject.name}/.env dist/${initUserDbProject.name}/.env`,
|
|
543
|
-
`cd dist/${initUserDbProject.name} && yarn install
|
|
642
|
+
`cd dist/${initUserDbProject.name} && yarn install`,
|
|
544
643
|
],
|
|
545
|
-
parallel: false
|
|
546
|
-
}
|
|
644
|
+
parallel: false,
|
|
645
|
+
},
|
|
547
646
|
};
|
|
548
647
|
// Update serve to depend on post-build instead of build
|
|
549
648
|
if (projectJson.targets.serve) {
|
|
550
649
|
projectJson.targets.serve.dependsOn = ['post-build'];
|
|
551
650
|
projectJson.targets.serve.options.buildTarget = `${initUserDbProject.name}:post-build`;
|
|
552
651
|
if (projectJson.targets.serve.configurations) {
|
|
553
|
-
Object.keys(projectJson.targets.serve.configurations).forEach(config => {
|
|
554
|
-
projectJson.targets.serve.configurations[config].buildTarget =
|
|
652
|
+
Object.keys(projectJson.targets.serve.configurations).forEach((config) => {
|
|
653
|
+
projectJson.targets.serve.configurations[config].buildTarget =
|
|
654
|
+
`${initUserDbProject.name}:post-build`;
|
|
555
655
|
});
|
|
556
656
|
}
|
|
557
657
|
}
|
|
558
658
|
fs.writeFileSync(projectJsonPath, JSON.stringify(projectJson, null, 2) + '\n');
|
|
559
|
-
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROJECT_ADDED_TARGETS, {
|
|
659
|
+
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROJECT_ADDED_TARGETS, {
|
|
660
|
+
name: initUserDbProject.name,
|
|
661
|
+
}));
|
|
560
662
|
}
|
|
561
663
|
}
|
|
562
664
|
// Configure React project with explicit build configurations
|
|
563
|
-
const reactProject = projects.find(p => p.type === 'react' && p.enabled);
|
|
665
|
+
const reactProject = projects.find((p) => p.type === 'react' && p.enabled);
|
|
564
666
|
if (reactProject) {
|
|
565
667
|
const projectJsonPath = path.join(monorepoPath, reactProject.name, 'project.json');
|
|
566
668
|
if (fs.existsSync(projectJsonPath)) {
|
|
@@ -576,19 +678,21 @@ async function main() {
|
|
|
576
678
|
outputs: [`{workspaceRoot}/dist/${reactProject.name}`],
|
|
577
679
|
options: {
|
|
578
680
|
cwd: reactProject.name,
|
|
579
|
-
command: 'vite build --mode development'
|
|
681
|
+
command: 'vite build --mode development',
|
|
580
682
|
},
|
|
581
683
|
configurations: {
|
|
582
684
|
development: {
|
|
583
|
-
command: 'vite build --mode development'
|
|
685
|
+
command: 'vite build --mode development',
|
|
584
686
|
},
|
|
585
687
|
production: {
|
|
586
|
-
command: 'vite build --mode production'
|
|
587
|
-
}
|
|
588
|
-
}
|
|
688
|
+
command: 'vite build --mode production',
|
|
689
|
+
},
|
|
690
|
+
},
|
|
589
691
|
};
|
|
590
692
|
fs.writeFileSync(projectJsonPath, JSON.stringify(projectJson, null, 2) + '\n');
|
|
591
|
-
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROJECT_ADDED_TARGETS, {
|
|
693
|
+
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROJECT_ADDED_TARGETS, {
|
|
694
|
+
name: reactProject.name,
|
|
695
|
+
}));
|
|
592
696
|
}
|
|
593
697
|
// Update vite.config.ts to handle mode properly
|
|
594
698
|
const viteConfigPath = path.join(monorepoPath, reactProject.name, 'vite.config.ts');
|
|
@@ -611,19 +715,46 @@ async function main() {
|
|
|
611
715
|
}
|
|
612
716
|
},
|
|
613
717
|
});
|
|
718
|
+
executor.addStep({
|
|
719
|
+
name: 'updateTsConfigAppFiles',
|
|
720
|
+
description: 'Updating tsconfig.app.json files with skipLibCheck',
|
|
721
|
+
execute: () => {
|
|
722
|
+
// Update tsconfig.app.json for API and inituserdb projects
|
|
723
|
+
const apiProject = projects.find((p) => p.type === 'api' && p.enabled);
|
|
724
|
+
const initUserDbProject = projects.find((p) => p.type === 'inituserdb' && p.enabled);
|
|
725
|
+
[apiProject, initUserDbProject].forEach((project) => {
|
|
726
|
+
if (project) {
|
|
727
|
+
const tsconfigAppPath = path.join(monorepoPath, project.name, 'tsconfig.app.json');
|
|
728
|
+
if (fs.existsSync(tsconfigAppPath)) {
|
|
729
|
+
const tsconfigApp = JSON.parse(fs.readFileSync(tsconfigAppPath, 'utf-8'));
|
|
730
|
+
tsconfigApp.compilerOptions = tsconfigApp.compilerOptions || {};
|
|
731
|
+
tsconfigApp.compilerOptions.skipLibCheck = true;
|
|
732
|
+
fs.writeFileSync(tsconfigAppPath, JSON.stringify(tsconfigApp, null, 2) + '\n');
|
|
733
|
+
logger_1.Logger.info(`Updated ${project.name}/tsconfig.app.json with skipLibCheck`);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
},
|
|
738
|
+
});
|
|
614
739
|
executor.addStep({
|
|
615
740
|
name: 'installReactComponents',
|
|
616
741
|
description: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.STEP_INSTALL_REACT_COMPONENTS),
|
|
617
742
|
execute: () => {
|
|
618
|
-
const reactLibProject = projects.find(p => p.type === 'react-lib' && p.enabled);
|
|
743
|
+
const reactLibProject = projects.find((p) => p.type === 'react-lib' && p.enabled);
|
|
619
744
|
if (reactLibProject) {
|
|
620
|
-
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROJECT_INSTALLING_PACKAGE, {
|
|
745
|
+
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROJECT_INSTALLING_PACKAGE, {
|
|
746
|
+
package: '@digitaldefiance/express-suite-react-components',
|
|
747
|
+
project: reactLibProject.name,
|
|
748
|
+
}));
|
|
621
749
|
const projectPackageJsonPath = path.join(monorepoPath, reactLibProject.name, 'package.json');
|
|
622
750
|
const projectPackageJson = JSON.parse(fs.readFileSync(projectPackageJsonPath, 'utf-8'));
|
|
623
751
|
projectPackageJson.dependencies = projectPackageJson.dependencies || {};
|
|
624
752
|
projectPackageJson.dependencies['@digitaldefiance/express-suite-react-components'] = 'latest';
|
|
625
753
|
fs.writeFileSync(projectPackageJsonPath, JSON.stringify(projectPackageJson, null, 2) + '\n');
|
|
626
|
-
(0, shell_utils_1.runCommand)('yarn install', {
|
|
754
|
+
(0, shell_utils_1.runCommand)('yarn install', {
|
|
755
|
+
cwd: monorepoPath,
|
|
756
|
+
dryRun: context.dryRun,
|
|
757
|
+
});
|
|
627
758
|
}
|
|
628
759
|
},
|
|
629
760
|
});
|
|
@@ -645,8 +776,10 @@ async function main() {
|
|
|
645
776
|
NVM_USE_VERSION: config.node?.version,
|
|
646
777
|
YARN_VERSION: config.node?.yarnVersion,
|
|
647
778
|
};
|
|
648
|
-
projects.forEach(project => {
|
|
649
|
-
const key = project.type === 'lib'
|
|
779
|
+
projects.forEach((project) => {
|
|
780
|
+
const key = project.type === 'lib'
|
|
781
|
+
? 'LIB_NAME'
|
|
782
|
+
: `${project.type.toUpperCase().replace(/-/g, '_')}_NAME`;
|
|
650
783
|
variables[key] = project.name;
|
|
651
784
|
});
|
|
652
785
|
(0, template_renderer_1.renderTemplates)(context.state.get('templatesDir'), monorepoPath, variables, config.templates?.engine, context.dryRun);
|
|
@@ -670,7 +803,10 @@ async function main() {
|
|
|
670
803
|
// Template variables for scaffolding
|
|
671
804
|
const scaffoldingVars = {
|
|
672
805
|
workspaceName,
|
|
673
|
-
WorkspaceName: workspaceName.charAt(0).toUpperCase() +
|
|
806
|
+
WorkspaceName: workspaceName.charAt(0).toUpperCase() +
|
|
807
|
+
workspaceName
|
|
808
|
+
.slice(1)
|
|
809
|
+
.replace(/-([a-z])/g, (_, c) => c.toUpperCase()),
|
|
674
810
|
prefix: projectPrefix,
|
|
675
811
|
namespace: namespaceRoot,
|
|
676
812
|
hostname,
|
|
@@ -702,7 +838,7 @@ async function main() {
|
|
|
702
838
|
}
|
|
703
839
|
}
|
|
704
840
|
// Copy project-specific scaffolding
|
|
705
|
-
projects.forEach(project => {
|
|
841
|
+
projects.forEach((project) => {
|
|
706
842
|
const projectSrc = path.join(scaffoldingDir, project.type);
|
|
707
843
|
if (fs.existsSync(projectSrc)) {
|
|
708
844
|
(0, template_renderer_1.copyDir)(projectSrc, path.join(monorepoPath, project.name), scaffoldingVars, 'mustache', context.dryRun);
|
|
@@ -710,6 +846,122 @@ async function main() {
|
|
|
710
846
|
});
|
|
711
847
|
},
|
|
712
848
|
});
|
|
849
|
+
executor.addStep({
|
|
850
|
+
name: 'fixPlaywrightPlugin',
|
|
851
|
+
description: 'Configuring Nx Playwright plugin to avoid daemon issues',
|
|
852
|
+
skip: () => !includeE2e,
|
|
853
|
+
execute: () => {
|
|
854
|
+
const nxJsonPath = path.join(monorepoPath, 'nx.json');
|
|
855
|
+
if (fs.existsSync(nxJsonPath)) {
|
|
856
|
+
const nxJson = JSON.parse(fs.readFileSync(nxJsonPath, 'utf-8'));
|
|
857
|
+
// Find and disable the Playwright plugin to avoid daemon worker issues
|
|
858
|
+
if (nxJson.plugins && Array.isArray(nxJson.plugins)) {
|
|
859
|
+
const playwrightPluginIndex = nxJson.plugins.findIndex((plugin) => (typeof plugin === 'string' && plugin.includes('playwright')) ||
|
|
860
|
+
(typeof plugin === 'object' &&
|
|
861
|
+
plugin.plugin?.includes('playwright')));
|
|
862
|
+
if (playwrightPluginIndex !== -1) {
|
|
863
|
+
// Comment out or remove the Playwright plugin to avoid daemon issues
|
|
864
|
+
// Users can re-enable it manually if needed after the Nx team fixes the issue
|
|
865
|
+
nxJson.plugins.splice(playwrightPluginIndex, 1);
|
|
866
|
+
logger_1.Logger.info('Removed Playwright plugin from nx.json to avoid daemon worker issues');
|
|
867
|
+
logger_1.Logger.info('E2E tests will still work, but without automatic project graph inference');
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
fs.writeFileSync(nxJsonPath, JSON.stringify(nxJson, null, 2) + '\n');
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
});
|
|
874
|
+
executor.addStep({
|
|
875
|
+
name: 'createTypesDirectory',
|
|
876
|
+
description: 'Creating types directory with global.d.ts',
|
|
877
|
+
execute: () => {
|
|
878
|
+
const typesDir = path.join(monorepoPath, 'types');
|
|
879
|
+
const globalDtsPath = path.join(typesDir, 'global.d.ts');
|
|
880
|
+
// Create types directory if it doesn't exist
|
|
881
|
+
if (!fs.existsSync(typesDir)) {
|
|
882
|
+
fs.mkdirSync(typesDir, { recursive: true });
|
|
883
|
+
}
|
|
884
|
+
// Create global.d.ts with Error extensions
|
|
885
|
+
const globalDtsContent = `/**
|
|
886
|
+
* Global ambient type declarations for Error and globalThis extensions
|
|
887
|
+
*
|
|
888
|
+
* This file extends standard TypeScript interfaces to support additional
|
|
889
|
+
* properties and methods used throughout the Digital Defiance monorepo.
|
|
890
|
+
*/
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Extend global interfaces for Error and globalThis
|
|
894
|
+
*/
|
|
895
|
+
declare global {
|
|
896
|
+
/**
|
|
897
|
+
* Extend Error constructor interface to include V8's captureStackTrace method
|
|
898
|
+
* This is available in Node.js and V8-based environments
|
|
899
|
+
*/
|
|
900
|
+
interface ErrorConstructor {
|
|
901
|
+
/**
|
|
902
|
+
* Create a .stack property on the provided targetObject
|
|
903
|
+
* @param targetObject - Object to capture stack trace for
|
|
904
|
+
* @param constructorOpt - Optional constructor function to hide from stack trace
|
|
905
|
+
*/
|
|
906
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Extend Error instance interface to include custom properties
|
|
911
|
+
* used for enhanced error handling throughout the codebase
|
|
912
|
+
*
|
|
913
|
+
* Note: The 'cause' property is already defined in ES2022 Error interface
|
|
914
|
+
*/
|
|
915
|
+
interface Error {
|
|
916
|
+
/**
|
|
917
|
+
* Timestamp when error was disposed (for resource cleanup tracking)
|
|
918
|
+
*/
|
|
919
|
+
disposedAt?: string;
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Error type classification (e.g., 'validation', 'network', 'auth')
|
|
923
|
+
*/
|
|
924
|
+
type?: string;
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Component identifier where the error originated
|
|
928
|
+
*/
|
|
929
|
+
componentId?: string;
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Map of reasons or context for the error
|
|
933
|
+
*/
|
|
934
|
+
reasonMap?: Record<string, unknown>;
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Additional metadata associated with the error
|
|
938
|
+
*/
|
|
939
|
+
metadata?: Record<string, unknown>;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Global active context for tracking application state
|
|
944
|
+
* TODO: Define proper type based on actual usage patterns
|
|
945
|
+
*/
|
|
946
|
+
var GlobalActiveContext: any;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// This export statement is required to make this file a module
|
|
950
|
+
// and ensure the global augmentation works correctly
|
|
951
|
+
export {};
|
|
952
|
+
`;
|
|
953
|
+
fs.writeFileSync(globalDtsPath, globalDtsContent);
|
|
954
|
+
logger_1.Logger.info('Created types/global.d.ts with Error extensions');
|
|
955
|
+
// Also create node_modules/types/global.d.ts for library references
|
|
956
|
+
const nodeModulesTypesDir = path.join(monorepoPath, 'node_modules', 'types');
|
|
957
|
+
const nodeModulesGlobalDtsPath = path.join(nodeModulesTypesDir, 'global.d.ts');
|
|
958
|
+
if (!fs.existsSync(nodeModulesTypesDir)) {
|
|
959
|
+
fs.mkdirSync(nodeModulesTypesDir, { recursive: true });
|
|
960
|
+
}
|
|
961
|
+
fs.writeFileSync(nodeModulesGlobalDtsPath, globalDtsContent);
|
|
962
|
+
logger_1.Logger.info('Created node_modules/types/global.d.ts for library references');
|
|
963
|
+
},
|
|
964
|
+
});
|
|
713
965
|
executor.addStep({
|
|
714
966
|
name: 'generateLicense',
|
|
715
967
|
description: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.STEP_GENERATE_LICENSE),
|
|
@@ -728,11 +980,11 @@ async function main() {
|
|
|
728
980
|
namespaceRoot,
|
|
729
981
|
gitRepo,
|
|
730
982
|
};
|
|
731
|
-
projects.forEach(project => {
|
|
983
|
+
projects.forEach((project) => {
|
|
732
984
|
scriptContext[`${project.type}Name`] = project.name;
|
|
733
985
|
});
|
|
734
986
|
const addScripts = {
|
|
735
|
-
|
|
987
|
+
build: 'NODE_ENV=production npx nx run-many --target=build --all --configuration=production',
|
|
736
988
|
'build:dev': 'NODE_ENV=development npx nx run-many --target=build --all --configuration=development',
|
|
737
989
|
'test:all': 'yarn test:jest && yarn test:e2e',
|
|
738
990
|
'test:jest': 'NODE_ENV=development npx nx run-many --target=test --all --configuration=development',
|
|
@@ -740,22 +992,28 @@ async function main() {
|
|
|
740
992
|
'prettier:check': "prettier --check '**/*.{ts,tsx}'",
|
|
741
993
|
'prettier:fix': "prettier --write '**/*.{ts,tsx}'",
|
|
742
994
|
};
|
|
743
|
-
const apiProject = projects.find(p => p.type === 'api');
|
|
995
|
+
const apiProject = projects.find((p) => p.type === 'api');
|
|
744
996
|
if (apiProject) {
|
|
745
|
-
addScripts['serve'] =
|
|
746
|
-
|
|
747
|
-
addScripts['serve:
|
|
748
|
-
|
|
997
|
+
addScripts['serve'] =
|
|
998
|
+
`npx nx serve ${apiProject.name} --configuration production`;
|
|
999
|
+
addScripts['serve:stream'] =
|
|
1000
|
+
`npx nx serve ${apiProject.name} --configuration production --output-style=stream`;
|
|
1001
|
+
addScripts['serve:dev'] =
|
|
1002
|
+
`npx nx serve ${apiProject.name} --configuration development`;
|
|
1003
|
+
addScripts['serve:dev:stream'] =
|
|
1004
|
+
`npx nx serve ${apiProject.name} --configuration development --output-style=stream`;
|
|
749
1005
|
addScripts['build:api'] = `npx nx build ${apiProject.name}`;
|
|
750
1006
|
}
|
|
751
|
-
const reactProject = projects.find(p => p.type === 'react');
|
|
1007
|
+
const reactProject = projects.find((p) => p.type === 'react');
|
|
752
1008
|
if (reactProject) {
|
|
753
1009
|
addScripts['build:react'] = `npx nx build ${reactProject.name}`;
|
|
754
1010
|
}
|
|
755
|
-
const initUserDbProject = projects.find(p => p.type === 'inituserdb');
|
|
1011
|
+
const initUserDbProject = projects.find((p) => p.type === 'inituserdb');
|
|
756
1012
|
if (initUserDbProject) {
|
|
757
|
-
addScripts['inituserdb'] =
|
|
758
|
-
|
|
1013
|
+
addScripts['inituserdb'] =
|
|
1014
|
+
`yarn build:dev && npx nx serve ${initUserDbProject.name} --output-style=stream`;
|
|
1015
|
+
addScripts['inituserdb:drop'] =
|
|
1016
|
+
`yarn build:dev && npx nx serve ${initUserDbProject.name} --output-style=stream --args=--drop`;
|
|
759
1017
|
}
|
|
760
1018
|
const interpolatedScripts = {};
|
|
761
1019
|
for (const [k, v] of Object.entries(addScripts)) {
|
|
@@ -777,8 +1035,8 @@ async function main() {
|
|
|
777
1035
|
name: 'setupEnvironment',
|
|
778
1036
|
description: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.STEP_SETUP_ENVIRONMENT),
|
|
779
1037
|
execute: () => {
|
|
780
|
-
const apiProject = projects.find(p => p.type === 'api');
|
|
781
|
-
const initUserDbProject = projects.find(p => p.type === 'inituserdb');
|
|
1038
|
+
const apiProject = projects.find((p) => p.type === 'api');
|
|
1039
|
+
const initUserDbProject = projects.find((p) => p.type === 'inituserdb');
|
|
782
1040
|
// Escape password for .env file usage
|
|
783
1041
|
const escapeEnvValue = (value) => {
|
|
784
1042
|
// Use single quotes - safest for passwords with special chars
|
|
@@ -788,7 +1046,9 @@ async function main() {
|
|
|
788
1046
|
};
|
|
789
1047
|
// Build MONGO_URI with optional password (URL-encode password for special characters)
|
|
790
1048
|
const buildMongoUri = (dbName) => {
|
|
791
|
-
const auth = mongoPassword
|
|
1049
|
+
const auth = mongoPassword
|
|
1050
|
+
? `admin:${encodeURIComponent(mongoPassword)}@`
|
|
1051
|
+
: '';
|
|
792
1052
|
// authSource=admin is always required when authenticating as admin user
|
|
793
1053
|
// replicaSet and directConnection settings depend on the MongoDB setup
|
|
794
1054
|
const params = devcontainerChoice === 'mongodb-replicaset'
|
|
@@ -814,7 +1074,8 @@ async function main() {
|
|
|
814
1074
|
envContent = envContent.replace(/MNEMONIC_ENCRYPTION_KEY=.*/g, `MNEMONIC_ENCRYPTION_KEY=${mnemonicEncryptionKey}`);
|
|
815
1075
|
envContent = envContent.replace(/MNEMONIC_HMAC_SECRET=.*/g, `MNEMONIC_HMAC_SECRET=${mnemonicHmacSecret}`);
|
|
816
1076
|
// Replace MONGO_URI if MongoDB devcontainer
|
|
817
|
-
if (devcontainerChoice === 'mongodb' ||
|
|
1077
|
+
if (devcontainerChoice === 'mongodb' ||
|
|
1078
|
+
devcontainerChoice === 'mongodb-replicaset') {
|
|
818
1079
|
const mongoUri = buildMongoUri(workspaceName);
|
|
819
1080
|
envContent = envContent.replace(/MONGO_URI=.*/g, `MONGO_URI=${mongoUri}`);
|
|
820
1081
|
}
|
|
@@ -839,7 +1100,8 @@ async function main() {
|
|
|
839
1100
|
}
|
|
840
1101
|
}
|
|
841
1102
|
// Setup devcontainer .env if devcontainer with MongoDB
|
|
842
|
-
if (devcontainerChoice === 'mongodb' ||
|
|
1103
|
+
if (devcontainerChoice === 'mongodb' ||
|
|
1104
|
+
devcontainerChoice === 'mongodb-replicaset') {
|
|
843
1105
|
const devcontainerEnvExamplePath = path.join(monorepoPath, '.devcontainer', '.env.example');
|
|
844
1106
|
const devcontainerEnvPath = path.join(monorepoPath, '.devcontainer', '.env');
|
|
845
1107
|
if (fs.existsSync(devcontainerEnvExamplePath)) {
|
|
@@ -872,7 +1134,10 @@ async function main() {
|
|
|
872
1134
|
description: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.STEP_REBUILD_NATIVE_MODULES),
|
|
873
1135
|
execute: () => {
|
|
874
1136
|
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.COMMAND_REBUILDING_NATIVE));
|
|
875
|
-
(0, shell_utils_1.runCommand)('yarn config set enableScripts true', {
|
|
1137
|
+
(0, shell_utils_1.runCommand)('yarn config set enableScripts true', {
|
|
1138
|
+
cwd: monorepoPath,
|
|
1139
|
+
dryRun: context.dryRun,
|
|
1140
|
+
});
|
|
876
1141
|
(0, shell_utils_1.runCommand)('yarn rebuild', { cwd: monorepoPath, dryRun: context.dryRun });
|
|
877
1142
|
},
|
|
878
1143
|
});
|
|
@@ -903,14 +1168,20 @@ async function main() {
|
|
|
903
1168
|
});
|
|
904
1169
|
if (doCommit) {
|
|
905
1170
|
(0, shell_utils_1.runCommand)('git add -A', { cwd: monorepoPath, dryRun: context.dryRun });
|
|
906
|
-
(0, shell_utils_1.runCommand)('git commit -m "Initial commit"', {
|
|
1171
|
+
(0, shell_utils_1.runCommand)('git commit -m "Initial commit"', {
|
|
1172
|
+
cwd: monorepoPath,
|
|
1173
|
+
dryRun: context.dryRun,
|
|
1174
|
+
});
|
|
907
1175
|
if (gitRepo) {
|
|
908
1176
|
const doPush = await (0, confirm_1.default)({
|
|
909
1177
|
message: (0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.PROMPT_PUSH_TO_REMOTE),
|
|
910
1178
|
default: true,
|
|
911
1179
|
});
|
|
912
1180
|
if (doPush) {
|
|
913
|
-
(0, shell_utils_1.runCommand)('git push --set-upstream origin main', {
|
|
1181
|
+
(0, shell_utils_1.runCommand)('git push --set-upstream origin main', {
|
|
1182
|
+
cwd: monorepoPath,
|
|
1183
|
+
dryRun: context.dryRun,
|
|
1184
|
+
});
|
|
914
1185
|
}
|
|
915
1186
|
}
|
|
916
1187
|
}
|
|
@@ -927,7 +1198,10 @@ async function main() {
|
|
|
927
1198
|
});
|
|
928
1199
|
if (installPlaywright) {
|
|
929
1200
|
logger_1.Logger.info((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.COMMAND_INSTALLING_PLAYWRIGHT_BROWSERS));
|
|
930
|
-
(0, shell_utils_1.runCommand)('yarn playwright install --with-deps', {
|
|
1201
|
+
(0, shell_utils_1.runCommand)('yarn playwright install --with-deps', {
|
|
1202
|
+
cwd: monorepoPath,
|
|
1203
|
+
dryRun: context.dryRun,
|
|
1204
|
+
});
|
|
931
1205
|
}
|
|
932
1206
|
else {
|
|
933
1207
|
logger_1.Logger.warning((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.COMMAND_SKIPPED_PLAYWRIGHT));
|
|
@@ -942,12 +1216,18 @@ async function main() {
|
|
|
942
1216
|
process.exit(0);
|
|
943
1217
|
}
|
|
944
1218
|
logger_1.Logger.header((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.SUCCESS_GENERATION_COMPLETE));
|
|
945
|
-
logger_1.Logger.success((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.SUCCESS_MONOREPO_CREATED, {
|
|
946
|
-
|
|
1219
|
+
logger_1.Logger.success((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.SUCCESS_MONOREPO_CREATED, {
|
|
1220
|
+
path: logger_1.Logger.path(monorepoPath),
|
|
1221
|
+
}));
|
|
1222
|
+
const apiProject = projects.find((p) => p.type === 'api');
|
|
947
1223
|
if (apiProject) {
|
|
948
|
-
logger_1.Logger.warning(`\n` +
|
|
1224
|
+
logger_1.Logger.warning(`\n` +
|
|
1225
|
+
(0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.WARNING_UPDATE_ENV_FILE, {
|
|
1226
|
+
name: apiProject.name,
|
|
1227
|
+
}));
|
|
949
1228
|
}
|
|
950
|
-
if (devcontainerChoice === 'mongodb' ||
|
|
1229
|
+
if (devcontainerChoice === 'mongodb' ||
|
|
1230
|
+
devcontainerChoice === 'mongodb-replicaset') {
|
|
951
1231
|
logger_1.Logger.warning((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.WARNING_UPDATE_DEVCONTAINER_ENV));
|
|
952
1232
|
}
|
|
953
1233
|
logger_1.Logger.section((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.SECTION_NEXT_STEPS));
|
|
@@ -958,7 +1238,7 @@ async function main() {
|
|
|
958
1238
|
logger_1.Logger.dim(` yarn build:dev`);
|
|
959
1239
|
logger_1.Logger.dim(` yarn serve:dev`);
|
|
960
1240
|
logger_1.Logger.section((0, i18n_1.getStarterTranslation)(i18n_1.StarterStringKey.SECTION_GENERATED_PROJECTS));
|
|
961
|
-
projects.forEach(p => {
|
|
1241
|
+
projects.forEach((p) => {
|
|
962
1242
|
if (p.enabled) {
|
|
963
1243
|
logger_1.Logger.dim(` ${p.type.padEnd(12)} ${p.name}`);
|
|
964
1244
|
}
|