Skip to content

Commit

Permalink
[WIP] first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ymrl committed Dec 18, 2023
0 parents commit 30cc1bf
Show file tree
Hide file tree
Showing 600 changed files with 125,301 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": [
"last 2 Chrome versions",
"last 2 Firefox versions",
"Firefox ESR",
"last 3 Safari versions",
"last 2 Edge versions",
"last 3 iOS versions",
"last 2 ChromeAndroid versions",
"last 2 FirefoxAndroid versions"
]
}
}
],
"@babel/preset-flow",
"@babel/preset-react",
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-flow-strip-types"
]
}
154 changes: 154 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
version: 2.1
executors:
node:
docker:
- image: cimg/node:18.16.1

defaults: &defaults
working_directory: ~/repo
parallelism: 1
executor:
name: node

aliases:
- &restore_npm_cache
restore_cache:
keys:
- npm-v7-dependency-{{ checksum "package-lock.json" }}
- npm-v7-dependency-

jobs:
build:
<<: *defaults

steps:
- checkout

- persist_to_workspace:
root: ~/
paths:
- repo

- *restore_npm_cache

- run:
name: install node dependencies
command: |
npm install
- run:
name: build package
command: |
npm run build
- save_cache:
paths:
- ./node_modules
key: npm-v7-dependency-{{ checksum "package-lock.json" }}

eslint_flow:
<<: *defaults

steps:
- attach_workspace:
at: ~/

- *restore_npm_cache

- run:
name: lint check for javascript
command: |
npm run lint --max-warnings=0
- store_test_results:
path: ./tmp/eslint

stylelint:
<<: *defaults

steps:
- attach_workspace:
at: ~/

- *restore_npm_cache

- run:
name: stylelint
command: |
npm run stylelint
- store_test_results:
path: ./tmp/stylelint

build_storybook:
<<: *defaults
resource_class: medium+

steps:
- attach_workspace:
at: ~/

- *restore_npm_cache

- run:
name: build
command: |
mkdir -p /tmp/storybook
npm run build-storybook -- -o /tmp/storybook
- store_artifacts:
path: /tmp/storybook

- run:
name: comment to pr
command: |
# PR トリガーではない場合はスキップ
if [ -z "$CIRCLE_PR_NUMBER" ]; then exit 0; fi
# https://support.circleci.com/hc/en-us/articles/5034956515355-How-to-Programmatically-Construct-the-URLs-for-Artifacts
index_html_url="https://output.circle-artifacts.com/output/job/${CIRCLE_WORKFLOW_JOB_ID}/artifacts/${CIRCLE_NODE_INDEX}/tmp/storybook/index.html"
# https://docs.github.com/en/rest/issues/comments?apiVersion=2022-11-28#create-an-issue-comment
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/issues/${CIRCLE_PR_NUMBER}/comments \
-d '{"body":"### Storybook\n'${index_html_url}'"}'
test:
<<: *defaults

steps:
- attach_workspace:
at: ~/

- *restore_npm_cache

- run:
name: test
command: npm test

- store_test_results:
path: ./tmp/test

workflows:
version: 2
integration:
jobs:
- build
- eslint_flow:
requires:
- build
- stylelint:
requires:
- build
- build_storybook:
context:
- github_token_sushi_bot
requires:
- build
- test:
requires:
- build
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/

12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
indent_style = tab
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist/
79 changes: 79 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
module.exports = {
parser: '@babel/eslint-parser',
env: {
browser: true,
jest: true,
node: true
},
plugins: ['react-hooks'],
globals: {},
extends: ['eslint:recommended', 'plugin:compat/recommended', 'plugin:import/recommended', 'plugin:jsx-a11y/recommended', 'plugin:react/recommended', 'plugin:storybook/recommended'],
settings: {
react: {
version: 'detect'
},
'import/resolver': {
node: {
extensions: ['.js', '.ts', '.tsx']
}
},
// TODO: browserslist を設定するか各 polyfill に対応
polyfills: ['window.scrollX', 'window.scrollY', 'Array.from']
},
rules: {
'no-unused-vars': ['error', {
vars: 'all',
args: 'all',
argsIgnorePattern: '^_'
}],
// TODO: ログインなどの要素に使えるようオフにしているが、要検討
'jsx-a11y/no-autofocus': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error'
},
overrides: [{
plugins: ['ft-flow'],
files: ['*.js', '*.js.flow'],
extends: ['plugin:ft-flow/recommended'],
rules: {
'ft-flow/generic-spacing': 'off',
'ft-flow/space-after-type-colon': 'off'
}
}, {
files: ['*.ts', '*.tsx'],
extends: ['eslint-config-freee-typescript'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'jsx-a11y/no-autofocus': 'off',
'@typescript-eslint/naming-convention': ['error', {
selector: 'default',
format: ['camelCase', 'PascalCase']
}, {
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase']
}, {
selector: 'parameter',
format: ['camelCase', 'snake_case', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow'
}, {
selector: 'property',
format: null
}, {
selector: 'memberLike',
modifiers: ['private'],
format: ['camelCase'],
leadingUnderscore: 'require'
}, {
selector: 'typeLike',
format: ['PascalCase']
}]
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts', '.tsx']
}
}
}
}]
};
20 changes: 20 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[ignore]
.*/__tests__/types/.*
lv1/.*
lv2/.*
utilities/.*
hooks/.*


[include]

[libs]

[lints]

[options]
server.max_workers=4
module.name_mapper='^vibes\(.*\)$' -> '<PROJECT_ROOT>\1'
sharedmemory.hash_table_pow=21

[strict]
18 changes: 18 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--
**注意**
これは public repositoryです。
ここに書いた情報は、全世界に公開されます。
社内の機密情報、特にリリース前のプロダクトや機能に関する情報を記載しないでください!
-->

## :memo: 概要
<!-- 変更内容を明記しよう -->

## :stuck_out_tongue: やってないこと
<!-- この PR ではやってないことなどを明記しよう -->

## :heavy_check_mark: 動作確認
<!-- 実装した個々の機能の再現方法を明記し、開発者・レビュワー共に確認しよう -->
- [ ] Storybook で 〇〇 が XX できるのを確認

33 changes: 33 additions & 0 deletions .github/workflows/publish_storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: publish Storybook
on:
push:
branches:
- 'main'
jobs:
publish:
if: github.repository == 'freee/vibes'
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: 'ap-northeast-1'
role-to-assume: ${{ secrets.PROD_AWS_ROLE_TO_ASSUME }}
# - uses: actions/setup-node@v3
# with:
# node-version-file: .node-version
# cache: 'npm'
# - name: Install Dependencies
# run: npm install
# - name: Build Storybook
# run: npm run build-storybook
- name: Publish to S3
env:
AWS_BUCKET: ${{ secrets.PROD_AWS_S3_BUCKET }}
run: aws s3 sync --delete ${GITHUB_WORKSPACE}/storybook-static/ ${AWS_BUCKET}



18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
node_modules
*.log
.DS_Store
.idea/
.cache
.vscode
storybook-static/
dist/

# docker
docker/.build_timestamp

# direnv / dotenv
.envrc
.env

# eslint cache
.eslintcache
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
Loading

0 comments on commit 30cc1bf

Please sign in to comment.