-
Notifications
You must be signed in to change notification settings - Fork 954
TS6 compatibility fixes + @teambit/harmony 0.4.12 #10466
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
base: master
Are you sure you want to change the base?
Changes from all commits
4387aaa
d1a01f7
03ef52b
e751234
6101f4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { expect } from 'chai'; | ||
| import { ComponentID } from '@teambit/component-id'; | ||
| import { EnvsAspect } from '@teambit/envs'; | ||
| import { ExtensionDataList } from '@teambit/legacy.extension-data'; | ||
| import type { Logger } from '@teambit/logger'; | ||
| import { ComponentConfigMerger } from './component-config-merger'; | ||
|
|
||
| const noopLogger = { debug() {}, trace() {} } as unknown as Logger; | ||
|
|
||
| describe('ComponentConfigMerger', () => { | ||
| describe('env changed on "other" while the current env is a workspace component', () => { | ||
| // Reproduces the `bit ci pr` config-sync failure: the lane still uses a workspace env (so | ||
| // envStrategy bails out with "keep the current env"), and main migrated the component onto a | ||
| // different EXTERNAL env. The generic aspect merge must NOT copy main's `teambit.envs/envs` | ||
| // config verbatim — that config only holds the env id without its version, so leaking it would | ||
| // produce an unversioned external env and crash the snap with ExternalEnvWithoutVersion. | ||
| let mergedConfig: Record<string, any>; | ||
| before(() => { | ||
| const wsEnv = 'my-scope.envs/ws-env'; | ||
| const extEnv = 'other-scope.envs/ext-env'; | ||
| // current & base: component uses the workspace env `wsEnv`. | ||
| const current = ExtensionDataList.fromConfigObject({ | ||
| [EnvsAspect.id]: { env: wsEnv }, | ||
| [`${wsEnv}@0.0.1`]: {}, | ||
| }); | ||
| const base = ExtensionDataList.fromConfigObject({ | ||
| [EnvsAspect.id]: { env: wsEnv }, | ||
| [`${wsEnv}@0.0.1`]: {}, | ||
| }); | ||
| // other (main): component migrated onto the external env `extEnv`. As stored in a committed | ||
| // version, `teambit.envs/envs.config.env` carries the id WITHOUT a version; the version lives | ||
| // only in the separate env-aspect entry. | ||
| const other = ExtensionDataList.fromConfigObject({ | ||
| [EnvsAspect.id]: { env: extEnv }, | ||
| [`${extEnv}@1.0.0`]: {}, | ||
| }); | ||
| // `wsEnv` is part of the workspace — this is what makes envStrategy decline. | ||
| const workspaceIds = [ComponentID.fromString(`${wsEnv}@0.0.1`)]; | ||
| const merger = new ComponentConfigMerger( | ||
| 'my-scope/some-comp', | ||
| workspaceIds, | ||
| undefined, | ||
| current, | ||
| base, | ||
| other, | ||
| 'lane', | ||
| 'main', | ||
| noopLogger, | ||
| 'ours' | ||
| ); | ||
| mergedConfig = merger.merge().getSuccessfullyMergedConfig(); | ||
| }); | ||
| it('should NOT sync teambit.envs/envs from the generic aspect merge (no unversioned env leak)', () => { | ||
| expect( | ||
| mergedConfig[EnvsAspect.id], | ||
| `expected no env to be synced, got: ${JSON.stringify(mergedConfig[EnvsAspect.id])}` | ||
| ).to.be.undefined; | ||
| }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script validates that the @teambit/harmony version is consistent across | ||
| # workspace.jsonc and the two bundle-install overrides in .circleci/config.yml. | ||
| # | ||
| # Why this can drift: workspace.jsonc pins harmony for the dev workspace build, | ||
| # while .circleci/config.yml re-pins it via `pnpm.overrides.@teambit/harmony` | ||
| # for the freshly-installed published `@teambit/bit` bundle used by e2e. Both | ||
| # must reference the SAME harmony version so e2e exercises what the workspace | ||
| # built with. It's easy to bump one and forget the other. | ||
| # | ||
| # Usage: | ||
| # ./scripts/check-harmony-version-sync.sh # validate (used by CI); exits 1 on mismatch | ||
| # ./scripts/check-harmony-version-sync.sh --fix # rewrite the config.yml overrides to match workspace.jsonc | ||
|
|
||
| set -e | ||
|
|
||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| YELLOW='\033[1;33m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| FIX=false | ||
| if [ "${1:-}" = "--fix" ]; then | ||
| FIX=true | ||
| fi | ||
|
|
||
| WORKSPACE_FILE="workspace.jsonc" | ||
| CONFIG_FILE=".circleci/config.yml" | ||
|
|
||
| echo "Checking @teambit/harmony version synchronization..." | ||
|
|
||
| # Source of truth: the harmony pins in workspace.jsonc. There are two (the | ||
| # dependency policy and the dependency-resolver overrides); they must agree. | ||
| WS_VERSIONS=$(grep -oE '"@teambit/harmony": *"[0-9]+\.[0-9]+\.[0-9]+"' "$WORKSPACE_FILE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | sort -u) | ||
| WS_COUNT=$(echo "$WS_VERSIONS" | grep -c .) | ||
|
|
||
| if [ -z "$WS_VERSIONS" ]; then | ||
| echo -e "${RED}✗ ERROR: no @teambit/harmony pin found in ${WORKSPACE_FILE}${NC}" | ||
| exit 1 | ||
| fi | ||
|
Comment on lines
+16
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Set -e aborts counting In check-harmony-version-sync.sh, WS_COUNT is computed using grep -c . while set -e is enabled; when WS_VERSIONS is empty (e.g. the grep patterns don’t match), grep exits non-zero and the script terminates before reaching the explicit “no @teambit/harmony pin found” error handling. This makes the new CI step fail with less actionable output than intended for that edge case. Agent Prompt
|
||
|
|
||
| if [ "$WS_COUNT" -ne 1 ]; then | ||
| echo -e "${RED}✗ ERROR: ${WORKSPACE_FILE} has inconsistent @teambit/harmony pins:${NC}" | ||
| echo "$WS_VERSIONS" | sed 's/^/ /' | ||
| echo -e "${YELLOW}Fix workspace.jsonc first so all @teambit/harmony pins match, then re-run.${NC}" | ||
|
Comment on lines
+18
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Hardcoded ansi + ✓/✗ output scripts/check-harmony-version-sync.sh introduces hardcoded ANSI color escape sequences and Unicode symbols (✓/✗) in CLI output. This violates the requirement to avoid ad-hoc styling/symbols and instead use the shared CLI output formatting toolkit for consistent output. Agent Prompt
|
||
| exit 1 | ||
| fi | ||
|
|
||
| EXPECTED="$WS_VERSIONS" | ||
| echo "Found @teambit/harmony in ${WORKSPACE_FILE}: $EXPECTED" | ||
|
|
||
| # The config.yml overrides look like: | ||
| # pnpm.overrides.@teambit/harmony" --values "0.4.12" | ||
| CONFIG_VERSIONS=$(grep -oE 'pnpm\.overrides\.@teambit/harmony" --values "[0-9]+\.[0-9]+\.[0-9]+"' "$CONFIG_FILE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | sort -u) | ||
|
|
||
|
Comment on lines
+33
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Strict harmony version regex scripts/check-harmony-version-sync.sh only recognizes @teambit/harmony pins that match an exact numeric "x.y.z" regex, so pins like "^0.4.12" or "0.4.13-rc.1" will be treated as missing/mismatched and fail the new CI step. This can unexpectedly block future bumps if the pinning format changes (ranges/prereleases). Agent Prompt
|
||
| if [ -z "$CONFIG_VERSIONS" ]; then | ||
| echo -e "${RED}✗ ERROR: no 'pnpm.overrides.@teambit/harmony' override found in ${CONFIG_FILE}${NC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$CONFIG_VERSIONS" = "$EXPECTED" ]; then | ||
| echo -e "${GREEN}✓ config.yml overrides match: @teambit/harmony@${EXPECTED}${NC}" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Mismatch. | ||
| if [ "$FIX" = true ]; then | ||
| # Rewrite every harmony override version in config.yml to EXPECTED. | ||
| # Temp file next to the target (explicit template for BSD/macOS portability) | ||
| # so the final mv is an atomic same-filesystem rename. | ||
| TMP=$(mktemp "${CONFIG_FILE}.XXXXXX") | ||
| trap 'rm -f "$TMP"' EXIT | ||
| sed -E "s|(pnpm\.overrides\.@teambit/harmony\" --values \")[0-9]+\.[0-9]+\.[0-9]+(\")|\1${EXPECTED}\2|g" "$CONFIG_FILE" > "$TMP" | ||
| mv "$TMP" "$CONFIG_FILE" | ||
|
|
||
| NEW_VERSIONS=$(grep -oE 'pnpm\.overrides\.@teambit/harmony" --values "[0-9]+\.[0-9]+\.[0-9]+"' "$CONFIG_FILE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | sort -u) | ||
| if [ "$NEW_VERSIONS" = "$EXPECTED" ]; then | ||
| echo -e "${GREEN}✓ Updated @teambit/harmony overrides in ${CONFIG_FILE} to ${EXPECTED}${NC}" | ||
| exit 0 | ||
| fi | ||
| echo -e "${RED}✗ --fix failed to update overrides in ${CONFIG_FILE}${NC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo -e "${RED}✗ ERROR: @teambit/harmony version mismatch!${NC}" | ||
| echo -e "${YELLOW}${WORKSPACE_FILE} has @teambit/harmony@${EXPECTED}, but ${CONFIG_FILE} has:${NC}" | ||
| echo "$CONFIG_VERSIONS" | sed 's/^/ /' | ||
| echo "" | ||
| echo -e "${YELLOW}Run: ./scripts/check-harmony-version-sync.sh --fix${NC}" | ||
| exit 1 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Broken env lane check
🐞 Bug≡ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools