-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adam McKee
committed
Apr 14, 2024
0 parents
commit 6980ba3
Showing
125 changed files
with
6,993 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.idea | ||
docker-compose.yml | ||
node_modules | ||
dist | ||
*/tsconfig.tsbuildinfo | ||
*/lib | ||
backend/.env | ||
backend/public | ||
e2e | ||
frontend/.env.offline | ||
frontend/.env.production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: blah | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
concurrency: blah-ci | ||
|
||
jobs: | ||
|
||
verified: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- verify-backend | ||
- verify-frontend | ||
- verify-template | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: echo "44.481800,-88.054413" | ||
|
||
verify-backend: | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgres:16 | ||
ports: | ||
- 5432:5432 | ||
env: | ||
POSTGRES_DB: eighty4 | ||
POSTGRES_USER: eighty4 | ||
POSTGRES_PASSWORD: eighty4 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 5s | ||
--health-timeout 5s | ||
--health-retries 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- name: sql | ||
run: | | ||
sudo apt-get install -y postgresql-client | ||
PGPASSWORD=eighty4 psql -h localhost -U eighty4 -f backend/sql/v001-init-schema.sql eighty4 | ||
- name: verify | ||
run: | | ||
corepack enable && corepack prepare pnpm@latest --activate | ||
pnpm i | ||
pnpm build | ||
pnpm test | ||
working-directory: backend | ||
|
||
verify-frontend: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- name: verify | ||
run: | | ||
apt-get update -y && apt-get install -y brotli | ||
corepack enable && corepack prepare pnpm@latest --activate | ||
pnpm i | ||
pnpm build | ||
pnpm svg | ||
working-directory: frontend | ||
|
||
verify-template: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- name: verify | ||
shell: 'script -q -e -c "bash {0}"' | ||
run: | | ||
corepack enable && corepack prepare pnpm@latest --activate | ||
pnpm i | ||
pnpm build | ||
pnpm test | ||
working-directory: template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: e2e | ||
|
||
on: | ||
push: | ||
branches: [ main, master ] | ||
pull_request: | ||
branches: [ main, master ] | ||
|
||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgres:16 | ||
ports: | ||
- 5432:5432 | ||
env: | ||
POSTGRES_DB: eighty4 | ||
POSTGRES_USER: eighty4 | ||
POSTGRES_PASSWORD: eighty4 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 5s | ||
--health-timeout 5s | ||
--health-retries 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- name: sql | ||
run: | | ||
sudo apt-get install -y postgresql-client | ||
PGPASSWORD=eighty4 psql -h localhost -U eighty4 -f backend/sql/v001-init-schema.sql eighty4 | ||
- name: pnpm | ||
run: | | ||
corepack enable && corepack prepare pnpm@latest --activate | ||
pnpm i | ||
- name: playwright | ||
env: | ||
CI: true | ||
run: | | ||
pnpm exec playwright install --with-deps | ||
pnpm exec playwright test | ||
working-directory: e2e | ||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: e2e/playwright-report/ | ||
retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.DS_Store | ||
.idea | ||
node_modules | ||
tsconfig.tsbuildinfo | ||
|
||
backend/lib | ||
backend/public | ||
contract/lib | ||
e2e/blob-report | ||
e2e/playwright/.cache | ||
e2e/playwright-report | ||
e2e/test-results | ||
frontend/.env.production | ||
frontend/dist | ||
github/lib | ||
template/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM node:20-alpine as build | ||
|
||
WORKDIR /install.sh | ||
COPY . . | ||
|
||
RUN corepack enable && corepack prepare pnpm@latest --activate | ||
RUN pnpm i | ||
RUN pnpm --filter @eighty4/install-frontend build && mv frontend/dist backend/public | ||
RUN pnpm --filter @eighty4/install-backend build | ||
RUN pnpm --filter @eighty4/install-backend --prod deploy dist | ||
|
||
FROM node:20-alpine | ||
|
||
WORKDIR /install.sh | ||
COPY --from=build /install.sh/dist /install.sh | ||
|
||
EXPOSE 5741 | ||
|
||
CMD ["node", "lib/Server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# install.eighty4.tech (unfortunately not install.sh) | ||
|
||
## Examples in the wild | ||
|
||
Here is a list of install scripts for popular applications: | ||
|
||
### Linux & OSX | ||
|
||
- rustup | ||
- wasm-pack | ||
|
||
### Windows | ||
|
||
## todos | ||
|
||
- https://neon.tech/docs/guides/aws-lambda | ||
- show profile avatar and login name of authed user | ||
- logout button | ||
- design framework | ||
- buttons: primary, secondary, disabled, icon | ||
- login button | ||
- input, select | ||
- repo link | ||
- release table | ||
- keyboard shortcut icons | ||
- color theme | ||
- minimized graph papers | ||
- loading indicator | ||
- #features text animation | ||
- #github text animation | ||
|
||
## cicd | ||
|
||
- write playwright tests | ||
- docker build after verified | ||
- run e2e tests against docker image | ||
- docker push | ||
- trigger deploy to linode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# https://github.com/settings/developers | ||
GITHUB_CLIENT_ID="" | ||
GITHUB_CLIENT_SECRET="" | ||
|
||
# https://node-postgres.com/features/connecting#environment-variables | ||
PGHOST="localhost" | ||
PGPORT="5432" | ||
PGDATABASE="eighty4" | ||
PGUSER="eighty4" | ||
PGPASSWORD="eighty4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "@eighty4/install-backend", | ||
"version": "0.0.1", | ||
"private": true, | ||
"author": "Adam McKee <[email protected]>", | ||
"license": "BSD-3-Clause", | ||
"type": "module", | ||
"scripts": { | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"dev": "tsx -r dotenv/config --watch src/Backend.ts", | ||
"build": "tsc --build" | ||
}, | ||
"dependencies": { | ||
"@eighty4/install-contract": "workspace:^", | ||
"@eighty4/install-github": "workspace:^", | ||
"@eighty4/install-template": "workspace:^", | ||
"cookie-parser": "^1.4.6", | ||
"express": "5.0.0-beta.3", | ||
"pg": "^8.11.5", | ||
"uuid": "^9.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/cookie-parser": "^1.4.7", | ||
"@types/express": "^4.17.21", | ||
"@types/pg": "8.11.2", | ||
"@types/uuid": "^9.0.8", | ||
"dotenv": "^16.4.5", | ||
"tsx": "^4.7.2", | ||
"typescript": "^5.4.4", | ||
"vitest": "^1.4.0" | ||
}, | ||
"files": [ | ||
"public/**/*", | ||
"lib/**/*", | ||
"package.json" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
drop schema if exists install_sh cascade; | ||
|
||
create schema install_sh; | ||
|
||
create table install_sh.users | ||
( | ||
id bigint primary key, | ||
email varchar not null, | ||
access_token varchar not null, | ||
created_when timestamp not null default now(), | ||
authed_when timestamp not null default now() | ||
); | ||
|
||
create table install_sh.scripts | ||
( | ||
id bigserial primary key, | ||
user_id integer not null references install_sh.users (id), | ||
repo_owner varchar not null, | ||
repo_name varchar not null, | ||
template_version varchar not null, | ||
created_when timestamp not null default now(), | ||
generated_when timestamp not null default now(), | ||
constraint script_user_repo_key unique (user_id, repo_owner, repo_name) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// import net from 'node:net' | ||
import cookieParser from 'cookie-parser' | ||
import express from 'express' | ||
import {authorizeGitHubUser, compressedStaticServer, printHttpLog} from './Middleware.js' | ||
import {generateScriptRouteFn, getLoginResultRouteFn, getOAuthRedirectRouteFn} from './Routes.js' | ||
|
||
const parsePortEnvVariable = (key: string, def: number): number => { | ||
const val = process.env[key] | ||
if (typeof val === 'undefined') { | ||
return def | ||
} else { | ||
try { | ||
return parseInt(val, 10) | ||
} catch (e) { | ||
console.error(`env variable ${key} must be numeric`) | ||
process.exit(1) | ||
} | ||
} | ||
} | ||
|
||
const HTTP_PORT = parsePortEnvVariable('HTTP_PORT', 5741) | ||
// const TCP_PORT = parsePortEnvVariable('TCP_PORT', 7411) | ||
|
||
const app = express() | ||
app.use(cookieParser()) | ||
app.use(express.json()) | ||
|
||
if (process.env['NODE_ENV'] === 'production') { | ||
app.use(compressedStaticServer) | ||
app.use(express.static('public')) | ||
} | ||
|
||
app.use(printHttpLog) | ||
|
||
app.get('/login/oauth/github', getOAuthRedirectRouteFn) | ||
app.get('/login/notify', getLoginResultRouteFn) | ||
app.post('/api/script', authorizeGitHubUser, generateScriptRouteFn) | ||
|
||
app.listen(HTTP_PORT, () => { | ||
console.log('install.sh http listening on', HTTP_PORT) | ||
}) | ||
|
||
// const tcp = net.createServer((c) => { | ||
// console.log('#feelthezig') | ||
// c.end() | ||
// }) | ||
// | ||
// tcp.listen(TCP_PORT, () => { | ||
// console.log('install.sh tcp listening on', TCP_PORT) | ||
// }) |
Oops, something went wrong.