@tdk-landscape/tdk-cli-core 1.3.175 → 1.3.177
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/dist/backend-languages/node.js +102 -0
- package/cli/dist/backend-languages/registry.js +2 -0
- package/cli/dist/commands/resource.js +1 -1
- package/cli/dist-bundle/{chunk-MVPIW42J.js → chunk-W66JQVU6.js} +146 -74
- package/cli/dist-bundle/cli.js +4 -4
- package/cli/dist-bundle/{cold-preflight-2CT7SSV5.js → cold-preflight-6WRQUFZ6.js} +1 -1
- package/cli/package.json +1 -1
- package/engine/topologies/platform/docker/dockerfile/language_dockerfile.star +27 -2
- package/engine/topologies/tilt/generators/validators.star +1 -0
- package/engine/topologies/tilt/resources/orchestrator/apply_compose_resource_registration.star +9 -3
- package/package.json +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export const NODE_DEV_COMMAND = "node --watch src/index.js";
|
|
2
|
+
export const nodeBackendProvider = {
|
|
3
|
+
id: "node",
|
|
4
|
+
label: "Node.js 22",
|
|
5
|
+
devCommand: NODE_DEV_COMMAND,
|
|
6
|
+
watch: ["src/**/*"],
|
|
7
|
+
installHint: "npm install # optional: Docker builds the image for you",
|
|
8
|
+
createFiles(name) {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
filename: "package.json",
|
|
12
|
+
content: `{
|
|
13
|
+
"name": "${name}",
|
|
14
|
+
"version": "1.0.0",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"dev": "node --watch src/index.js",
|
|
18
|
+
"start": "node src/index.js",
|
|
19
|
+
"test": "node --test"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`,
|
|
23
|
+
description: "Generating package.json",
|
|
24
|
+
emoji: "📦",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
filename: "src/index.js",
|
|
28
|
+
content: `import http from "node:http";
|
|
29
|
+
|
|
30
|
+
const name = "${name}";
|
|
31
|
+
const port = Number(process.env.PORT) || 3000;
|
|
32
|
+
|
|
33
|
+
function sendJson(res, status, data) {
|
|
34
|
+
res.writeHead(status, { "Content-Type": "application/json" });
|
|
35
|
+
res.end(JSON.stringify(data));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const server = http.createServer((req, res) => {
|
|
39
|
+
const url = new URL(req.url, \`http://\${req.headers.host || "localhost"}\`);
|
|
40
|
+
|
|
41
|
+
// Health check endpoint (required by TILT_RESOURCE_DEFAULTS.star)
|
|
42
|
+
if (req.method === "GET" && url.pathname === "/health") {
|
|
43
|
+
return sendJson(res, 200, { status: "ok", service: name });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (req.method === "GET" && url.pathname === "/") {
|
|
47
|
+
return sendJson(res, 200, {
|
|
48
|
+
service: name,
|
|
49
|
+
version: "1.0.0",
|
|
50
|
+
endpoints: ["/health"],
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return sendJson(res, 404, { error: "Not Found" });
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (process.env.NODE_ENV !== "test") {
|
|
58
|
+
// "0.0.0.0" listens on every interface, which Traefik needs inside the container network.
|
|
59
|
+
server.listen(port, "0.0.0.0", () => {
|
|
60
|
+
console.log(\`\\n🚀 \${name} running on http://localhost:\${port}\`);
|
|
61
|
+
console.log(\`📊 Health check: http://localhost:\${port}/health\\n\`);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
`,
|
|
65
|
+
description: "Generating backend source",
|
|
66
|
+
emoji: "💻",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
filename: "tests/health.test.js",
|
|
70
|
+
content: `import assert from "node:assert/strict";
|
|
71
|
+
import { after, before, describe, it } from "node:test";
|
|
72
|
+
import { server } from "../src/index.js";
|
|
73
|
+
|
|
74
|
+
describe("health check", () => {
|
|
75
|
+
let baseUrl;
|
|
76
|
+
|
|
77
|
+
before((_, done) => {
|
|
78
|
+
server.listen(0, "127.0.0.1", () => {
|
|
79
|
+
const address = server.address();
|
|
80
|
+
baseUrl = \`http://127.0.0.1:\${address.port}\`;
|
|
81
|
+
done();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
after((_, done) => {
|
|
86
|
+
server.close(done);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("GET /health returns 200 with ok status", async () => {
|
|
90
|
+
const res = await fetch(\`\${baseUrl}/health\`);
|
|
91
|
+
assert.equal(res.status, 200);
|
|
92
|
+
const body = await res.json();
|
|
93
|
+
assert.deepEqual(body, { status: "ok", service: "${name}" });
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
`,
|
|
97
|
+
description: "Generating smoke test",
|
|
98
|
+
emoji: "🧪",
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
},
|
|
102
|
+
};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { TdkError } from "../utils/errors.js";
|
|
4
4
|
import { bunBackendProvider } from "./bun.js";
|
|
5
5
|
import { goBackendProvider } from "./go.js";
|
|
6
|
+
import { nodeBackendProvider } from "./node.js";
|
|
6
7
|
import { pythonBackendProvider } from "./python.js";
|
|
7
8
|
import { rustBackendProvider } from "./rust.js";
|
|
8
9
|
export const DEFAULT_BACKEND_LANGUAGE = "bun";
|
|
@@ -11,6 +12,7 @@ export const BACKEND_LANGUAGES = {
|
|
|
11
12
|
python: pythonBackendProvider,
|
|
12
13
|
go: goBackendProvider,
|
|
13
14
|
rust: rustBackendProvider,
|
|
15
|
+
node: nodeBackendProvider,
|
|
14
16
|
};
|
|
15
17
|
export function getBackendLanguage(languageId) {
|
|
16
18
|
const id = (languageId ?? DEFAULT_BACKEND_LANGUAGE).trim().toLowerCase();
|
|
@@ -288,7 +288,7 @@ export const resourceCommand = new Command("resource")
|
|
|
288
288
|
.option("-t, --type <type>", "Resource type: backend, frontend, worker, mcp, agent, bring-your-own, sdk", "backend")
|
|
289
289
|
.option("--framework <id>", "Framework: frontend react (default), vue, svelte, preact, lit, solid, qwik, vanilla, tanstack-router (see --frameworks); backend hono (default), express, elysia, fastify, nestjs, koa, h3")
|
|
290
290
|
.option("--frameworks", "List registered frontend frameworks and exit")
|
|
291
|
-
.option("--language <id>", "Backend language: bun (default), python, go, rust")
|
|
291
|
+
.option("--language <id>", "Backend language: bun (default), python, go, rust, node")
|
|
292
292
|
.option("-s, --stack <stack>", "Stack to assign resource to", "default")
|
|
293
293
|
.option("-p, --path <path>", "Custom path for resource directory")
|
|
294
294
|
.option("--resource-path <path>", "Alias for --path (for backward compatibility)")
|