@teambit/workspace 0.0.1065 → 0.0.1067
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/dist/{preview-1685272045621.js → preview-1685418569798.js} +2 -2
- package/dist/types.d.ts +9 -0
- package/dist/types.js.map +1 -1
- package/dist/workspace-aspects-loader.d.ts +6 -1
- package/dist/workspace-aspects-loader.js +116 -40
- package/dist/workspace-aspects-loader.js.map +1 -1
- package/dist/workspace.d.ts +4 -1
- package/dist/workspace.js +3 -2
- package/dist/workspace.js.map +1 -1
- package/package-tar/teambit-workspace-0.0.1067.tgz +0 -0
- package/package.json +37 -37
- package/package-tar/teambit-workspace-0.0.1065.tgz +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.1067/dist/workspace.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.1067/dist/workspace.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/dist/types.d.ts
CHANGED
|
@@ -39,6 +39,15 @@ export interface WorkspaceExtConfig {
|
|
|
39
39
|
* from the scope aspects capsule.
|
|
40
40
|
*/
|
|
41
41
|
resolveAspectsFromNodeModules?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* If set to `true`, it allows the workspace to resolve envs from node modules
|
|
44
|
+
* installed in the workspace's `node_modules` directory.
|
|
45
|
+
* the envs will be resolved from the node_modules of the env's root (workspace/node_modules/.bit_roots/{envId})
|
|
46
|
+
* and if not found (usually when the env was hoisted to the root node_modules) then from the node_modules of the
|
|
47
|
+
* workspace.
|
|
48
|
+
* If not set or set to `false`, envs will only be resolved from the scope envs capsule.
|
|
49
|
+
*/
|
|
50
|
+
resolveEnvsFromRoots?: boolean;
|
|
42
51
|
/**
|
|
43
52
|
* If set to `true`, bit will try to load aspects dependencies automatically.
|
|
44
53
|
* even if the aspects dependencies are not configured in the workspace.jsonc root config.
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["interface VendorConfig {\n directory: string;\n}\n\nexport interface WorkspaceExtConfig {\n /**\n * name of the workspace.\n */\n name: string;\n\n /**\n * path to icon.\n */\n icon: string;\n\n /**\n * applies only on bit.dev. configure the main owner of your workspace\n */\n defaultOwner: string;\n\n /**\n * set the default scope when there is no matching for the component in the components array.\n */\n defaultScope: string;\n\n /**\n * set the default directory when there is no matching for the component in the components array.\n */\n defaultDirectory: string;\n\n /**\n * set the default structure of components in your project\n */\n vendor: VendorConfig;\n\n /**\n * All component extensions applied by default on all components in the workspace (except vendor components)\n */\n extensions: { [extensionsId: string]: string };\n\n /**\n * If set to\n * `true`, it allows the workspace to resolve scope's aspects from node modules\n * installed in the workspace's `node_modules` directory. If not set or set to `false`, aspects will only be resolved\n * from the scope aspects capsule.\n */\n resolveAspectsFromNodeModules?: boolean;\n\n /**\n * If set to `true`, bit will try to load aspects dependencies automatically.\n * even if the aspects dependencies are not configured in the workspace.jsonc root config.\n * for example having the aspect\n * main aspect\n * export class MainAspectMain {\n * ...\n * static dependencies = [MyDepAspect];\n * }\n * and the in the workspace.jsonc file:\n * {\n * ...\n * main-aspect: {}\n * }\n * when set to true, bit will try to load MyDepAspect automatically.\n */\n autoLoadAspectsDeps?: boolean;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["interface VendorConfig {\n directory: string;\n}\n\nexport interface WorkspaceExtConfig {\n /**\n * name of the workspace.\n */\n name: string;\n\n /**\n * path to icon.\n */\n icon: string;\n\n /**\n * applies only on bit.dev. configure the main owner of your workspace\n */\n defaultOwner: string;\n\n /**\n * set the default scope when there is no matching for the component in the components array.\n */\n defaultScope: string;\n\n /**\n * set the default directory when there is no matching for the component in the components array.\n */\n defaultDirectory: string;\n\n /**\n * set the default structure of components in your project\n */\n vendor: VendorConfig;\n\n /**\n * All component extensions applied by default on all components in the workspace (except vendor components)\n */\n extensions: { [extensionsId: string]: string };\n\n /**\n * If set to\n * `true`, it allows the workspace to resolve scope's aspects from node modules\n * installed in the workspace's `node_modules` directory. If not set or set to `false`, aspects will only be resolved\n * from the scope aspects capsule.\n */\n resolveAspectsFromNodeModules?: boolean;\n\n /**\n * If set to `true`, it allows the workspace to resolve envs from node modules\n * installed in the workspace's `node_modules` directory.\n * the envs will be resolved from the node_modules of the env's root (workspace/node_modules/.bit_roots/{envId})\n * and if not found (usually when the env was hoisted to the root node_modules) then from the node_modules of the\n * workspace.\n * If not set or set to `false`, envs will only be resolved from the scope envs capsule.\n */\n resolveEnvsFromRoots?: boolean;\n\n /**\n * If set to `true`, bit will try to load aspects dependencies automatically.\n * even if the aspects dependencies are not configured in the workspace.jsonc root config.\n * for example having the aspect\n * main aspect\n * export class MainAspectMain {\n * ...\n * static dependencies = [MyDepAspect];\n * }\n * and the in the workspace.jsonc file:\n * {\n * ...\n * main-aspect: {}\n * }\n * when set to true, bit will try to load MyDepAspect automatically.\n */\n autoLoadAspectsDeps?: boolean;\n}\n"],"mappings":""}
|
|
@@ -15,6 +15,7 @@ export declare type WorkspaceLoadAspectsOptions = LoadAspectsOptions & {
|
|
|
15
15
|
useScopeAspectsCapsule?: boolean;
|
|
16
16
|
runSubscribers?: boolean;
|
|
17
17
|
skipDeps?: boolean;
|
|
18
|
+
resolveEnvsFromRoots?: boolean;
|
|
18
19
|
};
|
|
19
20
|
export declare type AspectPackage = {
|
|
20
21
|
packageName: string;
|
|
@@ -31,14 +32,16 @@ export declare class WorkspaceAspectsLoader {
|
|
|
31
32
|
private onAspectsResolveSlot;
|
|
32
33
|
private onRootAspectAddedSlot;
|
|
33
34
|
private resolveAspectsFromNodeModules;
|
|
35
|
+
private resolveEnvsFromRoots;
|
|
34
36
|
private consumer;
|
|
35
37
|
private resolvedInstalledAspects;
|
|
36
|
-
constructor(workspace: Workspace, scope: ScopeMain, aspectLoader: AspectLoaderMain, envs: EnvsMain, dependencyResolver: DependencyResolverMain, logger: Logger, harmony: Harmony, onAspectsResolveSlot: OnAspectsResolveSlot, onRootAspectAddedSlot: OnRootAspectAddedSlot, resolveAspectsFromNodeModules?: boolean);
|
|
38
|
+
constructor(workspace: Workspace, scope: ScopeMain, aspectLoader: AspectLoaderMain, envs: EnvsMain, dependencyResolver: DependencyResolverMain, logger: Logger, harmony: Harmony, onAspectsResolveSlot: OnAspectsResolveSlot, onRootAspectAddedSlot: OnRootAspectAddedSlot, resolveAspectsFromNodeModules?: boolean, resolveEnvsFromRoots?: boolean);
|
|
37
39
|
/**
|
|
38
40
|
* load aspects from the workspace and if not exists in the workspace, load from the node_modules.
|
|
39
41
|
* keep in mind that the graph may have circles.
|
|
40
42
|
*/
|
|
41
43
|
loadAspects(ids?: string[], throwOnError?: boolean, neededFor?: string, opts?: WorkspaceLoadAspectsOptions): Promise<string[]>;
|
|
44
|
+
private loadFromScopeAspectsCapsule;
|
|
42
45
|
private loadAspectDefsByOrder;
|
|
43
46
|
resolveAspects(runtimeName?: string, componentIds?: ComponentID[], opts?: ResolveAspectsOptions): Promise<AspectDefinition[]>;
|
|
44
47
|
private logFoundWorkspaceVsScope;
|
|
@@ -100,6 +103,8 @@ export declare class WorkspaceAspectsLoader {
|
|
|
100
103
|
* @returns
|
|
101
104
|
*/
|
|
102
105
|
private groupComponentsByWorkspaceExistence;
|
|
106
|
+
private groupComponentsByLoadFromRootComps;
|
|
107
|
+
private shouldLoadFromRootComps;
|
|
103
108
|
/**
|
|
104
109
|
* split the provided components into 2 groups, one which are workspace components and the other which are not.
|
|
105
110
|
* @param components
|
|
@@ -101,7 +101,7 @@ function _bitError() {
|
|
|
101
101
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
102
102
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
103
103
|
class WorkspaceAspectsLoader {
|
|
104
|
-
constructor(workspace, scope, aspectLoader, envs, dependencyResolver, logger, harmony, onAspectsResolveSlot, onRootAspectAddedSlot, resolveAspectsFromNodeModules = false) {
|
|
104
|
+
constructor(workspace, scope, aspectLoader, envs, dependencyResolver, logger, harmony, onAspectsResolveSlot, onRootAspectAddedSlot, resolveAspectsFromNodeModules = false, resolveEnvsFromRoots = false) {
|
|
105
105
|
this.workspace = workspace;
|
|
106
106
|
this.scope = scope;
|
|
107
107
|
this.aspectLoader = aspectLoader;
|
|
@@ -112,10 +112,13 @@ class WorkspaceAspectsLoader {
|
|
|
112
112
|
this.onAspectsResolveSlot = onAspectsResolveSlot;
|
|
113
113
|
this.onRootAspectAddedSlot = onRootAspectAddedSlot;
|
|
114
114
|
this.resolveAspectsFromNodeModules = resolveAspectsFromNodeModules;
|
|
115
|
+
this.resolveEnvsFromRoots = resolveEnvsFromRoots;
|
|
115
116
|
(0, _defineProperty2().default)(this, "consumer", void 0);
|
|
116
117
|
(0, _defineProperty2().default)(this, "resolvedInstalledAspects", void 0);
|
|
117
118
|
this.consumer = this.workspace.consumer;
|
|
118
119
|
this.resolvedInstalledAspects = new Map();
|
|
120
|
+
// Only enable this when root components is enabled as well
|
|
121
|
+
this.resolveEnvsFromRoots = this.resolveEnvsFromRoots && this.dependencyResolver.hasRootComponents();
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
/**
|
|
@@ -130,7 +133,8 @@ class WorkspaceAspectsLoader {
|
|
|
130
133
|
runSubscribers: true,
|
|
131
134
|
skipDeps: false,
|
|
132
135
|
hideMissingModuleError: !!this.workspace.inInstallContext,
|
|
133
|
-
ignoreErrors: false
|
|
136
|
+
ignoreErrors: false,
|
|
137
|
+
resolveEnvsFromRoots: this.resolveEnvsFromRoots
|
|
134
138
|
};
|
|
135
139
|
const mergedOpts = _objectSpread(_objectSpread({}, defaultOpts), opts);
|
|
136
140
|
|
|
@@ -148,7 +152,7 @@ needed-for: ${neededFor || '<unknown>'}. using opts: ${JSON.stringify(mergedOpts
|
|
|
148
152
|
const {
|
|
149
153
|
workspaceIds,
|
|
150
154
|
nonWorkspaceIds
|
|
151
|
-
} = await this.groupIdsByWorkspaceExistence(componentIds);
|
|
155
|
+
} = await this.groupIdsByWorkspaceExistence(componentIds, mergedOpts.resolveEnvsFromRoots);
|
|
152
156
|
this.logFoundWorkspaceVsScope(loggerPrefix, workspaceIds, nonWorkspaceIds);
|
|
153
157
|
let idsToLoadFromWs = componentIds;
|
|
154
158
|
let scopeAspectIds = [];
|
|
@@ -158,31 +162,11 @@ needed-for: ${neededFor || '<unknown>'}. using opts: ${JSON.stringify(mergedOpts
|
|
|
158
162
|
// like for the cloud app
|
|
159
163
|
// it should be removed once we fix the issues
|
|
160
164
|
if (!this.resolveAspectsFromNodeModules) {
|
|
161
|
-
|
|
162
|
-
mergedOpts.useScopeAspectsCapsule = true;
|
|
163
|
-
}
|
|
165
|
+
mergedOpts.useScopeAspectsCapsule = true;
|
|
164
166
|
}
|
|
165
167
|
if (mergedOpts.useScopeAspectsCapsule) {
|
|
166
168
|
idsToLoadFromWs = workspaceIds;
|
|
167
|
-
|
|
168
|
-
const nonWorkspaceIdsString = nonWorkspaceIds.map(id => id.toString());
|
|
169
|
-
try {
|
|
170
|
-
scopeAspectIds = await this.scope.loadAspects(nonWorkspaceIdsString, throwOnError, neededFor, currentLane || undefined, {
|
|
171
|
-
packageManagerConfigRootDir: this.workspace.path,
|
|
172
|
-
workspaceName: this.workspace.name
|
|
173
|
-
});
|
|
174
|
-
} catch (err) {
|
|
175
|
-
if (err instanceof _exceptions().ComponentNotFound) {
|
|
176
|
-
var _config$workspaceConf;
|
|
177
|
-
const config = this.harmony.get('teambit.harmony/config');
|
|
178
|
-
const configStr = JSON.stringify(((_config$workspaceConf = config.workspaceConfig) === null || _config$workspaceConf === void 0 ? void 0 : _config$workspaceConf.raw) || {});
|
|
179
|
-
if (configStr.includes(err.id)) {
|
|
180
|
-
throw new (_bitError().BitError)(`error: a component "${err.id}" was not found
|
|
181
|
-
your workspace.jsonc has this component-id set. you might want to remove/change it.`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
throw err;
|
|
185
|
-
}
|
|
169
|
+
scopeAspectIds = await this.loadFromScopeAspectsCapsule(nonWorkspaceIds, throwOnError, neededFor);
|
|
186
170
|
}
|
|
187
171
|
const aspectsDefs = await this.resolveAspects(undefined, idsToLoadFromWs, _objectSpread({
|
|
188
172
|
excludeCore: true,
|
|
@@ -210,6 +194,31 @@ needed-for: ${neededFor || '<unknown>'}. using opts: ${JSON.stringify(mergedOpts
|
|
|
210
194
|
const manifestIds = manifests.map(manifest => manifest.id);
|
|
211
195
|
return (0, _lodash().compact)(manifestIds.concat(scopeAspectIds));
|
|
212
196
|
}
|
|
197
|
+
async loadFromScopeAspectsCapsule(ids, throwOnError, neededFor) {
|
|
198
|
+
let scopeAspectIds = [];
|
|
199
|
+
const currentLane = await this.consumer.getCurrentLaneObject();
|
|
200
|
+
if (!ids.length) return [];
|
|
201
|
+
const nonWorkspaceIdsString = ids.map(id => id.toString());
|
|
202
|
+
try {
|
|
203
|
+
scopeAspectIds = await this.scope.loadAspects(nonWorkspaceIdsString, throwOnError, neededFor, currentLane || undefined, {
|
|
204
|
+
packageManagerConfigRootDir: this.workspace.path,
|
|
205
|
+
workspaceName: this.workspace.name
|
|
206
|
+
});
|
|
207
|
+
return scopeAspectIds;
|
|
208
|
+
} catch (err) {
|
|
209
|
+
if (err instanceof _exceptions().ComponentNotFound) {
|
|
210
|
+
var _config$workspaceConf;
|
|
211
|
+
const config = this.harmony.get('teambit.harmony/config');
|
|
212
|
+
const configStr = JSON.stringify(((_config$workspaceConf = config.workspaceConfig) === null || _config$workspaceConf === void 0 ? void 0 : _config$workspaceConf.raw) || {});
|
|
213
|
+
if (configStr.includes(err.id)) {
|
|
214
|
+
throw new (_bitError().BitError)(`error: a component "${err.id}" was not found
|
|
215
|
+
your workspace.jsonc has this component-id set. you might want to remove/change it.`);
|
|
216
|
+
}
|
|
217
|
+
return scopeAspectIds;
|
|
218
|
+
}
|
|
219
|
+
throw err;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
213
222
|
async loadAspectDefsByOrder(aspectsDefs, seeders, throwOnError, hideMissingModuleError, neededFor, runSubscribers = true) {
|
|
214
223
|
const {
|
|
215
224
|
nonWorkspaceDefs
|
|
@@ -247,7 +256,8 @@ needed-for: ${neededFor || '<unknown>'}. using opts: ${JSON.stringify(mergedOpts
|
|
|
247
256
|
requestedOnly: false,
|
|
248
257
|
filterByRuntime: true,
|
|
249
258
|
useScopeAspectsCapsule: false,
|
|
250
|
-
workspaceName: this.workspace.name
|
|
259
|
+
workspaceName: this.workspace.name,
|
|
260
|
+
resolveEnvsFromRoots: false
|
|
251
261
|
};
|
|
252
262
|
const mergedOpts = _objectSpread(_objectSpread({}, defaultOpts), opts);
|
|
253
263
|
const idsToResolve = componentIds ? componentIds.map(id => id.toString()) : this.harmony.extensionsIds;
|
|
@@ -273,15 +283,18 @@ needed-for: ${neededFor || '<unknown>'}. using opts: ${JSON.stringify(mergedOpts
|
|
|
273
283
|
const finalDefs = this.aspectLoader.filterAspectDefs(targetDefs, idsToFilter, runtimeName, mergedOpts);
|
|
274
284
|
return finalDefs;
|
|
275
285
|
}
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
286
|
+
const groupedByIsPlugin = (0, _lodash().groupBy)(components, component => {
|
|
287
|
+
return this.aspectLoader.hasPluginFiles(component);
|
|
288
|
+
});
|
|
289
|
+
const graph = await this.getAspectsGraphWithoutCore(groupedByIsPlugin.false, this.isAspect.bind(this));
|
|
290
|
+
const aspectsComponents = graph.nodes.map(node => node.attr).concat(groupedByIsPlugin.true || []);
|
|
291
|
+
this.logger.debug(`${loggerPrefix} found ${aspectsComponents.length} aspects in the aspects-graph`);
|
|
279
292
|
const {
|
|
280
293
|
workspaceComps,
|
|
281
294
|
nonWorkspaceComps
|
|
282
|
-
} = await this.groupComponentsByWorkspaceExistence(
|
|
295
|
+
} = await this.groupComponentsByWorkspaceExistence(aspectsComponents, mergedOpts.resolveEnvsFromRoots);
|
|
283
296
|
const workspaceCompsIds = workspaceComps.map(c => c.id);
|
|
284
|
-
const nonWorkspaceCompsIds =
|
|
297
|
+
const nonWorkspaceCompsIds = nonWorkspaceComps.map(c => c.id);
|
|
285
298
|
this.logFoundWorkspaceVsScope(loggerPrefix, workspaceCompsIds, nonWorkspaceCompsIds);
|
|
286
299
|
const stringIds = [];
|
|
287
300
|
const wsAspectDefs = await this.aspectLoader.resolveAspects(workspaceComps, this.getWorkspaceAspectResolver(stringIds, runtimeName));
|
|
@@ -542,7 +555,7 @@ needed-for: ${neededFor || '<unknown>'}. using opts: ${JSON.stringify(mergedOpts
|
|
|
542
555
|
* @param isAspect
|
|
543
556
|
* @returns
|
|
544
557
|
*/
|
|
545
|
-
async getAspectsGraphWithoutCore(components, isAspect) {
|
|
558
|
+
async getAspectsGraphWithoutCore(components = [], isAspect) {
|
|
546
559
|
const ids = components.map(component => component.id);
|
|
547
560
|
const coreAspectsStringIds = this.aspectLoader.getCoreAspectIds();
|
|
548
561
|
// TODO: @gilad it causes many issues we need to find a better solution. removed for now.
|
|
@@ -582,7 +595,8 @@ needed-for: ${neededFor || '<unknown>'}. using opts: ${JSON.stringify(mergedOpts
|
|
|
582
595
|
const defaultOpts = {
|
|
583
596
|
useScopeAspectsCapsule: true,
|
|
584
597
|
throwOnError: false,
|
|
585
|
-
hideMissingModuleError: !!this.workspace.inInstallContext
|
|
598
|
+
hideMissingModuleError: !!this.workspace.inInstallContext,
|
|
599
|
+
resolveEnvsFromRoots: this.resolveEnvsFromRoots
|
|
586
600
|
};
|
|
587
601
|
const mergedOpts = _objectSpread(_objectSpread({}, defaultOpts), opts);
|
|
588
602
|
const extensionsIdsP = extensions.map(async extensionEntry => {
|
|
@@ -637,18 +651,63 @@ your workspace.jsonc has this component-id set. you might want to remove/change
|
|
|
637
651
|
* @param components
|
|
638
652
|
* @returns
|
|
639
653
|
*/
|
|
640
|
-
async groupComponentsByWorkspaceExistence(components) {
|
|
641
|
-
|
|
642
|
-
|
|
654
|
+
async groupComponentsByWorkspaceExistence(components, resolveEnvsFromRoots) {
|
|
655
|
+
let workspaceComps = [];
|
|
656
|
+
let nonWorkspaceComps = [];
|
|
643
657
|
await Promise.all(components.map(async component => {
|
|
644
658
|
const existOnWorkspace = await this.workspace.hasId(component.id);
|
|
645
659
|
existOnWorkspace ? workspaceComps.push(component) : nonWorkspaceComps.push(component);
|
|
646
660
|
}));
|
|
661
|
+
if (resolveEnvsFromRoots) {
|
|
662
|
+
const {
|
|
663
|
+
rootComps,
|
|
664
|
+
nonRootComps
|
|
665
|
+
} = await this.groupComponentsByLoadFromRootComps(nonWorkspaceComps);
|
|
666
|
+
workspaceComps = workspaceComps.concat(rootComps);
|
|
667
|
+
nonWorkspaceComps = nonRootComps;
|
|
668
|
+
}
|
|
647
669
|
return {
|
|
648
670
|
workspaceComps,
|
|
649
671
|
nonWorkspaceComps
|
|
650
672
|
};
|
|
651
673
|
}
|
|
674
|
+
async groupComponentsByLoadFromRootComps(components) {
|
|
675
|
+
const rootComps = [];
|
|
676
|
+
const nonRootComps = [];
|
|
677
|
+
await Promise.all(components.map(async component => {
|
|
678
|
+
const shouldLoadFromRootComps = await this.shouldLoadFromRootComps(component);
|
|
679
|
+
if (shouldLoadFromRootComps) {
|
|
680
|
+
rootComps.push(component);
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
nonRootComps.push(component);
|
|
684
|
+
}));
|
|
685
|
+
return {
|
|
686
|
+
rootComps,
|
|
687
|
+
nonRootComps
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
async shouldLoadFromRootComps(component) {
|
|
691
|
+
const rootDir = this.workspace.getComponentPackagePath(component);
|
|
692
|
+
const rootDirExist = await _fsExtra().default.pathExists(rootDir);
|
|
693
|
+
const aspectFilePath = await this.aspectLoader.getAspectFilePath(component, rootDir);
|
|
694
|
+
const aspectFilePathExist = aspectFilePath ? await _fsExtra().default.pathExists(aspectFilePath) : false;
|
|
695
|
+
const pluginFiles = await this.aspectLoader.getPluginFiles(component, rootDir);
|
|
696
|
+
|
|
697
|
+
// checking that we have the root dir (this means it's an aspect that needs to be loaded from there)
|
|
698
|
+
// and validate that localPathExist so we can
|
|
699
|
+
// really load the component from that path (if it's there it means that it's an env)
|
|
700
|
+
if (rootDirExist && (aspectFilePathExist || pluginFiles.length)) {
|
|
701
|
+
return true;
|
|
702
|
+
}
|
|
703
|
+
// If the component has env.jsonc we want to list it to be loaded from the root folder
|
|
704
|
+
// even if it's not there yet
|
|
705
|
+
// in that case we will fail to load it, and the user will need to run bit install
|
|
706
|
+
if (this.envs.hasEnvManifest(component)) {
|
|
707
|
+
return true;
|
|
708
|
+
}
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
652
711
|
|
|
653
712
|
/**
|
|
654
713
|
* split the provided components into 2 groups, one which are workspace components and the other which are not.
|
|
@@ -662,20 +721,37 @@ your workspace.jsonc has this component-id set. you might want to remove/change
|
|
|
662
721
|
var _aspectDef$component;
|
|
663
722
|
const id = (_aspectDef$component = aspectDef.component) === null || _aspectDef$component === void 0 ? void 0 : _aspectDef$component.id;
|
|
664
723
|
const existOnWorkspace = id ? await this.workspace.hasId(id) : true;
|
|
665
|
-
|
|
724
|
+
if (existOnWorkspace) {
|
|
725
|
+
workspaceDefs.push(aspectDef);
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
const shouldLoadFromRootComps = aspectDef.component ? await this.shouldLoadFromRootComps(aspectDef.component) : undefined;
|
|
729
|
+
if (shouldLoadFromRootComps) {
|
|
730
|
+
workspaceDefs.push(aspectDef);
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
nonWorkspaceDefs.push(aspectDef);
|
|
666
734
|
}));
|
|
667
735
|
return {
|
|
668
736
|
workspaceDefs,
|
|
669
737
|
nonWorkspaceDefs
|
|
670
738
|
};
|
|
671
739
|
}
|
|
672
|
-
async groupIdsByWorkspaceExistence(ids) {
|
|
673
|
-
|
|
674
|
-
|
|
740
|
+
async groupIdsByWorkspaceExistence(ids, resolveEnvsFromRoots) {
|
|
741
|
+
let workspaceIds = [];
|
|
742
|
+
let nonWorkspaceIds = [];
|
|
675
743
|
await Promise.all(ids.map(async id => {
|
|
676
744
|
const existOnWorkspace = await this.workspace.hasId(id);
|
|
677
745
|
existOnWorkspace ? workspaceIds.push(id) : nonWorkspaceIds.push(id);
|
|
678
746
|
}));
|
|
747
|
+
// We need to bring the components in order to really group them with taking the root comps into account
|
|
748
|
+
const scopeComponents = await this.importAndGetAspects(nonWorkspaceIds);
|
|
749
|
+
const {
|
|
750
|
+
nonWorkspaceComps,
|
|
751
|
+
workspaceComps
|
|
752
|
+
} = await this.groupComponentsByWorkspaceExistence(scopeComponents, resolveEnvsFromRoots);
|
|
753
|
+
workspaceIds = workspaceIds.concat(workspaceComps.map(c => c.id));
|
|
754
|
+
nonWorkspaceIds = nonWorkspaceComps.map(c => c.id);
|
|
679
755
|
return {
|
|
680
756
|
workspaceIds,
|
|
681
757
|
nonWorkspaceIds
|