Skip to content

Commit

Permalink
build: migrate to yarn v4 (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Jan 2, 2024
1 parent 10bcd7d commit 25bd7fb
Show file tree
Hide file tree
Showing 18 changed files with 16,636 additions and 11,829 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Enable Corepack
run: corepack enable

- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: yarn
env:
# https://github.com/actions/setup-node/issues/531#issuecomment-1819151412
SKIP_YARN_COREPACK_CHECK: 1

- name: Install Dependencies
run: yarn --frozen-lockfile
run: yarn --immutable
env:
SKIP_YARN_COREPACK_CHECK: 1

- name: Build, Lint and Test
run: |
Expand All @@ -38,6 +46,7 @@ jobs:
env:
EFF_NO_LINK_RULES: true
PARSER_NO_WATCH: true
SKIP_YARN_COREPACK_CHECK: 1

- name: Codecov
uses: codecov/codecov-action@v3
13 changes: 6 additions & 7 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: 'CodeQL'
name: CodeQL

on:
push:
branches: ['master']
pull_request:
branches: ['master']
schedule:
- cron: '41 19 * * 6'

Expand All @@ -20,22 +18,23 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [javascript]
language:
- javascript

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: '/language:${{ matrix.language }}'
10 changes: 8 additions & 2 deletions .github/workflows/pkg-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
- name: Enable Corepack
run: corepack enable

- name: Setup Node.js LTS
uses: actions/setup-node@v4
with:
node-version: 16
cache: yarn
env:
# https://github.com/actions/setup-node/issues/531#issuecomment-1819151412
SKIP_YARN_COREPACK_CHECK: 1

- name: Package Size Report
uses: pkg-size/action@v1
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,38 @@ jobs:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 16
uses: actions/setup-node@v3
- name: Enable Corepack
run: corepack enable

- name: Setup Node.js LTS
uses: actions/setup-node@v4
with:
node-version: 16
cache: yarn
env:
# https://github.com/actions/setup-node/issues/531#issuecomment-1819151412
SKIP_YARN_COREPACK_CHECK: 1

- name: Install Dependencies
run: yarn --frozen-lockfile
run: yarn --immutable
env:
SKIP_YARN_COREPACK_CHECK: 1

# required for linting before commit
- name: Build
run: yarn build
env:
SKIP_YARN_COREPACK_CHECK: 1

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release:only
commit: 'chore: release package(s)'
title: 'chore: release package(s)'
publish: yarn release:only
version: yarn run version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
SKIP_YARN_COREPACK_CHECK: 1
1 change: 1 addition & 0 deletions .yarn/plugins/plugin-prepare-lifecycle.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports={name:"plugin-prepare-lifecycle",factory:e=>({hooks:{afterAllInstalled(r){if(!r.topLevelWorkspace.manifest.scripts.get("prepare"))return;e("@yarnpkg/shell").execute("yarn prepare")}}})};
6 changes: 6 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
nodeLinker: node-modules

plugins:
- checksum: 37b2361b1502b2054e6779788c0e9bdd6a90ce49852a8cad2feda79b0614ec94f06fb6e78951f5f95429c610d7934dd077caa47413a0227378a102c55161616d
path: .yarn/plugins/plugin-prepare-lifecycle.cjs
spec: "https://github.com/un-es/yarn-plugin-prepare-lifecycle/releases/download/v0.0.1/index.js"
59 changes: 35 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,54 @@
"workspaces": [
"packages/*"
],
"packageManager": "yarn@1.22.19",
"packageManager": "yarn@4.0.2",
"scripts": {
"build": "run-p build:*",
"build": "run-p 'build:*'",
"build:r": "r -f es2015",
"build:ts": "tsc -b",
"clean": "rimraf packages/*/{lib,*.tsbuildinfo}",
"lint": "run-p lint:*",
"clean": "rimraf --glob 'packages/*/{lib,*.tsbuildinfo}'",
"lint": "yarn build && run-p 'lint:*'",
"lint:es": "eslint . --cache -f friendly",
"lint:tsc": "tsc --noEmit",
"prelint": "yarn build",
"prepare": "patch-package && simple-git-hooks && yarn-deduplicate --strategy fewer || exit 0",
"prerelease": "yarn build",
"release": "yarn release:only",
"release:only": "changeset publish --tag release-v2",
"test": "jest",
"typecov": "type-coverage"
"prepare": "patch-package && simple-git-hooks",
"release": "run-s build release:only",
"release:only": "changeset publish",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
"typecov": "type-coverage",
"version": "changeset version && yarn --no-immutable"
},
"devDependencies": {
"@1stg/lib-config": "^12.0.1",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@1stg/common-config": "^9.0.1",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@commitlint/cli": "^18.4.3",
"@pkgr/rollup": "^5.0.0",
"@types/acorn": "^6.0.0",
"@types/eslint": "^8.56.0",
"@types/eslint-plugin-markdown": "^2.0.0",
"@types/jest": "^29.5.3",
"@types/node": "^20.4.6",
"@types/react": "^18.2.18",
"@types/unist": "^2.0.6",
"jest": "^29.6.2",
"@types/eslint-plugin-markdown": "^2.0.2",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.6",
"@types/react": "^18.2.46",
"@types/unist": "^3.0.2",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"jest": "^30.0.0-alpha.2",
"lint-staged": "^15.2.0",
"npm-run-all2": "^6.1.1",
"patch-package": "^8.0.0",
"prettier": "^2.8.8",
"react": "^18.2.0",
"rimraf": "^5.0.5",
"simple-git-hooks": "^2.9.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"type-coverage": "^2.26.0",
"typescript": "^5.1.6",
"yarn-deduplicate": "^6.0.2"
"ts-node": "^10.9.2",
"type-coverage": "^2.27.1",
"typescript": "^5.3.3"
},
"resolutions": {
"@commitlint/cli": "^18.4.3",
"@types/acorn": "^6.0.0",
"lint-staged": "^15.2.0",
"prettier": "^2.8.8"
},
"commitlint": {
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-mdx/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const getPositionAtFactory = (text: string) => {
return {
line,
column: offset - currOffset,
// @ts-expect-error -- intended
offset,
}
}
Expand Down
2 changes: 0 additions & 2 deletions packages/eslint-mdx/src/meta.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error -- no idea
// @ts-ignore
import { name, version } from '../package.json'

export const meta = { name, version }
1 change: 1 addition & 0 deletions packages/eslint-mdx/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const restoreTokens = (
value?: string,
): Token => ({
type,
// @ts-expect-error -- intended
value,
start,
end,
Expand Down
10 changes: 4 additions & 6 deletions packages/eslint-mdx/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,10 @@ runAsWorker(

if (!jsxTokTypes) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
jsxTokTypes = acornJsx.default(
{
allowNamespacedObjects: true,
},
// @ts-expect-error
)(acorn.Parser).acornJsx.tokTypes
jsxTokTypes = acornJsx.default({
allowNamespacedObjects: true,
// @ts-expect-error -- no type
})(acorn.Parser).acornJsx.tokTypes
}

if (!TokenTranslator) {
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin-mdx/src/configs/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const addPrettierRules = () => {
return
}

/* istanbul ignore next */
overrides.push(
{
files: '*.md',
Expand Down
2 changes: 0 additions & 2 deletions packages/eslint-plugin-mdx/src/meta.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error -- no idea
// @ts-ignore
import { name, version } from '../package.json'

export const meta = { name, version }
18 changes: 0 additions & 18 deletions test/__snapshots__/fixtures.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1213,8 +1213,6 @@ exports[`fixtures should match all snapshots: 391.mdx 1`] = `
]
`;
exports[`fixtures should match all snapshots: 391.mdx 2`] = `undefined`;
exports[`fixtures should match all snapshots: 429.mdx 1`] = `
[
{
Expand Down Expand Up @@ -2079,8 +2077,6 @@ exports[`fixtures should match all snapshots: acorn.mdx 1`] = `
]
`;
exports[`fixtures should match all snapshots: acorn.mdx 2`] = `undefined`;
exports[`fixtures should match all snapshots: adjacent.mdx 1`] = `
[
{
Expand Down Expand Up @@ -2502,8 +2498,6 @@ exports[`fixtures should match all snapshots: comments.mdx 1`] = `
]
`;
exports[`fixtures should match all snapshots: comments.mdx 2`] = `undefined`;
exports[`fixtures should match all snapshots: details.mdx 1`] = `
[
{
Expand All @@ -2518,8 +2512,6 @@ exports[`fixtures should match all snapshots: details.mdx 1`] = `
]
`;
exports[`fixtures should match all snapshots: details.mdx 2`] = `undefined`;
exports[`fixtures should match all snapshots: jsx-in-list.mdx 1`] = `
[
{
Expand Down Expand Up @@ -2792,8 +2784,6 @@ exports[`fixtures should match all snapshots: no-unescaped-entities.mdx 1`] = `
]
`;
exports[`fixtures should match all snapshots: no-unescaped-entities.mdx 2`] = `undefined`;
exports[`fixtures should match all snapshots: no-unused-expressions.mdx 1`] = `
[
{
Expand All @@ -2810,8 +2800,6 @@ exports[`fixtures should match all snapshots: no-unused-expressions.mdx 1`] = `
]
`;
exports[`fixtures should match all snapshots: no-unused-expressions.mdx 2`] = `undefined`;
exports[`fixtures should match all snapshots: processor.mdx 1`] = `
[
{
Expand All @@ -2837,8 +2825,6 @@ exports[`fixtures should match all snapshots: processor.mdx 1`] = `
]
`;
exports[`fixtures should match all snapshots: processor.mdx 2`] = `undefined`;
exports[`fixtures should match all snapshots: remark.md 1`] = `[]`;
exports[`fixtures should match all snapshots: remark.mdx 1`] = `[]`;
Expand Down Expand Up @@ -2873,10 +2859,6 @@ exports[`fixtures should match all snapshots: test.md 2`] = `
]
`;
exports[`fixtures should match all snapshots: test.md 3`] = `undefined`;
exports[`fixtures should match all snapshots: test.md 4`] = `undefined`;
exports[`fixtures should match all snapshots: unicorn.jsx 1`] = `
[
{
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('fixtures', () => {
'test/fixtures/**/*{md,mdx}',
])
for (const { filePath, source, output } of results) {
if (source !== output) {
if (output != null && source !== output) {
// eslint-disable-next-line jest/no-conditional-expect
expect(output).toMatchSnapshot(path.basename(filePath))
}
Expand All @@ -87,7 +87,7 @@ describe('fixtures', () => {
'test/fixtures/**/code-blocks.{md,mdx}',
)
for (const { filePath, source, output } of results) {
if (source !== output) {
if (output != null && source !== output) {
// eslint-disable-next-line jest/no-conditional-expect
expect(output).toMatchSnapshot(path.basename(filePath))
}
Expand Down
Loading

0 comments on commit 25bd7fb

Please sign in to comment.