Browse Source

Remove electron specific app import

master
Andrew Kingston 6 years ago
parent
commit
78c6f9ca3d
  1. 16
      packages/builder/src/components/start/CreateAppModal.svelte
  2. 5
      packages/builder/src/components/start/Steps/Info.svelte
  3. 15
      packages/server/src/api/controllers/application.js

16
packages/builder/src/components/start/CreateAppModal.svelte

@ -123,13 +123,19 @@
async function createNewApp() { async function createNewApp() {
submitting = true submitting = true
try { try {
// Create form data to create app
let data = new FormData()
data.append("name", $createAppStore.values.applicationName)
data.append("useTemplate", template != null)
if (template) {
data.append("templateName", template.name)
data.append("templateKey", template.key)
data.append("templateFile", template.file)
}
// Create App // Create App
const appResp = await post("/api/applications", { const appResp = await post("/api/applications", data, {})
name: $createAppStore.values.applicationName,
template,
})
const appJson = await appResp.json() const appJson = await appResp.json()
if (!appResp.ok) { if (!appResp.ok) {
throw new Error(appJson.message) throw new Error(appJson.message)
} }

5
packages/builder/src/components/start/Steps/Info.svelte

@ -1,6 +1,5 @@
<script> <script>
import { Label, Heading, Input } from "@budibase/bbui" import { Label, Heading, Input } from "@budibase/bbui"
import Dropzone from "components/common/Dropzone.svelte"
const BYTES_IN_MB = 1000000 const BYTES_IN_MB = 1000000
const FILE_SIZE_LIMIT = BYTES_IN_MB * 5 const FILE_SIZE_LIMIT = BYTES_IN_MB * 5
@ -20,8 +19,8 @@
) )
return return
} }
file = fileArray[0] file = evt.target.files[0]
template.fileImportPath = file.path template.file = file
} }
</script> </script>

15
packages/server/src/api/controllers/application.js

@ -91,7 +91,6 @@ async function getAppUrlIfNotInUse(ctx) {
async function createInstance(template) { async function createInstance(template) {
const appId = generateAppID() const appId = generateAppID()
const db = new CouchDB(appId) const db = new CouchDB(appId)
await db.put({ await db.put({
_id: "_design/database", _id: "_design/database",
@ -106,10 +105,10 @@ async function createInstance(template) {
// replicate the template data to the instance DB // replicate the template data to the instance DB
// this is currently very hard to test, downloading and importing template files // this is currently very hard to test, downloading and importing template files
/* istanbul ignore next */ /* istanbul ignore next */
if (template) { if (template && template.useTemplate === "true") {
let dbDumpReadStream let dbDumpReadStream
if (template.fileImportPath) { if (template.file) {
dbDumpReadStream = fs.createReadStream(template.fileImportPath) dbDumpReadStream = fs.createReadStream(template.file.path)
} else { } else {
const templatePath = await downloadTemplate(...template.key.split("/")) const templatePath = await downloadTemplate(...template.key.split("/"))
dbDumpReadStream = fs.createReadStream( dbDumpReadStream = fs.createReadStream(
@ -162,8 +161,14 @@ exports.fetchAppPackage = async function(ctx) {
} }
exports.create = async function(ctx) { exports.create = async function(ctx) {
const { useTemplate, templateKey } = ctx.request.body
const instance = await createInstance({
useTemplate,
key: templateKey,
file: ctx.request.files.templateFile,
})
const url = await getAppUrlIfNotInUse(ctx) const url = await getAppUrlIfNotInUse(ctx)
const instance = await createInstance(ctx.request.body.template)
const appId = instance._id const appId = instance._id
const version = packageJson.version const version = packageJson.version
const newApplication = { const newApplication = {

Loading…
Cancel
Save