mirror of https://github.com/Budibase/budibase.git
12 changed files with 120 additions and 3334 deletions
@ -1,9 +1,35 @@ |
|||
const handler = require("./initHandler"); |
|||
|
|||
module.exports = { |
|||
command: "init", |
|||
command: "init [dir] [config] [username] [password]", |
|||
desc: "Initialise Budibase. Run this first to setup your local Budibase", |
|||
builder: yargs => {}, |
|||
builder: yargs => { |
|||
yargs.positional("dir", { |
|||
type: "string", |
|||
describe: "your apps directory - directory will be created if it does not exist", |
|||
default: ".", |
|||
alias: "d" |
|||
}); |
|||
yargs.positional("config", { |
|||
type: "string", |
|||
describe: "config template file to use - optional, defaults to config.js", |
|||
alias: "c", |
|||
default: "config.dev.js", |
|||
choices: ["dev", "contributors"] |
|||
}); |
|||
yargs.positional("username", { |
|||
type: "string", |
|||
describe: "username for admin interface", |
|||
alias: "u", |
|||
default: "" |
|||
}) |
|||
yargs.positional("password", { |
|||
type: "string", |
|||
describe: "passord for admin interface", |
|||
alias: "p", |
|||
default: "" |
|||
}) |
|||
}, |
|||
handler |
|||
} |
|||
|
|||
|
|||
File diff suppressed because it is too large
@ -0,0 +1,2 @@ |
|||
myapps/ |
|||
config.js |
|||
@ -1,76 +1 @@ |
|||
const create = require("./createMasterDb"); |
|||
const argv = require("yargs").argv |
|||
const readline = require('readline'); |
|||
const { promisify } = require('util'); |
|||
const { mkdir, remove } = require("fs-extra"); |
|||
const budibaseConfig = require("../config"); |
|||
const buildAppContext = require("../initialise/buildAppContext"); |
|||
|
|||
|
|||
readline.Interface.prototype.question[promisify.custom] = function(prompt) { |
|||
return new Promise(resolve => |
|||
readline.Interface.prototype.question.call(this, prompt, resolve), |
|||
); |
|||
}; |
|||
readline.Interface.prototype.questionAsync = promisify( |
|||
readline.Interface.prototype.question, |
|||
); |
|||
|
|||
|
|||
const question = async (q) => { |
|||
const rl = readline.createInterface({ |
|||
input: process.stdin, |
|||
output: process.stdout, |
|||
}); |
|||
var answer = await rl.questionAsync(q); |
|||
rl.close(); |
|||
return answer; |
|||
} |
|||
|
|||
(async () => { |
|||
const datastore = argv.datastore |
|||
? argv.datastore |
|||
: await question("Datastore: "); |
|||
|
|||
|
|||
if(!datastore) throw new Error("Datastore not supplied!"); |
|||
|
|||
|
|||
|
|||
const username = argv.username |
|||
? argv.username |
|||
: await question("Owner Username: "); |
|||
|
|||
const password = argv.password |
|||
? argv.password |
|||
: await question("Owner Password: "); |
|||
|
|||
if(!username) throw new Error("Username not supplied!"); |
|||
if(!password) throw new Error("Password not supplied!"); |
|||
|
|||
var datastoreModule = require("../../datastores/datastores/" + datastore); |
|||
|
|||
const rootconfig = {}; |
|||
for(let parameter in datastoreModule.configParameters) { |
|||
rootconfig[parameter] = argv[parameter] |
|||
? argv[parameter] |
|||
: await question(`${datastoreModule.configParameters[parameter]}: `); |
|||
} |
|||
|
|||
const cleanDev = argv.cleanDev ? true : false; |
|||
|
|||
if(cleanDev) { |
|||
try { |
|||
await remove(rootconfig.rootPath); |
|||
} |
|||
catch(_){} |
|||
await mkdir(rootconfig.rootPath); |
|||
} |
|||
|
|||
const appContext = await buildAppContext(budibaseConfig(), false); |
|||
await create( |
|||
appContext, |
|||
datastoreModule, |
|||
username, |
|||
password); |
|||
})() |
|||
require("../../cli/src/cli")(); |
|||
Loading…
Reference in new issue