Skip to content

Commit bb0cba2

Browse files
authored
ARC 2256 - Enable user to see the basic skeleton of new config experience (#2216)
* - Setting up proxy server * - Minor revert - spa-proxy added * - Local dev and Prod commands added - React SPA added * - Cleanup * - Cleanup * - Cleanup * - Adding the JS file for connect apps * - Adding yarn again to avoid build errors * - Read me added - Setup for Prod * - Read me added - Setup for Prod * - ESlint fixes * - Updating snapshots * - Updating snapshots
1 parent b7a7cca commit bb0cba2

24 files changed

+2316
-7
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/**/*.js
22
prestart.ts
3+
spa/

etc/spa-build/spa-build.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cd spa
2+
3+
# Doing yarn install to avoid any build errors
4+
yarn
5+
6+
yarn build
7+
8+
echo "All done!!"

package.json

+8-5
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
"prestart": "run-p setup clean db:dev",
1313
"clean": "rimraf coverage build tmp src/**/*.js src/**/*.js.map test/**/*.js test/**/*.js.map",
1414
"init": "run-p db",
15-
"start": "run-p start:main start:worker",
15+
"start": "run-p spa:dev start:main start:worker",
1616
"start:main": "tsnd -r tsconfig-paths/register --watch=.env*,db/config.json --inspect=0.0.0.0:9229 --respawn --transpile-only -- src/main.ts",
1717
"start:worker": "tsnd -r tsconfig-paths/register --watch=.env*,db/config.json --inspect=0.0.0.0:9230 --respawn --transpile-only -- src/worker.ts",
1818
"start:production": "run-p start:main:production start:worker:production",
1919
"start:main:production": "node -r tsconfig-paths/register src/main",
2020
"start:worker:production": "node -r tsconfig-paths/register src/worker",
2121
"setup": "dotenv -- ts-node -r tsconfig-paths/register prestart.ts",
22-
"build": "tsc -p ./tsconfig.json",
23-
"build:release": "tsc -p ./tsconfig.release.json",
24-
"build:watch": "tsc -w -p ./tsconfig.json",
22+
"build": "tsc -p ./tsconfig.json && yarn spa:build",
23+
"build:release": "tsc -p ./tsconfig.release.json && yarn spa:build",
24+
"build:watch": "tsc -w -p ./tsconfig.json && yarn spa:build",
2525
"lint": "run-p lint:*",
2626
"lint:ts": "eslint . --ext .ts,.tsx",
2727
"lint:yaml": "yamllint github-for-jira.sd.yml",
@@ -48,7 +48,9 @@
4848
"test:e2e:start:headed": "yarn test:e2e:start --headed",
4949
"test:e2e:debug": "PWDEBUG=1 yarn test:e2e:headed",
5050
"test:e2e:watch": "nodemon --watch test/e2e -e ts --exec 'yarn test:e2e'",
51-
"test:e2e:watch:headed": "nodemon --watch test/e2e -e ts --exec 'yarn test:e2e:headed'"
51+
"test:e2e:watch:headed": "nodemon --watch test/e2e -e ts --exec 'yarn test:e2e:headed'",
52+
"spa:dev": "cd spa && yarn dev",
53+
"spa:build": "etc/spa-build/spa-build.sh"
5254
},
5355
"dependencies": {
5456
"@atlaskit/css-reset": "^2.0.5",
@@ -77,6 +79,7 @@
7779
"hbs": "^4.1.2",
7880
"helmet": "^3.21.2",
7981
"hot-shots": "^8.3.2",
82+
"http-proxy": "^1.18.1",
8083
"https-proxy-agent": "5.0.0",
8184
"ioredis": "^4.16.3",
8285
"is-base64": "^1.1.0",

spa/.eslintrc.cjs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
env: { browser: true, es2020: true },
3+
extends: [
4+
'eslint:recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'plugin:react-hooks/recommended',
7+
],
8+
root: true,
9+
parser: '@typescript-eslint/parser',
10+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
11+
plugins: ['react-refresh'],
12+
rules: {
13+
'react-refresh/only-export-components': 'warn',
14+
'semi': [ 2, 'always' ],
15+
'@typescript-eslint/no-empty-function': 'off'
16+
},
17+
}

spa/.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

spa/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Overview
2+
3+
This is the new frontend version of the app in React JS.
4+
5+
# For Development
6+
7+
This SPA is already run when you start the GitHub for Jira app. The app should be running at `http://localhost:5173`.
8+
For local instances, a proxy server has been created to run this locally, which is running on `https://NODE_TUNNEL_URL/spa`.
9+
10+
# For Production
11+
12+
This SPA is build when you run the build for the GitHub for Jira app.
13+
Running the `yarn build` should create `dist` folder which is served by the GitHub for Jira app under the url `/spa`.
14+
Check `router.ts#59`

spa/index.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>GitHub for Jira</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/index.tsx"></script>
12+
<!-- Per https://blog.developer.atlassian.com/announcement-reminder-about-deprecation-of-xdm_e-usage-and-needing-to-load-all-js-from-the-cdn/ we are required to load this from this specific CDN -->
13+
<!-- DO NOT TOUCH!!! THIS IS NEEDED FOR CONNECT OR ELSE IT WILL CAUSE AN ERROR -->
14+
<script src="https://connect-cdn.atl-paas.net/all.js"></script>
15+
</body>
16+
</html>

spa/package.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "spa",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc && vite build",
9+
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"@atlaskit/button": "^16.8.0",
14+
"@atlaskit/css-reset": "^6.5.2",
15+
"react": "^18.2.0",
16+
"react-dom": "^18.2.0"
17+
},
18+
"devDependencies": {
19+
"@types/react": "^18.2.14",
20+
"@types/react-dom": "^18.2.6",
21+
"@typescript-eslint/eslint-plugin": "^5.59.0",
22+
"@typescript-eslint/parser": "^5.59.0",
23+
"@vitejs/plugin-react": "^4.0.0",
24+
"eslint": "^8.38.0",
25+
"eslint-plugin-react-hooks": "^4.6.0",
26+
"eslint-plugin-react-refresh": "^0.3.4",
27+
"typescript": "^5.0.2",
28+
"vite": "^4.3.9"
29+
}
30+
}

spa/src/App.tsx

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { useState } from "react";
2+
import Button from "@atlaskit/button";
3+
4+
/**
5+
* This is just for testing
6+
* TODO: Remove this dummy component and add the actual ones
7+
*/
8+
const App = () => {
9+
const [count, setCount] = useState(0);
10+
11+
return (
12+
<>
13+
<h1>SPA</h1>
14+
<Button onClick={() => setCount((count) => count + 1)}>
15+
count is {count}
16+
</Button>
17+
</>
18+
);
19+
};
20+
21+
export default App;

spa/src/index.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from "react";
2+
import ReactDOM from "react-dom/client";
3+
import App from "./App";
4+
5+
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
6+
<React.StrictMode>
7+
<App />
8+
</React.StrictMode>,
9+
);
10+

spa/src/vite-env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

spa/tsconfig.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"useDefineForClassFields": true,
5+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6+
"module": "ESNext",
7+
"skipLibCheck": true,
8+
9+
/* Bundler mode */
10+
"moduleResolution": "node",
11+
"allowImportingTsExtensions": true,
12+
"resolveJsonModule": true,
13+
"isolatedModules": true,
14+
"noEmit": true,
15+
"jsx": "react-jsx",
16+
17+
/* Linting */
18+
"strict": true,
19+
"noUnusedLocals": true,
20+
"noUnusedParameters": true,
21+
"noFallthroughCasesInSwitch": true,
22+
"allowSyntheticDefaultImports": true
23+
},
24+
"include": ["src"],
25+
"references": [{ "path": "./tsconfig.node.json" }]
26+
}

spa/tsconfig.node.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"skipLibCheck": true,
5+
"module": "ESNext",
6+
"moduleResolution": "node"
7+
},
8+
"include": ["vite.config.ts"]
9+
}

spa/vite.config.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from "vite";
2+
import react from "@vitejs/plugin-react";
3+
4+
/**
5+
* Documentation: https://vitejs.dev/config/
6+
*/
7+
export default defineConfig({
8+
plugins: [react()],
9+
base: "/spa"
10+
});

0 commit comments

Comments
 (0)