Skip to content

Commit

Permalink
feat: set pnpm as package manager (#125)
Browse files Browse the repository at this point in the history
Co-authored-by: Kamil Dubiel <kamil.dubiel@infinum.com>
  • Loading branch information
kamdubiel and kamdubiel authored May 9, 2024
1 parent 8407fd2 commit dfc1448
Show file tree
Hide file tree
Showing 14 changed files with 6,690 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "infinum/js-linters" }],
"changelog": ["@changesets/changelog-github", { "repo": "infinum/js-linters" }],
"commit": false,
"access": "restricted",
"baseBranch": "master",
Expand Down
14 changes: 14 additions & 0 deletions .changeset/strange-carrots-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@infinum/eslint-plugin': major
---

Set `pNPM` as package manager:
- Added `pnpm` lockfile and workspace configuration
- Added static code analysis scripts to `package.json`
- Configured `packageManager` for `corepack`
- Updated `CONTRIBUTING.md` documentation
- Updated `GithubActions` for `pnpm` support and resolved Node version warnings
- Updated `husky` configuration for `pnpm`
- Fixed `ESLint` configuration so it could be run for this repository also
- Fixed `npm` doppelgangers
- Added `changesets` config to `Prettier` ignore
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"root": true,
"extends": ["@infinum/core", "@infinum/typescript"]
"extends": ["plugin:@infinum/core", "plugin:@infinum/typescript", "plugin:prettier/recommended"],
"parserOptions": {
"project": "./tsconfig.json"
}
}
41 changes: 41 additions & 0 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 🩺 Code Analysis

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
code-analysis:
runs-on: ubuntu-22.04
steps:
- name: 📥 Checkout Repository
uses: actions/checkout@v4

- name: 🗃️ Install corepack
run: corepack enable

- name: ⚡️ Install pNPM
uses: pnpm/action-setup@v3
with:
run_install: false

- name: 🎰 Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.12.2
cache: 'pnpm'

- name: 📦 Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts

- name: 🏗️ Build the pacakge
run: pnpm build

- name: 🧐 Prettier
run: pnpm prettier:check

- name: 🫣 Lint
run: pnpm lint

- name: 🧪 Run Tests
run: pnpm test
49 changes: 33 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,54 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
if: github.event.inputs.branch == 'master'
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: 📥 Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}

- name: Setup Node.js 18.x
uses: actions/setup-node@v3
- name: 🗃️ Install corepack
run: corepack enable

- name: ⚡️ Install pNPM
uses: pnpm/action-setup@v3
with:
run_install: false

- name: 🎰 Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.12.2
cache: 'pnpm'

- name: 📦 Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts

- name: 🏗️ Build the pacakge
run: pnpm build

- name: 🧐 Prettier
run: pnpm prettier:check

# lock files are ignored for some reason we cannot remember
# because of that, `install` instead of `ci` is used
- name: Install Dependencies
run: npm install
- name: 🫣 Lint
run: pnpm lint

- name: Build packages
run: npm run build
- name: 🧪 Run Tests
run: pnpm test

- name: Create Release Pull Request or Publish to npm
- name: 📢 Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: npm publish
commit: "ci: version packages"
publish: pnpm publish
commit: 'ci: version packages'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create Git Tag
- name: 🚩 Create Git Tag
id: create_tag
if: steps.changesets.outputs.published == 'true'
run: |
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/run-tests.yml

This file was deleted.

5 changes: 1 addition & 4 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit
pnpm commitlint --edit
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
pnpm lint-staged
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm test
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ LICENSE

# Intentionally ignored
*.hbs
.changeset/config.json
28 changes: 12 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cd js-linters
2. Setup all the dependencies and packages

```sh
npm install
pnpm install
```

## Development
Expand All @@ -23,31 +23,28 @@ To ease the developer activity, we have created a few scripts that will help you

### Tooling

- [NPM](https://npm.io/) to manage dependencies
- [pNPM](https://pnpm.io/installation) to manage dependencies
- [TypeScript](https://www.typescriptlang.org/) to bundle package
- [uvu](https://github.com/lukeed/uvu) for testing configs and custom rules
- [CommitLint](https://commitlint.js.org/#/) for enforsing [the conventional commit messages](https://www.conventionalcommits.org/en/v1.0.0/)
- [Changeset](https://github.com/atlassian/changesets) for changes documentation, changelog generation, and release management.
- [CommitLint](https://commitlint.js.org/#/) for enforcing [the conventional commit messages](https://www.conventionalcommits.org/en/v1.0.0/)
- [Changesets](https://github.com/atlassian/changesets) for changes documentation, changelog generation, and release management.
- [Plop](https://plopjs.com/) for generating new rules and configs

### Commands

**`npm install`**: install all dependencies.
**`pnpm install`**: install all dependencies.

**`npm storybook`**: starts storybook server and loads stories in files that
end with `.stories.tsx`.
**`pnpm build`**: builds the package.

**`npm build`**: builds the package.
**`pnpm clean`**: removes the build output.

**`npm clean`**: removes the build output.
**`pnpm test`**: runs all tests.

**`npm test`**: runs all tests.
**`pnpm test:watch`**: runs all tests in watch mode.

**`npm test:watch`**: runs all tests in watch mode.
**`pnpm gen:config`**: runs plop script that generates a new config (name is provided as terminal prompt).

**`npm gen:config`**: runs plop script that generates a new config (name is provided as terminal prompt).

**`npm gen:rule`**: runs plop script that generates a new rule (name and description are provided as terminal prompt).
**`pnpm gen:rule`**: runs plop script that generates a new rule (name and description are provided as terminal prompt).

### Commit Convention

Expand All @@ -70,5 +67,4 @@ All commits that fix bugs or add features need a test.

## License

By contributing your code to the chakra-ui GitHub repository, you agree to
license your contribution under the MIT license.
By contributing your code to the @infinum/eslint-plugin GitHub repository, you agree to license your contribution under the MIT license.
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@infinum/eslint-plugin",
"version": "1.0.0",
"description": "Infinum's ESLint Plugin",
"main": "dist/index.js",
"main": "./dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/infinum/js-linters.git",
Expand All @@ -19,14 +19,17 @@
"README.md",
"LICENSE"
],
"packageManager": "pnpm@9.0.6",
"scripts": {
"build": "tsc -b tsconfig.build.json",
"clean": "tsc -b tsconfig.build.json --clean",
"fix": "manypkg fix",
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"gen:config": "plop config",
"gen:rule": "plop rule",
"prepare": "husky install",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "pnpm lint --fix",
"prepare": "husky",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"test:watch": "watchlist src tests --eager -- npm run test",
"test": "NODE_ENV=test uvu -r esbuild-register tests",
"typecheck": "tsc -p tsconfig.json --noEmit"
Expand Down Expand Up @@ -77,18 +80,21 @@
"@changesets/cli": "~2.26.2",
"@commitlint/cli": "~17.6.6",
"@commitlint/config-conventional": "~17.6.6",
"@infinum/eslint-plugin": "file:./",
"@infinum/eslint-plugin": "workspace:*",
"@manypkg/cli": "^0.19.1",
"@next/eslint-plugin-next": ">=11",
"@trivago/prettier-plugin-sort-imports": "~4.1.1",
"@types/node": "20.12.11",
"@typescript-eslint/eslint-plugin": "^5",
"@typescript-eslint/parser": "5.60.1",
"@typescript-eslint/utils": "5.60.1",
"esbuild": "~0.18.10",
"esbuild-register": "~3.4.2",
"eslint": "8.14.0",
"eslint-config-prettier": "8.10.0",
"eslint-plugin-jasmine": ">=4",
"eslint-plugin-jsx-a11y": ">=6",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": ">=7",
"eslint-plugin-react-hooks": ">=4",
"eslint-plugin-rxjs": ">=3",
Expand Down
Loading

0 comments on commit dfc1448

Please sign in to comment.