Skip to content

Commit

Permalink
[infra] Move staff to infra (#1973)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnvr authored Jun 3, 2024
2 parents 493153d + ea476b9 commit c9340ed
Show file tree
Hide file tree
Showing 27 changed files with 2,869 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: "Deploy (staff)"

on:
# Run on every push to main that changes web/apps/staff/
# Run on every push to main that changes infra/staff/
push:
branches: [main]
paths:
- "web/apps/staff/**"
- ".github/workflows/web-deploy-staff.yml"
- "infra/staff/**"
- ".github/workflows/infra-deploy-staff.yml"
# Also allow manually running the workflow
workflow_dispatch:

Expand All @@ -16,7 +16,7 @@ jobs:

defaults:
run:
working-directory: web
working-directory: infra/staff

steps:
- name: Checkout code
Expand All @@ -29,17 +29,20 @@ jobs:
with:
node-version: 20
cache: "yarn"
cache-dependency-path: "web/yarn.lock"
cache-dependency-path: "infra/staff/yarn.lock"

- name: Install dependencies
run: yarn install

- name: Build staff
run: yarn build:staff
- name: Lint
run: yarn lint

- name: Publish staff
- name: Build
run: yarn build

- name: Publish
uses: cloudflare/wrangler-action@v3
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: pages deploy --project-name=ente --commit-dirty=true --branch=deploy/staff web/apps/staff/dist
command: pages deploy --project-name=ente --commit-dirty=true --branch=deploy/staff infra/staff/dist
1 change: 1 addition & 0 deletions infra/staff/.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_ENTE_ENDPOINT = http://localhost:8080
37 changes: 37 additions & 0 deletions infra/staff/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* eslint-env node */
module.exports = {
root: true,
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:react/jsx-runtime",
],
plugins: ["@typescript-eslint", "react-refresh"],
parserOptions: { project: true },
parser: "@typescript-eslint/parser",
ignorePatterns: [".eslintrc.cjs", "vite.config.ts", "dist"],
settings: { react: { version: "18.2" } },
rules: {
/* Allow numbers to be used in template literals */
"@typescript-eslint/restrict-template-expressions": [
"error",
{
allowNumber: true,
},
],
/* Allow void expressions as the entire body of an arrow function */
"@typescript-eslint/no-confusing-void-expression": [
"error",
{
ignoreArrowShorthand: true,
},
],
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
};
17 changes: 17 additions & 0 deletions infra/staff/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Node
node_modules/

# macOS
.DS_Store

# Editors
.vscode/

# Local env files
.env*.local

# tsc
*.tsbuildinfo

# Vite
dist
8 changes: 8 additions & 0 deletions infra/staff/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tabWidth": 4,
"proseWrap": "always",
"plugins": [
"prettier-plugin-organize-imports",
"prettier-plugin-packagejson"
]
}
19 changes: 19 additions & 0 deletions infra/staff/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Staff dashboard

Web app for staff members to help with support and other administration.

### Development

Use `yarn dev` to run a local dev server with hot reload.

> [!TIP]
>
> See [web/docs/new.md](../../web/docs/new.md) for help in setting up your
> editor to do the formatting and linting. You can also run the formatter and
> linter manually using `yarn lint`, and `yarn lint-fix` to fix them. These
> commands automatically run on every PR.
### Deployment

The app gets redeployed whenever a PR is merged into main. See
[web/docs/deploy.md](../../web/docs/deploy.md) for more details.
File renamed without changes.
35 changes: 35 additions & 0 deletions infra/staff/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "staff",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "tsc && vite build",
"dev": "vite",
"lint": "yarn prettier --check --log-level warn . && yarn eslint && yarn tsc",
"lint-fix": "yarn prettier --write --log-level warn . && yarn eslint --fix && yarn tsc",
"preview": "vite preview"
},
"dependencies": {
"react": "^18",
"react-dom": "^18",
"zod": "^3"
},
"devDependencies": {
"@types/react": "^18",
"@types/react-dom": "^18",
"@typescript-eslint/eslint-plugin": "^7",
"@typescript-eslint/parser": "^7",
"@vitejs/plugin-react": "^4.2",
"eslint": "^8",
"eslint-plugin-react": "^7.34",
"eslint-plugin-react-hooks": "^4.6",
"eslint-plugin-react-refresh": "^0.4.7",
"prettier": "^3",
"prettier-plugin-organize-imports": "^3.2",
"prettier-plugin-packagejson": "^2.5",
"typescript": "^5",
"vite": "^5.2"
},
"packageManager": "[email protected]"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions infra/staff/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
/* TSConfig file used for typechecking the files in src/.
*
* The base configuration was generated using `yarn create vite`. This was
* already almost the same as the `tsconfig-typecheck.json` we use
* elsewhere, with one or two differences.
*
* For more details about the flags vite cares about, see
* https://vitejs.dev/guide/features.html#typescript-compiler-options
*/
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "esnext",
"skipLibCheck": true,

/* Bundler mode. */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Linting. */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,

/*
* On top of the generated configuration, we've mostly added additional
* strictness checks.
*/

/* Require the `type` modifier when importing types. */
"verbatimModuleSyntax": true,

/* Stricter than strict. */
"noImplicitReturns": true,
/* e.g. makes array indexing returns undefined. */
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
15 changes: 15 additions & 0 deletions infra/staff/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
/* TSConfig file used for typechecking vite's config file itself.
*
* These are vite defaults, generated using `yarn create vite`.
*/
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true
},
"include": ["vite.config.ts"]
}
File renamed without changes.
Loading

0 comments on commit c9340ed

Please sign in to comment.