generated from sergiodxa/remix-auth-strategy-template
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c278759
Showing
16 changed files
with
446 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint-disable unicorn/prefer-module */ | ||
module.exports = { | ||
root: true, | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["@typescript-eslint", "unicorn", "jest", "prettier"], | ||
extends: [ | ||
"plugin:unicorn/recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended", | ||
], | ||
rules: { | ||
"prefer-const": "off", | ||
"@typescript-eslint/explicit-module-boundary-types": "off", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"no-unused-vars": "off", | ||
"no-var": "off", | ||
"unicorn/no-null": "off", | ||
"unicorn/prefer-node-protocol": "off", | ||
"unicorn/filename-case": "off", | ||
"unicorn/prevent-abbreviations": "off", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
changelog: | ||
categories: | ||
- title: Documentation Changes | ||
labels: | ||
- documentation | ||
- title: New Features | ||
labels: | ||
- enhancement | ||
- title: Bug Fixes | ||
labels: | ||
- bug | ||
- title: Other Changes | ||
labels: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Bump version | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Type of version (major / minor / patch)' | ||
required: true | ||
|
||
jobs: | ||
bump-version: | ||
name: Bump version | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out source | ||
uses: actions/checkout@v2 | ||
with: | ||
ssh-key: ${{ secrets.DEPLOY_KEY }} | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' | ||
cache: 'npm' | ||
- name: Install dependencies | ||
uses: bahmutov/npm-install@v1 | ||
- name: Setup Git | ||
run: | | ||
git config user.name '${{ secrets.GIT_USER_NAME }}' | ||
git config user.email '${{ secrets.GIT_USER_EMAIL }}' | ||
- name: bump version | ||
run: npm version ${{ github.event.inputs.version }} | ||
|
||
- name: Push latest version | ||
run: git push origin main --follow-tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node 14 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14 | ||
|
||
- name: Install dependencies | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
typecheck: | ||
name: Typechecker | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node 14 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14 | ||
|
||
- name: Install dependencies | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Typecheck | ||
run: npm run typecheck | ||
|
||
test: | ||
name: Unit and Integration Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node 14 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14 | ||
|
||
- name: Install dependencies | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Test | ||
run: npm run test -- --ci --coverage --maxWorkers=2 | ||
|
||
lint: | ||
name: Linter | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node 14 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14 | ||
|
||
- name: Install dependencies | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Lint | ||
run: npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Publish | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm install | ||
- run: npm run build | ||
- run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/node_modules | ||
/build | ||
/coverage | ||
|
||
*.log | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Contribution | ||
|
||
## Setup | ||
|
||
Run `npm install` to install the dependencies. | ||
|
||
Run the tests with `npm run test`. | ||
|
||
Run the linter with `npm run lint`. | ||
|
||
Run the typechecker with `npm run typecheck`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Sergio Xalambrí | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Remix Auth - Strategy Template | ||
|
||
> A template for creating a new Remix Auth strategy. | ||
If you want to create a new strategy for Remix Auth, you could use this as a template for your repository. | ||
|
||
The repo installs the latest version of Remix Auth and do the setup for you to have tests, linting and typechecking. | ||
|
||
## How to use it | ||
|
||
1. In the `package.json` change `name` to your strategy name, also add a description and ideally an author, repository and homepage keys. | ||
2. In `src/index.ts` change the `MyStrategy` for the strategy name you want to use. | ||
3. Implement the strategy flow inside the `authenticate` method. Use `this.success` and `this.failure` to correctly send finish the flow. | ||
4. In `tests/index.test.ts` change the tests to use your strategy and test it. Inside the tests you have access to `jest-fetch-mock` to mock any fetch you may need to do. | ||
5. Once you are ready, set the secrets on Github | ||
- `NPM_TOKEN`: The token for the npm registry | ||
- `GIT_USER_NAME`: The you want the bump workflow to use in the commit. | ||
- `GIT_USER_EMAIL`: The email you want the bump workflow to use in the commit. | ||
|
||
## Scripts | ||
|
||
- `build`: Build the project for production using the TypeScript compiler (strips the types). | ||
- `typecheck`: Check the project for type errors, this also happens in build but it's useful to do in development. | ||
- `lint`: Runs ESLint againt the source codebase to ensure it pass the linting rules. | ||
- `test`: Runs all the test using Jest. | ||
|
||
## Documentations | ||
|
||
To facilitae creating a documentation for your strategy, you can use the following Markdown | ||
|
||
```markdown | ||
# Strategy Name | ||
|
||
<!-- Description --> | ||
|
||
## Supported runtimes | ||
|
||
| Runtime | Has Support | | ||
| ---------- | ----------- | | ||
| Node.js | ✅ | | ||
| Cloudflare | ✅ | | ||
|
||
<!-- If it doesn't support one runtime, explain here why --> | ||
|
||
## How to use | ||
|
||
<!-- Explain how to use the strategy, here you should tell what options it expects from the developer when instantiating the strategy --> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { Config } from "@jest/types"; | ||
// eslint-disable-next-line unicorn/prefer-node-protocol | ||
// eslint-disable-next-line unicorn/import-style | ||
import * as path from "path"; | ||
|
||
const config: Config.InitialOptions = { | ||
verbose: Boolean(process.env.CI), | ||
rootDir: path.resolve("."), | ||
collectCoverageFrom: ["<rootDir>/src/**/*.ts"], | ||
setupFilesAfterEnv: ["<rootDir>/config/jest/setup.ts"], | ||
testMatch: ["<rootDir>/test/**/*.test.ts"], | ||
transform: { | ||
"\\.[jt]sx?$": [ | ||
"babel-jest", | ||
{ configFile: "./config/jest/babel.config.js" }, | ||
], | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* This Babel configuration is not being used by Remix to compiler our app. | ||
* The reason to configure Babel in our project is because Jest needs this | ||
* file to support JSX and TypeScript. This is also the reason why the | ||
* preset-env targets is only the current version of Node.js | ||
*/ | ||
/* eslint-disable unicorn/prefer-module */ | ||
module.exports = { | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
targets: { node: "current" }, | ||
}, | ||
], | ||
[ | ||
"@babel/preset-react", | ||
{ | ||
runtime: "automatic", | ||
}, | ||
], | ||
"@babel/preset-typescript", | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { installGlobals } from "@remix-run/node"; | ||
import "jest-fetch-mock/setupJest"; | ||
|
||
installGlobals(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"name": "remix-auth-strategy-template", | ||
"version": "0.0.0", | ||
"main": "./build/index.js", | ||
"types": "./build/index.d.ts", | ||
"scripts": { | ||
"build": "tsc --project tsconfig.json", | ||
"typecheck": "tsc --project tsconfig.json --noEmit", | ||
"lint": "eslint --ext .ts,.tsx src/", | ||
"test": "jest --config=config/jest.config.ts --passWithNoTests", | ||
"coverage": "npm run test -- --coverage" | ||
}, | ||
"keywords": [ | ||
"remix", | ||
"remix-auth", | ||
"auth", | ||
"authentication", | ||
"strategy" | ||
], | ||
"license": "MIT", | ||
"files": [ | ||
"build", | ||
"package.json", | ||
"README.md" | ||
], | ||
"peerDependencies": { | ||
"@remix-run/server-runtime": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.14.2", | ||
"@babel/preset-env": "^7.14.1", | ||
"@babel/preset-react": "^7.13.13", | ||
"@babel/preset-typescript": "^7.13.0", | ||
"@remix-run/node": "^1.0.3", | ||
"@remix-run/react": "^1.1.1", | ||
"@remix-run/server-runtime": "^1.0.0", | ||
"@types/jest": "^26.0.23", | ||
"@typescript-eslint/eslint-plugin": "^4.23.0", | ||
"@typescript-eslint/parser": "^4.23.0", | ||
"babel-jest": "^26.6.3", | ||
"eslint": "^7.26.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-jest": "^24.3.6", | ||
"eslint-plugin-jest-dom": "^3.9.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"eslint-plugin-unicorn": "^32.0.1", | ||
"jest": "^26.6.3", | ||
"jest-fetch-mock": "^3.0.3", | ||
"prettier": "^2.3.2", | ||
"react": "^17.0.2", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.3.5" | ||
}, | ||
"dependencies": { | ||
"remix-auth": "^3.0.0" | ||
} | ||
} |
Oops, something went wrong.