Skip to content

Commit c916671

Browse files
authored
feat: switch to pnpm, update dependancies, switch to dependabot (#116)
1 parent 8054ccb commit c916671

File tree

11 files changed

+13321
-14020
lines changed

11 files changed

+13321
-14020
lines changed

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'npm'
4+
target-branch: 'master'
5+
directory: '/'
6+
schedule:
7+
interval: 'monthly'
8+
groups:
9+
minor-and-patch-updates:
10+
patterns:
11+
- '*'
12+
update-types:
13+
- 'minor'
14+
- 'patch'

.github/workflows/main.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,25 @@ jobs:
1717
with:
1818
fetch-depth: 0
1919

20-
- name: Set up Node
21-
uses: actions/setup-node@v4
20+
- name: Set up pnpm
21+
uses: pnpm/action-setup@v2
2222
with:
23-
node-version: lts/*
24-
cache: 'yarn'
23+
version: latest
2524

2625
- name: Install dependencies
27-
run: yarn install --frozen-lockfile
26+
run: pnpm install --frozen-lockfile
2827

2928
- name: Check types
30-
run: yarn type-check
29+
run: pnpm type-check
3130

3231
- name: Check linting
33-
run: yarn lint
32+
run: pnpm lint
3433

3534
- name: Run tests
36-
run: yarn test:ci
35+
run: pnpm test:ci
3736

3837
- name: Build storybook
39-
run: yarn build-storybook
38+
run: pnpm build-storybook
4039

4140
- name: Build package
42-
run: yarn build
41+
run: pnpm build

.github/workflows/publish.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,24 @@ jobs:
2222
with:
2323
fetch-depth: 0
2424

25-
- name: Set up Node
26-
uses: actions/setup-node@v4
25+
- name: Set up pnpm
26+
uses: pnpm/action-setup@v2
2727
with:
28-
node-version: lts/*
29-
cache: 'yarn'
28+
version: latest
3029

3130
- name: Deploy Storybook
3231
uses: bitovi/github-actions-storybook-to-github-pages@v1.0.2
3332
with:
34-
install_command: yarn install --frozen-lockfile
35-
build_command: yarn build-storybook
33+
install_command: pnpm install --frozen-lockfile
34+
build_command: pnpm build-storybook
3635
path: storybook-static
3736
env:
3837
GH_TOKEN: ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}
3938

4039
# - name: Build and publish to npm
4140
# if: github.ref == 'refs/tags/v*' # Only run on version tags
4241
# run: |
43-
# yarn build
42+
# pnpm build
4443
# npm login --registry=https://registry.npmjs.org/ --scope=your-scope
4544
# npm publish
4645
# env:

.husky/pre-commit

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
. "$(dirname "$0")/common.sh"
4-
5-
yarn lint-staged
1+
pnpm test:ci
2+
pnpm lint-staged

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ coverage
33
storybook-static
44
.prettierignore
55
yarn.lock
6+
pnpm-lock.yaml
67
*.snap
78
.npmrc
89
.husky

README.md

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,29 @@ A slightly opinionated starter kit for developing React and/or TypeScript packag
77
## 🏃 Getting started
88

99
```console
10-
npx degit TimMikeladze/tsup-react-package-starter my-react-package
10+
npx degit TimMikeladze/tsup-react-package-starter my-package
1111

12-
cd my-react-package && git init
12+
cd my-package && git init
1313

14-
yarn && yarn dev
14+
pnpm install && pnpm dev
1515
```
1616

17-
❗Important note: This project uses [yarn](https://yarnpkg.com/) for managing dependencies. If you want to use another package manager, remove the `yarn.lock` and control-f for usages of `yarn` in the project and replace them with your package manager of choice.
17+
❗Important note: This project uses [pnpm](https://pnpm.io/) for managing dependencies. If you want to use another package manager, remove the `pnpm-lock.yaml` and control-f for usages of `pnpm` in the project and replace them with your package manager of choice.
1818

1919
## What's included?
2020

2121
- ⚡️[tsup](https://github.com/egoist/tsup) - The simplest and fastest way to bundle your TypeScript libraries. Used to bundle package as ESM and CJS modules. Supports TypeScript, Code Splitting, PostCSS, and more out of the box.
22-
- 🔗 [Yalc](https://github.com/wclr/yalc) - Better workflow then npm or yarn link for package authors.
2322
- 📖 [Storybook](https://storybook.js.org/) - Build UI components and pages in isolation. It streamlines UI development, testing, and documentation.
24-
- ⚡️ [Vitest](https://vitest.dev/) - A testing framework for JavaScript. Preconfigured to work with TypeScript and JSX.
23+
- 🧪 [Vitest](https://vitest.dev/) - A testing framework for JavaScript. Preconfigured to work with TypeScript and JSX.
2524
- 🔼 [Release-it](https://github.com/release-it/release-it/) - release-it is a command line tool to automatically generate a new GitHub Release and populates it with the changes (commits) made since the last release.
2625
- 🐙 [Test & Publish via Github Actions](https://docs.github.com/en/actions) - CI/CD workflows for your package. Run tests on every commit plus integrate with Github Releases to automate publishing package to NPM and Storybook to Github Pages.
2726
- 📄 [Commitizen](https://github.com/commitizen/cz-cli) — When you commit with Commitizen, you'll be prompted to fill out any required commit fields at commit time.
28-
- 🚓 [Commitlint](https://github.com/conventional-changelog/commitlint) — Checks that your commit messages meet the conventional commit format.
29-
- 🐶 [Husky](https://github.com/typicode/husky) — Running scripts before committing.
27+
- 🐶 [Husky](https://github.com/typicode/husky) — Run scripts before committing.
3028
- 🚫 [lint-staged](https://github.com/okonet/lint-staged) — Run linters on git staged files
31-
- 🖌 [Renovate](https://github.com/renovatebot/renovate) - Universal dependency update tool that fits into your workflows. Configured to periodically check your dependencies for updates and send automated pull requests.
29+
- 🤖 [Dependabot](https://docs.github.com/en/code-security/dependabot) - Github powered dependency update tool that fits into your workflows. Configured to periodically check your dependencies for updates and send automated pull requests.
3230
- ☑️ [ESLint](https://eslint.org/) - A linter for JavaScript. Includes a simple configuration for React projects based on the recommended ESLint and AirBnB configs.
3331
- 🎨 [Prettier](https://prettier.io/) - An opinionated code formatter.
32+
- 🏃‍♀️‍➡️ [TSX](https://github.com/privatenumber/tsx) - Execute TypeScript files with zero-config in a Node.js environment.
3433

3534
## Usage
3635

@@ -39,29 +38,29 @@ yarn && yarn dev
3938
Watch and rebuild code with `tsup` and runs Storybook to preview your UI during development.
4039

4140
```console
42-
yarn dev
41+
pnpm dev
4342
```
4443

4544
Run all tests and watch for changes
4645

4746
```console
48-
yarn test
47+
pnpm test
4948
```
5049

5150
### 🏗️ Building
5251

5352
Build package with `tsup` for production.
5453

5554
```console
56-
yarn build
55+
pnpm build
5756
```
5857

5958
### ▶️ Running files written in TypeScript
6059

61-
To run a `.ts` file through Node.js you can simply the `ts` shorthand script in `package.json`.
60+
To execute a file written in TypeScript inside a Node.js environment, use the `tsx` command. This will detect your `tsconfig.json` and run the file with the correct configuration. This is perfect for running custom scripts while remaining type-safe.
6261

6362
```console
64-
yarn ts ./path/to/file.ts
63+
pnpm tsx ./path/to/file.ts
6564
```
6665

6766
This is useful for running scripts, starting a server, or any other code you want to run while remaining type-safe.
@@ -70,22 +69,20 @@ This is useful for running scripts, starting a server, or any other code you wan
7069

7170
Often times you want to `link` this package to another project when developing locally, circumventing the need to publish to NPM to consume it.
7271

73-
For this we use [yalc](https://github.com/wclr/yalc) which is a tool for local package development and simulating the publishing and installation of packages.
74-
75-
In a project where you want to consume your package simply run:
72+
In a project where you want to consume your package run:
7673

7774
```console
78-
npx yalc link my-react-package
75+
pnpm link my-package --global
7976
```
8077

81-
Learn more about `yalc` [here](https://github.com/wclr/yalc).
78+
Learn more about package linking [here](https://pnpm.io/cli/link).
8279

8380
### 📩 Committing
8481

8582
When you are ready to commit simply run the following command to get a well formatted commit message. All staged files will automatically be linted and fixed as well.
8683

8784
```console
88-
yarn commit
85+
pnpm commit
8986
```
9087

9188
### 🔖 Releasing, tagging & publishing to NPM
@@ -95,13 +92,13 @@ Create a semantic version tag and publish to Github Releases. When a new release
9592
Learn more about how to use the `release-it` command [here](https://github.com/release-it/release-it).
9693

9794
```console
98-
yarn release
95+
pnpm release
9996
```
10097

10198
When you are ready to publish to NPM simply run the following command:
10299

103100
```console
104-
yarn publish
101+
pnpm publish
105102
```
106103

107104
#### 🤖 Auto publish after Github Release (or manually by dispatching the Publish workflow)
@@ -114,7 +111,7 @@ yarn publish
114111

115112
Import CSS files works out of the box. Simply import your CSS files in your components and they will be bundled with your package.
116113

117-
[tsup](https://github.com/egoist/tsup) supports PostCSS out of the box. Simply run `yarn add postcss -D` add a `postcss.config.js` file to the root of your project, then add any plugins you need. Learn more how to configure PostCSS [here](https://tsup.egoist.dev/#css-support).
114+
[tsup](https://github.com/egoist/tsup) supports PostCSS out of the box. Simply run `pnpm add postcss -D` add a `postcss.config.js` file to the root of your project, then add any plugins you need. Learn more how to configure PostCSS [here](https://tsup.egoist.dev/#css-support).
118115

119116
Additionally consider using the [tsup](https://github.com/egoist/tsup) configuration option `injectStyle` to inject the CSS directly into your Javascript bundle instead of outputting a separate CSS file.
120117

package.json

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@
1010
"url": ""
1111
},
1212
"scripts": {
13-
"dev": "concurrently \"yarn build --watch\" \"yarn storybook\" \"yarn test\" ",
14-
"build": "tsup --onSuccess \"yarn link:self\"",
13+
"dev": "concurrently \"pnpm build --watch\" \"pnpm storybook\" \"pnpm test\" ",
14+
"build": "tsup --onSuccess \"pnpm link:self\"",
1515
"type-check": "tsc",
16-
"lint": "eslint --ignore-path .gitignore \"{src,tests}/**/*.+(ts|js|tsx)\"",
17-
"lint:fix": "yarn lint --fix && prettier --write .",
16+
"lint": "eslint --ignore-path .gitignore \"{src,tests}/**/*.+(ts|js|tsx|jsx)\"",
17+
"lint:fix": "pnpm lint --fix && prettier --write .",
1818
"test": "vitest",
1919
"test:ci": "vitest run --coverage",
20-
"prepare": "husky install",
20+
"prepare": "husky",
2121
"commit": "cz",
2222
"storybook": "storybook dev -p 6006",
2323
"build-storybook": "storybook build",
24-
"release": "yarn build && yarn release-it",
25-
"link:self": "yarn yalc publish && yarn link",
26-
"ts": "node node_modules/.bin/ts-node -r tsconfig-paths/register -O '{\"module\": \"commonjs\", \"moduleResolution\": \"classic\", \"resolveJsonModule\": false }' --transpile-only --project ./tsconfig.json"
24+
"release": "pnpm build && pnpm release-it",
25+
"link:self": "pnpm link --global"
2726
},
2827
"types": "./dist/index.d.ts",
2928
"exports": {
@@ -58,15 +57,13 @@
5857
}
5958
},
6059
"engines": {
61-
"node": ">=14.0.0"
60+
"node": ">=18.0.0"
6261
},
6362
"devDependencies": {
64-
"@babel/core": "7.23.9",
65-
"@babel/preset-env": "7.23.9",
63+
"@babel/core": "7.24.0",
64+
"@babel/preset-env": "7.24.0",
6665
"@babel/preset-react": "7.23.3",
6766
"@babel/preset-typescript": "7.23.3",
68-
"@commitlint/cli": "19.0.3",
69-
"@commitlint/config-conventional": "19.0.3",
7067
"@ryansonshine/commitizen": "4.2.8",
7168
"@ryansonshine/cz-conventional-changelog": "3.3.4",
7269
"@storybook/addon-essentials": "7.6.17",
@@ -78,28 +75,28 @@
7875
"@storybook/testing-library": "0.2.2",
7976
"@testing-library/jest-dom": "6.4.2",
8077
"@testing-library/react": "14.2.1",
81-
"@types/node": "20.11.19",
82-
"@types/react": "18.2.57",
83-
"@types/react-dom": "18.2.19",
78+
"@types/node": "20.11.25",
79+
"@types/react": "18.2.64",
80+
"@types/react-dom": "18.2.21",
8481
"@types/react-test-renderer": "18.0.7",
85-
"@typescript-eslint/eslint-plugin": "7.0.2",
86-
"@typescript-eslint/parser": "7.0.2",
82+
"@typescript-eslint/eslint-plugin": "7.1.1",
83+
"@typescript-eslint/parser": "7.1.1",
8784
"@vitejs/plugin-react": "4.2.1",
8885
"@vitest/coverage-v8": "1.3.1",
8986
"babel-loader": "9.1.3",
9087
"concurrently": "8.2.2",
91-
"eslint": "8.56.0",
88+
"eslint": "8.57.0",
9289
"eslint-config-airbnb": "19.0.4",
9390
"eslint-config-prettier": "9.1.0",
9491
"eslint-plugin-import": "2.29.1",
9592
"eslint-plugin-jsx-a11y": "6.8.0",
9693
"eslint-plugin-prefer-arrow": "1.2.3",
9794
"eslint-plugin-prettier": "5.1.3",
98-
"eslint-plugin-react": "7.33.2",
95+
"eslint-plugin-react": "7.34.0",
9996
"eslint-plugin-react-hooks": "4.6.0",
10097
"eslint-plugin-sort-class-members": "1.20.0",
10198
"eslint-plugin-storybook": "0.8.0",
102-
"eslint-plugin-typescript-sort-keys": "3.1.0",
99+
"eslint-plugin-typescript-sort-keys": "3.2.0",
103100
"eslint-plugin-unused-imports": "3.1.0",
104101
"husky": "9.0.11",
105102
"jsdom": "24.0.0",
@@ -114,20 +111,13 @@
114111
"ts-node": "10.9.2",
115112
"tsconfig-paths": "4.2.0",
116113
"tsup": "8.0.2",
117-
"typescript": "5.3.3",
118-
"vitest": "1.3.1",
119-
"yalc": "1.0.0-pre.53"
114+
"tsx": "4.7.1",
115+
"typescript": "5.4.2",
116+
"vitest": "1.3.1"
120117
},
121118
"peerDependencies": {
122119
"react": ">=17",
123120
"react-dom": ">=17"
124121
},
125-
"resolutions": {
126-
"glob-parent": ">=5.1.2",
127-
"parse-url": ">=8.1.0",
128-
"semver": ">=7.5.2",
129-
"trim": ">=0.0.3",
130-
"trim-newlines": ">=3.0.1",
131-
"yaml": ">=2.2.2"
132-
}
122+
"resolutions": {}
133123
}

0 commit comments

Comments
 (0)