-
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.
install binary script gen with webapp
- Loading branch information
Adam McKee
committed
Jun 2, 2024
0 parents
commit 8b5a872
Showing
129 changed files
with
7,075 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,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,86 @@ | ||
name: verify | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
concurrency: verify-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,42 @@ | ||
name: deploy frontend to gh pages | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- name: Build | ||
run: | | ||
corepack enable && corepack prepare pnpm@latest --activate | ||
pnpm i | ||
pnpm build | ||
working-directory: frontend | ||
- name: Setup Pages | ||
uses: actions/configure-pages@v4 | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: 'frontend/dist' | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
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,32 @@ | ||
# install.eighty4.tech (unfortunately not install.sh) | ||
|
||
## Development | ||
|
||
| Package | Command | | ||
|----------|----------| | ||
| frontend | pnpm dev | | ||
| backend | pnpm dev | | ||
|
||
Database features are currently disabled to migrate the backend to a serverless environment. | ||
|
||
### Offline development | ||
|
||
Auth and features are dependent on GitHub APIs and thus require network connectivity during development. | ||
|
||
These commands will stub API dependencies for offline development: | ||
|
||
| Package | Command | | ||
|----------|------------------| | ||
| frontend | pnpm dev:offline | | ||
| offline | pnpm dev | | ||
|
||
Selfies and #installsh tweets while developing on an airplane, on safari, or in a James Cameron-funded submersible expedition are appreciated! | ||
|
||
## Examples install scripts in the wild | ||
|
||
Here is a list of install scripts for popular applications: | ||
|
||
- homebrew | ||
- pnpm | ||
- rustup | ||
- wasm-pack |
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 --clean && 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.