cyberia 3.0.3 → 3.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/{.env.production → .env.example} +20 -4
  2. package/.github/workflows/engine-cyberia.cd.yml +43 -10
  3. package/.github/workflows/engine-cyberia.ci.yml +48 -26
  4. package/.github/workflows/ghpkg.ci.yml +5 -5
  5. package/.github/workflows/gitlab.ci.yml +1 -1
  6. package/.github/workflows/hardhat.ci.yml +82 -0
  7. package/.github/workflows/npmpkg.ci.yml +60 -14
  8. package/.github/workflows/publish.ci.yml +26 -7
  9. package/.github/workflows/publish.cyberia.ci.yml +5 -5
  10. package/.github/workflows/pwa-microservices-template-page.cd.yml +6 -7
  11. package/.github/workflows/pwa-microservices-template-test.ci.yml +4 -4
  12. package/.github/workflows/release.cd.yml +14 -8
  13. package/.vscode/extensions.json +9 -8
  14. package/.vscode/settings.json +3 -2
  15. package/CHANGELOG.md +643 -1
  16. package/CLI-HELP.md +132 -57
  17. package/Dockerfile +4 -2
  18. package/README.md +347 -22
  19. package/WHITE-PAPER.md +1540 -0
  20. package/bin/build.js +21 -12
  21. package/bin/cyberia.js +2640 -106
  22. package/bin/deploy.js +258 -372
  23. package/bin/file.js +5 -1
  24. package/bin/index.js +2640 -106
  25. package/bin/vs.js +3 -3
  26. package/conf.js +169 -105
  27. package/deployment.yaml +236 -20
  28. package/hardhat/.env.example +31 -0
  29. package/hardhat/README.md +531 -0
  30. package/hardhat/WHITE-PAPER.md +1540 -0
  31. package/hardhat/contracts/ObjectLayerToken.sol +391 -0
  32. package/hardhat/deployments/.gitkeep +0 -0
  33. package/hardhat/deployments/hardhat-ObjectLayerToken.json +11 -0
  34. package/hardhat/hardhat.config.js +136 -0
  35. package/hardhat/ignition/modules/ObjectLayerToken.js +21 -0
  36. package/hardhat/networks/besu-object-layer.network.json +138 -0
  37. package/hardhat/package-lock.json +4323 -0
  38. package/hardhat/package.json +36 -0
  39. package/hardhat/scripts/deployObjectLayerToken.js +98 -0
  40. package/hardhat/test/ObjectLayerToken.js +592 -0
  41. package/hardhat/types/ethers-contracts/ObjectLayerToken.ts +690 -0
  42. package/hardhat/types/ethers-contracts/common.ts +92 -0
  43. package/hardhat/types/ethers-contracts/factories/ObjectLayerToken__factory.ts +1055 -0
  44. package/hardhat/types/ethers-contracts/factories/index.ts +4 -0
  45. package/hardhat/types/ethers-contracts/hardhat.d.ts +47 -0
  46. package/hardhat/types/ethers-contracts/index.ts +6 -0
  47. package/jsdoc.dd-cyberia.json +68 -0
  48. package/jsdoc.json +65 -49
  49. package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +5 -4
  50. package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +5 -4
  51. package/manifests/deployment/dd-cyberia-development/deployment.yaml +562 -0
  52. package/manifests/deployment/dd-cyberia-development/proxy.yaml +297 -0
  53. package/manifests/deployment/dd-cyberia-development/pv-pvc.yaml +132 -0
  54. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  55. package/manifests/deployment/dd-test-development/deployment.yaml +88 -74
  56. package/manifests/deployment/dd-test-development/proxy.yaml +13 -4
  57. package/manifests/deployment/playwright/deployment.yaml +1 -1
  58. package/manifests/pv-pvc-dd.yaml +1 -1
  59. package/nodemon.json +1 -1
  60. package/package.json +60 -48
  61. package/proxy.yaml +118 -10
  62. package/pv-pvc.yaml +132 -0
  63. package/scripts/k3s-node-setup.sh +1 -1
  64. package/scripts/ports-ls.sh +2 -0
  65. package/scripts/rhel-grpc-setup.sh +56 -0
  66. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.controller.js +47 -1
  67. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.model.js +17 -2
  68. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.router.js +5 -0
  69. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.service.js +80 -7
  70. package/src/api/cyberia-dialogue/cyberia-dialogue.controller.js +93 -0
  71. package/src/api/cyberia-dialogue/cyberia-dialogue.model.js +36 -0
  72. package/src/api/cyberia-dialogue/cyberia-dialogue.router.js +29 -0
  73. package/src/api/cyberia-dialogue/cyberia-dialogue.service.js +51 -0
  74. package/src/api/cyberia-entity/cyberia-entity.controller.js +74 -0
  75. package/src/api/cyberia-entity/cyberia-entity.model.js +24 -0
  76. package/src/api/cyberia-entity/cyberia-entity.router.js +27 -0
  77. package/src/api/cyberia-entity/cyberia-entity.service.js +42 -0
  78. package/src/api/cyberia-instance/cyberia-fallback-world.js +368 -0
  79. package/src/api/cyberia-instance/cyberia-instance.controller.js +92 -0
  80. package/src/api/cyberia-instance/cyberia-instance.model.js +84 -0
  81. package/src/api/cyberia-instance/cyberia-instance.router.js +63 -0
  82. package/src/api/cyberia-instance/cyberia-instance.service.js +191 -0
  83. package/src/api/cyberia-instance/cyberia-portal-connector.js +486 -0
  84. package/src/api/cyberia-instance-conf/cyberia-instance-conf.controller.js +74 -0
  85. package/src/api/cyberia-instance-conf/cyberia-instance-conf.defaults.js +413 -0
  86. package/src/api/cyberia-instance-conf/cyberia-instance-conf.model.js +228 -0
  87. package/src/api/cyberia-instance-conf/cyberia-instance-conf.router.js +27 -0
  88. package/src/api/cyberia-instance-conf/cyberia-instance-conf.service.js +42 -0
  89. package/src/api/cyberia-map/cyberia-map.controller.js +79 -0
  90. package/src/api/cyberia-map/cyberia-map.model.js +30 -0
  91. package/src/api/cyberia-map/cyberia-map.router.js +40 -0
  92. package/src/api/cyberia-map/cyberia-map.service.js +74 -0
  93. package/src/api/document/document.service.js +1 -1
  94. package/src/api/file/file.controller.js +3 -1
  95. package/src/api/file/file.ref.json +18 -0
  96. package/src/api/file/file.service.js +28 -5
  97. package/src/api/ipfs/ipfs.controller.js +4 -25
  98. package/src/api/ipfs/ipfs.model.js +43 -34
  99. package/src/api/ipfs/ipfs.router.js +8 -13
  100. package/src/api/ipfs/ipfs.service.js +56 -104
  101. package/src/api/object-layer/README.md +347 -22
  102. package/src/api/object-layer/object-layer.controller.js +6 -2
  103. package/src/api/object-layer/object-layer.model.js +12 -8
  104. package/src/api/object-layer/object-layer.router.js +698 -42
  105. package/src/api/object-layer/object-layer.service.js +119 -37
  106. package/src/api/object-layer-render-frames/object-layer-render-frames.model.js +1 -2
  107. package/src/api/user/user.router.js +10 -5
  108. package/src/api/user/user.service.js +15 -14
  109. package/src/cli/baremetal.js +6 -10
  110. package/src/cli/cloud-init.js +0 -3
  111. package/src/cli/cluster.js +7 -7
  112. package/src/cli/db.js +723 -857
  113. package/src/cli/deploy.js +215 -105
  114. package/src/cli/env.js +34 -5
  115. package/src/cli/fs.js +5 -4
  116. package/src/cli/image.js +0 -3
  117. package/src/cli/index.js +83 -15
  118. package/src/cli/kubectl.js +211 -0
  119. package/src/cli/monitor.js +5 -6
  120. package/src/cli/release.js +284 -0
  121. package/src/cli/repository.js +708 -62
  122. package/src/cli/run.js +371 -151
  123. package/src/cli/secrets.js +73 -2
  124. package/src/cli/ssh.js +1 -1
  125. package/src/cli/test.js +3 -3
  126. package/src/client/Cryptokoyn.index.js +3 -4
  127. package/src/client/CyberiaPortal.index.js +3 -4
  128. package/src/client/Default.index.js +3 -4
  129. package/src/client/Itemledger.index.js +4 -963
  130. package/src/client/Underpost.index.js +3 -4
  131. package/src/client/components/core/AgGrid.js +20 -5
  132. package/src/client/components/core/Alert.js +2 -2
  133. package/src/client/components/core/AppStore.js +69 -0
  134. package/src/client/components/core/CalendarCore.js +2 -2
  135. package/src/client/components/core/Content.js +22 -3
  136. package/src/client/components/core/Docs.js +30 -6
  137. package/src/client/components/core/DropDown.js +137 -17
  138. package/src/client/components/core/FileExplorer.js +71 -4
  139. package/src/client/components/core/Input.js +1 -1
  140. package/src/client/components/core/Keyboard.js +2 -2
  141. package/src/client/components/core/LogIn.js +2 -2
  142. package/src/client/components/core/LogOut.js +2 -2
  143. package/src/client/components/core/Modal.js +20 -7
  144. package/src/client/components/core/Panel.js +0 -1
  145. package/src/client/components/core/PanelForm.js +19 -19
  146. package/src/client/components/core/RichText.js +1 -2
  147. package/src/client/components/core/SocketIo.js +82 -29
  148. package/src/client/components/core/SocketIoHandler.js +75 -0
  149. package/src/client/components/core/Stream.js +143 -95
  150. package/src/client/components/core/Webhook.js +40 -7
  151. package/src/client/components/cryptokoyn/AppStoreCryptokoyn.js +5 -0
  152. package/src/client/components/cryptokoyn/LogInCryptokoyn.js +3 -3
  153. package/src/client/components/cryptokoyn/LogOutCryptokoyn.js +2 -2
  154. package/src/client/components/cryptokoyn/MenuCryptokoyn.js +3 -3
  155. package/src/client/components/cryptokoyn/SocketIoCryptokoyn.js +3 -51
  156. package/src/client/components/cyberia/InstanceEngineCyberia.js +700 -0
  157. package/src/client/components/cyberia/MapEngineCyberia.js +1359 -2
  158. package/src/client/components/cyberia/ObjectLayerEngineModal.js +17 -6
  159. package/src/client/components/cyberia/ObjectLayerEngineViewer.js +92 -54
  160. package/src/client/components/cyberia-portal/AppStoreCyberiaPortal.js +5 -0
  161. package/src/client/components/cyberia-portal/CommonCyberiaPortal.js +217 -30
  162. package/src/client/components/cyberia-portal/CssCyberiaPortal.js +44 -2
  163. package/src/client/components/cyberia-portal/LogInCyberiaPortal.js +3 -4
  164. package/src/client/components/cyberia-portal/LogOutCyberiaPortal.js +2 -2
  165. package/src/client/components/cyberia-portal/MenuCyberiaPortal.js +104 -9
  166. package/src/client/components/cyberia-portal/RoutesCyberiaPortal.js +5 -0
  167. package/src/client/components/cyberia-portal/SocketIoCyberiaPortal.js +3 -49
  168. package/src/client/components/cyberia-portal/TranslateCyberiaPortal.js +4 -0
  169. package/src/client/components/default/AppStoreDefault.js +5 -0
  170. package/src/client/components/default/LogInDefault.js +3 -3
  171. package/src/client/components/default/LogOutDefault.js +2 -2
  172. package/src/client/components/default/MenuDefault.js +5 -5
  173. package/src/client/components/default/SocketIoDefault.js +3 -51
  174. package/src/client/components/itemledger/AppStoreItemledger.js +5 -0
  175. package/src/client/components/itemledger/LogInItemledger.js +3 -3
  176. package/src/client/components/itemledger/LogOutItemledger.js +2 -2
  177. package/src/client/components/itemledger/MenuItemledger.js +3 -3
  178. package/src/client/components/itemledger/SocketIoItemledger.js +3 -51
  179. package/src/client/components/underpost/AppStoreUnderpost.js +5 -0
  180. package/src/client/components/underpost/CssUnderpost.js +59 -0
  181. package/src/client/components/underpost/LogInUnderpost.js +6 -3
  182. package/src/client/components/underpost/LogOutUnderpost.js +4 -2
  183. package/src/client/components/underpost/MenuUnderpost.js +104 -18
  184. package/src/client/components/underpost/RoutesUnderpost.js +2 -0
  185. package/src/client/components/underpost/SocketIoUnderpost.js +3 -51
  186. package/src/client/public/cryptokoyn/assets/logo/base-icon.png +0 -0
  187. package/src/client/public/cryptokoyn/browserconfig.xml +12 -0
  188. package/src/client/public/cryptokoyn/microdata.json +85 -0
  189. package/src/client/public/cryptokoyn/site.webmanifest +57 -0
  190. package/src/client/public/cryptokoyn/sitemap +3 -3
  191. package/src/client/public/default/sitemap +3 -3
  192. package/src/client/public/itemledger/browserconfig.xml +2 -2
  193. package/src/client/public/itemledger/manifest.webmanifest +4 -4
  194. package/src/client/public/itemledger/microdata.json +71 -0
  195. package/src/client/public/itemledger/sitemap +3 -3
  196. package/src/client/public/itemledger/yandex-browser-manifest.json +2 -2
  197. package/src/client/public/test/sitemap +3 -3
  198. package/src/client/services/core/core.service.js +20 -8
  199. package/src/client/services/cyberia-dialogue/cyberia-dialogue.service.js +105 -0
  200. package/src/client/services/cyberia-entity/cyberia-entity.management.js +57 -0
  201. package/src/client/services/cyberia-entity/cyberia-entity.service.js +105 -0
  202. package/src/client/services/cyberia-instance/cyberia-instance.management.js +194 -0
  203. package/src/client/services/cyberia-instance/cyberia-instance.service.js +122 -0
  204. package/src/client/services/cyberia-instance-conf/cyberia-instance-conf.service.js +105 -0
  205. package/src/client/services/cyberia-map/cyberia-map.management.js +193 -0
  206. package/src/client/services/cyberia-map/cyberia-map.service.js +126 -0
  207. package/src/client/services/instance/instance.management.js +2 -2
  208. package/src/client/services/ipfs/ipfs.service.js +3 -23
  209. package/src/client/services/object-layer/object-layer.management.js +3 -3
  210. package/src/client/services/object-layer/object-layer.service.js +21 -0
  211. package/src/client/services/user/user.management.js +2 -2
  212. package/src/client/ssr/body/404.js +15 -11
  213. package/src/client/ssr/body/500.js +15 -11
  214. package/src/client/ssr/body/SwaggerDarkMode.js +285 -0
  215. package/src/client/ssr/head/PwaItemledger.js +60 -0
  216. package/src/client/ssr/offline/NoNetworkConnection.js +11 -10
  217. package/src/client/ssr/pages/CyberiaServerMetrics.js +1 -1
  218. package/src/client/ssr/pages/Test.js +11 -10
  219. package/src/client.build.js +0 -3
  220. package/src/client.dev.js +0 -3
  221. package/src/db/DataBaseProvider.js +17 -2
  222. package/src/db/mariadb/MariaDB.js +14 -9
  223. package/src/db/mongo/MongooseDB.js +17 -1
  224. package/src/grpc/cyberia/OFF_CHAIN_ECONOMY.md +305 -0
  225. package/src/grpc/cyberia/README.md +326 -0
  226. package/src/grpc/cyberia/grpc-server.js +530 -0
  227. package/src/index.js +24 -1
  228. package/src/proxy.js +0 -3
  229. package/src/runtime/express/Dockerfile +4 -0
  230. package/src/runtime/express/Express.js +33 -10
  231. package/src/runtime/lampp/Dockerfile +13 -2
  232. package/src/runtime/lampp/Lampp.js +33 -17
  233. package/src/runtime/wp/Dockerfile +68 -0
  234. package/src/runtime/wp/Wp.js +639 -0
  235. package/src/server/auth.js +36 -15
  236. package/src/server/backup.js +39 -12
  237. package/src/server/besu-genesis-generator.js +1630 -0
  238. package/src/server/client-build-docs.js +133 -17
  239. package/src/server/client-build-live.js +9 -18
  240. package/src/server/client-build.js +229 -101
  241. package/src/server/client-dev-server.js +14 -13
  242. package/src/server/client-formatted.js +109 -57
  243. package/src/server/conf.js +391 -164
  244. package/src/server/cron.js +27 -24
  245. package/src/server/dns.js +29 -12
  246. package/src/server/downloader.js +0 -2
  247. package/src/server/ipfs-client.js +24 -1
  248. package/src/server/logger.js +27 -9
  249. package/src/server/object-layer.js +217 -103
  250. package/src/server/peer.js +8 -2
  251. package/src/server/process.js +1 -50
  252. package/src/server/proxy.js +4 -8
  253. package/src/server/runtime.js +30 -9
  254. package/src/server/semantic-layer-generator-floor.js +359 -0
  255. package/src/server/semantic-layer-generator-skin.js +1294 -0
  256. package/src/server/semantic-layer-generator.js +116 -555
  257. package/src/server/ssr.js +0 -3
  258. package/src/server/start.js +19 -12
  259. package/src/server/tls.js +0 -2
  260. package/src/server.js +0 -4
  261. package/src/ws/IoInterface.js +1 -10
  262. package/src/ws/IoServer.js +14 -33
  263. package/src/ws/core/channels/core.ws.chat.js +65 -20
  264. package/src/ws/core/channels/core.ws.mailer.js +113 -32
  265. package/src/ws/core/channels/core.ws.stream.js +90 -31
  266. package/src/ws/core/core.ws.connection.js +12 -33
  267. package/src/ws/core/core.ws.emit.js +10 -26
  268. package/src/ws/core/core.ws.server.js +25 -58
  269. package/src/ws/default/channels/default.ws.main.js +53 -12
  270. package/src/ws/default/default.ws.connection.js +26 -13
  271. package/src/ws/default/default.ws.server.js +30 -12
  272. package/.env.development +0 -43
  273. package/.env.test +0 -43
  274. package/hardhat/contracts/CryptoKoyn.sol +0 -59
  275. package/hardhat/contracts/ItemLedger.sol +0 -73
  276. package/hardhat/contracts/Lock.sol +0 -34
  277. package/hardhat/hardhat.config.cjs +0 -45
  278. package/hardhat/ignition/modules/Lock.js +0 -18
  279. package/hardhat/networks/cryptokoyn-itemledger.network.json +0 -29
  280. package/hardhat/scripts/deployCryptokoyn.cjs +0 -25
  281. package/hardhat/scripts/deployItemledger.cjs +0 -25
  282. package/hardhat/test/Lock.js +0 -126
  283. package/hardhat/white-paper.md +0 -581
  284. package/src/client/components/cryptokoyn/CommonCryptokoyn.js +0 -29
  285. package/src/client/components/cryptokoyn/ElementsCryptokoyn.js +0 -38
  286. package/src/client/components/cyberia-portal/ElementsCyberiaPortal.js +0 -38
  287. package/src/client/components/default/ElementsDefault.js +0 -38
  288. package/src/client/components/itemledger/CommonItemledger.js +0 -29
  289. package/src/client/components/itemledger/ElementsItemledger.js +0 -38
  290. package/src/client/components/underpost/CommonUnderpost.js +0 -29
  291. package/src/client/components/underpost/ElementsUnderpost.js +0 -38
  292. package/src/ws/core/management/core.ws.chat.js +0 -8
  293. package/src/ws/core/management/core.ws.mailer.js +0 -16
  294. package/src/ws/core/management/core.ws.stream.js +0 -8
  295. package/src/ws/default/management/default.ws.main.js +0 -8
  296. package/white-paper.md +0 -581
@@ -7,7 +7,7 @@
7
7
  'use strict';
8
8
 
9
9
  import fs from 'fs-extra';
10
- import { srcFormatted, componentFormatted, viewFormatted, JSONweb } from './client-formatted.js';
10
+ import { transformClientJs, JSONweb } from './client-formatted.js';
11
11
  import { loggerFactory } from './logger.js';
12
12
  import {
13
13
  getCapVariableName,
@@ -15,9 +15,8 @@ import {
15
15
  orderArrayFromAttrInt,
16
16
  uniqueArray,
17
17
  } from '../client/components/core/CommonJs.js';
18
- import UglifyJS from 'uglify-js';
18
+ import { readConfJson } from './conf.js';
19
19
  import { minify } from 'html-minifier-terser';
20
- import dotenv from 'dotenv';
21
20
  import AdmZip from 'adm-zip';
22
21
  import * as dir from 'path';
23
22
  import { shellExec } from './process.js';
@@ -28,8 +27,6 @@ import Underpost from '../index.js';
28
27
  import { buildDocs } from './client-build-docs.js';
29
28
  import { ssrFactory } from './ssr.js';
30
29
 
31
- dotenv.config();
32
-
33
30
  // Static Site Generation (SSG)
34
31
 
35
32
  /**
@@ -77,23 +74,186 @@ const copyNonExistingFiles = (src, dest) => {
77
74
  }
78
75
  };
79
76
 
77
+ /** @type {string} Default XSL sitemap template used when no `sitemap` source file exists in the public directory. */
78
+ const defaultSitemapXsl = `<?xml version="1.0" encoding="UTF-8"?>
79
+ <xsl:stylesheet version="1.0"
80
+ xmlns:html="http://www.w3.org/TR/REC-html40"
81
+ xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
82
+ xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
83
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
84
+ <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
85
+ <xsl:template match="/">
86
+ <html xmlns="http://www.w3.org/1999/xhtml">
87
+ <head>
88
+ <title>XML Sitemap</title>
89
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
90
+ <style type="text/css">
91
+ body {
92
+ font-family: sans-serif;
93
+ font-size: 16px;
94
+ color: #242628;
95
+ }
96
+ a {
97
+ color: #000;
98
+ text-decoration: none;
99
+ }
100
+ a:hover {
101
+ text-decoration: underline;
102
+ }
103
+ table {
104
+ border: none;
105
+ border-collapse: collapse;
106
+ width: 100%
107
+ }
108
+ th {
109
+ text-align: left;
110
+ padding-right: 30px;
111
+ font-size: 11px;
112
+ }
113
+ thead th {
114
+ border-bottom: 1px solid #7d878a;
115
+ cursor: pointer;
116
+ }
117
+ td {
118
+ font-size:11px;
119
+ padding: 5px;
120
+ }
121
+ tr:nth-child(odd) td {
122
+ background-color: rgba(0,0,0,0.04);
123
+ }
124
+ tr:hover td {
125
+ background-color: #e2edf2;
126
+ }
127
+
128
+ #content {
129
+ margin: 0 auto;
130
+ padding: 2% 5%;
131
+ max-width: 800px;
132
+ }
133
+
134
+ .desc {
135
+ margin: 18px 3px;
136
+ line-height: 1.2em;
137
+ }
138
+ .desc a {
139
+ color: #5ba4e5;
140
+ }
141
+ </style>
142
+ </head>
143
+ <body>
144
+ <div id="content">
145
+ <h1>XML Sitemap</h1>
146
+ <p class="desc"> This is a sitemap generated by <a
147
+ href="{{web-url}}">{{web-url}}</a>
148
+ </p>
149
+ <xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) &gt; 0">
150
+ <table id="sitemap" cellpadding="3">
151
+ <thead>
152
+ <tr>
153
+ <th width="75%">Sitemap</th>
154
+ <th width="25%">Last Modified</th>
155
+ </tr>
156
+ </thead>
157
+ <tbody>
158
+ <xsl:for-each select="sitemap:sitemapindex/sitemap:sitemap">
159
+ <xsl:variable name="sitemapURL">
160
+ <xsl:value-of select="sitemap:loc" />
161
+ </xsl:variable>
162
+ <tr>
163
+ <td>
164
+ <a href="{$sitemapURL}">
165
+ <xsl:value-of select="sitemap:loc" />
166
+ </a>
167
+ </td>
168
+ <td>
169
+ <xsl:value-of
170
+ select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))" />
171
+ </td>
172
+ </tr>
173
+ </xsl:for-each>
174
+ </tbody>
175
+ </table>
176
+ </xsl:if>
177
+ <xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) &lt; 1">
178
+ <p class="desc">
179
+ <a href="{{web-url}}sitemap.xml" class="back-link">&#8592; Back to index</a>
180
+ </p>
181
+ <table
182
+ id="sitemap" cellpadding="3">
183
+ <thead>
184
+ <tr>
185
+ <th width="70%">URL (<xsl:value-of
186
+ select="count(sitemap:urlset/sitemap:url)" /> total)</th>
187
+ <th width="15%">Images</th>
188
+ <th title="Last Modification Time" width="15%">Last Modified</th>
189
+ </tr>
190
+ </thead>
191
+ <tbody>
192
+ <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'" />
193
+ <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
194
+ <xsl:for-each select="sitemap:urlset/sitemap:url">
195
+ <tr>
196
+ <td>
197
+ <xsl:variable name="itemURL">
198
+ <xsl:value-of select="sitemap:loc" />
199
+ </xsl:variable>
200
+ <a href="{$itemURL}">
201
+ <xsl:value-of select="sitemap:loc" />
202
+ </a>
203
+ </td>
204
+ <td>
205
+ <xsl:value-of select="count(image:image)" />
206
+ </td>
207
+ <td>
208
+ <xsl:value-of
209
+ select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))" />
210
+ </td>
211
+ </tr>
212
+ </xsl:for-each>
213
+ </tbody>
214
+ </table>
215
+ <p
216
+ class="desc">
217
+ <a href="{{web-url}}sitemap.xml" class="back-link">&#8592; Back to index</a>
218
+ </p>
219
+ </xsl:if>
220
+ </div>
221
+ </body>
222
+ </html>
223
+
224
+ </xsl:template>
225
+ </xsl:stylesheet>`;
226
+
80
227
  /**
81
228
  * @async
82
229
  * @function buildClient
83
230
  * @memberof clientBuild
84
231
  * @param {Object} options - Options for the build process.
232
+ * @param {string} options.deployId - The deployment ID for which to build the client.
85
233
  * @param {Array} options.liveClientBuildPaths - List of paths to build incrementally.
86
234
  * @param {Array} options.instances - List of instances to build.
87
235
  * @param {boolean} options.buildZip - Whether to create zip files of the builds.
236
+ * @param {boolean} options.fullBuild - Whether to perform a full build.
237
+ * @param {boolean} options.iconsBuild - Whether to build icons.
88
238
  * @returns {Promise<void>} - Promise that resolves when the build is complete.
89
239
  * @throws {Error} - If the build fails.
90
240
  * @memberof clientBuild
91
241
  */
92
- const buildClient = async (options = { liveClientBuildPaths: [], instances: [], buildZip: false }) => {
242
+ const buildClient = async (
243
+ options = {
244
+ deployId: '',
245
+ liveClientBuildPaths: [],
246
+ instances: [],
247
+ buildZip: false,
248
+ fullBuild: false,
249
+ iconsBuild: false,
250
+ },
251
+ ) => {
93
252
  const logger = loggerFactory(import.meta);
94
- const confClient = JSON.parse(fs.readFileSync(`./conf/conf.client.json`, 'utf8'));
95
- const confServer = JSON.parse(fs.readFileSync(`./conf/conf.server.json`, 'utf8'));
96
- const confSSR = JSON.parse(fs.readFileSync(`./conf/conf.ssr.json`, 'utf8'));
253
+ const deployId = options.deployId || process.env.DEPLOY_ID;
254
+ const confClient = readConfJson(deployId, 'client');
255
+ const confServer = readConfJson(deployId, 'server', { loadReplicas: true });
256
+ const confSSR = readConfJson(deployId, 'ssr');
97
257
  const packageData = JSON.parse(fs.readFileSync(`./package.json`, 'utf8'));
98
258
  const acmeChallengePath = `/.well-known/acme-challenge`;
99
259
  const publicPath = `./public`;
@@ -156,7 +316,8 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [],
156
316
  shellExec(`cd /home/dd && git clone https://github.com/designmodo/html-website-templates.git`);
157
317
  if (!fs.existsSync(`${rootClientPath}/index.php`)) {
158
318
  fs.copySync(`/home/dd/html-website-templates/${publicClientId.split('-publicClientId-')[1]}`, rootClientPath);
159
- shellExec(`cd ${rootClientPath} && git init && git add . && git commit -m "Base template implementation"`);
319
+ Underpost.repo.initLocalRepo({ path: rootClientPath });
320
+ shellExec(`cd ${rootClientPath} && git add . && git commit -m "Base template implementation"`);
160
321
  // git remote add origin git@github.com:<username>/<repo>.git
161
322
  fs.writeFileSync(`${rootClientPath}/.git/.htaccess`, `Deny from all`, 'utf8');
162
323
  }
@@ -178,26 +339,7 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [],
178
339
  } */,
179
340
  );
180
341
  } else if (fs.existsSync(`./engine-private/src/client/public/${publicClientId}`)) {
181
- switch (publicClientId) {
182
- case 'mysql_test':
183
- if (db) {
184
- fs.copySync(`./engine-private/src/client/public/${publicClientId}`, rootClientPath);
185
- fs.writeFileSync(
186
- `${rootClientPath}/index.php`,
187
- fs
188
- .readFileSync(`${rootClientPath}/index.php`, 'utf8')
189
- .replace('test_servername', 'localhost')
190
- .replace('test_username', db.user)
191
- .replace('test_password', db.password)
192
- .replace('test_dbname', db.name),
193
- 'utf8',
194
- );
195
- } else logger.error('not provided db config');
196
- break;
197
-
198
- default:
199
- break;
200
- }
342
+ fs.copySync(`./engine-private/src/client/public/${publicClientId}`, rootClientPath);
201
343
  }
202
344
  if (dists)
203
345
  for (const dist of dists) {
@@ -243,17 +385,14 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [],
243
385
  client,
244
386
  directory,
245
387
  disabledRebuild,
246
- minifyBuild,
247
388
  db,
248
389
  redirect,
249
390
  apis,
250
- iconsBuild,
251
- docsBuild,
252
391
  apiBaseProxyPath,
253
392
  apiBaseHost,
254
393
  ttiLoadTimeLimit,
255
394
  singleReplica,
256
- offlineBuild,
395
+ docs,
257
396
  } = confServer[host][path];
258
397
  if (singleReplica) continue;
259
398
  if (!confClient[client]) confClient[client] = {};
@@ -267,9 +406,10 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [],
267
406
  const rootClientPath = directory ? directory : `${publicPath}/${host}${path}`;
268
407
  const port = newInstance(currentPort);
269
408
  const publicClientId = publicRef ? publicRef : client;
270
- const fullBuildEnabled = !confServer[host][path].liteBuild && !enableLiveRebuild;
409
+ const fullBuildEnabled = options.fullBuild && !enableLiveRebuild;
271
410
  // const baseHost = process.env.NODE_ENV === 'production' ? `https://${host}` : `http://localhost:${port}`;
272
411
  const baseHost = process.env.NODE_ENV === 'production' ? `https://${host}` : ``;
412
+ const minifyBuild = process.env.NODE_ENV === 'production';
273
413
  // ''; // process.env.NODE_ENV === 'production' ? `https://${host}` : ``;
274
414
  currentPort++;
275
415
 
@@ -291,7 +431,7 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [],
291
431
  rootClientPath,
292
432
  acmeChallengeFullPath,
293
433
  publicClientId,
294
- iconsBuild,
434
+ iconsBuild: options.iconsBuild,
295
435
  metadata,
296
436
  publicCopyNonExistingFiles,
297
437
  });
@@ -307,19 +447,15 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [],
307
447
 
308
448
  if (enableLiveRebuild && !options.liveClientBuildPaths.find((p) => p.srcBuildPath === jsSrcPath)) continue;
309
449
 
310
- const jsSrc = componentFormatted(
311
- await srcFormatted(fs.readFileSync(jsSrcPath, 'utf8')),
312
- module,
450
+ const jsSrc = await transformClientJs(jsSrcPath, {
313
451
  dists,
314
- path,
315
- 'components',
452
+ proxyPath: path,
453
+ basePath: 'components',
454
+ module,
316
455
  baseHost,
317
- );
318
- fs.writeFileSync(
319
- jsPublicPath,
320
- minifyBuild || process.env.NODE_ENV === 'production' ? UglifyJS.minify(jsSrc).code : jsSrc,
321
- 'utf8',
322
- );
456
+ minify: minifyBuild,
457
+ });
458
+ fs.writeFileSync(jsPublicPath, jsSrc, 'utf8');
323
459
  }
324
460
  }
325
461
 
@@ -333,19 +469,15 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [],
333
469
  const jsPublicPath = `${rootClientPath}/services/${module}/${module}.service.js`;
334
470
  if (enableLiveRebuild && !options.liveClientBuildPaths.find((p) => p.srcBuildPath === jsSrcPath)) continue;
335
471
 
336
- let jsSrc = componentFormatted(
337
- await srcFormatted(fs.readFileSync(jsSrcPath, 'utf8')),
338
- module,
472
+ const jsSrc = await transformClientJs(jsSrcPath, {
339
473
  dists,
340
- path,
341
- 'services',
474
+ proxyPath: path,
475
+ basePath: 'services',
476
+ module,
342
477
  baseHost,
343
- );
344
- fs.writeFileSync(
345
- jsPublicPath,
346
- minifyBuild || process.env.NODE_ENV === 'production' ? UglifyJS.minify(jsSrc).code : jsSrc,
347
- 'utf8',
348
- );
478
+ minify: minifyBuild,
479
+ });
480
+ fs.writeFileSync(jsPublicPath, jsSrc, 'utf8');
349
481
  }
350
482
  }
351
483
 
@@ -355,19 +487,15 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [],
355
487
  const jsPublicPath = `${rootClientPath}/services/${module}/${module}.management.js`;
356
488
  if (enableLiveRebuild && !options.liveClientBuildPaths.find((p) => p.srcBuildPath === jsSrcPath)) continue;
357
489
 
358
- const jsSrc = componentFormatted(
359
- await srcFormatted(fs.readFileSync(jsSrcPath, 'utf8')),
360
- module,
490
+ const jsSrc = await transformClientJs(jsSrcPath, {
361
491
  dists,
362
- path,
363
- 'services',
492
+ proxyPath: path,
493
+ basePath: 'services',
494
+ module,
364
495
  baseHost,
365
- );
366
- fs.writeFileSync(
367
- jsPublicPath,
368
- minifyBuild || process.env.NODE_ENV === 'production' ? UglifyJS.minify(jsSrc).code : jsSrc,
369
- 'utf8',
370
- );
496
+ minify: minifyBuild,
497
+ });
498
+ fs.writeFileSync(jsPublicPath, jsSrc, 'utf8');
371
499
  }
372
500
  }
373
501
  }
@@ -385,13 +513,9 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [],
385
513
  const jsPublicPath = `${rootClientPath}/sw.js`;
386
514
 
387
515
  if (!(enableLiveRebuild && !options.liveClientBuildPaths.find((p) => p.srcBuildPath === jsSrcPath))) {
388
- const jsSrc = viewFormatted(await srcFormatted(fs.readFileSync(jsSrcPath, 'utf8')), dists, path, baseHost);
516
+ const jsSrc = await transformClientJs(jsSrcPath, { dists, proxyPath: path, baseHost, minify: minifyBuild });
389
517
 
390
- fs.writeFileSync(
391
- jsPublicPath,
392
- minifyBuild || process.env.NODE_ENV === 'production' ? UglifyJS.minify(jsSrc).code : jsSrc,
393
- 'utf8',
394
- );
518
+ fs.writeFileSync(jsPublicPath, jsSrc, 'utf8');
395
519
  }
396
520
 
397
521
  if (
@@ -411,18 +535,14 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [],
411
535
 
412
536
  logger.info('View build', buildPath);
413
537
 
414
- const jsSrc = viewFormatted(
415
- await srcFormatted(fs.readFileSync(`./src/client/${view.client}.index.js`, 'utf8')),
538
+ const jsSrc = await transformClientJs(`./src/client/${view.client}.index.js`, {
416
539
  dists,
417
- path,
540
+ proxyPath: path,
418
541
  baseHost,
419
- );
542
+ minify: minifyBuild,
543
+ });
420
544
 
421
- fs.writeFileSync(
422
- `${buildPath}${buildId}.js`,
423
- minifyBuild || process.env.NODE_ENV === 'production' ? UglifyJS.minify(jsSrc).code : jsSrc,
424
- 'utf8',
425
- );
545
+ fs.writeFileSync(`${buildPath}${buildId}.js`, jsSrc, 'utf8');
426
546
  const title = metadata.title ? metadata.title : title;
427
547
 
428
548
  const canonicalURL = `https://${host}${path}${
@@ -559,7 +679,7 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [],
559
679
 
560
680
  fs.writeFileSync(
561
681
  `${buildPath}index.html`,
562
- minifyBuild || process.env.NODE_ENV === 'production'
682
+ minifyBuild
563
683
  ? await minify(htmlSrc, {
564
684
  minifyCSS: true,
565
685
  minifyJS: true,
@@ -573,36 +693,43 @@ const buildClient = async (options = { liveClientBuildPaths: [], instances: [],
573
693
  }
574
694
  }
575
695
  if (!enableLiveRebuild && siteMapLinks.length > 0) {
576
- const xslUrl = fs.existsSync(`${rootClientPath}/sitemap`)
577
- ? `${path === '/' ? '' : path}/sitemap.xsl`
578
- : undefined;
579
- // Create a stream to write to
696
+ const hasSitemapTemplate = fs.existsSync(`${rootClientPath}/sitemap`);
697
+ const sitemapBaseUrl = `https://${host}${path === '/' ? '' : path}`;
698
+ // Create a stream to write to — omit xslUrl so we can inject a relative href below
580
699
  /** @type {import('sitemap').SitemapStreamOptions} */
581
- const sitemapOptions = { hostname: `https://${host}`, xslUrl };
700
+ const sitemapOptions = { hostname: `https://${host}` };
582
701
 
583
702
  const siteMapStream = new SitemapStream(sitemapOptions);
584
703
  let siteMapSrc = await new Promise((resolve) =>
585
704
  streamToPromise(Readable.from(siteMapLinks).pipe(siteMapStream)).then((data) => resolve(data.toString())),
586
705
  );
587
706
 
707
+ // Inject a relative xml-stylesheet PI so the XSL loads from the same origin
708
+ // (works on both http://localhost:<port> and https://production-host)
709
+ siteMapSrc = siteMapSrc.replace(
710
+ '<?xml version="1.0" encoding="UTF-8"?>',
711
+ '<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>',
712
+ );
713
+
588
714
  // Return a promise that resolves with your XML string
589
715
  fs.writeFileSync(`${rootClientPath}/sitemap.xml`, siteMapSrc, 'utf8');
590
- if (xslUrl)
591
- fs.writeFileSync(
592
- `${rootClientPath}/sitemap.xsl`,
593
- fs.readFileSync(`${rootClientPath}/sitemap`, 'utf8').replaceAll('{{web-url}}', `https://${host}${path}`),
594
- 'utf8',
595
- );
716
+
717
+ // Generate XSL stylesheet from source template or default fallback
718
+ const xslTemplate = hasSitemapTemplate
719
+ ? fs.readFileSync(`${rootClientPath}/sitemap`, 'utf8')
720
+ : defaultSitemapXsl;
721
+ const webUrl = `https://${host}${path === '/' ? '/' : `${path}/`}`;
722
+ fs.writeFileSync(`${rootClientPath}/sitemap.xsl`, xslTemplate.replaceAll('{{web-url}}', webUrl), 'utf8');
596
723
 
597
724
  fs.writeFileSync(
598
725
  `${rootClientPath}/robots.txt`,
599
726
  `User-agent: *
600
- Sitemap: https://${host}${path === '/' ? '' : path}/sitemap.xml`,
727
+ Sitemap: ${sitemapBaseUrl}/sitemap.xml`,
601
728
  'utf8',
602
729
  );
603
730
  }
604
731
 
605
- if (fullBuildEnabled && !enableLiveRebuild && docsBuild) {
732
+ if (fullBuildEnabled && docs) {
606
733
  await buildDocs({
607
734
  host,
608
735
  path,
@@ -612,13 +739,14 @@ Sitemap: https://${host}${path === '/' ? '' : path}/sitemap.xml`,
612
739
  publicClientId,
613
740
  rootClientPath,
614
741
  packageData,
742
+ docs,
615
743
  });
616
744
  }
617
745
 
618
746
  if (client) {
619
747
  let PRE_CACHED_RESOURCES = [];
620
748
 
621
- if (views && offlineBuild && fs.existsSync(`${rootClientPath}/sw.js`)) {
749
+ if (views && fs.existsSync(`${rootClientPath}/sw.js`)) {
622
750
  PRE_CACHED_RESOURCES = await fs.readdir(rootClientPath, { recursive: true });
623
751
  PRE_CACHED_RESOURCES = views
624
752
  .map((view) => `${path === '/' ? '' : path}${view.path}`)
@@ -637,7 +765,7 @@ Sitemap: https://${host}${path === '/' ? '' : path}/sitemap.xml`,
637
765
  const htmlSrc = Render({
638
766
  title: page.title,
639
767
  ssrPath,
640
- ssrHeadComponents: '',
768
+ ssrHeadComponents: '<base target="_top">',
641
769
  ssrBodyComponents: SsrComponent(),
642
770
  renderPayload: {
643
771
  apiBaseProxyPath,
@@ -665,7 +793,7 @@ Sitemap: https://${host}${path === '/' ? '' : path}/sitemap.xml`,
665
793
 
666
794
  fs.writeFileSync(
667
795
  buildHtmlPath,
668
- minifyBuild || process.env.NODE_ENV === 'production'
796
+ minifyBuild
669
797
  ? await minify(htmlSrc, {
670
798
  minifyCSS: true,
671
799
  minifyJS: true,
@@ -5,8 +5,10 @@
5
5
  */
6
6
  import fs from 'fs-extra';
7
7
  import nodemon from 'nodemon';
8
+ import dotenv from 'dotenv';
8
9
  import { shellExec } from './process.js';
9
10
  import { loggerFactory } from './logger.js';
11
+ import Underpost from '../index.js';
10
12
 
11
13
  const logger = loggerFactory(import.meta);
12
14
 
@@ -21,22 +23,20 @@ const logger = loggerFactory(import.meta);
21
23
  * @returns {void}
22
24
  * @memberof clientDevServer
23
25
  */
24
- const createClientDevServer = (
26
+ const createClientDevServer = async (
25
27
  deployId = process.argv[2] || 'dd-default',
26
28
  subConf = process.argv[3] || '',
27
29
  host = process.argv[4] || 'default.net',
28
30
  path = process.argv[5] || '/',
29
31
  ) => {
30
- shellExec(
31
- `env-cmd -f ./engine-private/conf/${deployId}/.env.${process.env.NODE_ENV}.${subConf}-dev-client node bin/deploy build-full-client ${deployId} ${subConf}-dev-client ${host} ${path}`.trim(),
32
- );
32
+ const devClientEnvPath = `./engine-private/conf/${deployId}/.env.${process.env.NODE_ENV}.${subConf}-dev-client`;
33
+ if (fs.existsSync(devClientEnvPath)) dotenv.config({ path: devClientEnvPath, override: true });
33
34
 
34
- shellExec(
35
- `env-cmd -f ./engine-private/conf/${deployId}/.env.${process.env.NODE_ENV}.${subConf}-dev-client node src/server ${deployId} ${subConf}-dev-client`.trim(),
36
- {
37
- async: true,
38
- },
39
- );
35
+ await Underpost.repo.client(deployId, `${subConf}-dev-client`.trim(), host, path);
36
+
37
+ shellExec(`node src/server ${deployId} ${subConf}-dev-client`.trim(), {
38
+ async: true,
39
+ });
40
40
 
41
41
  // https://github.com/remy/nodemon/blob/main/doc/events.md
42
42
 
@@ -47,7 +47,7 @@ const createClientDevServer = (
47
47
  // restart([ array of files triggering the restart ]) - child process has restarted
48
48
  // config:update - nodemon's config has changed
49
49
 
50
- if (fs.existsSync(`./tmp/client.build.json`)) fs.removeSync(`./tmp/client.build.json`);
50
+ if (fs.existsSync(`/tmp/client.build.json`)) fs.removeSync(`/tmp/client.build.json`);
51
51
 
52
52
  let buildPathScope = [];
53
53
 
@@ -77,10 +77,11 @@ const createClientDevServer = (
77
77
  }, 2500);
78
78
  const buildPathScopeBuild = buildPathScope.map((o) => o.path);
79
79
  logger.info('buildPathScopeBuild', buildPathScopeBuild);
80
- fs.writeFileSync(`./tmp/client.build.json`, JSON.stringify(buildPathScopeBuild, null, 4));
80
+ fs.writeFileSync(`/tmp/client.build.json`, JSON.stringify(buildPathScopeBuild, null, 4));
81
81
  })
82
82
  .on('crash', function (error) {
83
- logger.error(error, error.message);
83
+ if (error) logger.error(error, error.message || 'nodemon crash');
84
+ else logger.error('nodemon process crashed');
84
85
  });
85
86
  };
86
87