task-o-matic 0.0.13 ā 0.0.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/dist/commands/init.js +41 -8
- package/dist/commands/tasks/document/add.js +3 -3
- package/dist/commands/tasks/list.js +2 -2
- package/dist/commands/tasks/next.js +4 -4
- package/dist/commands/tasks/status.js +2 -2
- package/dist/lib/ai-service/ai-operations.d.ts +1 -1
- package/dist/lib/ai-service/ai-operations.d.ts.map +1 -1
- package/dist/lib/ai-service/base-operations.d.ts +22 -0
- package/dist/lib/ai-service/base-operations.d.ts.map +1 -1
- package/dist/lib/ai-service/base-operations.js +29 -1
- package/dist/lib/ai-service/task-operations.d.ts +1 -1
- package/dist/lib/ai-service/task-operations.d.ts.map +1 -1
- package/dist/lib/better-t-stack-cli.d.ts +36 -21
- package/dist/lib/better-t-stack-cli.d.ts.map +1 -1
- package/dist/lib/better-t-stack-cli.js +212 -33
- package/dist/lib/bootstrap/cli-bootstrap.d.ts +14 -0
- package/dist/lib/bootstrap/cli-bootstrap.d.ts.map +1 -0
- package/dist/lib/bootstrap/cli-bootstrap.js +325 -0
- package/dist/lib/bootstrap/index.d.ts +4 -0
- package/dist/lib/bootstrap/index.d.ts.map +1 -0
- package/dist/lib/bootstrap/index.js +19 -0
- package/dist/lib/bootstrap/medusa-bootstrap.d.ts +14 -0
- package/dist/lib/bootstrap/medusa-bootstrap.d.ts.map +1 -0
- package/dist/lib/bootstrap/medusa-bootstrap.js +218 -0
- package/dist/lib/bootstrap/opentui-bootstrap.d.ts +11 -0
- package/dist/lib/bootstrap/opentui-bootstrap.d.ts.map +1 -0
- package/dist/lib/bootstrap/opentui-bootstrap.js +342 -0
- package/dist/lib/config.d.ts +14 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +18 -0
- package/dist/services/prd.d.ts.map +1 -1
- package/dist/services/prd.js +18 -45
- package/dist/services/tasks.d.ts +2 -2
- package/dist/services/tasks.d.ts.map +1 -1
- package/dist/services/tasks.js +55 -85
- package/dist/types/index.d.ts +36 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/results.d.ts +60 -6
- package/dist/types/results.d.ts.map +1 -1
- package/dist/utils/error-utils.d.ts +70 -0
- package/dist/utils/error-utils.d.ts.map +1 -0
- package/dist/utils/error-utils.js +103 -0
- package/dist/utils/file-utils.d.ts +49 -0
- package/dist/utils/file-utils.d.ts.map +1 -0
- package/dist/utils/file-utils.js +77 -0
- package/dist/utils/id-generator.d.ts +92 -0
- package/dist/utils/id-generator.d.ts.map +1 -0
- package/dist/utils/id-generator.js +140 -0
- package/dist/utils/stack-formatter.d.ts +2 -1
- package/dist/utils/stack-formatter.d.ts.map +1 -1
- package/dist/utils/stack-formatter.js +8 -2
- package/dist/utils/storage-utils.d.ts +49 -0
- package/dist/utils/storage-utils.d.ts.map +1 -0
- package/dist/utils/storage-utils.js +79 -0
- package/dist/utils/streaming-utils.d.ts +38 -0
- package/dist/utils/streaming-utils.d.ts.map +1 -0
- package/dist/utils/streaming-utils.js +56 -0
- package/docs/agents/cli.md +58 -149
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/lib/bootstrap/cli-bootstrap.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAItD,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,kBAAkB,CAAC;IACpC,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;IACvC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA4GhD"}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.bootstrapCliProject = bootstrapCliProject;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const util_1 = require("util");
|
|
12
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
13
|
+
async function bootstrapCliProject(options) {
|
|
14
|
+
try {
|
|
15
|
+
console.log(chalk_1.default.blue(`\nš Bootstrapping CLI project: ${options.projectName}`));
|
|
16
|
+
// Create project directory
|
|
17
|
+
if (!(0, fs_1.existsSync)(options.projectPath)) {
|
|
18
|
+
(0, fs_1.mkdirSync)(options.projectPath, { recursive: true });
|
|
19
|
+
console.log(chalk_1.default.green(` ā Created project directory`));
|
|
20
|
+
}
|
|
21
|
+
// Create directory structure
|
|
22
|
+
const dirs = [
|
|
23
|
+
"src/cli",
|
|
24
|
+
"src/commands",
|
|
25
|
+
"src/types",
|
|
26
|
+
];
|
|
27
|
+
// Add services dir for standard+
|
|
28
|
+
if (options.dependencyLevel !== "minimal") {
|
|
29
|
+
dirs.push("src/services");
|
|
30
|
+
}
|
|
31
|
+
// Add test dir for full+
|
|
32
|
+
if (options.dependencyLevel === "full" || options.dependencyLevel === "task-o-matic") {
|
|
33
|
+
dirs.push("src/test");
|
|
34
|
+
}
|
|
35
|
+
dirs.forEach(dir => {
|
|
36
|
+
const fullPath = (0, path_1.join)(options.projectPath, dir);
|
|
37
|
+
(0, fs_1.mkdirSync)(fullPath, { recursive: true });
|
|
38
|
+
});
|
|
39
|
+
console.log(chalk_1.default.green(` ā Created directory structure`));
|
|
40
|
+
// Generate files
|
|
41
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.projectPath, "package.json"), generatePackageJson(options));
|
|
42
|
+
console.log(chalk_1.default.green(` ā Created package.json`));
|
|
43
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.projectPath, "tsconfig.json"), generateTsConfig(options.dependencyLevel === "full" || options.dependencyLevel === "task-o-matic"));
|
|
44
|
+
console.log(chalk_1.default.green(` ā Created tsconfig.json`));
|
|
45
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.projectPath, "src/cli/bin.ts"), generateBinTemplate(options.projectName));
|
|
46
|
+
console.log(chalk_1.default.green(` ā Created src/cli/bin.ts`));
|
|
47
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.projectPath, "src/index.ts"), generateIndexTemplate(options.projectName));
|
|
48
|
+
console.log(chalk_1.default.green(` ā Created src/index.ts`));
|
|
49
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.projectPath, "src/commands/index.ts"), generateCommandsIndexTemplate());
|
|
50
|
+
console.log(chalk_1.default.green(` ā Created src/commands/index.ts`));
|
|
51
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.projectPath, "src/commands/example.ts"), generateExampleCommandTemplate());
|
|
52
|
+
console.log(chalk_1.default.green(` ā Created src/commands/example.ts`));
|
|
53
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.projectPath, "src/types/index.ts"), generateTypesTemplate());
|
|
54
|
+
console.log(chalk_1.default.green(` ā Created src/types/index.ts`));
|
|
55
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.projectPath, "README.md"), generateReadmeTemplate(options));
|
|
56
|
+
console.log(chalk_1.default.green(` ā Created README.md`));
|
|
57
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.projectPath, ".gitignore"), generateGitignoreTemplate());
|
|
58
|
+
console.log(chalk_1.default.green(` ā Created .gitignore`));
|
|
59
|
+
// Install dependencies
|
|
60
|
+
console.log(chalk_1.default.cyan(`\n š¦ Installing dependencies with ${options.packageManager}...`));
|
|
61
|
+
const installCmd = options.packageManager === "npm" ? "npm install" :
|
|
62
|
+
options.packageManager === "pnpm" ? "pnpm install" :
|
|
63
|
+
"bun install";
|
|
64
|
+
await execAsync(installCmd, { cwd: options.projectPath });
|
|
65
|
+
console.log(chalk_1.default.green(` ā Dependencies installed`));
|
|
66
|
+
return {
|
|
67
|
+
success: true,
|
|
68
|
+
message: `CLI project "${options.projectName}" created successfully!`
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
73
|
+
return {
|
|
74
|
+
success: false,
|
|
75
|
+
message: `Failed to bootstrap CLI project: ${message}`
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function generatePackageJson(options) {
|
|
80
|
+
const deps = getBaseDependencies(options.dependencyLevel);
|
|
81
|
+
const devDeps = getDevDependencies(options);
|
|
82
|
+
const scripts = getScripts(options);
|
|
83
|
+
const pkg = {
|
|
84
|
+
name: options.projectName,
|
|
85
|
+
version: "0.1.0",
|
|
86
|
+
type: "module",
|
|
87
|
+
main: "./dist/lib/index.js",
|
|
88
|
+
types: "./dist/lib/index.d.ts",
|
|
89
|
+
bin: {
|
|
90
|
+
[options.projectName]: "./dist/cli/bin.js"
|
|
91
|
+
},
|
|
92
|
+
scripts,
|
|
93
|
+
dependencies: deps,
|
|
94
|
+
devDependencies: devDeps,
|
|
95
|
+
};
|
|
96
|
+
return JSON.stringify(pkg, null, 2);
|
|
97
|
+
}
|
|
98
|
+
function getBaseDependencies(level) {
|
|
99
|
+
const deps = {
|
|
100
|
+
minimal: {
|
|
101
|
+
commander: "latest",
|
|
102
|
+
chalk: "latest"
|
|
103
|
+
},
|
|
104
|
+
standard: {
|
|
105
|
+
commander: "latest",
|
|
106
|
+
chalk: "latest",
|
|
107
|
+
inquirer: "latest",
|
|
108
|
+
dotenv: "latest"
|
|
109
|
+
},
|
|
110
|
+
full: {
|
|
111
|
+
commander: "latest",
|
|
112
|
+
chalk: "latest",
|
|
113
|
+
inquirer: "latest",
|
|
114
|
+
dotenv: "latest"
|
|
115
|
+
},
|
|
116
|
+
"task-o-matic": {
|
|
117
|
+
commander: "latest",
|
|
118
|
+
chalk: "latest",
|
|
119
|
+
inquirer: "latest",
|
|
120
|
+
dotenv: "latest",
|
|
121
|
+
ai: "latest",
|
|
122
|
+
"@ai-sdk/anthropic": "latest",
|
|
123
|
+
"@ai-sdk/openai": "latest",
|
|
124
|
+
zod: "latest"
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
return deps[level];
|
|
128
|
+
}
|
|
129
|
+
function getDevDependencies(options) {
|
|
130
|
+
const devDeps = {
|
|
131
|
+
typescript: "latest",
|
|
132
|
+
"@types/node": "latest",
|
|
133
|
+
};
|
|
134
|
+
if (options.dependencyLevel === "full" || options.dependencyLevel === "task-o-matic") {
|
|
135
|
+
devDeps.mocha = "latest";
|
|
136
|
+
devDeps.tsx = "latest";
|
|
137
|
+
devDeps["@types/mocha"] = "latest";
|
|
138
|
+
}
|
|
139
|
+
return devDeps;
|
|
140
|
+
}
|
|
141
|
+
function getScripts(options) {
|
|
142
|
+
const scripts = {
|
|
143
|
+
build: "rm -rf dist && tsc",
|
|
144
|
+
"build:watch": "tsc --watch",
|
|
145
|
+
dev: "tsx src/cli/bin.ts",
|
|
146
|
+
start: "node dist/cli/bin.js",
|
|
147
|
+
"check-types": "tsc --noEmit"
|
|
148
|
+
};
|
|
149
|
+
if (options.dependencyLevel === "full" || options.dependencyLevel === "task-o-matic") {
|
|
150
|
+
scripts.test = "mocha -r tsx/cjs src/test/**/*.test.ts";
|
|
151
|
+
}
|
|
152
|
+
return scripts;
|
|
153
|
+
}
|
|
154
|
+
function generateBinTemplate(projectName) {
|
|
155
|
+
return `#!/usr/bin/env node
|
|
156
|
+
import { runCLI } from "../index.js";
|
|
157
|
+
|
|
158
|
+
runCLI().catch((error) => {
|
|
159
|
+
console.error(error);
|
|
160
|
+
process.exit(1);
|
|
161
|
+
});
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
function generateIndexTemplate(projectName) {
|
|
165
|
+
return `import { Command } from "commander";
|
|
166
|
+
import chalk from "chalk";
|
|
167
|
+
import { exampleCommand } from "./commands/example.js";
|
|
168
|
+
|
|
169
|
+
const program = new Command();
|
|
170
|
+
|
|
171
|
+
program
|
|
172
|
+
.name("${projectName}")
|
|
173
|
+
.description("CLI application generated by task-o-matic")
|
|
174
|
+
.version("0.1.0");
|
|
175
|
+
|
|
176
|
+
program.addCommand(exampleCommand);
|
|
177
|
+
|
|
178
|
+
program.action(() => {
|
|
179
|
+
console.log(chalk.blue("Welcome to ${projectName}!"));
|
|
180
|
+
console.log(chalk.gray("Run with --help to see available commands"));
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
export const runCLI = async () => {
|
|
184
|
+
await program.parseAsync(process.argv);
|
|
185
|
+
};
|
|
186
|
+
`;
|
|
187
|
+
}
|
|
188
|
+
function generateCommandsIndexTemplate() {
|
|
189
|
+
return `export * from "./example.js";
|
|
190
|
+
`;
|
|
191
|
+
}
|
|
192
|
+
function generateExampleCommandTemplate() {
|
|
193
|
+
return `import { Command } from "commander";
|
|
194
|
+
import chalk from "chalk";
|
|
195
|
+
|
|
196
|
+
export const exampleCommand = new Command("hello")
|
|
197
|
+
.description("Example command that greets the user")
|
|
198
|
+
.argument("[name]", "Name to greet", "World")
|
|
199
|
+
.action((name: string) => {
|
|
200
|
+
console.log(chalk.green(\`Hello, \${name}!\`));
|
|
201
|
+
});
|
|
202
|
+
`;
|
|
203
|
+
}
|
|
204
|
+
function generateTypesTemplate() {
|
|
205
|
+
return `// Add your custom types here
|
|
206
|
+
|
|
207
|
+
export interface ExampleType {
|
|
208
|
+
name: string;
|
|
209
|
+
value: number;
|
|
210
|
+
}
|
|
211
|
+
`;
|
|
212
|
+
}
|
|
213
|
+
function generateTsConfig(strict) {
|
|
214
|
+
const config = {
|
|
215
|
+
compilerOptions: {
|
|
216
|
+
target: "ES2022",
|
|
217
|
+
module: "ESNext",
|
|
218
|
+
moduleResolution: "bundler",
|
|
219
|
+
strict: strict,
|
|
220
|
+
esModuleInterop: true,
|
|
221
|
+
skipLibCheck: true,
|
|
222
|
+
declaration: true,
|
|
223
|
+
declarationMap: true,
|
|
224
|
+
outDir: "dist",
|
|
225
|
+
rootDir: "src",
|
|
226
|
+
},
|
|
227
|
+
include: ["src/**/*"],
|
|
228
|
+
exclude: ["node_modules", "dist"]
|
|
229
|
+
};
|
|
230
|
+
return JSON.stringify(config, null, 2);
|
|
231
|
+
}
|
|
232
|
+
function generateReadmeTemplate(options) {
|
|
233
|
+
return `# ${options.projectName}
|
|
234
|
+
|
|
235
|
+
CLI application generated by task-o-matic
|
|
236
|
+
|
|
237
|
+
## Installation
|
|
238
|
+
|
|
239
|
+
\`\`\`bash
|
|
240
|
+
${options.packageManager} install
|
|
241
|
+
\`\`\`
|
|
242
|
+
|
|
243
|
+
## Development
|
|
244
|
+
|
|
245
|
+
\`\`\`bash
|
|
246
|
+
# Run in development mode
|
|
247
|
+
${options.packageManager} run dev
|
|
248
|
+
|
|
249
|
+
# Build the project
|
|
250
|
+
${options.packageManager} run build
|
|
251
|
+
|
|
252
|
+
# Run the built CLI
|
|
253
|
+
${options.packageManager} start
|
|
254
|
+
\`\`\`
|
|
255
|
+
|
|
256
|
+
## Usage
|
|
257
|
+
|
|
258
|
+
\`\`\`bash
|
|
259
|
+
${options.projectName} --help
|
|
260
|
+
${options.projectName} hello World
|
|
261
|
+
\`\`\`
|
|
262
|
+
|
|
263
|
+
## Project Structure
|
|
264
|
+
|
|
265
|
+
- \`src/cli/bin.ts\` - CLI entry point
|
|
266
|
+
- \`src/index.ts\` - Main CLI setup with Commander.js
|
|
267
|
+
- \`src/commands/\` - Command implementations
|
|
268
|
+
- \`src/types/\` - TypeScript type definitions
|
|
269
|
+
${options.dependencyLevel !== "minimal" ? "- `src/services/` - Business logic services\n" : ""}${(options.dependencyLevel === "full" || options.dependencyLevel === "task-o-matic") ? "- `src/test/` - Test files\n" : ""}
|
|
270
|
+
## Dependencies
|
|
271
|
+
|
|
272
|
+
This project uses:
|
|
273
|
+
- **Commander.js** - CLI framework
|
|
274
|
+
- **Chalk** - Terminal string styling
|
|
275
|
+
${options.dependencyLevel !== "minimal" ? "- **Inquirer** - Interactive CLI prompts\n- **Dotenv** - Environment variable management\n" : ""}${options.dependencyLevel === "task-o-matic" ? "- **Vercel AI SDK** - AI integration\n- **Zod** - Runtime type validation\n" : ""}
|
|
276
|
+
## Scripts
|
|
277
|
+
|
|
278
|
+
- \`${options.packageManager} run build\` - Build the TypeScript project
|
|
279
|
+
- \`${options.packageManager} run dev\` - Run in development mode with tsx
|
|
280
|
+
- \`${options.packageManager} start\` - Run the built CLI
|
|
281
|
+
- \`${options.packageManager} run check-types\` - Type check without compilation
|
|
282
|
+
${(options.dependencyLevel === "full" || options.dependencyLevel === "task-o-matic") ? `- \`${options.packageManager} test\` - Run tests with Mocha\n` : ""}
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
Generated with [task-o-matic](https://github.com/anthropics/task-o-matic)
|
|
286
|
+
`;
|
|
287
|
+
}
|
|
288
|
+
function generateGitignoreTemplate() {
|
|
289
|
+
return `# Dependencies
|
|
290
|
+
node_modules/
|
|
291
|
+
.pnp
|
|
292
|
+
.pnp.js
|
|
293
|
+
|
|
294
|
+
# Testing
|
|
295
|
+
coverage/
|
|
296
|
+
|
|
297
|
+
# Production
|
|
298
|
+
dist/
|
|
299
|
+
build/
|
|
300
|
+
|
|
301
|
+
# Misc
|
|
302
|
+
.DS_Store
|
|
303
|
+
.env
|
|
304
|
+
.env.local
|
|
305
|
+
.env.development.local
|
|
306
|
+
.env.test.local
|
|
307
|
+
.env.production.local
|
|
308
|
+
|
|
309
|
+
# Logs
|
|
310
|
+
npm-debug.log*
|
|
311
|
+
yarn-debug.log*
|
|
312
|
+
yarn-error.log*
|
|
313
|
+
lerna-debug.log*
|
|
314
|
+
|
|
315
|
+
# IDEs
|
|
316
|
+
.idea/
|
|
317
|
+
.vscode/
|
|
318
|
+
*.swp
|
|
319
|
+
*.swo
|
|
320
|
+
*~
|
|
321
|
+
|
|
322
|
+
# TypeScript
|
|
323
|
+
*.tsbuildinfo
|
|
324
|
+
`;
|
|
325
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/bootstrap/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cli-bootstrap.js"), exports);
|
|
18
|
+
__exportStar(require("./opentui-bootstrap.js"), exports);
|
|
19
|
+
__exportStar(require("./medusa-bootstrap.js"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface MedusaBootstrapOptions {
|
|
2
|
+
projectName: string;
|
|
3
|
+
projectPath: string;
|
|
4
|
+
packageManager: "npm" | "pnpm" | "bun";
|
|
5
|
+
database?: "postgres" | "sqlite";
|
|
6
|
+
skipDb?: boolean;
|
|
7
|
+
skipInstall?: boolean;
|
|
8
|
+
version?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function bootstrapMedusaProject(options: MedusaBootstrapOptions): Promise<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
message: string;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=medusa-bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"medusa-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/lib/bootstrap/medusa-bootstrap.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;IACvC,QAAQ,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA2GhD"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.bootstrapMedusaProject = bootstrapMedusaProject;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const util_1 = require("util");
|
|
12
|
+
const crypto_1 = require("crypto");
|
|
13
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
14
|
+
async function bootstrapMedusaProject(options) {
|
|
15
|
+
try {
|
|
16
|
+
console.log(chalk_1.default.blue(`\nš Bootstrapping MedusaJS project: ${options.projectName}`));
|
|
17
|
+
// Create project directory
|
|
18
|
+
if (!(0, fs_1.existsSync)(options.projectPath)) {
|
|
19
|
+
(0, fs_1.mkdirSync)(options.projectPath, { recursive: true });
|
|
20
|
+
console.log(chalk_1.default.green(` ā Created project directory`));
|
|
21
|
+
}
|
|
22
|
+
// Build create-medusa-app command with correct package runner
|
|
23
|
+
const versionFlag = options.version ? `@${options.version}` : "@latest";
|
|
24
|
+
const dbFlag = options.database === "postgres"
|
|
25
|
+
? "--db-type postgres"
|
|
26
|
+
: "--db-type sqlite";
|
|
27
|
+
const skipInstallFlag = options.skipInstall ? "--skip-install" : "";
|
|
28
|
+
// Respect package manager for the runner
|
|
29
|
+
const packageRunner = options.packageManager === "npm"
|
|
30
|
+
? "npx"
|
|
31
|
+
: options.packageManager === "pnpm"
|
|
32
|
+
? "pnpm dlx"
|
|
33
|
+
: "bunx";
|
|
34
|
+
// Use the project path as the target directory
|
|
35
|
+
const createCmd = `${packageRunner} create-medusa-app${versionFlag} ${options.projectPath} ${dbFlag} ${skipInstallFlag} --skip-db --no-browser`;
|
|
36
|
+
console.log(chalk_1.default.cyan(`\n š¦ Running create-medusa-app with ${options.packageManager}...`));
|
|
37
|
+
await execAsync(createCmd, { cwd: process.cwd() });
|
|
38
|
+
console.log(chalk_1.default.green(` ā MedusaJS project scaffolded`));
|
|
39
|
+
// Generate environment file
|
|
40
|
+
const envContent = generateEnvFile(options);
|
|
41
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.projectPath, ".env"), envContent);
|
|
42
|
+
console.log(chalk_1.default.green(` ā Created .env file`));
|
|
43
|
+
// Generate README
|
|
44
|
+
const readmeContent = generateReadme(options);
|
|
45
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(options.projectPath, "README.md"), readmeContent);
|
|
46
|
+
console.log(chalk_1.default.green(` ā Created README.md`));
|
|
47
|
+
// Install dependencies if not skipped
|
|
48
|
+
if (!options.skipInstall) {
|
|
49
|
+
console.log(chalk_1.default.cyan(`\n š¦ Installing dependencies with ${options.packageManager}...`));
|
|
50
|
+
const installCmd = options.packageManager === "npm"
|
|
51
|
+
? "npm install"
|
|
52
|
+
: options.packageManager === "pnpm"
|
|
53
|
+
? "pnpm install"
|
|
54
|
+
: "bun install";
|
|
55
|
+
await execAsync(installCmd, { cwd: options.projectPath });
|
|
56
|
+
console.log(chalk_1.default.green(` ā Dependencies installed`));
|
|
57
|
+
}
|
|
58
|
+
// Setup database if not skipped
|
|
59
|
+
if (!options.skipDb) {
|
|
60
|
+
console.log(chalk_1.default.cyan(`\n šļø Setting up database...`));
|
|
61
|
+
try {
|
|
62
|
+
const packageRunner = options.packageManager === "npm"
|
|
63
|
+
? "npx"
|
|
64
|
+
: options.packageManager === "pnpm"
|
|
65
|
+
? "pnpm dlx"
|
|
66
|
+
: "bunx";
|
|
67
|
+
await execAsync(`${packageRunner} medusa db:setup`, {
|
|
68
|
+
cwd: options.projectPath,
|
|
69
|
+
});
|
|
70
|
+
console.log(chalk_1.default.green(` ā Database setup complete`));
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
const packageRunner = options.packageManager === "npm"
|
|
74
|
+
? "npx"
|
|
75
|
+
: options.packageManager === "pnpm"
|
|
76
|
+
? "pnpm dlx"
|
|
77
|
+
: "bunx";
|
|
78
|
+
console.log(chalk_1.default.yellow(` ā ļø Database setup skipped (run '${packageRunner} medusa db:setup' manually)`));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
success: true,
|
|
83
|
+
message: `MedusaJS project "${options.projectName}" created successfully!`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
88
|
+
return {
|
|
89
|
+
success: false,
|
|
90
|
+
message: `Failed to bootstrap MedusaJS project: ${message}`,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function generateEnvFile(options) {
|
|
95
|
+
const database = options.database || "sqlite";
|
|
96
|
+
const databaseUrl = database === "postgres"
|
|
97
|
+
? "postgres://postgres:postgres@localhost:5432/medusa-store"
|
|
98
|
+
: "sqlite://./medusa.db";
|
|
99
|
+
// Generate secure random secrets
|
|
100
|
+
const jwtSecret = (0, crypto_1.randomBytes)(32).toString("hex");
|
|
101
|
+
const cookieSecret = (0, crypto_1.randomBytes)(32).toString("hex");
|
|
102
|
+
return `# Database Configuration
|
|
103
|
+
DATABASE_URL=${databaseUrl}
|
|
104
|
+
|
|
105
|
+
# Authentication Secrets (auto-generated)
|
|
106
|
+
JWT_SECRET=${jwtSecret}
|
|
107
|
+
COOKIE_SECRET=${cookieSecret}
|
|
108
|
+
|
|
109
|
+
# CORS Configuration (adjust for your frontend)
|
|
110
|
+
STORE_CORS=http://localhost:8000
|
|
111
|
+
ADMIN_CORS=http://localhost:7001,http://localhost:7000
|
|
112
|
+
|
|
113
|
+
# Server Configuration
|
|
114
|
+
PORT=9000
|
|
115
|
+
|
|
116
|
+
# Redis (optional - uncomment for production)
|
|
117
|
+
# REDIS_URL=redis://localhost:6379
|
|
118
|
+
|
|
119
|
+
# Worker Mode (shared = single process, server = API only, worker = background jobs only)
|
|
120
|
+
WORKER_MODE=shared
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
function generateReadme(options) {
|
|
124
|
+
const database = options.database || "sqlite";
|
|
125
|
+
return `# ${options.projectName}
|
|
126
|
+
|
|
127
|
+
MedusaJS e-commerce backend generated by task-o-matic
|
|
128
|
+
|
|
129
|
+
## Getting Started
|
|
130
|
+
|
|
131
|
+
### Prerequisites
|
|
132
|
+
|
|
133
|
+
${database === "postgres"
|
|
134
|
+
? `- PostgreSQL database running
|
|
135
|
+
- Update \`DATABASE_URL\` in \`.env\` with your database credentials`
|
|
136
|
+
: `- SQLite (no additional setup required)`}
|
|
137
|
+
|
|
138
|
+
### Installation
|
|
139
|
+
|
|
140
|
+
\`\`\`bash
|
|
141
|
+
${options.packageManager} install
|
|
142
|
+
\`\`\`
|
|
143
|
+
|
|
144
|
+
### Database Setup
|
|
145
|
+
|
|
146
|
+
\`\`\`bash
|
|
147
|
+
# Run migrations and seed data
|
|
148
|
+
${options.packageManager === "npm"
|
|
149
|
+
? "npx"
|
|
150
|
+
: options.packageManager === "pnpm"
|
|
151
|
+
? "pnpm dlx"
|
|
152
|
+
: "bunx"} medusa db:setup
|
|
153
|
+
\`\`\`
|
|
154
|
+
|
|
155
|
+
### Development
|
|
156
|
+
|
|
157
|
+
\`\`\`bash
|
|
158
|
+
# Start development server
|
|
159
|
+
${options.packageManager} run dev
|
|
160
|
+
|
|
161
|
+
# The API will be available at http://localhost:9000
|
|
162
|
+
# Admin dashboard at http://localhost:9000/app
|
|
163
|
+
\`\`\`
|
|
164
|
+
|
|
165
|
+
### Build
|
|
166
|
+
|
|
167
|
+
\`\`\`bash
|
|
168
|
+
# Build for production
|
|
169
|
+
${options.packageManager} run build
|
|
170
|
+
|
|
171
|
+
# Start production server
|
|
172
|
+
${options.packageManager} start
|
|
173
|
+
\`\`\`
|
|
174
|
+
|
|
175
|
+
## Project Structure
|
|
176
|
+
|
|
177
|
+
- \`src/\` - Source code
|
|
178
|
+
- \`src/admin/\` - Admin dashboard customizations
|
|
179
|
+
- \`src/api/\` - API routes and middlewares
|
|
180
|
+
- \`src/modules/\` - Custom modules
|
|
181
|
+
- \`src/workflows/\` - Business logic workflows
|
|
182
|
+
- \`src/subscribers/\` - Event subscribers
|
|
183
|
+
- \`medusa-config.ts\` - MedusaJS configuration
|
|
184
|
+
- \`.env\` - Environment variables
|
|
185
|
+
|
|
186
|
+
## Environment Variables
|
|
187
|
+
|
|
188
|
+
Key environment variables (see \`.env\` for full list):
|
|
189
|
+
|
|
190
|
+
- \`DATABASE_URL\` - Database connection string
|
|
191
|
+
- \`JWT_SECRET\` - Secret for JWT tokens
|
|
192
|
+
- \`COOKIE_SECRET\` - Secret for cookies
|
|
193
|
+
- \`STORE_CORS\` - Allowed origins for storefront
|
|
194
|
+
- \`ADMIN_CORS\` - Allowed origins for admin
|
|
195
|
+
|
|
196
|
+
## Documentation
|
|
197
|
+
|
|
198
|
+
- [MedusaJS Documentation](https://docs.medusajs.com)
|
|
199
|
+
- [API Reference](https://docs.medusajs.com/api)
|
|
200
|
+
- [Admin Guide](https://docs.medusajs.com/admin)
|
|
201
|
+
|
|
202
|
+
## Next Steps
|
|
203
|
+
|
|
204
|
+
1. Configure your database connection in \`.env\`
|
|
205
|
+
2. Run \`${options.packageManager === "npm"
|
|
206
|
+
? "npx"
|
|
207
|
+
: options.packageManager === "pnpm"
|
|
208
|
+
? "pnpm dlx"
|
|
209
|
+
: "bunx"} medusa db:setup\` to initialize the database
|
|
210
|
+
3. Start the development server with \`${options.packageManager} run dev\`
|
|
211
|
+
4. Access the admin dashboard at http://localhost:9000/app
|
|
212
|
+
5. Create your first admin user
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
Generated with [task-o-matic](https://github.com/DimitriGilbert/task-o-matic)
|
|
217
|
+
`;
|
|
218
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface OpenTuiBootstrapOptions {
|
|
2
|
+
projectName: string;
|
|
3
|
+
projectPath: string;
|
|
4
|
+
framework: "solid" | "vue" | "react";
|
|
5
|
+
packageManager: "npm" | "pnpm" | "bun";
|
|
6
|
+
}
|
|
7
|
+
export declare function bootstrapOpenTuiProject(options: OpenTuiBootstrapOptions): Promise<{
|
|
8
|
+
success: boolean;
|
|
9
|
+
message: string;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=opentui-bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opentui-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/lib/bootstrap/opentui-bootstrap.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO,CAAC;IACrC,cAAc,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;CACxC;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA4FhD"}
|