34b957f331
* refactoring server for screens & page layout restructure * Disable API calls, UI placeholders. * buildPropsHierarchy is gone & screen has url * Recent changes. * router * router * updated git-ignore to reinclude server/utilities/builder * modified cli - budi new create new file structure * Fix uuid import. * prettier fixes * prettier fixes * prettier fixes * page/screen restructure.. broken tests * all tests passing at last * screen routing tests * Working screen editor and preview. * Render page previews to the screen. * Key input lists to ensure new array references when updating styles. * Ensure the iframe html and body fills the container. * Save screens via the API. * Get all save APIs almost working. * Write pages.json to disk. * Use correct API endpoint for saving styles. * Differentiate between saving properties of screens and pages. * Add required fields to default pages layouts. * Add _css default property to newly created screens. * Add default code property. * page layout / screens - app output * backend and fronend save seperately Co-authored-by: pngwn <pnda007@gmail.com>
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
const { appPackageFolder } = require("../createAppPackage")
|
|
const { readJSON, readdir, stat } = require("fs-extra")
|
|
const { join } = require("path")
|
|
const { keyBy } = require("lodash/fp")
|
|
|
|
module.exports = async (config, appname, pagename) => {
|
|
const appPath = appPackageFolder(config, appname)
|
|
return keyBy("name")(await fetchscreens(appPath, pagename))
|
|
}
|
|
|
|
const fetchscreens = async (appPath, pagename, relativePath = "") => {
|
|
const currentDir = join(appPath, "pages", pagename, "screens", relativePath)
|
|
|
|
const contents = await readdir(currentDir)
|
|
|
|
const screens = []
|
|
|
|
for (let item of contents) {
|
|
const itemRelativePath = join(relativePath, item)
|
|
const itemFullPath = join(currentDir, item)
|
|
const stats = await stat(itemFullPath)
|
|
|
|
if (stats.isFile()) {
|
|
if (!item.endsWith(".json")) continue
|
|
|
|
const component = await readJSON(itemFullPath)
|
|
|
|
component.name = itemRelativePath
|
|
.substring(0, itemRelativePath.length - 5)
|
|
.replace(/\\/g, "/")
|
|
|
|
component.props = component.props || {}
|
|
|
|
screens.push(component)
|
|
} else {
|
|
const childComponents = await fetchscreens(
|
|
appPath,
|
|
join(relativePath, item)
|
|
)
|
|
|
|
for (let c of childComponents) {
|
|
screens.push(c)
|
|
}
|
|
}
|
|
}
|
|
|
|
return screens
|
|
}
|