From 5ee72b1d870c429b6e952a6eb1afbf3cb54b9f9d Mon Sep 17 00:00:00 2001 From: michael shanks Date: Sat, 7 Sep 2019 06:50:35 +0100 Subject: [PATCH] build app... probably not orking yet.. --- packages/apiClient/recordApi.js | 0 packages/builder/src/builderStore/store.js | 7 +- packages/client/package.json | 4 +- packages/client/src/index.js | 4 +- packages/client/src/initialise.js | 24 ++----- packages/client/src/initialiseComponent.js | 16 ++--- .../appPackages/testApp/dist/package.tar.gz | Bin 2223 -> 2165 bytes .../testApp2/components/Joes Button.json | 11 ++++ .../testApp2/components/another noubtbtk.json | 11 ++++ .../testApp2/components/listofstuff.json | 41 ++++++++++++ .../testApp2/components/login2.json | 14 ++++ .../server/appPackages/testApp2/package.json | 15 +++++ .../server/appPackages/testApp2/pages.json | 20 ++---- .../standard-components/src/Button.svelte | 53 --------------- .../server/appPackages/testApp2/yarn.lock | 9 +++ packages/server/tests/builder.spec.js | 2 + packages/server/utilities/builder/buildApp.js | 61 +++++++++++------- .../utilities/builder/componentLibraryInfo.js | 19 ++++-- packages/server/utilities/builder/index.js | 20 +----- .../server/utilities/builder/savePackage.js | 25 +++++++ .../standard-components/.gitignore | 3 +- .../standard-components/README.md | 0 .../dist}/components.json | 0 .../standard-components/dist/package.json | 14 ++++ .../standard-components/package.json | 0 .../public/budibase-logo.png | Bin .../standard-components/public/bundle.css | 0 .../standard-components/public/bundle.css.map | 0 .../standard-components/public/bundle.js | 0 .../standard-components/public/bundle.js.map | 0 .../standard-components/public/favicon.png | Bin .../standard-components/public/global.css | 0 .../standard-components/public/index.html | 0 .../standard-components/rollup.config.js | 0 .../standard-components/rollup.testconfig.js | 0 .../standard-components/src/Form.svelte | 0 .../src/FormControl.svelte | 0 .../standard-components/src/Login.svelte | 0 .../standard-components/src/StackPanel.svelte | 0 .../src/Test/TestApp.svelte | 0 .../standard-components/src/Test/testMain.js | 0 .../standard-components/src/Textbox.svelte | 0 .../standard-components/src/button.svelte | 0 packages/standard-components/src/index.js | 6 ++ 44 files changed, 231 insertions(+), 148 deletions(-) delete mode 100644 packages/apiClient/recordApi.js create mode 100644 packages/server/appPackages/testApp2/components/Joes Button.json create mode 100644 packages/server/appPackages/testApp2/components/another noubtbtk.json create mode 100644 packages/server/appPackages/testApp2/components/listofstuff.json create mode 100644 packages/server/appPackages/testApp2/components/login2.json create mode 100644 packages/server/appPackages/testApp2/package.json delete mode 100644 packages/server/appPackages/testApp2/standard-components/src/Button.svelte create mode 100644 packages/server/appPackages/testApp2/yarn.lock create mode 100644 packages/server/utilities/builder/savePackage.js rename packages/{server/appPackages/testApp2 => }/standard-components/.gitignore (73%) rename packages/{server/appPackages/testApp2 => }/standard-components/README.md (100%) rename packages/{server/appPackages/testApp2/standard-components => standard-components/dist}/components.json (100%) create mode 100644 packages/standard-components/dist/package.json rename packages/{server/appPackages/testApp2 => }/standard-components/package.json (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/public/budibase-logo.png (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/public/bundle.css (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/public/bundle.css.map (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/public/bundle.js (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/public/bundle.js.map (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/public/favicon.png (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/public/global.css (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/public/index.html (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/rollup.config.js (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/rollup.testconfig.js (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/src/Form.svelte (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/src/FormControl.svelte (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/src/Login.svelte (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/src/StackPanel.svelte (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/src/Test/TestApp.svelte (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/src/Test/testMain.js (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/src/Textbox.svelte (100%) rename packages/{server/appPackages/testApp2 => }/standard-components/src/button.svelte (100%) create mode 100644 packages/standard-components/src/index.js diff --git a/packages/apiClient/recordApi.js b/packages/apiClient/recordApi.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/builder/src/builderStore/store.js b/packages/builder/src/builderStore/store.js index 2e53e97d5f..11b8e15829 100644 --- a/packages/builder/src/builderStore/store.js +++ b/packages/builder/src/builderStore/store.js @@ -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 = { diff --git a/packages/client/package.json b/packages/client/package.json index a39a8848e4..7a170d18e3 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -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" diff --git a/packages/client/src/index.js b/packages/client/src/index.js index f34a6e9d1d..0103299f9d 100644 --- a/packages/client/src/index.js +++ b/packages/client/src/index.js @@ -1,3 +1,5 @@ import { initialise } from "./initialise"; -initialise(); \ No newline at end of file +const appDefinition = window["##BUDIBASE_APPDEFINITION##"]; + +initialise(appDefinition); \ No newline at end of file diff --git a/packages/client/src/initialise.js b/packages/client/src/initialise.js index 3d6c1b20fc..cd6746b103 100644 --- a/packages/client/src/initialise.js +++ b/packages/client/src/initialise.js @@ -1,11 +1,8 @@ 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 = {}; for(let lib of appDefinition.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); - } \ No newline at end of file diff --git a/packages/client/src/initialiseComponent.js b/packages/client/src/initialiseComponent.js index 5ff0fbf686..37c36f99df 100644 --- a/packages/client/src/initialiseComponent.js +++ b/packages/client/src/initialiseComponent.js @@ -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); diff --git a/packages/server/appPackages/testApp/dist/package.tar.gz b/packages/server/appPackages/testApp/dist/package.tar.gz index 70c523e2e1ab18eaae1f9e702cde2f0ba8b53cb2..acfc8687d20f5a30b0bb97e47b7fb442665a72f1 100644 GIT binary patch literal 2165 zcmV-*2#WU~iwFP!000003hf(fkJ~mfp9ADS@Pq@pi*sx}?Ym7HV7p1t;F4`{>)e-O zkHJU|Wn;ddDoF|7&|Jm`uG|k~~h}0)Q^)vlp zIi6!XCj8mRG)MNxL(jYx*7htB634KVKRQp9x&ITuzE6bs!pIF_qW_!VVe>Th$lvnZ zp_0F4!xzVKkZFPVE$DB4DVy+(%m2YhMQ@z_@?eB`L5wql--aYMdPYRz1r>twFzuH2 zk?Qtif+ayQ@p&8oTF3+PZ*mVk10QyiFGwr~*2@PPERAI^9~KZszG7Gs1z$rA))+i` z&?7h-(C~&+u$_VZN0z*6nn!Hdu4xY5iCvT2#uSz!$s%IFnyA^dM1al|ngx+4!b03C zx|`@~Djwtb9;F_rh(baz#*OyM8kmG zRryd;?H%cJ#)vP$T8!oO^15f-0DblA%v?UTm2U?eMQ_QJhEy&5Y5c$IdL!-s9nXfq z?`r?=j5`0{20XlYj*u~@1Z>ftgI_?p1=`YJfQ*=PY4lc&smfOx{W)bpOhD7oFKH9X zW+}~-Ih<@@dB&B8Ds)XLVSy;lTA8^tyZ-D|I{ z_sVWD(-SMafJ|}1WF6{faBN`bt5p<{i@3}6kL#i+>O`zyn=n?PH=pemi z6j&S$#MK%`UzQbCY^Wm@SKv7qsWaJa*0P7YHD|?zZR4tzqoG@} z&JA|*+^*zMxAC&#Bcp0WSk6Dt!^k8K(F0P` zD^GFuoyt4YOzu1M56Ia&`X;_d6sp>M1c19)wm1b7A;>DNCHxzGbcsu zZ`qJM?M?AA>uquu###D&u6a4ihFtF0j~&~Pajia5MOpD%aIICI&roHH3Z8x2_5jL+ z%<&E7NqhzWe2u-pG_1!dZ}*u0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zu*2g&$FOuu<^QeD{#(H=J8wz{4we7<{4aKbF8|jG3g`b}`UbUm9((0)8|(9*ng0Gq zgaMuWTY!B3NeLPdI_qij%_M-?D{1v2{N&YR53s{gQMCWm-OqVIn&q+A{#|Qr|Axx{ zsP~_Gv%{#z6Sx1@QrvISc>eW-`inQ8&OTfS^B=#v9D}pZpMmjusLEeFe?3&hk3HlL z4Wd5(+iWPX*Zv)MZU45R?thFf{%Zx>_y6kewdC&;9(%MMn#LCUZ!{FxYyYEy{X6OT xU)49jdoP~2{crC7UoOtRjDLD}G5&CVHh%ZE3k5oK=+NPt#GjsboFxEW005NSdSU -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); -} - - - - - - - - \ No newline at end of file diff --git a/packages/server/appPackages/testApp2/yarn.lock b/packages/server/appPackages/testApp2/yarn.lock new file mode 100644 index 0000000000..f67d140ba2 --- /dev/null +++ b/packages/server/appPackages/testApp2/yarn.lock @@ -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" diff --git a/packages/server/tests/builder.spec.js b/packages/server/tests/builder.spec.js index a72f512de1..a1b7dbd258 100644 --- a/packages/server/tests/builder.spec.js +++ b/packages/server/tests/builder.spec.js @@ -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 () => { diff --git a/packages/server/utilities/builder/buildApp.js b/packages/server/utilities/builder/buildApp.js index 340bbbadd6..b748bc8ede 100644 --- a/packages/server/utilities/builder/buildApp.js +++ b/packages/server/utilities/builder/buildApp.js @@ -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); - - await copyClientLib(appPath); + pages, "main"); + + 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,12 +80,15 @@ 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 componentLibraries = []; - const appPublicPath = publicPath(appPath); + + const appPublicPath = publicPath(appPath, pageName); const appRootPath = rootPath(config, appname); + + const componentLibraries = []; + for(let lib of pages.componentLibraries) { const info = await componentLibraryInfo(appPath, lib); const source = join(info.libDir, info.components._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)}`); } \ No newline at end of file diff --git a/packages/server/utilities/builder/componentLibraryInfo.js b/packages/server/utilities/builder/componentLibraryInfo.js index 24e9730f71..e5eaceab03 100644 --- a/packages/server/utilities/builder/componentLibraryInfo.js +++ b/packages/server/utilities/builder/componentLibraryInfo.js @@ -1,11 +1,20 @@ const { - readJSON, exists + 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"); diff --git a/packages/server/utilities/builder/index.js b/packages/server/utilities/builder/index.js index 55f93d8bb8..5839d5b95f 100644 --- a/packages/server/utilities/builder/index.js +++ b/packages/server/utilities/builder/index.js @@ -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 { diff --git a/packages/server/utilities/builder/savePackage.js b/packages/server/utilities/builder/savePackage.js new file mode 100644 index 0000000000..a9d41a295b --- /dev/null +++ b/packages/server/utilities/builder/savePackage.js @@ -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); +} \ No newline at end of file diff --git a/packages/server/appPackages/testApp2/standard-components/.gitignore b/packages/standard-components/.gitignore similarity index 73% rename from packages/server/appPackages/testApp2/standard-components/.gitignore rename to packages/standard-components/.gitignore index 050b000879..2986122cff 100644 --- a/packages/server/appPackages/testApp2/standard-components/.gitignore +++ b/packages/standard-components/.gitignore @@ -2,5 +2,4 @@ node_modules yarn.lock package-lock.json -index.js -index.mjs \ No newline at end of file +dist/index.js diff --git a/packages/server/appPackages/testApp2/standard-components/README.md b/packages/standard-components/README.md similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/README.md rename to packages/standard-components/README.md diff --git a/packages/server/appPackages/testApp2/standard-components/components.json b/packages/standard-components/dist/components.json similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/components.json rename to packages/standard-components/dist/components.json diff --git a/packages/standard-components/dist/package.json b/packages/standard-components/dist/package.json new file mode 100644 index 0000000000..30f673602c --- /dev/null +++ b/packages/standard-components/dist/package.json @@ -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" +} diff --git a/packages/server/appPackages/testApp2/standard-components/package.json b/packages/standard-components/package.json similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/package.json rename to packages/standard-components/package.json diff --git a/packages/server/appPackages/testApp2/standard-components/public/budibase-logo.png b/packages/standard-components/public/budibase-logo.png similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/public/budibase-logo.png rename to packages/standard-components/public/budibase-logo.png diff --git a/packages/server/appPackages/testApp2/standard-components/public/bundle.css b/packages/standard-components/public/bundle.css similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/public/bundle.css rename to packages/standard-components/public/bundle.css diff --git a/packages/server/appPackages/testApp2/standard-components/public/bundle.css.map b/packages/standard-components/public/bundle.css.map similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/public/bundle.css.map rename to packages/standard-components/public/bundle.css.map diff --git a/packages/server/appPackages/testApp2/standard-components/public/bundle.js b/packages/standard-components/public/bundle.js similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/public/bundle.js rename to packages/standard-components/public/bundle.js diff --git a/packages/server/appPackages/testApp2/standard-components/public/bundle.js.map b/packages/standard-components/public/bundle.js.map similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/public/bundle.js.map rename to packages/standard-components/public/bundle.js.map diff --git a/packages/server/appPackages/testApp2/standard-components/public/favicon.png b/packages/standard-components/public/favicon.png similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/public/favicon.png rename to packages/standard-components/public/favicon.png diff --git a/packages/server/appPackages/testApp2/standard-components/public/global.css b/packages/standard-components/public/global.css similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/public/global.css rename to packages/standard-components/public/global.css diff --git a/packages/server/appPackages/testApp2/standard-components/public/index.html b/packages/standard-components/public/index.html similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/public/index.html rename to packages/standard-components/public/index.html diff --git a/packages/server/appPackages/testApp2/standard-components/rollup.config.js b/packages/standard-components/rollup.config.js similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/rollup.config.js rename to packages/standard-components/rollup.config.js diff --git a/packages/server/appPackages/testApp2/standard-components/rollup.testconfig.js b/packages/standard-components/rollup.testconfig.js similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/rollup.testconfig.js rename to packages/standard-components/rollup.testconfig.js diff --git a/packages/server/appPackages/testApp2/standard-components/src/Form.svelte b/packages/standard-components/src/Form.svelte similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/src/Form.svelte rename to packages/standard-components/src/Form.svelte diff --git a/packages/server/appPackages/testApp2/standard-components/src/FormControl.svelte b/packages/standard-components/src/FormControl.svelte similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/src/FormControl.svelte rename to packages/standard-components/src/FormControl.svelte diff --git a/packages/server/appPackages/testApp2/standard-components/src/Login.svelte b/packages/standard-components/src/Login.svelte similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/src/Login.svelte rename to packages/standard-components/src/Login.svelte diff --git a/packages/server/appPackages/testApp2/standard-components/src/StackPanel.svelte b/packages/standard-components/src/StackPanel.svelte similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/src/StackPanel.svelte rename to packages/standard-components/src/StackPanel.svelte diff --git a/packages/server/appPackages/testApp2/standard-components/src/Test/TestApp.svelte b/packages/standard-components/src/Test/TestApp.svelte similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/src/Test/TestApp.svelte rename to packages/standard-components/src/Test/TestApp.svelte diff --git a/packages/server/appPackages/testApp2/standard-components/src/Test/testMain.js b/packages/standard-components/src/Test/testMain.js similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/src/Test/testMain.js rename to packages/standard-components/src/Test/testMain.js diff --git a/packages/server/appPackages/testApp2/standard-components/src/Textbox.svelte b/packages/standard-components/src/Textbox.svelte similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/src/Textbox.svelte rename to packages/standard-components/src/Textbox.svelte diff --git a/packages/server/appPackages/testApp2/standard-components/src/button.svelte b/packages/standard-components/src/button.svelte similarity index 100% rename from packages/server/appPackages/testApp2/standard-components/src/button.svelte rename to packages/standard-components/src/button.svelte diff --git a/packages/standard-components/src/index.js b/packages/standard-components/src/index.js new file mode 100644 index 0000000000..fbf8bfb57d --- /dev/null +++ b/packages/standard-components/src/index.js @@ -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";