generate src wwws
This commit is contained in:
parent
c9504f8dae
commit
d96018f8a1
@ -16,6 +16,15 @@ const log = conf.api.activelog.includes(currentmod);
|
|||||||
const Wwws = {};
|
const Wwws = {};
|
||||||
|
|
||||||
Wwws.getwco = (wconame, ctx) => {
|
Wwws.getwco = (wconame, ctx) => {
|
||||||
|
/**
|
||||||
|
* In a webpage to add a wco
|
||||||
|
* <script src="/api/adminapi/wwws/getwco/wco.js?wcotribe=adminapi&tribe=adminapi&xapp=admin&pagename=apxid&code=enjoy"></script>
|
||||||
|
* This will update /tribe/objects/wwws/itm/xapp.json
|
||||||
|
* A wco has a /adminapi/objects/wco/itm/wconame.json
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
const filereq = `../${ctx.wcotribe}/objects/wco/${wconame}/${wconame}.js`;
|
const filereq = `../${ctx.wcotribe}/objects/wco/${wconame}/${wconame}.js`;
|
||||||
const wcoconf = `../${ctx.wcotribe}/objects/wco/itm/${wconame}.json`;
|
const wcoconf = `../${ctx.wcotribe}/objects/wco/itm/${wconame}.json`;
|
||||||
if (!fs.existsSync(filereq) || !fs.existsSync(wcoconf)) {
|
if (!fs.existsSync(filereq) || !fs.existsSync(wcoconf)) {
|
||||||
@ -32,13 +41,28 @@ Wwws.getwco = (wconame, ctx) => {
|
|||||||
const webconf = `../${ctx.tribe}/objects/wwws/itm/${ctx.xapp}.json`;
|
const webconf = `../${ctx.tribe}/objects/wwws/itm/${ctx.xapp}.json`;
|
||||||
const wcoinfo = fs.readJSONSync(wcoconf);
|
const wcoinfo = fs.readJSONSync(wcoconf);
|
||||||
const webpage = fs.readJSONSync(webconf);
|
const webpage = fs.readJSONSync(webconf);
|
||||||
|
// check that webconf for tailwindcsscontent property exist for this wco request
|
||||||
|
const pathtocheckfortw=[`../adminapi/objects/wco/${wconame}/*.{html,js,mustache}`,`../${ctx.tribe}/objects/wwws/${ctx.xapp}/src/**/*.{html,js,mustache}`]
|
||||||
|
if (!webconf.tailwindcsscontent){
|
||||||
|
webconf.tailwindcsscontent=[]
|
||||||
|
}
|
||||||
|
pathtocheckfortw.forEach(tw=>{
|
||||||
|
if (!webconf.tailwindcsscontent.includes(tw)){
|
||||||
|
webconf.tailwindcsscontent.push(tw)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// check that all tpl for this compoent are well in pages tpl object
|
||||||
if (wcoinfo.tpl && Object.keys(wcoinfo.tpl).length > 0) {
|
if (wcoinfo.tpl && Object.keys(wcoinfo.tpl).length > 0) {
|
||||||
Object.keys(wcoinfo.tpl).forEach((t) => {
|
Object.keys(wcoinfo.tpl).forEach((t) => {
|
||||||
|
//console.log(ctx.pagename,"---",t)
|
||||||
|
//console.log(Object.keys(webpage.pages[ctx.pagename].tpl))
|
||||||
if (!Object.keys(webpage.pages[ctx.pagename].tpl).includes(t)) {
|
if (!Object.keys(webpage.pages[ctx.pagename].tpl).includes(t)) {
|
||||||
|
//console.log(wcoinfo.tpl[t])
|
||||||
webpage.pages[ctx.pagename].tpl[t] = wcoinfo.tpl[t];
|
webpage.pages[ctx.pagename].tpl[t] = wcoinfo.tpl[t];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// check that tpldata exist for the wco, if not create them with template data example into the project
|
||||||
if (wcoinfo.tpldatamodel && Object.keys(wcoinfo.tpldatamodel).length > 0) {
|
if (wcoinfo.tpldatamodel && Object.keys(wcoinfo.tpldatamodel).length > 0) {
|
||||||
Object.keys(wcoinfo.tpldatamodel).forEach((t) => {
|
Object.keys(wcoinfo.tpldatamodel).forEach((t) => {
|
||||||
const pathtpldata = `../${ctx.tribe}/objects/wwws/${ctx.xapp}/src/tpldata/${wconame}/${t}`;
|
const pathtpldata = `../${ctx.tribe}/objects/wwws/${ctx.xapp}/src/tpldata/${wconame}/${t}`;
|
||||||
@ -58,6 +82,7 @@ Wwws.getwco = (wconame, ctx) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// check if referential are there for this wco
|
||||||
if (wcoinfo.ref && Object.keys(wcoinfo.ref).length > 0) {
|
if (wcoinfo.ref && Object.keys(wcoinfo.ref).length > 0) {
|
||||||
Object.keys(wcoinfo.ref).forEach((t) => {
|
Object.keys(wcoinfo.ref).forEach((t) => {
|
||||||
t = t.replace("{{tribe}}", ctx.tribe);
|
t = t.replace("{{tribe}}", ctx.tribe);
|
||||||
@ -66,6 +91,7 @@ Wwws.getwco = (wconame, ctx) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//check that schema are also their for wco
|
||||||
if (wcoinfo.schema && wcoinfo.schema.length > 0)
|
if (wcoinfo.schema && wcoinfo.schema.length > 0)
|
||||||
[
|
[
|
||||||
wcoinfo.schema.forEach((s) => {
|
wcoinfo.schema.forEach((s) => {
|
||||||
@ -75,7 +101,8 @@ Wwws.getwco = (wconame, ctx) => {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
fs.outputJSONSync(webconf, webpage);
|
// save the conf for update localdb when the web page request it
|
||||||
|
fs.outputJSONSync(webconf, webpage, {spaces:2});
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
ref: "Wwws",
|
ref: "Wwws",
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
"publishtestwall": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@wall-ants://home/phil/apxtowns/testwall-ants/tribes/$space/..",
|
"publishtestwall": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@wall-ants://home/phil/apxtowns/testwall-ants/tribes/$space/..",
|
||||||
"publishwall": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@wall-ants://home/phil/apxtowns/wall-ants/tribes/$space/..",
|
"publishwall": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@wall-ants://home/phil/apxtowns/wall-ants/tribes/$space/..",
|
||||||
"publishhouse": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@house-ants://home/phil/apxtowns/house-ants/tribes/$space/..",
|
"publishhouse": "scp -r /media/phil/usbfarm/apxtowns/dev-ants/tribes/$space phil@house-ants://home/phil/apxtowns/house-ants/tribes/$space/..",
|
||||||
"src:css": "node apxtri/models/Wwws.js $tribe $webapp src && tailwindcss --watch -c ../$tribe/objects/wwws/$webapp/tailwind.config.js -i ../$tribe/objects/wwws/$webapp/src/static/css/twdevstyle.css -o ../$tribe/objects/wwws/$webapp/src/static/css/twstyle.css",
|
"src:css": "tailwindcss --watch -c ../$tribe/objects/wwws/$webapp/tailwind.config.js -i ../$tribe/objects/wwws/$webapp/src/static/css/twdevstyle.css -o ../$tribe/objects/wwws/$webapp/src/static/css/twstyle.css",
|
||||||
"dist:css": "node apxtri/models/Wwws.js $tribe $webapp dist && tailwindcss --minify -c ../$tribe/objects/wwws/$webapp/tailwind.config.js -i ../$tribe/objects/wwws/$webapp/src/static/css/twdevstyle.css -o ../$tribe/objects/wwws/$webapp/dist/static/css/twstyle.css"
|
"dist:css": "node apxtri/models/Wwws.js $tribe $webapp dist && tailwindcss --minify -c ../$tribe/objects/wwws/$webapp/tailwind.config.js -i ../$tribe/objects/wwws/$webapp/src/static/css/twdevstyle.css -o ../$tribe/objects/wwws/$webapp/dist/static/css/twstyle.css"
|
||||||
},
|
},
|
||||||
"commentscript": "cf wiki apxtri doc for details: yarn startpm2 -n teswallants, yarn pm2 stop testwallants, yarn pm2 delete testwallants, yarn pm2 logs --lines 200 testwall, yarn pm2 monit -n testwallants, yarn pm2 save tribe=tribeid yarn apidoc to build apidoc // space=adminapi/www/cdn/apidoc yarn publishtestwall ",
|
"commentscript": "cf wiki apxtri doc for details: yarn startpm2 -n teswallants, yarn pm2 stop testwallants, yarn pm2 delete testwallants, yarn pm2 logs --lines 200 testwall, yarn pm2 monit -n testwallants, yarn pm2 save tribe=tribeid yarn apidoc to build apidoc // space=adminapi/www/cdn/apidoc yarn publishtestwall ",
|
||||||
@ -78,11 +78,10 @@
|
|||||||
"sharp": "^0.33.5",
|
"sharp": "^0.33.5",
|
||||||
"smtp-client": "^0.4.0",
|
"smtp-client": "^0.4.0",
|
||||||
"stripe": "^17.3.1",
|
"stripe": "^17.3.1",
|
||||||
"uuid": "^11.0.2"
|
"uuid": "^11.0.2",
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@tailwindcss/typography": "^0.5.15",
|
"@tailwindcss/typography": "^0.5.15",
|
||||||
"daisyui": "^4.12.23",
|
"daisyui": "^4.12.23",
|
||||||
"tailwindcss": "^3.4.17"
|
"tailwindcss": "^3.4.17"
|
||||||
}
|
},
|
||||||
|
"devDependencies": {}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user