@teambit/workspace 1.0.108 → 1.0.110
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/artifacts/preview/static/css/teambit.workspace/workspace-preview.0f99da04.css +55 -0
- package/artifacts/preview/static/images/2f046646df38433e90d7.png +0 -0
- package/artifacts/preview/static/images/b40d450de296e275550f.png +0 -0
- package/artifacts/preview/static/images/cb67fb802479e2710016.png +0 -0
- package/artifacts/preview/teambit_workspace_workspace-preview.js +2 -0
- package/dist/{preview-1703647408454.js → preview-1703733956734.js} +2 -2
- package/package.json +35 -31
- package/aspects-merger.ts +0 -319
- package/bit-map.ts +0 -277
- package/build-graph-from-fs.ts +0 -188
- package/build-graph-ids-from-fs.ts +0 -216
- package/capsule.cmd.ts +0 -217
- package/constants.ts +0 -1
- package/eject-conf.cmd.ts +0 -57
- package/filter.ts +0 -139
- package/index.ts +0 -22
- package/merge-conflict-file.ts +0 -129
- package/on-component-events.ts +0 -24
- package/pattern.cmd.ts +0 -53
- package/types.ts +0 -71
- package/use.cmd.ts +0 -25
- package/workspace-aspects-loader.ts +0 -885
- package/workspace-section.ts +0 -14
- package/workspace.aspect.ts +0 -9
- package/workspace.graphql.ts +0 -133
- package/workspace.main.runtime.ts +0 -56
- package/workspace.provider.ts +0 -282
- package/workspace.ts +0 -2014
- package/workspace.ui-root.ts +0 -65
package/workspace-section.ts
DELETED
package/workspace.aspect.ts
DELETED
package/workspace.graphql.ts
DELETED
|
@@ -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,56 +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
|
-
import GlobalConfigAspect from '@teambit/global-config';
|
|
16
|
-
|
|
17
|
-
import { EXT_NAME } from './constants';
|
|
18
|
-
import { OnComponentAdd, OnComponentChange, OnComponentRemove, OnComponentLoad } from './on-component-events';
|
|
19
|
-
import { WorkspaceAspect } from './workspace.aspect';
|
|
20
|
-
import workspaceProvider, { OnAspectsResolve, OnBitmapChange, OnRootAspectAdded } from './workspace.provider';
|
|
21
|
-
|
|
22
|
-
export const WorkspaceMain = {
|
|
23
|
-
name: EXT_NAME,
|
|
24
|
-
runtime: MainRuntime,
|
|
25
|
-
dependencies: [
|
|
26
|
-
PubsubAspect,
|
|
27
|
-
CLIAspect,
|
|
28
|
-
ScopeAspect,
|
|
29
|
-
ComponentAspect,
|
|
30
|
-
IsolatorAspect,
|
|
31
|
-
DependencyResolverAspect,
|
|
32
|
-
VariantsAspect,
|
|
33
|
-
LoggerAspect,
|
|
34
|
-
GraphqlAspect,
|
|
35
|
-
UIAspect,
|
|
36
|
-
BundlerAspect,
|
|
37
|
-
AspectLoaderAspect,
|
|
38
|
-
EnvsAspect,
|
|
39
|
-
GlobalConfigAspect,
|
|
40
|
-
],
|
|
41
|
-
slots: [
|
|
42
|
-
Slot.withType<OnComponentLoad>(),
|
|
43
|
-
Slot.withType<OnComponentChange>(),
|
|
44
|
-
Slot.withType<OnComponentAdd>(),
|
|
45
|
-
Slot.withType<OnComponentRemove>(),
|
|
46
|
-
Slot.withType<OnAspectsResolve>(),
|
|
47
|
-
Slot.withType<OnRootAspectAdded>(),
|
|
48
|
-
Slot.withType<OnBitmapChange>(),
|
|
49
|
-
],
|
|
50
|
-
provider: workspaceProvider,
|
|
51
|
-
defineRuntime: 'browser',
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
WorkspaceAspect.addRuntime(WorkspaceMain);
|
|
55
|
-
|
|
56
|
-
export default WorkspaceMain;
|
package/workspace.provider.ts
DELETED
|
@@ -1,282 +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 { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';
|
|
6
|
-
import type { ComponentMain, Component } from '@teambit/component';
|
|
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 type { ComponentConfigLoadOptions } from '@teambit/legacy/dist/consumer/config';
|
|
18
|
-
import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
|
|
19
|
-
import LegacyComponentLoader, { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';
|
|
20
|
-
import { ComponentID } from '@teambit/component-id';
|
|
21
|
-
import { GlobalConfigMain } from '@teambit/global-config';
|
|
22
|
-
import { EXT_NAME } from './constants';
|
|
23
|
-
import EjectConfCmd from './eject-conf.cmd';
|
|
24
|
-
import { OnComponentLoad, OnComponentAdd, OnComponentChange, OnComponentRemove } from './on-component-events';
|
|
25
|
-
import { WorkspaceExtConfig } from './types';
|
|
26
|
-
import { Workspace } from './workspace';
|
|
27
|
-
import getWorkspaceSchema from './workspace.graphql';
|
|
28
|
-
import { WorkspaceUIRoot } from './workspace.ui-root';
|
|
29
|
-
import { CapsuleCmd, CapsuleCreateCmd, CapsuleDeleteCmd, CapsuleListCmd } from './capsule.cmd';
|
|
30
|
-
import { EnvsSetCmd } from './envs-subcommands/envs-set.cmd';
|
|
31
|
-
import { EnvsUnsetCmd } from './envs-subcommands/envs-unset.cmd';
|
|
32
|
-
import { PatternCommand } from './pattern.cmd';
|
|
33
|
-
import { EnvsReplaceCmd } from './envs-subcommands/envs-replace.cmd';
|
|
34
|
-
import { ScopeSetCmd } from './scope-subcommands/scope-set.cmd';
|
|
35
|
-
import { UseCmd } from './use.cmd';
|
|
36
|
-
import { EnvsUpdateCmd } from './envs-subcommands/envs-update.cmd';
|
|
37
|
-
|
|
38
|
-
export type WorkspaceDeps = [
|
|
39
|
-
PubsubMain,
|
|
40
|
-
CLIMain,
|
|
41
|
-
ScopeMain,
|
|
42
|
-
ComponentMain,
|
|
43
|
-
IsolatorMain,
|
|
44
|
-
DependencyResolverMain,
|
|
45
|
-
VariantsMain,
|
|
46
|
-
LoggerMain,
|
|
47
|
-
GraphqlMain,
|
|
48
|
-
UiMain,
|
|
49
|
-
BundlerMain,
|
|
50
|
-
AspectLoaderMain,
|
|
51
|
-
EnvsMain,
|
|
52
|
-
GlobalConfigMain
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
export type OnComponentLoadSlot = SlotRegistry<OnComponentLoad>;
|
|
56
|
-
|
|
57
|
-
export type OnComponentChangeSlot = SlotRegistry<OnComponentChange>;
|
|
58
|
-
|
|
59
|
-
export type OnComponentAddSlot = SlotRegistry<OnComponentAdd>;
|
|
60
|
-
|
|
61
|
-
export type OnComponentRemoveSlot = SlotRegistry<OnComponentRemove>;
|
|
62
|
-
|
|
63
|
-
export type OnBitmapChange = () => Promise<void>;
|
|
64
|
-
export type OnBitmapChangeSlot = SlotRegistry<OnBitmapChange>;
|
|
65
|
-
|
|
66
|
-
export type OnAspectsResolve = (aspectsComponents: Component[]) => Promise<void>;
|
|
67
|
-
export type OnAspectsResolveSlot = SlotRegistry<OnAspectsResolve>;
|
|
68
|
-
|
|
69
|
-
export type OnRootAspectAdded = (aspectsId: ComponentID, inWs: boolean) => Promise<void>;
|
|
70
|
-
export type OnRootAspectAddedSlot = SlotRegistry<OnRootAspectAdded>;
|
|
71
|
-
|
|
72
|
-
export default async function provideWorkspace(
|
|
73
|
-
[
|
|
74
|
-
pubsub,
|
|
75
|
-
cli,
|
|
76
|
-
scope,
|
|
77
|
-
component,
|
|
78
|
-
isolator,
|
|
79
|
-
dependencyResolver,
|
|
80
|
-
variants,
|
|
81
|
-
loggerExt,
|
|
82
|
-
graphql,
|
|
83
|
-
ui,
|
|
84
|
-
bundler,
|
|
85
|
-
aspectLoader,
|
|
86
|
-
envs,
|
|
87
|
-
globalConfig,
|
|
88
|
-
]: WorkspaceDeps,
|
|
89
|
-
config: WorkspaceExtConfig,
|
|
90
|
-
[
|
|
91
|
-
onComponentLoadSlot,
|
|
92
|
-
onComponentChangeSlot,
|
|
93
|
-
onComponentAddSlot,
|
|
94
|
-
onComponentRemoveSlot,
|
|
95
|
-
onAspectsResolveSlot,
|
|
96
|
-
onRootAspectAddedSlot,
|
|
97
|
-
onBitmapChangeSlot,
|
|
98
|
-
]: [
|
|
99
|
-
OnComponentLoadSlot,
|
|
100
|
-
OnComponentChangeSlot,
|
|
101
|
-
OnComponentAddSlot,
|
|
102
|
-
OnComponentRemoveSlot,
|
|
103
|
-
OnAspectsResolveSlot,
|
|
104
|
-
OnRootAspectAddedSlot,
|
|
105
|
-
OnBitmapChangeSlot
|
|
106
|
-
],
|
|
107
|
-
harmony: Harmony
|
|
108
|
-
) {
|
|
109
|
-
const bitConfig: any = harmony.config.get('teambit.harmony/bit');
|
|
110
|
-
const consumer = await getConsumer(bitConfig.cwd);
|
|
111
|
-
if (!consumer) {
|
|
112
|
-
const capsuleCmd = getCapsulesCommands(isolator, scope, undefined);
|
|
113
|
-
cli.register(capsuleCmd);
|
|
114
|
-
return undefined;
|
|
115
|
-
}
|
|
116
|
-
// TODO: get the 'workspace' name in a better way
|
|
117
|
-
const logger = loggerExt.createLogger(EXT_NAME);
|
|
118
|
-
const workspace = new Workspace(
|
|
119
|
-
pubsub,
|
|
120
|
-
config,
|
|
121
|
-
consumer,
|
|
122
|
-
scope,
|
|
123
|
-
component,
|
|
124
|
-
dependencyResolver,
|
|
125
|
-
variants,
|
|
126
|
-
aspectLoader,
|
|
127
|
-
logger,
|
|
128
|
-
undefined,
|
|
129
|
-
harmony,
|
|
130
|
-
onComponentLoadSlot,
|
|
131
|
-
onComponentChangeSlot,
|
|
132
|
-
envs,
|
|
133
|
-
globalConfig,
|
|
134
|
-
onComponentAddSlot,
|
|
135
|
-
onComponentRemoveSlot,
|
|
136
|
-
onAspectsResolveSlot,
|
|
137
|
-
onRootAspectAddedSlot,
|
|
138
|
-
graphql,
|
|
139
|
-
onBitmapChangeSlot
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
const configMergeFile = workspace.getConflictMergeFile();
|
|
143
|
-
await configMergeFile.loadIfNeeded();
|
|
144
|
-
|
|
145
|
-
const getWorkspacePolicyFromPackageJson = () => {
|
|
146
|
-
const packageJson = workspace.consumer.packageJson?.packageJsonObject || {};
|
|
147
|
-
const policyFromPackageJson = dependencyResolver.getWorkspacePolicyFromPackageJson(packageJson);
|
|
148
|
-
return policyFromPackageJson;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const getWorkspacePolicyFromMergeConfig = () => {
|
|
152
|
-
const wsConfigMerge = workspace.getWorkspaceJsonConflictFromMergeConfig();
|
|
153
|
-
const policy = wsConfigMerge.data?.[DependencyResolverAspect.id]?.policy || {};
|
|
154
|
-
['dependencies', 'peerDependencies'].forEach((depField) => {
|
|
155
|
-
if (!policy[depField]) return;
|
|
156
|
-
policy[depField] = policy[depField].reduce((acc, current) => {
|
|
157
|
-
acc[current.name] = current.version;
|
|
158
|
-
return acc;
|
|
159
|
-
}, {});
|
|
160
|
-
});
|
|
161
|
-
const wsPolicy = dependencyResolver.getWorkspacePolicyFromConfigObject(policy);
|
|
162
|
-
return wsPolicy;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const getRootPolicy = () => {
|
|
166
|
-
const pkgJsonPolicy = getWorkspacePolicyFromPackageJson();
|
|
167
|
-
const configMergePolicy = getWorkspacePolicyFromMergeConfig();
|
|
168
|
-
return dependencyResolver.mergeWorkspacePolices([pkgJsonPolicy, configMergePolicy]);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
dependencyResolver.registerRootPolicy(getRootPolicy());
|
|
172
|
-
|
|
173
|
-
consumer.onCacheClear.push(() => workspace.clearCache());
|
|
174
|
-
|
|
175
|
-
LegacyComponentLoader.registerOnComponentLoadSubscriber(
|
|
176
|
-
async (legacyComponent: ConsumerComponent, opts?: ComponentLoadOptions) => {
|
|
177
|
-
if (opts?.originatedFromHarmony) return legacyComponent;
|
|
178
|
-
const id = await workspace.resolveComponentId(legacyComponent.id);
|
|
179
|
-
const newComponent = await workspace.get(id, legacyComponent, true, true, opts);
|
|
180
|
-
return newComponent.state._consumer;
|
|
181
|
-
}
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
ConsumerComponent.registerOnComponentConfigLoading(EXT_NAME, async (id, loadOpts: ComponentConfigLoadOptions) => {
|
|
185
|
-
const componentId = await workspace.resolveComponentId(id);
|
|
186
|
-
// We call here directly workspace.scope.get instead of workspace.get because part of the workspace get is loading consumer component
|
|
187
|
-
// which in turn run this event, which will make an infinite loop
|
|
188
|
-
// This component from scope here are only used for merging the extensions with the workspace components
|
|
189
|
-
const componentFromScope = await workspace.scope.get(componentId);
|
|
190
|
-
const { extensions } = await workspace.componentExtensions(componentId, componentFromScope, undefined, loadOpts);
|
|
191
|
-
const defaultScope = await workspace.componentDefaultScope(componentId);
|
|
192
|
-
|
|
193
|
-
const extensionsWithLegacyIdsP = extensions.map(async (extension) => {
|
|
194
|
-
const legacyEntry = extension.clone();
|
|
195
|
-
if (legacyEntry.extensionId) {
|
|
196
|
-
legacyEntry.newExtensionId = legacyEntry.extensionId;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return legacyEntry;
|
|
200
|
-
});
|
|
201
|
-
const extensionsWithLegacyIds = await Promise.all(extensionsWithLegacyIdsP);
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
defaultScope,
|
|
205
|
-
extensions: ExtensionDataList.fromArray(extensionsWithLegacyIds),
|
|
206
|
-
};
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
const workspaceSchema = getWorkspaceSchema(workspace, graphql);
|
|
210
|
-
ui.registerUiRoot(new WorkspaceUIRoot(workspace, bundler));
|
|
211
|
-
ui.registerPreStart(async () => {
|
|
212
|
-
return workspace.setComponentPathsRegExps();
|
|
213
|
-
});
|
|
214
|
-
graphql.register(workspaceSchema);
|
|
215
|
-
const capsuleCmd = getCapsulesCommands(isolator, scope, workspace);
|
|
216
|
-
const commands: CommandList = [new EjectConfCmd(workspace), capsuleCmd, new UseCmd(workspace)];
|
|
217
|
-
|
|
218
|
-
commands.push(new PatternCommand(workspace));
|
|
219
|
-
cli.register(...commands);
|
|
220
|
-
component.registerHost(workspace);
|
|
221
|
-
|
|
222
|
-
cli.registerOnStart(async (_hasWorkspace: boolean, currentCommand: string) => {
|
|
223
|
-
if (currentCommand === 'mini-status' || currentCommand === 'ms') {
|
|
224
|
-
return; // mini-status should be super fast.
|
|
225
|
-
}
|
|
226
|
-
if (currentCommand === 'install') {
|
|
227
|
-
workspace.inInstallContext = true;
|
|
228
|
-
}
|
|
229
|
-
await workspace.importCurrentLaneIfMissing();
|
|
230
|
-
const loadAspectsOpts = {
|
|
231
|
-
runSubscribers: false,
|
|
232
|
-
skipDeps: !config.autoLoadAspectsDeps,
|
|
233
|
-
};
|
|
234
|
-
const aspects = await workspace.loadAspects(
|
|
235
|
-
aspectLoader.getNotLoadedConfiguredExtensions(),
|
|
236
|
-
undefined,
|
|
237
|
-
'teambit.workspace/workspace (cli.registerOnStart)',
|
|
238
|
-
loadAspectsOpts
|
|
239
|
-
);
|
|
240
|
-
// clear aspect cache.
|
|
241
|
-
const componentIds = await workspace.resolveMultipleComponentIds(aspects);
|
|
242
|
-
componentIds.forEach((id) => {
|
|
243
|
-
workspace.clearComponentCache(id);
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
// add sub-commands "set" and "unset" to envs command.
|
|
248
|
-
const envsCommand = cli.getCommand('envs');
|
|
249
|
-
envsCommand?.commands?.push(new EnvsSetCmd(workspace)); // bit envs set
|
|
250
|
-
envsCommand?.commands?.push(new EnvsUnsetCmd(workspace)); // bit envs unset
|
|
251
|
-
envsCommand?.commands?.push(new EnvsReplaceCmd(workspace)); // bit envs replace
|
|
252
|
-
envsCommand?.commands?.push(new EnvsUpdateCmd(workspace)); // bit envs replace
|
|
253
|
-
|
|
254
|
-
// add sub-command "set" to scope command.
|
|
255
|
-
const scopeCommand = cli.getCommand('scope');
|
|
256
|
-
scopeCommand?.commands?.push(new ScopeSetCmd(workspace));
|
|
257
|
-
|
|
258
|
-
return workspace;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function getCapsulesCommands(isolator: IsolatorMain, scope: ScopeMain, workspace?: Workspace) {
|
|
262
|
-
const capsuleCmd = new CapsuleCmd(isolator, workspace, scope);
|
|
263
|
-
capsuleCmd.commands = [
|
|
264
|
-
new CapsuleListCmd(isolator, workspace, scope),
|
|
265
|
-
new CapsuleCreateCmd(workspace, scope, isolator),
|
|
266
|
-
new CapsuleDeleteCmd(isolator, scope, workspace),
|
|
267
|
-
];
|
|
268
|
-
return capsuleCmd;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* don't use loadConsumer() here, which throws ConsumerNotFound because some commands don't require
|
|
273
|
-
* the consumer to be available. such as, `bit init` or `bit list --remote`.
|
|
274
|
-
* most of the commands do need the consumer. the legacy commands that need the consumer throw an
|
|
275
|
-
* error when is missing. in the new/Harmony commands, such as `bis compile`, the workspace object
|
|
276
|
-
* is passed to the provider, so before using it, make sure it exists.
|
|
277
|
-
* keep in mind that you can't verify it in the provider itself, because the provider is running
|
|
278
|
-
* always for all commands before anything else is happening.
|
|
279
|
-
*/
|
|
280
|
-
async function getConsumer(path?: string): Promise<Consumer | undefined> {
|
|
281
|
-
return loadConsumerIfExist(path);
|
|
282
|
-
}
|