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

Feature/22998 - Init package #1

Merged
merged 34 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9d37f45
init project
rezkiy37 Jul 31, 2023
65ab46a
add typescript
rezkiy37 Jul 31, 2023
04f7cf3
add deps
rezkiy37 Jul 31, 2023
1434137
add eslint
rezkiy37 Jul 31, 2023
da8dd5b
add prettier
rezkiy37 Jul 31, 2023
0c8d20b
fix lint react warning
rezkiy37 Jul 31, 2023
1f49c78
uninstall deps
rezkiy37 Jul 31, 2023
d5db00c
fix id
rezkiy37 Jul 31, 2023
b5d46db
extend tsconfig
rezkiy37 Jul 31, 2023
cf0a088
add expensify deps
rezkiy37 Aug 1, 2023
f688ea3
fix ts launch
rezkiy37 Aug 1, 2023
fbb789d
fix lint
rezkiy37 Aug 2, 2023
85e214a
improve prettier ignore
rezkiy37 Aug 2, 2023
40d1f6b
improve project setup
rezkiy37 Aug 7, 2023
509c0c1
add husky
rezkiy37 Aug 7, 2023
f2b8c65
use pre-push
rezkiy37 Aug 7, 2023
79806f0
add gh actions
rezkiy37 Aug 8, 2023
bc0dea3
Revert "use pre-push"
rezkiy37 Aug 8, 2023
3b42444
Revert "add husky"
rezkiy37 Aug 8, 2023
56a4e39
split example with the source code
rezkiy37 Aug 8, 2023
8d396ce
prettify eslint
rezkiy37 Aug 8, 2023
3fbc77d
add react-fast-pdf package
rezkiy37 Aug 8, 2023
618624c
simplify scripts
rezkiy37 Aug 10, 2023
502e1e0
set 1.0.0 as initial version
rezkiy37 Aug 10, 2023
fd15c93
triger CI
rezkiy37 Aug 16, 2023
3e1437e
add on push trigger
rezkiy37 Aug 16, 2023
6a75742
triger CI
rezkiy37 Aug 16, 2023
c49cf7e
run prettier
rezkiy37 Aug 16, 2023
b1f8c63
Revert "add on push trigger"
rezkiy37 Aug 16, 2023
68b04e9
add test workflow
rezkiy37 Aug 16, 2023
59ce16f
fix
rezkiy37 Aug 16, 2023
1c31a34
remove test workflow
rezkiy37 Aug 16, 2023
a2d5aee
remove publish workflow
rezkiy37 Aug 16, 2023
5aa9aa4
connect cla workflow
rezkiy37 Aug 16, 2023
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
98 changes: 98 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"root": true,
"env": {
"browser": true,
"es2021": true,
"jest": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"extends": [
"eslint:recommended",
"airbnb",
"plugin:@typescript-eslint/recommended",
"plugin:react/jsx-runtime",
"plugin:jsx-a11y/recommended",
"plugin:react/recommended",
"prettier"
],
"plugins": [
"@typescript-eslint",
"react",
"jsx-a11y"
],
"ignorePatterns": [
"dist",
"node_modules",
".git"
],
"rules": {
"arrow-parens": [
"error",
"as-needed",
{
"requireForBlockBody": true
}
],
"no-invalid-this": "error",
"react/function-component-definition": [
"error",
{
"namedComponents": "function-declaration",
"unnamedComponents": "arrow-function"
}
],
"no-restricted-syntax": [
"error",
// The following four selectors prevent the usage of async/await
{
"selector": "AwaitExpression",
"message": "async/await is not allowed"
},
{
"selector": "FunctionDeclaration[async=true]",
"message": "async functions are not allowed"
},
{
"selector": "FunctionExpression[async=true]",
"message": "async functions are not allowed"
},
{
"selector": "ArrowFunctionExpression[async=true]",
"message": "async functions are not allowed"
},
{
"selector": "MethodDefinition[async=true]",
"message": "async methods are not allowed"
}
]
},
"overrides": [
{
"files": [
"*.ts",
"*.tsx"
],
"plugins": [
"@typescript-eslint"
],
"extends": [
"plugin:@typescript-eslint/recommended-type-checked",
"airbnb-typescript",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
}
}
],
"settings": {
"react": {
"version": "detect"
}
}
}
Binary file added .github/OSBotify-private-key.asc.gpg
Binary file not shown.
23 changes: 23 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- If necessary, assign reviewers that know the area or changes well. Feel free to tag any additional reviewers you see fit. -->

### Details

<!-- Explanation of the change or anything fishy that is going on -->

### Related Issues

<!-- Please replace GH_LINK with the link to the GitHub issue this Pull Request is related to -->

GH_LINK

### Manual Tests

<!---
Most changes should have accompanying tests. Describe the tests you added or if no tests were added an explanation about why one was not needed.
--->

### Linked PRs

<!---
Please include links to any update PRs in repos that must change their package.json version.
--->
39 changes: 39 additions & 0 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CLA Assistant

on:
issue_comment:
types: [created]
pull_request_target:
types: [opened, closed, synchronize]

jobs:
CLA:
runs-on: ubuntu-latest
# This job only runs for pull request comments or pull request target events (not issue comments)
if: github.event.issue.pull_request || github.event_name == 'pull_request_target'
steps:
- uses: actions-ecosystem/action-regex-match@9c35fe9ac1840239939c59e5db8839422eed8a73
id: sign
with:
text: ${{ github.event.comment.body }}
regex: '\s*I have read the CLA Document and I hereby sign the CLA\s*'
- uses: actions-ecosystem/action-regex-match@9c35fe9ac1840239939c59e5db8839422eed8a73
id: recheck
with:
text: ${{ github.event.comment.body }}
regex: '\s*recheck\s*'
- name: CLA Assistant
if: ${{ steps.recheck.outputs.match != '' || steps.sign.outputs.match != '' }} || github.event_name == 'pull_request_target'
# Version: 2.1.2-beta
uses: cla-assistant/github-action@948230deb0d44dd38957592f08c6bd934d96d0cf
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_BOTIFY_TOKEN }}
with:
path-to-signatures: '${{ github.repository }}/cla.json'
path-to-document: 'https://github.com/${{ github.repository }}/blob/main/CLA.md'
branch: 'main'
remote-organization-name: 'Expensify'
remote-repository-name: 'CLA'
lock-pullrequest-aftermerge: false
allowlist: 'snyk-bot,OSBotify'
87 changes: 87 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Publish package to npmjs

# This workflow runs when code is pushed to `main` (i.e: when a pull request is merged)
on:
push:
branches: [main]

# Ensure that only once instance of this workflow executes at a time.
# If multiple PRs are merged in quick succession, there will only ever be one publish workflow running and one pending.
concurrency: ${{ github.workflow }}

jobs:
version:
runs-on: ubuntu-latest

# OSBotify will update the version on `main`, so this check is important to prevent an infinite loop
if: ${{ github.actor != 'OSBotify' }}

steps:
- uses: actions/checkout@v3
with:
ref: main

- name: Decrypt & Import OSBotify GPG key
run: |
cd .github
gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output OSBotify-private-key.asc OSBotify-private-key.asc.gpg
gpg --import OSBotify-private-key.asc
env:
LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}

- name: Set up git for OSBotify
run: |
git config --global user.signingkey 367811D53E34168C
git config --global commit.gpgsign true
git config --global user.name OSBotify
git config --global user.email infra+osbotify@expensify.com

- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'

- name: Generate branch name
run: echo "BRANCH_NAME=OSBotify-bump-version-$(uuidgen)" >> $GITHUB_ENV

- name: Create branch for version-bump pull request
run: git checkout -b ${{ env.BRANCH_NAME }}

- name: Install npm packages
run: npm ci

- name: Update npm version
run: npm version patch

- name: Set new version in GitHub ENV
run: echo "NEW_VERSION=$(jq '.version' package.json)" >> $GITHUB_ENV

- name: Push branch and publish tags
run: git push --set-upstream origin ${{ env.BRANCH_NAME }} && git push --tags

- name: Create pull request
run: |
gh pr create \
--title "Update version to ${{ env.NEW_VERSION }}" \
--body "Update version to ${{ env.NEW_VERSION }}"
sleep 5
env:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

- name: Auto-approve pull request
run: gh pr review --approve ${{ env.BRANCH_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Auto-merge pull request
run: gh pr merge --merge --delete-branch ${{ env.BRANCH_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build package
run: npm run build

- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/style_and_syntax_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Style and Syntax Checks

on:
pull_request:
types: [opened, synchronize]

jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npx eslint src

- name: Run Prettier
run: npx prettier . --check

- name: Run TypeScript checks
run: npm run ts
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# OSX
.DS_Store

# node.js
node_modules/
npm-debug.log
dist/

# NPM file created by GitHub actions
.npmrc

# Decrypted private key we do not want to commit
.github/OSBotify-private-key.asc
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# The GH actions don't seem to compile and verify themselves well when Prettier is applied to them
dist
package.json
package-lock.json
*.html
*.css
*.scss
*.md
*.yml
*.yaml
9 changes: 9 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
tabWidth: 4,
singleQuote: true,
trailingComma: 'all',
bracketSpacing: false,
arrowParens: 'always',
printWidth: 190,
singleAttributePerLine: true,
};
74 changes: 74 additions & 0 deletions example/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
jest: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
tsconfigRootDir: __dirname,
},
extends: ['eslint:recommended', 'airbnb', 'plugin:@typescript-eslint/recommended', 'plugin:react/jsx-runtime', 'plugin:jsx-a11y/recommended', 'plugin:react/recommended', 'prettier'],
plugins: ['@typescript-eslint', 'react', 'jsx-a11y'],
ignorePatterns: ['dist', 'node_modules', '.git'],
rules: {
'arrow-parens': [
'error',
'as-needed',
{
requireForBlockBody: true,
},
],
'no-invalid-this': 'error',
'react/function-component-definition': [
'error',
{
namedComponents: 'function-declaration',
unnamedComponents: 'arrow-function',
},
],
'no-restricted-syntax': [
'error',
// The following four selectors prevent the usage of async/await
{
selector: 'AwaitExpression',
message: 'async/await is not allowed',
},
{
selector: 'FunctionDeclaration[async=true]',
message: 'async functions are not allowed',
},
{
selector: 'FunctionExpression[async=true]',
message: 'async functions are not allowed',
},
{
selector: 'ArrowFunctionExpression[async=true]',
message: 'async functions are not allowed',
},
{
selector: 'MethodDefinition[async=true]',
message: 'async methods are not allowed',
},
],
},
overrides: [
{
files: ['*.ts', '*.tsx'],
plugins: ['@typescript-eslint'],
extends: ['plugin:@typescript-eslint/recommended-type-checked', 'airbnb-typescript', 'prettier'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
},
],
settings: {
react: {
version: 'detect',
},
},
};
Loading