@teambit/workspace.modules.node-modules-linker 0.0.140 → 0.0.141
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentID } from '@teambit/component-id';
|
|
2
2
|
import BitMap from '@teambit/legacy/dist/consumer/bit-map/bit-map';
|
|
3
3
|
import ConsumerComponent from '@teambit/legacy/dist/consumer/component/consumer-component';
|
|
4
4
|
import PackageJsonFile from '@teambit/legacy/dist/consumer/component/package-json-file';
|
|
@@ -12,7 +12,7 @@ declare type LinkDetail = {
|
|
|
12
12
|
to: string;
|
|
13
13
|
};
|
|
14
14
|
export declare type NodeModulesLinksResult = {
|
|
15
|
-
id:
|
|
15
|
+
id: ComponentID;
|
|
16
16
|
bound: LinkDetail[];
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
@@ -59,11 +59,11 @@ export default class NodeModuleLinker {
|
|
|
59
59
|
*/
|
|
60
60
|
_applyTransformers(component: Component, packageJson: PackageJsonFile): Promise<void>;
|
|
61
61
|
}
|
|
62
|
-
export declare function linkToNodeModulesWithCodemod(workspace: Workspace, bitIds:
|
|
62
|
+
export declare function linkToNodeModulesWithCodemod(workspace: Workspace, bitIds: ComponentID[], changeRelativeToModulePaths: boolean): Promise<{
|
|
63
63
|
linksResults: NodeModulesLinksResult[];
|
|
64
64
|
codemodResults: any;
|
|
65
65
|
}>;
|
|
66
|
-
export declare function linkToNodeModulesByIds(workspace: Workspace, bitIds:
|
|
66
|
+
export declare function linkToNodeModulesByIds(workspace: Workspace, bitIds: ComponentID[], loadFromScope?: boolean): Promise<NodeModulesLinksResult[]>;
|
|
67
67
|
export declare function linkToNodeModulesByComponents(components: Component[], workspace: Workspace): Promise<NodeModulesLinksResult[]>;
|
|
68
68
|
export declare function removeLinksFromNodeModules(component: Component, workspace: Workspace, files: PathOsBasedAbsolute[]): Promise<void>;
|
|
69
69
|
export {};
|
|
@@ -66,7 +66,7 @@ class NodeModuleLinker {
|
|
|
66
66
|
link() {
|
|
67
67
|
var _a;
|
|
68
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
this.components = this.components.filter((component) => this.bitMap.getComponentIfExist(component.id
|
|
69
|
+
this.components = this.components.filter((component) => this.bitMap.getComponentIfExist(component.id));
|
|
70
70
|
const links = yield this.getLinks();
|
|
71
71
|
const linksResults = this.getLinksResults();
|
|
72
72
|
const workspacePath = this.workspace.path;
|
|
@@ -106,9 +106,9 @@ class NodeModuleLinker {
|
|
|
106
106
|
addLinkResult(symlink.componentId, symlink.src, symlink.dest);
|
|
107
107
|
});
|
|
108
108
|
this.components.forEach((component) => {
|
|
109
|
-
const existingLinkResult = getExistingLinkResult(component.id
|
|
109
|
+
const existingLinkResult = getExistingLinkResult(component.id);
|
|
110
110
|
if (!existingLinkResult) {
|
|
111
|
-
linksResults.push({ id: component.id
|
|
111
|
+
linksResults.push({ id: component.id, bound: [] });
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
return linksResults;
|
|
@@ -128,11 +128,10 @@ class NodeModuleLinker {
|
|
|
128
128
|
_populateComponentsLinks(component) {
|
|
129
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
130
|
const legacyComponent = component.state._consumer;
|
|
131
|
-
const componentId = component.id
|
|
131
|
+
const componentId = component.id;
|
|
132
132
|
const linkPath = (0, component_node_modules_path_1.default)({
|
|
133
133
|
bindingPrefix: legacyComponent.bindingPrefix,
|
|
134
134
|
id: componentId,
|
|
135
|
-
allowNonScope: true,
|
|
136
135
|
defaultScope: component.id.scope,
|
|
137
136
|
extensions: legacyComponent.extensions,
|
|
138
137
|
});
|
|
@@ -142,16 +141,16 @@ class NodeModuleLinker {
|
|
|
142
141
|
});
|
|
143
142
|
}
|
|
144
143
|
symlinkComponentDir(component, linkPath) {
|
|
145
|
-
const componentMap = this.bitMap.getComponent(component.id
|
|
144
|
+
const componentMap = this.bitMap.getComponent(component.id);
|
|
146
145
|
const filesToBind = componentMap.getAllFilesPaths();
|
|
147
146
|
filesToBind.forEach((file) => {
|
|
148
147
|
const fileWithRootDir = path.join(componentMap.rootDir, file);
|
|
149
148
|
const dest = path.join(linkPath, file);
|
|
150
|
-
this.dataToPersist.addSymlink(symlink_1.default.makeInstance(fileWithRootDir, dest, component.id
|
|
149
|
+
this.dataToPersist.addSymlink(symlink_1.default.makeInstance(fileWithRootDir, dest, component.id, true));
|
|
151
150
|
});
|
|
152
151
|
if (constants_1.IS_WINDOWS) {
|
|
153
152
|
// symlink the entire source directory into "_src" in node-modules.
|
|
154
|
-
this.dataToPersist.addSymlink(symlink_1.default.makeInstance(componentMap.rootDir, path.join(linkPath, constants_1.SOURCE_DIR_SYMLINK_TO_NM), component.id
|
|
153
|
+
this.dataToPersist.addSymlink(symlink_1.default.makeInstance(componentMap.rootDir, path.join(linkPath, constants_1.SOURCE_DIR_SYMLINK_TO_NM), component.id));
|
|
155
154
|
}
|
|
156
155
|
}
|
|
157
156
|
/**
|
|
@@ -186,8 +185,8 @@ class NodeModuleLinker {
|
|
|
186
185
|
const hasPackageJsonAsComponentFile = legacyComp.files.some((file) => file.relative === constants_1.PACKAGE_JSON);
|
|
187
186
|
if (hasPackageJsonAsComponentFile)
|
|
188
187
|
return; // don't generate package.json on top of the user package.json
|
|
189
|
-
const dest = path.join((0, component_node_modules_path_1.default)(Object.assign(Object.assign({}, legacyComp), { id: legacyComp.id
|
|
190
|
-
const packageJson = package_json_file_1.default.createFromComponent(dest, legacyComp, true
|
|
188
|
+
const dest = path.join((0, component_node_modules_path_1.default)(Object.assign(Object.assign({}, legacyComp), { id: legacyComp.id })));
|
|
189
|
+
const packageJson = package_json_file_1.default.createFromComponent(dest, legacyComp, true);
|
|
191
190
|
yield this._applyTransformers(component, packageJson);
|
|
192
191
|
if (constants_1.IS_WINDOWS) {
|
|
193
192
|
// in the workspace, override the "types" and add the "src" prefix.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-modules-linker.js","sourceRoot":"","sources":["../node-modules-linker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA0B;AAC1B,gEAAsC;AACtC,2CAA6B;AAC7B,kDAAwD;AAExD,8DAAoG;AAGpG,kHAAwF;AACxF,sHAA4F;AAC5F,8GAAqF;AAErF,gFAAwD;AACxD,6HAAuG;AAEvG,uGAAqH;AACrH,iFAAyD;AACzD,+HAAmG;AAEnG,kFAAkE;AAElE,yEAAoE;AAQpE;;;GAGG;AACH,MAAqB,gBAAgB;IAInC,YAAoB,UAAuB,EAAU,SAAoB;QAArD,eAAU,GAAV,UAAU,CAAa;QAAU,cAAS,GAAT,SAAS,CAAW;QACvE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,IAAI,yBAAa,EAAE,CAAC;IAC3C,CAAC;IACK,IAAI;;;YACR,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"node-modules-linker.js","sourceRoot":"","sources":["../node-modules-linker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA0B;AAC1B,gEAAsC;AACtC,2CAA6B;AAC7B,kDAAwD;AAExD,8DAAoG;AAGpG,kHAAwF;AACxF,sHAA4F;AAC5F,8GAAqF;AAErF,gFAAwD;AACxD,6HAAuG;AAEvG,uGAAqH;AACrH,iFAAyD;AACzD,+HAAmG;AAEnG,kFAAkE;AAElE,yEAAoE;AAQpE;;;GAGG;AACH,MAAqB,gBAAgB;IAInC,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,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC;QAC7F,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;QAClE,MAAM,aAAa,GAAG,0BAA0B,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;QACxF,gBAAM,CAAC,KAAK,CAAC;EACb,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;CAAA;AAZD,gEAYC"}
|
package/node-modules-linker.ts
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs-extra';
|
|
|
2
2
|
import pMapSeries from 'p-map-series';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { linkPkgsToBitRoots } from '@teambit/bit-roots';
|
|
5
|
-
import {
|
|
5
|
+
import { ComponentID } from '@teambit/component-id';
|
|
6
6
|
import { IS_WINDOWS, PACKAGE_JSON, SOURCE_DIR_SYMLINK_TO_NM } from '@teambit/legacy/dist/constants';
|
|
7
7
|
import BitMap from '@teambit/legacy/dist/consumer/bit-map/bit-map';
|
|
8
8
|
import ConsumerComponent from '@teambit/legacy/dist/consumer/component/consumer-component';
|
|
@@ -23,7 +23,7 @@ import { PackageJsonTransformer } from './package-json-transformer';
|
|
|
23
23
|
|
|
24
24
|
type LinkDetail = { from: string; to: string };
|
|
25
25
|
export type NodeModulesLinksResult = {
|
|
26
|
-
id:
|
|
26
|
+
id: ComponentID;
|
|
27
27
|
bound: LinkDetail[];
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -41,7 +41,7 @@ export default class NodeModuleLinker {
|
|
|
41
41
|
this.dataToPersist = new DataToPersist();
|
|
42
42
|
}
|
|
43
43
|
async link(): Promise<NodeModulesLinksResult[]> {
|
|
44
|
-
this.components = this.components.filter((component) => this.bitMap.getComponentIfExist(component.id
|
|
44
|
+
this.components = this.components.filter((component) => this.bitMap.getComponentIfExist(component.id));
|
|
45
45
|
const links = await this.getLinks();
|
|
46
46
|
const linksResults = this.getLinksResults();
|
|
47
47
|
const workspacePath = this.workspace.path;
|
|
@@ -66,8 +66,8 @@ export default class NodeModuleLinker {
|
|
|
66
66
|
}
|
|
67
67
|
getLinksResults(): NodeModulesLinksResult[] {
|
|
68
68
|
const linksResults: NodeModulesLinksResult[] = [];
|
|
69
|
-
const getExistingLinkResult = (id:
|
|
70
|
-
const addLinkResult = (id:
|
|
69
|
+
const getExistingLinkResult = (id: ComponentID) => linksResults.find((linkResult) => linkResult.id.isEqual(id));
|
|
70
|
+
const addLinkResult = (id: ComponentID | null | undefined, from: string, to: string) => {
|
|
71
71
|
if (!id) return;
|
|
72
72
|
const existingLinkResult = getExistingLinkResult(id);
|
|
73
73
|
if (existingLinkResult) {
|
|
@@ -80,9 +80,9 @@ export default class NodeModuleLinker {
|
|
|
80
80
|
addLinkResult(symlink.componentId, symlink.src, symlink.dest);
|
|
81
81
|
});
|
|
82
82
|
this.components.forEach((component) => {
|
|
83
|
-
const existingLinkResult = getExistingLinkResult(component.id
|
|
83
|
+
const existingLinkResult = getExistingLinkResult(component.id);
|
|
84
84
|
if (!existingLinkResult) {
|
|
85
|
-
linksResults.push({ id: component.id
|
|
85
|
+
linksResults.push({ id: component.id, bound: [] });
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
return linksResults;
|
|
@@ -103,11 +103,10 @@ export default class NodeModuleLinker {
|
|
|
103
103
|
*/
|
|
104
104
|
async _populateComponentsLinks(component: Component): Promise<void> {
|
|
105
105
|
const legacyComponent = component.state._consumer as ConsumerComponent;
|
|
106
|
-
const componentId = component.id
|
|
106
|
+
const componentId = component.id;
|
|
107
107
|
const linkPath: PathOsBasedRelative = getNodeModulesPathOfComponent({
|
|
108
108
|
bindingPrefix: legacyComponent.bindingPrefix,
|
|
109
109
|
id: componentId,
|
|
110
|
-
allowNonScope: true,
|
|
111
110
|
defaultScope: component.id.scope,
|
|
112
111
|
extensions: legacyComponent.extensions,
|
|
113
112
|
});
|
|
@@ -118,13 +117,13 @@ export default class NodeModuleLinker {
|
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
private symlinkComponentDir(component: Component, linkPath: PathOsBasedRelative) {
|
|
121
|
-
const componentMap = this.bitMap.getComponent(component.id
|
|
120
|
+
const componentMap = this.bitMap.getComponent(component.id);
|
|
122
121
|
|
|
123
122
|
const filesToBind = componentMap.getAllFilesPaths();
|
|
124
123
|
filesToBind.forEach((file) => {
|
|
125
124
|
const fileWithRootDir = path.join(componentMap.rootDir as string, file);
|
|
126
125
|
const dest = path.join(linkPath, file);
|
|
127
|
-
this.dataToPersist.addSymlink(Symlink.makeInstance(fileWithRootDir, dest, component.id
|
|
126
|
+
this.dataToPersist.addSymlink(Symlink.makeInstance(fileWithRootDir, dest, component.id, true));
|
|
128
127
|
});
|
|
129
128
|
|
|
130
129
|
if (IS_WINDOWS) {
|
|
@@ -133,7 +132,7 @@ export default class NodeModuleLinker {
|
|
|
133
132
|
Symlink.makeInstance(
|
|
134
133
|
componentMap.rootDir as string,
|
|
135
134
|
path.join(linkPath, SOURCE_DIR_SYMLINK_TO_NM),
|
|
136
|
-
component.id
|
|
135
|
+
component.id
|
|
137
136
|
)
|
|
138
137
|
);
|
|
139
138
|
}
|
|
@@ -173,10 +172,9 @@ export default class NodeModuleLinker {
|
|
|
173
172
|
getNodeModulesPathOfComponent({
|
|
174
173
|
...legacyComp,
|
|
175
174
|
id: legacyComp.id,
|
|
176
|
-
allowNonScope: true,
|
|
177
175
|
})
|
|
178
176
|
);
|
|
179
|
-
const packageJson = PackageJsonFile.createFromComponent(dest, legacyComp, true
|
|
177
|
+
const packageJson = PackageJsonFile.createFromComponent(dest, legacyComp, true);
|
|
180
178
|
await this._applyTransformers(component, packageJson);
|
|
181
179
|
if (IS_WINDOWS) {
|
|
182
180
|
// in the workspace, override the "types" and add the "src" prefix.
|
|
@@ -208,7 +206,7 @@ export default class NodeModuleLinker {
|
|
|
208
206
|
|
|
209
207
|
export async function linkToNodeModulesWithCodemod(
|
|
210
208
|
workspace: Workspace,
|
|
211
|
-
bitIds:
|
|
209
|
+
bitIds: ComponentID[],
|
|
212
210
|
changeRelativeToModulePaths: boolean
|
|
213
211
|
) {
|
|
214
212
|
let codemodResults;
|
|
@@ -221,7 +219,7 @@ export async function linkToNodeModulesWithCodemod(
|
|
|
221
219
|
|
|
222
220
|
export async function linkToNodeModulesByIds(
|
|
223
221
|
workspace: Workspace,
|
|
224
|
-
bitIds:
|
|
222
|
+
bitIds: ComponentID[],
|
|
225
223
|
loadFromScope = false
|
|
226
224
|
): Promise<NodeModulesLinksResult[]> {
|
|
227
225
|
const componentsIds = await workspace.resolveMultipleComponentIds(bitIds);
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/workspace.modules.node-modules-linker",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.141",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/workspace/modules/node-modules-linker",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.workspace",
|
|
8
8
|
"name": "modules/node-modules-linker",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.141"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"fs-extra": "10.0.0",
|
|
13
13
|
"p-map-series": "2.1.0",
|
|
14
14
|
"@teambit/bit-roots": "0.0.133",
|
|
15
|
-
"@teambit/component-
|
|
16
|
-
"@teambit/
|
|
15
|
+
"@teambit/component-id": "1.1.0",
|
|
16
|
+
"@teambit/component-package-version": "0.0.428"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/fs-extra": "9.0.7",
|
|
File without changes
|