Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BJvdA committed Mar 2, 2021
0 parents commit 31d2e8d
Show file tree
Hide file tree
Showing 70 changed files with 28,867 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-typescript",
"@babel/react"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
]
}
1 change: 1 addition & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ["@commitlint/config-conventional"] };
69 changes: 69 additions & 0 deletions .cz-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
module.exports = {
// add additional standard scopes here
scopes: [{ name: "accounts" }, { name: "admin" }],
// use this to permanently skip any questions by listing the message key as a string
skipQuestions: [],

/* DEFAULT CONFIG */
messages: {
type: "What type of changes are you committing:",
scope: "\nEnlighten us with the scope (optional):",
customScope: "Add the scope of your liking:",
subject: "Write a short and simple description of the change:\n",
body:
'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
breaking: "List any BREAKING CHANGES (optional):\n",
footer:
"List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n",
confirmCommit: "Are you sure you the above looks right?",
},
types: [
{
value: "fix",
name: "🐛 fix: Changes that fix a bug",
emoji: "🐛",
},
{
value: "feat",
name: " 🚀 feat: Changes that introduce a new feature",
emoji: "🚀",
},
{
value: "refactor",
name:
"🔍 refactor: Changes that neither fixes a bug nor adds a feature",
emoji: "🔍",
},
{
value: "test",
name: "💡 test: Adding missing tests",
emoji: "💡",
},
{
value: "style",
name:
"💅 style: Changes that do not impact the code base \n (white-space, formatting, missing semi-colons, etc)",
emoji: "💅",
},
{
value: "docs",
name: "📝 docs: Changes to the docs",
emoji: "📝",
},
{
value: "chore",
name:
"🤖 chore: Changes to the build process or auxiliary tools\n and or libraries such as auto doc generation",
emoji: "🤖",
},
],
allowTicketNumber: false,
isTicketNumberRequired: false,
ticketNumberPrefix: "#",
ticketNumberRegExp: "\\d{1,5}",
allowCustomScopes: true,
allowBreakingChanges: ["feat", "fix", "chore"],
breakingPrefix: "🚧 BREAKING CHANGES 🚧",
footerPrefix: "CLOSES ISSUE:",
subjectLimit: 100,
};
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/*
node_modules
public/*
dist/
.next
.next/*
25 changes: 25 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release
on:
push:
branches:
- master
jobs:
release:
name: Release
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 12
- name: Install dependencies
run: yarn
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn semantic-release
17 changes: 17 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CI
on: [pull_request]
jobs:
test:
name: 'Test'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 12
- name: Install modules
run: yarn
- name: Run tests
run: yarn test
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
.pnp
.pnp.js

# testing
coverage

# production
dist

# misc
.DS_Store
.env*

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
storybook-static
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/*
public/*
.next
.next/*
dist
coverage
39 changes: 39 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "angular",
"releaseRules": [
{
"release": "patch",
"type": "chore"
},
{
"release": "patch",
"type": "refactor"
},
{
"release": "patch",
"type": "style"
}
]
}
],
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
"@semantic-release/npm",
[
"@semantic-release/github",
{
"assets": ["CHANGELOG.md"]
}
]
]
}

23 changes: 23 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// These are all my auto-save configs
"editor.formatOnSave": true,
// turn it off for JS and JSX, we will do this via eslint
"[javascript]": {
"editor.formatOnSave": false
},
"[javascriptreact]": {
"editor.formatOnSave": false
},
"[typescript]": {
"editor.formatOnSave": false
},
"[typescriptreact]": {
"editor.formatOnSave": false
},
// tell the ESLint plugin to run on save
"editor.codeActionsOnSave": {
"source.fixAll": true
},
// Optional BUT IMPORTANT: If you have the prettier extension enabled for other languages like CSS and HTML, turn it off for JS since we are doing it through Eslint already
"prettier.disableLanguages": ["javascript", "javascriptreact", "typescript", "typescriptreact"]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Story of AMS

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.
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<p align="center">
<a href="https://storyofams.com/" target="_blank" align="center">
<img src="https://storyofams.com/public/[email protected]" alt="Story of AMS" width="120">
</a>
<h1 align="center">@storyofams/next-password-protect</h1>
</p>

Password protect your Next.js deployments.

## Installation

```sh
yarn add @storyofams/next-password-protect
# or
npm install @storyofams/next-password-protect
```

## Usage

There are 3 steps to enabling password protect: setting a global variable, adding the API route, and adding the HOC to \_app.

### Step 1

In order to be able to take advantage of dead code elimination, this library must be enabled using a global variable: `PASSWORD_PROTECT`.

To set this variable, add the following to `next.config.js`:

```javascript
const webpack = require('webpack');

module.exports = {
webpack(config) {
config.plugins.push(
new webpack.DefinePlugin({
PASSWORD_PROTECT: JSON.stringify(
// Add any logic you want here,
// returning `true` to enable password protect.
process.env.ENVIRONMENT === 'staging',
),
}),
);

return config;
},
});
```

### Step 2

Add an api route with the `passwordProtectHandler` api function. You can name it anything, as long as you pass the name to `apiPath` in the next step. By default it expects `/login`.

```javascript
import { passwordProtectHandler } from "@storyofams/next-password-protect";

export default passwordProtectHandler({
// Options go here (optional)
cookieName: "authorization",
});
```

### Step 3

Add the `withPasswordProtect` HOC to the default export of `App` in `pages/_app.tsx`:

```javascript
import { withPasswordProtect } from "@storyofams/next-password-protect";

// Before: export default App;
export default withPasswordProtect(App, "password", {
// Options go here (optional)
apiPath: "/login",
cookieName: "authorization",
});
```

_Note_: make sure to specify `apiPath` if the api route is not at `/login`!
1 change: 1 addition & 0 deletions example/.commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ["@commitlint/config-conventional"] };
Loading

0 comments on commit 31d2e8d

Please sign in to comment.