@tdk-landscape/tdk-cli-core 1.3.14
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/README.md +293 -0
- package/bin/tdk.js +14 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +64 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/completion.d.ts +3 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +294 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +220 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +176 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/down.d.ts +3 -0
- package/dist/commands/down.d.ts.map +1 -0
- package/dist/commands/down.js +32 -0
- package/dist/commands/down.js.map +1 -0
- package/dist/commands/help.d.ts +2 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +130 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/networks.d.ts +3 -0
- package/dist/commands/networks.d.ts.map +1 -0
- package/dist/commands/networks.js +260 -0
- package/dist/commands/networks.js.map +1 -0
- package/dist/commands/project.d.ts +3 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +360 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/projects.d.ts +3 -0
- package/dist/commands/projects.d.ts.map +1 -0
- package/dist/commands/projects.js +71 -0
- package/dist/commands/projects.js.map +1 -0
- package/dist/commands/resource.d.ts +69 -0
- package/dist/commands/resource.d.ts.map +1 -0
- package/dist/commands/resource.js +572 -0
- package/dist/commands/resource.js.map +1 -0
- package/dist/commands/resources.d.ts +3 -0
- package/dist/commands/resources.d.ts.map +1 -0
- package/dist/commands/resources.js +73 -0
- package/dist/commands/resources.js.map +1 -0
- package/dist/commands/stack.d.ts +3 -0
- package/dist/commands/stack.d.ts.map +1 -0
- package/dist/commands/stack.js +103 -0
- package/dist/commands/stack.js.map +1 -0
- package/dist/commands/stacks.d.ts +3 -0
- package/dist/commands/stacks.d.ts.map +1 -0
- package/dist/commands/stacks.js +43 -0
- package/dist/commands/stacks.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +71 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/ui.d.ts +3 -0
- package/dist/commands/ui.d.ts.map +1 -0
- package/dist/commands/ui.js +446 -0
- package/dist/commands/ui.js.map +1 -0
- package/dist/commands/up.d.ts +3 -0
- package/dist/commands/up.d.ts.map +1 -0
- package/dist/commands/up.js +149 -0
- package/dist/commands/up.js.map +1 -0
- package/dist/commands/upgrade.d.ts +3 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +454 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/version.d.ts +3 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +9 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/components/Accessible.d.ts +8 -0
- package/dist/components/Accessible.d.ts.map +1 -0
- package/dist/components/Accessible.js +10 -0
- package/dist/components/Accessible.js.map +1 -0
- package/dist/components/BaseTooltip.d.ts +4 -0
- package/dist/components/BaseTooltip.d.ts.map +1 -0
- package/dist/components/BaseTooltip.js +28 -0
- package/dist/components/BaseTooltip.js.map +1 -0
- package/dist/components/DetailPanel.d.ts +4 -0
- package/dist/components/DetailPanel.d.ts.map +1 -0
- package/dist/components/DetailPanel.js +18 -0
- package/dist/components/DetailPanel.js.map +1 -0
- package/dist/components/FileTree.d.ts +4 -0
- package/dist/components/FileTree.d.ts.map +1 -0
- package/dist/components/FileTree.js +47 -0
- package/dist/components/FileTree.js.map +1 -0
- package/dist/components/ResourceSelectInput.d.ts +4 -0
- package/dist/components/ResourceSelectInput.d.ts.map +1 -0
- package/dist/components/ResourceSelectInput.js +7 -0
- package/dist/components/ResourceSelectInput.js.map +1 -0
- package/dist/components/ResourceTable.d.ts +4 -0
- package/dist/components/ResourceTable.d.ts.map +1 -0
- package/dist/components/ResourceTable.js +18 -0
- package/dist/components/ResourceTable.js.map +1 -0
- package/dist/components/TabBar.d.ts +4 -0
- package/dist/components/TabBar.d.ts.map +1 -0
- package/dist/components/TabBar.js +17 -0
- package/dist/components/TabBar.js.map +1 -0
- package/dist/components/Tooltip.d.ts +12 -0
- package/dist/components/Tooltip.d.ts.map +1 -0
- package/dist/components/Tooltip.js +12 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +8 -0
- package/dist/components/index.js.map +1 -0
- package/dist/config/platform-standards.d.ts +159 -0
- package/dist/config/platform-standards.d.ts.map +1 -0
- package/dist/config/platform-standards.js +181 -0
- package/dist/config/platform-standards.js.map +1 -0
- package/dist/generator/extension-fetch.d.ts +9 -0
- package/dist/generator/extension-fetch.d.ts.map +1 -0
- package/dist/generator/extension-fetch.js +153 -0
- package/dist/generator/extension-fetch.js.map +1 -0
- package/dist/generator/template-engine.d.ts +60 -0
- package/dist/generator/template-engine.d.ts.map +1 -0
- package/dist/generator/template-engine.js +416 -0
- package/dist/generator/template-engine.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +236 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +17 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/cache.d.ts +19 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +64 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/command-helpers.d.ts +17 -0
- package/dist/utils/command-helpers.d.ts.map +1 -0
- package/dist/utils/command-helpers.js +48 -0
- package/dist/utils/command-helpers.js.map +1 -0
- package/dist/utils/constants.d.ts +50 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +100 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/discovery-context.d.ts +4 -0
- package/dist/utils/discovery-context.d.ts.map +1 -0
- package/dist/utils/discovery-context.js +39 -0
- package/dist/utils/discovery-context.js.map +1 -0
- package/dist/utils/docker.d.ts +3 -0
- package/dist/utils/docker.d.ts.map +1 -0
- package/dist/utils/docker.js +13 -0
- package/dist/utils/docker.js.map +1 -0
- package/dist/utils/env-validator.d.ts +15 -0
- package/dist/utils/env-validator.d.ts.map +1 -0
- package/dist/utils/env-validator.js +95 -0
- package/dist/utils/env-validator.js.map +1 -0
- package/dist/utils/errors.d.ts +28 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +127 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/file-helpers.d.ts +14 -0
- package/dist/utils/file-helpers.d.ts.map +1 -0
- package/dist/utils/file-helpers.js +45 -0
- package/dist/utils/file-helpers.js.map +1 -0
- package/dist/utils/formatting.d.ts +30 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/formatting.js +164 -0
- package/dist/utils/formatting.js.map +1 -0
- package/dist/utils/paths.d.ts +3 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +41 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/port-assignment.d.ts +6 -0
- package/dist/utils/port-assignment.d.ts.map +1 -0
- package/dist/utils/port-assignment.js +75 -0
- package/dist/utils/port-assignment.js.map +1 -0
- package/dist/utils/project-features.d.ts +23 -0
- package/dist/utils/project-features.d.ts.map +1 -0
- package/dist/utils/project-features.js +98 -0
- package/dist/utils/project-features.js.map +1 -0
- package/dist/utils/project-templates.d.ts +7 -0
- package/dist/utils/project-templates.d.ts.map +1 -0
- package/dist/utils/project-templates.js +24 -0
- package/dist/utils/project-templates.js.map +1 -0
- package/dist/utils/resource-features.d.ts +28 -0
- package/dist/utils/resource-features.d.ts.map +1 -0
- package/dist/utils/resource-features.js +148 -0
- package/dist/utils/resource-features.js.map +1 -0
- package/dist/utils/services.d.ts +18 -0
- package/dist/utils/services.d.ts.map +1 -0
- package/dist/utils/services.js +291 -0
- package/dist/utils/services.js.map +1 -0
- package/dist/utils/stack-features.d.ts +22 -0
- package/dist/utils/stack-features.d.ts.map +1 -0
- package/dist/utils/stack-features.js +13 -0
- package/dist/utils/stack-features.js.map +1 -0
- package/dist/utils/tar.d.ts +7 -0
- package/dist/utils/tar.d.ts.map +1 -0
- package/dist/utils/tar.js +21 -0
- package/dist/utils/tar.js.map +1 -0
- package/dist/utils/tilt.d.ts +18 -0
- package/dist/utils/tilt.d.ts.map +1 -0
- package/dist/utils/tilt.js +77 -0
- package/dist/utils/tilt.js.map +1 -0
- package/dist/utils/validation.d.ts +9 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +49 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +72 -0
- package/templates/.tiltignore.hbs +73 -0
- package/templates/TILT_RESOURCE_DEFAULTS.star.hbs +221 -0
- package/templates/TILT_TECH_STACK.star.hbs +150 -0
- package/templates/Tiltfile.hbs +295 -0
- package/templates/spec.master.hbs +186 -0
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import inquirer from "inquirer";
|
|
6
|
+
import { CREATABLE_RESOURCE_TYPES } from "../types/index.js";
|
|
7
|
+
import { assertValid, confirmOrCancel } from "../utils/command-helpers.js";
|
|
8
|
+
import { errorFactories, requireProjectRoot, runCommand } from "../utils/errors.js";
|
|
9
|
+
import { writeFilesWithProgress } from "../utils/file-helpers.js";
|
|
10
|
+
import { showCommandHeader } from "../utils/formatting.js";
|
|
11
|
+
import { assignPort } from "../utils/port-assignment.js";
|
|
12
|
+
import { getDefaultFeaturesForResourceType } from "../utils/resource-features.js";
|
|
13
|
+
import { discoverResources } from "../utils/services.js";
|
|
14
|
+
import { createKebabCaseValidator, validateResourceName } from "../utils/validation.js";
|
|
15
|
+
export const BASE_TEMPLATE = {
|
|
16
|
+
port: 0, // Will be assigned
|
|
17
|
+
dependencies: [],
|
|
18
|
+
build: {
|
|
19
|
+
dockerfile: "Dockerfile",
|
|
20
|
+
context: ".",
|
|
21
|
+
},
|
|
22
|
+
dev: {
|
|
23
|
+
command: "bun run dev",
|
|
24
|
+
watch: ["src/**/*"],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export const TYPE_SPECIFIC = {
|
|
28
|
+
backend: {
|
|
29
|
+
healthCheck: "/health",
|
|
30
|
+
},
|
|
31
|
+
frontend: {
|
|
32
|
+
dev: {
|
|
33
|
+
command: "bun run dev",
|
|
34
|
+
watch: ["src/**/*", "public/**/*"],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
worker: {
|
|
38
|
+
dev: {
|
|
39
|
+
command: "bun run worker",
|
|
40
|
+
watch: ["src/**/*"],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
export function createServiceJson(name, type, stack, port) {
|
|
45
|
+
const typeSpecific = TYPE_SPECIFIC[type];
|
|
46
|
+
const base = JSON.parse(JSON.stringify(BASE_TEMPLATE));
|
|
47
|
+
for (const [key, value] of Object.entries(typeSpecific)) {
|
|
48
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
49
|
+
base[key] = { ...base[key], ...value };
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
base[key] = value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
...base,
|
|
57
|
+
appName: name,
|
|
58
|
+
appType: type,
|
|
59
|
+
features: getDefaultFeaturesForResourceType(type),
|
|
60
|
+
name,
|
|
61
|
+
type,
|
|
62
|
+
stack,
|
|
63
|
+
port,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function createPackageJson(name, type) {
|
|
67
|
+
const isFrontend = type === "frontend";
|
|
68
|
+
return {
|
|
69
|
+
name: `@project/${name}`,
|
|
70
|
+
version: "0.0.1",
|
|
71
|
+
type: "module",
|
|
72
|
+
scripts: {
|
|
73
|
+
dev: isFrontend ? "vite" : "bun run --watch src/index.ts",
|
|
74
|
+
build: isFrontend ? "tsc && vite build" : "tsc",
|
|
75
|
+
test: "vitest",
|
|
76
|
+
lint: "biome check .",
|
|
77
|
+
"lint:fix": "biome check . --write",
|
|
78
|
+
},
|
|
79
|
+
dependencies: {
|
|
80
|
+
...(isFrontend ? {} : { hono: "^4.0.0" }),
|
|
81
|
+
},
|
|
82
|
+
devDependencies: {
|
|
83
|
+
"@types/bun": "latest",
|
|
84
|
+
typescript: "^7.0.2",
|
|
85
|
+
vitest: "^5.0.0",
|
|
86
|
+
"@biomejs/biome": "^2.5.13",
|
|
87
|
+
...(isFrontend ? { vite: "^5.0.0" } : {}),
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export const TSCONFIG_TEMPLATE = {
|
|
92
|
+
compilerOptions: {
|
|
93
|
+
target: "ES2022",
|
|
94
|
+
module: "ESNext",
|
|
95
|
+
moduleResolution: "bundler",
|
|
96
|
+
strict: true,
|
|
97
|
+
esModuleInterop: true,
|
|
98
|
+
skipLibCheck: true,
|
|
99
|
+
forceConsistentCasingInFileNames: true,
|
|
100
|
+
outDir: "./dist",
|
|
101
|
+
rootDir: "./src",
|
|
102
|
+
declaration: true,
|
|
103
|
+
declarationMap: true,
|
|
104
|
+
sourceMap: true,
|
|
105
|
+
},
|
|
106
|
+
include: ["src/**/*"],
|
|
107
|
+
exclude: ["node_modules", "dist"],
|
|
108
|
+
};
|
|
109
|
+
export const DOCKERFILE_TEMPLATE = `FROM oven/bun:1.2
|
|
110
|
+
|
|
111
|
+
WORKDIR /app
|
|
112
|
+
|
|
113
|
+
# Copy package files
|
|
114
|
+
COPY package.json bun.lock ./
|
|
115
|
+
|
|
116
|
+
# Install dependencies
|
|
117
|
+
RUN bun install --frozen-lockfile
|
|
118
|
+
|
|
119
|
+
# Copy source
|
|
120
|
+
COPY . .
|
|
121
|
+
|
|
122
|
+
# Build if needed
|
|
123
|
+
RUN bun run build
|
|
124
|
+
|
|
125
|
+
# Health check
|
|
126
|
+
HEALTHCHECK --interval=10s --timeout=5s --retries=3 \\
|
|
127
|
+
CMD curl -f http://localhost:3000/health || exit 1
|
|
128
|
+
|
|
129
|
+
EXPOSE 3000
|
|
130
|
+
|
|
131
|
+
CMD ["bun", "run", "start"]
|
|
132
|
+
`;
|
|
133
|
+
export function getBackendIndexTemplate(name) {
|
|
134
|
+
return `import { Hono } from 'hono';
|
|
135
|
+
|
|
136
|
+
const app = new Hono();
|
|
137
|
+
|
|
138
|
+
// Health check endpoint (required by TILT_RESOURCE_DEFAULTS.star)
|
|
139
|
+
app.get('/health', (c) => {
|
|
140
|
+
return c.json({ status: 'ok', service: '${name}' });
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
app.get('/health/live', (c) => {
|
|
144
|
+
return c.json({ status: 'alive', timestamp: Date.now() });
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
app.get('/health/ready', async (c) => {
|
|
148
|
+
const dependencies: Record<string, string> = {};
|
|
149
|
+
let allReady = true;
|
|
150
|
+
|
|
151
|
+
// Add dependency checks here (database, cache, etc.)
|
|
152
|
+
// Mark allReady = false if any dependency is unhealthy
|
|
153
|
+
|
|
154
|
+
const status = allReady ? 'ready' : 'not_ready';
|
|
155
|
+
return c.json({ status, dependencies }, allReady ? 200 : 503);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
app.get('/', (c) => {
|
|
159
|
+
return c.json({
|
|
160
|
+
service: '${name}',
|
|
161
|
+
version: '1.0.0',
|
|
162
|
+
endpoints: ['/health', '/health/live', '/health/ready']
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const port = process.env.PORT || 3000;
|
|
167
|
+
console.log('\\n🚀 ${name} running on http://localhost:' + port);
|
|
168
|
+
console.log('📊 Health check: http://localhost:' + port + '/health\\n');
|
|
169
|
+
|
|
170
|
+
export default {
|
|
171
|
+
port,
|
|
172
|
+
fetch: app.fetch,
|
|
173
|
+
};
|
|
174
|
+
`;
|
|
175
|
+
}
|
|
176
|
+
function getFrontendIndexTemplate(name) {
|
|
177
|
+
return `<!DOCTYPE html>
|
|
178
|
+
<html lang="en">
|
|
179
|
+
<head>
|
|
180
|
+
<meta charset="UTF-8" />
|
|
181
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
182
|
+
<title>${name}</title>
|
|
183
|
+
</head>
|
|
184
|
+
<body>
|
|
185
|
+
<div id="root"></div>
|
|
186
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
187
|
+
</body>
|
|
188
|
+
</html>
|
|
189
|
+
`;
|
|
190
|
+
}
|
|
191
|
+
const FRONTEND_MAIN_TEMPLATE = `import React from 'react';
|
|
192
|
+
import ReactDOM from 'react-dom/client';
|
|
193
|
+
import App from './App';
|
|
194
|
+
|
|
195
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
196
|
+
<React.StrictMode>
|
|
197
|
+
<App />
|
|
198
|
+
</React.StrictMode>,
|
|
199
|
+
);
|
|
200
|
+
`;
|
|
201
|
+
function getFrontendAppTemplate(name) {
|
|
202
|
+
return `function App() {
|
|
203
|
+
return (
|
|
204
|
+
<div style={{ padding: '2rem', fontFamily: 'system-ui' }}>
|
|
205
|
+
<h1>${name}</h1>
|
|
206
|
+
<p>Frontend resource created with TDK</p>
|
|
207
|
+
</div>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export default App;
|
|
212
|
+
`;
|
|
213
|
+
}
|
|
214
|
+
function getShutdownHandlerTemplate(signal) {
|
|
215
|
+
return `process.on('${signal}', () => {
|
|
216
|
+
console.log('[Worker] ${signal} received, shutting down gracefully...');
|
|
217
|
+
process.exit(0);
|
|
218
|
+
});`;
|
|
219
|
+
}
|
|
220
|
+
export function getWorkerIndexTemplate(name) {
|
|
221
|
+
return `console.log('🚀 ${name} worker started');
|
|
222
|
+
|
|
223
|
+
interface Job {
|
|
224
|
+
id: string;
|
|
225
|
+
type: string;
|
|
226
|
+
payload: Record<string, JsonValue>;
|
|
227
|
+
priority?: number;
|
|
228
|
+
timestamp?: string;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const CONFIG = {
|
|
232
|
+
pollIntervalMs: parseInt(process.env.WORKER_POLL_INTERVAL || '5000'),
|
|
233
|
+
maxRetries: parseInt(process.env.WORKER_MAX_RETRIES || '3'),
|
|
234
|
+
batchSize: parseInt(process.env.WORKER_BATCH_SIZE || '10'),
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
async function processJob(job: Job): Promise<void> {
|
|
238
|
+
console.log('[Worker] Processing job:', job.id, 'type:', job.type);
|
|
239
|
+
|
|
240
|
+
// Add job processing logic here using job.payload
|
|
241
|
+
|
|
242
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
243
|
+
console.log('[Worker] Job completed:', job.id);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
async function fetchJobs(): Promise<Job[]> {
|
|
247
|
+
// Connect to your queue (Redis, RabbitMQ, etc.) and fetch jobs
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async function main() {
|
|
252
|
+
console.log('[Worker] Configuration:', CONFIG);
|
|
253
|
+
|
|
254
|
+
while (true) {
|
|
255
|
+
try {
|
|
256
|
+
const jobs = await fetchJobs();
|
|
257
|
+
|
|
258
|
+
if (jobs.length === 0) {
|
|
259
|
+
await new Promise(resolve => setTimeout(resolve, CONFIG.pollIntervalMs));
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
console.log('[Worker] Fetched \${jobs.length} jobs');
|
|
264
|
+
|
|
265
|
+
for (const job of jobs) {
|
|
266
|
+
try {
|
|
267
|
+
await processJob(job);
|
|
268
|
+
} catch (error: unknown) {
|
|
269
|
+
console.error('[Worker] Job failed:', error);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
} catch (error: unknown) {
|
|
273
|
+
console.error('[Worker] Error in main loop:', error);
|
|
274
|
+
// Wait before retrying to avoid tight error loops
|
|
275
|
+
await new Promise(resolve => setTimeout(resolve, CONFIG.pollIntervalMs));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
${getShutdownHandlerTemplate("SIGTERM")}
|
|
281
|
+
|
|
282
|
+
${getShutdownHandlerTemplate("SIGINT")}
|
|
283
|
+
|
|
284
|
+
main().catch((err) => {
|
|
285
|
+
console.error('[Worker] Fatal error:', err);
|
|
286
|
+
process.exit(1);
|
|
287
|
+
});
|
|
288
|
+
`;
|
|
289
|
+
}
|
|
290
|
+
function getTestTemplate(name) {
|
|
291
|
+
return `import { describe, it, expect } from 'vitest';
|
|
292
|
+
|
|
293
|
+
describe('${name}', () => {
|
|
294
|
+
it('should pass a basic test', () => {
|
|
295
|
+
expect(true).toBe(true);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
`;
|
|
299
|
+
}
|
|
300
|
+
export const resourceCommand = new Command("resource")
|
|
301
|
+
.description("Create a new resource (service) from scratch, or register an existing one")
|
|
302
|
+
.argument("[name]", "Resource name (kebab-case)")
|
|
303
|
+
.option("-t, --type <type>", "Resource type: backend, frontend, worker, sdk", "backend")
|
|
304
|
+
.option("-s, --stack <stack>", "Stack to assign resource to", "default")
|
|
305
|
+
.option("-p, --path <path>", "Custom path for resource directory")
|
|
306
|
+
.option("--resource-path <path>", "Alias for --path (for backward compatibility)")
|
|
307
|
+
.option("--register-existing", "Register an existing resource without creating templates")
|
|
308
|
+
.action(async (name, options) => {
|
|
309
|
+
await runCommand(async () => {
|
|
310
|
+
const projectRoot = requireProjectRoot();
|
|
311
|
+
// Support --resource-path as alias for --path
|
|
312
|
+
const resourcePath = options.resourcePath || options.path;
|
|
313
|
+
showCommandHeader("Resource Creation");
|
|
314
|
+
const allResources = discoverResources();
|
|
315
|
+
let resourceName = name;
|
|
316
|
+
if (!resourceName) {
|
|
317
|
+
const { inputName } = await inquirer.prompt([
|
|
318
|
+
{
|
|
319
|
+
type: "input",
|
|
320
|
+
name: "inputName",
|
|
321
|
+
message: "Resource name (kebab-case):",
|
|
322
|
+
validate: createKebabCaseValidator("resource"),
|
|
323
|
+
},
|
|
324
|
+
]);
|
|
325
|
+
resourceName = inputName;
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
assertValid(validateResourceName(resourceName));
|
|
329
|
+
}
|
|
330
|
+
// Support sdk type for registering existing SDKs
|
|
331
|
+
let resourceType;
|
|
332
|
+
const validTypes = [...CREATABLE_RESOURCE_TYPES, "sdk"];
|
|
333
|
+
if (!validTypes.includes(options.type)) {
|
|
334
|
+
const { selectedType } = await inquirer.prompt([
|
|
335
|
+
{
|
|
336
|
+
type: "list",
|
|
337
|
+
name: "selectedType",
|
|
338
|
+
message: "Resource type:",
|
|
339
|
+
choices: [
|
|
340
|
+
{ name: "backend - API service with HTTP endpoints", value: "backend" },
|
|
341
|
+
{ name: "frontend - Web application/UI", value: "frontend" },
|
|
342
|
+
{ name: "worker - Background job processor", value: "worker" },
|
|
343
|
+
{ name: "sdk - Library/SDK (register existing)", value: "sdk" },
|
|
344
|
+
],
|
|
345
|
+
},
|
|
346
|
+
]);
|
|
347
|
+
resourceType = selectedType;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
resourceType = options.type;
|
|
351
|
+
}
|
|
352
|
+
let stackName = options.stack;
|
|
353
|
+
if (stackName === "default") {
|
|
354
|
+
const existingResources = allResources;
|
|
355
|
+
const stackSet = new Set();
|
|
356
|
+
for (const r of existingResources) {
|
|
357
|
+
if (r.stack)
|
|
358
|
+
stackSet.add(r.stack);
|
|
359
|
+
}
|
|
360
|
+
const existingStacks = Array.from(stackSet);
|
|
361
|
+
if (existingStacks.length > 0) {
|
|
362
|
+
const { selectedStack } = await inquirer.prompt([
|
|
363
|
+
{
|
|
364
|
+
type: "list",
|
|
365
|
+
name: "selectedStack",
|
|
366
|
+
message: "Assign to stack:",
|
|
367
|
+
choices: [
|
|
368
|
+
...existingStacks.map((s) => ({ name: s, value: s })),
|
|
369
|
+
{ name: "Create new stack", value: "__new__" },
|
|
370
|
+
],
|
|
371
|
+
},
|
|
372
|
+
]);
|
|
373
|
+
if (selectedStack === "__new__") {
|
|
374
|
+
const { newStack } = await inquirer.prompt([
|
|
375
|
+
{
|
|
376
|
+
type: "input",
|
|
377
|
+
name: "newStack",
|
|
378
|
+
message: "New stack name:",
|
|
379
|
+
validate: createKebabCaseValidator("stack"),
|
|
380
|
+
},
|
|
381
|
+
]);
|
|
382
|
+
stackName = newStack;
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
stackName = selectedStack;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
const { newStack } = await inquirer.prompt([
|
|
390
|
+
{
|
|
391
|
+
type: "input",
|
|
392
|
+
name: "newStack",
|
|
393
|
+
message: "Stack name (first resource):",
|
|
394
|
+
default: "main",
|
|
395
|
+
validate: createKebabCaseValidator("stack"),
|
|
396
|
+
},
|
|
397
|
+
]);
|
|
398
|
+
stackName = newStack;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
let finalResourcePath = resourcePath;
|
|
402
|
+
if (!finalResourcePath) {
|
|
403
|
+
const defaultPaths = {
|
|
404
|
+
backend: `services/${stackName}/${resourceName}`,
|
|
405
|
+
frontend: `apps/${resourceName}`,
|
|
406
|
+
worker: `workers/${resourceName}`,
|
|
407
|
+
sdk: `packages/${resourceName}`,
|
|
408
|
+
};
|
|
409
|
+
finalResourcePath = defaultPaths[resourceType];
|
|
410
|
+
}
|
|
411
|
+
const fullPath = resolve(projectRoot, finalResourcePath);
|
|
412
|
+
// Prevent path traversal attacks
|
|
413
|
+
const relativePathResult = relative(projectRoot, fullPath);
|
|
414
|
+
if (relativePathResult.startsWith("..") || isAbsolute(relativePathResult)) {
|
|
415
|
+
errorFactories.invalidPath(fullPath).display();
|
|
416
|
+
process.exit(1);
|
|
417
|
+
}
|
|
418
|
+
if (finalResourcePath.includes("\0") || /[<>:"|?*]/.test(finalResourcePath)) {
|
|
419
|
+
errorFactories.invalidPath(finalResourcePath).display();
|
|
420
|
+
process.exit(1);
|
|
421
|
+
}
|
|
422
|
+
// Check if resource already exists
|
|
423
|
+
const isExistingResource = existsSync(fullPath);
|
|
424
|
+
const hasServiceJson = existsSync(resolve(fullPath, "service.json"));
|
|
425
|
+
const shouldRegisterExisting = options.registerExisting ||
|
|
426
|
+
resourceType === "sdk" ||
|
|
427
|
+
(isExistingResource && hasServiceJson);
|
|
428
|
+
if (isExistingResource && !shouldRegisterExisting) {
|
|
429
|
+
errorFactories.directoryExists(fullPath).display();
|
|
430
|
+
process.exit(1);
|
|
431
|
+
}
|
|
432
|
+
const assignedPort = resourceType === "sdk"
|
|
433
|
+
? 0
|
|
434
|
+
: assignPort(resourceType, allResources);
|
|
435
|
+
console.log(chalk.gray("\nResource details:"));
|
|
436
|
+
console.log(chalk.gray(` Name: ${resourceName}`));
|
|
437
|
+
console.log(chalk.gray(` Type: ${resourceType}`));
|
|
438
|
+
console.log(chalk.gray(` Stack: ${stackName}`));
|
|
439
|
+
console.log(chalk.gray(` Port: ${assignedPort || "N/A (SDK)"}`));
|
|
440
|
+
console.log(chalk.gray(` Path: ${finalResourcePath}`));
|
|
441
|
+
if (shouldRegisterExisting && hasServiceJson) {
|
|
442
|
+
console.log(chalk.yellow("\n⚠️ Existing resource detected - will update service.json only"));
|
|
443
|
+
}
|
|
444
|
+
const confirmed = await confirmOrCancel(shouldRegisterExisting && hasServiceJson
|
|
445
|
+
? "\nRegister existing resource?"
|
|
446
|
+
: "\nCreate resource?");
|
|
447
|
+
if (!confirmed)
|
|
448
|
+
return;
|
|
449
|
+
// Handle existing resource registration
|
|
450
|
+
if (shouldRegisterExisting && hasServiceJson) {
|
|
451
|
+
// Read existing service.json
|
|
452
|
+
const { readFileSync } = await import("node:fs");
|
|
453
|
+
const existingServiceJsonPath = resolve(fullPath, "service.json");
|
|
454
|
+
const existingContent = readFileSync(existingServiceJsonPath, "utf-8");
|
|
455
|
+
const existingServiceJson = JSON.parse(existingContent);
|
|
456
|
+
// Update with new values while preserving existing fields
|
|
457
|
+
const updatedServiceJson = {
|
|
458
|
+
...existingServiceJson,
|
|
459
|
+
appName: resourceName,
|
|
460
|
+
appType: resourceType === "sdk" ? "sdk" : existingServiceJson.appType || resourceType,
|
|
461
|
+
stack: stackName,
|
|
462
|
+
...(assignedPort > 0 && { port: assignedPort }),
|
|
463
|
+
};
|
|
464
|
+
// Write updated service.json
|
|
465
|
+
const { writeFileSync } = await import("node:fs");
|
|
466
|
+
writeFileSync(existingServiceJsonPath, JSON.stringify(updatedServiceJson, null, 2));
|
|
467
|
+
console.log(chalk.green("\n✅ Existing resource registered successfully!"));
|
|
468
|
+
console.log(chalk.gray(`\nLocation: ${fullPath}`));
|
|
469
|
+
console.log(chalk.gray(`\nNext steps:`));
|
|
470
|
+
console.log(chalk.gray(` tdk up ${stackName}`));
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
// Create directory structure for new resources
|
|
474
|
+
console.log(chalk.blue("\n📁 Creating directory structure..."));
|
|
475
|
+
mkdirSync(fullPath, { recursive: true });
|
|
476
|
+
mkdirSync(resolve(fullPath, "src"), { recursive: true });
|
|
477
|
+
mkdirSync(resolve(fullPath, "tests"), { recursive: true });
|
|
478
|
+
// Prepare file generation tasks
|
|
479
|
+
const serviceJson = createServiceJson(resourceName, resourceType, stackName, assignedPort);
|
|
480
|
+
const packageJson = createPackageJson(resourceName, resourceType);
|
|
481
|
+
const tasks = [
|
|
482
|
+
{
|
|
483
|
+
type: "json",
|
|
484
|
+
filename: "service.json",
|
|
485
|
+
content: serviceJson,
|
|
486
|
+
description: "Generating service.json",
|
|
487
|
+
emoji: "📝",
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
type: "json",
|
|
491
|
+
filename: "package.json",
|
|
492
|
+
content: packageJson,
|
|
493
|
+
description: "Generating package.json",
|
|
494
|
+
emoji: "📦",
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
type: "json",
|
|
498
|
+
filename: "tsconfig.json",
|
|
499
|
+
content: TSCONFIG_TEMPLATE,
|
|
500
|
+
description: "Generating tsconfig.json",
|
|
501
|
+
emoji: "⚙️",
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
type: "text",
|
|
505
|
+
filename: "Dockerfile",
|
|
506
|
+
content: DOCKERFILE_TEMPLATE,
|
|
507
|
+
description: "Generating Dockerfile",
|
|
508
|
+
emoji: "🐳",
|
|
509
|
+
},
|
|
510
|
+
];
|
|
511
|
+
// Add source files based on resource type
|
|
512
|
+
if (resourceType === "backend") {
|
|
513
|
+
tasks.push({
|
|
514
|
+
type: "text",
|
|
515
|
+
filename: "src/index.ts",
|
|
516
|
+
content: getBackendIndexTemplate(resourceName),
|
|
517
|
+
description: "Generating backend source",
|
|
518
|
+
emoji: "💻",
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
else if (resourceType === "frontend") {
|
|
522
|
+
tasks.push({
|
|
523
|
+
type: "text",
|
|
524
|
+
filename: "index.html",
|
|
525
|
+
content: getFrontendIndexTemplate(resourceName),
|
|
526
|
+
description: "Generating HTML template",
|
|
527
|
+
emoji: "💻",
|
|
528
|
+
});
|
|
529
|
+
tasks.push({
|
|
530
|
+
type: "text",
|
|
531
|
+
filename: "src/main.tsx",
|
|
532
|
+
content: FRONTEND_MAIN_TEMPLATE,
|
|
533
|
+
description: "Generating React entry",
|
|
534
|
+
emoji: "💻",
|
|
535
|
+
});
|
|
536
|
+
tasks.push({
|
|
537
|
+
type: "text",
|
|
538
|
+
filename: "src/App.tsx",
|
|
539
|
+
content: getFrontendAppTemplate(resourceName),
|
|
540
|
+
description: "Generating React app",
|
|
541
|
+
emoji: "💻",
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
else if (resourceType === "worker") {
|
|
545
|
+
tasks.push({
|
|
546
|
+
type: "text",
|
|
547
|
+
filename: "src/index.ts",
|
|
548
|
+
content: getWorkerIndexTemplate(resourceName),
|
|
549
|
+
description: "Generating worker source",
|
|
550
|
+
emoji: "💻",
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
// Add test file
|
|
554
|
+
tasks.push({
|
|
555
|
+
type: "text",
|
|
556
|
+
filename: `tests/${resourceName}.test.ts`,
|
|
557
|
+
content: getTestTemplate(resourceName),
|
|
558
|
+
description: "Generating test file",
|
|
559
|
+
emoji: "🧪",
|
|
560
|
+
});
|
|
561
|
+
// Execute all file writes with progress
|
|
562
|
+
console.log(chalk.blue("💻 Generating source files..."));
|
|
563
|
+
writeFilesWithProgress(fullPath, tasks);
|
|
564
|
+
console.log(chalk.green("\n✅ Resource created successfully!"));
|
|
565
|
+
console.log(chalk.gray(`\nLocation: ${fullPath}`));
|
|
566
|
+
console.log(chalk.gray(`\nNext steps:`));
|
|
567
|
+
console.log(chalk.gray(` cd ${finalResourcePath}`));
|
|
568
|
+
console.log(chalk.gray(` bun install`));
|
|
569
|
+
console.log(chalk.gray(` tdk up ${stackName}`));
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
//# sourceMappingURL=resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../src/commands/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,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|
+
import chalk from "chalk";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { createDiscoveryContext } from "../utils/discovery-context.js";
|
|
4
|
+
import { requireProjectRoot, runCommand } from "../utils/errors.js";
|
|
5
|
+
import { formatCount, showAllSatisfyCondition, showDetail, showEmptyState, showStep, } from "../utils/formatting.js";
|
|
6
|
+
export const resourcesCommand = new Command("resources")
|
|
7
|
+
.description("List all resources (services) in the project")
|
|
8
|
+
.option("-v, --verbose", "Show detailed information about each resource", false)
|
|
9
|
+
.option("-s, --stack <stack>", "Filter resources by stack name")
|
|
10
|
+
.option("--no-stack", "Show only resources without a stack")
|
|
11
|
+
.option("--ports", "Show port assignments", false)
|
|
12
|
+
.action(async (options) => {
|
|
13
|
+
await runCommand(async () => {
|
|
14
|
+
requireProjectRoot();
|
|
15
|
+
const discovery = createDiscoveryContext();
|
|
16
|
+
if (discovery.resources.length === 0) {
|
|
17
|
+
showEmptyState("resources");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let resources = discovery.resources;
|
|
21
|
+
if (options.stack) {
|
|
22
|
+
resources = discovery.resourcesByStack.get(options.stack) || [];
|
|
23
|
+
if (resources.length === 0) {
|
|
24
|
+
showEmptyState("stack-services", ` in stack "${options.stack}"`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (options.noStack) {
|
|
29
|
+
resources = discovery.unassignedResources;
|
|
30
|
+
if (resources.length === 0) {
|
|
31
|
+
showAllSatisfyCondition("resources", "assigned to a stack");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
showStep(`Found ${formatCount(resources.length, "resource")}:\n`);
|
|
36
|
+
if (options.verbose || options.ports) {
|
|
37
|
+
for (const resource of resources) {
|
|
38
|
+
console.log(chalk.bold(`${resource.name}`));
|
|
39
|
+
if (resource.stack) {
|
|
40
|
+
console.log(chalk.gray(` Stack: ${resource.stack}`));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
console.log(chalk.yellow(` Stack: (not assigned)`));
|
|
44
|
+
}
|
|
45
|
+
if (options.ports && resource.port) {
|
|
46
|
+
console.log(chalk.gray(` Port: ${resource.port}`));
|
|
47
|
+
}
|
|
48
|
+
if (options.verbose) {
|
|
49
|
+
console.log(chalk.gray(` Type: ${resource.type || "unknown"}`));
|
|
50
|
+
console.log(chalk.gray(` Path: ${resource.configPath}`));
|
|
51
|
+
}
|
|
52
|
+
console.log();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
for (const resource of resources) {
|
|
57
|
+
const stackInfo = resource.stack
|
|
58
|
+
? chalk.gray(` [${resource.stack}]`)
|
|
59
|
+
: chalk.yellow(" [no stack]");
|
|
60
|
+
console.log(` ${resource.name}${stackInfo}`);
|
|
61
|
+
}
|
|
62
|
+
showDetail("\nRun with --verbose for more details or --ports to see port assignments.", 0);
|
|
63
|
+
}
|
|
64
|
+
const withoutStackCount = options.stack
|
|
65
|
+
? resources.filter((r) => !r.stack).length
|
|
66
|
+
: discovery.unassignedResources.length;
|
|
67
|
+
if (withoutStackCount > 0 && !options.noStack && !options.stack) {
|
|
68
|
+
console.log(chalk.yellow(`\n${formatCount(withoutStackCount, "resource")} not assigned to any stack.`));
|
|
69
|
+
showDetail('Run "tdk resources --no-stack" to see them, or "tdk stack" to assign them.');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=resources.js.map
|