diff --git a/.github/hooks/commit-msg b/.github/hooks/commit-msg index 70db84bd..c7b2e3f6 100755 --- a/.github/hooks/commit-msg +++ b/.github/hooks/commit-msg @@ -3,4 +3,4 @@ set -e commit_msg=$(cat .git/COMMIT_EDITMSG) -echo "$commit_msg" | npx commitlint +echo "$commit_msg" | bun commitlint diff --git a/.github/hooks/pre-commit b/.github/hooks/pre-commit index 0e900ed0..f68d8624 100755 --- a/.github/hooks/pre-commit +++ b/.github/hooks/pre-commit @@ -2,11 +2,12 @@ set -e -npm run lint +bun lint-staged +bun 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 @@ -14,10 +15,10 @@ 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 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1d3b6b10..996bd25c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,61 +9,60 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: 'CodeQL' on: [push] jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write - strategy: - fail-fast: false - matrix: - language: [ 'javascript', 'typescript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Use only 'java' to analyze code written in Java, Kotlin or both - # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + strategy: + fail-fast: false + matrix: + language: ['javascript', 'typescript'] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - steps: - - name: Checkout repository - uses: actions/checkout@v3 + steps: + - name: Checkout repository + uses: actions/checkout@v4 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: '/language:${{matrix.language}}' diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 07158575..a6e2c9e3 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -1,104 +1,108 @@ name: GitHub pages on: - push: - branches: - - develop + push: + branches: + - develop jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v4 + build: + runs-on: ubuntu-latest + permissions: + 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 install --package-lock-only --force - npm ci --force - git submodule update --init --recursive --remote + - uses: actions/setup-node@v4 + with: + node-version: 20 - - name: Semantic Release - id: semantic-release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - npx semantic-release + - name: Install deps + run: | + bun i - - name: Build demo app - env: - RELEASE_VERSION: ${{ steps.semantic-release.outputs.new-release-version }} - run: | - echo '********' - echo "RELEASE_VERSION: $RELEASE_VERSION" - echo '********' - bash .github/workflows/scripts/replace_template.sh $RELEASE_VERSION - npm run build + - name: Semantic Release + id: semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + npx semantic-release - - name: Deploy demo - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./dist/ngx-mask/browser + - name: Build demo app + env: + RELEASE_VERSION: ${{ steps.semantic-release.outputs.new-release-version }} + run: | + echo '********' + echo "RELEASE_VERSION: $RELEASE_VERSION" + echo '********' + bash .github/workflows/scripts/replace_template.sh $RELEASE_VERSION + bun run build - outputs: - version: ${{ steps.semantic-release.outputs.new-release-version }} + - name: Deploy demo + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist/ngx-mask/browser - slack_notification: - needs: - - build - runs-on: ubuntu-latest - steps: - - name: Post to a Slack channel - id: slack - uses: slackapi/slack-github-action@v1.26.0 - with: - channel-id: 'deployments' - payload: | - { - "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": "Version: `${{ needs.build.outputs.version || 'TBA' }}`" - } - }, - { - "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: ${{ secrets.WEBSITE_URL || 'TBA' }}" - } - } - ] - } - env: - SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + outputs: + version: ${{ steps.semantic-release.outputs.new-release-version }} + + slack_notification: + needs: + - build + runs-on: ubuntu-latest + steps: + - name: Post to a Slack channel + id: slack + uses: slackapi/slack-github-action@v1.26.0 + with: + channel-id: 'deployments' + payload: | + { + "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": "Version: `${{ needs.build.outputs.version || 'TBA' }}`" + } + }, + { + "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: ${{ secrets.WEBSITE_URL || 'TBA' }}" + } + } + ] + } + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6c054ef5..b802e2cc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,19 +9,22 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - 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/ - name: Build library run: | - npm install --package-lock-only --force - 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}} diff --git a/.github/workflows/quality-check.yml b/.github/workflows/quality-check.yml index d9c2ad30..4e0a593a 100644 --- a/.github/workflows/quality-check.yml +++ b/.github/workflows/quality-check.yml @@ -4,21 +4,25 @@ on: [push] 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@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Check quality - run: | - npm install --package-lock-only --force - 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 diff --git a/.github/workflows/scripts/quality.sh b/.github/workflows/scripts/quality.sh index d70768ec..97dea943 100644 --- a/.github/workflows/scripts/quality.sh +++ b/.github/workflows/scripts/quality.sh @@ -2,12 +2,12 @@ set -e -npm run lint +bun lint -npm run snyk:auth -- $snyk_token -npm run snyk:test +# 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 @@ -15,9 +15,9 @@ else echo "Type coverage is good! 🎉" fi -npm run test -npm run cypress:bash +bun run test +bun run cypress:bash -npm run build +bun run build -npm run build:lib +bun run build:lib diff --git a/.lintstagedrc b/.lintstagedrc new file mode 100644 index 00000000..ecfb0fd6 --- /dev/null +++ b/.lintstagedrc @@ -0,0 +1,7 @@ +{ + "*.{ts,js,json}": [ + "eslint --report-unused-disable-directives --max-warnings 0 --fix", + "prettier --write" + ], + "*.scss": "stylelint --fix" +} diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 00000000..16c3efdb Binary files /dev/null and b/bun.lockb differ diff --git a/package.json b/package.json index e4da0c26..8c9d3f39 100644 --- a/package.json +++ b/package.json @@ -23,27 +23,27 @@ "scripts": { "ng": "ng", "build": "ng build --base-href /ngx-mask/ --configuration production", - "build:lib": "ng build --configuration production ngx-mask-lib && npm run copy-libdocs", - "ci": "npm run lint && npm run build:lib && npm run test:all && npm run build", + "build:lib": "ng build --configuration production ngx-mask-lib && bun run copy-libdocs", + "ci": "bun run lint && bun run build:lib && bun run test:all && bun run build", "copy-libdocs": "cp README.md LICENSE dist/ngx-mask-lib", "lint:scss": "stylelint \"**/*.scss\"", "lint:scss:fix": "stylelint \"**/*.scss\" --fix", - "lint": "ng lint && npm run lint:scss", - "lint:fix": "ng lint --fix && npm run lint:scss:fix", + "lint": "ng lint && bun run lint:scss", + "lint:fix": "ng lint --fix && bun run lint:scss:fix", "lint:markdown": "markdownlint -i projects/ngx-mask-lib/coverage -i node_modules -i CHANGELOG.md ./", "pack:lib": "cd dist/ngx-mask-lib && npm pack", "precommit-msg": "echo 'Please wait while we do our pre-commit checks...' && exit 0", "prettier": "prettier './src/**/*.ts' './projects/**/*.ts' --write", "publish:lib": "cd dist/ngx-mask-lib && npm publish", - "release:major": "npm run version:major && npm run build:lib && npm run pack:lib && npm run publish:lib", - "release:minor": "npm run version:minor && npm run build:lib && npm run pack:lib && npm run publish:lib", - "release:patch": "npm run version:patch && npm run build:lib && npm run pack:lib && npm run publish:lib", + "release:major": "bun run version:major && bun run build:lib && bun run pack:lib && bun run publish:lib", + "release:minor": "bun run version:minor && bun run build:lib && bun run pack:lib && bun run publish:lib", + "release:patch": "bun run version:patch && bun run build:lib && bun run pack:lib && bun run publish:lib", "start": "ng serve", "start-prod": "angular-http-server --path dist/ngx-mask --p 3000 --silent", "test": "ng test", "cypress:open": "cypress open", "cypress:bash": "npx cypress run --component", - "test:all": "npm run test:app && npm run test:lib", + "test:all": "bun run test:app && bun run test:lib", "test:app": "ng test ngx-mask", "test:lib": "ng test ngx-mask-lib", "test:lib:ct": "ngcc && ng run ngx-mask-lib:ct", @@ -83,13 +83,11 @@ "@angular-eslint/schematics": "17.4.0", "@angular-eslint/template-parser": "17.4.0", "@angular/cli": "17.3.7", - "@angular/common": "17.3.8", "@angular/compiler-cli": "17.3.8", - "@angular/core": "17.3.8", "@angular/language-service": "17.3.8", - "@angular/platform-browser-dynamic": "17.3.8", "@commitlint/cli": "19.3.0", "@commitlint/config-conventional": "19.2.2", + "@jscutlery/cypress-angular": "^0.9.22", "@types/highlight.js": "9.12.4", "@types/jasmine": "5.1.4", "@types/node": "20.12.11", @@ -98,7 +96,6 @@ "@web/test-runner": "^0.18.1", "angular-cli-ghpages": "1.0.7", "angular-http-server": "1.12.0", - "@jscutlery/cypress-angular": "^0.9.22", "cypress": "13.9.0", "eslint": "8.57.0", "eslint-config-prettier": "9.1.0", @@ -106,6 +103,7 @@ "eslint-plugin-prettier": "5.1.3", "jasmine-core": "5.1.2", "jasmine-spec-reporter": "7.0.0", + "lint-staged": "15.2.7", "markdownlint-cli": "0.40.0", "ng-packagr": "17.3.0", "npm-check-updates": "^16.14.20",