@teambit/workspace 0.0.554 → 0.0.558

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 (89) hide show
  1. package/dist/build-graph-from-fs.d.ts +30 -0
  2. package/dist/build-graph-from-fs.js +4 -1
  3. package/dist/build-graph-from-fs.js.map +1 -1
  4. package/dist/install.cmd.d.ts +17 -3
  5. package/dist/install.cmd.js.map +1 -1
  6. package/dist/link/link.cmd.d.ts +15 -1
  7. package/dist/types.d.ts +21 -0
  8. package/dist/ui/workspace/workspace-model.d.ts +32 -1
  9. package/dist/ui/workspace/workspace-provider.d.ts +9 -0
  10. package/dist/ui/workspace/workspace.d.ts +3 -0
  11. package/dist/watch/output-formatter.d.ts +6 -0
  12. package/dist/watch/watch.cmd.d.ts +22 -1
  13. package/dist/watch/watcher.d.ts +9 -0
  14. package/dist/workspace-component/component-status.d.ts +57 -1
  15. package/dist/workspace-component/workspace-component-loader.d.ts +7 -0
  16. package/dist/workspace-component/workspace-component.d.ts +36 -1
  17. package/dist/workspace.d.ts +236 -3
  18. package/dist/workspace.js +6 -0
  19. package/dist/workspace.js.map +1 -1
  20. package/dist/workspace.ui-root.d.ts +18 -1
  21. package/dist/workspace.ui.runtime.d.ts +32 -1
  22. package/package.json +61 -53
  23. package/tsconfig.json +1 -2
  24. package/build-graph-from-fs.ts +0 -160
  25. package/capsule.cmd.ts +0 -136
  26. package/component-config-file/component-config-file.ts +0 -98
  27. package/component-config-file/exceptions/already-exists.ts +0 -7
  28. package/component-config-file/exceptions/index.ts +0 -1
  29. package/component-config-file/index.ts +0 -2
  30. package/component-tree.widget.tsx +0 -16
  31. package/constants.ts +0 -1
  32. package/eject-conf.cmd.tsx +0 -62
  33. package/events/index.ts +0 -3
  34. package/events/on-component-add-event.ts +0 -14
  35. package/events/on-component-change-event.ts +0 -14
  36. package/events/on-component-removed-event.ts +0 -14
  37. package/exceptions/dependency-type-not-supported-in-policy.ts +0 -7
  38. package/exceptions/incorrect-env-aspect.ts +0 -8
  39. package/exceptions/index.ts +0 -1
  40. package/index.ts +0 -19
  41. package/install.cmd.tsx +0 -67
  42. package/link/component-list-links.ts +0 -50
  43. package/link/core-aspects-links.ts +0 -50
  44. package/link/get-package-name-from-target.ts +0 -5
  45. package/link/index.ts +0 -1
  46. package/link/link-row.ts +0 -20
  47. package/link/link-to-dir.ts +0 -13
  48. package/link/link.cmd.ts +0 -96
  49. package/link/nested-deps-in-nm-links.ts +0 -47
  50. package/link/rewire-row.ts +0 -17
  51. package/list.cmd.tsx +0 -30
  52. package/on-component-events.ts +0 -14
  53. package/package-tar/teambit-workspace-0.0.554.tgz +0 -0
  54. package/tag-cmd.ts +0 -247
  55. package/types/asset.d.ts +0 -29
  56. package/types/style.d.ts +0 -42
  57. package/types.ts +0 -40
  58. package/ui/index.ts +0 -1
  59. package/ui/workspace/default-component.ts +0 -7
  60. package/ui/workspace/index.ts +0 -1
  61. package/ui/workspace/use-workspace.ts +0 -193
  62. package/ui/workspace/workspace-context.tsx +0 -5
  63. package/ui/workspace/workspace-model.ts +0 -66
  64. package/ui/workspace/workspace-overview/index.ts +0 -1
  65. package/ui/workspace/workspace-overview/workspace-overview.module.scss +0 -6
  66. package/ui/workspace/workspace-overview/workspace-overview.tsx +0 -21
  67. package/ui/workspace/workspace-provider.tsx +0 -23
  68. package/ui/workspace/workspace.module.scss +0 -40
  69. package/ui/workspace/workspace.tsx +0 -99
  70. package/ui/workspace-components-drawer/index.ts +0 -1
  71. package/ui/workspace-components-drawer/workspace-components-drawer.module.scss +0 -4
  72. package/ui/workspace-components-drawer/workspace-components.drawer.tsx +0 -49
  73. package/watch/REFACTOR_GUIDE.md +0 -14
  74. package/watch/check-types.ts +0 -5
  75. package/watch/output-formatter.ts +0 -50
  76. package/watch/watch.cmd.tsx +0 -142
  77. package/watch/watcher.ts +0 -289
  78. package/workspace-component/component-status.ts +0 -67
  79. package/workspace-component/index.ts +0 -2
  80. package/workspace-component/workspace-component-loader.ts +0 -276
  81. package/workspace-component/workspace-component.ts +0 -51
  82. package/workspace-section.ts +0 -14
  83. package/workspace.aspect.ts +0 -9
  84. package/workspace.graphql.ts +0 -133
  85. package/workspace.main.runtime.ts +0 -50
  86. package/workspace.provider.ts +0 -218
  87. package/workspace.ts +0 -1534
  88. package/workspace.ui-root.ts +0 -64
  89. package/workspace.ui.runtime.tsx +0 -215
@@ -3,7 +3,7 @@ import { IssuesList } from '@teambit/component-issues';
3
3
  import type { AspectLoaderMain, AspectDefinition } from '@teambit/aspect-loader';
4
4
  import { ComponentMain, Component, ComponentFactory, ComponentID, ComponentMap, AspectList, AspectData, InvalidComponent } from '@teambit/component';
5
5
  import { ComponentScopeDirMap } from '@teambit/config';
6
- import { DependencyLifecycleType, DependencyResolverMain, LinkingOptions, LinkResults } from '@teambit/dependency-resolver';
6
+ import { WorkspaceDependencyLifecycleType, DependencyResolverMain, LinkingOptions, LinkResults } from '@teambit/dependency-resolver';
7
7
  import { EnvsMain } from '@teambit/envs';
8
8
  import { GraphqlMain } from '@teambit/graphql';
9
9
  import { Harmony } from '@teambit/harmony';
@@ -45,7 +45,7 @@ export interface EjectConfOptions {
45
45
  }
46
46
  export declare type WorkspaceInstallOptions = {
47
47
  variants?: string;
48
- lifecycleType?: DependencyLifecycleType;
48
+ lifecycleType?: WorkspaceDependencyLifecycleType;
49
49
  dedupe: boolean;
50
50
  import: boolean;
51
51
  copyPeerToRuntimeOnRoot?: boolean;
@@ -64,11 +64,26 @@ export declare type TrackResult = {
64
64
  files: string[];
65
65
  warnings: Warnings;
66
66
  };
67
+ /**
68
+ * API of the Bit Workspace
69
+ */
67
70
  export declare class Workspace implements ComponentFactory {
71
+ /**
72
+ * private pubsub.
73
+ */
68
74
  private pubsub;
69
75
  private config;
76
+ /**
77
+ * private access to the legacy consumer instance.
78
+ */
70
79
  consumer: Consumer;
80
+ /**
81
+ * access to the workspace `Scope` instance
82
+ */
71
83
  readonly scope: ScopeMain;
84
+ /**
85
+ * access to the `ComponentProvider` instance
86
+ */
72
87
  private componentAspect;
73
88
  private isolator;
74
89
  private dependencyResolver;
@@ -76,10 +91,22 @@ export declare class Workspace implements ComponentFactory {
76
91
  private aspectLoader;
77
92
  private logger;
78
93
  private componentList;
94
+ /**
95
+ * private reference to the instance of Harmony.
96
+ */
79
97
  private harmony;
98
+ /**
99
+ * on component load slot.
100
+ */
80
101
  onComponentLoadSlot: OnComponentLoadSlot;
102
+ /**
103
+ * on component change slot.
104
+ */
81
105
  private onComponentChangeSlot;
82
106
  private envs;
107
+ /**
108
+ * on component add slot.
109
+ */
83
110
  private onComponentAddSlot;
84
111
  private onComponentRemoveSlot;
85
112
  private onPreWatchSlot;
@@ -88,10 +115,49 @@ export declare class Workspace implements ComponentFactory {
88
115
  owner?: string;
89
116
  componentsScopeDirsMap: ComponentScopeDirMap;
90
117
  componentLoader: WorkspaceComponentLoader;
91
- constructor(pubsub: PubsubMain, config: WorkspaceExtConfig, consumer: Consumer, scope: ScopeMain, componentAspect: ComponentMain, isolator: IsolatorMain, dependencyResolver: DependencyResolverMain, variants: VariantsMain, aspectLoader: AspectLoaderMain, logger: Logger, componentList: ComponentsList, harmony: Harmony, onComponentLoadSlot: OnComponentLoadSlot, onComponentChangeSlot: OnComponentChangeSlot, envs: EnvsMain, onComponentAddSlot: OnComponentAddSlot, onComponentRemoveSlot: OnComponentRemoveSlot, onPreWatchSlot: OnPreWatchSlot, graphql: GraphqlMain);
118
+ constructor(
119
+ /**
120
+ * private pubsub.
121
+ */
122
+ pubsub: PubsubMain, config: WorkspaceExtConfig,
123
+ /**
124
+ * private access to the legacy consumer instance.
125
+ */
126
+ consumer: Consumer,
127
+ /**
128
+ * access to the workspace `Scope` instance
129
+ */
130
+ scope: ScopeMain,
131
+ /**
132
+ * access to the `ComponentProvider` instance
133
+ */
134
+ componentAspect: ComponentMain, isolator: IsolatorMain, dependencyResolver: DependencyResolverMain, variants: VariantsMain, aspectLoader: AspectLoaderMain, logger: Logger, componentList: ComponentsList,
135
+ /**
136
+ * private reference to the instance of Harmony.
137
+ */
138
+ harmony: Harmony,
139
+ /**
140
+ * on component load slot.
141
+ */
142
+ onComponentLoadSlot: OnComponentLoadSlot,
143
+ /**
144
+ * on component change slot.
145
+ */
146
+ onComponentChangeSlot: OnComponentChangeSlot, envs: EnvsMain,
147
+ /**
148
+ * on component add slot.
149
+ */
150
+ onComponentAddSlot: OnComponentAddSlot, onComponentRemoveSlot: OnComponentRemoveSlot, onPreWatchSlot: OnPreWatchSlot, graphql: GraphqlMain);
92
151
  private validateConfig;
152
+ /**
153
+ * watcher api.
154
+ */
93
155
  readonly watcher: Watcher;
156
+ /**
157
+ * root path of the Workspace.
158
+ */
94
159
  get path(): string;
160
+ /** get the `node_modules` folder of this workspace */
95
161
  private get modulesPath();
96
162
  get isLegacy(): boolean;
97
163
  onComponentLoad(loadFn: OnComponentLoad): this;
@@ -99,29 +165,78 @@ export declare class Workspace implements ComponentFactory {
99
165
  registerOnComponentAdd(onComponentAddFunc: OnComponentAdd): this;
100
166
  registerOnComponentRemove(onComponentRemoveFunc: OnComponentRemove): this;
101
167
  registerOnPreWatch(onPreWatchFunc: OnPreWatch): this;
168
+ /**
169
+ * name of the workspace as configured in either `workspace.json`.
170
+ * defaults to workspace root directory name.
171
+ */
102
172
  get name(): string;
103
173
  get icon(): string;
104
174
  hasModifiedDependencies(component: Component): Promise<boolean>;
175
+ /**
176
+ * get Component issues
177
+ */
105
178
  getComponentIssues(component: Component): IssuesList | null;
179
+ /**
180
+ * provides status of all components in the workspace.
181
+ */
106
182
  getComponentStatus(component: Component): Promise<ComponentStatus>;
183
+ /**
184
+ * list all workspace components.
185
+ */
107
186
  list(filter?: {
108
187
  offset: number;
109
188
  limit: number;
110
189
  }): Promise<Component[]>;
190
+ /**
191
+ * list all invalid components.
192
+ * (see the invalid criteria in ConsumerComponent.isComponentInvalidByErrorType())
193
+ */
111
194
  listInvalid(): Promise<InvalidComponent[]>;
195
+ /**
196
+ * get ids of all workspace components.
197
+ */
112
198
  listIds(): Promise<ComponentID[]>;
199
+ /**
200
+ * Check if a specific id exist in the workspace
201
+ * @param componentId
202
+ */
113
203
  hasId(componentId: ComponentID): Promise<boolean>;
204
+ /**
205
+ * whether or not a workspace has a component with the given name
206
+ */
114
207
  hasName(name: string): Promise<boolean>;
208
+ /**
209
+ * Check if a specific id exist in the workspace or in the scope
210
+ * @param componentId
211
+ */
115
212
  hasIdNested(componentId: ComponentID, includeCache?: boolean): Promise<boolean>;
213
+ /**
214
+ * list all modified components in the workspace.
215
+ */
116
216
  modified(): Promise<Component[]>;
217
+ /**
218
+ * list all new components in the workspace.
219
+ */
117
220
  newComponents(): Promise<Component[]>;
221
+ /**
222
+ * get all workspace component-ids, include vendor components.
223
+ * (exclude nested dependencies in case dependencies are saved as components and not packages)
224
+ */
118
225
  getAllComponentIds(): Promise<ComponentID[]>;
119
226
  getNewAndModifiedIds(): Promise<ComponentID[]>;
120
227
  getLogs(id: ComponentID): Promise<ComponentLog[]>;
121
228
  getLegacyGraph(ids?: ComponentID[]): Promise<LegacyGraph>;
122
229
  loadCapsules(bitIds: string[]): Promise<import("@teambit/isolator").Capsule[]>;
230
+ /**
231
+ * fully load components, including dependency resolution and prepare them for runtime.
232
+ * @todo: remove the string option, use only BitId
233
+ */
123
234
  load(ids: Array<BitId | string>): Promise<ResolvedComponent[]>;
124
235
  createAspectList(extensionDataList: ExtensionDataList): Promise<AspectList>;
236
+ /**
237
+ * get a component from workspace
238
+ * @param id component ID
239
+ */
125
240
  get(componentId: ComponentID, forCapsule?: boolean, legacyComponent?: ConsumerComponent, useCache?: boolean, storeInCache?: boolean): Promise<Component>;
126
241
  getEnvSystemDescriptor(component: Component): Promise<AspectData>;
127
242
  clearCache(): void;
@@ -132,21 +247,62 @@ export declare class Workspace implements ComponentFactory {
132
247
  getState(id: ComponentID, hash: string): Promise<import("@teambit/component").State>;
133
248
  getSnap(id: ComponentID, hash: string): Promise<import("@teambit/component").Snap>;
134
249
  getCurrentLaneId(): LocalLaneId;
250
+ /**
251
+ * if checked out to a lane, return the remote lane id (name+scope). otherwise, return null.
252
+ */
135
253
  getCurrentRemoteLaneId(): RemoteLaneId | null;
136
254
  getDefaultExtensions(): ExtensionDataList;
137
255
  ejectConfig(id: ComponentID, options: EjectConfOptions): Promise<EjectConfResult>;
138
256
  private resolveScopeAspectListIds;
257
+ /**
258
+ * load components into the workspace through a variants pattern.
259
+ * @param pattern variants.
260
+ * @param scope scope name.
261
+ */
139
262
  byPattern(pattern: string, scope?: string): Promise<Component[]>;
140
263
  getMany(ids: Array<ComponentID>, forCapsule?: boolean): Promise<Component[]>;
141
264
  getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;
265
+ /**
266
+ * This will make sure to fetch the objects prior to load them
267
+ * do not use it if you are not sure you need it.
268
+ * It will influence the performance
269
+ * currently it used only for get many of aspects
270
+ * @param ids
271
+ * @param forCapsule
272
+ */
142
273
  importAndGetMany(ids: Array<ComponentID>, forCapsule?: boolean): Promise<Component[]>;
274
+ /**
275
+ * @deprecated use this.track() instead
276
+ * track a new component. (practically, add it to .bitmap).
277
+ *
278
+ * @param componentPaths component paths relative to the workspace dir
279
+ * @param id if not set, will be concluded from the filenames
280
+ * @param main if not set, will try to guess according to some strategies and throws if failed
281
+ * @param override whether add details to an existing component or re-define it
282
+ */
143
283
  add(componentPaths: PathOsBasedRelative[], id?: string, main?: string, override?: boolean): Promise<AddActionResults>;
284
+ /**
285
+ * add a new component to the .bitmap file.
286
+ * this method only adds the records in memory but doesn't persist to the filesystem.
287
+ * to write the .bitmap file once completed, run "await this.writeBitMap();"
288
+ */
144
289
  track(trackData: TrackData): Promise<TrackResult>;
145
290
  write(rootPath: string, component: Component): Promise<void>;
146
291
  writeBitMap(): Promise<void>;
292
+ /**
293
+ * Get the component root dir in the file system (relative to workspace or full)
294
+ * @param componentId
295
+ * @param relative return the path relative to the workspace or full path
296
+ */
147
297
  componentDir(componentId: ComponentID, bitMapOptions?: GetBitMapComponentOptions, options?: {
148
298
  relative: boolean;
149
299
  }): PathOsBased;
300
+ /**
301
+ * component's files in the workspace are symlinked to the node_modules, and a package.json file is generated on that
302
+ * package directory to simulate a valid node package.
303
+ * @returns the package directory inside the node_module.
304
+ * by default the absolute path, unless `options.relative` was set
305
+ */
150
306
  componentPackageDir(component: Component, options?: {
151
307
  relative: boolean;
152
308
  }): string;
@@ -156,34 +312,111 @@ export declare class Workspace implements ComponentFactory {
156
312
  componentDefaultScopeFromComponentDirAndName(relativeComponentDir: PathOsBasedRelative, name: string): Promise<string | undefined>;
157
313
  get defaultScope(): string;
158
314
  private componentDefaultScopeFromComponentDirAndNameWithoutConfigFile;
315
+ /**
316
+ * Calculate the component config based on:
317
+ * the component.json file in the component folder
318
+ * matching pattern in the variants config
319
+ * defaults extensions from workspace config
320
+ *
321
+ * @param {ComponentID} componentId
322
+ * @param {Component} [componentFromScope]
323
+ * @returns {Promise<ExtensionDataList>}
324
+ * @memberof Workspace
325
+ */
159
326
  componentExtensions(componentId: ComponentID, componentFromScope?: Component): Promise<ExtensionDataList>;
160
327
  triggerOnPreWatch(componentIds: ComponentID[], watchOpts: WatchOptions): Promise<void>;
328
+ /**
329
+ * This will mutate the entries with extensionId prop to have resolved legacy id
330
+ * This should be worked on the extension data list not the new aspect list
331
+ * @param extensionList
332
+ */
161
333
  private resolveExtensionListIds;
162
334
  private isVendorComponentByComponentDir;
335
+ /**
336
+ * return the component config from its folder (component.json)
337
+ * @param componentId
338
+ */
163
339
  private componentConfigFile;
164
340
  private componentConfigFileFromComponentDirAndName;
165
341
  getAspectsGraphWithoutCore(components: Component[], isAspect?: ShouldIgnoreFunc): Promise<LegacyGraph>;
342
+ /**
343
+ * load aspects from the workspace and if not exists in the workspace, load from the scope.
344
+ * keep in mind that the graph may have circles.
345
+ */
166
346
  loadAspects(ids?: string[], throwOnError?: boolean): Promise<void>;
347
+ /**
348
+ * Note - this gets called from Harmony only.
349
+ * returns one graph that includes all dependencies types. each edge has a label of the dependency
350
+ * type. the nodes content is the Component object.
351
+ */
167
352
  buildOneGraphForComponents(ids: BitId[], ignoreIds?: BitIds, shouldIgnoreFunc?: ShouldIgnoreFunc): Promise<LegacyGraph>;
168
353
  resolveAspects(runtimeName?: string, componentIds?: ComponentID[]): Promise<AspectDefinition[]>;
169
354
  private groupIdsByWorkspaceAndScope;
170
355
  private groupComponentsByWorkspaceAndScope;
356
+ /**
357
+ * Load all unloaded extensions from a list
358
+ * @param extensions list of extensions with config to load
359
+ */
171
360
  loadExtensions(extensions: ExtensionDataList, throwOnError?: boolean): Promise<void>;
361
+ /**
362
+ * Provides a cache folder, unique per key.
363
+ * Return value may be undefined, if workspace folder is unconventional (bare-scope, no node_modules, etc)
364
+ */
172
365
  getTempDir(id: string): string;
173
366
  requireComponents(components: Component[]): Promise<RequireableComponent[]>;
174
367
  private getComponentsDirectory;
368
+ /**
369
+ * Install dependencies for all components in the workspace
370
+ *
371
+ * @returns
372
+ * @memberof Workspace
373
+ */
175
374
  install(packages?: string[], options?: WorkspaceInstallOptions): Promise<ComponentMap<string>>;
176
375
  link(options?: WorkspaceLinkOptions): Promise<LinkResults>;
376
+ /**
377
+ * Generate a filter to pass to the installer
378
+ * This will filter deps which are come from remotes which defined in scope.json
379
+ * those components comes from local remotes, usually doesn't have a package in a registry
380
+ * so no reason to try to install them (it will fail)
381
+ */
177
382
  private generateFilterFnForDepsFromLocalRemote;
383
+ /**
384
+ * same as `this.importAndGetMany()` with a specific error handling of ComponentNotFound
385
+ */
178
386
  private importAndGetAspects;
179
387
  private importObjects;
388
+ /**
389
+ * this should be rarely in-use.
390
+ * it's currently used by watch extension as a quick workaround to load .bitmap and the components
391
+ */
180
392
  _reloadConsumer(): Promise<void>;
181
393
  getComponentPackagePath(component: ConsumerComponent | Component): string;
182
394
  get defaultDirectory(): string;
183
395
  get legacyDefaultDirectory(): string;
396
+ /**
397
+ * Transform the id to ComponentId and get the exact id as appear in bitmap
398
+ *
399
+ * @param {(string | ComponentID | BitId)} id
400
+ * @returns {Promise<ComponentID>}
401
+ * @memberof Workspace
402
+ */
184
403
  resolveComponentId(id: string | ComponentID | BitId): Promise<ComponentID>;
185
404
  resolveMultipleComponentIds(ids: Array<string | ComponentID | BitId>): Promise<ComponentID[]>;
405
+ /**
406
+ * This will mutate the original extensions list and resolve it's ids
407
+ *
408
+ * @param {ExtensionDataList} extensions
409
+ * @returns {Promise<void[]>}
410
+ * @memberof Workspace
411
+ */
186
412
  resolveExtensionsList(extensions: ExtensionDataList): Promise<void[]>;
413
+ /**
414
+ * This will mutate the original extensions list and make sure all extensions has the ids with the scope / default scope
415
+ *
416
+ * @param {ExtensionDataList} extensions
417
+ * @returns {Promise<void[]>}
418
+ * @memberof Workspace
419
+ */
187
420
  addDefaultScopeToExtensionsList(extensions: ExtensionDataList): Promise<void[]>;
188
421
  }
189
422
  export default Workspace;
package/dist/workspace.js CHANGED
@@ -1635,6 +1635,8 @@ class Workspace {
1635
1635
  async generateFilterFnForDepsFromLocalRemote() {
1636
1636
  // TODO: once scope create a new API for this, replace it with the new one
1637
1637
  const remotes = await this.scope._legacyRemotes();
1638
+ const reg = await this.dependencyResolver.getRegistries();
1639
+ const packageScopes = Object.keys(reg.scopes);
1638
1640
  return dependencyList => {
1639
1641
  const filtered = dependencyList.filter(dep => {
1640
1642
  if (!(dep instanceof _dependencyResolver().ComponentDependency)) {
@@ -1645,6 +1647,10 @@ class Workspace {
1645
1647
  return true;
1646
1648
  }
1647
1649
 
1650
+ if (packageScopes.some(scope => dep.packageName.startsWith(`@${scope}/`))) {
1651
+ return true;
1652
+ }
1653
+
1648
1654
  return false;
1649
1655
  });
1650
1656
  return filtered;