add initialiseClientDB

This commit is contained in:
Martin McKeaveney 2020-05-11 10:28:06 +01:00
parent b9aa1dc100
commit 9ff76c799c
17 changed files with 70 additions and 52 deletions

View File

@ -108,7 +108,6 @@ const setPackage = (store, initial) => async pkg => {
initial.appId = pkg.application._id initial.appId = pkg.application._id
store.set(initial) store.set(initial)
console.log(initial)
return initial return initial
} }
@ -359,7 +358,7 @@ const addChildComponent = store => (componentToAdd, presetName) => {
const newComponent = createProps(component, { const newComponent = createProps(component, {
...presetProps, ...presetProps,
instanceId _instanceId: instanceId
}, state) }, state)
state.currentComponentInfo._children = state.currentComponentInfo._children.concat( state.currentComponentInfo._children = state.currentComponentInfo._children.concat(

View File

@ -205,6 +205,14 @@ export default {
commonProps: {}, commonProps: {},
children: [], children: [],
}, },
{
name: "Map",
_component: "@budibase/standard-components/datamap",
description: "Shiny map",
icon: "ri-map-pin-line",
commonProps: {},
children: [],
},
], ],
}, },
], ],

View File

@ -3,10 +3,10 @@ const { exists, readFile, writeFile, ensureDir } = require("fs-extra")
const chalk = require("chalk") const chalk = require("chalk")
const { serverFileName, xPlatHomeDir } = require("../../common") const { serverFileName, xPlatHomeDir } = require("../../common")
const { join } = require("path") const { join } = require("path")
const initialiseClientDb = require("@budibase/server/db/initialiseClientDb") const initialiseClientDb = require("@budibase/server/src/db/initialiseClientDb")
const Sqrl = require("squirrelly") const Sqrl = require("squirrelly")
const uuid = require("uuid") const uuid = require("uuid")
const CouchDB = require("@budibase/server/db/client") const CouchDB = require("@budibase/server/src/db/client")
module.exports = opts => { module.exports = opts => {
run(opts) run(opts)

View File

@ -1,8 +1,8 @@
const { xPlatHomeDir } = require("../../common") const { xPlatHomeDir } = require("../../common")
const dotenv = require("dotenv") const dotenv = require("dotenv")
const createInstance = require("@budibase/server/api/controllers/instance") const createInstance = require("@budibase/server/src/api/controllers/instance")
.create .create
const createApplication = require("@budibase/server/api/controllers/application") const createApplication = require("@budibase/server/src/api/controllers/application")
.create .create
const { copy, readJSON, writeJSON, remove, exists } = require("fs-extra") const { copy, readJSON, writeJSON, remove, exists } = require("fs-extra")
const { resolve, join } = require("path") const { resolve, join } = require("path")

View File

@ -1,9 +1,8 @@
const app = require("@budibase/server/app")
const { xPlatHomeDir } = require("../../common") const { xPlatHomeDir } = require("../../common")
module.exports = ({ dir }) => { module.exports = ({ dir }) => {
dir = xPlatHomeDir(dir) dir = xPlatHomeDir(dir)
process.chdir(dir) process.chdir(dir)
app() app = require("@budibase/server/src/app")
console.log(`Budibase Builder running on port ${process.env.PORT}..`) console.log(`Budibase Builder running on port ${process.env.PORT}..`)
} }

View File

@ -5,7 +5,7 @@
"main": "src/index.js", "main": "src/index.js",
"scripts": { "scripts": {
"test": "jest", "test": "jest",
"test:integration": "jest neo --runInBand", "test:integration": "jest routes --runInBand",
"test:watch": "jest -w", "test:watch": "jest -w",
"initialise": "node ../cli/bin/budi init ./myapps -b local -q", "initialise": "node ../cli/bin/budi init ./myapps -b local -q",
"budi": "node ../cli/bin/budi", "budi": "node ../cli/bin/budi",

View File

@ -1,5 +1,5 @@
const supertest = require("supertest"); const supertest = require("supertest");
const app = require("../../../../app"); const app = require("../../../app");
const { createClientDatabase, destroyDatabase } = require("./couchTestUtils"); const { createClientDatabase, destroyDatabase } = require("./couchTestUtils");
@ -10,11 +10,7 @@ describe("/applications", () => {
let server; let server;
beforeAll(async () => { beforeAll(async () => {
server = await app({ server = app;
config: {
port: 3000
}
});
request = supertest(server); request = supertest(server);
await createClientDatabase(); await createClientDatabase();
}); });

View File

@ -1,5 +1,5 @@
const supertest = require("supertest"); const supertest = require("supertest");
const app = require("../../../../app"); const app = require("../../../app");
const { createClientDatabase, destroyClientDatabase } = require("./couchTestUtils") const { createClientDatabase, destroyClientDatabase } = require("./couchTestUtils")
@ -11,11 +11,7 @@ describe("/clients", () => {
let db; let db;
beforeAll(async () => { beforeAll(async () => {
server = await app({ server = app
config: {
port: 3000
}
});
request = supertest(server); request = supertest(server);
}); });

View File

@ -1,5 +1,5 @@
const supertest = require("supertest"); const supertest = require("supertest");
const app = require("../../../../app"); const app = require("../../../app");
const { const {
createInstanceDatabase, createInstanceDatabase,
createClientDatabase, createClientDatabase,
@ -15,11 +15,7 @@ describe("/instances", () => {
let server; let server;
beforeAll(async () => { beforeAll(async () => {
server = await app({ server = app
config: {
port: 3000
}
});
request = supertest(server); request = supertest(server);
}); });

View File

@ -10,11 +10,7 @@ describe("/models", () => {
let server; let server;
beforeAll(async () => { beforeAll(async () => {
server = await app({ server = app;
config: {
port: 3000
}
});
request = supertest(server); request = supertest(server);
}); });

View File

@ -1,5 +1,5 @@
const supertest = require("supertest"); const supertest = require("supertest");
const app = require("../../../../app"); const app = require("../../../app");
const { createInstanceDatabase, createModel } = require("./couchTestUtils"); const { createInstanceDatabase, createModel } = require("./couchTestUtils");
const TEST_INSTANCE_ID = "testing-123"; const TEST_INSTANCE_ID = "testing-123";
@ -20,11 +20,7 @@ describe("/records", () => {
let db; let db;
beforeAll(async () => { beforeAll(async () => {
server = await app({ server = app;
config: {
port: 3000
}
});
request = supertest(server); request = supertest(server);
}); });

View File

@ -1,5 +1,5 @@
const supertest = require("supertest"); const supertest = require("supertest");
const app = require("../../../../app"); const app = require("../../../app");
const { const {
createInstanceDatabase createInstanceDatabase
} = require("./couchTestUtils"); } = require("./couchTestUtils");
@ -15,11 +15,7 @@ describe("/users", () => {
let server; let server;
beforeAll(async () => { beforeAll(async () => {
server = await app({ server = app
config: {
port: 3000
}
});
request = supertest(server); request = supertest(server);
}); });
@ -45,8 +41,8 @@ describe("/users", () => {
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
.expect(200) .expect(200)
.end(async (err, res) => { .end(async (err, res) => {
const createdUser = res.body[0]; const user = res.body[0];
expect(createdUser.name).toEqual(TEST_USER.name); expect(user.name).toEqual(TEST_USER.name);
done(); done();
}); });
}) })

View File

@ -11,11 +11,7 @@ describe("/views", () => {
let db; let db;
beforeAll(async () => { beforeAll(async () => {
server = await app({ server = app;
config: {
port: 3000
}
});
request = supertest(server); request = supertest(server);
}); });
@ -29,7 +25,7 @@ describe("/views", () => {
}); });
afterEach(async () => { afterEach(async () => {
await db.destroy(); db && await db.destroy();
}); });
it("returns a success message when the view is successfully created", done => { it("returns a success message when the view is successfully created", done => {

View File

@ -291,6 +291,13 @@
} }
} }
}, },
"datamap": {
"description": "shiny chart",
"data": true,
"props": {
"model": "models"
}
},
"datachart": { "datachart": {
"description": "shiny chart", "description": "shiny chart",
"data": true, "data": true,

View File

@ -37,6 +37,7 @@
"license": "MIT", "license": "MIT",
"gitHead": "b1f4f90927d9e494e513220ef060af28d2d42455", "gitHead": "b1f4f90927d9e494e513220ef060af28d2d42455",
"dependencies": { "dependencies": {
"@beyonk/svelte-googlemaps": "^2.2.0",
"fusioncharts": "^3.15.1-sr.1", "fusioncharts": "^3.15.1-sr.1",
"svelte-fusioncharts": "^1.0.0" "svelte-fusioncharts": "^1.0.0"
} }

View File

@ -0,0 +1,31 @@
<script>
import { GoogleMap } from '@beyonk/svelte-googlemaps'
// export let _bb
// export let onLoad
// export let _instanceId
// export let model
// let mapComponent
// let headers = []
// let store = _bb.store
// $: data = $store[model._id] || []
// async function fetchData() {
// const FETCH_RECORDS_URL = `/api/${_instanceId}/all_${model._id}/records`
// const response = await _bb.api.get(FETCH_RECORDS_URL)
// if (response.status === 200) {
// const json = await response.json()
// store.update(state => {
// state[model._id] = json
// return state
// });
// } else {
// throw new Error("Failed to fetch records.", response)
// }
// }
</script>
<GoogleMap apiKey={"AIzaSyCPJ_eiSIbhRMmKBiVYXgh4HFHmbC4ZL5U"} />

View File

@ -19,3 +19,4 @@ export { default as dataform } from "./DataForm.svelte"
export { default as datachart } from "./DataChart.svelte" export { default as datachart } from "./DataChart.svelte"
export { default as datalist } from "./DataList.svelte" export { default as datalist } from "./DataList.svelte"
export { default as datasearch } from "./DataSearch.svelte" export { default as datasearch } from "./DataSearch.svelte"
export { default as datamap } from "./DataMap.svelte"