diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 0000000..e5b6d8d --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000..cfea69a --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", + "changelog": ["@changesets/changelog-github", { "repo": "asgardeo/passport-asgardeo" }], + "commit": false, + "fixed": [], + "linked": [], + "access": "restricted", + "baseBranch": "main", + "privatePackages": { + "version": true, + "tag": true + }, + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.changeset/purple-pumas-end.md b/.changeset/purple-pumas-end.md new file mode 100644 index 0000000..f1a7e50 --- /dev/null +++ b/.changeset/purple-pumas-end.md @@ -0,0 +1,5 @@ +--- +'@asgardeo/passport-asgardeo': patch +--- + +Very first release πŸŽ‰ diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6e87a00 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..5781d0a --- /dev/null +++ b/.eslintignore @@ -0,0 +1,6 @@ +# Global ignore file incase if a child package doesn't include one. + +/dist +/build +/node_modules +/coverage diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..ca7c925 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +module.exports = { + env: { + es6: true, + node: true, + }, + extends: ['plugin:@wso2/internal', 'plugin:@wso2/prettier'], + plugins: ['@wso2'], +}; diff --git a/issue_template.md b/.github/issue_template.md similarity index 96% rename from issue_template.md rename to .github/issue_template.md index 757e13e..52a7563 100644 --- a/issue_template.md +++ b/.github/issue_template.md @@ -1,18 +1,18 @@ -**Description:** - - -**Suggested Labels:** - - -**Suggested Assignees:** - - -**Affected Product Version:** - -**OS, DB, other environment details and versions:** - -**Steps to reproduce:** - - -**Related Issues:** - \ No newline at end of file +**Description:** + + +**Suggested Labels:** + + +**Suggested Assignees:** + + +**Affected Product Version:** + +**OS, DB, other environment details and versions:** + +**Steps to reproduce:** + + +**Related Issues:** + diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..3ce7212 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,21 @@ +### Purpose + + +### Related Issues +- + +### Related PRs +- + +### Checklist +- [ ] e2e cypress tests locally verified. +- [ ] Manual test round performed and verified. +- [ ] UX/UI review done on the final implementation. +- [ ] Documentation provided. (Add links if there are any) +- [ ] Unit tests provided. (Add links if there are any) +- [ ] Integration tests provided. (Add links if there are any) + +### Security checks +- [ ] Followed secure coding standards in http://wso2.com/technical-reports/wso2-secure-engineering-guidelines? +- [ ] Ran ESLint & Prettier plugins and verified? +- [ ] Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? diff --git a/.github/workflows/pr-builder.yml b/.github/workflows/pr-builder.yml new file mode 100644 index 0000000..a1ba36e --- /dev/null +++ b/.github/workflows/pr-builder.yml @@ -0,0 +1,235 @@ +# This workflow will build PRs submitted to the main branch. + +name: πŸ‘· PR Builder + +on: + pull_request: + branches: [main] + paths-ignore: + - "**.md" + - "LICENSE" + workflow_dispatch: + +# Avoid running multiple builds for the same PR. +concurrency: + group: pr-builder-${{ github.ref }} + cancel-in-progress: true + +env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + lint: + name: ⬣ ESLint (STATIC ANALYSIS) + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [lts/*] + pnpm-version: [latest] + steps: + - name: ⬇️ Checkout + id: checkout + uses: actions/checkout@v2.3.3 + with: + # We need to fetch all branches and commits so that Nx affected has a base to compare against. + fetch-depth: 0 + + - name: 🟒 Setup node + id: setup-node + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: 🐳 Set SHAs for Nx + id: set-shas + uses: nrwl/nx-set-shas@v3 + with: + main-branch-name: "main" + + - name: πŸ₯‘ Setup pnpm + id: setup-pnpm + uses: pnpm/action-setup@v2.1.0 + with: + version: ${{ matrix.pnpm-version }} + run_install: false + + - name: 🎈 Get pnpm store directory + id: get-pnpm-cache-dir + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - name: πŸ”† Cache pnpm modules + uses: actions/cache@v3 + id: pnpm-cache + with: + path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: 🧩 Install Dependencies + id: install-dependencies + run: pnpm install + + - name: πŸ¦„ Lint All Files + id: lint-with-eslint + run: pnpm nx affected --target=lint --parallel=3 --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} + + typecheck: + name: Κ¦ Typecheck (STATIC ANALYSIS) + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [lts/*] + pnpm-version: [latest] + steps: + - name: ⬇️ Checkout + id: checkout + uses: actions/checkout@v2.3.3 + with: + # We need to fetch all branches and commits so that Nx affected has a base to compare against. + fetch-depth: 0 + + - name: 🟒 Setup node + id: setup-node + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: 🐳 Set SHAs for Nx + id: set-shas + uses: nrwl/nx-set-shas@v3 + with: + main-branch-name: "main" + + - name: πŸ₯‘ Setup pnpm + uses: pnpm/action-setup@v2.1.0 + with: + version: ${{ matrix.pnpm-version }} + run_install: false + + - name: 🎈 Get pnpm store directory + id: get-pnpm-cache-dir + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - name: πŸ”† Cache pnpm modules + uses: actions/cache@v3 + id: pnpm-cache + with: + path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: 🧩 Install Dependencies + id: install-dependencies + run: pnpm install + + - name: β˜„οΈ Check Type Errors + run: pnpm nx affected --target=typecheck --parallel=3 --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} + + test: + name: πŸ‘Ύ Unit Test (TESTING) + # needs: [lint, typecheck] + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [lts/*] + pnpm-version: [latest] + steps: + - name: ⬇️ Checkout + id: checkout + uses: actions/checkout@v2.3.3 + with: + # We need to fetch all branches and commits so that Nx affected has a base to compare against. + fetch-depth: 0 + + - name: 🟒 Setup node + id: setup-node + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: πŸ₯‘ Setup pnpm + uses: pnpm/action-setup@v2.1.0 + with: + version: ${{ matrix.pnpm-version }} + run_install: false + + - name: 🎈 Get pnpm store directory + id: get-pnpm-cache-dir + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - name: πŸ”† Cache pnpm modules + uses: actions/cache@v3 + id: pnpm-cache + with: + path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: 🧩 Install Dependencies + id: install-dependencies + run: pnpm install + + - name: πŸƒ Run Jest & Collect Coverage + id: run-jest-test-and-coverage + run: pnpm test:ci + + - name: Upload `@asgardeo/passport-asgardeo` coverage reports to Codecov + id: upload-asgardeo-passport-coverage + uses: codecov/codecov-action@v4.0.1 + with: + files: ./lib/coverage/coverage-final.json + flags: '@asgardeo/passport-asgardeo' + token: ${{ secrets.CODECOV_TOKEN }} + + build: + name: 🚧 Build + # needs: [ lint, typecheck, test ] + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [lts/*] + pnpm-version: [latest] + steps: + - name: ⬇️ Checkout + id: checkout + uses: actions/checkout@v2.3.3 + + - name: 🟒 Setup node + id: setup-node + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: πŸ₯‘ Setup pnpm + uses: pnpm/action-setup@v2.1.0 + with: + version: ${{ matrix.pnpm-version }} + run_install: false + + - name: 🎈 Get pnpm store directory + id: get-pnpm-cache-dir + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - name: πŸ”† Cache pnpm modules + uses: actions/cache@v3 + id: pnpm-cache + with: + path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: 🧩 Install Dependencies + id: install-dependencies + run: pnpm install + + - name: πŸ—οΈ Build + id: build + run: pnpm build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1d0e910 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +# This workflow will release the packages. + +name: πŸš€ Release + +on: + push: + branches: + - main + workflow_dispatch: + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +env: + GH_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + +jobs: + release: + name: πŸ“¦ Release + if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')" + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [lts/*] + pnpm-version: [latest] + steps: + - name: ⬇️ Checkout + id: checkout + uses: actions/checkout@v2.3.3 + with: + fetch-depth: 0 + token: ${{ env.GH_TOKEN }} + + - name: 🟒 Setup node + id: setup-node + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: πŸ₯‘ Setup pnpm + id: setup-pnpm + uses: pnpm/action-setup@v2.1.0 + with: + version: ${{ matrix.pnpm-version }} + run_install: false + + - name: 🎈 Get pnpm store directory + id: get-pnpm-cache-dir + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + - name: 🧩 Install Dependencies + id: install-dependencies + run: pnpm install + + - name: πŸ—οΈ Build + id: build + run: pnpm build + + - name: πŸ“£ Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + title: "[Release] [GitHub Action] Update package versions" + publish: pnpm publish:packages + version: pnpm version:packages + commit: "[WSO2 Release] [GitHub Action] [Release] [skip ci] update package versions" + env: + GITHUB_TOKEN: ${{ env.GH_TOKEN }} diff --git a/.gitignore b/.gitignore index b1c8a62..300d4c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,34 +1,42 @@ -# Compiled class file -*.class +# See http://help.github.com/ignore-files/ for more about ignoring files. -# Log file -*.log +# compiled output +dist +tmp +/out-tsc -# BlueJ files -*.ctxt - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* -replay_pid* +# dependencies +node_modules -docs/ -reports/ +# IDEs and editors +/.idea +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# misc +/.sass-cache +/connect.lock +/coverage +/libpeerconnection.log +npm-debug.log +yarn-error.log +testem.log +/typings -# Mac OS X +# System Files .DS_Store +Thumbs.db -# Node.js -node_modules -npm-debug.log +# Nx +.nx diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index f1149ee..0000000 --- a/.jshintrc +++ /dev/null @@ -1,18 +0,0 @@ -{ - "node": true, - "bitwise": true, - "camelcase": true, - "curly": true, - "forin": true, - "immed": true, - "latedef": true, - "newcap": true, - "noarg": true, - "noempty": true, - "nonew": true, - "quotmark": "single", - "undef": true, - "unused": true, - "trailing": true, - "laxcomma": true -} diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 215b7fb..0000000 --- a/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile -docs/ -examples/ -reports/ -test/ - -.github/ -.jshintrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..19be10e --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +strict-peer-dependencies=false +auto-install-peers=true diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..9a2a0e2 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v20 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..5781d0a --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +# Global ignore file incase if a child package doesn't include one. + +/dist +/build +/node_modules +/coverage diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3297dfd..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: "node_js" -node_js: - - "5" - - "4" - - "3" # io.js - - "2" # io.js - - "1" # io.js - - "0.12" - - "0.10" - - "0.8" - - "0.6" - - -before_install: - - "npm install make-node@0.3.x -g" - - "preinstall-compat" - -script: - - "make test-cov" - -after_success: - - "make report-cov" - -sudo: false diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ad92582 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.formatOnSave": true +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..fbdb32d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,248 @@ +# Contributing to Asgardeo Passport Strategy + +This guide walks you through setting up the development environment and other important information for contributing to Asgardeo Passport Strategy. + +## Table of Contents +- [Prerequisite Software](#prerequisite-software) +- [Development Tools](#development-tools) + - [NX Console](#nx-console) + - [React Developer Tools](#react-developer-tools) + - [ESLint Plugin](#eslint-plugin) + - [Code Spell Checker](#code-spell-checker) + - [JSON Sort Order](#json-sort-order) +- [Setting up the Source Code](#setting-up-the-source-code) +- [Setting up the Development Environment](#setting-up-the-development-environment) +- [Contributing to the Documentation](#contributing-to-the-documentation) +- [Commit Message Guidelines](#commit-message-guidelines) + - [Commit Message Header](#commit-header) + - [Type](#type) + - [Scope](#scope) + - [Summary](#summary) + - [Commit Message Body](#commit-body) + - [Commit Message Footer](#commit-footer) + - [Revert commits](#revert-commits) + +## Prerequisite Software + +To build and write code, make sure you have the following set of tools on your local environment: + +* [Git](https://git-scm.com/downloads) - Open source distributed version control system. For install instructions, refer [this](https://www.atlassian.com/git/tutorials/install-git). +* [Node.js](https://nodejs.org/en/download/) - JavaScript runtime. (`v18 or higher`) +* [pnpm](https://pnpm.io/) - Alternate npm client for faster package installs. (`v9 or higher`) + +## Development Tools + +### NX Console + +Editor plugin which wraps NX commands so you don't have to memorize. + +- [Install for VS Code](https://marketplace.visualstudio.com/items?itemName=nrwl.angular-console) +- [Install for VS Web Storm](https://plugins.jetbrains.com/plugin/15000-nx-webstorm) + +### React Developer Tools + +Browser extension to debug React code. + +- [Download for Chrome](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en) +- [Download for Firefox](https://addons.mozilla.org/en-US/firefox/addon/react-devtools/) + +### ESLint Plugin + +Static code analysis tool for identifying problematic patterns found in JavaScript/Typescript code. + +- [Install for VS Code](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) +- [Install for VS Web Storm](https://www.jetbrains.com/help/webstorm/eslint.html) + +### Code Spell Checker + +A basic spell checker that works well with code and documents. + +- [Install for VS Code](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) + +### JSON Sort Order + +Sorts JSON objects in alphabetical order. + +- [Install for VS Code](https://marketplace.visualstudio.com/items?itemName=msyesyan.json-sorter) + +## Setting up the Source Code + +1. [Fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) the repository. +2. Clone your fork to the local machine. + +Replace `` with your own username. + +```shell +git clone https://github.com//passport-asgardeo.git +``` + +3. Set the original repo as the upstream remote. + +```shell +git remote add upstream https://github.com/asgardeo/passport-asgardeo.git +``` + +## Setting up the Development Environment + +1. Install dependencies. + +```bash +pnpm install +``` + +2. Build the project. + +```bash +pnpm build +``` + +## Contributing to the Documentation + +We use [Vitepress](https://vitepress.dev/) to generate the documentation site. The documentation site is located in the `docs` directory. +To contribute to the documentation, you can follow the steps below to start the Vitepress server locally. + +1. Navigate to the `docs` directory. + +```bash +cd docs +``` + +2. Start the Vitepress server. + +```bash +pnpm docs:dev +``` + +## Commit Message Guidelines + +*This specification is inspired by and supersedes the [AngularJS commit message format][commit-message-format].* + +We have very precise rules over how our Git commit messages must be formatted. +This format leads to **easier to read commit history**. + +Each commit message consists of a **header**, a **body**, and a **footer**. + +``` +
+ + + +