Skip to content

Commit

Permalink
feat(ref: #127): bun+nodejs, lint-staged (#128)
Browse files Browse the repository at this point in the history
* feat(ref: #127): bun+nodejs, lint-staged

* fix(no-ref): libraries
  • Loading branch information
lachesse authored Jun 19, 2024
1 parent 1aee893 commit fa329f1
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 117 deletions.
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
15 changes: 8 additions & 7 deletions .github/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

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 cypress:bash
bun run cypress:bash

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
with:
Expand Down
128 changes: 56 additions & 72 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,87 +6,71 @@ on:
- master

jobs:
<<<<<<< HEAD
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/
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'
- 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}}
=======
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: Build library
run: |
npm ci --force
git submodule update --init --recursive --remote
npm run build:lib
- name: Publish library
run: npm run publish:lib
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
>>>>>>> 3f307330fe37548a4adf15a75443b4fc468816d9

slack_notification:
needs:
- build
runs-on: ubuntu-latest
steps:
- name: Post to a Slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: 'deployments'
payload: |
{
"text": "GitHub Action build result: ${{ job.status == 'success' && ':white_check_mark:' || ':x:' }}",
"blocks": [
slack_notification:
needs:
- build
runs-on: ubuntu-latest
steps:
- name: Post to a Slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: 'deployments'
payload: |
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "GitHub Action build result: ${{ job.status == 'success' && ':white_check_mark:' || ':x:' }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Project: `${{ github.event.repository.name }}`"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Commit/PR URL: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Website URL: ${{ env.NPM_PACKAGE_URL }}"
}
"text": "GitHub Action build result: ${{ job.status == 'success' && ':white_check_mark:' || ':x:' }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "GitHub Action build result: ${{ job.status == 'success' && ':white_check_mark:' || ':x:' }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Project: `${{ github.event.repository.name }}`"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Commit/PR URL: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Website URL: ${{ env.NPM_PACKAGE_URL }}"
}
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
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
16 changes: 8 additions & 8 deletions .github/workflows/scripts/quality.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

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 cypress:bash
bun run cypress:bash

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: 5 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = tseslint.config(
'error',
{
type: 'attribute',
prefix: ["ngxCopyPaste", "jsdaddy"],
prefix: ['ngxCopyPaste', 'jsdaddy'],
style: 'camelCase',
},
],
Expand All @@ -77,7 +77,10 @@ module.exports = tseslint.config(
// Apply the Angular template rules which focus on accessibility of our apps
...angular.configs.templateAccessibility,
],
rules: {},
rules: {
'@angular-eslint/template/click-events-have-key-events': 'off',
'@angular-eslint/template/interactive-supports-focus': 'off',
},
},
{
files: ['**/*.js'],
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build ngx-copypaste --base-href /ngx-copypaste/ --configuration production",
"build:lib": "ng build --configuration production ngx-copypaste-lib && npm run copy-libdocs",
"build:lib": "ng build --configuration production ngx-copypaste-lib && bun run copy-libdocs",
"copy-libdocs": "cp README.md LICENSE dist/ngx-copypaste-lib",
"publish:lib": "cd dist/ngx-copypaste-lib && npm publish",
"test": "ng test",
"test:pre-commit": "ng test --watch=false",
"lint": "ng lint && npm run lint:scss",
"lint": "ng lint && bun run lint:scss",
"lint:scss": "stylelint \"**/*.scss\"",
"lint:scss:fix": "stylelint \"**/*.scss\" --fix",
"init:git:hooks": ".github/scripts/setup_hooks.sh",
"cypress:open": "cypress open",
"cypress:bash": "npx cypress run --component",
"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",
"snyk:auth": "snyk auth",
Expand Down Expand Up @@ -86,6 +86,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

0 comments on commit fa329f1

Please sign in to comment.