@create-node-app/core 0.1.2 → 0.1.4
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 +47 -4
- package/dist/index.mjs +47 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -57,18 +57,26 @@ var import_semver = __toESM(require("semver"));
|
|
|
57
57
|
var import_dns = __toESM(require("dns"));
|
|
58
58
|
var import_url = require("url");
|
|
59
59
|
var shouldUseYarn = () => {
|
|
60
|
-
const { hasMinYarnPnp, hasMaxYarnPnp } = checkYarnVersion();
|
|
60
|
+
const { hasMinYarnPnp, hasMaxYarnPnp, yarnVersion } = checkYarnVersion();
|
|
61
61
|
if (!hasMinYarnPnp) {
|
|
62
|
+
console.log(
|
|
63
|
+
import_chalk.default.yellow(
|
|
64
|
+
`You are using yarn version ${import_chalk.default.bold(
|
|
65
|
+
yarnVersion
|
|
66
|
+
)} which is not supported yet. To use Yarn, install v1.12.0 or higher and lower than v2.0.0. See https://yarnpkg.com for instructions on how to update.`
|
|
67
|
+
)
|
|
68
|
+
);
|
|
62
69
|
return false;
|
|
63
70
|
}
|
|
64
71
|
if (!hasMaxYarnPnp) {
|
|
65
72
|
console.log(
|
|
66
73
|
import_chalk.default.yellow(
|
|
67
|
-
`You are using a pre-release version of Yarn which is not supported yet. To use Yarn, install v1.12.0 or higher.`
|
|
74
|
+
`You are using a pre-release version of Yarn which is not supported yet. To use Yarn, install v1.12.0 or higher and lower than v2.0.0. See https://yarnpkg.com for instructions on how to update.`
|
|
68
75
|
)
|
|
69
76
|
);
|
|
70
77
|
return false;
|
|
71
78
|
}
|
|
79
|
+
return true;
|
|
72
80
|
};
|
|
73
81
|
var checkThatNpmCanReadCwd = () => {
|
|
74
82
|
const cwd = process.cwd();
|
|
@@ -671,6 +679,20 @@ var install = (root, useYarn = false, dependencies = [], verbose = false, isOnli
|
|
|
671
679
|
});
|
|
672
680
|
});
|
|
673
681
|
};
|
|
682
|
+
var runCommandInProjectDir = (root, command, args = [], successMessage = "Operation completed successfully.", errorMessage = "Operation failed.") => {
|
|
683
|
+
return new Promise((resolve, reject) => {
|
|
684
|
+
const child = (0, import_cross_spawn2.default)(command, args, { stdio: "inherit", cwd: root });
|
|
685
|
+
child.on("close", (code) => {
|
|
686
|
+
if (code !== 0) {
|
|
687
|
+
console.log(import_chalk3.default.red(errorMessage));
|
|
688
|
+
reject(new Error(`${command} ${args.join(" ")}`));
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
console.log(import_chalk3.default.green(successMessage));
|
|
692
|
+
resolve();
|
|
693
|
+
});
|
|
694
|
+
});
|
|
695
|
+
};
|
|
674
696
|
var run = async ({
|
|
675
697
|
root,
|
|
676
698
|
appName,
|
|
@@ -751,15 +773,36 @@ var run = async ({
|
|
|
751
773
|
JSON.stringify(packageJson, null, 2) + import_os3.default.EOL
|
|
752
774
|
);
|
|
753
775
|
}
|
|
754
|
-
(0, import_cross_spawn2.default)("git", ["init"], {
|
|
776
|
+
const gitInitProcess = (0, import_cross_spawn2.default)("git", ["init"], {
|
|
755
777
|
cwd: root
|
|
756
778
|
});
|
|
779
|
+
gitInitProcess.on("close", (code) => {
|
|
780
|
+
if (code !== 0) {
|
|
781
|
+
console.log(import_chalk3.default.red("Failed to initialize git repository."));
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
console.log(import_chalk3.default.green("Initialized git repository."));
|
|
785
|
+
});
|
|
757
786
|
if (installDependencies && isOnline) {
|
|
758
787
|
const packageJson = JSON.parse(
|
|
759
788
|
import_fs5.default.readFileSync(`${root}/package.json`, "utf8")
|
|
760
789
|
);
|
|
790
|
+
if (packageJson.scripts && packageJson.scripts["format"]) {
|
|
791
|
+
await runCommandInProjectDir(
|
|
792
|
+
root,
|
|
793
|
+
runCommand,
|
|
794
|
+
["format"],
|
|
795
|
+
"Successfully formatted code."
|
|
796
|
+
);
|
|
797
|
+
}
|
|
761
798
|
if (packageJson.scripts && packageJson.scripts["lint:fix"]) {
|
|
762
|
-
|
|
799
|
+
await runCommandInProjectDir(
|
|
800
|
+
root,
|
|
801
|
+
runCommand,
|
|
802
|
+
["lint:fix"],
|
|
803
|
+
"Successfully fixed linting errors.",
|
|
804
|
+
"Failed to fix linting errors."
|
|
805
|
+
);
|
|
763
806
|
}
|
|
764
807
|
}
|
|
765
808
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -29,18 +29,26 @@ import semver from "semver";
|
|
|
29
29
|
import dns from "dns";
|
|
30
30
|
import { URL as URL2 } from "url";
|
|
31
31
|
var shouldUseYarn = () => {
|
|
32
|
-
const { hasMinYarnPnp, hasMaxYarnPnp } = checkYarnVersion();
|
|
32
|
+
const { hasMinYarnPnp, hasMaxYarnPnp, yarnVersion } = checkYarnVersion();
|
|
33
33
|
if (!hasMinYarnPnp) {
|
|
34
|
+
console.log(
|
|
35
|
+
chalk.yellow(
|
|
36
|
+
`You are using yarn version ${chalk.bold(
|
|
37
|
+
yarnVersion
|
|
38
|
+
)} which is not supported yet. To use Yarn, install v1.12.0 or higher and lower than v2.0.0. See https://yarnpkg.com for instructions on how to update.`
|
|
39
|
+
)
|
|
40
|
+
);
|
|
34
41
|
return false;
|
|
35
42
|
}
|
|
36
43
|
if (!hasMaxYarnPnp) {
|
|
37
44
|
console.log(
|
|
38
45
|
chalk.yellow(
|
|
39
|
-
`You are using a pre-release version of Yarn which is not supported yet. To use Yarn, install v1.12.0 or higher.`
|
|
46
|
+
`You are using a pre-release version of Yarn which is not supported yet. To use Yarn, install v1.12.0 or higher and lower than v2.0.0. See https://yarnpkg.com for instructions on how to update.`
|
|
40
47
|
)
|
|
41
48
|
);
|
|
42
49
|
return false;
|
|
43
50
|
}
|
|
51
|
+
return true;
|
|
44
52
|
};
|
|
45
53
|
var checkThatNpmCanReadCwd = () => {
|
|
46
54
|
const cwd = process.cwd();
|
|
@@ -643,6 +651,20 @@ var install = (root, useYarn = false, dependencies = [], verbose = false, isOnli
|
|
|
643
651
|
});
|
|
644
652
|
});
|
|
645
653
|
};
|
|
654
|
+
var runCommandInProjectDir = (root, command, args = [], successMessage = "Operation completed successfully.", errorMessage = "Operation failed.") => {
|
|
655
|
+
return new Promise((resolve, reject) => {
|
|
656
|
+
const child = spawn2(command, args, { stdio: "inherit", cwd: root });
|
|
657
|
+
child.on("close", (code) => {
|
|
658
|
+
if (code !== 0) {
|
|
659
|
+
console.log(chalk3.red(errorMessage));
|
|
660
|
+
reject(new Error(`${command} ${args.join(" ")}`));
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
console.log(chalk3.green(successMessage));
|
|
664
|
+
resolve();
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
};
|
|
646
668
|
var run = async ({
|
|
647
669
|
root,
|
|
648
670
|
appName,
|
|
@@ -723,15 +745,36 @@ var run = async ({
|
|
|
723
745
|
JSON.stringify(packageJson, null, 2) + os3.EOL
|
|
724
746
|
);
|
|
725
747
|
}
|
|
726
|
-
spawn2("git", ["init"], {
|
|
748
|
+
const gitInitProcess = spawn2("git", ["init"], {
|
|
727
749
|
cwd: root
|
|
728
750
|
});
|
|
751
|
+
gitInitProcess.on("close", (code) => {
|
|
752
|
+
if (code !== 0) {
|
|
753
|
+
console.log(chalk3.red("Failed to initialize git repository."));
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
console.log(chalk3.green("Initialized git repository."));
|
|
757
|
+
});
|
|
729
758
|
if (installDependencies && isOnline) {
|
|
730
759
|
const packageJson = JSON.parse(
|
|
731
760
|
fs4.readFileSync(`${root}/package.json`, "utf8")
|
|
732
761
|
);
|
|
762
|
+
if (packageJson.scripts && packageJson.scripts["format"]) {
|
|
763
|
+
await runCommandInProjectDir(
|
|
764
|
+
root,
|
|
765
|
+
runCommand,
|
|
766
|
+
["format"],
|
|
767
|
+
"Successfully formatted code."
|
|
768
|
+
);
|
|
769
|
+
}
|
|
733
770
|
if (packageJson.scripts && packageJson.scripts["lint:fix"]) {
|
|
734
|
-
|
|
771
|
+
await runCommandInProjectDir(
|
|
772
|
+
root,
|
|
773
|
+
runCommand,
|
|
774
|
+
["lint:fix"],
|
|
775
|
+
"Successfully fixed linting errors.",
|
|
776
|
+
"Failed to fix linting errors."
|
|
777
|
+
);
|
|
735
778
|
}
|
|
736
779
|
}
|
|
737
780
|
};
|