-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
188 lines (145 loc) · 3.98 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/bin/bash
set -e
#####################
# --- Constants --- #
#####################
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
BACKEND_DIR="$THIS_DIR/pulumi-ui-backend"
FRONTEND_DIR="$THIS_DIR/pulumi-ui-frontend"
PLAYGROUND_DIR="$THIS_DIR/pulumi-playground"
##########################
# --- Task Functions --- #
##########################
function install:backend {
(cd "$BACKEND_DIR" && uv pip install --editable ".[dev]")
}
function run:wheel {
uvx --with ${BACKEND_DIR}/dist/pulumi_ui-*.whl pulumi-ui up --state-uri file://~
}
function install:frontend {
(cd "$FRONTEND_DIR" && pnpm install)
}
function install {
install:backend
install:frontend
}
function dev:backend {
(cd "$BACKEND_DIR" && uv run --with-editable ./ -- pulumi-ui up --state-uri file://~ --debug)
}
function dev:frontend {
(cd "$FRONTEND_DIR" && npm run build -- --watch)
}
function dev {
trap 'kill 0' SIGINT
dev:frontend &
dev:backend &
wait
}
function dev:backend-aws {
(cd "$BACKEND_DIR" && AWS_PROFILE="pulumi-ui" AWS_REGION="us-west-2" python -m pulumi_ui.cli up --state-uri s3://mlops-club-pulumi-state --debug)
}
function dev-aws {
trap 'kill 0' SIGINT
dev:frontend &
dev:backend-aws &
wait
}
function dev-local {
trap 'kill 0' SIGINT
dev:frontend &
dev:backend &
wait
}
function build:backend {
(cd "$BACKEND_DIR" && python -m build --sdist --wheel .)
}
function build:frontend {
(cd "$FRONTEND_DIR" && pnpm run build)
}
function build {
# Build frontend
(cd "$FRONTEND_DIR" && npm run build)
# Copy built files to the backend static folder
mkdir -p "$BACKEND_DIR/src/pulumi_ui/static"
cp -r "$FRONTEND_DIR/dist/"* "$BACKEND_DIR/src/pulumi_ui/static/"
# Build backend wheel
(cd "$BACKEND_DIR" && python -m build --wheel)
}
function lint:backend {
(cd "$BACKEND_DIR" && pre-commit run --all-files)
}
function lint:frontend {
(cd "$FRONTEND_DIR" && npm run lint)
}
function lint {
lint:backend
lint:frontend
}
function test:backend {
(cd "$BACKEND_DIR" && python -m pytest)
}
function test:frontend {
(cd "$FRONTEND_DIR" && npm test)
}
function test {
test:backend
test:frontend
}
function clean:backend {
(cd "$BACKEND_DIR" && bash run.sh clean)
}
function clean:frontend {
(cd "$FRONTEND_DIR" && rm -rf dist node_modules)
}
function clean {
clean:backend
clean:frontend
}
# Add these functions to the run.sh file
function ensure_pipx {
if ! command -v pipx &> /dev/null; then
echo "pipx not found. Installing pipx..."
python3 -m pip install pipx
python3 -m pipx ensurepath
fi
}
function run_built_wheel {
WHEEL_FILE=$(ls -t "$BACKEND_DIR/dist/"*.whl | head -n1)
deactivate || true
rm -rf .tmp-venv || true
uv venv .tmp-venv
source .tmp-venv/bin/activate
uv pip install "$WHEEL_FILE"
.tmp-venv/bin/pulumi-ui up
}
function generate_lockfile {
docker run --rm -v "$FRONTEND_DIR:/app" -w /app --platform linux/arm64 node:22-bookworm-slim sh -c "npm install -g pnpm && pnpm install --lockfile-only"
}
# ... (keep the existing functions)
# Add these new functions for the Pulumi project
function pulumi:install {
(cd "$PLAYGROUND_DIR" && pip install -r requirements.txt)
}
function pulumi:build-layer {
(cd "$PLAYGROUND_DIR/src/pulumi_playground/automation_api_stacks/lambda_layer" && docker build -t lambda-layer .)
}
function pulumi:preview {
(cd "$PLAYGROUND_DIR" && pulumi preview)
}
function pulumi:up {
(cd "$PLAYGROUND_DIR" && pulumi up)
}
function pulumi:destroy {
(cd "$PLAYGROUND_DIR" && pulumi destroy)
}
# Modify the help function to include the new Pulumi commands
function help {
echo "$0 <task> <args>"
echo "Tasks:"
compgen -A function | grep -v "^_" | sort | cat -n
}
TIMEFORMAT="Task completed in %3lR"
time ${@:-help}
function pulumi:deploy-automation {
(cd "$PLAYGROUND_DIR" && python -m pulumi_playground.automation_api_stacks.deploy)
}