Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix, show a descriptive error when "teambit.workspace/workspace" is missing from workspace.jsonc file #8585

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion scopes/harmony/bit/load-bit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { VERSION_DELIMITER } from '@teambit/legacy-bit-id';
import { getConsumerInfo, loadConsumer } from '@teambit/legacy/dist/consumer';
import { ConsumerInfo } from '@teambit/legacy/dist/consumer/consumer-locator';
import BitMap from '@teambit/legacy/dist/consumer/bit-map';
import { BitError } from '@teambit/bit-error';
import ComponentLoader from '@teambit/legacy/dist/consumer/component/component-loader';
import ComponentConfig from '@teambit/legacy/dist/consumer/config/component-config';
import ComponentOverrides from '@teambit/legacy/dist/consumer/config/component-overrides';
Expand Down Expand Up @@ -121,7 +122,11 @@ function attachVersionsFromBitmap(config: Config, consumerInfo: ConsumerInfo): C
// Do nothing here, invalid bitmaps will be handled later
// eslint-disable-next-line no-empty
} catch (e: any) {}
const defaultScope = rawConfig['teambit.workspace/workspace'].defaultScope;
const wsConfig = rawConfig['teambit.workspace/workspace'];
if (!wsConfig) throw new BitError('workspace.jsonc is missing the "teambit.workspace/workspace" property');
const defaultScope = wsConfig.defaultScope;
if (!defaultScope)
throw new BitError('workspace.jsonc is missing the "defaultScope" property in "teambit.workspace/workspace"');
const allBitmapIds = Object.keys(parsedBitMap).map((id) =>
BitMap.getComponentIdFromComponentJson(id, parsedBitMap[id], defaultScope)
);
Expand Down