Getting started for contributors fixed - see readme

This commit is contained in:
Michael Shanks 2019-11-23 07:28:24 +00:00
parent 4f29664990
commit 4814371904
12 changed files with 111 additions and 3325 deletions

View File

@ -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
}

View File

@ -4,7 +4,8 @@ const chalk = require("chalk");
const { serverFileName, getAppContext } = require("../../common");
const passwordQuestion = require("@inquirer/password");
const createMasterDb = require("@budibase/server/initialise/createMasterDb");
var localDatastore = require("@budibase/datastores/datastores/local");
const { join, resolve } = require("path");
const localDatastore = require("@budibase/datastores/datastores/local");
module.exports = (opts) => {
run(opts);
@ -12,10 +13,10 @@ module.exports = (opts) => {
const run = async (opts) => {
opts.datapath = "./.data";
await prompts(opts);
await createDataFolder(opts);
await createDevConfig(opts);
await createAppsDir(opts);
await createDataFolder(opts);
await initialiseDatabase(opts);
}
@ -32,39 +33,58 @@ const prompts = async (opts) => {
}
]
const answers = await inquirer.prompt(questions);
const password = await passwordQuestion({
message: "Password for Admin: ", mask: "*"
});
const passwordConfirm = await passwordQuestion({
message: "Confirm Password: ", mask: "*"
});
if(!opts.username) {
const answers = await inquirer.prompt(questions);
opts.username = answers.username;
}
if(password !== passwordConfirm)
throw new Exception("Passwords do not match!");
if(!opts.password) {
const password = await passwordQuestion({
message: "Password for Admin: ", mask: "*"
});
const passwordConfirm = await passwordQuestion({
message: "Confirm Password: ", mask: "*"
});
opts.username = answers.username;
opts.password = password;
if(password !== passwordConfirm)
throw new Exception("Passwords do not match!");
opts.password = password;
}
}
const createAppsDir = async (opts) => {
if(!await exists(opts.configJson.latestPackagesFolder)) {
await mkdir(opts.configJson.latestPackagesFolder);
}
}
const createDataFolder = async (opts) => {
if(await exists(opts.datapath)) {
const dataPath = opts.configJson.datastoreConfig.rootPath;
if(await exists(dataPath)) {
const err = `The path ${opts.datapath} already exists - has budibase already been initialised? Remove the directory to try again.`;
throw new Error(err);
}
await mkdir(opts.datapath);
await mkdir(dataPath);
}
const createDevConfig = async (opts) => {
if(await exists("config.js")) {
const configTemplateFile = `config.${opts.config}.js`;
const destConfigFile = "./config.js";
if(await exists(destConfigFile)) {
console.log(chalk.yellow("Config file already exists (config.js) - keeping your existing config"));
} else {
const srcConfig = serverFileName("config.dev.js");
const destFile = "./config.js";
await copy(srcConfig, destFile);
const srcConfig = serverFileName(configTemplateFile);
await copy(srcConfig, destConfigFile);
}
opts.configJson = require(resolve("./config.js"))();
}
const initialiseDatabase = async (opts) => {

View File

@ -22,7 +22,7 @@ const run = async (opts) => {
await bb.recordApi.save(app);
await createEmtpyAppPackage(opts);
exec(`cd ${opts.name} && npm install`);
exec(`cd ${join(opts.config.latestPackagesFolder, opts.name)} && npm install`);
}
const createEmtpyAppPackage = async (opts) => {

File diff suppressed because it is too large Load Diff

View File

@ -573,23 +573,6 @@
lodash "^4.17.10"
to-fast-properties "^2.0.0"
"@budibase/core@^0.0.12":
version "0.0.12"
resolved "https://registry.yarnpkg.com/@budibase/core/-/core-0.0.12.tgz#7ba0a63844ffd006a7f37781fd6b70158a03b71e"
integrity sha512-oEXTEcOiSHEbgSWuZ+z7+/wPw4cOBNTq12RyMq1KUgwqcldaCZVi2bPNA2sWKo84LbF3wWp7E37qDYsrzk/MOg==
dependencies:
"@nx-js/compiler-util" "^2.0.0"
date-fns "^1.29.0"
lodash "^4.17.13"
lunr "^2.3.5"
safe-buffer "^5.1.2"
shortid "^2.2.8"
"@nx-js/compiler-util@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@nx-js/compiler-util/-/compiler-util-2.0.0.tgz#c74c12165fa2f017a292bb79af007e8fce0af297"
integrity sha512-AxSQbwj9zqt8DYPZ6LwZdytqnwfiOEdcFdq4l8sdjkZmU2clTht7RDLCI8xvkp7KqgcNaOGlTeCM55TULWruyQ==
"@types/body-parser@*":
version "1.17.0"
resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.17.0.tgz#9f5c9d9bd04bb54be32d5eb9fc0d8c974e6cf58c"
@ -911,11 +894,6 @@ core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
date-fns@^1.29.0:
version "1.30.1"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c"
integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==
debug@=3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
@ -1417,11 +1395,6 @@ loose-envify@^1.0.0:
dependencies:
js-tokens "^3.0.0 || ^4.0.0"
lunr@^2.3.5:
version "2.3.8"
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.8.tgz#a8b89c31f30b5a044b97d2d28e2da191b6ba2072"
integrity sha512-oxMeX/Y35PNFuZoHp+jUj5OSEmLCaIH4KTFJh7a93cHBoFmpw2IoPs22VIz7vyO2YUnx2Tn9dzIwO2P/4quIRg==
make-dir@^1.0.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c"
@ -1535,11 +1508,6 @@ nan@^2.9.2:
version "2.11.1"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.1.tgz#90e22bccb8ca57ea4cd37cc83d3819b52eea6766"
nanoid@^2.1.0:
version "2.1.6"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.1.6.tgz#0665418f692e54cf44f34d4010761f3240a03314"
integrity sha512-2NDzpiuEy3+H0AVtdt8LoFi7PnqkOnIzYmJQp7xsEU6VexLluHQwKREuiz57XaQC5006seIadPrIZJhyS2n7aw==
nanomatch@^1.2.9:
version "1.2.13"
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
@ -1925,13 +1893,6 @@ set-value@^2.0.0:
is-plain-object "^2.0.3"
split-string "^3.0.1"
shortid@^2.2.8:
version "2.2.15"
resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.15.tgz#2b902eaa93a69b11120373cd42a1f1fe4437c122"
integrity sha512-5EaCy2mx2Jgc/Fdn9uuDuNIIfWBpzY4XIlhoqtXF6qsf+/+SGZ+FxDdX/ZsMZiWupIWNqAEmiNY4RC+LSmCeOw==
dependencies:
nanoid "^2.1.0"
signal-exit@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"

2
packages/server/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
myapps/
config.js

View File

@ -40,8 +40,8 @@
"type": "node",
"request": "launch",
"name": "Initialise Budibase",
"program": "${workspaceFolder}/initialise/initialiseBudibase.js",
"args": ["--datastore=local", "--username=test", "--password=test", "--rootPath=./.data", "--cleanDev"],
"program": "yarn",
"args": ["run", "initialise"],
"console": "externalTerminal"
}
]

View File

@ -3,11 +3,11 @@
module.exports = () => ({
datastore: "local",
datastoreConfig: {
rootPath: "./.data"
rootPath: "./myapps/.data"
},
keys: ["secret1", "secret2"],
port: 4001,
latestPackagesFolder: "appPackages",
latestPackagesFolder: "./myapps",
extraMasterPlugins: {},
dev:true,
customizeMaster: appDefinition => appDefinition,

View File

@ -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")();

View File

@ -6,7 +6,8 @@
"scripts": {
"test": "jest",
"build": "cd appPackages/_master && yarn && cd ../testApp && yarn && cd ../testApp2 && yarn",
"initialise": "node initialise/initialiseBudibase --datastore local --username admin --password admin --rootPath .data --cleanDev && node ../cli/bin/budi new testApp2",
"initialise": "node ./initialise/initialiseBudibase init -d ./myapps -c contributors -u admin -p admin",
"budi": "node ../cli/bin/budi",
"dev:builder": "node index"
},
"keywords": [

View File

@ -131,29 +131,6 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"
"@budibase/client@^0.0.9":
version "0.0.9"
resolved "https://registry.yarnpkg.com/@budibase/client/-/client-0.0.9.tgz#cebbdcaadbeee756348510b85ee5b0f97d89ba13"
integrity sha512-Q5SOcyki1S807d6s2oYJqU3yywFre7ou1/s7IC32Oj0O3/H5AqrH5uoTZkSM96d456k7G5BTc1mxg3mHhQyLzw==
dependencies:
"@nx-js/compiler-util" "^2.0.0"
lodash "^4.17.15"
lunr "^2.3.5"
shortid "^2.2.8"
svelte "^3.9.2"
"@budibase/core@^0.0.9":
version "0.0.9"
resolved "https://registry.yarnpkg.com/@budibase/core/-/core-0.0.9.tgz#6de9bd65b6c3d3fa64b2d7f76d5057f9b69b82d2"
integrity sha512-ZUZDdQBsJlX2J3k7PTxkOzhZINdCdJUIKGQ+KAZIyH9ZlglTOBpRpwvk+cr0jw2BjQI4Od+gGjoojutoZ70a3A==
dependencies:
"@nx-js/compiler-util" "^2.0.0"
date-fns "^1.29.0"
lodash "^4.17.13"
lunr "^2.3.5"
safe-buffer "^5.1.2"
shortid "^2.2.8"
"@cnakazawa/watch@^1.0.3":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.3.tgz#099139eaec7ebf07a27c1786a3ff64f39464d2ef"
@ -322,11 +299,6 @@
path-to-regexp "^1.1.1"
urijs "^1.19.0"
"@nx-js/compiler-util@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@nx-js/compiler-util/-/compiler-util-2.0.0.tgz#c74c12165fa2f017a292bb79af007e8fce0af297"
integrity sha512-AxSQbwj9zqt8DYPZ6LwZdytqnwfiOEdcFdq4l8sdjkZmU2clTht7RDLCI8xvkp7KqgcNaOGlTeCM55TULWruyQ==
"@phc/format@^0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@phc/format/-/format-0.5.0.tgz#a99d27a83d78b3100a191412adda04315e2e3aba"
@ -981,11 +953,6 @@ data-urls@^1.0.0:
whatwg-mimetype "^2.2.0"
whatwg-url "^7.0.0"
date-fns@^1.29.0:
version "1.30.1"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c"
integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==
debug@^2.2.0, debug@^2.3.3:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@ -2537,7 +2504,7 @@ lodash.sortby@^4.7.0:
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.15:
lodash@^4.17.11, lodash@^4.17.13:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
@ -2549,11 +2516,6 @@ loose-envify@^1.0.0:
dependencies:
js-tokens "^3.0.0 || ^4.0.0"
lunr@^2.3.5:
version "2.3.7"
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.7.tgz#05ccf3af9d0e169b8f432c97e02fc1bdf3f36343"
integrity sha512-HjFSiy0Y0qZoW5OA1I6qBi7OnsDdqQnaUr03jhorh30maQoaP+4lQCKklYE3Nq3WJMSUfuBl6N+bKY5wxCb9hw==
make-dir@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"
@ -2708,11 +2670,6 @@ nan@^2.12.1:
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==
nanoid@^2.1.0:
version "2.1.3"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.1.3.tgz#5130db537fca20d2676515fe7b8ecf8e22192914"
integrity sha512-SbgVmGjEUAR/rYdAM0p0TCdKtJILZeYk3JavV2cmNVmIeR0SaKDudLRk58au6gpJqyFM9qz8ufEsS91D7RZyYA==
nanomatch@^1.2.9:
version "1.2.13"
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
@ -3466,13 +3423,6 @@ shellwords@^0.1.1:
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==
shortid@^2.2.8:
version "2.2.15"
resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.15.tgz#2b902eaa93a69b11120373cd42a1f1fe4437c122"
integrity sha512-5EaCy2mx2Jgc/Fdn9uuDuNIIfWBpzY4XIlhoqtXF6qsf+/+SGZ+FxDdX/ZsMZiWupIWNqAEmiNY4RC+LSmCeOw==
dependencies:
nanoid "^2.1.0"
signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
@ -3750,11 +3700,6 @@ supports-color@^6.1.0:
dependencies:
has-flag "^3.0.0"
svelte@^3.9.2:
version "3.12.1"
resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.12.1.tgz#ddfacd43272ac3255907c682b74ee7d3d8b06b0c"
integrity sha512-t29WJNjHIqfrdMcVXqIyRfgLEaNz7MihKXTpb8qHlbzvf0WyOOIhIlwIGvl6ahJ9+9CLJwz0sjhFNAmPgo8BHg==
symbol-tree@^3.2.2:
version "3.2.4"
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"

View File

@ -76,7 +76,30 @@ then `cd ` into your local copy...
### 4. Running
`lerna run dev:builder` - will run up the builder and server together - i.e. when you want to do some work on the builder
A Budibase apps folder will have been created in `packages/server/myapps`. This is a blank apps folder, so you will need to create yourself an app:
```
cd packages/server
yarn run budi -- new your-app-name
```
then
`yarn run budi` and to run the budibase server
if you then want to run the builder in dev mode (i.e. with hot reloading):
... keep the server running, and..
1. Open a new console
2. `cd packages/builder`
3. `yarn start`
4. Access the builder on http://localhost:3000
Notice that when inside `packages/server`, you can use any Budibase CLI command via yarn:
e.g. `yarn budi -- new mikes_app` == `budi new mikes_app`
This will use the CLI directly from `packages/cli`, rather than your globally installed `budi`
## Documentation