Skip to content

Commit 81373e4

Browse files
committed
added a build script to make it easier for devs to launch
1 parent 91c1dd0 commit 81373e4

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

build.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
*
3+
*/
4+
5+
import child_process from "child_process";
6+
import { dirname } from "path";
7+
import { fileURLToPath } from "url";
8+
9+
const __dirname = dirname(fileURLToPath(import.meta.url));
10+
11+
const nextScript = `cd ${__dirname}/next-client && npm i && npm run build && npm run start`;
12+
const commonScript = `cd ${__dirname}/common && npm i && npm run build`;
13+
const expressScript = `cd ${__dirname}/express-pipeline && npm i && npm run build && npm run start`;
14+
15+
const runScript = (script) =>
16+
child_process.exec(
17+
`osascript -e 'tell application \"Terminal\" to do script \"${script}\"'`,
18+
);
19+
20+
const commonProcesss = runScript(commonScript);
21+
22+
commonProcesss.on("exit", function () {
23+
console.log("finished build common folder");
24+
const nextProcess = runScript(nextScript);
25+
const expressProcess = runScript(expressScript);
26+
nextProcess.on("exit", function () {
27+
console.log("finished building nextjs app");
28+
});
29+
30+
expressProcess.on("exit", function () {
31+
console.log("finished building express app");
32+
});
33+
});

contributing.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Working with Talk to the City
2+
3+
## Setup
4+
[See the setup instructions in README](./README.md#setup)
5+
6+
## Working in DEV
7+
After you have finished the basic setup:
8+
9+
1. run `npm i` at the root level
10+
2. run `npm run dev` at the root level. This will launch three different terminals
11+
- the NextJS client dev server
12+
- The Express app dev server
13+
- A watcher for changes in `/common`
14+
- Note: you can run these indepently by running `npm run dev` next/express folders and `npm run watch` in common.
15+
3. Go to `http://localhost:3000` to see the Next client
16+
17+
18+
## Tour De Repo
19+
20+
There are four main folders to look at:
21+
- `/next-client`
22+
- This is where the frontend client lives.
23+
- The two main features of it are the ability to submit data to the backend, and to render reports.
24+
- `/express-pipeline`
25+
- This is the backend Express app that handles submissions and works with the LLM to generate JSON reports.
26+
- Everything in `express-pipeline/src` will be transpiled into `/dist`.
27+
- `/common`
28+
- This is where shared type definitions are stored. It's symlinked with `next-client` and `/express-pipeline`.
29+
- If you don't have the watcher running, you'll need to rebuild anytime there's a change.
30+
- `/bin`
31+
- Scripts for managing Docker images. The main one you'll need to use is `./bin/docker-build-gcloud.sh`
32+
33+
Some general points:
34+
- The repo mostly uses TypeScript. Use TypeScript by default whenever you can.
35+
- Prettier is used for formatting. Code should always be formatted prior to being committed.
36+
- Husky is used for pre-commit hooks.
37+
- Zod is used for both types and parsing for any data shared across the frontend-backend.
38+
39+
## Submitting PRs
40+
41+
TBD

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"format": "npx prettier . --write",
77
"dev": "node dev.js",
8+
"build": "node build.js",
89
"prepare": "husky"
910
},
1011
"author": "Bruno Marnette",

0 commit comments

Comments
 (0)