Updated Home (markdown)

sawka 2023-08-09 23:23:49 -07:00
parent 6246a8cba1
commit 4235e908ba

108
Home.md

@ -1,107 +1 @@
# Build Instructions for Prompt Client
## Prereqs and Tools
Download and install Go (must be at least go 1.18):
```
brew install go
```
Download and install ScriptHaus (to run the build commands):
```
brew tap scripthaus-dev/scripthaus
brew install scripthaus
```
## Repositories
Create a work directory (where all the repos will be located). Note do *not* use ~/prompt or ~/prompt-dev (as these directories are used by the actual prompt app). I use ~/work/prompt-dev.
Clone these 3 prompt repositories into your work directory:
```
git clone git@github.com:commandlinedev/prompt-client.git
git clone git@github.com:commandlinedev/prompt-server.git
git clone git@github.com:commandlinedev/apishell.git
```
## Building API Shell
```
# must be run from the apishell directory
scripthaus run fullbuild
```
This will create a "bin" directory in your apishell directory. There should be 4 binaries built, variations of mshell-v0.2 for different architectures.
## Building Prompt Server
Prompt Server depends on APIShell to build. Because APIShell is held in a private repository we need to set up a go workspace so go will not try to download apishell directly (it will fail because the module url is not public).
In your work directory (not in the prompt-server subdirectory), create a file called go.work with this content:
```
go 1.18
use (
./apishell
./prompt-server
)
```
Now, cd to the prompt-server directory and run:
```
scripthaus run build
```
If this worked, it will create a "bin" directory with one executable called "local-server".
## Running the Development Version of Prompt
If you install the production version of Prompt, you'll see a green sidebar, and the data for Prompt is stored in the directory ~/prompt. The development version has a red/brown sidebar and stores its data in ~/prompt-dev. This allows the production and development versions to be run simultaneously with no conflicts. If the dev database is corrupted by development bugs, or the schema changes in development it will not affect the production copy.
### One-Time Setup
The dev version of prompt needs access to the mshell and local-server binaries that we built in the previous steps. We'll create symlinks in the prompt-client directory to the bin directories that got created earlier:
```
ln -s ../apishell/bin dev-bin
ln -s ../prompt-server/bin local-server-bin
```
Install modules (we use yarn):
```
yarn
```
Electron also requires specific builds of node_modules to work (because Electron embeds a specific node.js version that might not match your development node.js version). We use a special electron command to cross-compile those modules:
```
scripthaus run electron-rebuild
```
### Running WebPack
Two webpacks are required to run the client. One webpack will build the React code that runs inside of Electron. The other webpack builds the node.js code for the Electron App Wrapper.
For the React code:
```
scripthaus run webpack-watch
```
For the Electron App:
```
scripthaus run webpack-electron-watch
```
### Running the Prompt Dev Client
Now that webpack is running (and watching for file changes) we can finally run the Prompt Dev Client! To start the client run:
```
scripthaus run electron
```
To kill the client, either exit the Electron App normally or just Ctrl-C the ```scripthaus run electron``` command.
Because we're running webpack in watch mode, any changes you make to the typescript will be automatically picked up by the client after a refresh. Note that I've disabled hot-reloading in the webpack config, so to pick up new changes you'll have to manually refresh the Prompt Client window. To do that use "Command-Shift-R" (Command-R is used internally by Prompt and will not force a refresh).
[[Build Instructions]]