Merge pull request #312 from mjashanks/master

Auto populated login page
This commit is contained in:
Michael Shanks 2020-06-03 15:54:13 +01:00 committed by GitHub
commit 7b0f2a11c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 28 deletions

View File

@ -5,8 +5,9 @@ const newid = require("../../db/newid")
const env = require("../../environment")
const instanceController = require("./instance")
const { resolve, join } = require("path")
const { copy, readJSON, writeJSON, exists } = require("fs-extra")
const { copy, exists, readFile, writeFile } = require("fs-extra")
const { exec } = require("child_process")
const sqrl = require("squirrelly")
exports.fetch = async function(ctx) {
const db = new CouchDB(ClientDb.name(env.CLIENT_ID))
@ -82,16 +83,27 @@ const createEmptyAppPackage = async (ctx, app) => {
await copy(templateFolder, newAppFolder)
const packageJsonPath = join(appsFolder, app._id, "package.json")
const packageJson = await readJSON(packageJsonPath)
packageJson.name = npmFriendlyAppName(app.name)
await writeJSON(packageJsonPath, packageJson)
await updateJsonFile(join(appsFolder, app._id, "package.json"), {
name: npmFriendlyAppName(app.name),
})
await updateJsonFile(
join(appsFolder, app._id, "pages", "main", "page.json"),
app
)
await updateJsonFile(
join(appsFolder, app._id, "pages", "unauthenticated", "page.json"),
app
)
return newAppFolder
}
const updateJsonFile = async (filePath, app) => {
const json = await readFile(filePath, "utf8")
const newJson = sqrl.Render(json, app)
await writeFile(filePath, newJson, "utf8")
}
const runNpmInstall = async newAppFolder => {
return new Promise((resolve, reject) => {
const cmd = `cd ${newAppFolder} && npm install`

View File

@ -1,5 +1,5 @@
{
"name": "name",
"name": "{{ name }}",
"version": "1.0.0",
"description": "",
"author": "",

View File

@ -1,5 +1,5 @@
{
"title": "Test App",
"title": "{{ name }}",
"favicon": "./_shared/favicon.png",
"stylesheets": [],
"componentLibraries": ["@budibase/standard-components", "@budibase/materialdesign-components"],

View File

@ -1,20 +1,44 @@
{
"title": "Test App",
"componentLibraries": [
"@budibase/standard-components",
"@budibase/materialdesign-components"
],
"title": "{{ name }}",
"favicon": "./_shared/favicon.png",
"stylesheets": [],
"componentLibraries": ["@budibase/standard-components", "@budibase/materialdesign-components"],
"props" : {
"props": {
"_component": "@budibase/standard-components/container",
"_children": [
{
"_id": "686c252d-dbf2-4e28-9078-414ba4719759",
"_component": "@budibase/standard-components/login",
"_styles": {
"normal": {},
"hover": {},
"active": {},
"selected": {}
},
"_code": "",
"loginRedirect": "",
"usernameLabel": "Username",
"passwordLabel": "Password",
"loginButtonLabel": "Login",
"buttonClass": "",
"inputClass": "",
"_children": [],
"name": "{{ name }}",
"logo": ""
}
],
"_id": 1,
"type": "div",
"_styles": {
"active": {},
"hover": {},
"normal": {},
"selected": {}
"layout": {},
"position": {}
},
"_code": ""
"_code": "",
"className": "",
"onLoad": []
},
"_css": "",
"uiFunctions": ""