Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ref: #112): bun+nodejs, lint-staged #113

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/hooks/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -e

commit_msg=$(cat .git/COMMIT_EDITMSG)
echo "$commit_msg" | npx commitlint
echo "$commit_msg" | bun commitlint
13 changes: 7 additions & 6 deletions .github/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@

set -e

npm run lint
bun run lint-staged
bun run lint

npm run snyk:test
# bun run snyk:test

output=$(npm run type-coverage)
output=$(bun run type-coverage)
if echo "$output" | grep -q "lower than "; then
echo "$output"
exit 1 # Terminate the hook script with a non-zero exit code
else
echo "Type coverage is good! 🎉"
fi

npm run test
bun run test

npm run build
bun run build

npm run build:lib
bun run build:lib

11 changes: 8 additions & 3 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: actions/setup-node@v4
with:
node-version: 20

- uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install deps
run: |
npm ci --force
git submodule update --init --recursive --remote
bun i

- name: Semantic Release
id: semantic-release
Expand All @@ -37,7 +42,7 @@ jobs:
echo "RELEASE_VERSION: $RELEASE_VERSION"
echo '********'
bash .github/workflows/scripts/replace_template.sh $RELEASE_VERSION
npm run build
bun run build

- name: Deploy demo
uses: peaceiris/actions-gh-pages@v3
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
registry-url: 'https://registry.npmjs.org'
- name: Build library
run: |
npm ci --force
git submodule update --init --recursive --remote
npm run build:lib
bun i
bun run build:lib
- name: Publish library
run: npm run publish:lib
run: bun run publish:lib
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

Expand Down
46 changes: 26 additions & 20 deletions .github/workflows/quality-check.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
name: build and quality

on:
push:
branches:
- develop
pull_request:
branches:
- develop
push:
branches:
- develop
pull_request:
branches:
- develop

env:
snyk_token: ${{ secrets.SNYK_TOKEN }}
REF: ${{ github.head_ref || github.ref_name }}

jobs:
quality-check:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Check quality
run: |
npm ci --force
git submodule update --init --recursive --remote
bash .github/workflows/scripts/quality.sh
quality-check:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
submodules: true
ref: ${{ env.REF }}
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Check quality
run: |
bun i
bash .github/workflows/scripts/quality.sh
14 changes: 7 additions & 7 deletions .github/workflows/scripts/quality.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

set -e

npm run lint
bun run lint

npm run snyk:auth -- $snyk_token
npm run snyk:test
# bun run snyk:auth -- $snyk_token
# bun run snyk:test

output=$(npm run type-coverage)
output=$(bun run type-coverage)
if echo "$output" | grep -q "lower than "; then
echo "$output"
exit 1 # Terminate the hook script with a non-zero exit code
else
echo "Type coverage is good! 🎉"
fi

npm run test
bun run test

npm run build
bun run build

npm run build:lib
bun run build:lib
7 changes: 7 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"*.{ts,js,json}": [
"eslint --report-unused-disable-directives --max-warnings 0 --fix",
"prettier --write"
],
"*.scss": "stylelint --fix"
}
Binary file added bun.lockb
Binary file not shown.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build angular-loader --base-href /ngx-loader-indicator/ --configuration production",
"build:lib": "ng build --configuration production ngx-loader-indicator-lib && npm run copy-libdocs",
"build:lib": "ng build --configuration production ngx-loader-indicator-lib && bun run copy-libdocs",
"copy-libdocs": "cp README.md LICENSE dist/ngx-loader-indicator-lib",
"publish:lib": "cd dist/ngx-loader-indicator-lib && npm publish",
"test": "ng test",
"test:pre-commit": "ng test --watch=false",
"lint": "npx eslint . && npm run lint:scss",
"lint": "npx eslint . && bun run lint:scss",
"lint:scss": "stylelint \"**/*.scss\"",
"lint:scss:fix": "stylelint \"**/*.scss\" --fix",
"lint:fix": "ng lint --fix && npm run lint:scss:fix",
"lint:fix": "ng lint --fix && bun run lint:scss:fix",
"prettier:fix": "npx prettier --write .",
"type-coverage": "type-coverage",
"init:git:hooks": ".github/scripts/setup_hooks.sh",
Expand Down Expand Up @@ -74,6 +74,7 @@
"eslint-plugin-prettier": "5.1.3",
"jasmine-core": "5.1.2",
"jasmine-spec-reporter": "7.0.0",
"lint-staged": "15.2.7",
"ng-packagr": "18.0.0",
"npm-check-updates": "^16.14.20",
"postcss-scss": "4.0.9",
Expand Down