@teambit/workspace 0.0.551 → 0.0.556

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 (87) hide show
  1. package/dist/build-graph-from-fs.d.ts +30 -0
  2. package/dist/install.cmd.d.ts +17 -3
  3. package/dist/install.cmd.js.map +1 -1
  4. package/dist/link/link.cmd.d.ts +15 -1
  5. package/dist/types.d.ts +21 -0
  6. package/dist/ui/workspace/workspace-model.d.ts +32 -1
  7. package/dist/ui/workspace/workspace-provider.d.ts +9 -0
  8. package/dist/ui/workspace/workspace.d.ts +3 -0
  9. package/dist/watch/output-formatter.d.ts +6 -0
  10. package/dist/watch/watch.cmd.d.ts +22 -1
  11. package/dist/watch/watcher.d.ts +9 -0
  12. package/dist/workspace-component/component-status.d.ts +57 -1
  13. package/dist/workspace-component/workspace-component-loader.d.ts +7 -0
  14. package/dist/workspace-component/workspace-component.d.ts +36 -1
  15. package/dist/workspace.d.ts +236 -3
  16. package/dist/workspace.js +37 -5
  17. package/dist/workspace.js.map +1 -1
  18. package/dist/workspace.ui-root.d.ts +18 -1
  19. package/dist/workspace.ui.runtime.d.ts +32 -1
  20. package/package.json +58 -50
  21. package/build-graph-from-fs.ts +0 -160
  22. package/capsule.cmd.ts +0 -136
  23. package/component-config-file/component-config-file.ts +0 -98
  24. package/component-config-file/exceptions/already-exists.ts +0 -7
  25. package/component-config-file/exceptions/index.ts +0 -1
  26. package/component-config-file/index.ts +0 -2
  27. package/component-tree.widget.tsx +0 -16
  28. package/constants.ts +0 -1
  29. package/eject-conf.cmd.tsx +0 -62
  30. package/events/index.ts +0 -3
  31. package/events/on-component-add-event.ts +0 -14
  32. package/events/on-component-change-event.ts +0 -14
  33. package/events/on-component-removed-event.ts +0 -14
  34. package/exceptions/dependency-type-not-supported-in-policy.ts +0 -7
  35. package/exceptions/incorrect-env-aspect.ts +0 -8
  36. package/exceptions/index.ts +0 -1
  37. package/index.ts +0 -19
  38. package/install.cmd.tsx +0 -67
  39. package/link/component-list-links.ts +0 -50
  40. package/link/core-aspects-links.ts +0 -50
  41. package/link/get-package-name-from-target.ts +0 -5
  42. package/link/index.ts +0 -1
  43. package/link/link-row.ts +0 -20
  44. package/link/link-to-dir.ts +0 -13
  45. package/link/link.cmd.ts +0 -96
  46. package/link/nested-deps-in-nm-links.ts +0 -47
  47. package/link/rewire-row.ts +0 -17
  48. package/list.cmd.tsx +0 -30
  49. package/on-component-events.ts +0 -14
  50. package/package-tar/teambit-workspace-0.0.551.tgz +0 -0
  51. package/tag-cmd.ts +0 -247
  52. package/tsconfig.json +0 -35
  53. package/types/asset.d.ts +0 -29
  54. package/types/style.d.ts +0 -42
  55. package/types.ts +0 -40
  56. package/ui/index.ts +0 -1
  57. package/ui/workspace/default-component.ts +0 -7
  58. package/ui/workspace/index.ts +0 -1
  59. package/ui/workspace/use-workspace.ts +0 -193
  60. package/ui/workspace/workspace-context.tsx +0 -5
  61. package/ui/workspace/workspace-model.ts +0 -66
  62. package/ui/workspace/workspace-overview/index.ts +0 -1
  63. package/ui/workspace/workspace-overview/workspace-overview.module.scss +0 -6
  64. package/ui/workspace/workspace-overview/workspace-overview.tsx +0 -21
  65. package/ui/workspace/workspace-provider.tsx +0 -23
  66. package/ui/workspace/workspace.module.scss +0 -40
  67. package/ui/workspace/workspace.tsx +0 -99
  68. package/ui/workspace-components-drawer/index.ts +0 -1
  69. package/ui/workspace-components-drawer/workspace-components-drawer.module.scss +0 -4
  70. package/ui/workspace-components-drawer/workspace-components.drawer.tsx +0 -49
  71. package/watch/REFACTOR_GUIDE.md +0 -14
  72. package/watch/check-types.ts +0 -5
  73. package/watch/output-formatter.ts +0 -50
  74. package/watch/watch.cmd.tsx +0 -142
  75. package/watch/watcher.ts +0 -289
  76. package/workspace-component/component-status.ts +0 -67
  77. package/workspace-component/index.ts +0 -2
  78. package/workspace-component/workspace-component-loader.ts +0 -276
  79. package/workspace-component/workspace-component.ts +0 -51
  80. package/workspace-section.ts +0 -14
  81. package/workspace.aspect.ts +0 -9
  82. package/workspace.graphql.ts +0 -133
  83. package/workspace.main.runtime.ts +0 -50
  84. package/workspace.provider.ts +0 -218
  85. package/workspace.ts +0 -1517
  86. package/workspace.ui-root.ts +0 -64
  87. package/workspace.ui.runtime.tsx +0 -215
@@ -1,14 +0,0 @@
1
- // export class WorkspaceSection {
2
- // constructor(
3
- // readonly route: string
4
- // ) {}
5
-
6
- // toRoute() {
7
- // return {
8
- // path: this.toRoute
9
- // children:
10
- // };
11
- // }
12
- // };
13
-
14
- // export interface WorkspaceSection {}
@@ -1,9 +0,0 @@
1
- import { Aspect } from '@teambit/harmony';
2
-
3
- export const WorkspaceAspect = Aspect.create({
4
- id: 'teambit.workspace/workspace',
5
- dependencies: [],
6
- defaultConfig: {},
7
- });
8
-
9
- export default WorkspaceAspect;
@@ -1,133 +0,0 @@
1
- import { GraphqlMain } from '@teambit/graphql';
2
- import gql from 'graphql-tag';
3
-
4
- import { ComponentAdded, ComponentChanged, ComponentRemoved, Workspace } from './workspace';
5
- import { WorkspaceComponent } from './workspace-component';
6
-
7
- export default (workspace: Workspace, graphql: GraphqlMain) => {
8
- return {
9
- typeDefs: gql`
10
- type ModifyInfo {
11
- # is the component modified.
12
- hasModifiedFiles: Boolean
13
-
14
- # the component has Modified Dependencies
15
- hasModifiedDependencies: Boolean
16
- }
17
-
18
- type ComponentStatus {
19
- # component is pending to be tagged automatically.
20
- modifyInfo: ModifyInfo
21
-
22
- # is the new component new.
23
- isNew: Boolean
24
-
25
- # is the component deleted from the workspace.
26
- isDeleted: Boolean
27
-
28
- # is the component staged.
29
- isStaged: Boolean
30
-
31
- # does the component exists in the workspace.
32
- isInWorkspace: Boolean
33
-
34
- # does the component exists in the scope.
35
- isInScope: Boolean
36
-
37
- # does the component is outdated (pending for update).
38
- isOutdated: Boolean
39
- }
40
-
41
- extend type Component {
42
- status: ComponentStatus
43
- }
44
-
45
- type Issue {
46
- type: String!
47
- description: String!
48
- solution: String
49
- data: String
50
- }
51
-
52
- extend type Component {
53
- # the count of errors in component in workspace
54
- issuesCount: Int
55
- issues: [Issue]
56
- }
57
-
58
- type Workspace {
59
- name: String
60
- path: String
61
- icon: String
62
- components(offset: Int, limit: Int): [Component]
63
- getComponent(id: String!): Component
64
- }
65
-
66
- type Subscription {
67
- componentAdded: ComponentAdded
68
- componentChanged: ComponentChanged
69
- componentRemoved: ComponentRemoved
70
- }
71
-
72
- type ComponentAdded {
73
- component: Component
74
- }
75
-
76
- type ComponentChanged {
77
- component: Component
78
- }
79
-
80
- type ComponentRemoved {
81
- componentIds: [ComponentID]
82
- }
83
-
84
- type Query {
85
- workspace: Workspace
86
- }
87
- `,
88
- resolvers: {
89
- Subscription: {
90
- componentAdded: {
91
- subscribe: () => graphql.pubsub.asyncIterator(ComponentAdded),
92
- },
93
- componentChanged: {
94
- subscribe: () => graphql.pubsub.asyncIterator(ComponentChanged),
95
- },
96
- componentRemoved: {
97
- subscribe: () => graphql.pubsub.asyncIterator(ComponentRemoved),
98
- },
99
- },
100
- Component: {
101
- status: async (wsComponent: WorkspaceComponent) => {
102
- return wsComponent.getStatus();
103
- },
104
- issuesCount: (wsComponent: WorkspaceComponent): number => {
105
- return wsComponent.getIssues()?.count || 0;
106
- },
107
- issues: (wsComponent: WorkspaceComponent) => {
108
- return wsComponent.getIssues()?.toObjectWithDataAsString();
109
- },
110
- },
111
- Workspace: {
112
- path: (ws) => ws.path,
113
- name: (ws) => ws.name,
114
- icon: (ws) => ws.icon,
115
- components: async (ws: Workspace, { offset, limit }: { offset: number; limit: number }) => {
116
- return ws.list({ offset, limit });
117
- },
118
- getComponent: async (ws: Workspace, { id }: { id: string }) => {
119
- try {
120
- const componentID = await ws.resolveComponentId(id);
121
- const component = await ws.get(componentID);
122
- return component;
123
- } catch (error: any) {
124
- return null;
125
- }
126
- },
127
- },
128
- Query: {
129
- workspace: () => workspace,
130
- },
131
- },
132
- };
133
- };
@@ -1,50 +0,0 @@
1
- import { PubsubAspect } from '@teambit/pubsub';
2
- import { AspectLoaderAspect } from '@teambit/aspect-loader';
3
- import { BundlerAspect } from '@teambit/bundler';
4
- import { CLIAspect, MainRuntime } from '@teambit/cli';
5
- import { ComponentAspect } from '@teambit/component';
6
- import { DependencyResolverAspect } from '@teambit/dependency-resolver';
7
- import { EnvsAspect } from '@teambit/envs';
8
- import { GraphqlAspect } from '@teambit/graphql';
9
- import { Slot } from '@teambit/harmony';
10
- import { IsolatorAspect } from '@teambit/isolator';
11
- import { LoggerAspect } from '@teambit/logger';
12
- import { ScopeAspect } from '@teambit/scope';
13
- import { UIAspect } from '@teambit/ui';
14
- import { VariantsAspect } from '@teambit/variants';
15
-
16
- import { EXT_NAME } from './constants';
17
- import { OnComponentAdd, OnComponentChange, OnComponentRemove, OnComponentLoad } from './on-component-events';
18
- import { WorkspaceAspect } from './workspace.aspect';
19
- import workspaceProvider, { OnPreWatch } from './workspace.provider';
20
-
21
- export const WorkspaceMain = {
22
- name: EXT_NAME,
23
- runtime: MainRuntime,
24
- dependencies: [
25
- PubsubAspect,
26
- CLIAspect,
27
- ScopeAspect,
28
- ComponentAspect,
29
- IsolatorAspect,
30
- DependencyResolverAspect,
31
- VariantsAspect,
32
- LoggerAspect,
33
- GraphqlAspect,
34
- UIAspect,
35
- BundlerAspect,
36
- AspectLoaderAspect,
37
- EnvsAspect,
38
- ],
39
- slots: [
40
- Slot.withType<OnComponentLoad>(),
41
- Slot.withType<OnComponentChange>(),
42
- Slot.withType<OnComponentAdd>(),
43
- Slot.withType<OnComponentRemove>(),
44
- Slot.withType<OnPreWatch>(),
45
- ],
46
- provider: workspaceProvider,
47
- defineRuntime: 'browser',
48
- };
49
-
50
- WorkspaceAspect.addRuntime(WorkspaceMain);
@@ -1,218 +0,0 @@
1
- import { PubsubMain } from '@teambit/pubsub';
2
- import type { AspectLoaderMain } from '@teambit/aspect-loader';
3
- import { BundlerMain } from '@teambit/bundler';
4
- import { CLIMain, CommandList } from '@teambit/cli';
5
- import type { ComponentMain, Component } from '@teambit/component';
6
- import { DependencyResolverMain } from '@teambit/dependency-resolver';
7
- import { EnvsMain } from '@teambit/envs';
8
- import { GraphqlMain } from '@teambit/graphql';
9
- import { Harmony, SlotRegistry } from '@teambit/harmony';
10
- import { IsolatorMain } from '@teambit/isolator';
11
- import { LoggerMain } from '@teambit/logger';
12
- import type { ScopeMain } from '@teambit/scope';
13
- import { UiMain } from '@teambit/ui';
14
- import type { VariantsMain } from '@teambit/variants';
15
- import { Consumer, loadConsumerIfExist } from '@teambit/legacy/dist/consumer';
16
- import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
17
- import { registerDefaultScopeGetter } from '@teambit/legacy/dist/api/consumer';
18
- import { BitId } from '@teambit/legacy-bit-id';
19
- import ManyComponentsWriter from '@teambit/legacy/dist/consumer/component-ops/many-components-writer';
20
- import LegacyComponentLoader from '@teambit/legacy/dist/consumer/component/component-loader';
21
- import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
22
- import { EXT_NAME } from './constants';
23
- import EjectConfCmd from './eject-conf.cmd';
24
- import InstallCmd from './install.cmd';
25
- import { OnComponentLoad, OnComponentAdd, OnComponentChange, OnComponentRemove } from './on-component-events';
26
- import { WorkspaceExtConfig } from './types';
27
- import { WatchCommand } from './watch/watch.cmd';
28
- import { LinkCommand } from './link';
29
- import { Watcher, WatchOptions } from './watch/watcher';
30
- import { Workspace, WorkspaceInstallOptions } from './workspace';
31
- import getWorkspaceSchema from './workspace.graphql';
32
- import { WorkspaceUIRoot } from './workspace.ui-root';
33
- import { Tag } from './tag-cmd';
34
- import { CapsuleCmd, CapsuleCreateCmd, CapsuleListCmd } from './capsule.cmd';
35
-
36
- export type WorkspaceDeps = [
37
- PubsubMain,
38
- CLIMain,
39
- ScopeMain,
40
- ComponentMain,
41
- IsolatorMain,
42
- DependencyResolverMain,
43
- VariantsMain,
44
- LoggerMain,
45
- GraphqlMain,
46
- UiMain,
47
- BundlerMain,
48
- AspectLoaderMain,
49
- EnvsMain
50
- ];
51
-
52
- export type OnComponentLoadSlot = SlotRegistry<OnComponentLoad>;
53
-
54
- export type OnComponentChangeSlot = SlotRegistry<OnComponentChange>;
55
-
56
- export type OnComponentAddSlot = SlotRegistry<OnComponentAdd>;
57
-
58
- export type OnComponentRemoveSlot = SlotRegistry<OnComponentRemove>;
59
-
60
- export type OnPreWatch = (components: Component[], watchOpts: WatchOptions) => Promise<void>;
61
- export type OnPreWatchSlot = SlotRegistry<OnPreWatch>;
62
-
63
- export default async function provideWorkspace(
64
- [
65
- pubsub,
66
- cli,
67
- scope,
68
- component,
69
- isolator,
70
- dependencyResolver,
71
- variants,
72
- loggerExt,
73
- graphql,
74
- ui,
75
- bundler,
76
- aspectLoader,
77
- envs,
78
- ]: WorkspaceDeps,
79
- config: WorkspaceExtConfig,
80
- [onComponentLoadSlot, onComponentChangeSlot, onComponentAddSlot, onComponentRemoveSlot, onPreWatchSlot]: [
81
- OnComponentLoadSlot,
82
- OnComponentChangeSlot,
83
- OnComponentAddSlot,
84
- OnComponentRemoveSlot,
85
- OnPreWatchSlot
86
- ],
87
- harmony: Harmony
88
- ) {
89
- const bitConfig: any = harmony.config.get('teambit.harmony/bit');
90
- const consumer = await getConsumer(bitConfig.cwd);
91
- if (!consumer) return undefined;
92
- // TODO: get the 'workspace' name in a better way
93
- const logger = loggerExt.createLogger(EXT_NAME);
94
- const workspace = new Workspace(
95
- pubsub,
96
- config,
97
- consumer,
98
- scope,
99
- component,
100
- isolator,
101
- dependencyResolver,
102
- variants,
103
- aspectLoader,
104
- logger,
105
- undefined,
106
- harmony,
107
- onComponentLoadSlot,
108
- onComponentChangeSlot,
109
- envs,
110
- onComponentAddSlot,
111
- onComponentRemoveSlot,
112
- onPreWatchSlot,
113
- graphql
114
- );
115
-
116
- const getWorkspacePolicyFromPackageJson = () => {
117
- const packageJson = workspace.consumer.packageJson?.packageJsonObject || {};
118
- const policyFromPackageJson = dependencyResolver.getWorkspacePolicyFromPackageJson(packageJson);
119
- return policyFromPackageJson;
120
- };
121
-
122
- dependencyResolver.registerRootPolicy(getWorkspacePolicyFromPackageJson());
123
-
124
- ManyComponentsWriter.registerExternalInstaller({
125
- install: async () => {
126
- // TODO: think how we should pass this options
127
- const installOpts: WorkspaceInstallOptions = {
128
- dedupe: true,
129
- updateExisting: false,
130
- import: false,
131
- };
132
- return workspace.install(undefined, installOpts);
133
- },
134
- });
135
-
136
- consumer.onCacheClear.push(() => workspace.clearCache());
137
-
138
- if (!workspace.isLegacy) {
139
- LegacyComponentLoader.registerOnComponentLoadSubscriber(async (legacyComponent: ConsumerComponent) => {
140
- const id = await workspace.resolveComponentId(legacyComponent.id);
141
- const newComponent = await workspace.get(id, false, legacyComponent);
142
- return newComponent.state._consumer;
143
- });
144
- }
145
-
146
- ConsumerComponent.registerOnComponentConfigLoading(EXT_NAME, async (id) => {
147
- const componentId = await workspace.resolveComponentId(id);
148
- // We call here directly workspace.scope.get instead of workspace.get because part of the workspace get is loading consumer component
149
- // which in turn run this event, which will make an infinite loop
150
- // This component from scope here are only used for merging the extensions with the workspace components
151
- const componentFromScope = await workspace.scope.get(componentId);
152
- const extensions = await workspace.componentExtensions(componentId, componentFromScope);
153
- const defaultScope = await workspace.componentDefaultScope(componentId);
154
-
155
- await workspace.loadExtensions(extensions);
156
- const extensionsWithLegacyIdsP = extensions.map(async (extension) => {
157
- const legacyEntry = extension.clone();
158
- if (legacyEntry.extensionId) {
159
- const compId = await workspace.resolveComponentId(legacyEntry.extensionId);
160
- legacyEntry.extensionId = compId._legacy;
161
- legacyEntry.newExtensionId = compId;
162
- }
163
-
164
- return legacyEntry;
165
- });
166
- const extensionsWithLegacyIds = await Promise.all(extensionsWithLegacyIdsP);
167
-
168
- return {
169
- defaultScope,
170
- extensions: ExtensionDataList.fromArray(extensionsWithLegacyIds),
171
- };
172
- });
173
-
174
- /**
175
- * Add default scope from harmony during export.
176
- */
177
- registerDefaultScopeGetter(async (id: BitId) => {
178
- const componentId = await workspace.resolveComponentId(id);
179
- const defaultScope = await workspace.componentDefaultScope(componentId);
180
- return defaultScope;
181
- });
182
-
183
- const workspaceSchema = getWorkspaceSchema(workspace, graphql);
184
- ui.registerUiRoot(new WorkspaceUIRoot(workspace, bundler));
185
- graphql.register(workspaceSchema);
186
- const capsuleCmd = new CapsuleCmd();
187
- capsuleCmd.commands = [new CapsuleListCmd(isolator, workspace), new CapsuleCreateCmd(workspace, isolator)];
188
- const commands: CommandList = [new InstallCmd(workspace, logger), new EjectConfCmd(workspace), capsuleCmd];
189
- const watcher = new Watcher(workspace, pubsub);
190
- if (workspace && !workspace.consumer.isLegacy) {
191
- cli.unregister('watch');
192
- commands.push(new WatchCommand(pubsub, logger, watcher));
193
- cli.unregister('link');
194
- commands.push(new LinkCommand(workspace, logger));
195
- }
196
- commands.push(new Tag());
197
- cli.register(...commands);
198
- component.registerHost(workspace);
199
-
200
- cli.registerOnStart(async () => {
201
- await workspace.loadAspects(aspectLoader.getNotLoadedConfiguredExtensions());
202
- });
203
-
204
- return workspace;
205
- }
206
-
207
- /**
208
- * don't use loadConsumer() here, which throws ConsumerNotFound because some commands don't require
209
- * the consumer to be available. such as, `bit init` or `bit list --remote`.
210
- * most of the commands do need the consumer. the legacy commands that need the consumer throw an
211
- * error when is missing. in the new/Harmony commands, such as `bis compile`, the workspace object
212
- * is passed to the provider, so before using it, make sure it exists.
213
- * keep in mind that you can't verify it in the provider itself, because the provider is running
214
- * always for all commands before anything else is happening.
215
- */
216
- async function getConsumer(path?: string): Promise<Consumer | undefined> {
217
- return loadConsumerIfExist(path);
218
- }