cli init now working...
This commit is contained in:
parent
b2b94c8ccc
commit
2ab564d224
|
@ -9,7 +9,7 @@
|
|||
"request": "launch",
|
||||
"name": "init",
|
||||
"program": "${workspaceFolder}\\bin\\budi",
|
||||
"args": ["init", "-b", "pouch"],
|
||||
"args": ["init", "-b", "remote"],
|
||||
"console": "integratedTerminal",
|
||||
"cwd": "${workspaceFolder}/sandbox"
|
||||
},
|
||||
|
|
|
@ -31,10 +31,11 @@ const ensureAppDir = async opts => {
|
|||
}
|
||||
await ensureDir(opts.dir)
|
||||
|
||||
if (opts.database === "pouch") {
|
||||
if (opts.database === "local") {
|
||||
const dataDir = join(opts.dir, ".data")
|
||||
await ensureDir(dataDir)
|
||||
process.env.COUCH_DB_URL = dataDir
|
||||
process.env.COUCH_DB_URL =
|
||||
dataDir + (dataDir.endsWith("/") || dataDir.endsWith("\\") ? "" : "/")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,12 +52,14 @@ const prompts = async opts => {
|
|||
},
|
||||
]
|
||||
|
||||
if (opts.database === "couch" && !opts.couchDbUrl) {
|
||||
if (opts.database === "remote" && !opts.couchDbUrl) {
|
||||
const answers = await inquirer.prompt(questions)
|
||||
opts.couchDbUrl = answers.couchDbUrl
|
||||
}
|
||||
}
|
||||
|
||||
//https://admin:password@localhost:5984
|
||||
|
||||
const createClientDatabse = async opts => {
|
||||
const couch = CouchDb()
|
||||
if (opts.clientId === "new") {
|
||||
|
@ -72,6 +75,7 @@ const createClientDatabse = async opts => {
|
|||
}
|
||||
|
||||
const db = new couch(`client-${opts.clientId}`)
|
||||
console.log(await db.info())
|
||||
await initialiseClientDb(db)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
const PouchDB = require("pouchdb")
|
||||
require("pouchdb-all-dbs")(PouchDB)
|
||||
const allDbs = require("pouchdb-all-dbs")
|
||||
|
||||
module.exports = () => {
|
||||
const COUCH_DB_URL =
|
||||
process.env.COUCH_DB_URL || "http://admin:password@localhost:5984"
|
||||
const DATABASE_TYPE = process.env.DATABASE_TYPE || "couch"
|
||||
|
||||
PouchDB.defaults({
|
||||
const pouch = PouchDB.defaults({
|
||||
prefix: COUCH_DB_URL,
|
||||
})
|
||||
|
||||
return PouchDB
|
||||
allDbs(pouch)
|
||||
return pouch
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue