codellms
Version:
Use LLMS to automatically generate a complete application project.
64 lines (63 loc) • 2.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const fs = require("fs");
const TOML = require("@iarna/toml");
class Init extends core_1.Command {
//static flags = {
//config: Flags.string({char: 'c', description: 'toml config file', required: true}),
//}
async run() {
// create default toml file if not exists.
//const {flags} = await this.parse(Init)
const configFile = './codellms.toml';
const defaultConfigJson = {
dependencies: {
express: '4.18.1'
},
basic: {
language: 'javascript',
arch: 'clean architecture',
debug_retry: 3,
type: 'api',
db: 'sqlite'
},
openai: {
api_key: '<your_openai_api_key>',
api_base: 'https://api.openai.com/v1',
temperature: 0.5,
model: 'gpt-3.5-turbo'
},
api: {
style: "RESTful"
},
db: {
need_migration_file: false,
sqlite: {
url: './db.sqlite',
}
}
};
const defaultContent = TOML.stringify(defaultConfigJson);
fs.access(configFile, fs.constants.F_OK, error => {
if (error) {
this.log('init file: codellms.toml');
fs.writeFile(configFile, defaultContent, err => {
if (err)
throw err;
this.log('codellms.toml is created successfully');
});
}
else {
this.error('codellms.toml already exists!');
}
});
if (!fs.existsSync('./features')) {
fs.mkdirSync('./features', { recursive: true });
}
if (!fs.existsSync('./dbschemas')) {
fs.mkdirSync('./dbschemas', { recursive: true });
}
}
}
exports.default = Init;