Skip to content

Commit

Permalink
feat: offer-up script changes to work on codespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
amessbee committed Jul 6, 2024
1 parent 7309112 commit 6dd20cb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"docker:bash": "cd contract; docker compose exec agd bash",
"docker:make": "cd contract; docker compose exec agd make -C /workspace/contract",
"make:help": "make -C contract list",
"start:contract": "cd contract && yarn start",
"start:contract": "./set.hostname.sh && cd contract && yarn start",
"start:ui": "cd ui && yarn dev",
"lint": "yarn workspaces run lint",
"test": "yarn workspaces run test",
Expand Down
28 changes: 28 additions & 0 deletions set.hostname.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Step 1: Read the environment variable CODESPACE_NAME
CODESPACE_NAME="${CODESPACE_NAME}"

# Step 2: Define the file name
FILE="ui/src/App.tsx"

# Check if the file exists
if [ ! -f "$FILE" ]; then
echo "File $FILE does not exist."
exit 1
fi

# Step 3: Check if the environment variable is set and replace accordingly
if [ -z "$CODESPACE_NAME" ]; then
echo "CODESPACE_NAME is not set. Setting host with http://localhost"
sed -i "s|https://.*-1317\.app\.github\.dev/|http://localhost:1317|g" "$FILE"
sed -i "s|https://.*-26657\.app\.github\.dev/|http://localhost:26657|g" "$FILE"
else
echo "CODESPACE_NAME is set to $CODESPACE_NAME. Setting host with https://${CODESPACE_NAME}-1317.app.github.dev/"
sed -i "s|https://.*-1317\.app\.github\.dev/|https://${CODESPACE_NAME}-1317.app.github.dev/|g" "$FILE"
echo "CODESPACE_NAME is set to $CODESPACE_NAME. Setting host with https://${CODESPACE_NAME}-26675.app.github.dev/"
sed -i "s|https://.*-26657\.app\.github\.dev/|https://${CODESPACE_NAME}-26657.app.github.dev/|g" "$FILE"
fi

# Step 4: Notify the user of completion
echo "Replacement complete in $FILE"
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "./set.hostname.sh && vite",
"dev": "vite",
"build": "tsc && vite build",
"test": "vitest spec",
"test:e2e": "SKIP_EXTENSION_SETUP=true EXTENSION=keplr synpress run --configFile=test/e2e/synpress.config.cjs",
Expand Down

0 comments on commit 6dd20cb

Please sign in to comment.