@teambit/bvm.link 0.1.1 → 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/link.d.ts +1 -0
- package/dist/link.js +48 -32
- package/dist/link.js.map +1 -1
- package/link.ts +48 -34
- package/package-tar/teambit-bvm.link-0.1.4.tgz +0 -0
- package/package.json +6 -17
- package/{preview-1656583713587.js → preview-1658655758269.js} +3 -3
- package/package-tar/teambit-bvm.link-0.1.1.tgz +0 -0
package/dist/link.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare type LinkResult = {
|
|
|
5
5
|
previousLinkVersion?: string;
|
|
6
6
|
generatedLink: GeneratedLink;
|
|
7
7
|
pathExtenderReport?: PathExtenderReport;
|
|
8
|
+
warnings?: string[];
|
|
8
9
|
};
|
|
9
10
|
export { PathExtenderReport, ConfigReport, ConfigFileChangeType };
|
|
10
11
|
export declare type GeneratedLink = {
|
package/dist/link.js
CHANGED
|
@@ -21,7 +21,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
21
21
|
const bin_links_1 = __importDefault(require("bin-links"));
|
|
22
22
|
const bvm_error_1 = require("@teambit/bvm.error");
|
|
23
23
|
const os_1 = __importDefault(require("os"));
|
|
24
|
-
const
|
|
24
|
+
const semver_1 = __importDefault(require("semver"));
|
|
25
25
|
const IS_WINDOWS = os_1.default.platform() === 'win32';
|
|
26
26
|
const DOCS_BASE_URL = 'https://bit.dev/docs';
|
|
27
27
|
const WINDOWS_INSTALL_TROUBLESHOOTING_DOCS_URL = `${DOCS_BASE_URL}/reference/using-bvm#troubleshooting`;
|
|
@@ -71,8 +71,9 @@ function linkOne(linkName, version, opts = {}) {
|
|
|
71
71
|
throw new bvm_error_1.BvmError(`version ${concreteVersion} is not installed`);
|
|
72
72
|
}
|
|
73
73
|
let nodeExecPath;
|
|
74
|
+
const wantedNodeVersion = config.getWantedNodeVersion(versionDir);
|
|
75
|
+
const warnings = [];
|
|
74
76
|
if (!opts.useSystemNode) {
|
|
75
|
-
const wantedNodeVersion = config.getWantedNodeVersion(versionDir);
|
|
76
77
|
if (wantedNodeVersion) {
|
|
77
78
|
const node = config.getSpecificNodeVersionDir(wantedNodeVersion);
|
|
78
79
|
if (!node.exists) {
|
|
@@ -81,6 +82,9 @@ function linkOne(linkName, version, opts = {}) {
|
|
|
81
82
|
nodeExecPath = path_1.default.join(node.versionDir, process.platform === 'win32' ? 'node.exe' : 'bin/node');
|
|
82
83
|
}
|
|
83
84
|
}
|
|
85
|
+
else if (semver_1.default.lt(process.version, wantedNodeVersion)) {
|
|
86
|
+
warnings.push(`The system Node.js is ${process.version} while Bit CLI requires at least Node.js ${wantedNodeVersion}!`);
|
|
87
|
+
}
|
|
84
88
|
const pkg = {
|
|
85
89
|
bin: {
|
|
86
90
|
[linkName]: source
|
|
@@ -113,13 +117,17 @@ function linkOne(linkName, version, opts = {}) {
|
|
|
113
117
|
if (IS_WINDOWS) {
|
|
114
118
|
binDir = config.getBvmDirectory();
|
|
115
119
|
}
|
|
116
|
-
const pathExtenderReport = yield validateBinDirInPath(binDir, opts);
|
|
120
|
+
const { pathExtenderReport, warning } = yield validateBinDirInPath(binDir, opts);
|
|
121
|
+
if (warning) {
|
|
122
|
+
warnings.push(warning);
|
|
123
|
+
}
|
|
117
124
|
return {
|
|
118
125
|
linkName,
|
|
119
126
|
previousLinkVersion,
|
|
120
127
|
version: concreteVersion,
|
|
121
128
|
generatedLink,
|
|
122
129
|
pathExtenderReport,
|
|
130
|
+
warnings,
|
|
123
131
|
};
|
|
124
132
|
});
|
|
125
133
|
}
|
|
@@ -136,40 +144,48 @@ function validateBinDirInPath(binDir, opts = { addToPathIfMissing: true }) {
|
|
|
136
144
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
145
|
const osPaths = (process.env.PATH || process.env.Path || process.env.path).split(path_1.default.delimiter);
|
|
138
146
|
if (osPaths.indexOf(binDir) !== -1)
|
|
139
|
-
return;
|
|
147
|
+
return {};
|
|
140
148
|
if (!opts.addToPathIfMissing) {
|
|
141
|
-
const
|
|
142
|
-
|
|
149
|
+
const warningLines = [
|
|
150
|
+
'global Bit install location was not found in your PATH global variable.',
|
|
151
|
+
missingInPathError(binDir),
|
|
152
|
+
'',
|
|
153
|
+
];
|
|
154
|
+
return { warning: warningLines.join('\n') };
|
|
143
155
|
}
|
|
144
156
|
else {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
157
|
+
try {
|
|
158
|
+
const pathExtenderReport = yield (0, os_env_path_extender_1.addDirToEnvPath)(binDir, {
|
|
159
|
+
overwrite: true,
|
|
160
|
+
position: 'end',
|
|
161
|
+
configSectionName: 'bit',
|
|
162
|
+
});
|
|
163
|
+
return { pathExtenderReport };
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
if (err.code === 'ERR_PNPM_UNKNOWN_SHELL') {
|
|
167
|
+
return {
|
|
168
|
+
warning: `Couldn't update the system PATH because failed to detect the active shell.
|
|
169
|
+
You can either set the SHELL env variable to your shell name (e.g., "SHELL=bash bvm install")
|
|
170
|
+
or ${missingInPathError(binDir)}`
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
warning: `Couldn't update the system path: ${err.message}
|
|
175
|
+
${missingInPathError(binDir)}`
|
|
176
|
+
};
|
|
177
|
+
}
|
|
150
178
|
}
|
|
151
179
|
});
|
|
152
180
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return errLines.join('\n');
|
|
163
|
-
}
|
|
164
|
-
function macLinuxMissingInPathError(binDir, docsLink) {
|
|
165
|
-
// Join with \n for better visibility in windows
|
|
166
|
-
const errLines = [
|
|
167
|
-
'global Bit install location was not found in your PATH global variable.',
|
|
168
|
-
'please add the following to your bash/zsh profile then re-open the terminal:',
|
|
169
|
-
`export PATH=$HOME/bin:$PATH`,
|
|
170
|
-
`for more information read here - ${docsLink}
|
|
171
|
-
`
|
|
172
|
-
];
|
|
173
|
-
return errLines.join('\n');
|
|
181
|
+
function missingInPathError(binDir) {
|
|
182
|
+
if (IS_WINDOWS) {
|
|
183
|
+
return `run the following command and then re-open the terminal:
|
|
184
|
+
setx path "%path%;${binDir}" and re-open your terminal
|
|
185
|
+
for more information read here - ${WINDOWS_INSTALL_TROUBLESHOOTING_DOCS_URL}`;
|
|
186
|
+
}
|
|
187
|
+
return `add the following to your bash/zsh profile then re-open the terminal:
|
|
188
|
+
export PATH=$HOME/bin:$PATH
|
|
189
|
+
for more information read here - ${MAC_LINUX_INSTALL_TROUBLESHOOTING_DOCS_URL}`;
|
|
174
190
|
}
|
|
175
191
|
//# sourceMappingURL=link.js.map
|
package/dist/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sourceRoot":"","sources":["../link.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qEAAqH;AACrH,oDAA2C;AAC3C,gDAA4C;AAC5C,iEAAwC;AACxC,gDAAwB;AACxB,0DAAiC;AACjC,kDAA8C;AAC9C,4CAAoB;AACpB,
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../link.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qEAAqH;AACrH,oDAA2C;AAC3C,gDAA4C;AAC5C,iEAAwC;AACxC,gDAAwB;AACxB,0DAAiC;AACjC,kDAA8C;AAC9C,4CAAoB;AACpB,oDAA4B;AAE5B,MAAM,UAAU,GAAG,YAAE,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC;AAC7C,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAC7C,MAAM,wCAAwC,GAAG,GAAG,aAAa,sCAAsC,CAAC;AACxG,MAAM,0CAA0C,GAAG,GAAG,aAAa,sCAAsC,CAAC;AAE1G,MAAM,MAAM,GAAG,mBAAM,CAAC,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AE,kBAAkB,EAAE,CAAC;aAC/B;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,GAAG,CAAC,IAAI,KAAK,wBAAwB,EAAE;oBACzC,OAAO;wBACL,OAAO,EAAE;;KAEd,kBAAkB,CAAC,MAAM,CAAC,EAAE;qBACxB,CAAC;iBACH;gBACD,OAAO;oBACL,OAAO,EAAE,oCAAoC,GAAG,CAAC,OAAO;EAC9D,kBAAkB,CAAC,MAAM,CAAC,EAAE;iBACvB,CAAA;aACF;SACF;IACH,CAAC;CAAA;AAED,SAAS,kBAAkB,CAAC,MAAc;IACxC,IAAI,UAAU,EAAE;QACd,OAAO;oBACS,MAAM;mCACS,wCAAwC,EAAE,CAAC;KAC3E;IACD,OAAO;;mCAE0B,0CAA0C,EAAE,CAAC;AAChF,CAAC"}
|
package/link.ts
CHANGED
|
@@ -6,7 +6,7 @@ import path from 'path';
|
|
|
6
6
|
import binLinks from 'bin-links';
|
|
7
7
|
import { BvmError } from '@teambit/bvm.error';
|
|
8
8
|
import os from 'os';
|
|
9
|
-
import
|
|
9
|
+
import semver from 'semver';
|
|
10
10
|
|
|
11
11
|
const IS_WINDOWS = os.platform() === 'win32';
|
|
12
12
|
const DOCS_BASE_URL = 'https://bit.dev/docs';
|
|
@@ -21,6 +21,7 @@ export type LinkResult = {
|
|
|
21
21
|
previousLinkVersion?: string,
|
|
22
22
|
generatedLink: GeneratedLink
|
|
23
23
|
pathExtenderReport?: PathExtenderReport,
|
|
24
|
+
warnings?: string[],
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export { PathExtenderReport, ConfigReport, ConfigFileChangeType }
|
|
@@ -81,8 +82,9 @@ export async function linkOne(linkName: string, version: string | undefined, opt
|
|
|
81
82
|
throw new BvmError(`version ${concreteVersion} is not installed`);
|
|
82
83
|
}
|
|
83
84
|
let nodeExecPath: string;
|
|
85
|
+
const wantedNodeVersion = config.getWantedNodeVersion(versionDir);
|
|
86
|
+
const warnings: string[] = []
|
|
84
87
|
if (!opts.useSystemNode) {
|
|
85
|
-
const wantedNodeVersion = config.getWantedNodeVersion(versionDir);
|
|
86
88
|
if (wantedNodeVersion) {
|
|
87
89
|
const node = config.getSpecificNodeVersionDir(wantedNodeVersion);
|
|
88
90
|
if (!node.exists) {
|
|
@@ -90,6 +92,8 @@ export async function linkOne(linkName: string, version: string | undefined, opt
|
|
|
90
92
|
}
|
|
91
93
|
nodeExecPath = path.join(node.versionDir, process.platform === 'win32' ? 'node.exe' : 'bin/node');
|
|
92
94
|
}
|
|
95
|
+
} else if (semver.lt(process.version, wantedNodeVersion)) {
|
|
96
|
+
warnings.push(`The system Node.js is ${process.version} while Bit CLI requires at least Node.js ${wantedNodeVersion}!`)
|
|
93
97
|
}
|
|
94
98
|
const pkg = {
|
|
95
99
|
bin: {
|
|
@@ -124,7 +128,10 @@ export async function linkOne(linkName: string, version: string | undefined, opt
|
|
|
124
128
|
if (IS_WINDOWS){
|
|
125
129
|
binDir = config.getBvmDirectory();
|
|
126
130
|
}
|
|
127
|
-
const pathExtenderReport = await validateBinDirInPath(binDir, opts);
|
|
131
|
+
const { pathExtenderReport, warning } = await validateBinDirInPath(binDir, opts);
|
|
132
|
+
if (warning) {
|
|
133
|
+
warnings.push(warning);
|
|
134
|
+
}
|
|
128
135
|
|
|
129
136
|
return {
|
|
130
137
|
linkName,
|
|
@@ -132,6 +139,7 @@ export async function linkOne(linkName: string, version: string | undefined, opt
|
|
|
132
139
|
version: concreteVersion,
|
|
133
140
|
generatedLink,
|
|
134
141
|
pathExtenderReport,
|
|
142
|
+
warnings,
|
|
135
143
|
}
|
|
136
144
|
}
|
|
137
145
|
|
|
@@ -145,42 +153,48 @@ function getBitBinPath(){
|
|
|
145
153
|
return path.join('@teambit', 'bit', 'bin', 'bit');
|
|
146
154
|
}
|
|
147
155
|
|
|
148
|
-
async function validateBinDirInPath(binDir: string, opts: { addToPathIfMissing?: boolean } = { addToPathIfMissing: true }): Promise<PathExtenderReport | undefined> {
|
|
156
|
+
async function validateBinDirInPath(binDir: string, opts: { addToPathIfMissing?: boolean } = { addToPathIfMissing: true }): Promise<{ pathExtenderReport?: PathExtenderReport | undefined, warning?: string }> {
|
|
149
157
|
const osPaths = (process.env.PATH || process.env.Path || process.env.path).split(path.delimiter);
|
|
150
|
-
if (osPaths.indexOf(binDir) !== -1) return;
|
|
158
|
+
if (osPaths.indexOf(binDir) !== -1) return {};
|
|
151
159
|
if (!opts.addToPathIfMissing) {
|
|
152
|
-
const
|
|
153
|
-
|
|
160
|
+
const warningLines = [
|
|
161
|
+
'global Bit install location was not found in your PATH global variable.',
|
|
162
|
+
missingInPathError(binDir),
|
|
163
|
+
'',
|
|
164
|
+
];
|
|
165
|
+
return { warning: warningLines.join('\n') };
|
|
154
166
|
} else {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
167
|
+
try {
|
|
168
|
+
const pathExtenderReport = await addDirToEnvPath(binDir, {
|
|
169
|
+
overwrite: true,
|
|
170
|
+
position: 'end',
|
|
171
|
+
configSectionName: 'bit',
|
|
172
|
+
});
|
|
173
|
+
return { pathExtenderReport };
|
|
174
|
+
} catch (err) {
|
|
175
|
+
if (err.code === 'ERR_PNPM_UNKNOWN_SHELL') {
|
|
176
|
+
return {
|
|
177
|
+
warning: `Couldn't update the system PATH because failed to detect the active shell.
|
|
178
|
+
You can either set the SHELL env variable to your shell name (e.g., "SHELL=bash bvm install")
|
|
179
|
+
or ${missingInPathError(binDir)}`
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
warning: `Couldn't update the system path: ${err.message}
|
|
184
|
+
${missingInPathError(binDir)}`
|
|
185
|
+
}
|
|
186
|
+
}
|
|
160
187
|
}
|
|
161
188
|
}
|
|
162
189
|
|
|
163
|
-
function
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return errLines.join('\n');
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function macLinuxMissingInPathError(binDir: string, docsLink){
|
|
176
|
-
// Join with \n for better visibility in windows
|
|
177
|
-
const errLines = [
|
|
178
|
-
'global Bit install location was not found in your PATH global variable.',
|
|
179
|
-
'please add the following to your bash/zsh profile then re-open the terminal:',
|
|
180
|
-
`export PATH=$HOME/bin:$PATH`,
|
|
181
|
-
`for more information read here - ${docsLink}
|
|
182
|
-
`
|
|
183
|
-
];
|
|
184
|
-
return errLines.join('\n');
|
|
190
|
+
function missingInPathError(binDir: string) {
|
|
191
|
+
if (IS_WINDOWS) {
|
|
192
|
+
return `run the following command and then re-open the terminal:
|
|
193
|
+
setx path "%path%;${binDir}" and re-open your terminal
|
|
194
|
+
for more information read here - ${WINDOWS_INSTALL_TROUBLESHOOTING_DOCS_URL}`;
|
|
195
|
+
}
|
|
196
|
+
return `add the following to your bash/zsh profile then re-open the terminal:
|
|
197
|
+
export PATH=$HOME/bin:$PATH
|
|
198
|
+
for more information read here - ${MAC_LINUX_INSTALL_TROUBLESHOOTING_DOCS_URL}`;
|
|
185
199
|
}
|
|
186
200
|
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,43 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/bvm.link",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/bvm/link",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.bvm",
|
|
8
8
|
"name": "link",
|
|
9
|
-
"version": "0.1.
|
|
9
|
+
"version": "0.1.4"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"fs-extra": "9.1.0",
|
|
13
13
|
"@zkochan/cmd-shim": "5.3.0",
|
|
14
14
|
"bin-links": "2.2.1",
|
|
15
|
-
"
|
|
15
|
+
"semver": "7.3.4",
|
|
16
16
|
"@pnpm/os.env.path-extender": "0.2.4",
|
|
17
17
|
"@teambit/bvm.error": "0.0.4",
|
|
18
|
-
"@teambit/bvm.config": "0.1.
|
|
19
|
-
"@teambit/bvm.list": "0.0.
|
|
18
|
+
"@teambit/bvm.config": "0.1.1",
|
|
19
|
+
"@teambit/bvm.list": "0.0.35"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/fs-extra": "9.0.7",
|
|
23
|
-
"@types/
|
|
23
|
+
"@types/semver": "7.3.4",
|
|
24
24
|
"@babel/runtime": "7.12.18",
|
|
25
25
|
"@types/node": "12.20.4",
|
|
26
26
|
"@types/jest": "26.0.20"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {},
|
|
29
29
|
"license": "Apache-2.0",
|
|
30
|
-
"bit": {
|
|
31
|
-
"bindingPrefix": "@teambit",
|
|
32
|
-
"env": {},
|
|
33
|
-
"overrides": {
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@babel/runtime": "7.12.18",
|
|
36
|
-
"@types/node": "12.20.4",
|
|
37
|
-
"@types/jest": "26.0.20"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
30
|
"private": false,
|
|
42
31
|
"engines": {
|
|
43
32
|
"node": ">=12.15.0"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import * as overview_0 from '/Users/giladshoham/Library/Caches/Bit/capsules/f3900c88552f465f36e94e9f684555a848de0105/teambit.bvm_link@0.1.
|
|
1
|
+
;
|
|
2
|
+
import * as overview_0 from '/Users/giladshoham/Library/Caches/Bit/capsules/f3900c88552f465f36e94e9f684555a848de0105/teambit.bvm_link@0.1.4/dist/link.docs.md';
|
|
3
3
|
|
|
4
4
|
export const compositions = [];
|
|
5
|
-
export const overview = [overview_0]
|
|
5
|
+
export const overview = [overview_0];
|
|
Binary file
|