@teambit/workspace 1.0.106 → 1.0.108

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.
Files changed (86) hide show
  1. package/aspects-merger.ts +319 -0
  2. package/bit-map.ts +277 -0
  3. package/build-graph-from-fs.ts +188 -0
  4. package/build-graph-ids-from-fs.ts +216 -0
  5. package/capsule.cmd.ts +217 -0
  6. package/constants.ts +1 -0
  7. package/dist/aspects-merger.js +13 -22
  8. package/dist/aspects-merger.js.map +1 -1
  9. package/dist/bit-map.d.ts +1 -1
  10. package/dist/build-graph-from-fs.d.ts +2 -2
  11. package/dist/build-graph-from-fs.js +1 -2
  12. package/dist/build-graph-from-fs.js.map +1 -1
  13. package/dist/build-graph-ids-from-fs.js +1 -1
  14. package/dist/build-graph-ids-from-fs.js.map +1 -1
  15. package/dist/capsule.cmd.d.ts +2 -2
  16. package/dist/capsule.cmd.js +1 -2
  17. package/dist/capsule.cmd.js.map +1 -1
  18. package/dist/component-config-file/component-config-file.d.ts +2 -2
  19. package/dist/component-tree.widget.d.ts +2 -2
  20. package/dist/eject-conf.cmd.d.ts +2 -2
  21. package/dist/envs-subcommands/envs-replace.cmd.d.ts +1 -1
  22. package/dist/envs-subcommands/envs-set.cmd.d.ts +1 -1
  23. package/dist/envs-subcommands/envs-unset.cmd.d.ts +1 -1
  24. package/dist/envs-subcommands/envs-update.cmd.d.ts +1 -1
  25. package/dist/filter.d.ts +1 -1
  26. package/dist/filter.js +1 -1
  27. package/dist/filter.js.map +1 -1
  28. package/dist/merge-conflict-file.d.ts +1 -1
  29. package/dist/merge-conflict-file.js +1 -2
  30. package/dist/merge-conflict-file.js.map +1 -1
  31. package/dist/on-component-events.d.ts +6 -6
  32. package/dist/{preview-1703505948637.js → preview-1703647408454.js} +2 -2
  33. package/dist/scope-subcommands/scope-set.cmd.d.ts +1 -1
  34. package/dist/ui/workspace/use-workspace.d.ts +8 -8
  35. package/dist/ui/workspace/use-workspace.js +7 -18
  36. package/dist/ui/workspace/use-workspace.js.map +1 -1
  37. package/dist/ui/workspace/workspace-model.d.ts +3 -3
  38. package/dist/ui/workspace/workspace-overview/workspace-overview.d.ts +2 -2
  39. package/dist/ui/workspace/workspace-overview/workspace-overview.js +1 -2
  40. package/dist/ui/workspace/workspace-overview/workspace-overview.js.map +1 -1
  41. package/dist/ui/workspace/workspace-provider.d.ts +3 -3
  42. package/dist/ui/workspace/workspace.d.ts +3 -3
  43. package/dist/workspace-aspects-loader.d.ts +3 -3
  44. package/dist/workspace-aspects-loader.js +7 -11
  45. package/dist/workspace-aspects-loader.js.map +1 -1
  46. package/dist/workspace-component/comp-files.d.ts +3 -3
  47. package/dist/workspace-component/component-status.d.ts +3 -3
  48. package/dist/workspace-component/workspace-component-loader.d.ts +5 -5
  49. package/dist/workspace-component/workspace-component-loader.js +31 -28
  50. package/dist/workspace-component/workspace-component-loader.js.map +1 -1
  51. package/dist/workspace.composition.d.ts +2 -2
  52. package/dist/workspace.d.ts +6 -6
  53. package/dist/workspace.graphql.d.ts +2 -2
  54. package/dist/workspace.graphql.js +2 -4
  55. package/dist/workspace.graphql.js.map +1 -1
  56. package/dist/workspace.js +16 -23
  57. package/dist/workspace.js.map +1 -1
  58. package/dist/workspace.provider.d.ts +12 -12
  59. package/dist/workspace.provider.js +8 -11
  60. package/dist/workspace.provider.js.map +1 -1
  61. package/dist/workspace.ui.drawer.d.ts +1 -1
  62. package/dist/workspace.ui.drawer.js +5 -6
  63. package/dist/workspace.ui.drawer.js.map +1 -1
  64. package/dist/workspace.ui.runtime.d.ts +1 -1
  65. package/dist/workspace.ui.runtime.js +2 -8
  66. package/dist/workspace.ui.runtime.js.map +1 -1
  67. package/eject-conf.cmd.ts +57 -0
  68. package/filter.ts +139 -0
  69. package/index.ts +22 -0
  70. package/merge-conflict-file.ts +129 -0
  71. package/on-component-events.ts +24 -0
  72. package/package.json +39 -46
  73. package/pattern.cmd.ts +53 -0
  74. package/tsconfig.json +16 -21
  75. package/types/asset.d.ts +15 -3
  76. package/types.ts +71 -0
  77. package/use.cmd.ts +25 -0
  78. package/workspace-aspects-loader.ts +885 -0
  79. package/workspace-component/workspace-component-loader.ts +25 -16
  80. package/workspace-section.ts +14 -0
  81. package/workspace.aspect.ts +9 -0
  82. package/workspace.graphql.ts +133 -0
  83. package/workspace.main.runtime.ts +56 -0
  84. package/workspace.provider.ts +282 -0
  85. package/workspace.ts +2014 -0
  86. package/workspace.ui-root.ts +65 -0
package/filter.ts ADDED
@@ -0,0 +1,139 @@
1
+ import { ComponentID, ComponentIdList } from '@teambit/component-id';
2
+ import pMapSeries from 'p-map-series';
3
+ import { ModelComponent } from '@teambit/legacy/dist/scope/models';
4
+ import { compact } from 'lodash';
5
+ import { Workspace } from './workspace';
6
+
7
+ export const statesFilter = [
8
+ 'new',
9
+ 'modified',
10
+ 'deprecated',
11
+ 'deleted',
12
+ 'snappedOnMain',
13
+ 'softTagged',
14
+ 'codeModified',
15
+ ] as const;
16
+ export type StatesFilter = typeof statesFilter[number];
17
+
18
+ export class Filter {
19
+ constructor(private workspace: Workspace) {}
20
+
21
+ async by(criteria: StatesFilter | string, ids: ComponentID[]): Promise<ComponentID[]> {
22
+ return criteria.includes(':') ? this.byMultiParamState(criteria, ids) : this.byState(criteria as StatesFilter, ids);
23
+ }
24
+
25
+ async byState(state: StatesFilter, ids: ComponentID[]): Promise<ComponentID[]> {
26
+ const statePerMethod = {
27
+ new: this.byNew,
28
+ modified: this.byModified,
29
+ deprecated: this.byDeprecated,
30
+ deleted: this.byDeleted,
31
+ snappedOnMain: this.bySnappedOnMain,
32
+ softTagged: this.bySoftTagged,
33
+ codeModified: this.byCodeModified,
34
+ };
35
+ if (!statePerMethod[state]) {
36
+ throw new Error(`state ${state} is not recognized, possible values: ${statesFilter.join(', ')}`);
37
+ }
38
+ return statePerMethod[state].bind(this)(ids);
39
+ }
40
+
41
+ async byMultiParamState(state: string, ids: ComponentID[]): Promise<ComponentID[]> {
42
+ const stateSplit = state.split(':');
43
+ if (stateSplit.length < 2) {
44
+ throw new Error(`byMultiParamState expect the state to have at least one param after the colon, got ${state}`);
45
+ }
46
+ const [stateName, ...stateParams] = stateSplit;
47
+ if (stateName === 'env') {
48
+ return this.byEnv(stateParams[0], ids);
49
+ }
50
+ throw new Error(`byMultiParamState expect the state to be one of the following: ['env'], got ${stateName}`);
51
+ }
52
+
53
+ async byEnv(env: string, withinIds?: ComponentID[]): Promise<ComponentID[]> {
54
+ const ids = withinIds || (await this.workspace.listIds());
55
+ const comps = await this.workspace.getMany(ids);
56
+ const compsUsingEnv = comps.filter((c) => {
57
+ const envId = this.workspace.envs.getEnvId(c);
58
+ const envIdWithoutVer = ComponentID.getStringWithoutVersion(envId);
59
+ return envIdWithoutVer === env;
60
+ });
61
+ return compsUsingEnv.map((c) => c.id);
62
+ }
63
+
64
+ async byModified(withinIds?: ComponentID[]): Promise<ComponentID[]> {
65
+ const ids = withinIds || (await this.workspace.listIds());
66
+ const comps = await this.workspace.getMany(ids);
67
+ const modifiedIds = await Promise.all(comps.map(async (comp) => ((await comp.isModified()) ? comp.id : undefined)));
68
+ return compact(modifiedIds);
69
+ }
70
+
71
+ async byCodeModified(withinIds?: ComponentID[]): Promise<ComponentID[]> {
72
+ const ids = withinIds || (await this.workspace.listIds());
73
+ const compFiles = await pMapSeries(ids, (id) => this.workspace.getFilesModification(id));
74
+ const modifiedIds = compFiles.filter((c) => c.isModified()).map((c) => c.id);
75
+ return compact(modifiedIds);
76
+ }
77
+
78
+ async byNew(withinIds?: ComponentID[]): Promise<ComponentID[]> {
79
+ const ids = withinIds || (await this.workspace.listIds());
80
+ return ids.filter((id) => !id.hasVersion());
81
+ }
82
+
83
+ async byDeprecated(withinIds?: ComponentID[]) {
84
+ const ids = withinIds || (await this.workspace.listIds());
85
+ const comps = await this.workspace.getMany(ids);
86
+ const results = await Promise.all(
87
+ comps.map(async (c) => {
88
+ const modelComponent = await this.workspace.consumer.scope.getModelComponentIfExist(c.id);
89
+ const deprecated = await modelComponent?.isDeprecated(this.workspace.consumer.scope.objects);
90
+ return deprecated ? c.id : null;
91
+ })
92
+ );
93
+ return compact(results);
94
+ }
95
+
96
+ async byDeleted(withinIds?: ComponentID[]) {
97
+ const ids = withinIds || (await this.workspace.listIds());
98
+ const comps = await this.workspace.getMany(ids);
99
+ const deletedIds = comps.filter((c) => c.isDeleted()).map((c) => c.id);
100
+ return compact(deletedIds);
101
+ }
102
+
103
+ byDuringMergeState(): ComponentIdList {
104
+ const unmergedComponents = this.workspace.scope.legacyScope.objects.unmergedComponents.getComponents();
105
+ return ComponentIdList.fromArray(unmergedComponents.map((u) => ComponentID.fromObject(u.id)));
106
+ }
107
+
108
+ /**
109
+ * list components that their head is a snap, not a tag.
110
+ * this is relevant only when the lane is the default (main), otherwise, the head is always a snap.
111
+ * components that are during-merge are filtered out, we don't want them during tag and don't want
112
+ * to show them in the "snapped" section in bit-status.
113
+ */
114
+ async bySnappedOnMain(withinIds?: ComponentID[]) {
115
+ if (!this.workspace.isOnMain()) {
116
+ return [];
117
+ }
118
+ const ids = withinIds || (await this.workspace.listIds());
119
+ const compIds = ComponentIdList.fromArray(ids);
120
+ const componentsFromModel = await this.getModelComps(ids);
121
+ const compsDuringMerge = this.byDuringMergeState();
122
+ const comps = componentsFromModel
123
+ .filter((c) => compIds.hasWithoutVersion(c.toComponentId()))
124
+ .filter((c) => !compsDuringMerge.hasWithoutVersion(c.toComponentId()))
125
+ .filter((c) => c.isHeadSnap());
126
+ return comps.map((c) => c.toComponentIdWithHead());
127
+ }
128
+
129
+ bySoftTagged(withinIds?: ComponentID[]): ComponentID[] {
130
+ const withCompIds = ComponentIdList.fromArray(withinIds || []);
131
+ const all = this.workspace.consumer.bitMap.components.filter((c) => c.nextVersion).map((c) => c.id);
132
+ return withinIds ? all.filter((id) => withCompIds.hasWithoutVersion(id)) : all;
133
+ }
134
+
135
+ private async getModelComps(ids: ComponentID[]): Promise<ModelComponent[]> {
136
+ const comps = await Promise.all(ids.map((id) => this.workspace.scope.getBitObjectModelComponent(id, false)));
137
+ return compact(comps);
138
+ }
139
+ }
package/index.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { WorkspaceAspect } from './workspace.aspect';
2
+ // eslint-disable-next-line import/prefer-default-export
3
+ export type { default as Workspace, ExtensionsOrigin } from './workspace';
4
+ // TODO: change to module path once track the utils folder
5
+ export type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';
6
+ export type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';
7
+ export type { WorkspaceMain } from './workspace.main.runtime';
8
+ export * from './events';
9
+ export type { WorkspaceUI } from './workspace.ui.runtime';
10
+ export type { SerializableResults, OnComponentLoad, OnComponentEventResult } from './on-component-events';
11
+ export { ComponentStatus } from './workspace-component';
12
+ export type { WorkspaceModelComponent } from './ui/workspace/workspace-model';
13
+ export { Workspace as WorkspaceModel } from './ui/workspace/workspace-model';
14
+ export { WorkspaceContext } from './ui/workspace/workspace-context';
15
+ export { OutsideWorkspaceError } from './exceptions/outside-workspace';
16
+ export type { WorkspaceComponent } from './workspace-component';
17
+ export type { ComponentConfigFile } from './component-config-file';
18
+ export type { CompFiles, FilesStatus } from './workspace-component/comp-files';
19
+ export type { MergeOptions as BitmapMergeOptions } from './bit-map';
20
+ export type { WorkspaceExtConfig } from './types';
21
+ export { WorkspaceAspect };
22
+ export default WorkspaceAspect;
@@ -0,0 +1,129 @@
1
+ import { MergeConfigFilename } from '@teambit/legacy/dist/constants';
2
+ import path from 'path';
3
+ import fs from 'fs-extra';
4
+ import { MergeConfigConflict } from './exceptions/merge-config-conflict';
5
+
6
+ const idPrefix = `[*]`;
7
+ const idDivider = '-'.repeat(80);
8
+ type ConflictPerId = { [compIdWithoutVersion: string]: string };
9
+
10
+ export class MergeConflictFile {
11
+ conflictPerId: ConflictPerId | undefined;
12
+ constructor(private workspacePath: string) {}
13
+
14
+ addConflict(id: string, conflict: string) {
15
+ if (!this.conflictPerId) this.conflictPerId = {};
16
+ this.conflictPerId[id] = conflict;
17
+ }
18
+
19
+ removeConflict(id: string) {
20
+ delete this.conflictPerId?.[id];
21
+ }
22
+
23
+ async getConflict(id: string): Promise<string | undefined> {
24
+ await this.loadIfNeeded();
25
+ if (!this.conflictPerId) throw new Error(`this.conflictPerId must be instantiated after load`);
26
+ return this.conflictPerId[id];
27
+ }
28
+
29
+ getConflictAssumeIsLoaded(id: string): string | undefined {
30
+ if (!this.conflictPerId)
31
+ throw new Error(`MergeConflictFile was not loaded yet, please load it before calling this function`);
32
+ return this.conflictPerId[id];
33
+ }
34
+
35
+ getConflictParsed(id: string): Record<string, any> | undefined {
36
+ const configMergeContent = this.getConflictAssumeIsLoaded(id);
37
+ if (!configMergeContent) return undefined;
38
+ try {
39
+ return JSON.parse(configMergeContent);
40
+ } catch (err: any) {
41
+ if (this.stringHasConflictMarker(configMergeContent)) {
42
+ throw new MergeConfigConflict(this.getPath());
43
+ }
44
+ throw new Error(`unable to parse the merge-conflict entry for ${id} as the JSON is invalid. err: ${err.message}`);
45
+ }
46
+ }
47
+
48
+ hasConflict(): boolean {
49
+ return Boolean(this.conflictPerId && Object.keys(this.conflictPerId).length);
50
+ }
51
+
52
+ getPath() {
53
+ return path.join(this.workspacePath, MergeConfigFilename);
54
+ }
55
+
56
+ async loadIfNeeded() {
57
+ if (this.conflictPerId) return; // already loaded
58
+ const fileContent = await this.getFileContentIfExists();
59
+ if (!fileContent) {
60
+ this.conflictPerId = {}; // to indicate that it's loaded
61
+ return;
62
+ }
63
+ const parsedConflict = this.parseConflict(fileContent);
64
+ this.conflictPerId = parsedConflict;
65
+ }
66
+
67
+ async write() {
68
+ if (!this.hasConflict()) return;
69
+ const afterFormat = this.formatConflicts();
70
+ await fs.writeFile(this.getPath(), afterFormat);
71
+ }
72
+
73
+ async delete() {
74
+ await fs.remove(this.getPath());
75
+ }
76
+
77
+ private formatConflicts(): string {
78
+ const conflictPerId = this.conflictPerId;
79
+ if (!conflictPerId) throw new Error('conflictPerId is not populated');
80
+ const title = `# Resolve configuration conflicts per component and make sure the Component ID remain in place`;
81
+ const conflicts = Object.keys(conflictPerId)
82
+ .map((id) => {
83
+ const conflict = conflictPerId[id];
84
+ return `${idDivider}
85
+ ${idPrefix} ${id}
86
+ ${idDivider}
87
+ ${conflict}`;
88
+ })
89
+ .join('\n\n');
90
+ return `${title}\n\n${conflicts}`;
91
+ }
92
+
93
+ private stringHasConflictMarker(str: string): boolean {
94
+ return str.includes('<<<<<<<') || str.includes('>>>>>>>');
95
+ }
96
+
97
+ private parseConflict(conflict: string): ConflictPerId {
98
+ // remove irrelevant lines
99
+ conflict = conflict
100
+ .split('\n')
101
+ .filter((line) => line !== idDivider && !line.startsWith('#'))
102
+ .join('\n');
103
+ // split by id
104
+ const conflictPerId: ConflictPerId = {};
105
+ const split = conflict.split(idPrefix);
106
+ split.forEach((conflictItem) => {
107
+ const conflictItemSplit = conflictItem.split('\n');
108
+ const [rawId, ...conflictStr] = conflictItemSplit;
109
+ const id = rawId.trim();
110
+ if (!id) return; // first line has it empty
111
+ conflictPerId[id] = conflictStr.join('\n');
112
+ });
113
+ return conflictPerId;
114
+ }
115
+
116
+ private async getFileContentIfExists(): Promise<string | undefined> {
117
+ const filePath = this.getPath();
118
+ let fileContent: string;
119
+ try {
120
+ fileContent = await fs.readFile(filePath, 'utf-8');
121
+ } catch (err: any) {
122
+ if (err.code === 'ENOENT') {
123
+ return undefined;
124
+ }
125
+ throw err;
126
+ }
127
+ return fileContent;
128
+ }
129
+ }
@@ -0,0 +1,24 @@
1
+ import { Component, ComponentID, AspectData } from '@teambit/component';
2
+ import { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';
3
+ import type { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
4
+ import { WatchOptions } from '@teambit/watcher';
5
+
6
+ export type SerializableResults = { results: any; toString: () => string };
7
+ export type OnComponentChange = (
8
+ component: Component,
9
+ files: PathOsBasedAbsolute[],
10
+ removedFiles: PathOsBasedAbsolute[],
11
+ watchOpts: WatchOptions
12
+ ) => Promise<SerializableResults | void>;
13
+ export type OnComponentAdd = (
14
+ component: Component,
15
+ files: string[],
16
+ watchOpts: WatchOptions
17
+ ) => Promise<SerializableResults | void>;
18
+ export type OnComponentRemove = (componentId: ComponentID) => Promise<SerializableResults>;
19
+ export type OnComponentEventResult = { extensionId: string; results: SerializableResults };
20
+
21
+ export type OnComponentLoad = (
22
+ component: Component,
23
+ loadOpts?: ComponentLoadOptions
24
+ ) => Promise<AspectData | undefined>;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/workspace",
3
- "version": "1.0.106",
3
+ "version": "1.0.108",
4
4
  "homepage": "https://bit.cloud/teambit/workspace/workspace",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.workspace",
8
8
  "name": "workspace",
9
- "version": "1.0.106"
9
+ "version": "1.0.108"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -25,8 +25,6 @@
25
25
  "classnames": "2.2.6",
26
26
  "pluralize": "8.0.0",
27
27
  "reset-css": "5.0.1",
28
- "core-js": "^3.0.0",
29
- "@babel/runtime": "7.20.0",
30
28
  "@teambit/component-id": "1.2.0",
31
29
  "@teambit/harmony": "0.4.6",
32
30
  "@teambit/bit-error": "0.0.404",
@@ -34,8 +32,8 @@
34
32
  "@teambit/graph.cleargraph": "0.0.1",
35
33
  "@teambit/component.ui.component-status-resolver": "0.0.510",
36
34
  "@teambit/component-version": "1.0.3",
37
- "@teambit/dependencies.modules.packages-excluder": "1.0.8",
38
35
  "@teambit/legacy-bit-id": "1.1.0",
36
+ "@teambit/dependencies.modules.packages-excluder": "1.0.8",
39
37
  "@teambit/design.ui.tree": "0.0.15",
40
38
  "@teambit/lanes.hooks.use-lane-components": "0.0.253",
41
39
  "@teambit/lanes.hooks.use-lanes": "0.0.254",
@@ -61,58 +59,56 @@
61
59
  "@teambit/explorer.ui.gallery.component-grid": "0.0.496",
62
60
  "@teambit/workspace.ui.empty-workspace": "0.0.508",
63
61
  "@teambit/workspace.ui.workspace-component-card": "0.0.516",
64
- "@teambit/component": "1.0.106",
65
- "@teambit/dependency-resolver": "1.0.106",
66
- "@teambit/envs": "1.0.106",
67
- "@teambit/logger": "0.0.932",
68
- "@teambit/scope": "1.0.106",
69
- "@teambit/graph": "1.0.106",
70
- "@teambit/cli": "0.0.839",
71
- "@teambit/isolator": "1.0.106",
72
- "@teambit/component-tree": "1.0.106",
62
+ "@teambit/component": "1.0.108",
63
+ "@teambit/dependency-resolver": "1.0.108",
64
+ "@teambit/envs": "1.0.108",
65
+ "@teambit/logger": "0.0.933",
66
+ "@teambit/scope": "1.0.108",
67
+ "@teambit/graph": "1.0.108",
68
+ "@teambit/cli": "0.0.840",
69
+ "@teambit/isolator": "1.0.108",
70
+ "@teambit/component-tree": "1.0.108",
73
71
  "@teambit/harmony.modules.resolved-component": "0.0.495",
74
- "@teambit/watcher": "1.0.106",
75
- "@teambit/aspect-loader": "1.0.106",
76
- "@teambit/config": "0.0.857",
77
- "@teambit/global-config": "0.0.841",
72
+ "@teambit/watcher": "1.0.108",
73
+ "@teambit/aspect-loader": "1.0.108",
74
+ "@teambit/config": "0.0.859",
75
+ "@teambit/global-config": "0.0.842",
78
76
  "@teambit/harmony.modules.requireable-component": "0.0.495",
79
77
  "@teambit/toolbox.modules.module-resolver": "0.0.5",
80
- "@teambit/workspace.modules.node-modules-linker": "0.0.157",
81
- "@teambit/graphql": "1.0.106",
82
- "@teambit/bundler": "1.0.106",
83
- "@teambit/pubsub": "1.0.106",
84
- "@teambit/ui": "1.0.106",
85
- "@teambit/variants": "0.0.950",
86
- "@teambit/component-issues": "0.0.137",
78
+ "@teambit/workspace.modules.node-modules-linker": "0.0.158",
79
+ "@teambit/graphql": "1.0.108",
80
+ "@teambit/bundler": "1.0.108",
81
+ "@teambit/pubsub": "1.0.108",
82
+ "@teambit/ui": "1.0.108",
83
+ "@teambit/variants": "0.0.952",
84
+ "@teambit/component-issues": "0.0.138",
87
85
  "@teambit/workspace.modules.match-pattern": "0.0.502",
88
- "@teambit/component.ui.component-drawer": "0.0.380",
89
- "@teambit/command-bar": "1.0.106",
90
- "@teambit/sidebar": "1.0.106",
91
- "@teambit/component-descriptor": "0.0.407",
92
- "@teambit/deprecation": "1.0.106"
86
+ "@teambit/component.ui.component-drawer": "0.0.381",
87
+ "@teambit/command-bar": "1.0.108",
88
+ "@teambit/sidebar": "1.0.108",
89
+ "@teambit/component-descriptor": "0.0.408",
90
+ "@teambit/deprecation": "1.0.108"
93
91
  },
94
92
  "devDependencies": {
95
93
  "@types/lodash": "4.14.165",
96
94
  "@types/lodash.compact": "3.0.6",
97
- "@types/react": "^17.0.8",
98
95
  "@types/fs-extra": "9.0.7",
99
96
  "@types/find-root": "1.1.2",
100
97
  "@types/memoizee": "0.4.5",
101
98
  "@types/classnames": "2.2.11",
102
99
  "@types/pluralize": "0.0.29",
103
100
  "@types/mocha": "9.1.0",
104
- "@types/node": "12.20.4",
105
- "@types/react-dom": "^17.0.5",
106
- "@types/jest": "^26.0.0",
107
- "@types/testing-library__jest-dom": "5.9.5",
108
- "@teambit/workspace.content.workspace-overview": "1.95.0"
101
+ "@types/jest": "^29.2.2",
102
+ "@types/testing-library__jest-dom": "^5.9.5",
103
+ "@teambit/workspace.content.workspace-overview": "1.95.0",
104
+ "@teambit/harmony.envs.core-aspect-env": "0.0.13"
109
105
  },
110
106
  "peerDependencies": {
111
107
  "@apollo/client": "^3.6.0",
112
- "react-router-dom": "^6.0.0",
113
- "@teambit/legacy": "1.0.624",
114
- "react": "^16.8.0 || ^17.0.0",
115
- "react-dom": "^16.8.0 || ^17.0.0"
108
+ "react": "^17.0.0 || ^18.0.0",
109
+ "react-router-dom": "^6.8.1",
110
+ "@types/react": "^18.2.12",
111
+ "@teambit/legacy": "1.0.624"
116
112
  },
117
113
  "license": "Apache-2.0",
118
114
  "optionalDependencies": {},
@@ -126,7 +122,7 @@
126
122
  },
127
123
  "private": false,
128
124
  "engines": {
129
- "node": ">=12.22.0"
125
+ "node": ">=16.0.0"
130
126
  },
131
127
  "repository": {
132
128
  "type": "git",
@@ -135,12 +131,9 @@
135
131
  "keywords": [
136
132
  "bit",
137
133
  "bit-aspect",
134
+ "bit-core-aspect",
138
135
  "components",
139
136
  "collaboration",
140
- "web",
141
- "react",
142
- "react-components",
143
- "angular",
144
- "angular-components"
137
+ "web"
145
138
  ]
146
139
  }
package/pattern.cmd.ts ADDED
@@ -0,0 +1,53 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import chalk from 'chalk';
3
+ import { Workspace } from './workspace';
4
+ import { statesFilter } from './filter';
5
+
6
+ export class PatternCommand implements Command {
7
+ name = 'pattern <pattern>';
8
+ alias = '';
9
+ description = 'list the component ids matching the given pattern';
10
+ extendedDescription = `this command helps validating a pattern before using it in other commands.
11
+ NOTE: always wrap the pattern with quotes to avoid collision with shell commands. depending on your shell, it might be single or double quotes.
12
+ a pattern can be a simple component-id or component-name. e.g. 'ui/button'.
13
+ a pattern can be used with wildcards for multiple component ids, e.g. 'org.scope/utils/**' or '**/utils/**' to capture all org/scopes.
14
+ to enter multiple patterns, separate them by a comma, e.g. 'ui/*, lib/*'
15
+ to exclude, use '!'. e.g. 'ui/**, !ui/button'
16
+ the matching algorithm is from multimatch (@see https://github.com/sindresorhus/multimatch).
17
+
18
+ to filter by a state or attribute, prefix the pattern with "$". e.g. '$deprecated', '$modified'.
19
+ list of supported states: [${statesFilter.join(', ')}].
20
+ to filter by multi-params state/attribute, separate the params with ":", e.g. '$env:teambit.react/react'.
21
+ list of supported multi-params states: [env].
22
+ to match a state and another criteria, use " AND " keyword. e.g. '$modified AND teambit.workspace/**'. note that the state must be first.
23
+ `;
24
+ examples = [
25
+ { cmd: "bit pattern '**'", description: 'matches all components' },
26
+ {
27
+ cmd: "bit pattern '*/ui/*'",
28
+ description:
29
+ 'matches components with any scope-name and the "ui" namespace. e.g. "ui/button" but not "ui/elements/button"',
30
+ },
31
+ {
32
+ cmd: "bit pattern '*/ui/**'",
33
+ description: 'matches components whose namespace starts with "ui/" e.g. "ui/button", "ui/elements/button"',
34
+ },
35
+ { cmd: "bit pattern 'bar, foo'", description: 'matches two components: bar and foo' },
36
+ { cmd: "bit pattern 'my-scope.org/**'", description: 'matches all components of the scope "my-scope.org"' },
37
+ ];
38
+ group = 'development';
39
+ private = false;
40
+ options = [['j', 'json', 'return the output as JSON']] as CommandOptions;
41
+
42
+ constructor(private workspace: Workspace) {}
43
+
44
+ async report([pattern]: [string]) {
45
+ const ids = await this.json([pattern]);
46
+ const title = chalk.green(`found ${chalk.bold(ids.length.toString())} components matching the pattern`);
47
+ return `${title}\n${ids.join('\n')}`;
48
+ }
49
+
50
+ async json([pattern]: [string]) {
51
+ return this.workspace.idsByPattern(pattern, false);
52
+ }
53
+ }
package/tsconfig.json CHANGED
@@ -1,38 +1,33 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "lib": [
4
- "es2019",
5
- "DOM",
6
- "ES6",
7
- "DOM.Iterable",
8
- "ScriptHost"
4
+ "esnext",
5
+ "dom",
6
+ "dom.Iterable"
9
7
  ],
10
- "target": "es2015",
11
- "module": "CommonJS",
12
- "jsx": "react",
13
- "allowJs": true,
14
- "composite": true,
8
+ "target": "es2020",
9
+ "module": "es2020",
10
+ "jsx": "react-jsx",
15
11
  "declaration": true,
16
12
  "sourceMap": true,
17
- "skipLibCheck": true,
18
13
  "experimentalDecorators": true,
19
- "outDir": "dist",
14
+ "skipLibCheck": true,
20
15
  "moduleResolution": "node",
21
16
  "esModuleInterop": true,
22
- "rootDir": ".",
23
17
  "resolveJsonModule": true,
24
- "emitDeclarationOnly": true,
25
- "emitDecoratorMetadata": true,
26
- "allowSyntheticDefaultImports": true,
27
- "strictPropertyInitialization": false,
28
- "strict": true,
29
- "noImplicitAny": false,
30
- "preserveConstEnums": true
18
+ "allowJs": true,
19
+ "outDir": "dist",
20
+ "emitDeclarationOnly": true
31
21
  },
32
22
  "exclude": [
23
+ "artifacts",
24
+ "public",
33
25
  "dist",
26
+ "node_modules",
27
+ "package.json",
34
28
  "esm.mjs",
35
- "package.json"
29
+ "**/*.cjs",
30
+ "./dist"
36
31
  ],
37
32
  "include": [
38
33
  "**/*",
package/types/asset.d.ts CHANGED
@@ -5,12 +5,12 @@ declare module '*.png' {
5
5
  declare module '*.svg' {
6
6
  import type { FunctionComponent, SVGProps } from 'react';
7
7
 
8
- export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
9
11
  const src: string;
10
12
  export default src;
11
13
  }
12
-
13
- // @TODO Gilad
14
14
  declare module '*.jpg' {
15
15
  const value: any;
16
16
  export = value;
@@ -27,3 +27,15 @@ declare module '*.bmp' {
27
27
  const value: any;
28
28
  export = value;
29
29
  }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }