@teambit/install 1.0.1270 → 1.0.1272
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/get-package-name-from-target.js +6 -2
- package/dist/link/get-package-name-from-target.js.map +1 -1
- package/dist/link/get-package-name-from-target.spec.d.ts +1 -0
- package/dist/link/get-package-name-from-target.spec.js +32 -0
- package/dist/link/get-package-name-from-target.spec.js.map +1 -0
- package/link/get-package-name-from-target.spec.ts +23 -0
- package/link/get-package-name-from-target.ts +6 -2
- package/package.json +17 -17
- /package/dist/{preview-1793641674677.js → preview-1793650270979.js} +0 -0
|
@@ -5,8 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getPackageNameFromTarget = getPackageNameFromTarget;
|
|
7
7
|
function getPackageNameFromTarget(targetPath) {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const normalized = targetPath.replace(/\\/g, '/');
|
|
9
|
+
const nodeModulesIndex = normalized.lastIndexOf('node_modules');
|
|
10
|
+
if (nodeModulesIndex === -1) return targetPath;
|
|
11
|
+
const segments = normalized.substring(nodeModulesIndex).split('/');
|
|
12
|
+
const isScoped = segments[1]?.startsWith('@');
|
|
13
|
+
const packagePath = segments.slice(0, isScoped ? 3 : 2).join('/');
|
|
10
14
|
return `./${packagePath}`;
|
|
11
15
|
}
|
|
12
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getPackageNameFromTarget","targetPath","
|
|
1
|
+
{"version":3,"names":["getPackageNameFromTarget","targetPath","normalized","replace","nodeModulesIndex","lastIndexOf","segments","substring","split","isScoped","startsWith","packagePath","slice","join"],"sources":["get-package-name-from-target.ts"],"sourcesContent":["export function getPackageNameFromTarget(targetPath: string): string {\n const normalized = targetPath.replace(/\\\\/g, '/');\n const nodeModulesIndex = normalized.lastIndexOf('node_modules');\n if (nodeModulesIndex === -1) return targetPath;\n const segments = normalized.substring(nodeModulesIndex).split('/');\n const isScoped = segments[1]?.startsWith('@');\n const packagePath = segments.slice(0, isScoped ? 3 : 2).join('/');\n return `./${packagePath}`;\n}\n"],"mappings":";;;;;;AAAO,SAASA,wBAAwBA,CAACC,UAAkB,EAAU;EACnE,MAAMC,UAAU,GAAGD,UAAU,CAACE,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;EACjD,MAAMC,gBAAgB,GAAGF,UAAU,CAACG,WAAW,CAAC,cAAc,CAAC;EAC/D,IAAID,gBAAgB,KAAK,CAAC,CAAC,EAAE,OAAOH,UAAU;EAC9C,MAAMK,QAAQ,GAAGJ,UAAU,CAACK,SAAS,CAACH,gBAAgB,CAAC,CAACI,KAAK,CAAC,GAAG,CAAC;EAClE,MAAMC,QAAQ,GAAGH,QAAQ,CAAC,CAAC,CAAC,EAAEI,UAAU,CAAC,GAAG,CAAC;EAC7C,MAAMC,WAAW,GAAGL,QAAQ,CAACM,KAAK,CAAC,CAAC,EAAEH,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,CAACI,IAAI,CAAC,GAAG,CAAC;EACjE,OAAO,KAAKF,WAAW,EAAE;AAC3B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _chai() {
|
|
4
|
+
const data = require("chai");
|
|
5
|
+
_chai = function () {
|
|
6
|
+
return data;
|
|
7
|
+
};
|
|
8
|
+
return data;
|
|
9
|
+
}
|
|
10
|
+
function _getPackageNameFromTarget() {
|
|
11
|
+
const data = require("./get-package-name-from-target");
|
|
12
|
+
_getPackageNameFromTarget = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
describe('getPackageNameFromTarget', () => {
|
|
18
|
+
it('should handle POSIX scoped packages', () => {
|
|
19
|
+
(0, _chai().expect)((0, _getPackageNameFromTarget().getPackageNameFromTarget)('/workspace/node_modules/@teambit/harmony/dist/index.js')).to.equal('./node_modules/@teambit/harmony');
|
|
20
|
+
});
|
|
21
|
+
it('should handle Windows scoped packages with backslashes', () => {
|
|
22
|
+
(0, _chai().expect)((0, _getPackageNameFromTarget().getPackageNameFromTarget)('C:\\workspace\\node_modules\\@teambit\\harmony\\dist\\index.js')).to.equal('./node_modules/@teambit/harmony');
|
|
23
|
+
});
|
|
24
|
+
it('should handle POSIX unscoped packages', () => {
|
|
25
|
+
(0, _chai().expect)((0, _getPackageNameFromTarget().getPackageNameFromTarget)('/workspace/node_modules/lodash/index.js')).to.equal('./node_modules/lodash');
|
|
26
|
+
});
|
|
27
|
+
it('should handle Windows unscoped packages with backslashes', () => {
|
|
28
|
+
(0, _chai().expect)((0, _getPackageNameFromTarget().getPackageNameFromTarget)('C:\\workspace\\node_modules\\lodash\\index.js')).to.equal('./node_modules/lodash');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=get-package-name-from-target.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_chai","data","require","_getPackageNameFromTarget","describe","it","expect","getPackageNameFromTarget","to","equal"],"sources":["get-package-name-from-target.spec.ts"],"sourcesContent":["import { expect } from 'chai';\nimport { getPackageNameFromTarget } from './get-package-name-from-target';\n\ndescribe('getPackageNameFromTarget', () => {\n it('should handle POSIX scoped packages', () => {\n expect(getPackageNameFromTarget('/workspace/node_modules/@teambit/harmony/dist/index.js')).to.equal(\n './node_modules/@teambit/harmony'\n );\n });\n it('should handle Windows scoped packages with backslashes', () => {\n expect(getPackageNameFromTarget('C:\\\\workspace\\\\node_modules\\\\@teambit\\\\harmony\\\\dist\\\\index.js')).to.equal(\n './node_modules/@teambit/harmony'\n );\n });\n it('should handle POSIX unscoped packages', () => {\n expect(getPackageNameFromTarget('/workspace/node_modules/lodash/index.js')).to.equal('./node_modules/lodash');\n });\n it('should handle Windows unscoped packages with backslashes', () => {\n expect(getPackageNameFromTarget('C:\\\\workspace\\\\node_modules\\\\lodash\\\\index.js')).to.equal(\n './node_modules/lodash'\n );\n });\n});\n"],"mappings":";;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,0BAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,yBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEAG,QAAQ,CAAC,0BAA0B,EAAE,MAAM;EACzCC,EAAE,CAAC,qCAAqC,EAAE,MAAM;IAC9C,IAAAC,cAAM,EAAC,IAAAC,oDAAwB,EAAC,wDAAwD,CAAC,CAAC,CAACC,EAAE,CAACC,KAAK,CACjG,iCACF,CAAC;EACH,CAAC,CAAC;EACFJ,EAAE,CAAC,wDAAwD,EAAE,MAAM;IACjE,IAAAC,cAAM,EAAC,IAAAC,oDAAwB,EAAC,gEAAgE,CAAC,CAAC,CAACC,EAAE,CAACC,KAAK,CACzG,iCACF,CAAC;EACH,CAAC,CAAC;EACFJ,EAAE,CAAC,uCAAuC,EAAE,MAAM;IAChD,IAAAC,cAAM,EAAC,IAAAC,oDAAwB,EAAC,yCAAyC,CAAC,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,uBAAuB,CAAC;EAC/G,CAAC,CAAC;EACFJ,EAAE,CAAC,0DAA0D,EAAE,MAAM;IACnE,IAAAC,cAAM,EAAC,IAAAC,oDAAwB,EAAC,+CAA+C,CAAC,CAAC,CAACC,EAAE,CAACC,KAAK,CACxF,uBACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getPackageNameFromTarget } from './get-package-name-from-target';
|
|
3
|
+
|
|
4
|
+
describe('getPackageNameFromTarget', () => {
|
|
5
|
+
it('should handle POSIX scoped packages', () => {
|
|
6
|
+
expect(getPackageNameFromTarget('/workspace/node_modules/@teambit/harmony/dist/index.js')).to.equal(
|
|
7
|
+
'./node_modules/@teambit/harmony'
|
|
8
|
+
);
|
|
9
|
+
});
|
|
10
|
+
it('should handle Windows scoped packages with backslashes', () => {
|
|
11
|
+
expect(getPackageNameFromTarget('C:\\workspace\\node_modules\\@teambit\\harmony\\dist\\index.js')).to.equal(
|
|
12
|
+
'./node_modules/@teambit/harmony'
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
it('should handle POSIX unscoped packages', () => {
|
|
16
|
+
expect(getPackageNameFromTarget('/workspace/node_modules/lodash/index.js')).to.equal('./node_modules/lodash');
|
|
17
|
+
});
|
|
18
|
+
it('should handle Windows unscoped packages with backslashes', () => {
|
|
19
|
+
expect(getPackageNameFromTarget('C:\\workspace\\node_modules\\lodash\\index.js')).to.equal(
|
|
20
|
+
'./node_modules/lodash'
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export function getPackageNameFromTarget(targetPath: string): string {
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const normalized = targetPath.replace(/\\/g, '/');
|
|
3
|
+
const nodeModulesIndex = normalized.lastIndexOf('node_modules');
|
|
4
|
+
if (nodeModulesIndex === -1) return targetPath;
|
|
5
|
+
const segments = normalized.substring(nodeModulesIndex).split('/');
|
|
6
|
+
const isScoped = segments[1]?.startsWith('@');
|
|
7
|
+
const packagePath = segments.slice(0, isScoped ? 3 : 2).join('/');
|
|
4
8
|
return `./${packagePath}`;
|
|
5
9
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/install",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1272",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/workspace/install",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.workspace",
|
|
8
8
|
"name": "install",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.1272"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "4.1.2",
|
|
@@ -30,8 +30,12 @@
|
|
|
30
30
|
"@teambit/component-package-version": "0.0.466",
|
|
31
31
|
"@teambit/component-version": "1.0.4",
|
|
32
32
|
"@teambit/component.sources": "0.0.247",
|
|
33
|
+
"@teambit/component": "1.0.1248",
|
|
33
34
|
"@teambit/dependencies.fs.linked-dependencies": "0.0.89",
|
|
34
35
|
"@teambit/harmony.modules.runtimes": "0.0.4",
|
|
36
|
+
"@teambit/host-initializer": "0.0.946",
|
|
37
|
+
"@teambit/issues": "1.0.1248",
|
|
38
|
+
"@teambit/objects": "0.0.740",
|
|
35
39
|
"@teambit/pkg.modules.component-package-name": "0.0.199",
|
|
36
40
|
"@teambit/toolbox.json.jsonc-utils": "0.0.17",
|
|
37
41
|
"@teambit/variants": "0.0.1701",
|
|
@@ -39,21 +43,17 @@
|
|
|
39
43
|
"@teambit/workspace.root-components": "1.0.1",
|
|
40
44
|
"@teambit/bit-error": "0.0.404",
|
|
41
45
|
"@teambit/toolbox.time.time-format": "0.0.502",
|
|
42
|
-
"@teambit/dependency-resolver": "1.0.
|
|
43
|
-
"@teambit/workspace": "1.0.
|
|
44
|
-
"@teambit/application": "1.0.
|
|
45
|
-
"@teambit/aspect-loader": "1.0.
|
|
46
|
-
"@teambit/bundler": "1.0.
|
|
47
|
-
"@teambit/compiler": "1.0.
|
|
48
|
-
"@teambit/
|
|
49
|
-
"@teambit/
|
|
50
|
-
"@teambit/
|
|
51
|
-
"@teambit/
|
|
52
|
-
"@teambit/
|
|
53
|
-
"@teambit/issues": "1.0.1248",
|
|
54
|
-
"@teambit/objects": "0.0.740",
|
|
55
|
-
"@teambit/ui": "1.0.1269",
|
|
56
|
-
"@teambit/workspace-config-files": "1.0.1270"
|
|
46
|
+
"@teambit/dependency-resolver": "1.0.1253",
|
|
47
|
+
"@teambit/workspace": "1.0.1271",
|
|
48
|
+
"@teambit/application": "1.0.1271",
|
|
49
|
+
"@teambit/aspect-loader": "1.0.1251",
|
|
50
|
+
"@teambit/bundler": "1.0.1269",
|
|
51
|
+
"@teambit/compiler": "1.0.1271",
|
|
52
|
+
"@teambit/envs": "1.0.1251",
|
|
53
|
+
"@teambit/generator": "1.0.1272",
|
|
54
|
+
"@teambit/ipc-events": "1.0.1270",
|
|
55
|
+
"@teambit/ui": "1.0.1270",
|
|
56
|
+
"@teambit/workspace-config-files": "1.0.1271"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/fs-extra": "9.0.7",
|
|
File without changes
|