init-workspace-cervvaljs 0.1.6 → 0.1.7
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/bin/index.js +18 -9
- package/package.json +1 -1
- package/workspace/_package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -21,9 +21,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.cli = void 0;
|
|
24
|
-
const path = __importStar(require("path"));
|
|
25
|
-
const fs = __importStar(require("fs"));
|
|
26
24
|
const child_process_1 = require("child_process");
|
|
25
|
+
const fs = __importStar(require("fs"));
|
|
26
|
+
const path = __importStar(require("path"));
|
|
27
27
|
// console colors
|
|
28
28
|
const FgRed = "\x1b[31m";
|
|
29
29
|
const FgGreen = "\x1b[32m";
|
|
@@ -33,7 +33,7 @@ const FgReset = "\x1b[0m";
|
|
|
33
33
|
* execSync with standard input outputs
|
|
34
34
|
*/
|
|
35
35
|
function execSyncWithIo(cmd) {
|
|
36
|
-
return child_process_1.execSync(cmd, { stdio: "inherit" });
|
|
36
|
+
return (0, child_process_1.execSync)(cmd, { stdio: "inherit" });
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Init workspace
|
|
@@ -43,8 +43,16 @@ function execSyncWithIo(cmd) {
|
|
|
43
43
|
* @param options options
|
|
44
44
|
* @param options.dry if true, init will be simulated but not executed
|
|
45
45
|
* @param options.update if true, init will be done even if config files are already present
|
|
46
|
+
* @param options.pnpmVersion if given, fix version of pnpm
|
|
46
47
|
*/
|
|
47
48
|
function initWorkspace(options) {
|
|
49
|
+
// check if user is on Windows & current path contains spaces
|
|
50
|
+
const operatingSystem = process.platform;
|
|
51
|
+
const currentPath = process.cwd();
|
|
52
|
+
if (operatingSystem === "win32" && /\s/.test(currentPath)) {
|
|
53
|
+
console.error(FgRed + "Your workspace path should not contain any whitespaces when using Windows", FgReset);
|
|
54
|
+
process.exit(4 /* WRONG_PATH_FORMAT */);
|
|
55
|
+
}
|
|
48
56
|
// check Node Version
|
|
49
57
|
let nodeVersionStr = process.version.toLowerCase();
|
|
50
58
|
if (nodeVersionStr.startsWith("v")) {
|
|
@@ -80,17 +88,18 @@ function initWorkspace(options) {
|
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
|
-
//
|
|
91
|
+
// Install pnpm
|
|
92
|
+
const pnpmFixedVersion = options.pnpmVersion ? "@^" + options.pnpmVersion : "";
|
|
84
93
|
if (!(options === null || options === void 0 ? void 0 : options.update)) {
|
|
85
|
-
console.info("* install pnpm : npm install -g pnpm");
|
|
94
|
+
console.info("* install pnpm : npm install -g pnpm" + pnpmFixedVersion);
|
|
86
95
|
if (!(options === null || options === void 0 ? void 0 : options.dry)) {
|
|
87
|
-
execSyncWithIo("npm install -g pnpm");
|
|
96
|
+
execSyncWithIo("npm install -g pnpm" + pnpmFixedVersion);
|
|
88
97
|
}
|
|
89
98
|
}
|
|
90
99
|
else {
|
|
91
|
-
console.info("* update pnpm : pnpm add -g pnpm");
|
|
100
|
+
console.info("* update pnpm : pnpm add -g pnpm" + pnpmFixedVersion);
|
|
92
101
|
if (!(options === null || options === void 0 ? void 0 : options.dry)) {
|
|
93
|
-
execSyncWithIo("pnpm add -g pnpm");
|
|
102
|
+
execSyncWithIo("pnpm add -g pnpm" + pnpmFixedVersion);
|
|
94
103
|
}
|
|
95
104
|
}
|
|
96
105
|
console.info("* display pnpm version : pnpm -v");
|
|
@@ -132,7 +141,7 @@ function initWorkspace(options) {
|
|
|
132
141
|
* parses command arguments and inits workspace in current working directory
|
|
133
142
|
*/
|
|
134
143
|
function cli() {
|
|
135
|
-
const options = { dry: false, update: false };
|
|
144
|
+
const options = { dry: false, update: false, pnpmVersion: "6.32.11" };
|
|
136
145
|
const args = process.argv.slice(2);
|
|
137
146
|
if (args.includes("--dry")) {
|
|
138
147
|
console.info("* dry mode on");
|
package/package.json
CHANGED
package/workspace/_package.json
CHANGED