temba-cli 0.42.8
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/README.md +7 -0
- package/cli.js +25 -0
- package/create/create.js +29 -0
- package/create/starter-template/package.json +10 -0
- package/create/starter-template/src/server.js +7 -0
- package/package.json +16 -0
package/README.md
ADDED
package/cli.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { create } from './create/create.js'
|
|
3
|
+
|
|
4
|
+
const [, , command, ...args] = process.argv
|
|
5
|
+
|
|
6
|
+
const ensure = (condition = false, message) => {
|
|
7
|
+
if (!condition) {
|
|
8
|
+
console.error(message)
|
|
9
|
+
process.exit(1)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
console.log('\n🚀 Temba CLI')
|
|
14
|
+
|
|
15
|
+
ensure(command, 'Please provide a command')
|
|
16
|
+
|
|
17
|
+
if (command === 'create') {
|
|
18
|
+
const projectName = args[0]
|
|
19
|
+
ensure(projectName?.length, 'Please provide a project name')
|
|
20
|
+
create(...args)
|
|
21
|
+
} else {
|
|
22
|
+
ensure(false, `Unknown command: '${command}'`)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
console.log('')
|
package/create/create.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { fileURLToPath } from 'url'
|
|
3
|
+
import fs from 'fs-extra'
|
|
4
|
+
import { execSync } from 'child_process'
|
|
5
|
+
|
|
6
|
+
export function create(projectName) {
|
|
7
|
+
const templateFolder = path.resolve(
|
|
8
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
9
|
+
'starter-template',
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
const targetFolder = path.resolve(process.cwd(), projectName)
|
|
13
|
+
|
|
14
|
+
console.log(` ...Creating project in: ${targetFolder}`)
|
|
15
|
+
|
|
16
|
+
fs.copySync(templateFolder, targetFolder, {
|
|
17
|
+
overwrite: true,
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
execSync('npm install', {
|
|
21
|
+
cwd: targetFolder,
|
|
22
|
+
stdio: 'inherit',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
execSync('npm start', {
|
|
26
|
+
cwd: targetFolder,
|
|
27
|
+
stdio: 'inherit',
|
|
28
|
+
})
|
|
29
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "temba-cli",
|
|
3
|
+
"version": "0.42.8",
|
|
4
|
+
"description": "CLI for scaffolding and managing Temba APIs",
|
|
5
|
+
"bin": {
|
|
6
|
+
"temba": "./cli.js"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": [
|
|
10
|
+
"cli.js",
|
|
11
|
+
"create/"
|
|
12
|
+
],
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"fs-extra": "^11.3.0"
|
|
15
|
+
}
|
|
16
|
+
}
|