opticore-installer 1.2.55 → 1.2.57

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 CHANGED
@@ -568,37 +568,21 @@ var SUpdateEnv = class {
568
568
  * @protected
569
569
  */
570
570
  updateDatabaseSection(envFileLines, arg) {
571
- const sectionHeader = "#DATABASE";
572
- const sectionStart = envFileLines.findIndex((line) => line.trim() === sectionHeader);
573
- if (sectionStart === -1) {
574
- console.warn(`Section ${sectionHeader} not found in .env file`);
575
- return;
576
- }
577
- for (let i = sectionStart + 1; i < envFileLines.length; i++) {
571
+ const keyMap = {
572
+ DATA_BASE_NAME: arg.dbName,
573
+ DATA_BASE_USER: arg.dbUser,
574
+ DATA_BASE_PASSWORD: arg.dbPwd,
575
+ DATA_BASE_HOST: arg.dbHost,
576
+ DATA_BASE_PORT: arg.dbPort
577
+ };
578
+ for (let i = 0; i < envFileLines.length; i++) {
578
579
  const line = envFileLines[i].trim();
579
- if (line.startsWith("#") && line !== sectionHeader) {
580
- break;
581
- }
582
580
  if (!line || line.startsWith("#")) {
583
581
  continue;
584
582
  }
585
583
  const [key] = line.split("=");
586
- switch (key) {
587
- case "DATA_BASE_NAME":
588
- envFileLines[i] = `${key}=${arg.dbName ?? ""}`;
589
- break;
590
- case "DATA_BASE_USER":
591
- envFileLines[i] = `${key}=${arg.dbUser ?? ""}`;
592
- break;
593
- case "DATA_BASE_PASSWORD":
594
- envFileLines[i] = `${key}=${arg.dbPwd ?? ""}`;
595
- break;
596
- case "DATA_BASE_HOST":
597
- envFileLines[i] = `${key}=${arg.dbHost ?? ""}`;
598
- break;
599
- case "DATA_BASE_PORT":
600
- envFileLines[i] = `${key}=${arg.dbPort ?? ""}`;
601
- break;
584
+ if (Object.prototype.hasOwnProperty.call(keyMap, key)) {
585
+ envFileLines[i] = `${key}=${keyMap[key] ?? ""}`;
602
586
  }
603
587
  }
604
588
  }
@@ -609,34 +593,25 @@ var SUpdateEnv = class {
609
593
  * @protected
610
594
  */
611
595
  updateArgConnexionSection(envFileLines, argumentConnection) {
612
- const sectionHeader = "#ARG CONNEXION";
613
- const sectionStart = envFileLines.findIndex((line) => line.trim() === sectionHeader);
614
- if (sectionStart === -1) {
615
- console.warn(`Section ${sectionHeader} not found in .env file`);
616
- return;
617
- }
618
596
  if (argumentConnection === void 0) {
619
597
  return;
620
598
  }
621
- let found = false;
622
- for (let i = sectionStart + 1; i < envFileLines.length; i++) {
599
+ const targetKey = "ARGUMENTS_DATABASE_CONNECTION";
600
+ for (let i = 0; i < envFileLines.length; i++) {
623
601
  const line = envFileLines[i].trim();
624
- if (line.startsWith("#") && line !== sectionHeader) {
625
- break;
626
- }
627
602
  if (!line || line.startsWith("#")) {
628
603
  continue;
629
604
  }
630
605
  const [key] = line.split("=");
631
- if (key === "ARGUMENTS_DATABASE_CONNECTION") {
606
+ if (key === targetKey) {
632
607
  envFileLines[i] = `${key}=${argumentConnection ?? ""}`;
633
- found = true;
634
- break;
608
+ return;
635
609
  }
636
610
  }
637
- if (!found && argumentConnection !== null) {
638
- const insertPosition = sectionStart + 1;
639
- envFileLines.splice(insertPosition, 0, `ARGUMENTS_DATABASE_CONNECTION=${argumentConnection}`);
611
+ if (argumentConnection !== null) {
612
+ const headerIndex = envFileLines.findIndex((line) => /^#+\s*ARG\s*CONNEXION\s*$/i.test(line.trim()));
613
+ const insertPosition = headerIndex !== -1 ? headerIndex + 1 : envFileLines.length;
614
+ envFileLines.splice(insertPosition, 0, `${targetKey}=${argumentConnection}`);
640
615
  }
641
616
  }
642
617
  };
@@ -644,7 +619,7 @@ var SUpdateEnv = class {
644
619
  // src/presentations/middlewares/templateProject/templateProject.middleware.ts
645
620
  var MTemplateProject = async (repoGit, projectPath, currentPath, callback, arg, projectName, argumentConnection) => {
646
621
  await SProjectCreation(repoGit, projectPath, currentPath, projectName);
647
- callback;
622
+ await callback([]);
648
623
  new SUpdateEnv(arg, argumentConnection);
649
624
  };
650
625
 
@@ -868,45 +843,53 @@ var MSelectDB = async (projectPath, currentPath, projectName) => {
868
843
  });
869
844
  return dbChosen;
870
845
  } else {
846
+ const envParams = params.envParams;
871
847
  dbSelect.map(async (item) => {
872
848
  switch (item) {
873
- case CDbNameValue.mysql:
849
+ case CDbNameValue.mysql: {
850
+ const mysqlParams = { ...envParams, projectPath };
874
851
  await MTemplateProject(
875
852
  CProjectTemplatePath.mysql,
876
853
  projectPath,
877
854
  currentPath,
878
- async () => await createMySQLDatabase(
879
- //@ts-ignore
880
- params.dbParams
881
- ),
882
- params.envParams,
855
+ async () => await createMySQLDatabase(mysqlParams),
856
+ envParams,
883
857
  projectName,
884
858
  CConnectionProperties
885
859
  );
886
860
  break;
887
- case CDbNameValue.postgresql:
861
+ }
862
+ case CDbNameValue.postgresql: {
863
+ const postgresParams = {
864
+ host: envParams.dbHost,
865
+ user: envParams.dbUser,
866
+ password: envParams.dbPwd,
867
+ port: envParams.dbPort,
868
+ database: envParams.dbName,
869
+ projectName
870
+ };
888
871
  await MTemplateProject(
889
872
  CProjectTemplatePath.postgresql,
890
873
  projectPath,
891
874
  currentPath,
892
- async () => await createPostgresDatabase(
893
- //@ts-ignore
894
- params.dbParams
895
- ),
896
- params.envParams,
875
+ async () => await createPostgresDatabase(postgresParams),
876
+ envParams,
897
877
  projectName
898
878
  );
899
879
  break;
900
- case CDbNameValue.mongodb:
880
+ }
881
+ case CDbNameValue.mongodb: {
882
+ const mongoParams = { ...envParams, projectPath };
901
883
  await MTemplateProject(
902
884
  CProjectTemplatePath.mongodb,
903
885
  projectPath,
904
886
  currentPath,
905
- async () => await createMongoDatabase(params),
906
- params.envParams,
887
+ async () => await createMongoDatabase(mongoParams),
888
+ envParams,
907
889
  projectName
908
890
  );
909
891
  break;
892
+ }
910
893
  case CDbNameValue.oracle:
911
894
  await MTemplateProject(
912
895
  CProjectTemplatePath.oracle,
@@ -914,7 +897,7 @@ var MSelectDB = async (projectPath, currentPath, projectName) => {
914
897
  currentPath,
915
898
  async () => {
916
899
  },
917
- params.envParams,
900
+ envParams,
918
901
  projectName
919
902
  );
920
903
  break;
@@ -925,7 +908,7 @@ var MSelectDB = async (projectPath, currentPath, projectName) => {
925
908
  currentPath,
926
909
  async () => {
927
910
  },
928
- params.envParams,
911
+ envParams,
929
912
  projectName
930
913
  );
931
914
  break;
package/dist/index.js CHANGED
@@ -545,37 +545,21 @@ var SUpdateEnv = class {
545
545
  * @protected
546
546
  */
547
547
  updateDatabaseSection(envFileLines, arg) {
548
- const sectionHeader = "#DATABASE";
549
- const sectionStart = envFileLines.findIndex((line) => line.trim() === sectionHeader);
550
- if (sectionStart === -1) {
551
- console.warn(`Section ${sectionHeader} not found in .env file`);
552
- return;
553
- }
554
- for (let i = sectionStart + 1; i < envFileLines.length; i++) {
548
+ const keyMap = {
549
+ DATA_BASE_NAME: arg.dbName,
550
+ DATA_BASE_USER: arg.dbUser,
551
+ DATA_BASE_PASSWORD: arg.dbPwd,
552
+ DATA_BASE_HOST: arg.dbHost,
553
+ DATA_BASE_PORT: arg.dbPort
554
+ };
555
+ for (let i = 0; i < envFileLines.length; i++) {
555
556
  const line = envFileLines[i].trim();
556
- if (line.startsWith("#") && line !== sectionHeader) {
557
- break;
558
- }
559
557
  if (!line || line.startsWith("#")) {
560
558
  continue;
561
559
  }
562
560
  const [key] = line.split("=");
563
- switch (key) {
564
- case "DATA_BASE_NAME":
565
- envFileLines[i] = `${key}=${arg.dbName ?? ""}`;
566
- break;
567
- case "DATA_BASE_USER":
568
- envFileLines[i] = `${key}=${arg.dbUser ?? ""}`;
569
- break;
570
- case "DATA_BASE_PASSWORD":
571
- envFileLines[i] = `${key}=${arg.dbPwd ?? ""}`;
572
- break;
573
- case "DATA_BASE_HOST":
574
- envFileLines[i] = `${key}=${arg.dbHost ?? ""}`;
575
- break;
576
- case "DATA_BASE_PORT":
577
- envFileLines[i] = `${key}=${arg.dbPort ?? ""}`;
578
- break;
561
+ if (Object.prototype.hasOwnProperty.call(keyMap, key)) {
562
+ envFileLines[i] = `${key}=${keyMap[key] ?? ""}`;
579
563
  }
580
564
  }
581
565
  }
@@ -586,34 +570,25 @@ var SUpdateEnv = class {
586
570
  * @protected
587
571
  */
588
572
  updateArgConnexionSection(envFileLines, argumentConnection) {
589
- const sectionHeader = "#ARG CONNEXION";
590
- const sectionStart = envFileLines.findIndex((line) => line.trim() === sectionHeader);
591
- if (sectionStart === -1) {
592
- console.warn(`Section ${sectionHeader} not found in .env file`);
593
- return;
594
- }
595
573
  if (argumentConnection === void 0) {
596
574
  return;
597
575
  }
598
- let found = false;
599
- for (let i = sectionStart + 1; i < envFileLines.length; i++) {
576
+ const targetKey = "ARGUMENTS_DATABASE_CONNECTION";
577
+ for (let i = 0; i < envFileLines.length; i++) {
600
578
  const line = envFileLines[i].trim();
601
- if (line.startsWith("#") && line !== sectionHeader) {
602
- break;
603
- }
604
579
  if (!line || line.startsWith("#")) {
605
580
  continue;
606
581
  }
607
582
  const [key] = line.split("=");
608
- if (key === "ARGUMENTS_DATABASE_CONNECTION") {
583
+ if (key === targetKey) {
609
584
  envFileLines[i] = `${key}=${argumentConnection ?? ""}`;
610
- found = true;
611
- break;
585
+ return;
612
586
  }
613
587
  }
614
- if (!found && argumentConnection !== null) {
615
- const insertPosition = sectionStart + 1;
616
- envFileLines.splice(insertPosition, 0, `ARGUMENTS_DATABASE_CONNECTION=${argumentConnection}`);
588
+ if (argumentConnection !== null) {
589
+ const headerIndex = envFileLines.findIndex((line) => /^#+\s*ARG\s*CONNEXION\s*$/i.test(line.trim()));
590
+ const insertPosition = headerIndex !== -1 ? headerIndex + 1 : envFileLines.length;
591
+ envFileLines.splice(insertPosition, 0, `${targetKey}=${argumentConnection}`);
617
592
  }
618
593
  }
619
594
  };
@@ -621,7 +596,7 @@ var SUpdateEnv = class {
621
596
  // src/presentations/middlewares/templateProject/templateProject.middleware.ts
622
597
  var MTemplateProject = async (repoGit, projectPath, currentPath, callback, arg, projectName, argumentConnection) => {
623
598
  await SProjectCreation(repoGit, projectPath, currentPath, projectName);
624
- callback;
599
+ await callback([]);
625
600
  new SUpdateEnv(arg, argumentConnection);
626
601
  };
627
602
 
@@ -845,45 +820,53 @@ var MSelectDB = async (projectPath, currentPath, projectName) => {
845
820
  });
846
821
  return dbChosen;
847
822
  } else {
823
+ const envParams = params.envParams;
848
824
  dbSelect.map(async (item) => {
849
825
  switch (item) {
850
- case CDbNameValue.mysql:
826
+ case CDbNameValue.mysql: {
827
+ const mysqlParams = { ...envParams, projectPath };
851
828
  await MTemplateProject(
852
829
  CProjectTemplatePath.mysql,
853
830
  projectPath,
854
831
  currentPath,
855
- async () => await createMySQLDatabase(
856
- //@ts-ignore
857
- params.dbParams
858
- ),
859
- params.envParams,
832
+ async () => await createMySQLDatabase(mysqlParams),
833
+ envParams,
860
834
  projectName,
861
835
  CConnectionProperties
862
836
  );
863
837
  break;
864
- case CDbNameValue.postgresql:
838
+ }
839
+ case CDbNameValue.postgresql: {
840
+ const postgresParams = {
841
+ host: envParams.dbHost,
842
+ user: envParams.dbUser,
843
+ password: envParams.dbPwd,
844
+ port: envParams.dbPort,
845
+ database: envParams.dbName,
846
+ projectName
847
+ };
865
848
  await MTemplateProject(
866
849
  CProjectTemplatePath.postgresql,
867
850
  projectPath,
868
851
  currentPath,
869
- async () => await createPostgresDatabase(
870
- //@ts-ignore
871
- params.dbParams
872
- ),
873
- params.envParams,
852
+ async () => await createPostgresDatabase(postgresParams),
853
+ envParams,
874
854
  projectName
875
855
  );
876
856
  break;
877
- case CDbNameValue.mongodb:
857
+ }
858
+ case CDbNameValue.mongodb: {
859
+ const mongoParams = { ...envParams, projectPath };
878
860
  await MTemplateProject(
879
861
  CProjectTemplatePath.mongodb,
880
862
  projectPath,
881
863
  currentPath,
882
- async () => await createMongoDatabase(params),
883
- params.envParams,
864
+ async () => await createMongoDatabase(mongoParams),
865
+ envParams,
884
866
  projectName
885
867
  );
886
868
  break;
869
+ }
887
870
  case CDbNameValue.oracle:
888
871
  await MTemplateProject(
889
872
  CProjectTemplatePath.oracle,
@@ -891,7 +874,7 @@ var MSelectDB = async (projectPath, currentPath, projectName) => {
891
874
  currentPath,
892
875
  async () => {
893
876
  },
894
- params.envParams,
877
+ envParams,
895
878
  projectName
896
879
  );
897
880
  break;
@@ -902,7 +885,7 @@ var MSelectDB = async (projectPath, currentPath, projectName) => {
902
885
  currentPath,
903
886
  async () => {
904
887
  },
905
- params.envParams,
888
+ envParams,
906
889
  projectName
907
890
  );
908
891
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opticore-installer",
3
- "version": "1.2.55",
3
+ "version": "1.2.57",
4
4
  "description": "opticore framework installer",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -44,4 +44,4 @@
44
44
  "devDependencies": {
45
45
  "@types/pg": "^8.20.0"
46
46
  }
47
- }
47
+ }