@surph_ai/sdk 0.0.1 → 0.0.3
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/auth/index.js +2 -2
- package/index.js +19 -11
- package/package.json +2 -2
- package/scaffold/index.js +33 -103
- package/scaffold/tool/README.md +28 -0
- package/scaffold/tool/env.txt +2 -0
- package/scaffold/tool/package-lock.json +2459 -0
- package/scaffold/tool/package.json +21 -0
- package/scaffold/tool/server/app.js +17 -0
- package/scaffold/tool/server/routes/index.js +8 -0
- package/scaffold/tool/server/routes/tool.js +67 -0
- package/scaffold/tool/server/templates/index.html +20 -0
- package/scaffold/tool/tools/index.js +8 -0
- package/scaffold/app/gulpfile.js +0 -12
- package/scaffold/app/package.json +0 -24
- package/scaffold/app/src/index.js +0 -14
package/auth/index.js
CHANGED
|
@@ -38,7 +38,7 @@ module.exports = {
|
|
|
38
38
|
},
|
|
39
39
|
|
|
40
40
|
isLoggedIn: () => {
|
|
41
|
-
const userProfilePath = path.join(os.homedir(), '.
|
|
41
|
+
const userProfilePath = path.join(os.homedir(), '.surph_user')
|
|
42
42
|
if (!fs.existsSync(userProfilePath)) {
|
|
43
43
|
return false
|
|
44
44
|
}
|
|
@@ -78,7 +78,7 @@ module.exports = {
|
|
|
78
78
|
|
|
79
79
|
currentUser: () => {
|
|
80
80
|
return new Promise((resolve, reject) => {
|
|
81
|
-
const userProfilePath = path.join(os.homedir(), '.
|
|
81
|
+
const userProfilePath = path.join(os.homedir(), '.surph_user')
|
|
82
82
|
if (!fs.existsSync(userProfilePath)) {
|
|
83
83
|
// Not logged in
|
|
84
84
|
resolve(false);
|
package/index.js
CHANGED
|
@@ -53,7 +53,7 @@ program.command('version')
|
|
|
53
53
|
.description('show current version')
|
|
54
54
|
.action((cmd, options) => {
|
|
55
55
|
try {
|
|
56
|
-
const text = `${colors.cyan(`\
|
|
56
|
+
const text = `${colors.cyan(`\nSurph Version: `)} ${colors.brightGreen(`${VERSION}`)}\n`
|
|
57
57
|
console.log(text)
|
|
58
58
|
} catch (error) {
|
|
59
59
|
// console.log(colors.red('\nError: '+err.message+'\n'))
|
|
@@ -62,7 +62,7 @@ program.command('version')
|
|
|
62
62
|
})
|
|
63
63
|
|
|
64
64
|
program.command('profile')
|
|
65
|
-
.description('Current
|
|
65
|
+
.description('Current Surph user')
|
|
66
66
|
.action(async (cmd, options) => {
|
|
67
67
|
const user = await auth.currentUser()
|
|
68
68
|
if (user === false) {
|
|
@@ -75,7 +75,7 @@ program.command('profile')
|
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
program.command('login')
|
|
78
|
-
.description('login to
|
|
78
|
+
.description('login to Surph')
|
|
79
79
|
.action(async (cmd, options) => {
|
|
80
80
|
try {
|
|
81
81
|
const credentials = await auth.showPrompt()
|
|
@@ -91,7 +91,7 @@ program.command('login')
|
|
|
91
91
|
const user = { id: data._id, username: data.username }
|
|
92
92
|
|
|
93
93
|
shell.cd('')
|
|
94
|
-
utils.write('.
|
|
94
|
+
utils.write('.Surph_user', JSON.stringify(user, null, 2) + '\n')
|
|
95
95
|
|
|
96
96
|
const successText = `${colors.cyan(`\nSuccess! `)} ${colors.brightGreen(`Currently Logged In As ${user.username}\n`)}`
|
|
97
97
|
console.log(successText)
|
|
@@ -105,9 +105,9 @@ program.command('dev')
|
|
|
105
105
|
.action(async (cmd, options) => {
|
|
106
106
|
try {
|
|
107
107
|
// shell.cp('-R', path.join(__dirname, '../default/lambda/js/index.js'), 'vectors/js/index.js')
|
|
108
|
-
shell.cd(path.join(__dirname, 'base/
|
|
108
|
+
shell.cd(path.join(__dirname, 'base/Surph-base'))
|
|
109
109
|
shell.exec('npm run dev')
|
|
110
|
-
// shell.cd('
|
|
110
|
+
// shell.cd('Surph-base')
|
|
111
111
|
|
|
112
112
|
// shell.exec('gulp build --gulpfile node_modules/@turbo360/turbo-sdk/src/gulpfile.js --silent')
|
|
113
113
|
|
|
@@ -117,11 +117,15 @@ program.command('dev')
|
|
|
117
117
|
})
|
|
118
118
|
|
|
119
119
|
program.command('new <name>')
|
|
120
|
-
.description('create new
|
|
120
|
+
.description('create new Surph app')
|
|
121
121
|
.action(name => scaffold(name, 'project'))
|
|
122
122
|
|
|
123
|
+
program.command('tool <name>')
|
|
124
|
+
.description('create new Surph tool')
|
|
125
|
+
.action(name => scaffold(name, 'tool'))
|
|
126
|
+
|
|
123
127
|
program.command('connect')
|
|
124
|
-
.description('Connect to
|
|
128
|
+
.description('Connect to Surph project')
|
|
125
129
|
.action(async (cmd, options) => {
|
|
126
130
|
try {
|
|
127
131
|
const user = await auth.currentUser() // must be logged in.
|
|
@@ -202,7 +206,7 @@ program.command('connect')
|
|
|
202
206
|
})
|
|
203
207
|
|
|
204
208
|
program.command('build')
|
|
205
|
-
.description('compile
|
|
209
|
+
.description('compile Surph app')
|
|
206
210
|
.action(name => {
|
|
207
211
|
shell.exec('gulp build --gulpfile node_modules/@turbo360/turbo-sdk/src/gulpfile.js --silent')
|
|
208
212
|
|
|
@@ -214,7 +218,7 @@ program.command('build')
|
|
|
214
218
|
|
|
215
219
|
program.command('deploy')
|
|
216
220
|
.option('-t, --type <default_or_static>', 'deployment type | static or default', 'default') // https://www.npmjs.com/package/commander#default-option-value
|
|
217
|
-
.description('Deploy to
|
|
221
|
+
.description('Deploy to Surph')
|
|
218
222
|
.action(async (cmd, options) => {
|
|
219
223
|
try {
|
|
220
224
|
const { type } = cmd
|
|
@@ -236,7 +240,7 @@ program.command('deploy')
|
|
|
236
240
|
} = dotenv.parse(utils.readFile('.env') ?? '')
|
|
237
241
|
|
|
238
242
|
if (TURBO_PROJECT === null || TURBO_PROJECT_SLUG === null) {
|
|
239
|
-
program.error('
|
|
243
|
+
program.error('Surph project not connected. To connect, run:\n\n$ vly connect',
|
|
240
244
|
ERRORS.PROJECT_NOT_CONNECTED)
|
|
241
245
|
}
|
|
242
246
|
|
|
@@ -264,3 +268,7 @@ program.command('deploy')
|
|
|
264
268
|
})
|
|
265
269
|
|
|
266
270
|
program.parse(process.argv)
|
|
271
|
+
|
|
272
|
+
module.exports = {
|
|
273
|
+
|
|
274
|
+
}
|
package/package.json
CHANGED
package/scaffold/index.js
CHANGED
|
@@ -19,47 +19,6 @@ const nextSteps = function(name){
|
|
|
19
19
|
console.log('For full documentation, visit https://docs.turbo360.co\n')
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
/*
|
|
23
|
-
var importVectors = function(shell){
|
|
24
|
-
shell.mkdir('-p', 'vectors')
|
|
25
|
-
shell.mkdir('-p', 'vectors/js')
|
|
26
|
-
shell.mkdir('-p', 'vectors/py')
|
|
27
|
-
shell.cp('-R', path.join(__dirname, '../default/lambda/js/index.js'), 'vectors/js/index.js')
|
|
28
|
-
shell.cp('-R', path.join(__dirname, '../default/lambda/py/requirements.txt'), 'vectors/py/requirements.txt')
|
|
29
|
-
shell.cp('-R', path.join(__dirname, '../default/lambda/py/app.py'), 'vectors/py/app.py')
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
var currentConfig = function(format){
|
|
33
|
-
if (format == null)
|
|
34
|
-
format = 'vertex'
|
|
35
|
-
|
|
36
|
-
var filename = null
|
|
37
|
-
if (format == 'vertex')
|
|
38
|
-
filename = 'vertex-package.json'
|
|
39
|
-
|
|
40
|
-
return new Promise(function(resolve, reject){
|
|
41
|
-
utils.getRequest('https://cdn.turbo360-dev.com/dist/config/'+filename, null)
|
|
42
|
-
.then(function(response){
|
|
43
|
-
// console.log('CONFIG: ' + JSON.stringify(data))
|
|
44
|
-
if (response.confirmation != 'success'){
|
|
45
|
-
throw new Error('')
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
resolve(response.data)
|
|
50
|
-
})
|
|
51
|
-
.catch(function(err){
|
|
52
|
-
// don't reject this promise. if error, return static
|
|
53
|
-
// value from above.
|
|
54
|
-
resolve({
|
|
55
|
-
vertexVersion: VERTEX_NPM_VERSION,
|
|
56
|
-
turboVersion: TURBO_NPM_VERSION
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
22
|
|
|
64
23
|
module.exports = (name, type = 'app') => {
|
|
65
24
|
/*
|
|
@@ -72,17 +31,7 @@ module.exports = (name, type = 'app') => {
|
|
|
72
31
|
|
|
73
32
|
const { platform } = process
|
|
74
33
|
|
|
75
|
-
|
|
76
|
-
shell.mkdir('-p', name)
|
|
77
|
-
shell.cd(name)
|
|
78
|
-
|
|
79
|
-
shell.cp('-R', path.join(__dirname, 'app/package.json'), 'package.json')
|
|
80
|
-
|
|
81
|
-
// www:
|
|
82
|
-
shell.mkdir('-p', 'src')
|
|
83
|
-
shell.cp('-R', path.join(__dirname, `app/src/*`), 'src/')
|
|
84
|
-
}
|
|
85
|
-
|
|
34
|
+
/*
|
|
86
35
|
if (type === 'project') {
|
|
87
36
|
console.log('create project: ' + name)
|
|
88
37
|
shell.mkdir('-p', name)
|
|
@@ -115,57 +64,38 @@ module.exports = (name, type = 'app') => {
|
|
|
115
64
|
const pkgJson = JSON.parse(pkgJsonStr)
|
|
116
65
|
pkgJson.name = name
|
|
117
66
|
utils.write('package.json', JSON.stringify(pkgJson, null, 2) + '\n')
|
|
67
|
+
}
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
if (type === 'tool') {
|
|
71
|
+
console.log('create tool: ' + name)
|
|
72
|
+
shell.mkdir('-p', name)
|
|
73
|
+
shell.cd(name)
|
|
74
|
+
|
|
75
|
+
shell.mkdir('-p', 'server')
|
|
76
|
+
shell.cp('-R', path.join(__dirname, 'tool/server/app.js'), 'server/app.js')
|
|
77
|
+
shell.cp('-R', path.join(__dirname, 'tool/package.json'), 'package.json')
|
|
78
|
+
|
|
79
|
+
// routes:
|
|
80
|
+
shell.mkdir('-p', 'server/routes')
|
|
81
|
+
shell.cp('-R', path.join(__dirname, `tool/server/routes/*`), 'server/routes/')
|
|
82
|
+
|
|
83
|
+
// views:
|
|
84
|
+
shell.mkdir('-p', 'server/templates')
|
|
85
|
+
shell.cp('-R', path.join(__dirname, `tool/server/templates/*`), 'server/templates/')
|
|
86
|
+
// shell.cd('server/templates')
|
|
87
|
+
|
|
88
|
+
const pkgJsonStr = utils.readFile(path.join(__dirname, 'tool/package.json'))
|
|
89
|
+
const pkgJson = JSON.parse(pkgJsonStr)
|
|
90
|
+
pkgJson.name = name
|
|
91
|
+
utils.write('package.json', JSON.stringify(pkgJson, null, 2) + '\n')
|
|
92
|
+
|
|
93
|
+
const envStr = utils.readFile(path.join(__dirname, 'tool/env.txt'))
|
|
94
|
+
utils.write('.env', envStr)
|
|
95
|
+
|
|
96
|
+
shell.mkdir('-p', 'tools')
|
|
97
|
+
shell.cp('-R', path.join(__dirname, `tool/tools/*`), 'tools/')
|
|
118
98
|
|
|
119
|
-
/*
|
|
120
|
-
const scripts = {
|
|
121
|
-
start: 'node ./www/bin',
|
|
122
|
-
test: '',
|
|
123
|
-
build: '',
|
|
124
|
-
postinstall: 'saxa postinstall'
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const devDependencies = {
|
|
128
|
-
nodemon: '^2.0.1',
|
|
129
|
-
rimraf: '^2.6.2'
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const dependencies = {
|
|
133
|
-
'content-type': '^1.0.4',
|
|
134
|
-
'cookie-signature': '1.0.6',
|
|
135
|
-
'escape-html': '^1.0.3',
|
|
136
|
-
'express': '^4.17.1',
|
|
137
|
-
'finalhandler': '1.1.1',
|
|
138
|
-
'fresh': '0.5.2',
|
|
139
|
-
'merge-descriptors': '1.0.1',
|
|
140
|
-
'methods': '^1.1.2',
|
|
141
|
-
'on-finished': '^2.3.0',
|
|
142
|
-
'parseurl': '^1.3.2',
|
|
143
|
-
'path-to-regexp': '0.1.7',
|
|
144
|
-
'proxy-addr': '^2.0.3',
|
|
145
|
-
'qs': '6.11.1',
|
|
146
|
-
'range-parser': '^1.2.0',
|
|
147
|
-
'saxa': '0.0.26',
|
|
148
|
-
'safe-buffer': '5.1.1',
|
|
149
|
-
'send': '0.16.2',
|
|
150
|
-
'serve-static': '1.13.2',
|
|
151
|
-
'setprototypeof': '1.1.0',
|
|
152
|
-
'statuses': '^1.4.0',
|
|
153
|
-
'type-is': '^1.6.16',
|
|
154
|
-
'utils-merge': '1.0.1',
|
|
155
|
-
'vary': '^1.1.2'
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// package.json
|
|
159
|
-
const pkg = {
|
|
160
|
-
name,
|
|
161
|
-
version: '0.0.0',
|
|
162
|
-
private: true,
|
|
163
|
-
scripts,
|
|
164
|
-
dependencies,
|
|
165
|
-
devDependencies,
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
utils.write('package.json', JSON.stringify(pkg, null, 2) + '\n')
|
|
169
|
-
*/
|
|
170
99
|
}
|
|
100
|
+
|
|
171
101
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# demo
|
|
2
|
+
|
|
3
|
+
This project was built with Saxa Labs. To learn more, click here: https://www.saxalabs.com
|
|
4
|
+
|
|
5
|
+
## Instructions
|
|
6
|
+
After cloning into repo, cd to project root directory and install dependencies:
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
$ npm install
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
To run dev server, install Turbo CLI globally:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
$ sudo npm install saxa-cli -g
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then run devserver from project root directory:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
$ turbo devserver
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
To build for production, run build:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
$ npm run build
|
|
28
|
+
```
|