Skip to content

Commit

Permalink
Fixes TypeScript 3.5 compatibility (yarnpkg#1061)
Browse files Browse the repository at this point in the history
* Updates the patches

* Adds tests

* Fixes versions

* Updates the cache
  • Loading branch information
arcanis authored Mar 11, 2020
1 parent 864eb1f commit 35c7558
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 57 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/e2e-typescript-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
paths:
- .github/workflows/e2e-typescript-workflow.yml
- packages/plugin-compat/sources/patches/typescript.patch.ts
- scripts/e2e-setup-ci.sh

name: 'E2E TypeScript'
Expand All @@ -27,6 +28,17 @@ jobs:
run: |
node ./scripts/run-yarn.js build:cli
- name: 'Installing all versions of TS'
run: |
source scripts/e2e-setup-ci.sh
yarn init -p
yarn add \
v35@npm:[email protected] \
v36@npm:[email protected] \
v37@npm:[email protected] \
v38@npm:[email protected]
- name: 'Running the integration test'
run: |
source scripts/e2e-setup-ci.sh
Expand Down
76 changes: 38 additions & 38 deletions .pnp.js

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions .yarn/versions/e34a429d.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
releases:
"@yarnpkg/cli": prerelease
"@yarnpkg/plugin-compat": prerelease

declined:
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-node-modules"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
5 changes: 3 additions & 2 deletions packages/plugin-compat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ This plugin is included by default in Yarn.

## Compatibility Features

- [`typescript`](https://yarnpkg.com/package?typescript): Auto-merge of [#35206](https://github.com/microsoft/TypeScript/pull/35206)
- [`resolve`](https://yarnpkg.com/package/?resolve): Implements [`normalize-options.js`](https://github.com/browserify/resolve/pull/174)
- Various [extensions](/configuration/yarnrc#packageExtensions) are enabled by default (full list [here](https://github.com/yarnpkg/berry/blob/master/packages/plugin-compat/sources/extensions.ts))
- [`typescript`](/package/typescript): Auto-merge of [#35206](https://github.com/microsoft/TypeScript/pull/35206)
- [`resolve`](/package/resolve): Implements [`normalize-options.js`](https://github.com/browserify/resolve/pull/174)
41 changes: 27 additions & 14 deletions packages/plugin-compat/extra/typescript/gen-typescript-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ set -ex
THIS_DIR=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)
TEMP_DIR="$(mktemp -d)"

HASHES=(
"426f5a7" ">=3 <3.6"
"bcb6dbf" ">3.6"
)

git clone [email protected]:arcanis/typescript "$TEMP_DIR"/clone

mkdir -p "$TEMP_DIR"/orig
Expand All @@ -11,36 +16,44 @@ mkdir -p "$TEMP_DIR"/patched
reset-git() {
git checkout .
git clean -df

yarn
}

cd "$TEMP_DIR"/clone

yarn

reset-git
git checkout master

yarn gulp local LKG
cp -r lib "$TEMP_DIR"/orig/

reset-git
git checkout mael/pnp
while [[ ${#HASHES[@]} -gt 0 ]]; do
HASH="${HASHES[0]}"
RANGE="${HASHES[1]}"
HASHES=("${HASHES[@]:2}")

yarn gulp local LKG
cp -r lib/ "$TEMP_DIR"/patched/
reset-git
git checkout "$HASH"

yarn gulp local LKG
cp -r lib/ "$TEMP_DIR"/patched/

PATCHFILE="$THIS_DIR"/../../sources/patches/typescript.patch.ts
rm -f "$PATCHFILE" && touch "$PATCHFILE"
PATCHFILE="$THIS_DIR"/../../sources/patches/typescript.patch.ts
rm -f "$PATCHFILE" && touch "$PATCHFILE"

git diff --no-index "$TEMP_DIR"/orig "$TEMP_DIR"/patched \
| perl -p -e"s#^--- #semver exclusivity $RANGE\n--- #" \
| perl -p -e"s#$TEMP_DIR/orig##" \
| perl -p -e"s#$TEMP_DIR/patched##" \
| perl -p -e"s#__spreadArrays#[].concat#" \
>> "$TEMP_DIR"/patch.tmp || true
done

echo 'export const patch =' \
>> "$PATCHFILE"
git diff --no-index "$TEMP_DIR"/orig "$TEMP_DIR"/patched \
| perl -p -e"s#^--- #semver exclusivity >=3\n--- #" \
| perl -p -e"s#$TEMP_DIR/orig##" \
| perl -p -e"s#$TEMP_DIR/patched##" \
| perl -p -e"s#__spreadArrays#[].concat#" \
> "$TEMP_DIR"/patch.tmp || true
node "$THIS_DIR"/../jsonEscape.js < "$TEMP_DIR"/patch.tmp \
>> "$PATCHFILE"
echo ';' \
>> "$PATCHFILE"

2 changes: 1 addition & 1 deletion packages/plugin-compat/sources/patches/typescript.patch.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24510,7 +24510,7 @@ typescript@^3.7.5:

"typescript@patch:typescript@*#builtin<compat/typescript>":
version: 3.7.4
resolution: "typescript@patch:typescript@npm%3A3.7.4#builtin<compat/typescript>::version=3.7.4&hash=3ac2d9"
resolution: "typescript@patch:typescript@npm%3A3.7.4#builtin<compat/typescript>::version=3.7.4&hash=270b6c"
bin:
tsc: ./bin/tsc
tsserver: ./bin/tsserver
Expand All @@ -24520,7 +24520,7 @@ typescript@^3.7.5:

"typescript@patch:typescript@^3.7.5#builtin<compat/typescript>":
version: 3.7.5
resolution: "typescript@patch:typescript@npm%3A3.7.5#builtin<compat/typescript>::version=3.7.5&hash=3ac2d9"
resolution: "typescript@patch:typescript@npm%3A3.7.5#builtin<compat/typescript>::version=3.7.5&hash=270b6c"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
Expand Down

0 comments on commit 35c7558

Please sign in to comment.