Skip to content

Commit c2517c9

Browse files
committed
No more spaning everyhting in
1 parent 6220f4c commit c2517c9

3 files changed

Lines changed: 20 additions & 42 deletions

File tree

editor-backend/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ RUN pip install --no-cache-dir -r requirements.txt
9292

9393
COPY app/ ./app/
9494
COPY sdk/ ./sdk/
95+
COPY entrypoint.sh /entrypoint.sh
9596

9697
RUN mkdir -p /app/lib /app/data /root/Arduino /var/cache/ccache /var/lib/velxio-build
9798
COPY --from=qemu-provider /qemu/ /app/lib/
@@ -125,4 +126,4 @@ EXPOSE 8001
125126
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=90s \
126127
CMD curl -f "http://localhost:${PORT:-8001}/health" || exit 1
127128

128-
CMD ["sh", "-c", "echo \"[entrypoint] starting editor backend on port ${PORT:-8001}\" && exec uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8001}"]
129+
CMD ["/entrypoint.sh"]

editor-backend/entrypoint.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ ! -f /root/.arduino15/package_index.json ]; then
5+
echo "[entrypoint] initializing Arduino CLI indexes..."
6+
arduino-cli core update-index
7+
fi
8+
9+
if [ ! -f /root/.arduino15/package_index.json.bundled ]; then
10+
echo "[entrypoint] installing Arduino AVR core..."
11+
arduino-cli core install arduino:avr
12+
echo "[entrypoint] copying package index..."
13+
cp /root/.arduino15/package_index.json /root/.arduino15/package_index.json.bundled 2>/dev/null || true
14+
fi
15+
16+
echo "[entrypoint] starting editor backend on port ${PORT:-8001}"
17+
exec uvicorn app.main:app --host 0.0.0.0 --port "${PORT:-8001}"

src/lib/velxio/data/kitInventory.ts

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,6 @@ export const MISSING_KIT_B_PARTS = [
9090
"DuPont cables as placeable parts",
9191
];
9292

93-
const KIT_DEFAULT_PROPERTIES: Record<string, Record<string, unknown>> = {
94-
"led-red": { color: "red" },
95-
"led-yellow": { color: "yellow" },
96-
"led-blue": { color: "blue" },
97-
"led-green": { color: "green" },
98-
thermistor: { temperature: 25 },
99-
lm35dz: { temperature: 25 },
100-
dht11: { temperature: 25, humidity: 50 },
101-
"water-level-sensor": { level: 0 },
102-
"microphone-module": { soundLevel: 512 },
103-
"obstacle-avoidance-module": { distance: 100 },
104-
"74hc595": { values: [0, 0, 0, 0, 0, 0, 0, 0] },
105-
};
106-
10793
export function normalizeKitType(kitType?: string | null): KitType {
10894
return kitType === "esp32" ? "esp32" : "arduino";
10995
}
@@ -165,36 +151,10 @@ export function countKitBoards(boards: { boardKind?: BoardKind }[]) {
165151
return counts;
166152
}
167153

168-
function createKitComponent(metadataId: string, index: number, x: number, y: number) {
169-
return {
170-
id: `${metadataId.replace(/-/g, "_")}_kit_${index}`,
171-
metadataId,
172-
x,
173-
y,
174-
properties: { ...(KIT_DEFAULT_PROPERTIES[metadataId] ?? {}) },
175-
};
176-
}
177-
178154
export function createInitialKitPayload(kitType?: string | null) {
179155
const kit = normalizeKitType(kitType);
180156
const boardKind: BoardKind = kit === "esp32" ? "esp32" : "arduino-uno";
181157
const boardId = boardKind;
182-
const components = [];
183-
let slot = 0;
184-
185-
for (const [metadataId, quantity] of Object.entries(KIT_COMPONENT_LIMITS[kit])) {
186-
for (let i = 0; i < quantity; i += 1) {
187-
if (metadataId === "breadboard-full") {
188-
components.push(createKitComponent(metadataId, i + 1, 520, 80));
189-
continue;
190-
}
191-
192-
const col = slot % 8;
193-
const row = Math.floor(slot / 8);
194-
components.push(createKitComponent(metadataId, i + 1, 80 + col * 170, 620 + row * 150));
195-
slot += 1;
196-
}
197-
}
198158

199159
return {
200160
boards: [
@@ -215,7 +175,7 @@ export function createInitialKitPayload(kitType?: string | null) {
215175
fileGroups: {
216176
[`group-${boardId}`]: [{ name: "sketch.ino", content: "" }],
217177
},
218-
components,
178+
components: [],
219179
wires: [],
220180
activeBoardId: boardId,
221181
};

0 commit comments

Comments
 (0)