Skip to content

Commit

Permalink
feat(compat): update patch for typescript 4.4 (#3297)
Browse files Browse the repository at this point in the history
* fix(compat): remove trailing slash

* fix(compat): update patch for 4.4

* test: add testcase

* chore: versions

* fix: handle references that doesn't point to a package root

* fix: backport references fix to 4.2

* chore: dedupe

* fix: avoid direct requires to `pnpapi`

* chore: reuse files in validation

* chore: update to `4.4.2`

There was no conflict but updated the patch either way
  • Loading branch information
merceyz authored Aug 31, 2021
1 parent 2021f47 commit ffe1a64
Show file tree
Hide file tree
Showing 34 changed files with 3,427 additions and 455 deletions.
230 changes: 127 additions & 103 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion .yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript",
"version": "4.3.2-sdk",
"version": "4.4.1-rc-sdk",
"main": "./lib/typescript.js",
"type": "commonjs"
}
25 changes: 25 additions & 0 deletions .yarn/versions/93771db7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
releases:
"@yarnpkg/cli": minor
"@yarnpkg/plugin-compat": minor

This comment has been minimized.

Copy link
@arcanis

arcanis Sep 3, 2021

Member

Note for next time: probably fine to mark them patch for TS upgrades


declined:
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-nm"
- "@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"
- vscode-zipfs
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
- "@yarnpkg/pnp"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"jest-junit": "^10.0.0",
"micromatch": "^4.0.2",
"tslib": "^1.13.0",
"typescript": "^4.3.2"
"typescript": "^4.4.2"
},
"resolutions": {
"yoga-layout-prebuilt": "patch:[email protected]#./.yarn/patches/yoga-layout-prebuilt.patch"
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"typedoc": "next",
"typedoc-neo-theme": "^1.0.7",
"typedoc-plugin-yarn": "portal:./typedoc-plugin-yarn",
"typescript": "^4.3.2",
"typescript": "^4.4.2",
"unescape-html": "^1.1.0",
"unfetch": "^4.1.0",
"unified": "^7.1.0",
Expand Down
132 changes: 78 additions & 54 deletions packages/plugin-compat/extra/typescript/gen-typescript-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,71 @@ const IGNORED_VERSIONS = new Set([
`3.3.3333`,
]);

const SLICES = [{
from: `5d50de3`,
to: `426f5a7`,
onto: `e39bdc3`,
range: `>=3.2 <3.5`,
}, {
from: `5d50de3`,
to: `426f5a7`,
onto: `cf7b2d4`,
range: `>=3.5 <=3.6`,
}, {
from: `5d50de3`,
to: `426f5a7`,
onto: `cda54b8`,
range: `>3.6 <3.7`,
}, {
from: `5d50de3`,
to: `2f85932`,
onto: `e39bdc3`,
range: `>=3.7 <3.9`,
}, {
from: `5d50de3`,
to: `3af06df`,
onto: `551f0dd`,
range: `>=3.9 <4.0`,
}, {
from: `6dbdd2f`,
to: `6dbdd2f`,
onto: `56865f7`,
range: `>=4.0 <4.1`,
}, {
from: `746d79b`,
to: `746d79b`,
onto: `69972a3`,
range: `>=4.1 <4.2`,
}, {
from: `8e0e870`,
to: `58bf162`,
onto: `bfc55b5`,
range: `>=4.2 <4.3`,
}, {
from: `ef7f019`,
to: `ef7f019`,
onto: `28e3e6f`,
range: `>=4.3`,
}];
const SLICES = [
{
from: `5d50de3`,
to: `426f5a7`,
onto: `e39bdc3`,
range: `>=3.2 <3.5`,
},
{
from: `5d50de3`,
to: `426f5a7`,
onto: `cf7b2d4`,
range: `>=3.5 <=3.6`,
},
{
from: `5d50de3`,
to: `426f5a7`,
onto: `cda54b8`,
range: `>3.6 <3.7`,
},
{
from: `5d50de3`,
to: `2f85932`,
onto: `e39bdc3`,
range: `>=3.7 <3.9`,
},
{
from: `5d50de3`,
to: `3af06df`,
onto: `551f0dd`,
range: `>=3.9 <4.0`,
},
{
from: `6dbdd2f`,
to: `6dbdd2f`,
onto: `56865f7`,
range: `>=4.0 <4.1`,
},
{
from: `746d79b`,
to: `746d79b`,
onto: `69972a3`,
range: `>=4.1 <4.2`,
},
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.2
{
from: `8e0e8703b9c95013aec7819e4593d099cdf7763a`,
to: `545d5a8c5409dac447a668d4e7d315702fd115d6`,
onto: `bfc55b5762443c37ecdef08a3b5a4e057b4d1e85`,
range: `>=4.2 <4.3`,
},
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.3
{
from: `530aad19e4ac19d35cb6b200168c91ce86cb0050`,
to: `6d7d4d2ce0df8e65a2c86a20c014c053ef530ea3`,
onto: `28e3e6ff2f49f1dbf06d31809ec73dbe42f1aa63`,
range: `>=4.3 <4.4`,
},
// https://github.com/merceyz/TypeScript/tree/merceyz/pnp-4.4
{
from: `793bfe32745bf6797924354b0fd5be62cf01950c`,
to: `88a10595c32309fc26eb4a7f5a858d98e883dae0`,
onto: `a10409ccaa3604790dc45f52ef0402eb49015dcf`,
range: `>=4.4`,
},
];

async function fetch(url) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -172,6 +191,7 @@ async function cloneRepository() {
if (!fs.existsSync(TS_REPO)) {
await execFile(`git`, [`clone`, `https://github.com/arcanis/typescript`, TS_REPO]);
await execFile(`git`, [`remote`, `add`, `upstream`, `https://github.com/microsoft/typescript`], TS_REPO_SPAWN);
await execFile(`git`, [`remote`, `add`, `upstream2`, `https://github.com/merceyz/typescript`], TS_REPO_SPAWN);
}

try {
Expand All @@ -183,6 +203,7 @@ async function cloneRepository() {

await execFile(`git`, [`fetch`, `origin`], TS_REPO_SPAWN);
await execFile(`git`, [`fetch`, `upstream`], TS_REPO_SPAWN);
await execFile(`git`, [`fetch`, `upstream2`], TS_REPO_SPAWN);
}

async function resetGit(hash) {
Expand Down Expand Up @@ -267,21 +288,24 @@ async function run({from, to, onto, range}) {
}

async function validate(version, patchFile) {
const code = Math.floor(Math.random() * 0x100000000).toString(16).padStart(8, `0`);
const tmpDir = path.join(TMP_DIR, `${code}`);

const data = await fetch(`https://registry.yarnpkg.com/typescript/-/typescript-${version}.tgz`);
const tarball = path.join(tmpDir, `typescript.tgz`);
const tmpDir = path.join(TMP_DIR, `v${version}`);
const tarball = path.join(tmpDir, `package.tgz`);

await fs.promises.mkdir(tmpDir, {recursive: true});
await fs.promises.writeFile(tarball, data);

if (!fs.existsSync(tarball)) {
const data = await fetch(`https://registry.yarnpkg.com/typescript/-/typescript-${version}.tgz`);
await fs.promises.writeFile(tarball, data);
}

if (!fs.existsSync(path.join(tmpDir, `package`)))
await execFile(`tar`, [`xvf`, tarball], {cwd: tmpDir});

let patch = await fs.promises.readFile(patchFile, `utf8`);
patch = patch.replace(/^semver .*\n/gm, ``);
await fs.promises.writeFile(path.join(tmpDir, `patch.diff`), patch);

await execFile(`tar`, [`xvf`, tarball], {cwd: tmpDir});
await execFile(`git`, [`apply`, `../patch.diff`], {cwd: path.join(tmpDir, `package`)});
await execFile(`git`, [`apply`, `--check`, `../patch.diff`], {cwd: path.join(tmpDir, `package`)});
}

async function main() {
Expand Down
Loading

0 comments on commit ffe1a64

Please sign in to comment.