@teambit/bvm.link 0.1.0 → 0.1.3
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 +3 -0
- package/dist/link.js +64 -38
- package/dist/link.js.map +1 -1
- package/link.ts +66 -41
- package/package-tar/teambit-bvm.link-0.1.3.tgz +0 -0
- package/package.json +6 -17
- package/{preview-1656407165993.js → preview-1658334660095.js} +3 -3
- package/package-tar/teambit-bvm.link-0.1.0.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 = {
|
|
@@ -13,10 +14,12 @@ export declare type GeneratedLink = {
|
|
|
13
14
|
};
|
|
14
15
|
export declare function linkAll(opts: {
|
|
15
16
|
addToPathIfMissing?: boolean;
|
|
17
|
+
useSystemNode?: boolean;
|
|
16
18
|
}): Promise<LinkResult[]>;
|
|
17
19
|
export interface LinkOptions {
|
|
18
20
|
addToConfig?: boolean;
|
|
19
21
|
addToPathIfMissing?: boolean;
|
|
22
|
+
useSystemNode?: boolean;
|
|
20
23
|
}
|
|
21
24
|
export declare function linkDefault(version: string | undefined, opts?: LinkOptions): Promise<LinkResult>;
|
|
22
25
|
export declare function linkOne(linkName: string, version: string | undefined, opts?: LinkOptions): Promise<LinkResult>;
|
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`;
|
|
@@ -33,11 +33,19 @@ function linkAll(opts) {
|
|
|
33
33
|
const defaultLinkVersion = config.getDefaultLinkVersion();
|
|
34
34
|
const localLatest = (yield (0, bvm_list_1.listLocal)()).latest();
|
|
35
35
|
const promises = Object.entries(links).map(([linkName, version]) => {
|
|
36
|
-
return linkOne(linkName, version, {
|
|
36
|
+
return linkOne(linkName, version, {
|
|
37
|
+
addToConfig: false,
|
|
38
|
+
addToPathIfMissing: opts.addToPathIfMissing,
|
|
39
|
+
useSystemNode: opts.useSystemNode,
|
|
40
|
+
});
|
|
37
41
|
});
|
|
38
42
|
if (!defaultLinkVersion && localLatest) {
|
|
39
43
|
const defaultLinkName = config.getDefaultLinkName();
|
|
40
|
-
promises.push(linkOne(defaultLinkName, localLatest.version, {
|
|
44
|
+
promises.push(linkOne(defaultLinkName, localLatest.version, {
|
|
45
|
+
addToConfig: true,
|
|
46
|
+
addToPathIfMissing: opts.addToPathIfMissing,
|
|
47
|
+
useSystemNode: opts.useSystemNode,
|
|
48
|
+
}));
|
|
41
49
|
}
|
|
42
50
|
return Promise.all(promises);
|
|
43
51
|
});
|
|
@@ -62,14 +70,20 @@ function linkOne(linkName, version, opts = {}) {
|
|
|
62
70
|
if (!exists) {
|
|
63
71
|
throw new bvm_error_1.BvmError(`version ${concreteVersion} is not installed`);
|
|
64
72
|
}
|
|
65
|
-
const wantedNodeVersion = config.getWantedNodeVersion(versionDir);
|
|
66
73
|
let nodeExecPath;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
const wantedNodeVersion = config.getWantedNodeVersion(versionDir);
|
|
75
|
+
const warnings = [];
|
|
76
|
+
if (!opts.useSystemNode) {
|
|
77
|
+
if (wantedNodeVersion) {
|
|
78
|
+
const node = config.getSpecificNodeVersionDir(wantedNodeVersion);
|
|
79
|
+
if (!node.exists) {
|
|
80
|
+
throw new bvm_error_1.BvmError(`Node.js version ${wantedNodeVersion} is not installed. Try to reinstall the wanted bit CLI version with the --override option`);
|
|
81
|
+
}
|
|
82
|
+
nodeExecPath = path_1.default.join(node.versionDir, process.platform === 'win32' ? 'node.exe' : 'bin/node');
|
|
71
83
|
}
|
|
72
|
-
|
|
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}!`);
|
|
73
87
|
}
|
|
74
88
|
const pkg = {
|
|
75
89
|
bin: {
|
|
@@ -103,13 +117,17 @@ function linkOne(linkName, version, opts = {}) {
|
|
|
103
117
|
if (IS_WINDOWS) {
|
|
104
118
|
binDir = config.getBvmDirectory();
|
|
105
119
|
}
|
|
106
|
-
const pathExtenderReport = yield validateBinDirInPath(binDir, opts);
|
|
120
|
+
const { pathExtenderReport, warning } = yield validateBinDirInPath(binDir, opts);
|
|
121
|
+
if (warning) {
|
|
122
|
+
warnings.push(warning);
|
|
123
|
+
}
|
|
107
124
|
return {
|
|
108
125
|
linkName,
|
|
109
126
|
previousLinkVersion,
|
|
110
127
|
version: concreteVersion,
|
|
111
128
|
generatedLink,
|
|
112
129
|
pathExtenderReport,
|
|
130
|
+
warnings,
|
|
113
131
|
};
|
|
114
132
|
});
|
|
115
133
|
}
|
|
@@ -128,38 +146,46 @@ function validateBinDirInPath(binDir, opts = { addToPathIfMissing: true }) {
|
|
|
128
146
|
if (osPaths.indexOf(binDir) !== -1)
|
|
129
147
|
return;
|
|
130
148
|
if (!opts.addToPathIfMissing) {
|
|
131
|
-
const
|
|
132
|
-
|
|
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') };
|
|
133
155
|
}
|
|
134
156
|
else {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
+
}
|
|
140
178
|
}
|
|
141
179
|
});
|
|
142
180
|
}
|
|
143
|
-
function
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return errLines.join('\n');
|
|
153
|
-
}
|
|
154
|
-
function macLinuxMissingInPathError(binDir, docsLink) {
|
|
155
|
-
// Join with \n for better visibility in windows
|
|
156
|
-
const errLines = [
|
|
157
|
-
'global Bit install location was not found in your PATH global variable.',
|
|
158
|
-
'please add the following to your bash/zsh profile then re-open the terminal:',
|
|
159
|
-
`export PATH=$HOME/bin:$PATH`,
|
|
160
|
-
`for more information read here - ${docsLink}
|
|
161
|
-
`
|
|
162
|
-
];
|
|
163
|
-
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}`;
|
|
164
190
|
}
|
|
165
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,IAAI,EAAE,CAAC;AAkB7B,SAAsB,OAAO,CAAC,IAA+D;;QAC3F,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAChC,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AO,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 }
|
|
@@ -30,16 +31,24 @@ export type GeneratedLink = {
|
|
|
30
31
|
target: string
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
export async function linkAll(opts: { addToPathIfMissing?: boolean }): Promise<LinkResult[]>{
|
|
34
|
+
export async function linkAll(opts: { addToPathIfMissing?: boolean, useSystemNode?: boolean }): Promise<LinkResult[]>{
|
|
34
35
|
const links = config.getLinks();
|
|
35
36
|
const defaultLinkVersion = config.getDefaultLinkVersion();
|
|
36
37
|
const localLatest = (await listLocal()).latest();
|
|
37
38
|
const promises = Object.entries(links).map(([linkName, version]) => {
|
|
38
|
-
return linkOne(linkName, version, {
|
|
39
|
+
return linkOne(linkName, version, {
|
|
40
|
+
addToConfig: false,
|
|
41
|
+
addToPathIfMissing: opts.addToPathIfMissing,
|
|
42
|
+
useSystemNode: opts.useSystemNode,
|
|
43
|
+
});
|
|
39
44
|
});
|
|
40
45
|
if (!defaultLinkVersion && localLatest){
|
|
41
46
|
const defaultLinkName = config.getDefaultLinkName();
|
|
42
|
-
promises.push(linkOne(defaultLinkName, localLatest.version, {
|
|
47
|
+
promises.push(linkOne(defaultLinkName, localLatest.version, {
|
|
48
|
+
addToConfig: true,
|
|
49
|
+
addToPathIfMissing: opts.addToPathIfMissing,
|
|
50
|
+
useSystemNode: opts.useSystemNode,
|
|
51
|
+
}))
|
|
43
52
|
}
|
|
44
53
|
return Promise.all(promises);
|
|
45
54
|
}
|
|
@@ -47,6 +56,7 @@ export async function linkAll(opts: { addToPathIfMissing?: boolean }): Promise<L
|
|
|
47
56
|
export interface LinkOptions {
|
|
48
57
|
addToConfig?: boolean
|
|
49
58
|
addToPathIfMissing?: boolean
|
|
59
|
+
useSystemNode?: boolean
|
|
50
60
|
}
|
|
51
61
|
|
|
52
62
|
export async function linkDefault(
|
|
@@ -71,14 +81,19 @@ export async function linkOne(linkName: string, version: string | undefined, opt
|
|
|
71
81
|
if (!exists){
|
|
72
82
|
throw new BvmError(`version ${concreteVersion} is not installed`);
|
|
73
83
|
}
|
|
74
|
-
const wantedNodeVersion = config.getWantedNodeVersion(versionDir);
|
|
75
84
|
let nodeExecPath: string;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
const wantedNodeVersion = config.getWantedNodeVersion(versionDir);
|
|
86
|
+
const warnings: string[] = []
|
|
87
|
+
if (!opts.useSystemNode) {
|
|
88
|
+
if (wantedNodeVersion) {
|
|
89
|
+
const node = config.getSpecificNodeVersionDir(wantedNodeVersion);
|
|
90
|
+
if (!node.exists) {
|
|
91
|
+
throw new BvmError(`Node.js version ${wantedNodeVersion} is not installed. Try to reinstall the wanted bit CLI version with the --override option`);
|
|
92
|
+
}
|
|
93
|
+
nodeExecPath = path.join(node.versionDir, process.platform === 'win32' ? 'node.exe' : 'bin/node');
|
|
80
94
|
}
|
|
81
|
-
|
|
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}!`)
|
|
82
97
|
}
|
|
83
98
|
const pkg = {
|
|
84
99
|
bin: {
|
|
@@ -113,7 +128,10 @@ export async function linkOne(linkName: string, version: string | undefined, opt
|
|
|
113
128
|
if (IS_WINDOWS){
|
|
114
129
|
binDir = config.getBvmDirectory();
|
|
115
130
|
}
|
|
116
|
-
const pathExtenderReport = await validateBinDirInPath(binDir, opts);
|
|
131
|
+
const { pathExtenderReport, warning } = await validateBinDirInPath(binDir, opts);
|
|
132
|
+
if (warning) {
|
|
133
|
+
warnings.push(warning);
|
|
134
|
+
}
|
|
117
135
|
|
|
118
136
|
return {
|
|
119
137
|
linkName,
|
|
@@ -121,6 +139,7 @@ export async function linkOne(linkName: string, version: string | undefined, opt
|
|
|
121
139
|
version: concreteVersion,
|
|
122
140
|
generatedLink,
|
|
123
141
|
pathExtenderReport,
|
|
142
|
+
warnings,
|
|
124
143
|
}
|
|
125
144
|
}
|
|
126
145
|
|
|
@@ -134,42 +153,48 @@ function getBitBinPath(){
|
|
|
134
153
|
return path.join('@teambit', 'bit', 'bin', 'bit');
|
|
135
154
|
}
|
|
136
155
|
|
|
137
|
-
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 }> {
|
|
138
157
|
const osPaths = (process.env.PATH || process.env.Path || process.env.path).split(path.delimiter);
|
|
139
158
|
if (osPaths.indexOf(binDir) !== -1) return;
|
|
140
159
|
if (!opts.addToPathIfMissing) {
|
|
141
|
-
const
|
|
142
|
-
|
|
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') };
|
|
143
166
|
} else {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
+
}
|
|
149
187
|
}
|
|
150
188
|
}
|
|
151
189
|
|
|
152
|
-
function
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return errLines.join('\n');
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function macLinuxMissingInPathError(binDir: string, 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');
|
|
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}`;
|
|
174
199
|
}
|
|
175
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.3",
|
|
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.3"
|
|
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.3/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
|