init-workspace-cervvaljs 0.1.4 → 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/README.md +3 -3
- package/bin/index.js +41 -17
- package/package.json +1 -1
- package/workspace/_package.json +3 -2
- package/.pnpm-debug.log +0 -16
package/README.md
CHANGED
|
@@ -13,15 +13,15 @@ This package setups a pnpm Cervval.js workspace :
|
|
|
13
13
|
Create a workspace folder and run
|
|
14
14
|
* Init
|
|
15
15
|
```
|
|
16
|
-
npx init-workspace-cervvaljs
|
|
16
|
+
npx init-workspace-cervvaljs@latest
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
* Simulate init
|
|
20
20
|
```
|
|
21
|
-
npx init-workspace-cervvaljs --dry
|
|
21
|
+
npx init-workspace-cervvaljs@latest --dry
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
* Update (overwrite config files)
|
|
25
25
|
```
|
|
26
|
-
npx init-workspace-cervvaljs --update
|
|
26
|
+
npx init-workspace-cervvaljs@latest --update
|
|
27
27
|
```
|
package/bin/index.js
CHANGED
|
@@ -21,14 +21,19 @@ 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
|
+
// console colors
|
|
28
|
+
const FgRed = "\x1b[31m";
|
|
29
|
+
const FgGreen = "\x1b[32m";
|
|
30
|
+
const FgBlue = "\x1b[34m";
|
|
31
|
+
const FgReset = "\x1b[0m";
|
|
27
32
|
/**
|
|
28
33
|
* execSync with standard input outputs
|
|
29
34
|
*/
|
|
30
35
|
function execSyncWithIo(cmd) {
|
|
31
|
-
return child_process_1.execSync(cmd, { stdio: "inherit" });
|
|
36
|
+
return (0, child_process_1.execSync)(cmd, { stdio: "inherit" });
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* Init workspace
|
|
@@ -38,8 +43,16 @@ function execSyncWithIo(cmd) {
|
|
|
38
43
|
* @param options options
|
|
39
44
|
* @param options.dry if true, init will be simulated but not executed
|
|
40
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
|
|
41
47
|
*/
|
|
42
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
|
+
}
|
|
43
56
|
// check Node Version
|
|
44
57
|
let nodeVersionStr = process.version.toLowerCase();
|
|
45
58
|
if (nodeVersionStr.startsWith("v")) {
|
|
@@ -48,14 +61,14 @@ function initWorkspace(options) {
|
|
|
48
61
|
const nodeMainVersion = Number(nodeVersionStr.substring(0, nodeVersionStr.indexOf(".")));
|
|
49
62
|
console.info("* Node version", nodeMainVersion, "(" + process.version + ")");
|
|
50
63
|
if (nodeMainVersion < 14) {
|
|
51
|
-
console.error("Node version 14 or above is required, init aborted");
|
|
64
|
+
console.error(FgRed + "Node version 14 or above is required, init aborted", FgReset);
|
|
52
65
|
console.info("1. Install NVM");
|
|
53
66
|
console.info(" Linux: https://github.com/nvm-sh/nvm");
|
|
54
67
|
console.info(" Windows: https://github.com/coreybutler/nvm-windows");
|
|
55
68
|
console.info("2. Install Node");
|
|
56
69
|
console.info(" nvm install 14.17.0");
|
|
57
70
|
console.info(" nvm use 14.17.0");
|
|
58
|
-
|
|
71
|
+
process.exit(1 /* WRONG_NODE */);
|
|
59
72
|
}
|
|
60
73
|
// check config files are not already in current folder
|
|
61
74
|
const configFiles = ["package.json", "pnpm-workspace.yaml"];
|
|
@@ -63,26 +76,30 @@ function initWorkspace(options) {
|
|
|
63
76
|
for (const cf of configFiles) {
|
|
64
77
|
if (fs.existsSync("./" + cf)) {
|
|
65
78
|
if (!(options === null || options === void 0 ? void 0 : options.update)) {
|
|
66
|
-
console.error(cf + " found - init cancelled");
|
|
67
|
-
|
|
79
|
+
console.error(FgRed + cf + " found - init cancelled", FgReset);
|
|
80
|
+
process.exit(2 /* INIT_BUT_FILE_EXISTS */);
|
|
68
81
|
}
|
|
69
82
|
}
|
|
70
83
|
else if (options === null || options === void 0 ? void 0 : options.update) {
|
|
71
|
-
console.error(cf + " was not found
|
|
84
|
+
console.error(FgRed + cf + " was not found");
|
|
85
|
+
console.error(FgRed + "- Are you at the workspace root ?", FgReset);
|
|
86
|
+
console.error(FgRed + "- Do you want to initialize a new workspace ? then you need to remove --update", FgReset);
|
|
87
|
+
process.exit(3 /* UPDATE_BUT_FILE_DOES_NOT_EXIST */);
|
|
72
88
|
}
|
|
73
89
|
}
|
|
74
90
|
}
|
|
75
|
-
//
|
|
91
|
+
// Install pnpm
|
|
92
|
+
const pnpmFixedVersion = options.pnpmVersion ? "@^" + options.pnpmVersion : "";
|
|
76
93
|
if (!(options === null || options === void 0 ? void 0 : options.update)) {
|
|
77
|
-
console.info("* install pnpm : npm install -g pnpm");
|
|
94
|
+
console.info("* install pnpm : npm install -g pnpm" + pnpmFixedVersion);
|
|
78
95
|
if (!(options === null || options === void 0 ? void 0 : options.dry)) {
|
|
79
|
-
execSyncWithIo("npm install -g pnpm");
|
|
96
|
+
execSyncWithIo("npm install -g pnpm" + pnpmFixedVersion);
|
|
80
97
|
}
|
|
81
98
|
}
|
|
82
99
|
else {
|
|
83
|
-
console.info("* update pnpm : pnpm add -g pnpm");
|
|
100
|
+
console.info("* update pnpm : pnpm add -g pnpm" + pnpmFixedVersion);
|
|
84
101
|
if (!(options === null || options === void 0 ? void 0 : options.dry)) {
|
|
85
|
-
execSyncWithIo("pnpm add -g pnpm");
|
|
102
|
+
execSyncWithIo("pnpm add -g pnpm" + pnpmFixedVersion);
|
|
86
103
|
}
|
|
87
104
|
}
|
|
88
105
|
console.info("* display pnpm version : pnpm -v");
|
|
@@ -114,8 +131,9 @@ function initWorkspace(options) {
|
|
|
114
131
|
console.info("pnpm install");
|
|
115
132
|
}
|
|
116
133
|
else {
|
|
117
|
-
console.info(
|
|
118
|
-
console.info("
|
|
134
|
+
console.info(FgBlue + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
|
135
|
+
console.info(FgBlue + "*update done, you can now install packages");
|
|
136
|
+
console.info(FgGreen + "pnpm install", FgReset);
|
|
119
137
|
}
|
|
120
138
|
return true;
|
|
121
139
|
}
|
|
@@ -123,7 +141,7 @@ function initWorkspace(options) {
|
|
|
123
141
|
* parses command arguments and inits workspace in current working directory
|
|
124
142
|
*/
|
|
125
143
|
function cli() {
|
|
126
|
-
const options = { dry: false, update: false };
|
|
144
|
+
const options = { dry: false, update: false, pnpmVersion: "6.32.11" };
|
|
127
145
|
const args = process.argv.slice(2);
|
|
128
146
|
if (args.includes("--dry")) {
|
|
129
147
|
console.info("* dry mode on");
|
|
@@ -133,7 +151,13 @@ function cli() {
|
|
|
133
151
|
console.info("* update mode on");
|
|
134
152
|
options.update = true;
|
|
135
153
|
}
|
|
136
|
-
|
|
154
|
+
try {
|
|
155
|
+
initWorkspace(options);
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
console.error(err);
|
|
159
|
+
process.exit(99 /* UNEXPECTED */);
|
|
160
|
+
}
|
|
137
161
|
}
|
|
138
162
|
exports.cli = cli;
|
|
139
163
|
cli();
|
package/package.json
CHANGED
package/workspace/_package.json
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
"node": ">=14"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"clean-node-modules": "rimraf **/node_modules"
|
|
10
|
+
"clean-node-modules": "rimraf **/node_modules",
|
|
11
|
+
"postinstall": "cwt rewrite-tsconfig-references"
|
|
11
12
|
},
|
|
12
13
|
"dependencies": {},
|
|
13
14
|
"devDependencies": {
|
|
@@ -19,5 +20,5 @@
|
|
|
19
20
|
"eslintConfig": {
|
|
20
21
|
"extends": "@cervval.js/eslint-config-cervvaljs"
|
|
21
22
|
},
|
|
22
|
-
"version": "0.1.
|
|
23
|
+
"version": "0.1.7"
|
|
23
24
|
}
|
package/.pnpm-debug.log
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"0 debug pnpm:scope": {
|
|
3
|
-
"selected": 1,
|
|
4
|
-
"workspacePrefix": "D:\\Travail\\Workspaces\\js"
|
|
5
|
-
},
|
|
6
|
-
"1 error pnpm": {
|
|
7
|
-
"code": "ERR_PNPM_GIT_NOT_UNCLEAN",
|
|
8
|
-
"hint": "If you want to disable Git checks on publish, set the \"git-checks\" setting to \"false\", or run again with \"--no-git-checks\".",
|
|
9
|
-
"err": {
|
|
10
|
-
"name": "Error",
|
|
11
|
-
"message": "Unclean working tree. Commit or stash changes first.",
|
|
12
|
-
"code": "ERR_PNPM_GIT_NOT_UNCLEAN",
|
|
13
|
-
"stack": "Error: Unclean working tree. Commit or stash changes first.\n at Object.handler [as publish] (C:\\Users\\gasni\\AppData\\Roaming\\npm\\pnpm-global\\5\\node_modules\\.pnpm\\pnpm@6.3.0\\node_modules\\pnpm\\dist\\pnpm.cjs:116588:15)\n at processTicksAndRejections (internal/process/task_queues.js:93:5)\n at async Timeout._onTimeout (C:\\Users\\gasni\\AppData\\Roaming\\npm\\pnpm-global\\5\\node_modules\\.pnpm\\pnpm@6.3.0\\node_modules\\pnpm\\dist\\pnpm.cjs:121003:22)"
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|