@teambit/workspace 1.0.65 → 1.0.67

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/esm.d.mts ADDED
@@ -0,0 +1,5 @@
1
+ export const ComponentStatus: any;
2
+ export const WorkspaceAspect: any;
3
+ export const WorkspaceContext: any;
4
+ export default cjsModule;
5
+ import cjsModule from "./index.js";
package/dist/esm.mjs ADDED
@@ -0,0 +1,8 @@
1
+ // eslint-disable-next-line import/no-unresolved
2
+ import cjsModule from './index.js';
3
+
4
+ export const ComponentStatus = cjsModule.ComponentStatus;
5
+ export const WorkspaceAspect = cjsModule.WorkspaceAspect;
6
+ export const WorkspaceContext = cjsModule.WorkspaceContext;
7
+
8
+ export default cjsModule;
@@ -0,0 +1,27 @@
1
+ import { ComponentID, ComponentIdList } from '@teambit/component-id';
2
+ import { Workspace } from './workspace';
3
+ export declare const statesFilter: readonly ["new", "modified", "deprecated", "deleted", "snappedOnMain", "softTagged", "codeModified"];
4
+ export declare type StatesFilter = typeof statesFilter[number];
5
+ export declare class Filter {
6
+ private workspace;
7
+ constructor(workspace: Workspace);
8
+ by(criteria: StatesFilter | string, ids: ComponentID[]): Promise<ComponentID[]>;
9
+ byState(state: StatesFilter, ids: ComponentID[]): Promise<ComponentID[]>;
10
+ byMultiParamState(state: string, ids: ComponentID[]): Promise<ComponentID[]>;
11
+ byEnv(env: string, withinIds?: ComponentID[]): Promise<ComponentID[]>;
12
+ byModified(withinIds?: ComponentID[]): Promise<ComponentID[]>;
13
+ byCodeModified(withinIds?: ComponentID[]): Promise<ComponentID[]>;
14
+ byNew(withinIds?: ComponentID[]): Promise<ComponentID[]>;
15
+ byDeprecated(withinIds?: ComponentID[]): Promise<ComponentID[]>;
16
+ byDeleted(withinIds?: ComponentID[]): Promise<ComponentID[]>;
17
+ byDuringMergeState(): ComponentIdList;
18
+ /**
19
+ * list components that their head is a snap, not a tag.
20
+ * this is relevant only when the lane is the default (main), otherwise, the head is always a snap.
21
+ * components that are during-merge are filtered out, we don't want them during tag and don't want
22
+ * to show them in the "snapped" section in bit-status.
23
+ */
24
+ bySnappedOnMain(withinIds?: ComponentID[]): Promise<ComponentID[]>;
25
+ bySoftTagged(withinIds?: ComponentID[]): ComponentID[];
26
+ private getModelComps;
27
+ }
package/dist/filter.js ADDED
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.statesFilter = exports.Filter = void 0;
7
+ function _componentId() {
8
+ const data = require("@teambit/component-id");
9
+ _componentId = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _pMapSeries() {
15
+ const data = _interopRequireDefault(require("p-map-series"));
16
+ _pMapSeries = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _lodash() {
22
+ const data = require("lodash");
23
+ _lodash = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+ const statesFilter = exports.statesFilter = ['new', 'modified', 'deprecated', 'deleted', 'snappedOnMain', 'softTagged', 'codeModified'];
30
+ class Filter {
31
+ constructor(workspace) {
32
+ this.workspace = workspace;
33
+ }
34
+ async by(criteria, ids) {
35
+ return criteria.includes(':') ? this.byMultiParamState(criteria, ids) : this.byState(criteria, ids);
36
+ }
37
+ async byState(state, ids) {
38
+ const statePerMethod = {
39
+ new: this.byNew,
40
+ modified: this.byModified,
41
+ deprecated: this.byDeprecated,
42
+ deleted: this.byDeleted,
43
+ snappedOnMain: this.bySnappedOnMain,
44
+ softTagged: this.bySoftTagged,
45
+ codeModified: this.byCodeModified
46
+ };
47
+ if (!statePerMethod[state]) {
48
+ throw new Error(`state ${state} is not recognized, possible values: ${statesFilter.join(', ')}`);
49
+ }
50
+ return statePerMethod[state].bind(this)(ids);
51
+ }
52
+ async byMultiParamState(state, ids) {
53
+ const stateSplit = state.split(':');
54
+ if (stateSplit.length < 2) {
55
+ throw new Error(`byMultiParamState expect the state to have at least one param after the colon, got ${state}`);
56
+ }
57
+ const [stateName, ...stateParams] = stateSplit;
58
+ if (stateName === 'env') {
59
+ return this.byEnv(stateParams[0], ids);
60
+ }
61
+ throw new Error(`byMultiParamState expect the state to be one of the following: ['env'], got ${stateName}`);
62
+ }
63
+ async byEnv(env, withinIds) {
64
+ const ids = withinIds || (await this.workspace.listIds());
65
+ const comps = await this.workspace.getMany(ids);
66
+ const compsUsingEnv = comps.filter(c => {
67
+ const envId = this.workspace.envs.getEnvId(c);
68
+ const envIdWithoutVer = _componentId().ComponentID.getStringWithoutVersion(envId);
69
+ return envIdWithoutVer === env;
70
+ });
71
+ return compsUsingEnv.map(c => c.id);
72
+ }
73
+ async byModified(withinIds) {
74
+ const ids = withinIds || (await this.workspace.listIds());
75
+ const comps = await this.workspace.getMany(ids);
76
+ const modifiedIds = await Promise.all(comps.map(async comp => (await comp.isModified()) ? comp.id : undefined));
77
+ return (0, _lodash().compact)(modifiedIds);
78
+ }
79
+ async byCodeModified(withinIds) {
80
+ const ids = withinIds || (await this.workspace.listIds());
81
+ const compFiles = await (0, _pMapSeries().default)(ids, id => this.workspace.getFilesModification(id));
82
+ const modifiedIds = compFiles.filter(c => c.isModified()).map(c => c.id);
83
+ return (0, _lodash().compact)(modifiedIds);
84
+ }
85
+ async byNew(withinIds) {
86
+ const ids = withinIds || (await this.workspace.listIds());
87
+ return ids.filter(id => !id.hasVersion());
88
+ }
89
+ async byDeprecated(withinIds) {
90
+ const ids = withinIds || (await this.workspace.listIds());
91
+ const comps = await this.workspace.getMany(ids);
92
+ const results = await Promise.all(comps.map(async c => {
93
+ const modelComponent = await this.workspace.consumer.scope.getModelComponentIfExist(c.id);
94
+ const deprecated = await (modelComponent === null || modelComponent === void 0 ? void 0 : modelComponent.isDeprecated(this.workspace.consumer.scope.objects));
95
+ return deprecated ? c.id : null;
96
+ }));
97
+ return (0, _lodash().compact)(results);
98
+ }
99
+ async byDeleted(withinIds) {
100
+ const ids = withinIds || (await this.workspace.listIds());
101
+ const comps = await this.workspace.getMany(ids);
102
+ const deletedIds = comps.filter(c => c.isDeleted()).map(c => c.id);
103
+ return (0, _lodash().compact)(deletedIds);
104
+ }
105
+ byDuringMergeState() {
106
+ const unmergedComponents = this.workspace.scope.legacyScope.objects.unmergedComponents.getComponents();
107
+ return _componentId().ComponentIdList.fromArray(unmergedComponents.map(u => _componentId().ComponentID.fromObject(u.id)));
108
+ }
109
+
110
+ /**
111
+ * list components that their head is a snap, not a tag.
112
+ * this is relevant only when the lane is the default (main), otherwise, the head is always a snap.
113
+ * components that are during-merge are filtered out, we don't want them during tag and don't want
114
+ * to show them in the "snapped" section in bit-status.
115
+ */
116
+ async bySnappedOnMain(withinIds) {
117
+ if (!this.workspace.isOnMain()) {
118
+ return [];
119
+ }
120
+ const ids = withinIds || (await this.workspace.listIds());
121
+ const compIds = _componentId().ComponentIdList.fromArray(ids);
122
+ const componentsFromModel = await this.getModelComps(ids);
123
+ const compsDuringMerge = this.byDuringMergeState();
124
+ const comps = componentsFromModel.filter(c => compIds.hasWithoutVersion(c.toComponentId())).filter(c => !compsDuringMerge.hasWithoutVersion(c.toComponentId())).filter(c => c.isHeadSnap());
125
+ return comps.map(c => c.toComponentIdWithHead());
126
+ }
127
+ bySoftTagged(withinIds) {
128
+ const withCompIds = _componentId().ComponentIdList.fromArray(withinIds || []);
129
+ const all = this.workspace.consumer.bitMap.components.filter(c => c.nextVersion).map(c => c.id);
130
+ return withinIds ? all.filter(id => withCompIds.hasWithoutVersion(id)) : all;
131
+ }
132
+ async getModelComps(ids) {
133
+ const comps = await Promise.all(ids.map(id => this.workspace.scope.getBitObjectModelComponent(id, false)));
134
+ return (0, _lodash().compact)(comps);
135
+ }
136
+ }
137
+ exports.Filter = Filter;
138
+
139
+ //# sourceMappingURL=filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_componentId","data","require","_pMapSeries","_interopRequireDefault","_lodash","obj","__esModule","default","statesFilter","exports","Filter","constructor","workspace","by","criteria","ids","includes","byMultiParamState","byState","state","statePerMethod","new","byNew","modified","byModified","deprecated","byDeprecated","deleted","byDeleted","snappedOnMain","bySnappedOnMain","softTagged","bySoftTagged","codeModified","byCodeModified","Error","join","bind","stateSplit","split","length","stateName","stateParams","byEnv","env","withinIds","listIds","comps","getMany","compsUsingEnv","filter","c","envId","envs","getEnvId","envIdWithoutVer","ComponentID","getStringWithoutVersion","map","id","modifiedIds","Promise","all","comp","isModified","undefined","compact","compFiles","pMapSeries","getFilesModification","hasVersion","results","modelComponent","consumer","scope","getModelComponentIfExist","isDeprecated","objects","deletedIds","isDeleted","byDuringMergeState","unmergedComponents","legacyScope","getComponents","ComponentIdList","fromArray","u","fromObject","isOnMain","compIds","componentsFromModel","getModelComps","compsDuringMerge","hasWithoutVersion","toComponentId","isHeadSnap","toComponentIdWithHead","withCompIds","bitMap","components","nextVersion","getBitObjectModelComponent"],"sources":["filter.ts"],"sourcesContent":["import { ComponentID, ComponentIdList } from '@teambit/component-id';\nimport pMapSeries from 'p-map-series';\nimport { ModelComponent } from '@teambit/legacy/dist/scope/models';\nimport { compact } from 'lodash';\nimport { Workspace } from './workspace';\n\nexport const statesFilter = [\n 'new',\n 'modified',\n 'deprecated',\n 'deleted',\n 'snappedOnMain',\n 'softTagged',\n 'codeModified',\n] as const;\nexport type StatesFilter = typeof statesFilter[number];\n\nexport class Filter {\n constructor(private workspace: Workspace) {}\n\n async by(criteria: StatesFilter | string, ids: ComponentID[]): Promise<ComponentID[]> {\n return criteria.includes(':') ? this.byMultiParamState(criteria, ids) : this.byState(criteria as StatesFilter, ids);\n }\n\n async byState(state: StatesFilter, ids: ComponentID[]): Promise<ComponentID[]> {\n const statePerMethod = {\n new: this.byNew,\n modified: this.byModified,\n deprecated: this.byDeprecated,\n deleted: this.byDeleted,\n snappedOnMain: this.bySnappedOnMain,\n softTagged: this.bySoftTagged,\n codeModified: this.byCodeModified,\n };\n if (!statePerMethod[state]) {\n throw new Error(`state ${state} is not recognized, possible values: ${statesFilter.join(', ')}`);\n }\n return statePerMethod[state].bind(this)(ids);\n }\n\n async byMultiParamState(state: string, ids: ComponentID[]): Promise<ComponentID[]> {\n const stateSplit = state.split(':');\n if (stateSplit.length < 2) {\n throw new Error(`byMultiParamState expect the state to have at least one param after the colon, got ${state}`);\n }\n const [stateName, ...stateParams] = stateSplit;\n if (stateName === 'env') {\n return this.byEnv(stateParams[0], ids);\n }\n throw new Error(`byMultiParamState expect the state to be one of the following: ['env'], got ${stateName}`);\n }\n\n async byEnv(env: string, withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const compsUsingEnv = comps.filter((c) => {\n const envId = this.workspace.envs.getEnvId(c);\n const envIdWithoutVer = ComponentID.getStringWithoutVersion(envId);\n return envIdWithoutVer === env;\n });\n return compsUsingEnv.map((c) => c.id);\n }\n\n async byModified(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const modifiedIds = await Promise.all(comps.map(async (comp) => ((await comp.isModified()) ? comp.id : undefined)));\n return compact(modifiedIds);\n }\n\n async byCodeModified(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const compFiles = await pMapSeries(ids, (id) => this.workspace.getFilesModification(id));\n const modifiedIds = compFiles.filter((c) => c.isModified()).map((c) => c.id);\n return compact(modifiedIds);\n }\n\n async byNew(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n return ids.filter((id) => !id.hasVersion());\n }\n\n async byDeprecated(withinIds?: ComponentID[]) {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const results = await Promise.all(\n comps.map(async (c) => {\n const modelComponent = await this.workspace.consumer.scope.getModelComponentIfExist(c.id);\n const deprecated = await modelComponent?.isDeprecated(this.workspace.consumer.scope.objects);\n return deprecated ? c.id : null;\n })\n );\n return compact(results);\n }\n\n async byDeleted(withinIds?: ComponentID[]) {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const deletedIds = comps.filter((c) => c.isDeleted()).map((c) => c.id);\n return compact(deletedIds);\n }\n\n byDuringMergeState(): ComponentIdList {\n const unmergedComponents = this.workspace.scope.legacyScope.objects.unmergedComponents.getComponents();\n return ComponentIdList.fromArray(unmergedComponents.map((u) => ComponentID.fromObject(u.id)));\n }\n\n /**\n * list components that their head is a snap, not a tag.\n * this is relevant only when the lane is the default (main), otherwise, the head is always a snap.\n * components that are during-merge are filtered out, we don't want them during tag and don't want\n * to show them in the \"snapped\" section in bit-status.\n */\n async bySnappedOnMain(withinIds?: ComponentID[]) {\n if (!this.workspace.isOnMain()) {\n return [];\n }\n const ids = withinIds || (await this.workspace.listIds());\n const compIds = ComponentIdList.fromArray(ids);\n const componentsFromModel = await this.getModelComps(ids);\n const compsDuringMerge = this.byDuringMergeState();\n const comps = componentsFromModel\n .filter((c) => compIds.hasWithoutVersion(c.toComponentId()))\n .filter((c) => !compsDuringMerge.hasWithoutVersion(c.toComponentId()))\n .filter((c) => c.isHeadSnap());\n return comps.map((c) => c.toComponentIdWithHead());\n }\n\n bySoftTagged(withinIds?: ComponentID[]): ComponentID[] {\n const withCompIds = ComponentIdList.fromArray(withinIds || []);\n const all = this.workspace.consumer.bitMap.components.filter((c) => c.nextVersion).map((c) => c.id);\n return withinIds ? all.filter((id) => withCompIds.hasWithoutVersion(id)) : all;\n }\n\n private async getModelComps(ids: ComponentID[]): Promise<ModelComponent[]> {\n const comps = await Promise.all(ids.map((id) => this.workspace.scope.getBitObjectModelComponent(id, false)));\n return compact(comps);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,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AAC;EACpD;EAEAhE,YAAYA,CAACa,SAAyB,EAAiB;IACrD,MAAMoD,WAAW,GAAGb,8BAAe,CAACC,SAAS,CAACxC,SAAS,IAAI,EAAE,CAAC;IAC9D,MAAMiB,GAAG,GAAG,IAAI,CAAClD,SAAS,CAAC6D,QAAQ,CAACyB,MAAM,CAACC,UAAU,CAACjD,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACiD,WAAW,CAAC,CAAC1C,GAAG,CAAEP,CAAC,IAAKA,CAAC,CAACQ,EAAE,CAAC;IACnG,OAAOd,SAAS,GAAGiB,GAAG,CAACZ,MAAM,CAAES,EAAE,IAAKsC,WAAW,CAACJ,iBAAiB,CAAClC,EAAE,CAAC,CAAC,GAAGG,GAAG;EAChF;EAEA,MAAc6B,aAAaA,CAAC5E,GAAkB,EAA6B;IACzE,MAAMgC,KAAK,GAAG,MAAMc,OAAO,CAACC,GAAG,CAAC/C,GAAG,CAAC2C,GAAG,CAAEC,EAAE,IAAK,IAAI,CAAC/C,SAAS,CAAC8D,KAAK,CAAC2B,0BAA0B,CAAC1C,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5G,OAAO,IAAAO,iBAAO,EAACnB,KAAK,CAAC;EACvB;AACF;AAACtC,OAAA,CAAAC,MAAA,GAAAA,MAAA"}
package/dist/index.d.ts CHANGED
@@ -7,7 +7,8 @@ export * from './events';
7
7
  export type { WorkspaceUI } from './workspace.ui.runtime';
8
8
  export type { SerializableResults, OnComponentLoad, OnComponentEventResult } from './on-component-events';
9
9
  export { ComponentStatus } from './workspace-component';
10
- export { WorkspaceModelComponent, Workspace as WorkspaceModel } from './ui/workspace/workspace-model';
10
+ export type { WorkspaceModelComponent } from './ui/workspace/workspace-model';
11
+ export { Workspace as WorkspaceModel } from './ui/workspace/workspace-model';
11
12
  export { WorkspaceContext } from './ui/workspace/workspace-context';
12
13
  export { OutsideWorkspaceError } from './exceptions/outside-workspace';
13
14
  export type { WorkspaceComponent } from './workspace-component';
package/dist/index.js CHANGED
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  var _exportNames = {
7
7
  WorkspaceAspect: true,
8
8
  ComponentStatus: true,
9
- WorkspaceModelComponent: true,
10
9
  WorkspaceModel: true,
11
10
  WorkspaceContext: true,
12
11
  OutsideWorkspaceError: true
@@ -41,12 +40,6 @@ Object.defineProperty(exports, "WorkspaceModel", {
41
40
  return _workspaceModel().Workspace;
42
41
  }
43
42
  });
44
- Object.defineProperty(exports, "WorkspaceModelComponent", {
45
- enumerable: true,
46
- get: function () {
47
- return _workspaceModel().WorkspaceModelComponent;
48
- }
49
- });
50
43
  exports.default = void 0;
51
44
  function _workspace() {
52
45
  const data = require("./workspace.aspect");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_workspace","data","require","_events","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_workspaceComponent","_workspaceModel","_workspaceContext","_outsideWorkspace","_default","default","WorkspaceAspect"],"sources":["index.ts"],"sourcesContent":["import { WorkspaceAspect } from './workspace.aspect';\n// eslint-disable-next-line import/prefer-default-export\nexport type { default as Workspace, ExtensionsOrigin } from './workspace';\n// TODO: change to module path once track the utils folder\nexport type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';\nexport type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';\nexport type { WorkspaceMain } from './workspace.main.runtime';\nexport * from './events';\nexport type { WorkspaceUI } from './workspace.ui.runtime';\nexport type { SerializableResults, OnComponentLoad, OnComponentEventResult } from './on-component-events';\nexport { ComponentStatus } from './workspace-component';\nexport { WorkspaceModelComponent, Workspace as WorkspaceModel } from './ui/workspace/workspace-model';\nexport { WorkspaceContext } from './ui/workspace/workspace-context';\nexport { OutsideWorkspaceError } from './exceptions/outside-workspace';\nexport type { WorkspaceComponent } from './workspace-component';\nexport type { ComponentConfigFile } from './component-config-file';\nexport type { CompFiles, FilesStatus } from './workspace-component/comp-files';\nexport type { MergeOptions as BitmapMergeOptions } from './bit-map';\nexport type { WorkspaceExtConfig } from './types';\nexport { WorkspaceAspect };\nexport default WorkspaceAspect;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAOA,IAAAE,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAGA,SAAAS,oBAAA;EAAA,MAAAf,IAAA,GAAAC,OAAA;EAAAc,mBAAA,YAAAA,CAAA;IAAA,OAAAf,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAgB,gBAAA;EAAA,MAAAhB,IAAA,GAAAC,OAAA;EAAAe,eAAA,YAAAA,CAAA;IAAA,OAAAhB,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAiB,kBAAA;EAAA,MAAAjB,IAAA,GAAAC,OAAA;EAAAgB,iBAAA,YAAAA,CAAA;IAAA,OAAAjB,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAkB,kBAAA;EAAA,MAAAlB,IAAA,GAAAC,OAAA;EAAAiB,iBAAA,YAAAA,CAAA;IAAA,OAAAlB,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAZA;AAEA;AAAA,IAAAmB,QAAA,GAAAR,OAAA,CAAAS,OAAA,GAiBeC,4BAAe"}
1
+ {"version":3,"names":["_workspace","data","require","_events","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_workspaceComponent","_workspaceModel","_workspaceContext","_outsideWorkspace","_default","default","WorkspaceAspect"],"sources":["index.ts"],"sourcesContent":["import { WorkspaceAspect } from './workspace.aspect';\n// eslint-disable-next-line import/prefer-default-export\nexport type { default as Workspace, ExtensionsOrigin } from './workspace';\n// TODO: change to module path once track the utils folder\nexport type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';\nexport type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';\nexport type { WorkspaceMain } from './workspace.main.runtime';\nexport * from './events';\nexport type { WorkspaceUI } from './workspace.ui.runtime';\nexport type { SerializableResults, OnComponentLoad, OnComponentEventResult } from './on-component-events';\nexport { ComponentStatus } from './workspace-component';\nexport type { WorkspaceModelComponent } from './ui/workspace/workspace-model';\nexport { Workspace as WorkspaceModel } from './ui/workspace/workspace-model';\nexport { WorkspaceContext } from './ui/workspace/workspace-context';\nexport { OutsideWorkspaceError } from './exceptions/outside-workspace';\nexport type { WorkspaceComponent } from './workspace-component';\nexport type { ComponentConfigFile } from './component-config-file';\nexport type { CompFiles, FilesStatus } from './workspace-component/comp-files';\nexport type { MergeOptions as BitmapMergeOptions } from './bit-map';\nexport type { WorkspaceExtConfig } from './types';\nexport { WorkspaceAspect };\nexport default WorkspaceAspect;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAOA,IAAAE,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAGA,SAAAS,oBAAA;EAAA,MAAAf,IAAA,GAAAC,OAAA;EAAAc,mBAAA,YAAAA,CAAA;IAAA,OAAAf,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAgB,gBAAA;EAAA,MAAAhB,IAAA,GAAAC,OAAA;EAAAe,eAAA,YAAAA,CAAA;IAAA,OAAAhB,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAiB,kBAAA;EAAA,MAAAjB,IAAA,GAAAC,OAAA;EAAAgB,iBAAA,YAAAA,CAAA;IAAA,OAAAjB,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAkB,kBAAA;EAAA,MAAAlB,IAAA,GAAAC,OAAA;EAAAiB,iBAAA,YAAAA,CAAA;IAAA,OAAAlB,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAbA;AAEA;AAAA,IAAAmB,QAAA,GAAAR,OAAA,CAAAS,OAAA,GAkBeC,4BAAe"}
@@ -11,6 +11,13 @@ function _chalk() {
11
11
  };
12
12
  return data;
13
13
  }
14
+ function _filter() {
15
+ const data = require("./filter");
16
+ _filter = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
14
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
22
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
23
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
@@ -22,12 +29,18 @@ class PatternCommand {
22
29
  _defineProperty(this, "alias", '');
23
30
  _defineProperty(this, "description", 'list the component ids matching the given pattern');
24
31
  _defineProperty(this, "extendedDescription", `this command helps validating a pattern before using it in other commands.
32
+ NOTE: always wrap the pattern with quotes to avoid collision with shell commands. depending on your shell, it might be single or double quotes.
25
33
  a pattern can be a simple component-id or component-name. e.g. 'ui/button'.
26
34
  a pattern can be used with wildcards for multiple component ids, e.g. 'org.scope/utils/**' or '**/utils/**' to capture all org/scopes.
27
35
  to enter multiple patterns, separate them by a comma, e.g. 'ui/*, lib/*'
28
36
  to exclude, use '!'. e.g. 'ui/**, !ui/button'
29
- the matching algorithm is from multimatch (@see https://github.com/sindresorhus/multimatch)
30
- NOTE: always wrap the pattern with single quotes '' and not double "" to avoid collision with shell commands
37
+ the matching algorithm is from multimatch (@see https://github.com/sindresorhus/multimatch).
38
+
39
+ to filter by a state or attribute, prefix the pattern with "$". e.g. '$deprecated', '$modified'.
40
+ list of supported states: [${_filter().statesFilter.join(', ')}].
41
+ to filter by multi-params state/attribute, separate the params with ":", e.g. '$env:teambit.react/react'.
42
+ list of supported multi-params states: [env].
43
+ to match a state and another criteria, use " AND " keyword. e.g. '$modified AND teambit.workspace/**'. note that the state must be first.
31
44
  `);
32
45
  _defineProperty(this, "examples", [{
33
46
  cmd: "bit pattern '**'",
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","PatternCommand","constructor","workspace","cmd","description","report","pattern","ids","json","title","chalk","green","bold","length","toString","join","idsByPattern","exports"],"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/**' or '**/utils/**' to capture all org/scopes.\nto enter multiple patterns, separate them by a comma, e.g. 'ui/*, lib/*'\nto exclude, use '!'. e.g. 'ui/**, !ui/button'\nthe matching algorithm is from multimatch (@see https://github.com/sindresorhus/multimatch)\nNOTE: always wrap the pattern with single quotes '' and not double \"\" to avoid collision with shell commands\n`;\n examples = [\n { cmd: \"bit pattern '**'\", description: 'matches all components' },\n {\n cmd: \"bit pattern '*/ui/*'\",\n description:\n 'matches components with any scope-name and the \"ui\" namespace. e.g. \"ui/button\" but not \"ui/elements/button\"',\n },\n {\n cmd: \"bit pattern '*/ui/**'\",\n description: 'matches components whose namespace starts with \"ui/\" e.g. \"ui/button\", \"ui/elements/button\"',\n },\n { cmd: \"bit pattern 'bar, foo'\", description: 'matches two components: bar and foo' },\n { cmd: \"bit pattern 'my-scope.org/**'\", description: 'matches all components of the scope \"my-scope.org\"' },\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,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,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GAAG,EAAE,sBAAsB;MAC3BC,WAAW,EACT;IACJ,CAAC,EACD;MACED,GAAG,EAAE,uBAAuB;MAC5BC,WAAW,EAAE;IACf,CAAC,EACD;MAAED,GAAG,EAAE,wBAAwB;MAAEC,WAAW,EAAE;IAAsC,CAAC,EACrF;MAAED,GAAG,EAAE,+BAA+B;MAAEC,WAAW,EAAE;IAAqD,CAAC,CAC5G;IAAA1B,eAAA,gBACO,aAAa;IAAAA,eAAA,kBACX,KAAK;IAAAA,eAAA,kBACL,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,2BAA2B,CAAC,CAAC;EAEX;EAE3C,MAAM2B,MAAMA,CAAC,CAACC,OAAO,CAAW,EAAE;IAChC,MAAMC,GAAG,GAAG,MAAM,IAAI,CAACC,IAAI,CAAC,CAACF,OAAO,CAAC,CAAC;IACtC,MAAMG,KAAK,GAAGC,gBAAK,CAACC,KAAK,CAAE,SAAQD,gBAAK,CAACE,IAAI,CAACL,GAAG,CAACM,MAAM,CAACC,QAAQ,CAAC,CAAC,CAAE,kCAAiC,CAAC;IACvG,OAAQ,GAAEL,KAAM,KAAIF,GAAG,CAACQ,IAAI,CAAC,IAAI,CAAE,EAAC;EACtC;EAEA,MAAMP,IAAIA,CAAC,CAACF,OAAO,CAAW,EAAE;IAC9B,OAAO,IAAI,CAACJ,SAAS,CAACc,YAAY,CAACV,OAAO,EAAE,KAAK,CAAC;EACpD;AACF;AAACW,OAAA,CAAAjB,cAAA,GAAAA,cAAA"}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_filter","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","PatternCommand","constructor","workspace","statesFilter","join","cmd","description","report","pattern","ids","json","title","chalk","green","bold","length","toString","idsByPattern","exports"],"sources":["pattern.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from './workspace';\nimport { statesFilter } from './filter';\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.\nNOTE: always wrap the pattern with quotes to avoid collision with shell commands. depending on your shell, it might be single or double quotes.\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/**' or '**/utils/**' to capture all org/scopes.\nto enter multiple patterns, separate them by a comma, e.g. 'ui/*, lib/*'\nto exclude, use '!'. e.g. 'ui/**, !ui/button'\nthe matching algorithm is from multimatch (@see https://github.com/sindresorhus/multimatch).\n\nto filter by a state or attribute, prefix the pattern with \"$\". e.g. '$deprecated', '$modified'.\nlist of supported states: [${statesFilter.join(', ')}].\nto filter by multi-params state/attribute, separate the params with \":\", e.g. '$env:teambit.react/react'.\nlist of supported multi-params states: [env].\nto match a state and another criteria, use \" AND \" keyword. e.g. '$modified AND teambit.workspace/**'. note that the state must be first.\n`;\n examples = [\n { cmd: \"bit pattern '**'\", description: 'matches all components' },\n {\n cmd: \"bit pattern '*/ui/*'\",\n description:\n 'matches components with any scope-name and the \"ui\" namespace. e.g. \"ui/button\" but not \"ui/elements/button\"',\n },\n {\n cmd: \"bit pattern '*/ui/**'\",\n description: 'matches components whose namespace starts with \"ui/\" e.g. \"ui/button\", \"ui/elements/button\"',\n },\n { cmd: \"bit pattern 'bar, foo'\", description: 'matches two components: bar and foo' },\n { cmd: \"bit pattern 'my-scope.org/**'\", description: 'matches all components of the scope \"my-scope.org\"' },\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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D;AACF;AAACU,OAAA,CAAAlB,cAAA,GAAAA,cAAA"}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@1.0.65/dist/workspace.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@1.0.65/dist/workspace.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@1.0.67/dist/workspace.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@1.0.67/dist/workspace.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -14,12 +14,12 @@ export declare function useWorkspace(options?: UseWorkspaceOptions): {
14
14
  loading: boolean;
15
15
  networkStatus: import("@apollo/client").NetworkStatus;
16
16
  called: boolean;
17
+ variables: import("@apollo/client").OperationVariables | undefined;
17
18
  startPolling: (pollInterval: number) => void;
18
19
  stopPolling: () => void;
19
20
  updateQuery: <TVars = import("@apollo/client").OperationVariables>(mapFn: (previousQueryResult: any, options: Pick<import("@apollo/client").WatchQueryOptions<TVars, any>, "variables">) => any) => void;
20
21
  refetch: (variables?: Partial<import("@apollo/client").OperationVariables> | undefined) => Promise<import("@apollo/client").ApolloQueryResult<any>>;
21
22
  reobserve: (newOptions?: Partial<import("@apollo/client").WatchQueryOptions<import("@apollo/client").OperationVariables, any>> | undefined, newNetworkStatus?: import("@apollo/client").NetworkStatus | undefined) => Promise<import("@apollo/client").ApolloQueryResult<any>>;
22
- variables: import("@apollo/client").OperationVariables | undefined;
23
23
  fetchMore: <TFetchData = any, TFetchVars = import("@apollo/client").OperationVariables>(fetchMoreOptions: import("@apollo/client").FetchMoreQueryOptions<TFetchVars, TFetchData> & {
24
24
  updateQuery?: ((previousQueryResult: any, options: {
25
25
  fetchMoreResult: TFetchData;
@@ -38,6 +38,7 @@ import type { MergeOptions as BitmapMergeOptions } from './bit-map';
38
38
  import { AspectPackage, GetConfiguredUserAspectsPackagesOptions, WorkspaceAspectsLoader, WorkspaceLoadAspectsOptions } from './workspace-aspects-loader';
39
39
  import { MergeConflictFile } from './merge-conflict-file';
40
40
  import { CompFiles } from './workspace-component/comp-files';
41
+ import { Filter } from './filter';
41
42
  export declare type EjectConfResult = {
42
43
  configPath: string;
43
44
  };
@@ -122,6 +123,7 @@ export declare class Workspace implements ComponentFactory {
122
123
  */
123
124
  private componentPathsRegExps;
124
125
  localAspects: string[];
126
+ filter: Filter;
125
127
  constructor(
126
128
  /**
127
129
  * private pubsub.
@@ -316,6 +318,7 @@ export declare class Workspace implements ComponentFactory {
316
318
  * it supports negate (!) character to exclude ids.
317
319
  */
318
320
  idsByPattern(pattern: string, throwForNoMatch?: boolean): Promise<ComponentID[]>;
321
+ filterIdsFromPoolIdsByPattern(pattern: string, ids: ComponentID[], throwForNoMatch?: boolean): Promise<ComponentID[]>;
319
322
  /**
320
323
  * useful for workspace commands, such as `bit build`, `bit compile`.
321
324
  * by default, it should be running on new and modified components.
package/dist/workspace.js CHANGED
@@ -312,6 +312,13 @@ function _compFiles() {
312
312
  };
313
313
  return data;
314
314
  }
315
+ function _filter() {
316
+ const data = require("./filter");
317
+ _filter = function () {
318
+ return data;
319
+ };
320
+ return data;
321
+ }
315
322
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
316
323
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
317
324
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -404,6 +411,7 @@ class Workspace {
404
411
  */
405
412
  _defineProperty(this, "componentPathsRegExps", []);
406
413
  _defineProperty(this, "localAspects", []);
414
+ _defineProperty(this, "filter", void 0);
407
415
  this.componentLoadedSelfAsAspects = (0, _cacheFactory().createInMemoryCache)({
408
416
  maxSize: (0, _inMemoryCache().getMaxSizeForComponents)()
409
417
  });
@@ -421,6 +429,7 @@ class Workspace {
421
429
  });
422
430
 
423
431
  this.aspectsMerger = new (_aspectsMerger().AspectsMerger)(this, this.harmony);
432
+ this.filter = new (_filter().Filter)(this);
424
433
  }
425
434
  validateConfig() {
426
435
  if (this.consumer.isLegacy) return;
@@ -1054,7 +1063,9 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
1054
1063
  * it supports negate (!) character to exclude ids.
1055
1064
  */
1056
1065
  async idsByPattern(pattern, throwForNoMatch = true) {
1057
- if (!pattern.includes('*') && !pattern.includes(',')) {
1066
+ const specialSyntax = ['*', ',', '!', '$', ':'];
1067
+ const isId = !specialSyntax.some(char => pattern.includes(char));
1068
+ if (isId) {
1058
1069
  // if it's not a pattern but just id, resolve it without multimatch to support specifying id without scope-name
1059
1070
  const id = await this.resolveComponentId(pattern);
1060
1071
  if (this.exists(id)) return [id];
@@ -1062,7 +1073,10 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
1062
1073
  return [];
1063
1074
  }
1064
1075
  const ids = await this.listIds();
1065
- return this.scope.filterIdsFromPoolIdsByPattern(pattern, ids, throwForNoMatch);
1076
+ return this.filterIdsFromPoolIdsByPattern(pattern, ids, throwForNoMatch);
1077
+ }
1078
+ async filterIdsFromPoolIdsByPattern(pattern, ids, throwForNoMatch = true) {
1079
+ return this.scope.filterIdsFromPoolIdsByPattern(pattern, ids, throwForNoMatch, this.filter.by.bind(this.filter));
1066
1080
  }
1067
1081
 
1068
1082
  /**