opticore-installer 1.2.55 → 1.2.56

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
 
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opticore-installer",
3
- "version": "1.2.55",
3
+ "version": "1.2.56",
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
+ }