Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Initial setup #1

Merged
merged 6 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_NAME="Amplify SAM"
12 changes: 12 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
vite.config.ts
vitest.config.ts
playwright.config.ts

src/api
src/config

**/*.json
**/*.md
**/*.cjs
**/*.yaml
**/*.mjs
84 changes: 84 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:react-hooks/recommended',
'plugin:react/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: 'module',
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
plugins: ['react', 'react-hooks', '@typescript-eslint', 'simple-import-sort'],
rules: {
'react/react-in-jsx-scope': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-floating-promises': 'off', // we don't always care about unhandled promises
'@typescript-eslint/prefer-nullish-coalescing': 'off', // we sometimes want to use || instead of ??
'@typescript-eslint/no-misused-promises': [
'error',
{ checksVoidReturn: false },
],
},
overrides: [
{
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
rules: {
'simple-import-sort/imports': [
'error',
{
groups: [
// `react` first
['^react?(.+)'],
// Packages starting with `@`
['^@'],
// Packages starting with `~`
['^~'],
// Imports starting with `./`, `../` `src`
[
'^\\.\\.(?!/?$)',
'^\\.\\./?$',
'^\\./(?=.*/)(?!/?$)',
'^\\.(?!/?$)',
'^\\./?$',
'src',
],
// Imports starting with a character
['^[a-z]'],
// Style imports
['^.+\\.s?css$'],
// Side effect imports
['^\\u0000'],
],
},
],
},
},
{
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
excludedFiles: ['*.test.*', '*.stories.*', './src/providers/AuthProvider/**', './src/utils/auth_environment.ts'],
rules: {
'no-console': ['warn', { allow: ['warn', 'error'] }],
}
},
],
settings: {
react: {
pragma: 'React',
version: 'detect',
},
},
};
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @equinor/amplify-frontend
21 changes: 21 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build
on:
workflow_call:
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [21.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build
21 changes: 21 additions & 0 deletions .github/workflows/build_storybook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build storybook
on:
workflow_call:
jobs:
build-storybook:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [21.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build-storybook
21 changes: 21 additions & 0 deletions .github/workflows/code_coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test
on:
workflow_call:
jobs:
code-coverage:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [21.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4

- name: Install dependencies
run: npm ci

- name: Unit tests
run: npm run test:coverage
21 changes: 21 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint
on:
workflow_call:
jobs:
lint:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [21.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4

- name: Install dependencies
run: npm ci

- name: Linting
run: npm run lint
27 changes: 27 additions & 0 deletions .github/workflows/npm_publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: NPM Publish
on:
workflow_call:
secrets:
npm-token:
required: true
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 21.x

- name: Install dependencies
run: npm ci

- name: Run Tests
run: npm run test:ci

- name: Build Components
run: npm run build-components:ci

- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.npm-token }}
29 changes: 29 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Pull request

on:
pull_request:
branches: [main]
paths:
- "**"
- ".github/workflows/**"
workflow_dispatch:
jobs:
lint:
name: Lint
uses: ./.github/workflows/lint.yaml

test:
name: Test
uses: ./.github/workflows/test.yaml

code-coverage:
name: Code coverage
uses: ./.github/workflows/code_coverage.yaml

build:
name: Build
uses: ./.github/workflows/build.yaml

build-storybook:
name: Build storybook
uses: ./.github/workflows/build_storybook.yaml
22 changes: 22 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This is a basic workflow to help you get started with Actions

name: NPM Publish

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]

jobs:
publish:
name: Publish to NPM
uses: ./.github/workflows/npm_publish.yaml
secrets:
npm-token: ${{ secrets.NPM_TOKEN }}
release:
name: Create release notes
needs: [publish]
uses: ./.github/workflows/release.yaml
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Create release
on:
workflow_call:
secrets:
github-token:
required: true
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'

- name: Install dependencies
run: npm ci

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.github-token }}
run: npx semantic-release
21 changes: 21 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test
on:
workflow_call:
jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [21.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4

- name: Install dependencies
run: npm ci

- name: Unit tests
run: npm run test:ci
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
/dist
/lib

# testing
/coverage

# Webstorm user specific settings
.idea/workspace.xml

# production
/build
/storybook-static

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

# yarn modern
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*

4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/amplify-sam.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading