@surph_ai/cli 0.0.22 → 0.0.24
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/cli.js +3 -0
- package/package.json +1 -1
- package/scaffold/index.js +24 -5
- package/scaffold/tool/package.json +1 -1
package/cli.js
CHANGED
package/package.json
CHANGED
package/scaffold/index.js
CHANGED
|
@@ -5,6 +5,20 @@ const fs = require('fs')
|
|
|
5
5
|
const dotenv = require('dotenv')
|
|
6
6
|
const utils = require('../utils')
|
|
7
7
|
|
|
8
|
+
// Cross-platform browser opener. Falls back to printing the URL — matters for
|
|
9
|
+
// SSH / headless / broken default handlers, where `open` silently no-ops.
|
|
10
|
+
const openBrowser = (url) => {
|
|
11
|
+
const cmd = process.platform === 'darwin' ? `open "${url}"`
|
|
12
|
+
: process.platform === 'win32' ? `start "" "${url}"`
|
|
13
|
+
: `xdg-open "${url}"`
|
|
14
|
+
exec(cmd, (err) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
console.log(colors.yellow(`\nCouldn't open browser automatically. Open this URL manually:\n`))
|
|
17
|
+
console.log(colors.cyan(url) + '\n')
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
8
22
|
function generateRandomSuffix(length = 6) {
|
|
9
23
|
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
10
24
|
let result = '';
|
|
@@ -145,11 +159,16 @@ module.exports = async (name, type = 'app') => {
|
|
|
145
159
|
const cheatsheetResp = await fetch('https://surph.s3.us-east-1.amazonaws.com/tools/cli/CHEATSHEET.md')
|
|
146
160
|
utils.write('CHEATSHEET.md', await cheatsheetResp.text())
|
|
147
161
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
162
|
+
shell.cd(name)
|
|
163
|
+
shell.exec('npm install')
|
|
164
|
+
shell.exec('npm run dev')
|
|
165
|
+
openBrowser('http://localhost:6767')
|
|
166
|
+
|
|
167
|
+
// console.log('\n- - - - - Next Steps - - - - - ')
|
|
168
|
+
// console.log('1. $ cd ' + name)
|
|
169
|
+
// console.log('2. $ npm install or $ yarn install')
|
|
170
|
+
// console.log('3. $ npm run dev')
|
|
171
|
+
// console.log('4. Open http://localhost:6767 in a browser')
|
|
153
172
|
console.log('\nFor full documentation, visit https://docs.surph.ai\n')
|
|
154
173
|
|
|
155
174
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "npm run build && concurrently \"npm run watch\" \"surph toolserver\" \"surph chatserver\"",
|
|
7
|
+
"dev": "npm run build && concurrently \"npm run watch\" \"surph toolserver\" \"surph chatserver\" \"surph browser 'http://localhost:6767'\"",
|
|
8
8
|
"test": "",
|
|
9
9
|
"build": "rimraf dist && tsc",
|
|
10
10
|
"watch": "tsc -w",
|