Skip to content

Commit a53b6ca

Browse files
Initial commit
1 parent 0b3f890 commit a53b6ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+15243
-1
lines changed

.devcontainer/devcontainer.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "Workbench template",
3+
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm",
4+
"hostRequirements": {
5+
"storage": "32gb",
6+
"memory": "8gb",
7+
"cpus": 4
8+
},
9+
// Runs automatically after Prebuild Template environment is created.
10+
"onCreateCommand": ".devcontainer/onCreate.sh",
11+
// Runs automatically every time the dev container has been (re-)started
12+
"postStartCommand": {
13+
"app": "USE_DESIGNER=true USE_SPARK_AGENT=true npm run dev",
14+
"ports": "gh cs ports visibility 5000:public -c $CODESPACE_NAME",
15+
"server": "spark-server",
16+
"spark-agent": "spark-agent",
17+
// "spark-designer": "spark-designer",
18+
"spark-file-syncer": "file-syncer.js 13000 >> /tmp/.spark-file-syncer.log 2>&1"
19+
},
20+
"forwardPorts": [4000, 5000, 9000, 13000],
21+
"features": {
22+
"ghcr.io/devcontainers/features/sshd:1": {
23+
"version": "latest"
24+
}
25+
}
26+
}
27+

.devcontainer/onCreate.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
rm -rf ./spark-sdk-dist
6+
7+
echo "Downloading the latest release of workbench-template from GitHub"
8+
9+
GITHUB_PAT="$RELEASE_PAT"
10+
REPO="github/workbench-template"
11+
12+
# Fetch the latest release information
13+
LATEST_RELEASE=$(curl -s -H "Authorization: token $GITHUB_PAT" https://api.github.com/repos/$REPO/releases/latest)
14+
15+
# Extract the first browser_download_url from the assets
16+
DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | jq -r '.assets[0].url')
17+
echo "Download URL: $DOWNLOAD_URL"
18+
19+
20+
# Fetch the latest release information
21+
curl -L -o dist.zip -H "Authorization: token $GITHUB_PAT" -H "Accept: application/octet-stream" "$DOWNLOAD_URL"
22+
23+
unzip -o dist.zip
24+
rm dist.zip
25+
26+
sudo mv ./spark-sdk-dist/server.js /usr/local/bin/spark-server
27+
sudo mv ./spark-sdk-dist/designer.js /usr/local/bin/spark-designer
28+
sudo mv ./spark-sdk-dist/file-syncer.js /usr/local/bin/spark-file-syncer
29+
sudo mv ./spark-sdk-dist/spark-agent.js /usr/local/bin/spark-agent
30+
31+
tar -xzf ./spark-sdk-dist/spark-tools/spark-tools.tgz
32+
33+
mkdir -p /workspaces/spark-tools
34+
sudo mv ./package/* /workspaces/spark-tools
35+
sudo rmdir ./package
36+
rm -rf ./spark-sdk-dist
37+
38+
cd /workspaces/spark-tools
39+
npm link
40+
41+
cd /workspaces/spark-template
42+
npm link @github/spark -f

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
.env
27+
**/agent-eval-report*
28+
.spark-tools

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# spark-template
1+
# Spark

components.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": false,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.js",
8+
"css": "src/main.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
},
20+
"iconLibrary": "lucide"
21+
}

deploy.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "[--Build: Started--]"
6+
7+
# Clean up the dist directory
8+
echo "Cleaning up the dist directory..."
9+
rm -rf dist
10+
11+
# Build the frontend
12+
echo "Compiling frontend..."
13+
npm install -f # force because there is a known mismatch of shadcn and react 19 - https://ui.shadcn.com/docs/react-19
14+
npm run build
15+
16+
# Build the backend
17+
echo "Compiling backend..."
18+
npm --prefix server install
19+
npm --prefix server run build
20+
21+
echo "Copying extra files..."
22+
cp ./server/package.json ./dist/package.json
23+
24+
echo "[--Build: Complete--]"
25+
echo "Executing the deployment upload script"
26+
echo "[--Deployment: Started--]"
27+
28+
# Check if GITHUB_RUNTIME_PERMANENT_NAME is empty.
29+
# This will be set when you run with the `copilot_workbench_kv_aca` flag.
30+
if [ -z "$GITHUB_RUNTIME_PERMANENT_NAME" ]; then
31+
echo "GITHUB_RUNTIME_PERMANENT_NAME is empty. Falling back to CODESPACE_NAME."
32+
33+
GITHUB_RUNTIME_PERMANENT_NAME=${CODESPACE_NAME}
34+
size=${#GITHUB_RUNTIME_PERMANENT_NAME}
35+
# if size is > 20, then truncate the name.
36+
# this is a limitation that's also enforced by the dotcom API
37+
# but I'd rather ensure that the command succeeds.
38+
if [ $size -gt 20 ]; then
39+
GITHUB_RUNTIME_PERMANENT_NAME=${GITHUB_RUNTIME_PERMANENT_NAME:0:20}
40+
fi
41+
fi
42+
43+
echo "Deploying as ${GITHUB_USER} to ${GITHUB_RUNTIME_PERMANENT_NAME}"
44+
45+
gh runtime create \
46+
--app ${GITHUB_RUNTIME_PERMANENT_NAME} \
47+
--env "GITHUB_RUNTIME_PERMANENT_NAME=${GITHUB_RUNTIME_PERMANENT_NAME}" \
48+
--secret "GITHUB_TOKEN=${GITHUB_TOKEN}" \
49+
50+
gh runtime deploy \
51+
--app ${GITHUB_RUNTIME_PERMANENT_NAME} \
52+
--dir dist
53+
54+
DEPLOYED_URL="$(gh runtime get --app ${GITHUB_RUNTIME_PERMANENT_NAME})"
55+
56+
echo "[--URL-App=[https://${DEPLOYED_URL}]--]"
57+
echo "[--Deployment: Complete--]"

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>GitHub Workbench</title>
7+
<link href="/src/main.css" rel="stylesheet">
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)