Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdannael committed Jun 19, 2024
2 parents 7637a06 + a01a2bb commit c1c7b99
Show file tree
Hide file tree
Showing 795 changed files with 8,862 additions and 22,535 deletions.
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Feel free to open an issue for things like this:

Before you open an issue:

- Make sure you're using the **latest** version of Knip (see [https://github.com/webpro/knip/releases][5])
- Make sure you're using the **latest** version of Knip (see [https://github.com/webpro-nl/knip/releases][5])
- Use GitHub search to find related questions, known issues, etc.
- If relevant, use the `--debug` flag which might reveal errors, potential issues with configuration, etc.

Expand All @@ -47,12 +47,12 @@ Please consider this before opening a pull request:
- Read [development][6] instructions and guidelines.
- If you think your PR is not ready for review yet, [set it as a draft][7].
- No need to worry about commit messages, they will probably be squashed into a single commit when merged.
- After your first PR is merged, you are automatically added to the list of contributors.
- After your first PR is merged, you are automatically added to the [list of contributors](https://knip.dev/#-contributors).

[1]: ./CODE_OF_CONDUCT.md
[2]: https://knip.dev
[3]: #open-an-issue
[4]: #open-a-pull-request
[5]: https://github.com/webpro/knip/releases
[5]: https://github.com/webpro-nl/knip/releases
[6]: ./DEVELOPMENT.md
[7]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request
[7]: https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request
77 changes: 55 additions & 22 deletions .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Development

Development in this repository is based on:
Development in this repository is using:

- Node.js
- npm
- Bun
- TypeScript
- ESLint
- Biome

You should have Bun installed, the rest comes with `bun install`.

## Getting started

Expand All @@ -18,9 +19,9 @@ This guide assumes familiarity with concepts like [forking][1] and [cloning a re
Example terminal commands:

```shell
gh repo fork webpro/knip --clone
gh repo fork webpro-nl/knip --clone
cd knip
npm install
bun install
cd packages/knip
```

Expand All @@ -33,7 +34,8 @@ There's a separate guide for [writing a plugin][5].
## Watcher

```shell
npm run watch
cd packages/knip
bun link && bun run build --watch
```

Changes in the source code are now automatically picked up, and `knip` is available globally to run from any directory.
Expand All @@ -44,27 +46,58 @@ You can then also run `npm link knip` from another repository to use the linked
Pull requests should include one or more tests. See the `tests` and `fixtures` directories to find relevant files that
you may want to borrow or copy from.

Let's assume you created `fixtures/feature` and `test/feature.test.ts`. There are a few ways to run it:
Let's assume you created `fixtures/feature` and `test/feature.test.ts`. Here's 4 ways to run it:

### Run the test

```shell
bun test ./test/feature.test.ts
```

### Run Knip in the directory

```shell
cd fixtures/feature
knip
```

### Attach debugger to Node.js

Auto or smart-attach to every Node.js process launched in terminal in IDE, and then:

```shell
cd fixtures/feature
tsx ../../src/cli.ts
```

### Attach debugger to Bun

Set a breakpoint and start Knip with Bun while waiting for the debugger to be attached:

```shell
cd fixtures/feature
bun --inspect-wait=127.0.0.1:6499/knip run ../../src/cli.ts
```

Attach the debugger using the "Attach to Bun" launch configuration.

### Attach debugger to Bun from a test

- `node loader --tsx test/feature.test.ts`
- `npx tsx test/feature.test.ts`
- Use [launch configurations][6] in VS Code and start debugging from `test/feature.test.ts`.
- Go to `cd fixtures/feature` and run `knip` (or `knip --debug`)
Run the "Debug Bun test" launch configuration from any test file.

## QA

Knip has a few tools set up to verify code quality and to format code and documentation:

```shell
npm run build
npm run format
npm run knip
npm run knip:production
npm run lint
npm test
bun run format
bun run lint
bun run knip
bun run knip:production
bun run test
```

To run all commands in sequence: `npm run qa`
To run all commands in sequence: `bun run qa`

## GitHub Action

Expand All @@ -73,9 +106,9 @@ can be merged. Another workflow acts as [integration test][8] against repositori

[1]: https://docs.github.com/get-started/quickstart/fork-a-repo
[2]: https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository
[3]: https://github.com/webpro/knip
[3]: https://github.com/webpro-nl/knip
[4]: https://cli.github.com/
[5]: https://knip.dev/guides/writing-a-plugin/
[6]: ../.vscode/launch.json
[7]: https://github.com/webpro/knip/actions/workflows/test.yml
[8]: https://github.com/webpro/knip/actions/workflows/integration.yml
[7]: https://github.com/webpro-nl/knip/actions/workflows/test.yml
[8]: https://github.com/webpro-nl/knip/actions/workflows/integration.yml
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
github: webpro
open_collective: webpro
polar: webpro-nl
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Through [the CI workflow][1] the changes will be tested in Ubuntu, macOS and Windows. The changes will also be [tested
against a number of external projects][2].
[1]: https://github.com/webpro/knip/blob/main/.github/workflows/test.yml
[2]: https://github.com/webpro/knip/blob/main/.github/workflows/integration.yml
[1]: https://github.com/webpro-nl/knip/blob/main/.github/workflows/ci.yml
[2]: https://github.com/webpro-nl/knip/blob/main/.github/workflows/integration.yml
-->
38 changes: 38 additions & 0 deletions .github/workflows/ci-bun.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Tests (Bun)

on:
workflow_dispatch:
pull_request:
push:
branches:
- '**'
tags:
- '!**'

jobs:
test:
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
# - windows-latest # temp disabled because https://github.com/oven-sh/bun/issues/9932
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- name: Install dependencies
run: bun install --ignore-scripts --frozen-lockfile
- name: Run formatter, linter, import sorter
run: bun ci
- name: Build knip
run: bun run build
working-directory: packages/knip
- name: Run knip
run: bunx --bun knip
- name: Run knip (production/strict)
run: bunx --bun knip --production --strict
- name: Test knip
run: bun run test
working-directory: packages/knip
35 changes: 35 additions & 0 deletions .github/workflows/ci-ts-beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Tests (against typescript@beta in Node.js v22)

on:
workflow_dispatch:
pull_request:
push:
branches:
- '**'
tags:
- '!**'

jobs:
test:
runs-on: ubuntu-latest
name: Ubuntu/Node v22
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm install --ignore-scripts
- name: Install latest peer dependencies
run: |
npm install -w packages/knip typescript@rc @types/node@latest
- name: Build knip
run: npm run build
working-directory: packages/knip
- name: Test knip
run: npm run test:node
working-directory: packages/knip
- name: Run knip
run: npx knip
- name: Run knip --production --strict
run: npx knip --production --strict
35 changes: 35 additions & 0 deletions .github/workflows/ci-ts-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Tests (against typescript@latest in Node.js v20)

on:
workflow_dispatch:
pull_request:
push:
branches:
- '**'
tags:
- '!**'

jobs:
test:
runs-on: ubuntu-latest
name: Ubuntu/Node v20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm install --ignore-scripts
- name: Install latest peer dependencies
run: |
npm install -w packages/knip typescript@latest @types/node@20 --ignore-scripts
- name: Build knip
run: npm run build
working-directory: packages/knip
- name: Test knip
run: npm run test:node
working-directory: packages/knip
- name: Run knip
run: npx knip
- name: Run knip --production --strict
run: npx knip --production --strict
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Tests (against [email protected])

on:
workflow_dispatch:
pull_request:
push:
branches:
- '**'
tags:
- '!**'

jobs:
test:
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
node:
- 18
- 20

runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} (Node v${{ matrix.node }})

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm install [email protected] @types/node@18 --ignore-scripts
- name: Build knip
run: npm run build
working-directory: packages/knip
- name: Run knip
run: npx knip
- name: Run knip (production/strict)
run: npx knip --production --strict
- name: Test knip
run: npm run test:node
working-directory: packages/knip
Loading

0 comments on commit c1c7b99

Please sign in to comment.