From 9b30f4f03ee64029967e33c63f9015dd0c243f1c Mon Sep 17 00:00:00 2001 From: andresbautista Date: Mon, 3 Feb 2025 14:38:31 +0100 Subject: [PATCH 1/5] feat: added LICENSE, workflows and updated README --- .github/workflows/lint.yml | 54 +++++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 18 ++++++++++++ .github/workflows/release.yml | 33 +++++++++++++++++++++ LICENSE | 21 ++++++++++++++ README.md | 29 +++++++++++++++++++ 5 files changed, 155 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/release.yml create mode 100644 LICENSE diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..a18c334 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,54 @@ +name: Lint +on: + workflow_call: + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + cache: yarn + + - name: Install project dependencies + run: yarn install + + - name: Run build script + run: yarn build + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: SvelteKitUtils + path: | + dist + + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + cache: yarn + + - name: Install project dependencies + run: yarn install + + - name: Check + run: yarn check + + - name: Eslint check + run: yarn eslint-check + + - name: Prettier check + run: yarn prettier-check diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..ae15db1 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,18 @@ +name: Main +on: + workflow_dispatch: + push: + branches: [main] +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: true + +jobs: + lint: + uses: ./.github/workflows/lint.yml + secrets: inherit + + release: + needs: lint + uses: ./.github/workflows/release.yml + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..df92db4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release +on: + workflow_call: + secrets: + NPM_TOKEN: + required: true + +jobs: + release: + name: Release + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + cache: yarn + + - name: Install project dependencies + run: yarn install + + - name: Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + publish: yarn changeset publish + createGithubReleases: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2673c1b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Chialab + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index e69de29..c40cfec 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,29 @@ +# SvelteKit Utils + +**SvelteKit Utils** is a set of libraries and utilities to improve the development experience with [SvelteKit](https://kit.svelte.dev/). + +## Usage + +Package is distribuited as NPM packages through the official NPM registry. + +### Install + +As long as the project is private, you must login to the NPM registry. Ask a colleague for credentials and run: + +``` +npm login +``` + +Then, you can use the `npm` cli or the `yarn` package manager to install the package as a dependency: + +``` +npm install @chialab/sveltekit-utils +``` + +``` +yarn add @chialab/sveltekit-utils +``` + +## License + +**SvelteKit Utils** are released under the [MIT](https://github.com/chialab/sveltekit-utils/blob/main/LICENSE) license. \ No newline at end of file From c477bf8ac54e202a620883a6b326582b09d35b79 Mon Sep 17 00:00:00 2001 From: andresbautista Date: Mon, 3 Feb 2025 14:49:39 +0100 Subject: [PATCH 2/5] chore: remove unnecessary NPM login instructions from README --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index c40cfec..f836563 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,6 @@ Package is distribuited as NPM packages through the official NPM registry. ### Install -As long as the project is private, you must login to the NPM registry. Ask a colleague for credentials and run: - -``` -npm login -``` - Then, you can use the `npm` cli or the `yarn` package manager to install the package as a dependency: ``` From 545f865a8d1789cfd5de8fe3059093b10b69ce2c Mon Sep 17 00:00:00 2001 From: andresbautista Date: Mon, 3 Feb 2025 14:49:52 +0100 Subject: [PATCH 3/5] refactor: simplify lint workflow and add pull request workflow --- .github/workflows/lint.yml | 35 +++++------------------------------ .github/workflows/pr.yml | 12 ++++++++++++ 2 files changed, 17 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a18c334..c022a4f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,31 +3,6 @@ on: workflow_call: jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - cache: yarn - - - name: Install project dependencies - run: yarn install - - - name: Run build script - run: yarn build - - - name: Upload build artifacts - uses: actions/upload-artifact@v3 - with: - name: SvelteKitUtils - path: | - dist - lint: name: Lint runs-on: ubuntu-latest @@ -45,10 +20,10 @@ jobs: run: yarn install - name: Check - run: yarn check + run: yarn run check - - name: Eslint check - run: yarn eslint-check + - name: Check eslint + run: yarn run eslint-check - - name: Prettier check - run: yarn prettier-check + - name: Check prettier + run: yarn run prettier-check diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..b856dea --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,12 @@ +name: Pull Request +on: + pull_request: + types: [opened, synchronize] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + uses: ./.github/workflows/lint.yml + secrets: inherit From a4ca9f520ba6ee1f80dea9442faf6761e1814f20 Mon Sep 17 00:00:00 2001 From: andresbautista Date: Mon, 3 Feb 2025 14:53:36 +0100 Subject: [PATCH 4/5] chore: remove unused publish command from release workflow and clean up package.json scripts --- .github/workflows/release.yml | 1 - package.json | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index df92db4..6731151 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,6 @@ jobs: id: changesets uses: changesets/action@v1 with: - publish: yarn changeset publish createGithubReleases: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index 8d7ba6d..59b28b7 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,7 @@ "eslint-fix": "eslint --fix --ignore-path .gitignore . --ext .js,.cjs,.ts,.svelte", "prettier-check": "prettier --check \"./**/*.{json,css,js,cjs,ts,svelte}\"", "prettier-fix": "prettier --write \"./**/*.{json,css,js,cjs,ts,svelte}\"", - "lint-fix-all": "yarn eslint-fix && yarn prettier-fix", - "publish": "yarn npm publish --tolerate-republish; git tag \"v$(node -e 'console.log(require(\"./package.json\").version);')\" || true" + "lint-fix-all": "yarn eslint-fix && yarn prettier-fix" }, "dependencies": { "cookie": "^1.0.2", From e45c574b0590e6baffb906455e95f85b44ee371c Mon Sep 17 00:00:00 2001 From: andresbautista Date: Mon, 3 Feb 2025 14:54:31 +0100 Subject: [PATCH 5/5] feat: add build step to release workflow --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6731151..f00c013 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,6 +22,9 @@ jobs: - name: Install project dependencies run: yarn install + - name: Build project + run: yarn build + - name: Create Release Pull Request or Publish to npm id: changesets uses: changesets/action@v1