@teambit/workspace 0.0.762 → 0.0.765
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/pattern.cmd.d.ts +1 -0
- package/dist/pattern.cmd.js +8 -0
- package/dist/pattern.cmd.js.map +1 -1
- package/dist/workspace.d.ts +2 -0
- package/dist/workspace.js +96 -107
- package/dist/workspace.js.map +1 -1
- package/package-tar/teambit-workspace-0.0.765.tgz +0 -0
- package/package.json +31 -32
- package/{preview-1655279906398.js → preview-1655522887639.js} +2 -2
- package/package-tar/teambit-workspace-0.0.762.tgz +0 -0
package/dist/pattern.cmd.d.ts
CHANGED
package/dist/pattern.cmd.js
CHANGED
|
@@ -37,6 +37,14 @@ class PatternCommand {
|
|
|
37
37
|
(0, _defineProperty2().default)(this, "name", 'pattern <pattern>');
|
|
38
38
|
(0, _defineProperty2().default)(this, "alias", '');
|
|
39
39
|
(0, _defineProperty2().default)(this, "description", 'list the component ids matching the given pattern');
|
|
40
|
+
(0, _defineProperty2().default)(this, "extendedDescription", `this command helps validating a pattern before using it in other commands.
|
|
41
|
+
a pattern can be a simple component-id or component-name. e.g. "ui/button".
|
|
42
|
+
a pattern can be used with wildcards for multiple component ids, e.g. "org.scope/utils/**".
|
|
43
|
+
to enter multiple patterns, separate them by a comma, e.g. "ui/*, lib/*"
|
|
44
|
+
to exclude, use "!". e.g. "ui/**, !ui/button"
|
|
45
|
+
always wrap the pattern with quotes to avoid collision with shell commands.
|
|
46
|
+
the matching algorithm is done by multimatch (@see https://github.com/sindresorhus/multimatch)
|
|
47
|
+
`);
|
|
40
48
|
(0, _defineProperty2().default)(this, "group", 'development');
|
|
41
49
|
(0, _defineProperty2().default)(this, "private", false);
|
|
42
50
|
(0, _defineProperty2().default)(this, "options", [['j', 'json', 'return the output as JSON']]);
|
package/dist/pattern.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PatternCommand","constructor","workspace","report","pattern","ids","json","title","chalk","green","bold","length","toString","join","idsByPattern"],"sources":["pattern.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from './workspace';\n\nexport class PatternCommand implements Command {\n name = 'pattern <pattern>';\n alias = '';\n description = 'list the component ids matching the given pattern';\n group = 'development';\n private = false;\n options = [['j', 'json', 'return the output as JSON']] as CommandOptions;\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern]: [string]) {\n const ids = await this.json([pattern]);\n const title = chalk.green(`found ${chalk.bold(ids.length.toString())} components matching the pattern`);\n return `${title}\\n${ids.join('\\n')}`;\n }\n\n async json([pattern]: [string]) {\n return this.workspace.idsByPattern(pattern, false);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,cAAN,CAAwC;
|
|
1
|
+
{"version":3,"names":["PatternCommand","constructor","workspace","report","pattern","ids","json","title","chalk","green","bold","length","toString","join","idsByPattern"],"sources":["pattern.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from './workspace';\n\nexport class PatternCommand implements Command {\n name = 'pattern <pattern>';\n alias = '';\n description = 'list the component ids matching the given pattern';\n extendedDescription = `this command helps validating a pattern before using it in other commands.\na pattern can be a simple component-id or component-name. e.g. \"ui/button\".\na pattern can be used with wildcards for multiple component ids, e.g. \"org.scope/utils/**\".\nto enter multiple patterns, separate them by a comma, e.g. \"ui/*, lib/*\"\nto exclude, use \"!\". e.g. \"ui/**, !ui/button\"\nalways wrap the pattern with quotes to avoid collision with shell commands.\nthe matching algorithm is done by multimatch (@see https://github.com/sindresorhus/multimatch)\n`;\n\n group = 'development';\n private = false;\n options = [['j', 'json', 'return the output as JSON']] as CommandOptions;\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern]: [string]) {\n const ids = await this.json([pattern]);\n const title = chalk.green(`found ${chalk.bold(ids.length.toString())} components matching the pattern`);\n return `${title}\\n${ids.join('\\n')}`;\n }\n\n async json([pattern]: [string]) {\n return this.workspace.idsByPattern(pattern, false);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,cAAN,CAAwC;EAiB7CC,WAAW,CAASC,SAAT,EAA+B;IAAA,KAAtBA,SAAsB,GAAtBA,SAAsB;IAAA,8CAhBnC,mBAgBmC;IAAA,+CAflC,EAekC;IAAA,qDAd5B,mDAc4B;IAAA,6DAbnB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,CAM4C;IAAA,+CAJlC,aAIkC;IAAA,iDAHhC,KAGgC;IAAA,iDAFhC,CAAC,CAAC,GAAD,EAAM,MAAN,EAAc,2BAAd,CAAD,CAEgC;EAAE;;EAEhC,MAANC,MAAM,CAAC,CAACC,OAAD,CAAD,EAAsB;IAChC,MAAMC,GAAG,GAAG,MAAM,KAAKC,IAAL,CAAU,CAACF,OAAD,CAAV,CAAlB;;IACA,MAAMG,KAAK,GAAGC,gBAAA,CAAMC,KAAN,CAAa,SAAQD,gBAAA,CAAME,IAAN,CAAWL,GAAG,CAACM,MAAJ,CAAWC,QAAX,EAAX,CAAkC,kCAAvD,CAAd;;IACA,OAAQ,GAAEL,KAAM,KAAIF,GAAG,CAACQ,IAAJ,CAAS,IAAT,CAAe,EAAnC;EACD;;EAES,MAAJP,IAAI,CAAC,CAACF,OAAD,CAAD,EAAsB;IAC9B,OAAO,KAAKF,SAAL,CAAeY,YAAf,CAA4BV,OAA5B,EAAqC,KAArC,CAAP;EACD;;AA3B4C"}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -271,6 +271,8 @@ export declare class Workspace implements ComponentFactory {
|
|
|
271
271
|
*/
|
|
272
272
|
private resolveScopeAspectListIds;
|
|
273
273
|
/**
|
|
274
|
+
* @deprecated use `this.idsByPattern` instead for consistency. also, it supports negation and list of patterns.
|
|
275
|
+
*
|
|
274
276
|
* load components into the workspace through a variants pattern.
|
|
275
277
|
* @param pattern variants.
|
|
276
278
|
* @param scope scope name.
|
package/dist/workspace.js
CHANGED
|
@@ -14,8 +14,6 @@ require("core-js/modules/es.promise.js");
|
|
|
14
14
|
|
|
15
15
|
require("core-js/modules/es.regexp.exec.js");
|
|
16
16
|
|
|
17
|
-
require("core-js/modules/es.string.trim.js");
|
|
18
|
-
|
|
19
17
|
Object.defineProperty(exports, "__esModule", {
|
|
20
18
|
value: true
|
|
21
19
|
});
|
|
@@ -61,16 +59,6 @@ function _pMapSeries() {
|
|
|
61
59
|
return data;
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
function _multimatch() {
|
|
65
|
-
const data = _interopRequireDefault(require("multimatch"));
|
|
66
|
-
|
|
67
|
-
_multimatch = function () {
|
|
68
|
-
return data;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return data;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
62
|
function _aspectLoader() {
|
|
75
63
|
const data = require("@teambit/aspect-loader");
|
|
76
64
|
|
|
@@ -1078,6 +1066,8 @@ class Workspace {
|
|
|
1078
1066
|
return resolvedList;
|
|
1079
1067
|
}
|
|
1080
1068
|
/**
|
|
1069
|
+
* @deprecated use `this.idsByPattern` instead for consistency. also, it supports negation and list of patterns.
|
|
1070
|
+
*
|
|
1081
1071
|
* load components into the workspace through a variants pattern.
|
|
1082
1072
|
* @param pattern variants.
|
|
1083
1073
|
* @param scope scope name.
|
|
@@ -1110,17 +1100,7 @@ class Workspace {
|
|
|
1110
1100
|
}
|
|
1111
1101
|
|
|
1112
1102
|
const ids = await this.listIds();
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
const idsToCheck = id => [id.toStringWithoutVersion(), id._legacy.toStringWithoutVersion()];
|
|
1116
|
-
|
|
1117
|
-
const idsFiltered = ids.filter(id => (0, _multimatch().default)(idsToCheck(id), patterns).length);
|
|
1118
|
-
|
|
1119
|
-
if (throwForNoMatch && !idsFiltered.length) {
|
|
1120
|
-
throw new (_bitError().BitError)(`unable to find any matching for "${pattern}" pattern`);
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
return idsFiltered;
|
|
1103
|
+
return this.scope.filterIdsFromPoolIdsByPattern(pattern, ids, throwForNoMatch);
|
|
1124
1104
|
}
|
|
1125
1105
|
/**
|
|
1126
1106
|
* useful for workspace commands, such as `bit build`, `bit compile`.
|
|
@@ -1136,7 +1116,8 @@ class Workspace {
|
|
|
1136
1116
|
}
|
|
1137
1117
|
|
|
1138
1118
|
if (pattern) {
|
|
1139
|
-
|
|
1119
|
+
const ids = await this.idsByPattern(pattern);
|
|
1120
|
+
return this.getMany(ids);
|
|
1140
1121
|
}
|
|
1141
1122
|
|
|
1142
1123
|
const newAndModified = await this.newAndModified();
|
|
@@ -2454,110 +2435,118 @@ your workspace.jsonc has this component-id set. you might want to remove/change
|
|
|
2454
2435
|
|
|
2455
2436
|
let legacyId = this.consumer.getParsedIdIfExist(id.toString(), true, true);
|
|
2456
2437
|
|
|
2457
|
-
if (
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
const _bitMapId = this.consumer.getParsedIdIfExist(idWithoutVersion, false, true); // This logic is very specific, and very sensitive for changes please do not touch this without consulting with @ran or @gilad
|
|
2463
|
-
// example (partial list) cases which should be handled are:
|
|
2464
|
-
// use case 1 - ws component provided with the local scope name:
|
|
2465
|
-
// source id : my-scope1/my-name1
|
|
2466
|
-
// bitmap res (_id) : my-name1 (comp is tagged but not exported)
|
|
2467
|
-
// local scope name : my-scope1
|
|
2468
|
-
// scope content : my-name1
|
|
2469
|
-
// expected result : my-name1
|
|
2470
|
-
// use case 2 - component with same name exist in ws and scope (but with different scope name)
|
|
2471
|
-
// source id : my-scope2/my-name1
|
|
2472
|
-
// bitmap res (_id) : my-name1 (comp exist in ws but it's actually different component)
|
|
2473
|
-
// local scope name : my-scope1
|
|
2474
|
-
// scope content : my-scope2/my-name1
|
|
2475
|
-
// expected result : my-scope2/my-name1
|
|
2476
|
-
// use case 3 - component with same name exist in ws and scope (but with different scope name) - source provided without scope name
|
|
2477
|
-
// source id : my-name1
|
|
2478
|
-
// bitmap res (_id) : my-name1 (comp exist in ws but it's actually different component)
|
|
2479
|
-
// local scope name : my-scope1
|
|
2480
|
-
// scope content : my-scope1/my-name1 and my-scope2/my-name1
|
|
2481
|
-
// expected result : my-name1 (get the name from the bitmap)
|
|
2482
|
-
// use case 4 - component with the same name and different scope are imported into the ws
|
|
2483
|
-
// source id : my-name1
|
|
2484
|
-
// bitmap res (_id) : my-scope2/my-name1 (comp exist in ws from different scope (imported))
|
|
2485
|
-
// local scope name : my-scope1
|
|
2486
|
-
// scope content : my-scope2/my-name1
|
|
2487
|
-
// expected result : my-scope2/my-name1 (get the name from the bitmap)
|
|
2488
|
-
// No entry in bitmap at all, search for the original input id
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
if (!_bitMapId) {
|
|
2492
|
-
return await this.scope.resolveComponentId(id.toString());
|
|
2493
|
-
}
|
|
2438
|
+
if (legacyId) {
|
|
2439
|
+
const defaultScope = await getDefaultScope(legacyId); // only reason to strip the scopeName from the given id is when this id has the defaultScope, because .bitmap
|
|
2440
|
+
// doesn't have the defaultScope. if the given id doesn't have scope or has scope different than the default,
|
|
2441
|
+
// then don't ignore it. search with the scope-name.
|
|
2494
2442
|
|
|
2495
|
-
|
|
2443
|
+
const shouldSearchWithoutScopeInProvidedId = id.toString().startsWith(`${defaultScope}/`);
|
|
2444
|
+
legacyId = this.consumer.getParsedIdIfExist(id.toString(), true, shouldSearchWithoutScopeInProvidedId);
|
|
2496
2445
|
|
|
2497
|
-
|
|
2498
|
-
|
|
2446
|
+
if (legacyId) {
|
|
2447
|
+
return _component().ComponentID.fromLegacy(legacyId, defaultScope);
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2499
2450
|
|
|
2451
|
+
try {
|
|
2452
|
+
const idWithVersion = id.toString();
|
|
2453
|
+
const [idWithoutVersion, version] = id.toString().split('@');
|
|
2454
|
+
|
|
2455
|
+
const _bitMapId = this.consumer.getParsedIdIfExist(idWithoutVersion, false, true); // This logic is very specific, and very sensitive for changes please do not touch this without consulting with @ran or @gilad
|
|
2456
|
+
// example (partial list) cases which should be handled are:
|
|
2457
|
+
// use case 1 - ws component provided with the local scope name:
|
|
2458
|
+
// source id : my-scope1/my-name1
|
|
2459
|
+
// bitmap res (_id) : my-name1 (comp is tagged but not exported)
|
|
2460
|
+
// local scope name : my-scope1
|
|
2461
|
+
// scope content : my-name1
|
|
2462
|
+
// expected result : my-name1
|
|
2463
|
+
// use case 2 - component with same name exist in ws and scope (but with different scope name)
|
|
2464
|
+
// source id : my-scope2/my-name1
|
|
2465
|
+
// bitmap res (_id) : my-name1 (comp exist in ws but it's actually different component)
|
|
2466
|
+
// local scope name : my-scope1
|
|
2467
|
+
// scope content : my-scope2/my-name1
|
|
2468
|
+
// expected result : my-scope2/my-name1
|
|
2469
|
+
// use case 3 - component with same name exist in ws and scope (but with different scope name) - source provided without scope name
|
|
2470
|
+
// source id : my-name1
|
|
2471
|
+
// bitmap res (_id) : my-name1 (comp exist in ws but it's actually different component)
|
|
2472
|
+
// local scope name : my-scope1
|
|
2473
|
+
// scope content : my-scope1/my-name1 and my-scope2/my-name1
|
|
2474
|
+
// expected result : my-name1 (get the name from the bitmap)
|
|
2475
|
+
// use case 4 - component with the same name and different scope are imported into the ws
|
|
2476
|
+
// source id : my-name1
|
|
2477
|
+
// bitmap res (_id) : my-scope2/my-name1 (comp exist in ws from different scope (imported))
|
|
2478
|
+
// local scope name : my-scope1
|
|
2479
|
+
// scope content : my-scope2/my-name1
|
|
2480
|
+
// expected result : my-scope2/my-name1 (get the name from the bitmap)
|
|
2481
|
+
// No entry in bitmap at all, search for the original input id
|
|
2482
|
+
|
|
2483
|
+
|
|
2484
|
+
if (!_bitMapId) {
|
|
2485
|
+
return await this.scope.resolveComponentId(id.toString());
|
|
2486
|
+
}
|
|
2500
2487
|
|
|
2501
|
-
|
|
2502
|
-
return await this.scope.resolveComponentId(_bitMapIdWithVersion);
|
|
2503
|
-
} // Handle case when I tagged the component locally with a default scope which is not the local scope
|
|
2504
|
-
// but not exported it yet
|
|
2505
|
-
// now i'm trying to load it with source id contain the default scope prefix
|
|
2506
|
-
// we want to get it from the local first before assuming it's something coming from outside
|
|
2488
|
+
const _bitMapIdWithoutVersion = _bitMapId.toStringWithoutVersion();
|
|
2507
2489
|
|
|
2490
|
+
const _bitMapIdWithVersion = _bitMapId.changeVersion(version).toString(); // The id in the bitmap has prefix which is not in the source id - the bitmap entry has scope name
|
|
2491
|
+
// Handle use case 4
|
|
2508
2492
|
|
|
2509
|
-
if (!_bitMapId.scope) {
|
|
2510
|
-
const defaultScopeForBitmapId = await getDefaultScope(_bitMapId, {
|
|
2511
|
-
ignoreVersion: true
|
|
2512
|
-
});
|
|
2513
2493
|
|
|
2514
|
-
|
|
2515
|
-
|
|
2494
|
+
if (_bitMapIdWithoutVersion.endsWith(idWithoutVersion) && _bitMapIdWithoutVersion !== idWithoutVersion) {
|
|
2495
|
+
return await this.scope.resolveComponentId(_bitMapIdWithVersion);
|
|
2496
|
+
} // Handle case when I tagged the component locally with a default scope which is not the local scope
|
|
2497
|
+
// but not exported it yet
|
|
2498
|
+
// now i'm trying to load it with source id contain the default scope prefix
|
|
2499
|
+
// we want to get it from the local first before assuming it's something coming from outside
|
|
2516
2500
|
|
|
2517
|
-
if (version) {
|
|
2518
|
-
_bitmapIdWithVersionForSource = _bitMapId.changeVersion(version);
|
|
2519
|
-
}
|
|
2520
2501
|
|
|
2521
|
-
|
|
2522
|
-
|
|
2502
|
+
if (!_bitMapId.scope) {
|
|
2503
|
+
const defaultScopeForBitmapId = await getDefaultScope(_bitMapId, {
|
|
2504
|
+
ignoreVersion: true
|
|
2505
|
+
});
|
|
2523
2506
|
|
|
2507
|
+
const getFromBitmapAddDefaultScope = () => {
|
|
2508
|
+
let _bitmapIdWithVersionForSource = _bitMapId;
|
|
2524
2509
|
|
|
2525
|
-
if (
|
|
2526
|
-
|
|
2527
|
-
}
|
|
2510
|
+
if (version) {
|
|
2511
|
+
_bitmapIdWithVersionForSource = _bitMapId.changeVersion(version);
|
|
2512
|
+
}
|
|
2528
2513
|
|
|
2514
|
+
return _component().ComponentID.fromLegacy(_bitmapIdWithVersionForSource, defaultScopeForBitmapId);
|
|
2515
|
+
}; // a case when the given id contains the default scope
|
|
2529
2516
|
|
|
2530
|
-
const fromScope = await this.scope.resolveComponentId(idWithVersion);
|
|
2531
2517
|
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
}
|
|
2518
|
+
if (idWithVersion.startsWith(`${defaultScopeForBitmapId}/${_bitMapIdWithoutVersion}`)) {
|
|
2519
|
+
return getFromBitmapAddDefaultScope();
|
|
2520
|
+
} // a case when the given id does not contain the default scope
|
|
2536
2521
|
|
|
2537
|
-
if (idWithoutVersion.endsWith(_bitMapIdWithoutVersion) && _bitMapIdWithoutVersion !== idWithoutVersion) {
|
|
2538
|
-
// The id in the bitmap doesn't have scope, the source id has scope
|
|
2539
|
-
// Handle use case 2 and use case 1
|
|
2540
|
-
if (id.toString().startsWith(this.scope.name)) {
|
|
2541
|
-
// Handle use case 1 - the provided id has scope name same as the local scope name
|
|
2542
|
-
// we want to send it as it appear in the bitmap
|
|
2543
|
-
return await this.scope.resolveComponentId(_bitMapIdWithVersion);
|
|
2544
|
-
} // Handle use case 2 - the provided id has scope which is not the local scope
|
|
2545
|
-
// we want to search by the source id
|
|
2546
2522
|
|
|
2523
|
+
const fromScope = await this.scope.resolveComponentId(idWithVersion);
|
|
2547
2524
|
|
|
2548
|
-
|
|
2549
|
-
|
|
2525
|
+
if (!fromScope._legacy.hasScope()) {
|
|
2526
|
+
return getFromBitmapAddDefaultScope();
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
if (idWithoutVersion.endsWith(_bitMapIdWithoutVersion) && _bitMapIdWithoutVersion !== idWithoutVersion) {
|
|
2531
|
+
// The id in the bitmap doesn't have scope, the source id has scope
|
|
2532
|
+
// Handle use case 2 and use case 1
|
|
2533
|
+
if (id.toString().startsWith(this.scope.name)) {
|
|
2534
|
+
// Handle use case 1 - the provided id has scope name same as the local scope name
|
|
2535
|
+
// we want to send it as it appear in the bitmap
|
|
2536
|
+
return await this.scope.resolveComponentId(_bitMapIdWithVersion);
|
|
2537
|
+
} // Handle use case 2 - the provided id has scope which is not the local scope
|
|
2538
|
+
// we want to search by the source id
|
|
2550
2539
|
|
|
2551
2540
|
|
|
2552
2541
|
return await this.scope.resolveComponentId(idWithVersion);
|
|
2553
|
-
}
|
|
2554
|
-
legacyId = _legacyBitId().BitId.parse(id.toString(), true);
|
|
2555
|
-
return _component().ComponentID.fromLegacy(legacyId);
|
|
2556
|
-
}
|
|
2557
|
-
}
|
|
2542
|
+
} // Handle use case 3
|
|
2558
2543
|
|
|
2559
|
-
|
|
2560
|
-
|
|
2544
|
+
|
|
2545
|
+
return await this.scope.resolveComponentId(idWithVersion);
|
|
2546
|
+
} catch (error) {
|
|
2547
|
+
legacyId = _legacyBitId().BitId.parse(id.toString(), true);
|
|
2548
|
+
return _component().ComponentID.fromLegacy(legacyId);
|
|
2549
|
+
}
|
|
2561
2550
|
}
|
|
2562
2551
|
|
|
2563
2552
|
async resolveMultipleComponentIds(ids) {
|