@teambit/workspace.modules.node-modules-linker 0.0.254 → 0.0.256
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/codemod-components.js +147 -115
- package/dist/codemod-components.js.map +1 -1
- package/dist/index.js +55 -9
- package/dist/index.js.map +1 -1
- package/dist/node-modules-linker.d.ts +1 -1
- package/dist/node-modules-linker.js +335 -296
- package/dist/node-modules-linker.js.map +1 -1
- package/dist/package-json-transformer.js +75 -63
- package/dist/package-json-transformer.js.map +1 -1
- package/package.json +15 -15
- package/types/asset.d.ts +15 -3
- package/dist/preview-1738379875603.js +0 -7
|
@@ -1,97 +1,129 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
15
6
|
exports.changeCodeFromRelativeToModulePaths = changeCodeFromRelativeToModulePaths;
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function changeCodeFromRelativeToModulePaths(workspace, bitIds) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
const components = yield loadComponents(workspace, bitIds);
|
|
25
|
-
const componentsWithRelativeIssues = components.filter((c) => c.state.issues && c.state.issues.getIssue(component_issues_1.IssuesClasses.RelativeComponentsAuthored));
|
|
26
|
-
const dataToPersist = new component_sources_1.DataToPersist();
|
|
27
|
-
const codemodResults = yield Promise.all(componentsWithRelativeIssues.map((component) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const { files, warnings } = yield codemodComponent(workspace, component);
|
|
29
|
-
dataToPersist.addManyFiles(files);
|
|
30
|
-
return { id: component.id, changedFiles: files.map((f) => f.relative), warnings };
|
|
31
|
-
})));
|
|
32
|
-
yield dataToPersist.persistAllToFS();
|
|
33
|
-
const idsToReload = codemodResults.filter((c) => !c.warnings || c.warnings.length === 0).map((c) => c.id);
|
|
34
|
-
yield reloadComponents(workspace, idsToReload);
|
|
35
|
-
return codemodResults.filter((c) => c.changedFiles.length || c.warnings);
|
|
36
|
-
});
|
|
7
|
+
function _path() {
|
|
8
|
+
const data = _interopRequireDefault(require("path"));
|
|
9
|
+
_path = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
37
13
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const componentsWithRelativeIssues = components.filter((c) => c.state.issues && c.state.issues.getIssue(component_issues_1.IssuesClasses.RelativeComponentsAuthored));
|
|
45
|
-
if (componentsWithRelativeIssues.length) {
|
|
46
|
-
const failedComps = componentsWithRelativeIssues.map((c) => c.id.toString()).join(', ');
|
|
47
|
-
throw new Error(`failed rewiring the following components: ${failedComps}`);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
14
|
+
function _componentIssues() {
|
|
15
|
+
const data = require("@teambit/component-issues");
|
|
16
|
+
_componentIssues = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
50
20
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
21
|
+
function _componentId() {
|
|
22
|
+
const data = require("@teambit/component-id");
|
|
23
|
+
_componentId = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
57
27
|
}
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const warnings = [];
|
|
65
|
-
yield Promise.all(component.filesystem.files.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
var _a;
|
|
67
|
-
const relativeInstances = (_a = issues.getIssue(component_issues_1.IssuesClasses.RelativeComponentsAuthored)) === null || _a === void 0 ? void 0 : _a.data[(0, legacy_utils_1.pathNormalizeToLinux)(file.relative)];
|
|
68
|
-
if (!relativeInstances)
|
|
69
|
-
return;
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
const fileBefore = file.contents.toString();
|
|
72
|
-
let newFileString = fileBefore;
|
|
73
|
-
yield Promise.all(relativeInstances.map((relativeEntry) => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
const id = relativeEntry.componentId;
|
|
75
|
-
const requiredComponent = yield workspace.get(id);
|
|
76
|
-
const consumerComp = requiredComponent.state._consumer;
|
|
77
|
-
const packageName = (0, pkg_modules_component_package_name_1.componentIdToPackageName)(Object.assign(Object.assign({}, consumerComp), { id }));
|
|
78
|
-
const cssFamily = ['.css', '.scss', '.less', '.sass'];
|
|
79
|
-
const isCss = cssFamily.includes(file.extname);
|
|
80
|
-
const packageNameSupportCss = isCss ? `~${packageName}` : packageName;
|
|
81
|
-
const stringToReplace = getNameWithoutInternalPath(workspace, relativeEntry);
|
|
82
|
-
// @todo: the "dist" should be replaced by the compiler dist-dir.
|
|
83
|
-
// newFileString = replacePackageName(newFileString, stringToReplace, packageNameSupportCss, 'dist');
|
|
84
|
-
newFileString = (0, legacy_utils_1.replacePackageName)(newFileString, stringToReplace, packageNameSupportCss);
|
|
85
|
-
})));
|
|
86
|
-
if (fileBefore !== newFileString) {
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
file.contents = Buffer.from(newFileString);
|
|
89
|
-
files.push(file);
|
|
90
|
-
}
|
|
91
|
-
})));
|
|
92
|
-
return { files, warnings };
|
|
93
|
-
});
|
|
28
|
+
function _legacy() {
|
|
29
|
+
const data = require("@teambit/legacy.utils");
|
|
30
|
+
_legacy = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
94
34
|
}
|
|
35
|
+
function _pkgModules() {
|
|
36
|
+
const data = require("@teambit/pkg.modules.component-package-name");
|
|
37
|
+
_pkgModules = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function _component() {
|
|
43
|
+
const data = require("@teambit/component.sources");
|
|
44
|
+
_component = function () {
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
50
|
+
async function changeCodeFromRelativeToModulePaths(workspace, bitIds) {
|
|
51
|
+
const components = await loadComponents(workspace, bitIds);
|
|
52
|
+
const componentsWithRelativeIssues = components.filter(c => c.state.issues && c.state.issues.getIssue(_componentIssues().IssuesClasses.RelativeComponentsAuthored));
|
|
53
|
+
const dataToPersist = new (_component().DataToPersist)();
|
|
54
|
+
const codemodResults = await Promise.all(componentsWithRelativeIssues.map(async component => {
|
|
55
|
+
const {
|
|
56
|
+
files,
|
|
57
|
+
warnings
|
|
58
|
+
} = await codemodComponent(workspace, component);
|
|
59
|
+
dataToPersist.addManyFiles(files);
|
|
60
|
+
return {
|
|
61
|
+
id: component.id,
|
|
62
|
+
changedFiles: files.map(f => f.relative),
|
|
63
|
+
warnings
|
|
64
|
+
};
|
|
65
|
+
}));
|
|
66
|
+
await dataToPersist.persistAllToFS();
|
|
67
|
+
const idsToReload = codemodResults.filter(c => !c.warnings || c.warnings.length === 0).map(c => c.id);
|
|
68
|
+
await reloadComponents(workspace, idsToReload);
|
|
69
|
+
return codemodResults.filter(c => c.changedFiles.length || c.warnings);
|
|
70
|
+
}
|
|
71
|
+
async function reloadComponents(workspace, compIds) {
|
|
72
|
+
workspace.clearAllComponentsCache();
|
|
73
|
+
if (!compIds.length) return;
|
|
74
|
+
const components = await loadComponents(workspace, compIds);
|
|
75
|
+
const componentsWithRelativeIssues = components.filter(c => c.state.issues && c.state.issues.getIssue(_componentIssues().IssuesClasses.RelativeComponentsAuthored));
|
|
76
|
+
if (componentsWithRelativeIssues.length) {
|
|
77
|
+
const failedComps = componentsWithRelativeIssues.map(c => c.id.toString()).join(', ');
|
|
78
|
+
throw new Error(`failed rewiring the following components: ${failedComps}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function loadComponents(workspace, bitIds) {
|
|
82
|
+
const componentsIds = bitIds.length ? _componentId().ComponentIdList.fromArray(bitIds) : await workspace.listIds();
|
|
83
|
+
const components = await workspace.getMany(componentsIds);
|
|
84
|
+
return components;
|
|
85
|
+
}
|
|
86
|
+
async function codemodComponent(workspace, component) {
|
|
87
|
+
const issues = component.state.issues;
|
|
88
|
+
const files = [];
|
|
89
|
+
if (!issues || !issues.getIssue(_componentIssues().IssuesClasses.RelativeComponentsAuthored)) return {
|
|
90
|
+
files
|
|
91
|
+
};
|
|
92
|
+
const warnings = [];
|
|
93
|
+
await Promise.all(component.filesystem.files.map(async file => {
|
|
94
|
+
const relativeInstances = issues.getIssue(_componentIssues().IssuesClasses.RelativeComponentsAuthored)?.data[(0, _legacy().pathNormalizeToLinux)(file.relative)];
|
|
95
|
+
if (!relativeInstances) return;
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
const fileBefore = file.contents.toString();
|
|
98
|
+
let newFileString = fileBefore;
|
|
99
|
+
await Promise.all(relativeInstances.map(async relativeEntry => {
|
|
100
|
+
const id = relativeEntry.componentId;
|
|
101
|
+
const requiredComponent = await workspace.get(id);
|
|
102
|
+
const consumerComp = requiredComponent.state._consumer;
|
|
103
|
+
const packageName = (0, _pkgModules().componentIdToPackageName)({
|
|
104
|
+
...consumerComp,
|
|
105
|
+
id
|
|
106
|
+
});
|
|
107
|
+
const cssFamily = ['.css', '.scss', '.less', '.sass'];
|
|
108
|
+
const isCss = cssFamily.includes(file.extname);
|
|
109
|
+
const packageNameSupportCss = isCss ? `~${packageName}` : packageName;
|
|
110
|
+
const stringToReplace = getNameWithoutInternalPath(workspace, relativeEntry);
|
|
111
|
+
// @todo: the "dist" should be replaced by the compiler dist-dir.
|
|
112
|
+
// newFileString = replacePackageName(newFileString, stringToReplace, packageNameSupportCss, 'dist');
|
|
113
|
+
newFileString = (0, _legacy().replacePackageName)(newFileString, stringToReplace, packageNameSupportCss);
|
|
114
|
+
}));
|
|
115
|
+
if (fileBefore !== newFileString) {
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
file.contents = Buffer.from(newFileString);
|
|
118
|
+
files.push(file);
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
121
|
+
return {
|
|
122
|
+
files,
|
|
123
|
+
warnings
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
95
127
|
/**
|
|
96
128
|
* e.g.
|
|
97
129
|
* importSource: '../workspace/workspace.ui'
|
|
@@ -104,33 +136,33 @@ function codemodComponent(workspace, component) {
|
|
|
104
136
|
* remains intact. ('../workspace/workspace.ui' => '@bit/workspace/workspace.ui').
|
|
105
137
|
*/
|
|
106
138
|
function getNameWithoutInternalPath(workspace, relativeEntry) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const filePathRelativeToWorkspace = relativeEntry.relativePath.sourceRelativePath;
|
|
116
|
-
if (filePathRelativeToWorkspace === mainFile) {
|
|
117
|
-
return importSource;
|
|
118
|
-
}
|
|
119
|
-
// the importSource is not the main-file but an internal file, remove the internal part.
|
|
120
|
-
const internalPath = (0, legacy_utils_1.pathRelativeLinux)(rootDir, filePathRelativeToWorkspace);
|
|
121
|
-
const removeLastOccurrence = (str, toRemove) => str.replace(new RegExp(`/${toRemove}$`), '');
|
|
122
|
-
if (importSource.endsWith(internalPath)) {
|
|
123
|
-
return removeLastOccurrence(importSource, internalPath);
|
|
124
|
-
}
|
|
125
|
-
const internalPathNoExt = internalPath.replace(path_1.default.extname(internalPath), '');
|
|
126
|
-
if (importSource.endsWith(internalPathNoExt)) {
|
|
127
|
-
return removeLastOccurrence(importSource, internalPathNoExt);
|
|
128
|
-
}
|
|
129
|
-
const internalPathNoIndex = removeLastOccurrence(internalPathNoExt, 'index');
|
|
130
|
-
if (importSource.endsWith(internalPathNoIndex)) {
|
|
131
|
-
return removeLastOccurrence(importSource, internalPathNoIndex);
|
|
132
|
-
}
|
|
133
|
-
// unable to find anything useful. just return the importSource.
|
|
139
|
+
const importSource = relativeEntry.importSource;
|
|
140
|
+
const componentMap = workspace.consumer.bitMap.getComponentIfExist(relativeEntry.componentId);
|
|
141
|
+
if (!componentMap) return importSource;
|
|
142
|
+
const rootDir = componentMap.rootDir;
|
|
143
|
+
if (!rootDir) return importSource;
|
|
144
|
+
const mainFile = componentMap.trackDir ? componentMap.mainFile : (0, _legacy().pathJoinLinux)(rootDir, componentMap.mainFile);
|
|
145
|
+
const filePathRelativeToWorkspace = relativeEntry.relativePath.sourceRelativePath;
|
|
146
|
+
if (filePathRelativeToWorkspace === mainFile) {
|
|
134
147
|
return importSource;
|
|
148
|
+
}
|
|
149
|
+
// the importSource is not the main-file but an internal file, remove the internal part.
|
|
150
|
+
const internalPath = (0, _legacy().pathRelativeLinux)(rootDir, filePathRelativeToWorkspace);
|
|
151
|
+
const removeLastOccurrence = (str, toRemove) => str.replace(new RegExp(`/${toRemove}$`), '');
|
|
152
|
+
if (importSource.endsWith(internalPath)) {
|
|
153
|
+
return removeLastOccurrence(importSource, internalPath);
|
|
154
|
+
}
|
|
155
|
+
const internalPathNoExt = internalPath.replace(_path().default.extname(internalPath), '');
|
|
156
|
+
if (importSource.endsWith(internalPathNoExt)) {
|
|
157
|
+
return removeLastOccurrence(importSource, internalPathNoExt);
|
|
158
|
+
}
|
|
159
|
+
const internalPathNoIndex = removeLastOccurrence(internalPathNoExt, 'index');
|
|
160
|
+
if (importSource.endsWith(internalPathNoIndex)) {
|
|
161
|
+
return removeLastOccurrence(importSource, internalPathNoIndex);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// unable to find anything useful. just return the importSource.
|
|
165
|
+
return importSource;
|
|
135
166
|
}
|
|
167
|
+
|
|
136
168
|
//# sourceMappingURL=codemod-components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codemod-components.js","sourceRoot":"","sources":["../codemod-components.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAgBA,kFAqBC;AArCD,gDAAwB;AAExB,gEAA2F;AAE3F,wDAAqE;AACrE,wDAAmH;AACnH,oGAAuF;AACvF,kEAAuE;AASvE,SAAsB,mCAAmC,CACvD,SAAoB,EACpB,MAAqB;;QAErB,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC3D,MAAM,4BAA4B,GAAG,UAAU,CAAC,MAAM,CACpD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,gCAAa,CAAC,0BAA0B,CAAC,CAC3F,CAAC;QACF,MAAM,aAAa,GAAG,IAAI,iCAAa,EAAE,CAAC;QAC1C,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CACtC,4BAA4B,CAAC,GAAG,CAAC,CAAO,SAAS,EAAE,EAAE;YACnD,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YACzE,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAClC,OAAO,EAAE,EAAE,EAAE,SAAS,CAA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,CAAC,CAAC;IAC7E,IAAI,YAAY,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC/C,OAAO,oBAAoB,CAAC,YAAY,EAAE,mBAAmB,CAAC,CAAC;IACjE,CAAC;IAED,gEAAgE;IAChE,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
1
|
+
{"version":3,"names":["_path","data","_interopRequireDefault","require","_componentIssues","_componentId","_legacy","_pkgModules","_component","e","__esModule","default","changeCodeFromRelativeToModulePaths","workspace","bitIds","components","loadComponents","componentsWithRelativeIssues","filter","c","state","issues","getIssue","IssuesClasses","RelativeComponentsAuthored","dataToPersist","DataToPersist","codemodResults","Promise","all","map","component","files","warnings","codemodComponent","addManyFiles","id","changedFiles","f","relative","persistAllToFS","idsToReload","length","reloadComponents","compIds","clearAllComponentsCache","failedComps","toString","join","Error","componentsIds","ComponentIdList","fromArray","listIds","getMany","filesystem","file","relativeInstances","pathNormalizeToLinux","fileBefore","contents","newFileString","relativeEntry","componentId","requiredComponent","get","consumerComp","_consumer","packageName","componentIdToPackageName","cssFamily","isCss","includes","extname","packageNameSupportCss","stringToReplace","getNameWithoutInternalPath","replacePackageName","Buffer","from","push","importSource","componentMap","consumer","bitMap","getComponentIfExist","rootDir","mainFile","trackDir","pathJoinLinux","filePathRelativeToWorkspace","relativePath","sourceRelativePath","internalPath","pathRelativeLinux","removeLastOccurrence","str","toRemove","replace","RegExp","endsWith","internalPathNoExt","path","internalPathNoIndex"],"sources":["codemod-components.ts"],"sourcesContent":["import path from 'path';\nimport { Workspace } from '@teambit/workspace';\nimport { IssuesClasses, RelativeComponentsAuthoredEntry } from '@teambit/component-issues';\nimport { Component } from '@teambit/component';\nimport { ComponentID, ComponentIdList } from '@teambit/component-id';\nimport { pathJoinLinux, pathNormalizeToLinux, pathRelativeLinux, replacePackageName } from '@teambit/legacy.utils';\nimport { componentIdToPackageName } from '@teambit/pkg.modules.component-package-name';\nimport { DataToPersist, SourceFile } from '@teambit/component.sources';\nimport { ConsumerComponent } from '@teambit/legacy.consumer-component';\n\nexport type CodemodResult = {\n id: ComponentID;\n changedFiles: string[];\n warnings?: string[];\n};\n\nexport async function changeCodeFromRelativeToModulePaths(\n workspace: Workspace,\n bitIds: ComponentID[]\n): Promise<CodemodResult[]> {\n const components = await loadComponents(workspace, bitIds);\n const componentsWithRelativeIssues = components.filter(\n (c) => c.state.issues && c.state.issues.getIssue(IssuesClasses.RelativeComponentsAuthored)\n );\n const dataToPersist = new DataToPersist();\n const codemodResults = await Promise.all(\n componentsWithRelativeIssues.map(async (component) => {\n const { files, warnings } = await codemodComponent(workspace, component);\n dataToPersist.addManyFiles(files);\n return { id: component.id, changedFiles: files.map((f) => f.relative), warnings };\n })\n );\n await dataToPersist.persistAllToFS();\n const idsToReload = codemodResults.filter((c) => !c.warnings || c.warnings.length === 0).map((c) => c.id);\n await reloadComponents(workspace, idsToReload);\n\n return codemodResults.filter((c) => c.changedFiles.length || c.warnings);\n}\n\nasync function reloadComponents(workspace: Workspace, compIds: ComponentID[]) {\n workspace.clearAllComponentsCache();\n if (!compIds.length) return;\n const components = await loadComponents(workspace, compIds);\n const componentsWithRelativeIssues = components.filter(\n (c) => c.state.issues && c.state.issues.getIssue(IssuesClasses.RelativeComponentsAuthored)\n );\n if (componentsWithRelativeIssues.length) {\n const failedComps = componentsWithRelativeIssues.map((c) => c.id.toString()).join(', ');\n throw new Error(`failed rewiring the following components: ${failedComps}`);\n }\n}\n\nasync function loadComponents(workspace: Workspace, bitIds: ComponentID[]): Promise<Component[]> {\n const componentsIds = bitIds.length ? ComponentIdList.fromArray(bitIds) : await workspace.listIds();\n const components = await workspace.getMany(componentsIds);\n\n return components;\n}\n\nasync function codemodComponent(\n workspace: Workspace,\n component: Component\n): Promise<{ files: SourceFile[]; warnings?: string[] }> {\n const issues = component.state.issues;\n const files: SourceFile[] = [];\n if (!issues || !issues.getIssue(IssuesClasses.RelativeComponentsAuthored)) return { files };\n const warnings: string[] = [];\n await Promise.all(\n component.filesystem.files.map(async (file: SourceFile) => {\n const relativeInstances = issues.getIssue(IssuesClasses.RelativeComponentsAuthored)?.data[\n pathNormalizeToLinux(file.relative)\n ];\n if (!relativeInstances) return;\n // @ts-ignore\n const fileBefore = file.contents.toString() as string;\n let newFileString = fileBefore;\n await Promise.all(\n relativeInstances.map(async (relativeEntry: RelativeComponentsAuthoredEntry) => {\n const id = relativeEntry.componentId;\n const requiredComponent = await workspace.get(id);\n const consumerComp = requiredComponent.state._consumer as ConsumerComponent;\n const packageName = componentIdToPackageName({ ...consumerComp, id });\n const cssFamily = ['.css', '.scss', '.less', '.sass'];\n const isCss = cssFamily.includes(file.extname);\n const packageNameSupportCss = isCss ? `~${packageName}` : packageName;\n const stringToReplace = getNameWithoutInternalPath(workspace, relativeEntry);\n // @todo: the \"dist\" should be replaced by the compiler dist-dir.\n // newFileString = replacePackageName(newFileString, stringToReplace, packageNameSupportCss, 'dist');\n newFileString = replacePackageName(newFileString, stringToReplace, packageNameSupportCss);\n })\n );\n if (fileBefore !== newFileString) {\n // @ts-ignore\n file.contents = Buffer.from(newFileString);\n files.push(file);\n }\n })\n );\n return { files, warnings };\n}\n\n/**\n * e.g.\n * importSource: '../workspace/workspace.ui'\n * sourceRelativePath: 'extensions/workspace/workspace.ui.tsx'\n * rootDir in .bitmap: 'extensions/workspace'.\n *\n * expected to return \"../workspace\", as this is the path to the package root without the internal path.\n *\n * eventually, only this string is replaced by the new package-name and the internal-path part\n * remains intact. ('../workspace/workspace.ui' => '@bit/workspace/workspace.ui').\n */\nfunction getNameWithoutInternalPath(workspace: Workspace, relativeEntry: RelativeComponentsAuthoredEntry): string {\n const importSource = relativeEntry.importSource;\n const componentMap = workspace.consumer.bitMap.getComponentIfExist(relativeEntry.componentId);\n if (!componentMap) return importSource;\n const rootDir = componentMap.rootDir;\n if (!rootDir) return importSource;\n const mainFile = componentMap.trackDir ? componentMap.mainFile : pathJoinLinux(rootDir, componentMap.mainFile);\n const filePathRelativeToWorkspace = relativeEntry.relativePath.sourceRelativePath;\n if (filePathRelativeToWorkspace === mainFile) {\n return importSource;\n }\n // the importSource is not the main-file but an internal file, remove the internal part.\n const internalPath = pathRelativeLinux(rootDir, filePathRelativeToWorkspace);\n const removeLastOccurrence = (str, toRemove) => str.replace(new RegExp(`/${toRemove}$`), '');\n if (importSource.endsWith(internalPath)) {\n return removeLastOccurrence(importSource, internalPath);\n }\n const internalPathNoExt = internalPath.replace(path.extname(internalPath), '');\n if (importSource.endsWith(internalPathNoExt)) {\n return removeLastOccurrence(importSource, internalPathNoExt);\n }\n const internalPathNoIndex = removeLastOccurrence(internalPathNoExt, 'index');\n if (importSource.endsWith(internalPathNoIndex)) {\n return removeLastOccurrence(importSource, internalPathNoIndex);\n }\n\n // unable to find anything useful. just return the importSource.\n return importSource;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,iBAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,gBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,aAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,YAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,YAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,WAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,WAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,UA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KAAKD,GAAG,CAACE,OAAO,CAAC,IAAIC,MAAM,CAAC,IAAIF,QAAQ,GAAG,CAAC,EAAE,EAAE,CAAC;EAC5F,IAAIhB,YAAY,CAACmB,QAAQ,CAACP,YAAY,CAAC,EAAE;IACvC,OAAOE,oBAAoB,CAACd,YAAY,EAAEY,YAAY,CAAC;EACzD;EACA,MAAMQ,iBAAiB,GAAGR,YAAY,CAACK,OAAO,CAACI,eAAI,CAAC7B,OAAO,CAACoB,YAAY,CAAC,EAAE,EAAE,CAAC;EAC9E,IAAIZ,YAAY,CAACmB,QAAQ,CAACC,iBAAiB,CAAC,EAAE;IAC5C,OAAON,oBAAoB,CAACd,YAAY,EAAEoB,iBAAiB,CAAC;EAC9D;EACA,MAAME,mBAAmB,GAAGR,oBAAoB,CAACM,iBAAiB,EAAE,OAAO,CAAC;EAC5E,IAAIpB,YAAY,CAACmB,QAAQ,CAACG,mBAAmB,CAAC,EAAE;IAC9C,OAAOR,oBAAoB,CAACd,YAAY,EAAEsB,mBAAmB,CAAC;EAChE;;EAEA;EACA,OAAOtB,YAAY;AACrB","ignoreList":[]}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(exports, "
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "NodeModulesLinksResult", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _nodeModulesLinker().NodeModulesLinksResult;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "PackageJsonTransformer", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _packageJsonTransformer().PackageJsonTransformer;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "linkToNodeModulesByComponents", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _nodeModulesLinker().linkToNodeModulesByComponents;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "linkToNodeModulesByIds", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _nodeModulesLinker().linkToNodeModulesByIds;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "linkToNodeModulesWithCodemod", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _nodeModulesLinker().linkToNodeModulesWithCodemod;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "removeLinksFromNodeModules", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _nodeModulesLinker().removeLinksFromNodeModules;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
function _nodeModulesLinker() {
|
|
43
|
+
const data = require("./node-modules-linker");
|
|
44
|
+
_nodeModulesLinker = function () {
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
function _packageJsonTransformer() {
|
|
50
|
+
const data = require("./package-json-transformer");
|
|
51
|
+
_packageJsonTransformer = function () {
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
|
|
11
57
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_nodeModulesLinker","data","require","_packageJsonTransformer"],"sources":["index.ts"],"sourcesContent":["export {\n NodeModulesLinksResult,\n linkToNodeModulesByIds,\n linkToNodeModulesWithCodemod,\n linkToNodeModulesByComponents,\n removeLinksFromNodeModules,\n} from './node-modules-linker';\n\nexport { PackageJsonTransformer } from './package-json-transformer';\n\nexport type { CodemodResult } from './codemod-components';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,mBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,kBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAE,wBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,uBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","ignoreList":[]}
|
|
@@ -48,7 +48,7 @@ export default class NodeModuleLinker {
|
|
|
48
48
|
* do not delete this code, but make sure the package manger nest the installed version into it's dependent
|
|
49
49
|
* @param component
|
|
50
50
|
*/
|
|
51
|
-
_deleteExistingLinksRootIfSymlink(linkPath: string):
|
|
51
|
+
_deleteExistingLinksRootIfSymlink(linkPath: string): undefined;
|
|
52
52
|
/**
|
|
53
53
|
* create package.json on node_modules/@bit/component-name/package.json with a property 'main'
|
|
54
54
|
* pointing to the component's main file.
|