Skip to content

Commit

Permalink
chore: several updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Feb 23, 2024
1 parent 56ff003 commit 4d53e0d
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 96 deletions.
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto
*.* text eol=lf
*.lockb binary diff=lockb
Binary file added .github/art/cover.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .github/art/cover_ts_starter.png
Binary file not shown.
82 changes: 28 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ on:
branches:
- main

env:
PR_NUMBER: '${{ github.event.number }}'
SOURCE_BRANCH: $GITHUB_HEAD_REF
FIXER_BRANCH: auto-fixed/$GITHUB_HEAD_REF
TITLE: Apply fixes from JS-CS-Fixer
DESCRIPTION: This merge request applies JS code style fixes from an analysis carried out through GitHub Actions.

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
Expand All @@ -27,14 +20,22 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install bun
- name: Install Bun
uses: oven-sh/setup-bun@v1

- name: Install dependencies
- name: Use cached node_modules
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
node-modules-
- name: Install Dependencies
run: bun install

- name: Lint
run: bun --bun run lint
run: bun run lint

typecheck:
runs-on: ubuntu-latest
Expand All @@ -45,7 +46,15 @@ jobs:
- name: Install bun
uses: oven-sh/setup-bun@v1

- name: Install dependencies
- name: Use cached node_modules
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
node-modules-
- name: Install Dependencies
run: bun install

- name: Typecheck
Expand All @@ -60,51 +69,16 @@ jobs:
- name: Install bun
uses: oven-sh/setup-bun@v1

- name: Use cached node_modules
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
node-modules-
- name: Install Dependencies
run: bun install

- name: Unit Test
run: bun test

js-cs-fixer:
runs-on: ubuntu-latest

if: github.event_name == 'pull_request' && ! startsWith(github.ref, 'refs/heads/auto-fixed/')

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Install bun
uses: oven-sh/setup-bun@v1

- name: Install Dependencies
run: bun install

- name: Prepare Git User
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "[email protected]"
git checkout -B "${{ env.FIXER_BRANCH }}"
- name: Apply auto-fixers
run: bun run lint:fix

- name: Create Fixer PR
run: |
if [[ -z $(git status --porcelain) ]]; then
echo "Nothing to fix... Exiting."
exit 0
fi
OPEN_PRS=`curl --silent -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open"`
OPEN_FIXER_PRS=`echo ${OPEN_PRS} | grep -o "\"ref\": \"${{ env.FIXER_BRANCH }}\"" | wc -l`
git commit -am "${{ env.TITLE }}"
git push origin "${{ env.FIXER_BRANCH }}" --force
if [ ${OPEN_FIXER_PRS} -eq "0" ]; then
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/pulls" \
-d "{ \"head\":\"${{ env.FIXER_BRANCH }}\", \"base\":\"${{ env.SOURCE_BRANCH }}\", \"title\":\"${{ env.TITLE }}\", \"body\":\"${{ env.DESCRIPTION }}\n\nTriggered by #${{ env.PR_NUMBER }}\" }"
fi
exit 1
10 changes: 9 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ jobs:
- name: Install bun
uses: oven-sh/setup-bun@v1

- name: Install dependencies
- name: Use cached node_modules
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
node-modules-
- name: Install Dependencies
run: bun install

- name: Build the release
Expand Down
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Automatic dts generation
![Social Card of Bun Plugin DTS Auto](./.github/art/cover.jpg)

# bun-plugin-dts-auto

[![npm version][npm-version-src]][npm-version-href]
[![GitHub Actions][github-actions-src]][github-actions-href]
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
<!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
[![npm downloads][npm-downloads-src]][npm-downloads-href]
<!-- [![Codecov][codecov-src]][codecov-href] -->

This Bun plugin generates dts files for your TypeScript project.

## Features

- 🚗 Automatic dts generation based on your entrypoints
- 🗺️ Support for source map generations
- Automatic dts generation based on your entrypoints
- Support for source map generations
- Honors & inherits your `tsconfig.json` settings

## Usage

Expand All @@ -28,7 +31,9 @@ await Bun.build({
entrypoints: [
'src/index.ts',
],

outdir: './dist',

plugins: [
dts({
withSourceMap: true, // optional
Expand All @@ -39,21 +44,24 @@ await Bun.build({
console.log('Build complete ✅')
```

> [!NOTE]
> Please note, this plugin honors your `tsconfig.json` settings (e.g. `compilerOptions.outDir`).
## 🧪 Testing

```bash
bun test
```

## 📈 Changelog
## Changelog

Please see our [releases](https://github.com/stacksjs/bun-plugin-dts-auto/releases) page for more information on what has changed recently.

## 🚜 Contributing
## Contributing

Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.

## 🏝 Community
## Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Expand All @@ -63,11 +71,11 @@ For casual chit-chat with others using this package:

[Join the Stacks Discord Server](https://discord.gg/stacksjs)

## 📄 License
## License

The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/bun-plugin-dts-auto/tree/main/LICENSE.md) for more information.

Made with ❤️
Made with 💙

<!-- Badges -->
[npm-version-src]: <https://img.shields.io/npm/v/bun-plugin-dts-auto?style=flat-square>
Expand Down
3 changes: 3 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ await Bun.build({
entrypoints: [
'src/index.ts',
],

outdir: './dist',

external: [
'typescript',
'bun',
'node:path',
],

plugins: [
dts(),
],
Expand Down
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion commitlint.config.js → commitlint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module.exports = {
rules: {
// @see: https://commitlint.js.org/#/reference-rules
'scope-enum': [
2, 'always',
2,
'always',
scopes,
],
},
Expand Down
8 changes: 8 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import stacks from '@stacksjs/eslint-config'

export default stacks({
stylistic: {
indent: 2, // 4, or 'tab'
quotes: 'single', // or 'double'
},
})
37 changes: 21 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "bun-plugin-dts-auto",
"type": "module",
"version": "0.2.2",
"description": "Automatically generate d.ts files for Bun packages.",
"description": "A Bun Bundler plugin that auto generates your d.ts types.",
"author": "Chris Breuer <[email protected]>",
"license": "MIT",
"homepage": "https://github.com/stacksjs/bun-plugin-dts-auto#readme",
Expand All @@ -17,6 +18,7 @@
"generation",
"typescript",
"types",
"auto",
"bun",
"package"
],
Expand All @@ -25,43 +27,46 @@
"bun": "./src/index.ts",
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./*": {
"bun": "./src/*",
"import": "./dist/*"
}
},
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
"dist",
"src"
],
"scripts": {
"build": "bun --bun build.ts",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"fresh": "rimraf node_modules/ bun.lock && bun i",
"build": "bun build.ts",
"lint": "bunx eslint .",
"lint:fix": "bunx eslint . --fix",
"fresh": "bunx rimraf node_modules/ bun.lock && bun i",
"commit": "git cz",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"prepublishOnly": "bun --bun run build",
"release": "bunx --bun bumpp package.json --all",
"start": "bun --bun src/index.ts",
"changelog": "bunx changelogen --output CHANGELOG.md",
"prepublishOnly": "bun run build",
"release": "bun run changelog && bunx bumpp package.json --all",
"test": "bun test",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@ow3/eslint-config": "^0.47.3",
"@commitlint/cli": "^18.6.1",
"@stacksjs/eslint-config": "^0.58.73",
"@types/node": "^20.11.20",
"bumpp": "^9.3.0",
"bun-types": "^0.8.1",
"changelogen": "^0.5.5",
"commitizen": "^4.3.0",
"conventional-changelog-cli": "^3.0.0",
"cz-git": "^1.8.0",
"eslint": "^8.56.0",
"lint-staged": "^15.2.2",
"rimraf": "^5.0.5",
"simple-git-hooks": "^2.9.0",
"typescript": "^5.3.3"
},
"simple-git-hooks": {
"pre-commit": "npx --no-install lint-staged",
"commit-msg": "npx --no -- commitlint --edit $1"
"pre-commit": "bun lint-staged",
"commit-msg": "bunx --no -- commitlint --edit $1"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,vue}": "eslint --fix"
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import p from 'node:path'
import process from 'node:process'
import type { BunPlugin } from 'bun'
import ts from 'typescript'

Expand Down
23 changes: 11 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
{
"compilerOptions": {
"incremental": true,
"target": "esnext",
"module": "esnext",
"lib": [
"esnext"
],
"moduleDetection": "force",
"module": "esnext",
"moduleResolution": "bundler",
"noEmit": true,
"resolveJsonModule": true,
"types": [
"node"
],
"allowImportingTsExtensions": true,
"moduleDetection": "force",
"esModuleInterop": true,
"strict": true,
"strictNullChecks": true,
"resolveJsonModule": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"incremental": true,
"noEmit": true,
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipDefaultLibCheck": true,
"types": [
"node",
"bun-types"
]
"skipLibCheck": true
}
}

0 comments on commit 4d53e0d

Please sign in to comment.