From 5a4b268c1c467bf272de219b0fb38fa4ae03e69c Mon Sep 17 00:00:00 2001 From: JackNoordhuis Date: Tue, 12 Sep 2023 18:23:55 +1000 Subject: [PATCH 1/2] update ci workflow + add pages publish workflow * Builds documentation site using typedoc package. * PR dev changes to dist branch. --- .github/workflows/ci.yml | 89 +++++++++++++++++++++++++ .github/workflows/pages-publish.yml | 67 +++++++++++++++++++ .github/workflows/publish-tsc-build.yml | 23 ------- .github/workflows/tsc-build.yml | 39 ----------- .gitignore | 1 + README.md | 17 +++-- package.json | 12 ++-- typedoc.json | 11 +++ 8 files changed, 184 insertions(+), 75 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/pages-publish.yml delete mode 100644 .github/workflows/publish-tsc-build.yml delete mode 100644 .github/workflows/tsc-build.yml create mode 100644 typedoc.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..45aa33a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,89 @@ +name: CI + +on: + push: + branches: [dev, dist] + +permissions: + contents: read + +env: + GITHUB_ACTIONS: true + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 5 + + strategy: + fail-fast: true + matrix: + node-version: [18] + + steps: + - uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Cache node_modules + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}}-${{ matrix.node-version }}-node_modules-${{ hashFiles('package.json') }} + + - name: Install dependencies + run: npm install + + - name: Build alpine-typescript + run: npm run build + + stage: + name: Stage changes as pull request + needs: [test] + runs-on: ubuntu-latest + timeout-minutes: 5 + + strategy: + fail-fast: true + matrix: + node-version: [18] + + if: github.ref == 'refs/heads/dev' + steps: + - run: 'echo "Staging dev changes"' + - uses: actions/checkout@v3 + with: + ref: dist + + - name: Reset branch + run: | + git fetch origin dev:dev + git reset --hard dev + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Cache node_modules + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}}-${{ matrix.node-version }}-node_modules-${{ hashFiles('package.json') }} + + - name: Install dependencies + run: npm install + + - name: Build alpine-typescript + run: npm run build-ci + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.STAGE_DEPLOY_KEY }} + title: Merge dev changes to dist + branch: dev-to-dist + assignees: JackNoordhuis diff --git a/.github/workflows/pages-publish.yml b/.github/workflows/pages-publish.yml new file mode 100644 index 0000000..c441a4b --- /dev/null +++ b/.github/workflows/pages-publish.yml @@ -0,0 +1,67 @@ +name: Publish Pages + +on: + push: + branches: [dist] + +permissions: + contents: write + +env: + GITHUB_ACTIONS: true + +jobs: + build: + name: Generate site + runs-on: ubuntu-latest + timeout-minutes: 5 + + strategy: + fail-fast: true + matrix: + node-version: [18] + + steps: + - uses: actions/checkout@v4 + + - name: Cache node_modules + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}}-${{ matrix.node-version }}-node_modules-${{ hashFiles('package.json') }} + + - name: Install dependencies + run: npm install + + - name: Build alpine-typescript + run: npm run docs-ci + + - name: Fix permissions + run: | + chmod -c -R +rX "./docs-build" | while read line; do + echo "::warning title=Invalid file permissions automatically fixed::$line" + done + + - uses: actions/upload-pages-artifact@v2 + with: + name: github-pages + path: ./docs-build + + publish: + name: Publish + needs: [build] + runs-on: ubuntu-latest + timeout-minutes: 5 + + permissions: + pages: write + id-token: write + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 diff --git a/.github/workflows/publish-tsc-build.yml b/.github/workflows/publish-tsc-build.yml deleted file mode 100644 index e1d0b50..0000000 --- a/.github/workflows/publish-tsc-build.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: publish-build - -on: - push: - branches: [dev] - -permissions: - contents: write - -env: - GITHUB_ACTIONS: true - -jobs: - publish: - runs-on: ubuntu-latest - timeout-minutes: 5 - - strategy: - matrix: - node-version: [18] - - steps: -# TODO: Cache tsc-build output and push to dist branch diff --git a/.github/workflows/tsc-build.yml b/.github/workflows/tsc-build.yml deleted file mode 100644 index 2b3679b..0000000 --- a/.github/workflows/tsc-build.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: build - -on: - push: - branches: [dev] - -permissions: - contents: read - -env: - GITHUB_ACTIONS: true - -jobs: - build: - runs-on: ubuntu-latest - timeout-minutes: 5 - - strategy: - matrix: - node-version: [18] - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - - name: Cache node_modules - uses: actions/cache@v3 - with: - path: node_modules - key: ${{ runner.os }}}-${{ matrix.node-version }}-node_modules-${{ hashFiles('package.json') }} - - - name: Install dependencies - run: npm install - - - name: Build alpine-typescript - run: npm run build diff --git a/.gitignore b/.gitignore index e5a82eb..04093ad 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ package-lock.json /node_modules .github/**/node_modules +docs-build/ ## Make sure tsc output isn't included in development branches *.d.ts diff --git a/README.md b/README.md index 79e81ab..8000eba 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@

- - - - Project Banner (@nxtlvlsoftware/alpine-typescript) - + + + + Project Banner (@nxtlvlsoftware/alpine-typescript) +

@@ -309,7 +309,7 @@ Alpine itself is very flexible with what it considers a component so this packag limitations. The only requirement imposed is the initial state of your component must be returned by some kind of constructor function. -See Alpine's [x-data documentation](https://alpinejs.dev/globals/alpine-data) for more information. +See Alpine's [Alpine.data() documentation](https://alpinejs.dev/globals/alpine-data) for more information. ##### Generic Types Any function that satisfies this type requirement: @@ -396,8 +396,7 @@ Guide #### Issues -Found a problem with this project? Make sure to open an issue on -the [issue tracker](https://github.com/NxtLvLSoftware/alpine-typescript/issues) +Found a problem with this project? Make sure to open an issue on the [issue tracker](https://github.com/NxtLvLSoftware/alpine-typescript/issues) and we'll do our best to get it sorted! ## License Information @@ -406,7 +405,7 @@ and we'll do our best to get it sorted! freely available to use under the terms of the [MIT License](https://www.techtarget.com/whatis/definition/MIT-License-X11-license-or-MIT-X-license). -__A full copy of the license is available [here](../LICENSE).__ +__A full copy of the license is available [here](https://github.com/NxtLvlSoftware/alpine-typescript/blob/dev/LICENSE).__ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, diff --git a/package.json b/package.json index a6fb33b..9112b5f 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,17 @@ "files": [ "README.md", "LICENSE", - "src/*", - "index.ts", + "src/**/*.d.ts", + "src/**/*.js", "index.d.ts", "index.js" ], "scripts": { - "build": "tsc -p ./", - "dev": "tsc --watch -p ./" + "build": "tsc --inlineSources --removeComments -p ./", + "build-ci": "tsc --pretty false --inlineSourceMap --removeComments --listEmittedFiles -p ./", + "dev": "tsc --watch -p ./", + "docs": "npx typedoc --out docs-build --cacheBust index.ts", + "docs-ci": "npx typedoc --gitRemote dist --out docs-build --cacheBust index.ts" }, "keywords": [ "alpine", @@ -27,6 +30,7 @@ "@types/alpinejs": "^3.7.2" }, "devDependencies": { + "typedoc": "^0.25.1", "typescript": "^5.1.6" } } diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 0000000..49b09ad --- /dev/null +++ b/typedoc.json @@ -0,0 +1,11 @@ +{ + "navigationLinks": { + "GitHub": "https://github.com/NxtLvlSoftware/alpine-typescript", + "Twitter": "https://twitter.com/NxtLvlSoftware" + }, + "sidebarLinks": { + "GitHub": "https://github.com/NxtLvlSoftware/alpine-typescript", + "Twitter": "https://twitter.com/NxtLvlSoftware", + "Home": "/index.html" + } +} \ No newline at end of file From c78651cb380359d87cd4ee240ac12a292700baac Mon Sep 17 00:00:00 2001 From: JackNoordhuis Date: Tue, 12 Sep 2023 18:25:37 +1000 Subject: [PATCH 2/2] update ci workflow: use build-ci script --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45aa33a..08e1b89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: run: npm install - name: Build alpine-typescript - run: npm run build + run: npm run build-ci stage: name: Stage changes as pull request