build app... probably not orking yet..
This commit is contained in:
parent
dc0ad5c0d1
commit
5ee72b1d87
|
@ -24,6 +24,7 @@ import {
|
|||
} from "../common/core";
|
||||
import {writable} from "svelte/store";
|
||||
import { defaultPagesObject } from "../userInterface/pagesParsing/defaultPagesObject"
|
||||
import { buildPropsHierarchy } from "../userInterface/pagesParsing/buildPropsHierarchy"
|
||||
import api from "./api";
|
||||
import { isRootComponent } from "../userInterface/pagesParsing/searchComponents";
|
||||
import {
|
||||
|
@ -579,8 +580,10 @@ const savePackage = (store, s) => {
|
|||
hierarchy:s.hierarchy,
|
||||
triggers:s.triggers,
|
||||
actions: groupBy("name")(s.actions),
|
||||
mainUi: s.mainUi,
|
||||
unauthenticatedUi: s.unauthenticatedUi
|
||||
props: {
|
||||
main: buildPropsHierarchy(s.allComponents, s.pages.main.appBody),
|
||||
unauthenticated: buildPropsHierarchy(s.allComponents, s.pages.unauthenticated.appBody)
|
||||
}
|
||||
};
|
||||
|
||||
const data = {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "budibase-builder",
|
||||
"name": "budibase-client",
|
||||
"version": "0.0.1",
|
||||
"license": "AGPL-3.0",
|
||||
"license": "MPL-2.0",
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"test": "jest"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { initialise } from "./initialise";
|
||||
|
||||
initialise();
|
||||
const appDefinition = window["##BUDIBASE_APPDEFINITION##"];
|
||||
|
||||
initialise(appDefinition);
|
|
@ -1,10 +1,7 @@
|
|||
import { writable } from "svelte/store";
|
||||
import { initialiseComponent } from "./initialiseComponent";
|
||||
|
||||
export const initialise = async (document, appDefinition, pageDefinition) => {
|
||||
for(let stylesheet of pageDefinition.stylesheets) {
|
||||
addStylesheet(document, stylesheet);
|
||||
}
|
||||
export const initialise = async (document, appDefinition) => {
|
||||
|
||||
const componentLibraries = {};
|
||||
|
||||
|
@ -16,20 +13,9 @@ export const initialise = async (document, appDefinition, pageDefinition) => {
|
|||
const store = writable({});
|
||||
|
||||
initialiseComponent(allComponents, componentLibraries, store)(
|
||||
appDefinition.rootProps,
|
||||
appDefinition.props,
|
||||
document.body);
|
||||
}
|
||||
const componentLibraryUrl = (lib, rootUrlPath) =>
|
||||
`${rootPath}/api/componentlibrary?lib=${encodeURI(lib)}`
|
||||
const componentLibraryUrl = (lib, appRootPath) =>
|
||||
`${appRootPath}/componentlibrary?lib=${encodeURI(lib)}`
|
||||
|
||||
const addStylesheet = (document, url) => {
|
||||
|
||||
const head = document.head;
|
||||
const link = document.createElement("link");
|
||||
|
||||
link.type = "text/css";
|
||||
link.rel = "stylesheet";
|
||||
link.href = url;
|
||||
|
||||
head.appendChild(link);
|
||||
}
|
|
@ -9,8 +9,9 @@ import { $ } from "./core/common";
|
|||
|
||||
export const initialiseComponent = (allComponents, componentLibraries, store) => (props, htmlElement) => {
|
||||
|
||||
const rootComponent = getRootComponent(
|
||||
props._component, allComponents);
|
||||
const component = getComponent(
|
||||
props._component,
|
||||
allComponents);
|
||||
|
||||
const _app = {
|
||||
initialiseComponent: initialiseComponent(allComponents, componentLibraries, store),
|
||||
|
@ -18,7 +19,7 @@ export const initialiseComponent = (allComponents, componentLibraries, store) =>
|
|||
};
|
||||
|
||||
const {componentName, libName} = splitName(
|
||||
rootComponent.name);
|
||||
component.name);
|
||||
|
||||
new (componentLibraries[libName][componentName])({
|
||||
target: htmlElement,
|
||||
|
@ -27,13 +28,8 @@ export const initialiseComponent = (allComponents, componentLibraries, store) =>
|
|||
|
||||
}
|
||||
|
||||
const getRootComponent = (componentName, allComponents) => {
|
||||
const component = find(c => c.name === componentName)(allComponents);
|
||||
|
||||
if(isRootComponent(component)) return component;
|
||||
|
||||
return getRootComponent(component.inherits, allComponents);
|
||||
}
|
||||
const getComponent = (componentName, allComponents) =>
|
||||
find(c => c.name === componentName)(allComponents);
|
||||
|
||||
const isRootComponent = c => isUndefined(c.inherits);
|
||||
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "Joes Button",
|
||||
"description": "",
|
||||
"inherits": "./standard-components/button",
|
||||
"props": {
|
||||
"className": "btn btn-danger"
|
||||
},
|
||||
"tags": [
|
||||
"button"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "another noubtbtk",
|
||||
"description": "",
|
||||
"inherits": "./standard-components/button",
|
||||
"props": {
|
||||
"contentText": "Mike"
|
||||
},
|
||||
"tags": [
|
||||
"button"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"name": "listofstuff",
|
||||
"description": "",
|
||||
"inherits": "./standard-components/stackpanel",
|
||||
"props": {
|
||||
"children": [
|
||||
{
|
||||
"_component": "listofstuff:children",
|
||||
"control": {
|
||||
"_component": "Primary Button",
|
||||
"contentText": "Button",
|
||||
"contentComponent": {
|
||||
"_component": ""
|
||||
},
|
||||
"className": "btn btn-primary",
|
||||
"disabled": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"_component": "listofstuff:children",
|
||||
"control": {
|
||||
"_component": "Joes Button",
|
||||
"contentText": "Button",
|
||||
"contentComponent": {
|
||||
"_component": ""
|
||||
},
|
||||
"className": "btn btn-danger",
|
||||
"disabled": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"_component": "listofstuff",
|
||||
"direction": "vertical"
|
||||
},
|
||||
"tags": [
|
||||
"div",
|
||||
"container",
|
||||
"layout",
|
||||
"panel"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "login2",
|
||||
"description": "",
|
||||
"inherits": "./standard-components/login",
|
||||
"props": {
|
||||
"usernameLabel": "User"
|
||||
},
|
||||
"tags": [
|
||||
"login",
|
||||
"credentials",
|
||||
"password",
|
||||
"logon"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "testapp2",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "plugins.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"budibase-client": "file:../../../client/dist",
|
||||
"budibase-standard-components": "file:../../../standard-components/dist"
|
||||
}
|
||||
}
|
|
@ -1,20 +1,12 @@
|
|||
{
|
||||
"main": {
|
||||
"index": {
|
||||
"title": "yyyaaa"
|
||||
},
|
||||
"appBody": "Random Button"
|
||||
"index": {},
|
||||
"appBody": ""
|
||||
},
|
||||
"unauthenticated": {
|
||||
"index": {
|
||||
"title": "Test App 1 - Login"
|
||||
},
|
||||
"appBody": "login_screen"
|
||||
"index": {},
|
||||
"appBody": ""
|
||||
},
|
||||
"componentLibraries": [
|
||||
"./standard-components"
|
||||
],
|
||||
"stylesheets": [
|
||||
"https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
||||
]
|
||||
"componentLibraries": [],
|
||||
"stylesheets": []
|
||||
}
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
<script>
|
||||
export let className = "default";
|
||||
export let disabled = false;
|
||||
export let contentText;
|
||||
export let contentComponent;
|
||||
|
||||
export let _app;
|
||||
let contentComponentContainer;
|
||||
|
||||
$:{
|
||||
if(_app && contentComponentContainer)
|
||||
_app.initialiseComponent(contentComponent, contentComponentContainer);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<button class={className} {disabled} on:click>
|
||||
{#if contentComponent && contentComponent._component}
|
||||
<div bind:this={contentComponentContainer}>
|
||||
</div>
|
||||
{:else if contentText}
|
||||
{contentText}
|
||||
{:else}
|
||||
<slot />
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
.default {
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
padding: 0.4em;
|
||||
margin: 0 0 0.5em 0;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 2px;
|
||||
color: #333;
|
||||
background-color: #f4f4f4;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.default:active {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
.default:focus {
|
||||
border-color: #666;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -0,0 +1,9 @@
|
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"budibase-client@file:../../../client/dist":
|
||||
version "0.0.1"
|
||||
|
||||
"budibase-standard-components@file:../../../standard-components/dist":
|
||||
version "1.0.0"
|
|
@ -10,6 +10,8 @@ const derivedComponent2 = require("../appPackages/testApp/components/subfolder/o
|
|||
const { readJSON, pathExists, unlink } = require("fs-extra");
|
||||
|
||||
const app = require("./testApp")();
|
||||
testComponents.textbox.name = `./customComponents/textbox`;
|
||||
testMoreComponents.textbox.name = `./moreCustomComponents/textbox`;
|
||||
|
||||
beforeAll(async () => {
|
||||
|
||||
|
|
|
@ -10,40 +10,50 @@ const {
|
|||
const { join } = require("path");
|
||||
const sqrl = require('squirrelly');
|
||||
|
||||
module.exports = async (config, appname, pageName, pages, appdefinition) => {
|
||||
module.exports = async (config, appname, pages, appdefinition) => {
|
||||
|
||||
const appPath = appPackageFolder(config, appname);
|
||||
|
||||
await buildClientAppDefinition(
|
||||
config, appname,
|
||||
appdefinition, componentLibraries,
|
||||
appPath, appRootPath)
|
||||
appPath, pages, "main");
|
||||
|
||||
await buildClientAppDefinition(
|
||||
config, appname,
|
||||
appdefinition, componentLibraries,
|
||||
appPath, pages, "unauthenticated")
|
||||
|
||||
await buildIndexHtml(
|
||||
config, appname, appPath,
|
||||
pageName, pages);
|
||||
pages, "main");
|
||||
|
||||
await copyClientLib(appPath);
|
||||
await buildIndexHtml(
|
||||
config, appname, appPath,
|
||||
pages, "unauthenticated");
|
||||
|
||||
await copyClientLib(appPath, "main");
|
||||
await copyClientLib(appPath, "unauthenticated");
|
||||
|
||||
}
|
||||
|
||||
const publicPath = async appPath => join(appPath, "public");
|
||||
const publicPath = async (appPath, pageName) => join(appPath, "public", pageName);
|
||||
const rootPath = (config, appname) => config.useAppRootPath ? `/${appname}` : "";
|
||||
|
||||
const copyClientLib = async appPath => {
|
||||
const copyClientLib = async (appPath, pageName) => {
|
||||
var sourcepath = require.resolve("budibase-client",{
|
||||
basedir: appPath
|
||||
paths: [appPath]
|
||||
});
|
||||
var destPath = join(publicPath(appPath), "budibase-client.js");
|
||||
var destPath = join(publicPath(appPath, pageName), "budibase-client.js");
|
||||
|
||||
await copyFile(sourcepath, destPath, constants.COPYFILE_FICLONE);
|
||||
|
||||
}
|
||||
|
||||
const buildIndexHtml = async (config, appname, appPath, pageName, pages) => {
|
||||
const buildIndexHtml = async (config, appname, appPath, pages, pageName) => {
|
||||
|
||||
|
||||
const appPublicPath = publicPath(appPath);
|
||||
const appPublicPath = publicPath(appPath, pageName);
|
||||
const appRootPath = rootPath(config, appname);
|
||||
|
||||
const stylesheetUrl = s =>
|
||||
|
@ -51,11 +61,10 @@ const buildIndexHtml = async (config, appname, appPath, pageName, pages) => {
|
|||
? s
|
||||
: `/${rootPath(config, appname)}/${s}`;
|
||||
|
||||
|
||||
const templateObj = {
|
||||
title = pages[pageName].index.title || "Budibase App",
|
||||
favicon = `${appRootPath}/${pages[pageName].index.favicon || "/assets/favicon.png"}`,
|
||||
stylesheets = pages.stylesheets.map(stylesheetUrl),
|
||||
title: pages[pageName].index.title || "Budibase App",
|
||||
favicon: `${appRootPath}/${pages[pageName].index.favicon || "/assets/favicon.png"}`,
|
||||
stylesheets: pages.stylesheets.map(stylesheetUrl),
|
||||
appRootPath
|
||||
}
|
||||
|
||||
|
@ -71,11 +80,14 @@ const buildIndexHtml = async (config, appname, appPath, pageName, pages) => {
|
|||
}
|
||||
|
||||
|
||||
const buildClientAppDefinition = async (config, appname, appdefinition, pages, appPath) => {
|
||||
const buildClientAppDefinition = async (config, appname, appdefinition, appPath, pages, pageName) => {
|
||||
|
||||
|
||||
const appPublicPath = publicPath(appPath, pageName);
|
||||
const appRootPath = rootPath(config, appname);
|
||||
|
||||
|
||||
const componentLibraries = [];
|
||||
const appPublicPath = publicPath(appPath);
|
||||
const appRootPath = rootPath(config, appname);
|
||||
|
||||
for(let lib of pages.componentLibraries) {
|
||||
const info = await componentLibraryInfo(appPath, lib);
|
||||
|
@ -101,11 +113,14 @@ const buildClientAppDefinition = async (config, appname, appdefinition, pages, a
|
|||
|
||||
const filename = join(appPublicPath, "clientAppDefinition.js");
|
||||
|
||||
const clientAppDefObj = {
|
||||
hierarchy: appdefinition.hierarchy,
|
||||
componentLibraries: pages.componentLibraries,
|
||||
appRootPath: appRootPath,
|
||||
props: appdefinition.props[pageName]
|
||||
}
|
||||
|
||||
await writeFile(filename,
|
||||
`window['##BUDIBASE_APPDEFINITION##'] = {
|
||||
hierarchy: ${JSON.stringify(appdefinition.hierarchy)},
|
||||
componentLibraries: ${JSON.stringify(componentLibraries)},
|
||||
appRootPath: '${appRootPath}'
|
||||
}`);
|
||||
`window['##BUDIBASE_APPDEFINITION##'] = ${JSON.stringify(clientAppDefObj)}`);
|
||||
|
||||
}
|
|
@ -1,11 +1,20 @@
|
|||
const {
|
||||
readJSON, exists
|
||||
} = require("fs-extra");
|
||||
const { resolve } = require("path");
|
||||
const {
|
||||
resolve, join , dirname
|
||||
} = require("path");
|
||||
|
||||
const getLibDir = (appPath, libname) => require.resolve(libname, {
|
||||
basedir: appPath
|
||||
});
|
||||
const getLibDir = (appPath, libname) => {
|
||||
try {
|
||||
const componentsFile = require.resolve(
|
||||
join(libname, "components.json"),
|
||||
{ paths: [appPath]});
|
||||
return dirname(componentsFile);
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
const getComponentsFilepath = libPath =>
|
||||
resolve(libPath, "components.json");
|
||||
|
|
|
@ -26,6 +26,9 @@ const {
|
|||
const {merge} = require("lodash");
|
||||
|
||||
const { componentLibraryInfo } = require("./componentLibraryInfo");
|
||||
const savePackage = require("./savePackage");
|
||||
|
||||
module.exports.savePackage = savePackage;
|
||||
|
||||
module.exports.getPackageForBuilder = async (config, appname) => {
|
||||
const appPath = appPackageFolder(config, appname);
|
||||
|
@ -47,23 +50,7 @@ module.exports.getPackageForBuilder = async (config, appname) => {
|
|||
|
||||
}
|
||||
|
||||
module.exports.savePackage = async (config, appname, pkg) => {
|
||||
const appPath = appPackageFolder(config, appname);
|
||||
await writeJSON(
|
||||
`${appPath}/appDefinition.json`,
|
||||
pkg.appDefinition,
|
||||
{spaces:2});
|
||||
|
||||
await writeJSON(
|
||||
`${appPath}/access_levels.json`,
|
||||
pkg.accessLevels,
|
||||
{spaces:2});
|
||||
|
||||
await writeJSON(
|
||||
`${appPath}/pages.json`,
|
||||
pkg.pages,
|
||||
{spaces:2});
|
||||
}
|
||||
|
||||
module.exports.getApps = async (config) =>
|
||||
await readdir(appsFolder(config));
|
||||
|
@ -173,7 +160,6 @@ const fetchDerivedComponents = async (appPath, relativePath = "") => {
|
|||
.replace(/\\/g, "/");
|
||||
|
||||
component.props = component.props || {};
|
||||
component.props._component = component.name;
|
||||
|
||||
components.push(component);
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
const { appPackageFolder } = require("../createAppPackage");
|
||||
const { writeJSON } = require("fs-extra");
|
||||
const buildApp = require("./buildApp");
|
||||
|
||||
module.exports = async (config, appname, pkg) => {
|
||||
const appPath = appPackageFolder(config, appname);
|
||||
await writeJSON(
|
||||
`${appPath}/appDefinition.json`,
|
||||
pkg.appDefinition,
|
||||
{spaces:2});
|
||||
|
||||
await writeJSON(
|
||||
`${appPath}/access_levels.json`,
|
||||
pkg.accessLevels,
|
||||
{spaces:2});
|
||||
|
||||
await writeJSON(
|
||||
`${appPath}/pages.json`,
|
||||
pkg.pages,
|
||||
{spaces:2});
|
||||
|
||||
await buildApp(
|
||||
config, appname,
|
||||
pkg.pages, pkg.appDefinition);
|
||||
}
|
|
@ -2,5 +2,4 @@
|
|||
node_modules
|
||||
yarn.lock
|
||||
package-lock.json
|
||||
index.js
|
||||
index.mjs
|
||||
dist/index.js
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "budibase-standard-components",
|
||||
"svelte": "src/index.svelte",
|
||||
"main": "index.js",
|
||||
"devDependencies": {},
|
||||
"keywords": [
|
||||
"budibase"
|
||||
],
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"version": "1.0.0",
|
||||
"license": "MPL-2.0"
|
||||
}
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
@ -0,0 +1,6 @@
|
|||
export {default as button} from "./Button.svelte";
|
||||
export {default as login} from "./Login.svelte";
|
||||
export {default as form} from "./Form.svelte";
|
||||
export {default as formControl} from "./FormControl.svelte";
|
||||
export {default as textbox} from "./Textbox.svelte";
|
||||
export {default as stackpanel} from "./StackPanel.svelte";
|
Loading…
Reference in New Issue