@teambit/workspace 0.0.555 → 0.0.559

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 (69) hide show
  1. package/dist/build-graph-from-fs.js +4 -1
  2. package/dist/build-graph-from-fs.js.map +1 -1
  3. package/dist/workspace.d.ts +7 -0
  4. package/dist/workspace.js +23 -0
  5. package/dist/workspace.js.map +1 -1
  6. package/package.json +65 -50
  7. package/tsconfig.json +1 -1
  8. package/build-graph-from-fs.ts +0 -160
  9. package/capsule.cmd.ts +0 -136
  10. package/component-config-file/component-config-file.ts +0 -98
  11. package/component-config-file/exceptions/already-exists.ts +0 -7
  12. package/component-config-file/exceptions/index.ts +0 -1
  13. package/component-config-file/index.ts +0 -2
  14. package/component-tree.widget.tsx +0 -16
  15. package/constants.ts +0 -1
  16. package/eject-conf.cmd.tsx +0 -62
  17. package/events/index.ts +0 -3
  18. package/events/on-component-add-event.ts +0 -14
  19. package/events/on-component-change-event.ts +0 -14
  20. package/events/on-component-removed-event.ts +0 -14
  21. package/exceptions/dependency-type-not-supported-in-policy.ts +0 -7
  22. package/exceptions/incorrect-env-aspect.ts +0 -8
  23. package/exceptions/index.ts +0 -1
  24. package/index.ts +0 -19
  25. package/install.cmd.tsx +0 -67
  26. package/link/component-list-links.ts +0 -50
  27. package/link/core-aspects-links.ts +0 -50
  28. package/link/get-package-name-from-target.ts +0 -5
  29. package/link/index.ts +0 -1
  30. package/link/link-row.ts +0 -20
  31. package/link/link-to-dir.ts +0 -13
  32. package/link/link.cmd.ts +0 -96
  33. package/link/nested-deps-in-nm-links.ts +0 -47
  34. package/link/rewire-row.ts +0 -17
  35. package/list.cmd.tsx +0 -30
  36. package/on-component-events.ts +0 -14
  37. package/package-tar/teambit-workspace-0.0.555.tgz +0 -0
  38. package/tag-cmd.ts +0 -247
  39. package/types/asset.d.ts +0 -29
  40. package/types/style.d.ts +0 -42
  41. package/types.ts +0 -40
  42. package/ui/index.ts +0 -1
  43. package/ui/workspace/default-component.ts +0 -7
  44. package/ui/workspace/index.ts +0 -1
  45. package/ui/workspace/use-workspace.ts +0 -193
  46. package/ui/workspace/workspace-context.tsx +0 -5
  47. package/ui/workspace/workspace-model.ts +0 -66
  48. package/ui/workspace/workspace-overview/index.ts +0 -1
  49. package/ui/workspace/workspace-overview/workspace-overview.tsx +0 -21
  50. package/ui/workspace/workspace-provider.tsx +0 -23
  51. package/ui/workspace/workspace.tsx +0 -99
  52. package/ui/workspace-components-drawer/index.ts +0 -1
  53. package/ui/workspace-components-drawer/workspace-components.drawer.tsx +0 -49
  54. package/watch/check-types.ts +0 -5
  55. package/watch/output-formatter.ts +0 -50
  56. package/watch/watch.cmd.tsx +0 -142
  57. package/watch/watcher.ts +0 -289
  58. package/workspace-component/component-status.ts +0 -67
  59. package/workspace-component/index.ts +0 -2
  60. package/workspace-component/workspace-component-loader.ts +0 -276
  61. package/workspace-component/workspace-component.ts +0 -51
  62. package/workspace-section.ts +0 -14
  63. package/workspace.aspect.ts +0 -9
  64. package/workspace.graphql.ts +0 -133
  65. package/workspace.main.runtime.ts +0 -50
  66. package/workspace.provider.ts +0 -218
  67. package/workspace.ts +0 -1539
  68. package/workspace.ui-root.ts +0 -64
  69. package/workspace.ui.runtime.tsx +0 -215
@@ -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
- }