autu populated login page
This commit is contained in:
parent
c10c1bed08
commit
77a16f95da
|
@ -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,20 +1,44 @@
|
||||||
{
|
{
|
||||||
"title": "Test App",
|
"componentLibraries": [
|
||||||
|
"@budibase/standard-components",
|
||||||
|
"@budibase/materialdesign-components"
|
||||||
|
],
|
||||||
|
"title": "{{ name }}",
|
||||||
"favicon": "./_shared/favicon.png",
|
"favicon": "./_shared/favicon.png",
|
||||||
"stylesheets": [],
|
"stylesheets": [],
|
||||||
"componentLibraries": ["@budibase/standard-components", "@budibase/materialdesign-components"],
|
|
||||||
"props": {
|
"props": {
|
||||||
"_component": "@budibase/standard-components/container",
|
"_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": [],
|
"_children": [],
|
||||||
|
"name": "{{ name }}",
|
||||||
|
"logo": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
"_id": 1,
|
"_id": 1,
|
||||||
"type": "div",
|
"type": "div",
|
||||||
"_styles": {
|
"_styles": {
|
||||||
"active": {},
|
"layout": {},
|
||||||
"hover": {},
|
"position": {}
|
||||||
"normal": {},
|
|
||||||
"selected": {}
|
|
||||||
},
|
},
|
||||||
"_code": ""
|
"_code": "",
|
||||||
|
"className": "",
|
||||||
|
"onLoad": []
|
||||||
},
|
},
|
||||||
"_css": "",
|
"_css": "",
|
||||||
"uiFunctions": ""
|
"uiFunctions": ""
|
||||||
|
|
Loading…
Reference in New Issue