Skip to content

Commit f8e9561

Browse files
committed
Added dev:chatbots scripts
1 parent 204d644 commit f8e9561

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
},
3737
"scripts": {
3838
"prepare": "husky",
39+
"dev:chatbots": "node utils/dev/chatbots",
40+
"dev:chatbot": "npm run dev:chatbots",
3941
"lint": "eslint . --cache",
4042
"lint:all": "eslint .",
4143
"lint:fix": "eslint . --fix --cache",
@@ -52,6 +54,7 @@
5254
"@eslint/json": "^1.2.0",
5355
"@eslint/markdown": "^8.0.1",
5456
"@stylistic/eslint-plugin": "^5.10.0",
57+
"cross-spawn": "^7.0.6",
5558
"eslint": "^10.3.0",
5659
"eslint-plugin-import-x": "^4.16.2",
5760
"eslint-plugin-regexp": "^3.1.0",

utils/dev/chatbots.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env node
2+
3+
// Opens KudoAI chatbots in VS Code
4+
5+
(() => {
6+
'use strict'
7+
8+
const chatbots = ['amazongpt', 'bravegpt', 'duckduckgpt', 'googlegpt']
9+
10+
// Import LIBS
11+
const { resolve, dirname } = require('path'),
12+
spawn = require('cross-spawn')
13+
14+
// Init UI COLORS
15+
const br = '\x1b[91m', // bright red
16+
nc = '\x1b[0m' // no color
17+
18+
// Init PATHS
19+
const repoRoot = (dir => {
20+
while (dir != '/' && !require('fs').existsSync(resolve(dir, 'package.json'))) dir = dirname(dir) ; return dir
21+
})(__dirname)
22+
const filePaths = chatbots.map(
23+
chatbot => resolve(repoRoot, `chatgpt/${chatbot}/${chatbot}.user.js`)
24+
).filter(path => require('fs').existsSync(path))
25+
26+
// OPEN files
27+
spawn('code', ['-r', repoRoot, ...filePaths], { stdio: 'inherit' })
28+
.on('error', err => console.error(`${br}Failed to open VS Code: ${err.message}${nc}`))
29+
})()

0 commit comments

Comments
 (0)