autu populated login page
This commit is contained in:
parent
63a87066c7
commit
bae6a37b5d
|
@ -5,8 +5,9 @@ const newid = require("../../db/newid")
|
||||||
const env = require("../../environment")
|
const env = require("../../environment")
|
||||||
const instanceController = require("./instance")
|
const instanceController = require("./instance")
|
||||||
const { resolve, join } = require("path")
|
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 { exec } = require("child_process")
|
||||||
|
const sqrl = require("squirrelly")
|
||||||
|
|
||||||
exports.fetch = async function(ctx) {
|
exports.fetch = async function(ctx) {
|
||||||
const db = new CouchDB(ClientDb.name(env.CLIENT_ID))
|
const db = new CouchDB(ClientDb.name(env.CLIENT_ID))
|
||||||
|
@ -82,16 +83,27 @@ const createEmptyAppPackage = async (ctx, app) => {
|
||||||
|
|
||||||
await copy(templateFolder, newAppFolder)
|
await copy(templateFolder, newAppFolder)
|
||||||
|
|
||||||
const packageJsonPath = join(appsFolder, app._id, "package.json")
|
await updateJsonFile(join(appsFolder, app._id, "package.json"), {
|
||||||
const packageJson = await readJSON(packageJsonPath)
|
name: npmFriendlyAppName(app.name),
|
||||||
|
})
|
||||||
packageJson.name = npmFriendlyAppName(app.name)
|
await updateJsonFile(
|
||||||
|
join(appsFolder, app._id, "pages", "main", "page.json"),
|
||||||
await writeJSON(packageJsonPath, packageJson)
|
app
|
||||||
|
)
|
||||||
|
await updateJsonFile(
|
||||||
|
join(appsFolder, app._id, "pages", "unauthenticated", "page.json"),
|
||||||
|
app
|
||||||
|
)
|
||||||
|
|
||||||
return newAppFolder
|
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 => {
|
const runNpmInstall = async newAppFolder => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const cmd = `cd ${newAppFolder} && npm install`
|
const cmd = `cd ${newAppFolder} && npm install`
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "name",
|
"name": "{{ name }}",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"title": "Test App",
|
"title": "{{ name }}",
|
||||||
"favicon": "./_shared/favicon.png",
|
"favicon": "./_shared/favicon.png",
|
||||||
"stylesheets": [],
|
"stylesheets": [],
|
||||||
"componentLibraries": ["@budibase/standard-components", "@budibase/materialdesign-components"],
|
"componentLibraries": ["@budibase/standard-components", "@budibase/materialdesign-components"],
|
||||||
|
|
|
@ -1,21 +1,45 @@
|
||||||
{
|
{
|
||||||
"title": "Test App",
|
"componentLibraries": [
|
||||||
"favicon": "./_shared/favicon.png",
|
"@budibase/standard-components",
|
||||||
"stylesheets": [],
|
"@budibase/materialdesign-components"
|
||||||
"componentLibraries": ["@budibase/standard-components", "@budibase/materialdesign-components"],
|
],
|
||||||
"props" : {
|
"title": "{{ name }}",
|
||||||
"_component": "@budibase/standard-components/container",
|
"favicon": "./_shared/favicon.png",
|
||||||
"_children": [],
|
"stylesheets": [],
|
||||||
"_id": 1,
|
"props": {
|
||||||
"type": "div",
|
"_component": "@budibase/standard-components/container",
|
||||||
"_styles": {
|
"_children": [
|
||||||
"active": {},
|
{
|
||||||
"hover": {},
|
"_id": "686c252d-dbf2-4e28-9078-414ba4719759",
|
||||||
"normal": {},
|
"_component": "@budibase/standard-components/login",
|
||||||
"selected": {}
|
"_styles": {
|
||||||
},
|
"normal": {},
|
||||||
"_code": ""
|
"hover": {},
|
||||||
},
|
"active": {},
|
||||||
"_css": "",
|
"selected": {}
|
||||||
"uiFunctions": ""
|
},
|
||||||
|
"_code": "",
|
||||||
|
"loginRedirect": "",
|
||||||
|
"usernameLabel": "Username",
|
||||||
|
"passwordLabel": "Password",
|
||||||
|
"loginButtonLabel": "Login",
|
||||||
|
"buttonClass": "",
|
||||||
|
"inputClass": "",
|
||||||
|
"_children": [],
|
||||||
|
"name": "{{ name }}",
|
||||||
|
"logo": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_id": 1,
|
||||||
|
"type": "div",
|
||||||
|
"_styles": {
|
||||||
|
"layout": {},
|
||||||
|
"position": {}
|
||||||
|
},
|
||||||
|
"_code": "",
|
||||||
|
"className": "",
|
||||||
|
"onLoad": []
|
||||||
|
},
|
||||||
|
"_css": "",
|
||||||
|
"uiFunctions": ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue