@wabot-dev/create 0.0.1 → 0.0.2
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/bin/create-wabot.mjs +19 -2
- package/package.json +1 -1
package/bin/create-wabot.mjs
CHANGED
|
@@ -42,7 +42,11 @@ async function createProject(projectName, options) {
|
|
|
42
42
|
// Write the updated package.json
|
|
43
43
|
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2))
|
|
44
44
|
|
|
45
|
+
// Create .env file
|
|
46
|
+
await createEnvFile(targetDir, options.dbUrl, options.llmUrl, options.apiKey)
|
|
47
|
+
|
|
45
48
|
console.log(chalk.green('\nSuccess! 🎉 Created', projectName))
|
|
49
|
+
console.log(chalk.yellow('\n .env file add DATABASE_URL, WABOT_LLM_URL, WABOT_API_KEY'))
|
|
46
50
|
console.log('\nInside that directory, you can run several commands:')
|
|
47
51
|
console.log(chalk.cyan('\n npm install'))
|
|
48
52
|
console.log(' Install the project dependencies')
|
|
@@ -59,12 +63,25 @@ async function createProject(projectName, options) {
|
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
async function createEnvFile(targetDir, dbUrl, llmUrl, apiKey) {
|
|
67
|
+
const envContent = `
|
|
68
|
+
DATABASE_URL=${dbUrl}
|
|
69
|
+
WABOT_LLM_URL=${llmUrl}
|
|
70
|
+
WABOT_API_KEY=${apiKey}
|
|
71
|
+
`
|
|
72
|
+
|
|
73
|
+
await fs.writeFile(path.join(targetDir, '.env'), envContent.trim())
|
|
74
|
+
}
|
|
75
|
+
|
|
62
76
|
// Set up the CLI
|
|
63
77
|
program
|
|
64
78
|
.name('create-wabot')
|
|
65
79
|
.description('Create a new Wabot project')
|
|
66
80
|
.argument('[project-directory]', 'project name')
|
|
67
|
-
.
|
|
81
|
+
.option('--db-url <dbUrl>', 'database url')
|
|
82
|
+
.option('--llm-url <llmUrl>', 'llm url')
|
|
83
|
+
.option('--api-key <key>', 'api key')
|
|
84
|
+
.action(async (projectDirectory, options) => {
|
|
68
85
|
let projectName = projectDirectory
|
|
69
86
|
|
|
70
87
|
if (!projectName) {
|
|
@@ -83,7 +100,7 @@ program
|
|
|
83
100
|
projectName = response.projectName
|
|
84
101
|
}
|
|
85
102
|
|
|
86
|
-
await createProject(projectName)
|
|
103
|
+
await createProject(projectName, options)
|
|
87
104
|
})
|
|
88
105
|
|
|
89
106
|
program.parse()
|