Skip to content

Commit

Permalink
Cleanup and switch to pnpm (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
danez authored Dec 16, 2022
1 parent 050313d commit 4802dfb
Show file tree
Hide file tree
Showing 39 changed files with 9,800 additions and 15,325 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ end_of_line = lf
insert_final_newline = true
charset = utf-8

[*.{js,cjs,mjs,ts,tsx,mts,cts}]
[*.{js,cjs,mjs,ts,tsx,mts,cts,mdx}]
indent_style = space
indent_size = 2
#indent_style = tab
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
benchmark/suites/
**/__fixtures__/
**/dist/
**/node_modules
6 changes: 3 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
root: true,
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
parserOptions: {
ecmaVersion: 2020,
ecmaVersion: 2022,
sourceType: 'module',
},
rules: {
Expand Down Expand Up @@ -35,7 +35,7 @@ module.exports = {
},
overrides: [
{
files: ['*.cjs'],
files: ['**/*.cjs'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'script',
Expand All @@ -45,7 +45,7 @@ module.exports = {
},
},
{
files: '**/*.ts',
files: ['**/*.ts', '**/*.tsx'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: ['plugin:@typescript-eslint/recommended'],
Expand Down
42 changes: 27 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,25 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
cache: 'pnpm'

- name: Install dependencies
run: yarn install --immutable
run: pnpm install --frozen-lockfile

- name: Unit tests with coverage
if: '${{ matrix.node == env.NODE_VERSION }}'
run: yarn test --coverage
run: pnpm test -- --coverage

- name: Unit tests
if: '${{ matrix.node != env.NODE_VERSION }}'
run: yarn test
run: pnpm test

- name: Upload coverage to Codecov
if: '${{ matrix.node == env.NODE_VERSION }}'
Expand All @@ -60,17 +63,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
cache: 'pnpm'

- name: Install dependencies
run: yarn install --immutable
run: pnpm install --frozen-lockfile

- name: Lint
run: yarn lint
run: pnpm lint

playground:
name: Test build playground
Expand All @@ -81,20 +87,23 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
cache: 'pnpm'

- name: Install dependencies
run: yarn install --immutable
run: pnpm install --frozen-lockfile

- name: Build
run: yarn build
run: pnpm build

- name: Build playground
run: yarn playground:build
run: pnpm playground:build

deploy:
name: Deploy playground
Expand All @@ -107,20 +116,23 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
cache: 'pnpm'

- name: Install dependencies
run: yarn install --immutable
run: pnpm install --frozen-lockfile

- name: Build
run: yarn build
run: pnpm build

- name: Build playground
run: yarn playground:build
run: pnpm playground:build

- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@ jobs:
with:
persist-credentials: false

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
cache: 'pnpm'

- name: Install dependencies
run: yarn install --immutable
run: pnpm install --frozen-lockfile

- name: Run Changesets
id: changesets
uses: changesets/action@v1
with:
publish: yarn release
version: yarn changesets-version
publish: pnpm changesets-release
version: pnpm changesets-version
title: Packages ready to publish
commit: Publish new versions
env:
Expand Down
9 changes: 1 addition & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
benchmark/suites/
dist/
**/node_modules/*
!**/__fixtures__/**/node_modules/*
.idea/
coverage/
yarn-error.log
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tasks:
- init: yarn install
- init: pnpm install
vscode:
extensions:
- dbaeumer.vscode-eslint
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
link-workspace-packages=false
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
benchmark/suites/
**/__fixtures__/
benchmark/fixtures/
**/dist/
**/node_modules
4 changes: 0 additions & 4 deletions .release-please-manifest.json

This file was deleted.

28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

807 changes: 0 additions & 807 deletions .yarn/releases/yarn-3.3.0.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions .yarnrc.yml

This file was deleted.

9 changes: 0 additions & 9 deletions benchmark/.gitignore

This file was deleted.

20 changes: 11 additions & 9 deletions benchmark/index.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import fs from 'fs';
import path, { dirname, join } from 'path';
import path, { dirname } from 'path';
import { fileURLToPath } from 'url';
import Table from 'cli-table';
import glob from 'fast-glob';
import Benchmark from 'benchmark';
import { parse } from '../packages/react-docgen/dist/main.js';
import { parse as parse5 } from 'react-docgen5';
import { parse as parse6old } from 'react-docgen6pre';
import { parse as parse6 } from 'react-docgen6latest';

console.log(`Node: ${process.version}`);

const __dirname = dirname(fileURLToPath(import.meta.url));

const head = ['fixture', 'v5.4.3', 'v6.0.0-alpha.3', 'current'];
const head = ['fixture', 'v5.4.3', 'v6.0.0-alpha.4', 'current'];

process.stdout.write(`Preparing suites ... `);

Expand Down Expand Up @@ -42,10 +42,10 @@ if (!global.gc) {
}

const preparedSuites = [];
const suite = new Benchmark.Suite('bootstrap');

suites.forEach(({ name, files }) => {
const suite = new Benchmark.Suite(name);

files.forEach(file => {
const code = fs.readFileSync(path.join(__dirname, file), 'utf-8');
const options = { filename: file, babelrc: false, configFile: false };
Expand All @@ -54,7 +54,7 @@ suites.forEach(({ name, files }) => {
try {
// warmup
parse(code, newOptions);
parse6old(code, undefined, undefined, options);
parse6(code, newOptions);
parse5(code, undefined, undefined, options);
global.gc();

Expand All @@ -63,17 +63,19 @@ suites.forEach(({ name, files }) => {
options,
newOptions,
});
} catch {}
} catch {
// ignore errors
}
});

suite.add('v5.4.3', () => {
for (const { code, options } of preparedSuites) {
parse5(code, undefined, undefined, options);
}
});
suite.add('v6.0.0-alpha.3', () => {
for (const { code, options } of preparedSuites) {
parse6old(code, undefined, undefined, options);
suite.add('v6.0.0-alpha.4', () => {
for (const { code, newOptions } of preparedSuites) {
parse6(code, newOptions);
}
});
suite.add('current', () => {
Expand Down
5 changes: 3 additions & 2 deletions benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"dependencies": {
"benchmark": "2.1.4",
"cli-table": "0.3.11",
"fast-glob": "^3.2.12",
"fast-glob": "3.2.12",
"microtime": "3.1.1",
"react-docgen5": "npm:[email protected]",
"react-docgen6pre": "npm:react-docgen@^6.0.0-alpha"
"react-docgen6latest": "npm:react-docgen@^6.0.0-alpha.4",
"react-docgen": "workspace:react-docgen@^6.0.0-alpha.4"
}
}
Loading

0 comments on commit 4802dfb

Please sign in to comment.