opticore-installer 1.2.58 → 1.2.60
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/index.cjs +45 -6
- package/dist/index.js +45 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -463,6 +463,10 @@ function endingMessageInfo(projectName) {
|
|
|
463
463
|
console.log(` ${import_chalk4.default.dim("\u276F")} ${import_chalk4.default.cyan("npm run start:dev")}
|
|
464
464
|
`);
|
|
465
465
|
console.log(` ${import_chalk4.default.dim("NB: Before running app, make sure to define in .env file application host and port.")}
|
|
466
|
+
`);
|
|
467
|
+
console.log(` ${import_chalk4.default.bold("Recommended packages:")}`);
|
|
468
|
+
console.log(` ${import_chalk4.default.dim("\u276F")} ${import_chalk4.default.cyan("npm install opticore-validator")} ${import_chalk4.default.dim("\u2014 data schema validation with rich rules and custom messages.")}`);
|
|
469
|
+
console.log(` ${import_chalk4.default.dim("\u276F")} ${import_chalk4.default.cyan("npm install opticore-orm-orchestrator")} ${import_chalk4.default.dim("\u2014 interactive model/entity generator for Prisma, TypeORM, Drizzle ORM, MikroORM and Sequelize.")}
|
|
466
470
|
`);
|
|
467
471
|
(0, import_prompts9.outro)(import_chalk4.default.dim("To install opticore components: ") + import_chalk4.default.green("npx opticore list"));
|
|
468
472
|
}
|
|
@@ -546,9 +550,11 @@ var import_fs4 = __toESM(require("fs"), 1);
|
|
|
546
550
|
var SUpdateEnv = class {
|
|
547
551
|
arg;
|
|
548
552
|
argumentConnection;
|
|
549
|
-
|
|
553
|
+
dbUrlScheme;
|
|
554
|
+
constructor(arg, argumentConnection, dbUrlScheme) {
|
|
550
555
|
this.arg = arg;
|
|
551
556
|
this.argumentConnection = argumentConnection;
|
|
557
|
+
this.dbUrlScheme = dbUrlScheme;
|
|
552
558
|
this.__init();
|
|
553
559
|
}
|
|
554
560
|
/**
|
|
@@ -559,6 +565,7 @@ var SUpdateEnv = class {
|
|
|
559
565
|
const envFileLines = import_fs4.default.readFileSync("config/env/.env", "utf8").split("\n");
|
|
560
566
|
this.updateDatabaseSection(envFileLines, this.arg);
|
|
561
567
|
this.updateArgConnexionSection(envFileLines, this.argumentConnection);
|
|
568
|
+
this.updateDatabaseUrlSection(envFileLines, this.arg, this.dbUrlScheme);
|
|
562
569
|
import_fs4.default.writeFileSync("config/env/.env", envFileLines.join("\n"));
|
|
563
570
|
}
|
|
564
571
|
/**
|
|
@@ -614,12 +621,39 @@ var SUpdateEnv = class {
|
|
|
614
621
|
envFileLines.splice(insertPosition, 0, `${targetKey}=${argumentConnection}`);
|
|
615
622
|
}
|
|
616
623
|
}
|
|
624
|
+
/**
|
|
625
|
+
* Derives DATABASE_URL from the DATA_BASE_* values so both stay consistent.
|
|
626
|
+
* Only touches the file when the DATABASE_URL key already exists there and a scheme
|
|
627
|
+
* (e.g. "postgres", "mysql", "mongodb") is known for the chosen database.
|
|
628
|
+
*
|
|
629
|
+
* @param envFileLines
|
|
630
|
+
* @param arg
|
|
631
|
+
* @param dbUrlScheme
|
|
632
|
+
* @protected
|
|
633
|
+
*/
|
|
634
|
+
updateDatabaseUrlSection(envFileLines, arg, dbUrlScheme) {
|
|
635
|
+
if (!dbUrlScheme || !arg?.dbName) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
const targetKey = "DATABASE_URL";
|
|
639
|
+
const index = envFileLines.findIndex((line) => {
|
|
640
|
+
const trimmed = line.trim();
|
|
641
|
+
return !trimmed.startsWith("#") && trimmed.split("=")[0] === targetKey;
|
|
642
|
+
});
|
|
643
|
+
if (index === -1) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
const user = encodeURIComponent(arg.dbUser ?? "");
|
|
647
|
+
const pwd = encodeURIComponent(arg.dbPwd ?? "");
|
|
648
|
+
const databaseUrl = `${dbUrlScheme}://${user}:${pwd}@${arg.dbHost ?? ""}:${arg.dbPort ?? ""}/${arg.dbName}`;
|
|
649
|
+
envFileLines[index] = `${targetKey}=${databaseUrl}`;
|
|
650
|
+
}
|
|
617
651
|
};
|
|
618
652
|
|
|
619
653
|
// src/presentations/middlewares/templateProject/templateProject.middleware.ts
|
|
620
|
-
var MTemplateProject = async (repoGit, projectPath, currentPath, callback, arg, projectName, argumentConnection) => {
|
|
654
|
+
var MTemplateProject = async (repoGit, projectPath, currentPath, callback, arg, projectName, argumentConnection, dbUrlScheme) => {
|
|
621
655
|
await SProjectCreation(repoGit, projectPath, currentPath, projectName);
|
|
622
|
-
new SUpdateEnv(arg, argumentConnection);
|
|
656
|
+
new SUpdateEnv(arg, argumentConnection, dbUrlScheme);
|
|
623
657
|
await callback([]);
|
|
624
658
|
};
|
|
625
659
|
|
|
@@ -855,7 +889,8 @@ var MSelectDB = async (projectPath, currentPath, projectName) => {
|
|
|
855
889
|
async () => await createMySQLDatabase(mysqlParams),
|
|
856
890
|
envParams,
|
|
857
891
|
projectName,
|
|
858
|
-
CConnectionProperties
|
|
892
|
+
CConnectionProperties,
|
|
893
|
+
"mysql"
|
|
859
894
|
);
|
|
860
895
|
break;
|
|
861
896
|
}
|
|
@@ -874,7 +909,9 @@ var MSelectDB = async (projectPath, currentPath, projectName) => {
|
|
|
874
909
|
currentPath,
|
|
875
910
|
async () => await createPostgresDatabase(postgresParams),
|
|
876
911
|
envParams,
|
|
877
|
-
projectName
|
|
912
|
+
projectName,
|
|
913
|
+
void 0,
|
|
914
|
+
"postgres"
|
|
878
915
|
);
|
|
879
916
|
break;
|
|
880
917
|
}
|
|
@@ -886,7 +923,9 @@ var MSelectDB = async (projectPath, currentPath, projectName) => {
|
|
|
886
923
|
currentPath,
|
|
887
924
|
async () => await createMongoDatabase(mongoParams),
|
|
888
925
|
envParams,
|
|
889
|
-
projectName
|
|
926
|
+
projectName,
|
|
927
|
+
void 0,
|
|
928
|
+
"mongodb"
|
|
890
929
|
);
|
|
891
930
|
break;
|
|
892
931
|
}
|
package/dist/index.js
CHANGED
|
@@ -440,6 +440,10 @@ function endingMessageInfo(projectName) {
|
|
|
440
440
|
console.log(` ${chalk4.dim("\u276F")} ${chalk4.cyan("npm run start:dev")}
|
|
441
441
|
`);
|
|
442
442
|
console.log(` ${chalk4.dim("NB: Before running app, make sure to define in .env file application host and port.")}
|
|
443
|
+
`);
|
|
444
|
+
console.log(` ${chalk4.bold("Recommended packages:")}`);
|
|
445
|
+
console.log(` ${chalk4.dim("\u276F")} ${chalk4.cyan("npm install opticore-validator")} ${chalk4.dim("\u2014 data schema validation with rich rules and custom messages.")}`);
|
|
446
|
+
console.log(` ${chalk4.dim("\u276F")} ${chalk4.cyan("npm install opticore-orm-orchestrator")} ${chalk4.dim("\u2014 interactive model/entity generator for Prisma, TypeORM, Drizzle ORM, MikroORM and Sequelize.")}
|
|
443
447
|
`);
|
|
444
448
|
outro(chalk4.dim("To install opticore components: ") + chalk4.green("npx opticore list"));
|
|
445
449
|
}
|
|
@@ -523,9 +527,11 @@ import fs4 from "fs";
|
|
|
523
527
|
var SUpdateEnv = class {
|
|
524
528
|
arg;
|
|
525
529
|
argumentConnection;
|
|
526
|
-
|
|
530
|
+
dbUrlScheme;
|
|
531
|
+
constructor(arg, argumentConnection, dbUrlScheme) {
|
|
527
532
|
this.arg = arg;
|
|
528
533
|
this.argumentConnection = argumentConnection;
|
|
534
|
+
this.dbUrlScheme = dbUrlScheme;
|
|
529
535
|
this.__init();
|
|
530
536
|
}
|
|
531
537
|
/**
|
|
@@ -536,6 +542,7 @@ var SUpdateEnv = class {
|
|
|
536
542
|
const envFileLines = fs4.readFileSync("config/env/.env", "utf8").split("\n");
|
|
537
543
|
this.updateDatabaseSection(envFileLines, this.arg);
|
|
538
544
|
this.updateArgConnexionSection(envFileLines, this.argumentConnection);
|
|
545
|
+
this.updateDatabaseUrlSection(envFileLines, this.arg, this.dbUrlScheme);
|
|
539
546
|
fs4.writeFileSync("config/env/.env", envFileLines.join("\n"));
|
|
540
547
|
}
|
|
541
548
|
/**
|
|
@@ -591,12 +598,39 @@ var SUpdateEnv = class {
|
|
|
591
598
|
envFileLines.splice(insertPosition, 0, `${targetKey}=${argumentConnection}`);
|
|
592
599
|
}
|
|
593
600
|
}
|
|
601
|
+
/**
|
|
602
|
+
* Derives DATABASE_URL from the DATA_BASE_* values so both stay consistent.
|
|
603
|
+
* Only touches the file when the DATABASE_URL key already exists there and a scheme
|
|
604
|
+
* (e.g. "postgres", "mysql", "mongodb") is known for the chosen database.
|
|
605
|
+
*
|
|
606
|
+
* @param envFileLines
|
|
607
|
+
* @param arg
|
|
608
|
+
* @param dbUrlScheme
|
|
609
|
+
* @protected
|
|
610
|
+
*/
|
|
611
|
+
updateDatabaseUrlSection(envFileLines, arg, dbUrlScheme) {
|
|
612
|
+
if (!dbUrlScheme || !arg?.dbName) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
const targetKey = "DATABASE_URL";
|
|
616
|
+
const index = envFileLines.findIndex((line) => {
|
|
617
|
+
const trimmed = line.trim();
|
|
618
|
+
return !trimmed.startsWith("#") && trimmed.split("=")[0] === targetKey;
|
|
619
|
+
});
|
|
620
|
+
if (index === -1) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
const user = encodeURIComponent(arg.dbUser ?? "");
|
|
624
|
+
const pwd = encodeURIComponent(arg.dbPwd ?? "");
|
|
625
|
+
const databaseUrl = `${dbUrlScheme}://${user}:${pwd}@${arg.dbHost ?? ""}:${arg.dbPort ?? ""}/${arg.dbName}`;
|
|
626
|
+
envFileLines[index] = `${targetKey}=${databaseUrl}`;
|
|
627
|
+
}
|
|
594
628
|
};
|
|
595
629
|
|
|
596
630
|
// src/presentations/middlewares/templateProject/templateProject.middleware.ts
|
|
597
|
-
var MTemplateProject = async (repoGit, projectPath, currentPath, callback, arg, projectName, argumentConnection) => {
|
|
631
|
+
var MTemplateProject = async (repoGit, projectPath, currentPath, callback, arg, projectName, argumentConnection, dbUrlScheme) => {
|
|
598
632
|
await SProjectCreation(repoGit, projectPath, currentPath, projectName);
|
|
599
|
-
new SUpdateEnv(arg, argumentConnection);
|
|
633
|
+
new SUpdateEnv(arg, argumentConnection, dbUrlScheme);
|
|
600
634
|
await callback([]);
|
|
601
635
|
};
|
|
602
636
|
|
|
@@ -832,7 +866,8 @@ var MSelectDB = async (projectPath, currentPath, projectName) => {
|
|
|
832
866
|
async () => await createMySQLDatabase(mysqlParams),
|
|
833
867
|
envParams,
|
|
834
868
|
projectName,
|
|
835
|
-
CConnectionProperties
|
|
869
|
+
CConnectionProperties,
|
|
870
|
+
"mysql"
|
|
836
871
|
);
|
|
837
872
|
break;
|
|
838
873
|
}
|
|
@@ -851,7 +886,9 @@ var MSelectDB = async (projectPath, currentPath, projectName) => {
|
|
|
851
886
|
currentPath,
|
|
852
887
|
async () => await createPostgresDatabase(postgresParams),
|
|
853
888
|
envParams,
|
|
854
|
-
projectName
|
|
889
|
+
projectName,
|
|
890
|
+
void 0,
|
|
891
|
+
"postgres"
|
|
855
892
|
);
|
|
856
893
|
break;
|
|
857
894
|
}
|
|
@@ -863,7 +900,9 @@ var MSelectDB = async (projectPath, currentPath, projectName) => {
|
|
|
863
900
|
currentPath,
|
|
864
901
|
async () => await createMongoDatabase(mongoParams),
|
|
865
902
|
envParams,
|
|
866
|
-
projectName
|
|
903
|
+
projectName,
|
|
904
|
+
void 0,
|
|
905
|
+
"mongodb"
|
|
867
906
|
);
|
|
868
907
|
break;
|
|
869
908
|
}
|