@griddo/cx 11.7.10 → 11.7.12-rc.0

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 (302) hide show
  1. package/README.md +27 -226
  2. package/build/adapters/gatsby/actions/clean.js +10 -0
  3. package/build/adapters/gatsby/actions/clean.js.map +1 -0
  4. package/build/adapters/gatsby/actions/close.js +14 -0
  5. package/build/adapters/gatsby/actions/close.js.map +1 -0
  6. package/build/adapters/gatsby/actions/data.js +18 -0
  7. package/build/adapters/gatsby/actions/data.js.map +1 -0
  8. package/build/adapters/gatsby/actions/healthCheck.js +10 -0
  9. package/build/adapters/gatsby/actions/healthCheck.js.map +1 -0
  10. package/build/adapters/gatsby/actions/init.js +22 -0
  11. package/build/adapters/gatsby/actions/init.js.map +1 -0
  12. package/build/adapters/gatsby/actions/logs.js +9 -0
  13. package/build/adapters/gatsby/actions/logs.js.map +1 -0
  14. package/build/adapters/gatsby/actions/meta.js +13 -0
  15. package/build/adapters/gatsby/actions/meta.js.map +1 -0
  16. package/build/adapters/gatsby/actions/prepare.js +9 -0
  17. package/build/adapters/gatsby/actions/prepare.js.map +1 -0
  18. package/build/adapters/gatsby/actions/relocation.js +15 -0
  19. package/build/adapters/gatsby/actions/relocation.js.map +1 -0
  20. package/build/adapters/gatsby/actions/restore.js +26 -0
  21. package/build/adapters/gatsby/actions/restore.js.map +1 -0
  22. package/build/adapters/gatsby/actions/ssg.js +9 -0
  23. package/build/adapters/gatsby/actions/ssg.js.map +1 -0
  24. package/build/adapters/gatsby/actions/sync.js +51 -0
  25. package/build/adapters/gatsby/actions/sync.js.map +1 -0
  26. package/build/adapters/gatsby/index.js +78 -0
  27. package/build/adapters/gatsby/index.js.map +1 -0
  28. package/build/adapters/gatsby/shared/artifacts.js +20 -0
  29. package/build/adapters/gatsby/shared/artifacts.js.map +1 -0
  30. package/build/adapters/gatsby/shared/context.js +31 -0
  31. package/build/adapters/gatsby/shared/context.js.map +1 -0
  32. package/build/adapters/gatsby/shared/diff-assets.js +101 -0
  33. package/build/adapters/gatsby/shared/diff-assets.js.map +1 -0
  34. package/build/adapters/gatsby/shared/extract-assets.js +58 -0
  35. package/build/adapters/gatsby/shared/extract-assets.js.map +1 -0
  36. package/build/adapters/gatsby/shared/gatsby-build.js +55 -0
  37. package/build/adapters/gatsby/shared/gatsby-build.js.map +1 -0
  38. package/build/adapters/gatsby/shared/sync-render.js +210 -0
  39. package/build/adapters/gatsby/shared/sync-render.js.map +1 -0
  40. package/build/adapters/gatsby/shared/types.js +3 -0
  41. package/build/adapters/gatsby/shared/types.js.map +1 -0
  42. package/build/commands/end-render.js +87 -0
  43. package/build/commands/end-render.js.map +1 -0
  44. package/build/commands/prepare-assets-directory.js +30 -0
  45. package/build/commands/prepare-assets-directory.js.map +1 -0
  46. package/build/commands/prepare-domains-render.js +133 -0
  47. package/build/commands/prepare-domains-render.js.map +1 -0
  48. package/build/commands/reset-render.js +21 -0
  49. package/build/commands/reset-render.js.map +1 -0
  50. package/build/commands/start-render.js +44 -0
  51. package/build/commands/start-render.js.map +1 -0
  52. package/build/commands/upload-search-content.js +180 -0
  53. package/build/commands/upload-search-content.js.map +1 -0
  54. package/build/constants/endpoints.js +43 -0
  55. package/build/constants/endpoints.js.map +1 -0
  56. package/build/constants/envs.js +68 -0
  57. package/build/constants/envs.js.map +1 -0
  58. package/build/constants/errors.js +81 -0
  59. package/build/constants/errors.js.map +1 -0
  60. package/build/services/auth.js +40 -0
  61. package/build/services/auth.js.map +1 -0
  62. package/build/services/db-class.js +49 -0
  63. package/build/services/db-class.js.map +1 -0
  64. package/build/services/db.js +34 -0
  65. package/build/services/db.js.map +1 -0
  66. package/build/services/navigation.js +96 -0
  67. package/build/services/navigation.js.map +1 -0
  68. package/build/services/reference-fields.js +131 -0
  69. package/build/services/reference-fields.js.map +1 -0
  70. package/build/services/robots.js +60 -0
  71. package/build/services/robots.js.map +1 -0
  72. package/build/services/sites.js +110 -0
  73. package/build/services/sites.js.map +1 -0
  74. package/build/services/store.js +257 -0
  75. package/build/services/store.js.map +1 -0
  76. package/build/types/api.js +3 -0
  77. package/build/types/api.js.map +1 -0
  78. package/build/types/global.js +3 -0
  79. package/build/types/global.js.map +1 -0
  80. package/build/types/navigation.js +3 -0
  81. package/build/types/navigation.js.map +1 -0
  82. package/build/types/pages.js +3 -0
  83. package/build/types/pages.js.map +1 -0
  84. package/build/types/render.js +10 -0
  85. package/build/types/render.js.map +1 -0
  86. package/build/types/sites.js +3 -0
  87. package/build/types/sites.js.map +1 -0
  88. package/build/types/templates.js +3 -0
  89. package/build/types/templates.js.map +1 -0
  90. package/build/utils/api.js +165 -0
  91. package/build/utils/api.js.map +1 -0
  92. package/build/utils/artifacts.js +38 -0
  93. package/build/utils/artifacts.js.map +1 -0
  94. package/build/utils/brush.js +30 -0
  95. package/build/utils/brush.js.map +1 -0
  96. package/build/utils/cache.js +106 -0
  97. package/build/utils/cache.js.map +1 -0
  98. package/build/utils/check-environment-health.js +69 -0
  99. package/build/utils/check-environment-health.js.map +1 -0
  100. package/build/utils/core-utils.js +270 -0
  101. package/build/utils/core-utils.js.map +1 -0
  102. package/build/utils/domains.js +37 -0
  103. package/build/utils/domains.js.map +1 -0
  104. package/build/utils/errors.js +30 -0
  105. package/build/utils/errors.js.map +1 -0
  106. package/build/utils/folders.js +341 -0
  107. package/build/utils/folders.js.map +1 -0
  108. package/build/utils/images.js +45 -0
  109. package/build/utils/images.js.map +1 -0
  110. package/build/utils/instance.js +66 -0
  111. package/build/utils/instance.js.map +1 -0
  112. package/build/utils/loggin.js +119 -0
  113. package/build/utils/loggin.js.map +1 -0
  114. package/build/utils/npm-deps/find-up-simple.js +75 -0
  115. package/build/utils/npm-deps/find-up-simple.js.map +1 -0
  116. package/build/utils/npm-deps/pkg-dir.js +20 -0
  117. package/build/utils/npm-deps/pkg-dir.js.map +1 -0
  118. package/build/utils/npm-deps/xml-parser.js +49 -0
  119. package/build/utils/npm-deps/xml-parser.js.map +1 -0
  120. package/build/utils/pages.js +359 -0
  121. package/build/utils/pages.js.map +1 -0
  122. package/build/utils/render.js +168 -0
  123. package/build/utils/render.js.map +1 -0
  124. package/build/utils/sitemaps.js +110 -0
  125. package/build/utils/sitemaps.js.map +1 -0
  126. package/build/utils/sites.js +105 -0
  127. package/build/utils/sites.js.map +1 -0
  128. package/build/utils/store.js +193 -0
  129. package/build/utils/store.js.map +1 -0
  130. package/exporter/adapters/gatsby/actions/clean.ts +14 -0
  131. package/exporter/adapters/gatsby/actions/close.ts +20 -0
  132. package/exporter/adapters/gatsby/actions/data.ts +25 -0
  133. package/exporter/adapters/gatsby/actions/healthCheck.ts +10 -0
  134. package/exporter/adapters/gatsby/actions/init.ts +26 -0
  135. package/exporter/adapters/gatsby/actions/logs.ts +10 -0
  136. package/exporter/adapters/gatsby/actions/meta.ts +16 -0
  137. package/exporter/adapters/gatsby/actions/prepare.ts +9 -0
  138. package/exporter/adapters/gatsby/actions/relocation.ts +15 -0
  139. package/exporter/adapters/gatsby/actions/restore.ts +36 -0
  140. package/exporter/adapters/gatsby/actions/ssg.ts +12 -0
  141. package/exporter/adapters/gatsby/actions/sync.ts +71 -0
  142. package/exporter/adapters/gatsby/index.ts +73 -153
  143. package/exporter/adapters/gatsby/shared/artifacts.ts +16 -0
  144. package/exporter/adapters/gatsby/shared/context.ts +50 -0
  145. package/exporter/adapters/gatsby/shared/diff-assets.ts +113 -0
  146. package/exporter/adapters/gatsby/shared/extract-assets.ts +61 -0
  147. package/exporter/adapters/gatsby/shared/gatsby-build.ts +58 -0
  148. package/exporter/adapters/gatsby/shared/sync-render.ts +276 -0
  149. package/exporter/adapters/gatsby/shared/types.ts +35 -0
  150. package/exporter/build-esbuild.noop +42 -0
  151. package/exporter/build.sh +4 -38
  152. package/exporter/commands/end-render.ts +72 -70
  153. package/exporter/commands/prepare-assets-directory.ts +30 -0
  154. package/exporter/commands/prepare-domains-render.ts +143 -31
  155. package/exporter/commands/reset-render.ts +10 -3
  156. package/exporter/commands/start-render.ts +22 -45
  157. package/exporter/commands/upload-search-content.ts +194 -21
  158. package/exporter/constants/endpoints.ts +2 -1
  159. package/exporter/constants/envs.ts +57 -55
  160. package/exporter/{errors/errors-data.ts → constants/errors.ts} +24 -14
  161. package/exporter/services/auth.ts +7 -6
  162. package/exporter/services/db-class.ts +54 -0
  163. package/exporter/services/db.ts +32 -0
  164. package/exporter/services/navigation.ts +4 -10
  165. package/exporter/services/reference-fields.ts +9 -24
  166. package/exporter/services/robots.ts +9 -16
  167. package/exporter/services/sites.ts +36 -24
  168. package/exporter/services/store.ts +107 -96
  169. package/exporter/types/api.ts +27 -28
  170. package/exporter/types/global.ts +8 -11
  171. package/exporter/types/navigation.ts +1 -1
  172. package/exporter/types/pages.ts +2 -3
  173. package/exporter/types/render.ts +59 -0
  174. package/exporter/types/sites.ts +1 -2
  175. package/exporter/utils/api.ts +55 -75
  176. package/exporter/utils/artifacts.ts +38 -0
  177. package/exporter/utils/brush.ts +34 -0
  178. package/exporter/utils/cache.ts +37 -62
  179. package/exporter/utils/check-environment-health.ts +80 -0
  180. package/exporter/utils/core-utils.ts +133 -272
  181. package/exporter/utils/domains.ts +10 -7
  182. package/exporter/{errors/index.ts → utils/errors.ts} +10 -9
  183. package/exporter/utils/folders.ts +163 -98
  184. package/exporter/utils/images.ts +1 -6
  185. package/exporter/utils/instance.ts +9 -13
  186. package/exporter/utils/loggin.ts +44 -91
  187. package/exporter/utils/npm-deps/find-up-simple.ts +100 -0
  188. package/exporter/utils/npm-deps/pkg-dir.ts +17 -0
  189. package/exporter/utils/npm-deps/xml-parser.ts +57 -0
  190. package/exporter/utils/pages.ts +23 -88
  191. package/exporter/utils/render.ts +180 -48
  192. package/exporter/utils/sitemaps.ts +129 -0
  193. package/exporter/utils/sites.ts +19 -197
  194. package/exporter/utils/store.ts +87 -180
  195. package/gatsby-browser.tsx +41 -58
  196. package/gatsby-config.ts +10 -17
  197. package/gatsby-node.ts +17 -78
  198. package/gatsby-ssr.tsx +2 -1
  199. package/package.json +35 -86
  200. package/plugins/gatsby-plugin-svgr-loader/gatsby-node.js +55 -0
  201. package/plugins/gatsby-plugin-svgr-loader/package.json +8 -0
  202. package/react/DynamicScript/index.tsx +33 -0
  203. package/{exporter/react → react}/Favicon/index.tsx +1 -7
  204. package/{exporter/react → react}/GriddoIntegrations/index.tsx +16 -22
  205. package/{exporter/react → react}/GriddoIntegrations/utils.ts +21 -9
  206. package/{build/react/index.d.ts → react/index.tsx} +1 -0
  207. package/src/components/Head.tsx +13 -46
  208. package/src/components/template.tsx +8 -30
  209. package/src/gatsby-node-utils.ts +73 -2
  210. package/src/html.tsx +2 -11
  211. package/src/types.ts +5 -5
  212. package/tsconfig.commands.json +36 -0
  213. package/tsconfig.exporter.json +19 -0
  214. package/tsconfig.json +5 -3
  215. package/build/adapters/gatsby/index.d.ts +0 -4
  216. package/build/adapters/gatsby/utils.d.ts +0 -22
  217. package/build/artifacts/index.d.ts +0 -6
  218. package/build/commands/end-render.d.ts +0 -2
  219. package/build/commands/move-assets.d.ts +0 -1
  220. package/build/commands/prepare-domains-render.d.ts +0 -1
  221. package/build/commands/reset-render.d.ts +0 -2
  222. package/build/commands/start-render.d.ts +0 -2
  223. package/build/commands/upload-search-content.d.ts +0 -2
  224. package/build/constants/endpoints.d.ts +0 -19
  225. package/build/constants/envs.d.ts +0 -37
  226. package/build/constants/index.d.ts +0 -57
  227. package/build/end-render.js +0 -74
  228. package/build/end-render.js.map +0 -7
  229. package/build/errors/errors-data.d.ts +0 -22
  230. package/build/errors/index.d.ts +0 -15
  231. package/build/index.d.ts +0 -29
  232. package/build/index.js +0 -73
  233. package/build/index.js.map +0 -7
  234. package/build/prepare-domains-render.js +0 -73
  235. package/build/prepare-domains-render.js.map +0 -7
  236. package/build/react/Favicon/index.d.ts +0 -5
  237. package/build/react/Favicon/utils.d.ts +0 -9
  238. package/build/react/GriddoIntegrations/index.d.ts +0 -20
  239. package/build/react/GriddoIntegrations/utils.d.ts +0 -26
  240. package/build/react/index.js +0 -3
  241. package/build/registers/api.d.ts +0 -9
  242. package/build/registers/gatsby.d.ts +0 -9
  243. package/build/registers/index.d.ts +0 -3
  244. package/build/reset-render.js +0 -74
  245. package/build/reset-render.js.map +0 -7
  246. package/build/services/auth.d.ts +0 -10
  247. package/build/services/domains.d.ts +0 -6
  248. package/build/services/navigation.d.ts +0 -50
  249. package/build/services/reference-fields.d.ts +0 -20
  250. package/build/services/register.d.ts +0 -36
  251. package/build/services/robots.d.ts +0 -19
  252. package/build/services/settings.d.ts +0 -4
  253. package/build/services/sites.d.ts +0 -29
  254. package/build/services/store.d.ts +0 -6
  255. package/build/start-render.js +0 -100
  256. package/build/start-render.js.map +0 -7
  257. package/build/types/api.d.ts +0 -142
  258. package/build/types/global.d.ts +0 -84
  259. package/build/types/navigation.d.ts +0 -28
  260. package/build/types/pages.d.ts +0 -144
  261. package/build/types/sites.d.ts +0 -57
  262. package/build/types/templates.d.ts +0 -8
  263. package/build/upload-search-content.js +0 -74
  264. package/build/upload-search-content.js.map +0 -7
  265. package/build/utils/alerts.d.ts +0 -3
  266. package/build/utils/api.d.ts +0 -23
  267. package/build/utils/cache.d.ts +0 -35
  268. package/build/utils/core-utils.d.ts +0 -107
  269. package/build/utils/create-build-data.d.ts +0 -8
  270. package/build/utils/domains.d.ts +0 -13
  271. package/build/utils/folders.d.ts +0 -53
  272. package/build/utils/health-checks.d.ts +0 -7
  273. package/build/utils/images.d.ts +0 -16
  274. package/build/utils/instance.d.ts +0 -21
  275. package/build/utils/loggin.d.ts +0 -51
  276. package/build/utils/pages.d.ts +0 -34
  277. package/build/utils/render.d.ts +0 -13
  278. package/build/utils/searches.d.ts +0 -15
  279. package/build/utils/sites.d.ts +0 -31
  280. package/build/utils/store.d.ts +0 -81
  281. package/cx.config.d.ts +0 -5
  282. package/cx.config.js +0 -36
  283. package/exporter/adapters/gatsby/utils.ts +0 -161
  284. package/exporter/artifacts/README.md +0 -34
  285. package/exporter/artifacts/index.ts +0 -33
  286. package/exporter/commands/move-assets.ts +0 -11
  287. package/exporter/constants/index.ts +0 -129
  288. package/exporter/index.ts +0 -82
  289. package/exporter/react/index.tsx +0 -11
  290. package/exporter/registers/api.ts +0 -14
  291. package/exporter/registers/gatsby.ts +0 -14
  292. package/exporter/registers/index.ts +0 -4
  293. package/exporter/services/domains.ts +0 -16
  294. package/exporter/services/register.ts +0 -113
  295. package/exporter/services/settings.ts +0 -17
  296. package/exporter/utils/alerts.ts +0 -29
  297. package/exporter/utils/create-build-data.ts +0 -17
  298. package/exporter/utils/health-checks.ts +0 -64
  299. package/exporter/utils/searches.ts +0 -156
  300. package/src/README.md +0 -7
  301. package/start-render.js +0 -7
  302. /package/{exporter/react → react}/Favicon/utils.ts +0 -0
@@ -1,161 +0,0 @@
1
- import { spawnSync } from "node:child_process";
2
- import path from "node:path";
3
-
4
- import fsx from "fs-extra";
5
-
6
- import { envs } from "../../constants";
7
- import { throwError } from "../../errors";
8
- import { ErrorInSSGBuildProcess } from "../../errors/errors-data";
9
- import { getConfig } from "../../utils/core-utils";
10
- import { verboseLog } from "../../utils/loggin";
11
-
12
- const config = getConfig();
13
-
14
- /**
15
- * Return the assetPrefix with the domain concatenated `assetPrefix/domain` only
16
- * if the domain is "pro-" **and** there is a env `GRIDDO_ASSET_PREFIX` with any
17
- * value different from `null`, `undefined` or `empty string`
18
- *
19
- * else...
20
- * - If assetPrefix or domain is falsy, returns ""
21
- * - If the domain is not "pro-", returns ""
22
- */
23
- function getGatsbyAssetPrefixWithDomain(domain: string) {
24
- const { proDomain } = getConfig();
25
-
26
- if (!envs.GRIDDO_ASSET_PREFIX || !domain) {
27
- return "";
28
- }
29
-
30
- if (!domain.startsWith(proDomain)) {
31
- return "";
32
- }
33
-
34
- const assetPrefixWithDomain = `${envs.GRIDDO_ASSET_PREFIX}/${domain}`;
35
-
36
- verboseLog(
37
- `Reading process.env.GRIDDO_ASSET_PREFIX, ${envs.GRIDDO_ASSET_PREFIX}`,
38
- );
39
- verboseLog(
40
- `Setting the asset prefix with the domain concatenated, ${assetPrefixWithDomain}`,
41
- );
42
-
43
- return assetPrefixWithDomain;
44
- }
45
-
46
- /**
47
- * Spawn a new node process `yarn gatsby-build`
48
- * @note This proccess (`yarn gatsby-build`) can not access to the custom Griddo
49
- * `process.env` so it needs variables passed to it via the `env` prop.
50
- */
51
- function runGatsbyBuildCommand(assetPrefixWithDomain: string) {
52
- verboseLog(`read assetPrefixWithDomain, ${assetPrefixWithDomain}`);
53
- verboseLog(
54
- `using this NODE_OPTIONS in gatsby command: ${process.env.NODE_OPTIONS}`,
55
- );
56
-
57
- const { __ssg } = config.paths();
58
-
59
- // Remove `--openssl-legacy-provider` from NODE_OPTIONS because this value
60
- // break Gataby render.
61
- const nodeOptionsWithoutLegacyOpenSSL = process.env.NODE_OPTIONS
62
- ? process.env.NODE_OPTIONS.replace(
63
- /--openssl-legacy-provider\s*/g,
64
- "",
65
- ).trim()
66
- : "";
67
-
68
- const command = spawnSync(
69
- "yarn",
70
- ["gatsby-build", envs.GRIDDO_SSG_VERBOSE_LOGS ? "--verbose" : ""],
71
- {
72
- cwd: __ssg,
73
- stdio: ["ignore", "inherit", "ignore"],
74
- encoding: "utf8",
75
- shell: true,
76
- env: Object.assign(process.env, {
77
- GRIDDO_EXPORTER: "true",
78
- SPAWN_ASSET_PREFIX_WITH_DOMAIN: assetPrefixWithDomain,
79
- NODE_OPTIONS: nodeOptionsWithoutLegacyOpenSSL,
80
- }),
81
- },
82
- );
83
-
84
- if (command.status !== 0) {
85
- throwError(ErrorInSSGBuildProcess(command));
86
- }
87
- }
88
-
89
- /**
90
- * Update the Griddo's `/dist` dir with the contents from `public` dir only
91
- * with files of type: js, json and css.
92
- */
93
- async function createDistFromGatsbyPublic(
94
- domain: string,
95
- needsAssetPrefix: boolean,
96
- ) {
97
- const { __cx, __ssg } = config.paths(domain);
98
-
99
- const cxDistDir = path.join(__cx, "dist");
100
- const cxAssetsDir = path.join(__cx, "assets");
101
- const cxDistDirWithDomain = path.join(__cx, "dist", domain);
102
- const publicDir = path.join(__ssg, "public");
103
-
104
- const validFilesFromPublic = fsx
105
- .readdirSync(publicDir)
106
- .filter(
107
- (file) =>
108
- path.extname(file) === ".js" ||
109
- path.extname(file) === ".json" ||
110
- path.extname(file) === ".css",
111
- );
112
-
113
- const pageDataSrc = `${publicDir}/page-data`;
114
- const pageDataDest = `${cxAssetsDir}/page-data`;
115
-
116
- const projectStaticSrc = path.join(__ssg, "static");
117
- const projectStaticDest = cxAssetsDir;
118
-
119
- const gatsbyStaticSrc = `${cxDistDir}/static`;
120
- const gatsbyStaticDest = `${cxAssetsDir}/static`;
121
-
122
- try {
123
- fsx.mkdirSync(cxAssetsDir, { recursive: true });
124
- fsx.copySync(publicDir, cxDistDir, { preserveTimestamps: true });
125
-
126
- if (needsAssetPrefix) {
127
- fsx.copySync(pageDataSrc, pageDataDest, { preserveTimestamps: true });
128
- if (fsx.existsSync(projectStaticSrc)) {
129
- fsx.copySync(projectStaticSrc, projectStaticDest, {
130
- overwrite: false,
131
- preserveTimestamps: true,
132
- });
133
- }
134
- fsx.copySync(gatsbyStaticSrc, gatsbyStaticDest, {
135
- overwrite: false,
136
- preserveTimestamps: true,
137
- });
138
- if (fsx.existsSync(projectStaticSrc)) {
139
- fsx.copySync(projectStaticSrc, cxDistDirWithDomain, {
140
- overwrite: false,
141
- preserveTimestamps: true,
142
- });
143
- }
144
-
145
- // Copia el resto de archivos...
146
- validFilesFromPublic.map((file) => {
147
- const fileSrc = `${publicDir}/${file}`;
148
- const fileDest = `${cxAssetsDir}/${file}`;
149
- fsx.copySync(fileSrc, fileDest, { preserveTimestamps: true });
150
- });
151
- }
152
- } catch (err) {
153
- console.error(err);
154
- }
155
- }
156
-
157
- export {
158
- createDistFromGatsbyPublic,
159
- getGatsbyAssetPrefixWithDomain,
160
- runGatsbyBuildCommand,
161
- };
@@ -1,34 +0,0 @@
1
- # CX Artifacs
2
-
3
- ## How to add an artifact.
4
-
5
- An artifact is a **full path** to a file or directory if it has a fixed
6
- location or only a **name** when it is going to be moved (archived/restored)
7
- between directories in the rendering process and therefore doesn't have a
8
- single location.
9
-
10
- Only the exporter knows where the artifacts are archived and restored, so the
11
- artifacts don't need to know anything other than their own location or name.
12
-
13
- Si estás creando un adaptador, sus artefactos deberán ir en un archivo separado (igual que `artifacts/cx.ts`) y exportar una función por defecto que devuelva un `Artifacts`. Todo deberá estar exportado desde `artifacts/index.ts`.
14
-
15
- **Artifacts have four categories:**
16
-
17
- - **initials**: Are directories that need to be created for their
18
- future use.
19
-
20
- - **archivables**: Are stored in `__exports` which is the one uploaded to the
21
- server as the final render and restored in `__cx` and `__ssg` to be reused in the
22
- render. Therefore, they don't have a single location and should be added only
23
- with the artifact name (directory/file)
24
-
25
- - **cacheables**: Are stored in `__cache` and restored in `__cx` and `__ssg` to be
26
- reused in each domain render. Therefore, they don't have a single location.
27
-
28
- - **disposables**: Are generated alwais in `__cx` and `__ssg` or fixed locations.
29
- These artifacts are discarded (deleted) in each domain render. They are
30
- temporary directories and/or files.
31
-
32
- ## Example
33
-
34
- Check `cx.ts` inside `./artifacts` directory to see how to add an artifact.
@@ -1,33 +0,0 @@
1
- import type { Artifacts } from "../types/global";
2
-
3
- import path from "node:path";
4
-
5
- import { getConfig } from "../utils/core-utils";
6
-
7
- /**
8
- * Returns the artifacts of CX.
9
- */
10
- function getCxArtifacts(domain: string): Artifacts {
11
- const config = getConfig();
12
- const { __cx, __exports, __cache } = config.paths(domain);
13
-
14
- return {
15
- initials: [
16
- __exports, // `/exports/<domain>`
17
- __cache, // `__cx/.cx-cache/<domain>`
18
- path.join(__cx, "store"),
19
- path.join(__cx, "apiCache"),
20
- ],
21
- disposables: [
22
- path.join(__cx, "store"),
23
- path.join(__cx, "apiCache"),
24
- path.join(__cx, "render-metadata.json"),
25
- path.join(__cx, "dist"),
26
- path.join(__cx, "debug"),
27
- ],
28
- cacheables: ["apiCache", "store"],
29
- archivables: ["dist", "assets", "debug"],
30
- };
31
- }
32
-
33
- export default getCxArtifacts;
@@ -1,11 +0,0 @@
1
- import { execSync } from "node:child_process";
2
- import path from "node:path";
3
-
4
- const domainName = "pro-griddo";
5
- const domainPath = path.resolve(
6
- __dirname,
7
- `../../../exports/sites/${domainName}`,
8
- );
9
-
10
- execSync(`mkdir -p ${domainPath}/assets/${domainName}`);
11
- execSync(`cp -R ${domainPath}/assets/* ${domainPath}/assets/${domainName}`);
@@ -1,129 +0,0 @@
1
- import type { LifeCyclesNames } from "../types/global";
2
-
3
- import {
4
- AI_EMBEDDINGS,
5
- ALERT,
6
- BUILD_END,
7
- BUILD_START,
8
- DOMAINS,
9
- GET_ALL,
10
- GET_PAGE,
11
- GET_PAGES,
12
- GET_REFERENCE_FIELD_DATA,
13
- GET_SITEMAP,
14
- INFO,
15
- LANGUAGES,
16
- LOGIN,
17
- RESET_RENDER,
18
- ROBOTS,
19
- SEARCH,
20
- SETTINGS,
21
- SOCIALS,
22
- } from "./endpoints";
23
- import {
24
- GRIDDO_AI_EMBEDDINGS,
25
- GRIDDO_ALERT_FEATURE,
26
- GRIDDO_API_CONCURRENCY_COUNT,
27
- GRIDDO_API_MAX_RESPONSE_SIZE,
28
- GRIDDO_API_URL,
29
- GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS,
30
- GRIDDO_ASSET_PREFIX,
31
- GRIDDO_BOT_PASSWORD,
32
- GRIDDO_BOT_USER,
33
- GRIDDO_BUILD_LOGS,
34
- GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS,
35
- GRIDDO_CLOSE_LIFECYCLE_MAX_ATTEMPTS,
36
- GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS,
37
- GRIDDO_DEBUG_LOGS,
38
- GRIDDO_FIXTURES_DOMAIN_NAMES,
39
- GRIDDO_FIXTURES_SITE_NAMES,
40
- GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS,
41
- GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS,
42
- GRIDDO_PUBLIC_API_URL,
43
- GRIDDO_REACT_APP_INSTANCE,
44
- GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS,
45
- GRIDDO_RENDER_ALL_SITES,
46
- GRIDDO_RENDER_BREAKPOINTS_FEATURE,
47
- GRIDDO_RENDER_PAGES,
48
- GRIDDO_RENDER_SITE,
49
- GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS,
50
- GRIDDO_SEARCH_FEATURE,
51
- GRIDDO_SKIP_BUILD_CHECKS,
52
- GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS,
53
- GRIDDO_SSG_MAX_PAGE_SIZE,
54
- GRIDDO_SSG_VERBOSE_LOGS,
55
- GRIDDO_VERBOSE_LOGS,
56
- } from "./envs";
57
-
58
- const endpoints = {
59
- ALERT,
60
- AI_EMBEDDINGS,
61
- BUILD_END,
62
- BUILD_START,
63
- DOMAINS,
64
- GET_ALL,
65
- GET_PAGE,
66
- GET_PAGES,
67
- GET_REFERENCE_FIELD_DATA,
68
- GET_SITEMAP,
69
- INFO,
70
- LANGUAGES,
71
- LOGIN,
72
- RESET_RENDER,
73
- ROBOTS,
74
- SEARCH,
75
- SETTINGS,
76
- SOCIALS,
77
- };
78
-
79
- const envs = {
80
- GRIDDO_AI_EMBEDDINGS,
81
- GRIDDO_ALERT_FEATURE,
82
- GRIDDO_API_CONCURRENCY_COUNT,
83
- GRIDDO_API_MAX_RESPONSE_SIZE,
84
- GRIDDO_API_URL,
85
- GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS,
86
- GRIDDO_ASSET_PREFIX,
87
- GRIDDO_BOT_PASSWORD,
88
- GRIDDO_BOT_USER,
89
- GRIDDO_BUILD_LOGS,
90
- GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS,
91
- GRIDDO_CLOSE_LIFECYCLE_MAX_ATTEMPTS,
92
- GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS,
93
- GRIDDO_DEBUG_LOGS,
94
- GRIDDO_FIXTURES_DOMAIN_NAMES,
95
- GRIDDO_FIXTURES_SITE_NAMES,
96
- GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS,
97
- GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS,
98
- GRIDDO_PUBLIC_API_URL,
99
- GRIDDO_REACT_APP_INSTANCE,
100
- GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS,
101
- GRIDDO_RENDER_ALL_SITES,
102
- GRIDDO_RENDER_BREAKPOINTS_FEATURE,
103
- GRIDDO_RENDER_PAGES,
104
- GRIDDO_RENDER_SITE,
105
- GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS,
106
- GRIDDO_SEARCH_FEATURE,
107
- GRIDDO_SKIP_BUILD_CHECKS,
108
- GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS,
109
- GRIDDO_SSG_MAX_PAGE_SIZE,
110
- GRIDDO_SSG_VERBOSE_LOGS,
111
- GRIDDO_VERBOSE_LOGS,
112
- };
113
-
114
- const lifeCycleNames: Record<LifeCyclesNames, LifeCyclesNames> = {
115
- __DEBUG__: "__DEBUG__",
116
- Archive: "Archive",
117
- Clean: "Clean",
118
- Close: "Close",
119
- Data: "Data",
120
- HealthCheck: "HealthCheck",
121
- Init: "Init",
122
- Meta: "Meta",
123
- Prepare: "Prepare",
124
- Relocation: "Relocation",
125
- Restore: "Restore",
126
- SSG: "SSG",
127
- } as const;
128
-
129
- export { endpoints, envs, lifeCycleNames };
package/exporter/index.ts DELETED
@@ -1,82 +0,0 @@
1
- /**
2
- *
3
- * Griddo CX library main export file.
4
- *
5
- * This file exports functions to use in both: adapters and SSG's frameworks.
6
- * Turning CX basically in a javascript library.
7
- *
8
- * # React
9
- * There is another export in the `/react` directory to use exclusivelly in
10
- * the browser context where nodejs (path, fs, etc..) is not available.
11
- *
12
- * # Separate scripts.
13
- * There are some separate .ts files as end-render.ts or reset-render.ts
14
- * that are intended to be used by infra via npm script like `npm run
15
- * end-render`
16
- *
17
- */
18
-
19
- import type { SocialsResponse } from "./types/api";
20
- import type {
21
- AdditionalInfo,
22
- Dimensions,
23
- GriddoListPage,
24
- GriddoMultiPage,
25
- GriddoPageObject,
26
- GriddoSinglePage,
27
- } from "./types/pages";
28
- import type { Site } from "./types/sites";
29
-
30
- import { endpoints, envs } from "./constants";
31
- import { apiRegister } from "./registers/index";
32
- import { FileRegister, MemoryRegister, Register } from "./services/register";
33
- import { insertAlert } from "./utils/alerts";
34
- import { getConfig, walk } from "./utils/core-utils";
35
- import {
36
- componentLibraryPathAlias,
37
- isComponentLibrary,
38
- resolveComponentsPath,
39
- } from "./utils/instance";
40
- import {
41
- buildLog,
42
- debugLog,
43
- infoLog,
44
- pageSizeLog,
45
- verboseLog,
46
- } from "./utils/loggin";
47
- import {
48
- getBuildPagesFromCachedStore,
49
- getBuildPagesFromStore,
50
- getBuildPagesPath,
51
- } from "./utils/store";
52
-
53
- export {
54
- apiRegister,
55
- buildLog,
56
- componentLibraryPathAlias,
57
- debugLog,
58
- endpoints,
59
- envs,
60
- FileRegister,
61
- getBuildPagesFromCachedStore,
62
- getBuildPagesFromStore,
63
- getBuildPagesPath,
64
- getConfig,
65
- infoLog,
66
- insertAlert,
67
- isComponentLibrary,
68
- MemoryRegister,
69
- pageSizeLog,
70
- Register,
71
- resolveComponentsPath,
72
- verboseLog,
73
- walk,
74
- type AdditionalInfo,
75
- type Dimensions,
76
- type GriddoListPage,
77
- type GriddoMultiPage,
78
- type GriddoPageObject,
79
- type GriddoSinglePage,
80
- type Site,
81
- type SocialsResponse,
82
- };
@@ -1,11 +0,0 @@
1
- //
2
- // Griddo CX library react export file.
3
- // This file exports functions to use in the SSG's frameworks.
4
- //
5
- // import { ... } from "@griddo/cx/react";
6
- //
7
-
8
- import { Favicon } from "./Favicon";
9
- import { GriddoIntegrations } from "./GriddoIntegrations";
10
-
11
- export { Favicon, GriddoIntegrations };
@@ -1,14 +0,0 @@
1
- import { MemoryRegister, Register } from "../services/register";
2
-
3
- const entries = {
4
- API_RESPONSE_TOO_BIG: {
5
- title: "API response size is too large",
6
- description:
7
- "API response size is too large and may affect rendering performance",
8
- entries: [],
9
- },
10
- };
11
-
12
- const register = new Register(new MemoryRegister(entries));
13
-
14
- export default register;
@@ -1,14 +0,0 @@
1
- import { MemoryRegister, Register } from "../services/register";
2
-
3
- const entries = {
4
- GATSBY_PAGE_SIZE_TOO_BIG: {
5
- title: "Gatsby JSON page size is too large",
6
- description:
7
- "The JSON of some Gatsby pages (page-data folder) are too large and may affect rendering performance",
8
- entries: [],
9
- },
10
- };
11
-
12
- const register = new Register(new MemoryRegister(entries));
13
-
14
- export default register;
@@ -1,4 +0,0 @@
1
- import apiRegister from "./api";
2
- import gatsbyRegister from "./gatsby";
3
-
4
- export { apiRegister, gatsbyRegister };
@@ -1,16 +0,0 @@
1
- import type { Domains } from "../types/global";
2
-
3
- import { endpoints } from "../constants";
4
- import { get } from "../utils/api";
5
-
6
- /**
7
- * Get an array of available domain.
8
- */
9
- async function getAllDomains() {
10
- return get<Domains>({
11
- endpoint: endpoints.DOMAINS,
12
- useApiCacheDir: false,
13
- });
14
- }
15
-
16
- export { getAllDomains };
@@ -1,113 +0,0 @@
1
- import fsx from "fs-extra";
2
-
3
- type Entry = Record<string, unknown>;
4
-
5
- type EntryData = {
6
- title: string;
7
- description: string;
8
- entries: Array<Entry>;
9
- };
10
-
11
- type Entries = Record<string, EntryData>;
12
-
13
- interface RegisterBase<T extends Entries> {
14
- insert(name: keyof T, entry: Entry): void;
15
- get(name: keyof T): EntryData;
16
- getAll(): T;
17
- }
18
-
19
- class MemoryRegister<T extends Entries> implements RegisterBase<T> {
20
- entries: T;
21
-
22
- constructor(entries: T) {
23
- this.entries = entries;
24
- }
25
-
26
- insert(name: keyof T, entry: Entry) {
27
- this.entries[name].entries.push(entry);
28
- }
29
-
30
- get(name: keyof T) {
31
- return this.entries[name];
32
- }
33
-
34
- getAll() {
35
- return this.entries;
36
- }
37
- }
38
-
39
- class FileRegister<T extends Entries> implements RegisterBase<T> {
40
- private readonly filePath: string;
41
- entries: T;
42
-
43
- constructor(filePath: string, entries: T) {
44
- this.entries = entries;
45
- this.filePath = filePath;
46
- try {
47
- fsx.writeJSONSync(this.filePath, this.entries);
48
- } catch (e) {
49
- console.error(`Error writing ${this.filePath}`, e);
50
- }
51
- }
52
-
53
- private getCurrentEntries(): T {
54
- return fsx.readJSONSync(this.filePath, "utf8") as T;
55
- }
56
-
57
- insert(name: keyof T, entry: Entry) {
58
- try {
59
- const currentEntries = this.getCurrentEntries();
60
- currentEntries[name].entries.push(entry);
61
- fsx.writeJSONSync(this.filePath, currentEntries);
62
- } catch (e) {
63
- console.error(e);
64
- }
65
- }
66
-
67
- get(name: keyof T) {
68
- try {
69
- return fsx.readJSONSync(this.filePath, "utf8")[name] as EntryData;
70
- } catch (e) {
71
- console.error(e);
72
- throw new Error(`Error reading ${this.filePath}`);
73
- }
74
- }
75
-
76
- getAll() {
77
- try {
78
- return fsx.readJSONSync(this.filePath, "utf8") as T;
79
- } catch (e) {
80
- console.error(e);
81
- throw new Error(`Error reading ${this.filePath}`);
82
- }
83
- }
84
- }
85
-
86
- class Register<T extends Entries> {
87
- private strategy: RegisterBase<T>;
88
-
89
- constructor(strategy: RegisterBase<T>) {
90
- this.strategy = strategy;
91
- }
92
-
93
- insert<K extends keyof T>(name: K, entry: Entry) {
94
- this.strategy.insert(name, entry);
95
- }
96
-
97
- get<K extends keyof T>(name: K) {
98
- return this.strategy.get(name);
99
- }
100
-
101
- getAll() {
102
- return this.strategy.getAll();
103
- }
104
- }
105
-
106
- export {
107
- FileRegister,
108
- MemoryRegister,
109
- Register,
110
- type Entries,
111
- type Entry,
112
- type EntryData,
113
- };
@@ -1,17 +0,0 @@
1
- import type { Settings } from "../types/global";
2
-
3
- import { endpoints } from "../constants";
4
- import { get, post } from "../utils/api";
5
-
6
- async function getAllSettings() {
7
- return get<Settings>({ endpoint: endpoints.SETTINGS });
8
- }
9
-
10
- async function resetRender() {
11
- await post({
12
- endpoint: endpoints.RESET_RENDER,
13
- useApiCacheDir: false,
14
- });
15
- }
16
-
17
- export { getAllSettings, resetRender };
@@ -1,29 +0,0 @@
1
- import type { GriddoAlertRegisterProps } from "@griddo/core";
2
-
3
- import axios from "axios";
4
-
5
- import { endpoints } from "../constants";
6
-
7
- // Esta función está duplicada de core de manera intencionada por si esta recibe
8
- // cambios necesitados solo por CX.
9
- // Nota: Sí estamos reutilizando el type.
10
- async function insertAlert({
11
- area,
12
- description,
13
- fullData,
14
- instantNotification = false,
15
- level,
16
- }: Omit<GriddoAlertRegisterProps, "publicApiUrl">) {
17
- const url = endpoints.ALERT;
18
- const body = { level, area, description, fullData, instantNotification };
19
-
20
- try {
21
- await axios.post(url, body, {
22
- headers: { "Content-Type": "application/json", Connection: "close" },
23
- });
24
- } catch (error) {
25
- console.error("Error creating Griddo alert:", error);
26
- }
27
- }
28
-
29
- export { insertAlert };
@@ -1,17 +0,0 @@
1
- import { createAPICacheDir } from "./cache";
2
- import { sanitizeAPICacheDir } from "./core-utils";
3
- import { createStore } from "../services/store";
4
-
5
- /**
6
- * Download all data: sites, pages etc.. from the instance private Griddo API.
7
- * Then you can use the generator funcion `getBuildPagesFromStore()` to get the pages and
8
- * `getBuildMetadata()` to get build and sites metadata as objects. Both from
9
- * exporter utils sites dir.
10
- */
11
- async function createDomainRenderData(domain: string) {
12
- createAPICacheDir();
13
- await createStore(domain);
14
- sanitizeAPICacheDir();
15
- }
16
-
17
- export { createDomainRenderData };