@create-node-app/core 0.3.4 → 0.3.6

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.js CHANGED
@@ -571,6 +571,8 @@ var fileLoader = ({
571
571
  appName,
572
572
  originalDirectory,
573
573
  verbose,
574
+ useYarn,
575
+ usePnpm,
574
576
  srcDir = DEFAULT_SRC_PATH,
575
577
  runCommand,
576
578
  installCommand,
@@ -589,6 +591,8 @@ var fileLoader = ({
589
591
  appName,
590
592
  originalDirectory,
591
593
  verbose,
594
+ useYarn,
595
+ usePnpm,
592
596
  mode,
593
597
  srcDir,
594
598
  runCommand,
@@ -604,6 +608,8 @@ var loadFiles = async ({
604
608
  appName,
605
609
  originalDirectory,
606
610
  verbose,
611
+ useYarn = false,
612
+ usePnpm = false,
607
613
  srcDir = DEFAULT_SRC_PATH,
608
614
  runCommand,
609
615
  installCommand,
@@ -621,22 +627,33 @@ var loadFiles = async ({
621
627
  "!package-lock.json",
622
628
  "!template.json",
623
629
  "!yarn.lock",
624
- "!pnpm-lock.yaml"
630
+ "!pnpm-lock.yaml",
631
+ // based on the package manager we want to ignore files containing
632
+ // the other package as condition.
633
+ // For example, if `usePnpm` is true, the we need to ignore
634
+ // all files with `.if-npm` or `.if-yarn` somewhere in the name.
635
+ ...usePnpm ? ["!*.if-npm.*", "!*.if-yarn.*"] : useYarn ? ["!*.if-npm.*", "!*.if-pnpm.*"] : ["!*.if-yarn.*", "!*.if-pnpm.*"]
625
636
  ],
626
637
  directoryFilter: ["!package"]
627
638
  })) {
628
639
  try {
640
+ const entryWithoutNodePackageManager = {
641
+ ...entry,
642
+ path: entry.path.replace(/\.if-(npm|yarn|pnpm)/, "")
643
+ };
629
644
  await fileLoader({
630
645
  root,
631
646
  templateDir,
632
647
  appName,
633
648
  originalDirectory,
634
649
  verbose,
650
+ useYarn,
651
+ usePnpm,
635
652
  srcDir,
636
653
  runCommand,
637
654
  installCommand,
638
655
  ...customOptions
639
- })(entry);
656
+ })(entryWithoutNodePackageManager);
640
657
  } catch (err) {
641
658
  if (verbose) {
642
659
  console.log(err);
@@ -671,13 +688,13 @@ var install = (root, useYarn = false, usePnpm = false, dependencies = [], verbos
671
688
  }
672
689
  } else if (usePnpm) {
673
690
  command = "pnpm";
674
- args = ["add", "--save"];
691
+ args = ["install", "--loglevel", "error"];
675
692
  if (isDevDependencies) {
676
693
  args.push("--save-dev");
694
+ } else {
695
+ args.push("--save");
677
696
  }
678
697
  args.push(...dependencies);
679
- args.push("--cwd");
680
- args.push(root);
681
698
  } else {
682
699
  command = "npm";
683
700
  args = ["install", "--loglevel", "error"];
@@ -752,6 +769,8 @@ var run = async ({
752
769
  appName,
753
770
  originalDirectory,
754
771
  verbose,
772
+ useYarn,
773
+ usePnpm,
755
774
  runCommand,
756
775
  installCommand,
757
776
  ...customOptions
@@ -790,10 +809,10 @@ var run = async ({
790
809
  }
791
810
  } else {
792
811
  console.log(import_chalk3.default.yellow("Skip package installation."));
793
- const packageJson = JSON.parse(
812
+ const packageJson2 = JSON.parse(
794
813
  import_fs5.default.readFileSync(`${root}/package.json`, "utf8")
795
814
  );
796
- packageJson.dependencies = dependencies.reduce((dep, elem) => {
815
+ packageJson2.dependencies = dependencies.reduce((dep, elem) => {
797
816
  const nextDep = dep;
798
817
  if (/.+@(\^|~)?[0-9a-zA-Z-.]+$/.test(elem)) {
799
818
  const [name, version] = elem.split("@");
@@ -803,7 +822,7 @@ var run = async ({
803
822
  }
804
823
  return nextDep;
805
824
  }, {});
806
- packageJson.devDependencies = devDependencies.reduce((dep, elem) => {
825
+ packageJson2.devDependencies = devDependencies.reduce((dep, elem) => {
807
826
  const nextDep = dep;
808
827
  if (/.+@(\^|~)?[0-9a-zA-Z-.]+$/.test(elem)) {
809
828
  const [name, version] = elem.split("@");
@@ -815,7 +834,7 @@ var run = async ({
815
834
  }, {});
816
835
  import_fs5.default.writeFileSync(
817
836
  import_path4.default.join(root, "package.json"),
818
- JSON.stringify(packageJson, null, 2) + import_os3.default.EOL
837
+ JSON.stringify(packageJson2, null, 2) + import_os3.default.EOL
819
838
  );
820
839
  console.log();
821
840
  console.log(import_chalk3.default.green("Successfully updated package.json."));
@@ -831,10 +850,10 @@ var run = async ({
831
850
  "Failed to initialize git repository. Run `git init` to initialize git repository after the process is completed."
832
851
  );
833
852
  if (installDependencies && isOnline) {
834
- const packageJson = JSON.parse(
853
+ const packageJson2 = JSON.parse(
835
854
  import_fs5.default.readFileSync(`${root}/package.json`, "utf8")
836
855
  );
837
- if (packageJson.scripts && packageJson.scripts["format"]) {
856
+ if (packageJson2.scripts && packageJson2.scripts["format"]) {
838
857
  try {
839
858
  await runCommandInProjectDir(
840
859
  root,
@@ -846,7 +865,7 @@ var run = async ({
846
865
  } catch {
847
866
  }
848
867
  }
849
- if (packageJson.scripts && packageJson.scripts["lint:fix"]) {
868
+ if (packageJson2.scripts && packageJson2.scripts["lint:fix"]) {
850
869
  try {
851
870
  await runCommandInProjectDir(
852
871
  root,
@@ -861,7 +880,23 @@ var run = async ({
861
880
  }
862
881
  console.log();
863
882
  console.log(import_chalk3.default.green("Successfully created project " + appName + "."));
864
- process.chdir(root);
883
+ console.log();
884
+ console.log("Done! Now run:");
885
+ console.log();
886
+ console.log(import_chalk3.default.cyan(` cd ${appName}`));
887
+ console.log(import_chalk3.default.cyan(` ${installCommand}`));
888
+ const packageJson = JSON.parse(
889
+ import_fs5.default.readFileSync(`${root}/package.json`, "utf8")
890
+ );
891
+ const lookForScripts = ["sls:offline", "dev", "start"];
892
+ for (const script of lookForScripts) {
893
+ if (packageJson.scripts && packageJson.scripts[script]) {
894
+ console.log(import_chalk3.default.cyan(` ${runCommand} ${script}`));
895
+ break;
896
+ }
897
+ }
898
+ console.log();
899
+ console.log(import_chalk3.default.green("Happy hacking!"));
865
900
  };
866
901
  var createApp = async ({
867
902
  name,
package/dist/index.mjs CHANGED
@@ -542,6 +542,8 @@ var fileLoader = ({
542
542
  appName,
543
543
  originalDirectory,
544
544
  verbose,
545
+ useYarn,
546
+ usePnpm,
545
547
  srcDir = DEFAULT_SRC_PATH,
546
548
  runCommand,
547
549
  installCommand,
@@ -560,6 +562,8 @@ var fileLoader = ({
560
562
  appName,
561
563
  originalDirectory,
562
564
  verbose,
565
+ useYarn,
566
+ usePnpm,
563
567
  mode,
564
568
  srcDir,
565
569
  runCommand,
@@ -575,6 +579,8 @@ var loadFiles = async ({
575
579
  appName,
576
580
  originalDirectory,
577
581
  verbose,
582
+ useYarn = false,
583
+ usePnpm = false,
578
584
  srcDir = DEFAULT_SRC_PATH,
579
585
  runCommand,
580
586
  installCommand,
@@ -592,22 +598,33 @@ var loadFiles = async ({
592
598
  "!package-lock.json",
593
599
  "!template.json",
594
600
  "!yarn.lock",
595
- "!pnpm-lock.yaml"
601
+ "!pnpm-lock.yaml",
602
+ // based on the package manager we want to ignore files containing
603
+ // the other package as condition.
604
+ // For example, if `usePnpm` is true, the we need to ignore
605
+ // all files with `.if-npm` or `.if-yarn` somewhere in the name.
606
+ ...usePnpm ? ["!*.if-npm.*", "!*.if-yarn.*"] : useYarn ? ["!*.if-npm.*", "!*.if-pnpm.*"] : ["!*.if-yarn.*", "!*.if-pnpm.*"]
596
607
  ],
597
608
  directoryFilter: ["!package"]
598
609
  })) {
599
610
  try {
611
+ const entryWithoutNodePackageManager = {
612
+ ...entry,
613
+ path: entry.path.replace(/\.if-(npm|yarn|pnpm)/, "")
614
+ };
600
615
  await fileLoader({
601
616
  root,
602
617
  templateDir,
603
618
  appName,
604
619
  originalDirectory,
605
620
  verbose,
621
+ useYarn,
622
+ usePnpm,
606
623
  srcDir,
607
624
  runCommand,
608
625
  installCommand,
609
626
  ...customOptions
610
- })(entry);
627
+ })(entryWithoutNodePackageManager);
611
628
  } catch (err) {
612
629
  if (verbose) {
613
630
  console.log(err);
@@ -642,13 +659,13 @@ var install = (root, useYarn = false, usePnpm = false, dependencies = [], verbos
642
659
  }
643
660
  } else if (usePnpm) {
644
661
  command = "pnpm";
645
- args = ["add", "--save"];
662
+ args = ["install", "--loglevel", "error"];
646
663
  if (isDevDependencies) {
647
664
  args.push("--save-dev");
665
+ } else {
666
+ args.push("--save");
648
667
  }
649
668
  args.push(...dependencies);
650
- args.push("--cwd");
651
- args.push(root);
652
669
  } else {
653
670
  command = "npm";
654
671
  args = ["install", "--loglevel", "error"];
@@ -723,6 +740,8 @@ var run = async ({
723
740
  appName,
724
741
  originalDirectory,
725
742
  verbose,
743
+ useYarn,
744
+ usePnpm,
726
745
  runCommand,
727
746
  installCommand,
728
747
  ...customOptions
@@ -761,10 +780,10 @@ var run = async ({
761
780
  }
762
781
  } else {
763
782
  console.log(chalk3.yellow("Skip package installation."));
764
- const packageJson = JSON.parse(
783
+ const packageJson2 = JSON.parse(
765
784
  fs4.readFileSync(`${root}/package.json`, "utf8")
766
785
  );
767
- packageJson.dependencies = dependencies.reduce((dep, elem) => {
786
+ packageJson2.dependencies = dependencies.reduce((dep, elem) => {
768
787
  const nextDep = dep;
769
788
  if (/.+@(\^|~)?[0-9a-zA-Z-.]+$/.test(elem)) {
770
789
  const [name, version] = elem.split("@");
@@ -774,7 +793,7 @@ var run = async ({
774
793
  }
775
794
  return nextDep;
776
795
  }, {});
777
- packageJson.devDependencies = devDependencies.reduce((dep, elem) => {
796
+ packageJson2.devDependencies = devDependencies.reduce((dep, elem) => {
778
797
  const nextDep = dep;
779
798
  if (/.+@(\^|~)?[0-9a-zA-Z-.]+$/.test(elem)) {
780
799
  const [name, version] = elem.split("@");
@@ -786,7 +805,7 @@ var run = async ({
786
805
  }, {});
787
806
  fs4.writeFileSync(
788
807
  path3.join(root, "package.json"),
789
- JSON.stringify(packageJson, null, 2) + os3.EOL
808
+ JSON.stringify(packageJson2, null, 2) + os3.EOL
790
809
  );
791
810
  console.log();
792
811
  console.log(chalk3.green("Successfully updated package.json."));
@@ -802,10 +821,10 @@ var run = async ({
802
821
  "Failed to initialize git repository. Run `git init` to initialize git repository after the process is completed."
803
822
  );
804
823
  if (installDependencies && isOnline) {
805
- const packageJson = JSON.parse(
824
+ const packageJson2 = JSON.parse(
806
825
  fs4.readFileSync(`${root}/package.json`, "utf8")
807
826
  );
808
- if (packageJson.scripts && packageJson.scripts["format"]) {
827
+ if (packageJson2.scripts && packageJson2.scripts["format"]) {
809
828
  try {
810
829
  await runCommandInProjectDir(
811
830
  root,
@@ -817,7 +836,7 @@ var run = async ({
817
836
  } catch {
818
837
  }
819
838
  }
820
- if (packageJson.scripts && packageJson.scripts["lint:fix"]) {
839
+ if (packageJson2.scripts && packageJson2.scripts["lint:fix"]) {
821
840
  try {
822
841
  await runCommandInProjectDir(
823
842
  root,
@@ -832,7 +851,23 @@ var run = async ({
832
851
  }
833
852
  console.log();
834
853
  console.log(chalk3.green("Successfully created project " + appName + "."));
835
- process.chdir(root);
854
+ console.log();
855
+ console.log("Done! Now run:");
856
+ console.log();
857
+ console.log(chalk3.cyan(` cd ${appName}`));
858
+ console.log(chalk3.cyan(` ${installCommand}`));
859
+ const packageJson = JSON.parse(
860
+ fs4.readFileSync(`${root}/package.json`, "utf8")
861
+ );
862
+ const lookForScripts = ["sls:offline", "dev", "start"];
863
+ for (const script of lookForScripts) {
864
+ if (packageJson.scripts && packageJson.scripts[script]) {
865
+ console.log(chalk3.cyan(` ${runCommand} ${script}`));
866
+ break;
867
+ }
868
+ }
869
+ console.log();
870
+ console.log(chalk3.green("Happy hacking!"));
836
871
  };
837
872
  var createApp = async ({
838
873
  name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@create-node-app/core",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "scripts": {
17
17
  "lint": "eslint **/*.ts*",
18
18
  "lint:fix": "eslint **/*.ts* --fix",
19
- "typecheck": "tsc --noEmit",
19
+ "type-check": "tsc --noEmit",
20
20
  "build": "tsup ./index.ts --format esm,cjs --dts",
21
21
  "dev": "tsup ./index.ts --format esm,cjs --watch --dts"
22
22
  },