@griddo/cx 11.9.7 → 11.9.8-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 (222) hide show
  1. package/README.md +78 -193
  2. package/build/commands/end-render.js +31 -0
  3. package/build/commands/end-render.js.map +7 -0
  4. package/build/commands/prepare-assets-directory.js +9 -0
  5. package/build/commands/prepare-assets-directory.js.map +7 -0
  6. package/build/commands/prepare-domains-render.js +38 -0
  7. package/build/commands/prepare-domains-render.js.map +7 -0
  8. package/build/commands/reset-render.js +31 -0
  9. package/build/commands/reset-render.js.map +7 -0
  10. package/build/commands/start-embeddings.js +31 -0
  11. package/build/commands/start-embeddings.js.map +7 -0
  12. package/build/commands/start-render.js +66 -0
  13. package/build/commands/start-render.js.map +7 -0
  14. package/build/commands/upload-search-content.js +31 -0
  15. package/build/commands/upload-search-content.js.map +7 -0
  16. package/build/core/GriddoLog.d.ts +16 -0
  17. package/build/core/db.d.ts +4 -0
  18. package/build/core/dist-rollback.d.ts +2 -0
  19. package/build/{errors/index.d.ts → core/errors.d.ts} +5 -4
  20. package/build/core/fs.d.ts +69 -0
  21. package/build/core/logger.d.ts +18 -0
  22. package/build/index.d.ts +10 -29
  23. package/build/index.js +406 -73
  24. package/build/services/auth.d.ts +2 -5
  25. package/build/services/manage-store.d.ts +48 -0
  26. package/build/services/render.d.ts +70 -0
  27. package/build/shared/envs.d.ts +19 -0
  28. package/build/{errors/errors-data.d.ts → shared/errors.d.ts} +5 -3
  29. package/build/shared/npm-modules/brush.d.ts +18 -0
  30. package/build/shared/npm-modules/find-up-simple.d.ts +34 -0
  31. package/build/shared/npm-modules/pkg-dir.d.ts +7 -0
  32. package/build/{types → shared/types}/api.d.ts +18 -18
  33. package/build/{types → shared/types}/global.d.ts +15 -16
  34. package/build/{types → shared/types}/navigation.d.ts +5 -5
  35. package/build/{types → shared/types}/pages.d.ts +9 -9
  36. package/build/shared/types/render.d.ts +54 -0
  37. package/build/{types → shared/types}/sites.d.ts +18 -19
  38. package/cli.mjs +239 -0
  39. package/exporter/build-esbuild.noop +42 -0
  40. package/exporter/build.sh +17 -28
  41. package/exporter/commands/README.md +151 -0
  42. package/exporter/commands/end-render.ts +65 -86
  43. package/exporter/commands/prepare-assets-directory.ts +34 -0
  44. package/exporter/commands/prepare-domains-render.ts +143 -35
  45. package/exporter/commands/reset-render.ts +12 -7
  46. package/exporter/commands/single-domain-upload-search-content.noop +206 -0
  47. package/exporter/commands/start-embeddings.ts +29 -0
  48. package/exporter/commands/start-render.ts +26 -64
  49. package/exporter/commands/upload-search-content.ts +201 -26
  50. package/exporter/core/GriddoLog.ts +45 -0
  51. package/exporter/core/check-env-health.ts +200 -0
  52. package/exporter/core/db-class.ts +54 -0
  53. package/exporter/core/db.ts +33 -0
  54. package/exporter/core/dist-rollback.ts +40 -0
  55. package/exporter/core/errors.ts +82 -0
  56. package/exporter/core/fs.ts +385 -0
  57. package/exporter/{utils → core}/images.ts +1 -6
  58. package/exporter/{utils → core}/instance.ts +9 -13
  59. package/exporter/core/life-cycle.ts +73 -0
  60. package/exporter/core/logger.ts +141 -0
  61. package/exporter/core/objects.ts +37 -0
  62. package/exporter/core/print-logos.ts +21 -0
  63. package/exporter/index.ts +14 -56
  64. package/exporter/services/api.ts +306 -0
  65. package/exporter/services/auth.ts +8 -10
  66. package/exporter/services/domains.ts +23 -8
  67. package/exporter/services/manage-sites.ts +116 -0
  68. package/exporter/services/manage-store.ts +235 -0
  69. package/exporter/services/navigation.ts +12 -18
  70. package/exporter/{utils → services}/pages.ts +27 -92
  71. package/exporter/services/reference-fields.ts +14 -32
  72. package/exporter/services/render-artifacts.ts +44 -0
  73. package/exporter/services/render.ts +229 -0
  74. package/exporter/services/robots.ts +33 -61
  75. package/exporter/services/sitemaps.ts +129 -0
  76. package/exporter/services/sites.ts +40 -28
  77. package/exporter/services/store.ts +386 -319
  78. package/exporter/shared/context.ts +49 -0
  79. package/exporter/{constants → shared}/endpoints.ts +12 -11
  80. package/exporter/shared/envs.ts +62 -0
  81. package/exporter/{errors/errors-data.ts → shared/errors.ts} +24 -14
  82. package/exporter/shared/npm-modules/README.md +36 -0
  83. package/exporter/shared/npm-modules/brush.ts +34 -0
  84. package/exporter/shared/npm-modules/find-up-simple.ts +100 -0
  85. package/exporter/shared/npm-modules/pkg-dir.ts +17 -0
  86. package/exporter/shared/npm-modules/xml-parser.ts +57 -0
  87. package/exporter/{types → shared/types}/api.ts +40 -41
  88. package/exporter/{types → shared/types}/global.ts +17 -21
  89. package/exporter/{types → shared/types}/navigation.ts +3 -3
  90. package/exporter/{types → shared/types}/pages.ts +10 -11
  91. package/exporter/shared/types/render.ts +63 -0
  92. package/exporter/{types → shared/types}/sites.ts +18 -19
  93. package/exporter/ssg-adapters/gatsby/actions/clean.ts +26 -0
  94. package/exporter/ssg-adapters/gatsby/actions/close.ts +17 -0
  95. package/exporter/ssg-adapters/gatsby/actions/data.ts +22 -0
  96. package/exporter/ssg-adapters/gatsby/actions/healthCheck.ts +10 -0
  97. package/exporter/ssg-adapters/gatsby/actions/init.ts +12 -0
  98. package/exporter/ssg-adapters/gatsby/actions/logs.ts +10 -0
  99. package/exporter/ssg-adapters/gatsby/actions/meta.ts +13 -0
  100. package/exporter/ssg-adapters/gatsby/actions/prepare.ts +9 -0
  101. package/exporter/ssg-adapters/gatsby/actions/relocation.ts +15 -0
  102. package/exporter/ssg-adapters/gatsby/actions/restore.ts +21 -0
  103. package/exporter/ssg-adapters/gatsby/actions/ssg.ts +12 -0
  104. package/exporter/ssg-adapters/gatsby/actions/sync.ts +65 -0
  105. package/exporter/ssg-adapters/gatsby/index.ts +114 -0
  106. package/exporter/ssg-adapters/gatsby/shared/artifacts.ts +16 -0
  107. package/exporter/ssg-adapters/gatsby/shared/diff-assets.ts +128 -0
  108. package/exporter/ssg-adapters/gatsby/shared/extract-assets.ts +75 -0
  109. package/exporter/ssg-adapters/gatsby/shared/gatsby-build.ts +58 -0
  110. package/exporter/ssg-adapters/gatsby/shared/sync-render.ts +300 -0
  111. package/exporter/ssg-adapters/gatsby/shared/types.ts +35 -0
  112. package/exporter/ssg-adapters/gatsby/shared/utils.ts +33 -0
  113. package/gatsby-browser.tsx +41 -58
  114. package/gatsby-config.ts +10 -17
  115. package/gatsby-node.ts +20 -80
  116. package/gatsby-ssr.tsx +2 -1
  117. package/package.json +41 -92
  118. package/plugins/gatsby-plugin-svgr-loader/gatsby-node.js +55 -0
  119. package/plugins/gatsby-plugin-svgr-loader/package.json +8 -0
  120. package/react/DynamicScript/index.tsx +33 -0
  121. package/{exporter/react/Favicon → react/GriddoFavicon}/index.tsx +3 -9
  122. package/{exporter/react → react}/GriddoIntegrations/index.tsx +17 -23
  123. package/{exporter/react → react}/GriddoIntegrations/utils.ts +24 -12
  124. package/react/GriddoOpenGraph/index.tsx +39 -0
  125. package/src/components/Head.tsx +30 -73
  126. package/src/components/template.tsx +8 -30
  127. package/src/gatsby-node-utils.ts +76 -2
  128. package/src/html.tsx +2 -11
  129. package/src/types.ts +5 -5
  130. package/tsconfig.commands.json +36 -0
  131. package/tsconfig.exporter.json +20 -0
  132. package/tsconfig.json +5 -3
  133. package/build/adapters/gatsby/index.d.ts +0 -4
  134. package/build/adapters/gatsby/utils.d.ts +0 -22
  135. package/build/artifacts/index.d.ts +0 -6
  136. package/build/commands/end-render.d.ts +0 -2
  137. package/build/commands/move-assets.d.ts +0 -1
  138. package/build/commands/prepare-domains-render.d.ts +0 -1
  139. package/build/commands/reset-render.d.ts +0 -2
  140. package/build/commands/start-render.d.ts +0 -2
  141. package/build/commands/upload-search-content.d.ts +0 -2
  142. package/build/constants/envs.d.ts +0 -37
  143. package/build/constants/index.d.ts +0 -57
  144. package/build/end-render.js +0 -74
  145. package/build/end-render.js.map +0 -7
  146. package/build/index.js.map +0 -7
  147. package/build/prepare-domains-render.js +0 -73
  148. package/build/prepare-domains-render.js.map +0 -7
  149. package/build/react/Favicon/index.d.ts +0 -5
  150. package/build/react/Favicon/utils.d.ts +0 -9
  151. package/build/react/GriddoIntegrations/index.d.ts +0 -20
  152. package/build/react/GriddoIntegrations/utils.d.ts +0 -26
  153. package/build/react/index.d.ts +0 -3
  154. package/build/react/index.js +0 -3
  155. package/build/registers/api.d.ts +0 -9
  156. package/build/registers/gatsby.d.ts +0 -9
  157. package/build/registers/index.d.ts +0 -3
  158. package/build/reset-render.js +0 -74
  159. package/build/reset-render.js.map +0 -7
  160. package/build/services/domains.d.ts +0 -6
  161. package/build/services/navigation.d.ts +0 -50
  162. package/build/services/reference-fields.d.ts +0 -20
  163. package/build/services/register.d.ts +0 -36
  164. package/build/services/robots.d.ts +0 -19
  165. package/build/services/settings.d.ts +0 -4
  166. package/build/services/sites.d.ts +0 -29
  167. package/build/services/store.d.ts +0 -6
  168. package/build/start-render.js +0 -100
  169. package/build/start-render.js.map +0 -7
  170. package/build/types/templates.d.ts +0 -8
  171. package/build/upload-search-content.js +0 -74
  172. package/build/upload-search-content.js.map +0 -7
  173. package/build/utils/alerts.d.ts +0 -3
  174. package/build/utils/api.d.ts +0 -23
  175. package/build/utils/cache.d.ts +0 -35
  176. package/build/utils/core-utils.d.ts +0 -107
  177. package/build/utils/create-build-data.d.ts +0 -8
  178. package/build/utils/domains.d.ts +0 -13
  179. package/build/utils/folders.d.ts +0 -53
  180. package/build/utils/health-checks.d.ts +0 -7
  181. package/build/utils/images.d.ts +0 -16
  182. package/build/utils/loggin.d.ts +0 -51
  183. package/build/utils/pages.d.ts +0 -34
  184. package/build/utils/render.d.ts +0 -13
  185. package/build/utils/searches.d.ts +0 -15
  186. package/build/utils/sites.d.ts +0 -31
  187. package/build/utils/store.d.ts +0 -81
  188. package/cx.config.d.ts +0 -5
  189. package/cx.config.js +0 -36
  190. package/exporter/adapters/gatsby/index.ts +0 -162
  191. package/exporter/adapters/gatsby/utils.ts +0 -161
  192. package/exporter/artifacts/README.md +0 -34
  193. package/exporter/artifacts/index.ts +0 -33
  194. package/exporter/commands/move-assets.ts +0 -11
  195. package/exporter/constants/envs.ts +0 -94
  196. package/exporter/constants/index.ts +0 -129
  197. package/exporter/errors/index.ts +0 -40
  198. package/exporter/react/index.tsx +0 -11
  199. package/exporter/registers/api.ts +0 -14
  200. package/exporter/registers/gatsby.ts +0 -14
  201. package/exporter/registers/index.ts +0 -4
  202. package/exporter/services/register.ts +0 -113
  203. package/exporter/services/settings.ts +0 -17
  204. package/exporter/utils/alerts.ts +0 -29
  205. package/exporter/utils/api.ts +0 -243
  206. package/exporter/utils/cache.ts +0 -142
  207. package/exporter/utils/core-utils.ts +0 -458
  208. package/exporter/utils/create-build-data.ts +0 -17
  209. package/exporter/utils/domains.ts +0 -39
  210. package/exporter/utils/folders.ts +0 -320
  211. package/exporter/utils/health-checks.ts +0 -64
  212. package/exporter/utils/loggin.ts +0 -184
  213. package/exporter/utils/render.ts +0 -71
  214. package/exporter/utils/searches.ts +0 -156
  215. package/exporter/utils/sites.ts +0 -312
  216. package/exporter/utils/store.ts +0 -314
  217. package/src/README.md +0 -7
  218. package/start-render.js +0 -7
  219. /package/build/{utils → core}/instance.d.ts +0 -0
  220. /package/build/{constants → shared}/endpoints.d.ts +0 -0
  221. /package/exporter/{types → shared/types}/templates.ts +0 -0
  222. /package/{exporter/react/Favicon → react/GriddoFavicon}/utils.ts +0 -0
@@ -1,162 +0,0 @@
1
- import type {
2
- Artifacts,
3
- LifeCyclesNames,
4
- LifeCycleSteps,
5
- } from "../../types/global";
6
-
7
- import path from "node:path";
8
-
9
- import {
10
- createDistFromGatsbyPublic,
11
- getGatsbyAssetPrefixWithDomain,
12
- runGatsbyBuildCommand,
13
- } from "./utils";
14
- import getCxArtifacts from "../../artifacts";
15
- import { AuthService } from "../../services/auth";
16
- import {
17
- createDomainMetadata,
18
- doLifeCycle,
19
- getConfig,
20
- saveBuildEndLogs,
21
- } from "../../utils/core-utils";
22
- import { createDomainRenderData } from "../../utils/create-build-data";
23
- import {
24
- copyArtifacts,
25
- createArtifacts,
26
- deleteDisposableSiteDirs,
27
- moveArtifacts,
28
- removeArtifacts,
29
- removeVirtualPagesFromStore,
30
- renameArtifact,
31
- } from "../../utils/folders";
32
- import { infoLog } from "../../utils/loggin";
33
- import {
34
- createSentinelRenderFile,
35
- deleteSentinelRenderFile,
36
- isValidRender,
37
- } from "../../utils/render";
38
-
39
- /**
40
- * Render every instance domain with the Gatsby adapter.
41
- */
42
- export async function renderDomainsWithGatsbyAdapter(domain: string) {
43
- await AuthService.login();
44
- const config = getConfig();
45
-
46
- infoLog(`Initializing render for the domain ${domain}\n`);
47
-
48
- const {
49
- //
50
- __ssg,
51
- __exports,
52
- __cache,
53
- __cx,
54
- __components,
55
- } = config.paths(domain);
56
-
57
- // Griddo artifacts
58
- const cxArtifacts = getCxArtifacts(domain);
59
-
60
- // Gatsby artifacts
61
- const gatsbyArtifacts: Pick<Artifacts, "disposables" | "cacheables"> = {
62
- disposables: [
63
- path.join(__ssg, "public"),
64
- path.join(__ssg, "static"),
65
- path.join(__ssg, ".cache"),
66
- ],
67
- cacheables: [".cache"],
68
- };
69
-
70
- // These variables are involved in the build for create the dist directory
71
- // from public and pass to the gatsby-build command via spawnSync.
72
- const assetPrefix = getGatsbyAssetPrefixWithDomain(domain);
73
- const needsAssetPrefix = !!assetPrefix && assetPrefix !== "";
74
-
75
- // Compose artifacts
76
- const disposableArtifacts = [
77
- ...cxArtifacts.disposables,
78
- ...gatsbyArtifacts.disposables,
79
- ];
80
-
81
- // LifeCycles
82
-
83
- const allLifeCycles: Array<{
84
- name: LifeCyclesNames;
85
- steps: LifeCycleSteps;
86
- }> = [
87
- {
88
- name: "Init",
89
- steps: [() => createSentinelRenderFile()],
90
- },
91
-
92
- {
93
- name: "Clean",
94
- steps: [() => removeArtifacts(disposableArtifacts)],
95
- },
96
-
97
- {
98
- name: "Prepare",
99
- steps: [() => createArtifacts(cxArtifacts.initials)],
100
- },
101
-
102
- {
103
- name: "Restore",
104
- steps: [
105
- () => copyArtifacts(__components, __ssg, ["static"]),
106
- () => copyArtifacts(__exports, __cx, cxArtifacts.archivables),
107
- () =>
108
- renameArtifact(path.join(__cx, "dist"), path.join(__ssg, "public")),
109
- () => moveArtifacts(__cache, __cx, cxArtifacts.cacheables),
110
- () => moveArtifacts(__cache, __ssg, gatsbyArtifacts.cacheables),
111
- ],
112
- },
113
-
114
- {
115
- name: "Data",
116
- steps: [() => createDomainRenderData(domain)],
117
- },
118
-
119
- {
120
- name: "SSG",
121
- steps: [() => runGatsbyBuildCommand(assetPrefix)],
122
- },
123
-
124
- {
125
- name: "Relocation",
126
- steps: [() => createDistFromGatsbyPublic(domain, needsAssetPrefix)],
127
- },
128
-
129
- {
130
- name: "Meta",
131
- steps: [() => createDomainMetadata(domain), () => saveBuildEndLogs()],
132
- },
133
-
134
- {
135
- name: "Archive",
136
- steps: [
137
- () => removeVirtualPagesFromStore(),
138
- () => deleteDisposableSiteDirs(),
139
- () =>
140
- moveArtifacts(__cx, __exports, cxArtifacts.archivables, {
141
- withBackup: true,
142
- }),
143
- () => moveArtifacts(__cx, __cache, cxArtifacts.cacheables),
144
- () => moveArtifacts(__ssg, __cache, gatsbyArtifacts.cacheables),
145
- ],
146
- },
147
-
148
- {
149
- name: "Close",
150
- steps: [() => removeArtifacts(disposableArtifacts)],
151
- },
152
-
153
- {
154
- name: "HealthCheck",
155
- steps: [() => isValidRender(), () => deleteSentinelRenderFile()],
156
- },
157
- ];
158
-
159
- for (const { name, steps } of allLifeCycles) {
160
- await doLifeCycle(name, steps);
161
- }
162
- }
@@ -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,94 +0,0 @@
1
- /**
2
- * Here are all the environment variables that the CX code uses.
3
- */
4
-
5
- import dotenv from "dotenv";
6
-
7
- import { isTruthy } from "../utils/core-utils";
8
-
9
- dotenv.config();
10
-
11
- //
12
- // Credentials
13
- //
14
- /* prettier-ignore */ const GRIDDO_API_URL = process.env.GRIDDO_API_URL || process.env.API_URL;
15
- /* prettier-ignore */ const GRIDDO_PUBLIC_API_URL = process.env.GRIDDO_PUBLIC_API_URL || process.env.PUBLIC_API_URL;
16
- /* prettier-ignore */ const GRIDDO_BOT_USER = process.env.botEmail || process.env.GRIDDO_BOT_USER;
17
- /* prettier-ignore */ const GRIDDO_BOT_PASSWORD = process.env.botPassword|| process.env.GRIDDO_BOT_PASSWORD;
18
-
19
- //
20
- // Rendering
21
- //
22
- /* prettier-ignore */ const GRIDDO_API_CONCURRENCY_COUNT = Number.parseInt( process.env.GRIDDO_API_CONCURRENCY_COUNT || "10");
23
- /* prettier-ignore */ const GRIDDO_RENDER_ALL_SITES = isTruthy(process.env.GRIDDO_RENDER_ALL_SITES || process.env.updateAllSites);
24
- /* prettier-ignore */ const GRIDDO_RENDER_SITE = Number.parseInt(process.env.GRIDDO_RENDER_SITE || "")
25
- /* prettier-ignore */ const GRIDDO_RENDER_PAGES = (process.env.GRIDDO_RENDER_PAGES || "").split(",").map((item) => Number.parseInt(item)).filter(Boolean);
26
- /* prettier-ignore */ const GRIDDO_SKIP_BUILD_CHECKS = isTruthy(process.env.GRIDDO_SKIP_BUILD_CHECKS)
27
- /* prettier-ignore */ const GRIDDO_DEBUG_LOGS = isTruthy(process.env.GRIDDO_DEBUG_LOGS);
28
- /* prettier-ignore */ const GRIDDO_BUILD_LOGS = isTruthy(process.env.GRIDDO_BUILD_LOGS);
29
- /* prettier-ignore */ const GRIDDO_RENDER_BREAKPOINTS_FEATURE = isTruthy(process.env.GRIDDO_RENDER_BREAKPOINTS_FEATURE);
30
- /* prettier-ignore */ const GRIDDO_SSG_VERBOSE_LOGS = isTruthy(process.env.GRIDDO_SSG_VERBOSE_LOGS)
31
- /* prettier-ignore */ const GRIDDO_SEARCH_FEATURE = isTruthy(process.env.GRIDDO_SEARCH_FEATURE);
32
- /* prettier-ignore */ const GRIDDO_ASSET_PREFIX = process.env.GRIDDO_ASSET_PREFIX || process.env.ASSET_PREFIX;
33
- /* prettier-ignore */ const GRIDDO_REACT_APP_INSTANCE = process.env.GRIDDO_REACT_APP_INSTANCE || process.env.REACT_APP_INSTANCE;
34
- /* prettier-ignore */ const GRIDDO_AI_EMBEDDINGS = isTruthy(process.env.GRIDDO_AI_EMBEDDINGS);
35
- /* prettier-ignore */ const GRIDDO_VERBOSE_LOGS = isTruthy(process.env.GRIDDO_VERBOSE_LOGS);
36
- /* prettier-ignore */ const GRIDDO_ALERT_FEATURE = isTruthy(process.env.GRIDDO_ALERT_FEATURE);
37
- /* prettier-ignore */ const GRIDDO_API_MAX_RESPONSE_SIZE = Number.parseInt(process.env.GRIDDO_API_MAX_RESPONSE_SIZE || "81920") // 80KB
38
- /* prettier-ignore */ const GRIDDO_SSG_MAX_PAGE_SIZE = Number.parseInt(process.env.GRIDDO_SSG_MAX_PAGE_SIZE || "524288") // 512KB
39
-
40
- //
41
- // LifeCycle
42
- //
43
- /* prettier-ignore */ const GRIDDO_INIT_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_INIT_LIFECYCLE_MAX_ATTEMPTS || "1");
44
- /* prettier-ignore */ const GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS || "1");
45
- /* prettier-ignore */ const GRIDDO_CLOSE_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_CLOSE_LIFECYCLE_MAX_ATTEMPTS || "1");
46
- /* prettier-ignore */ const GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS || "1");
47
- /* prettier-ignore */ const GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS || "1");
48
- /* prettier-ignore */ const GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS || "1");
49
- /* prettier-ignore */ const GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS || "2");
50
- /* prettier-ignore */ const GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS || "1");
51
- /* prettier-ignore */ const GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS || "4");
52
- /* prettier-ignore */ const GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS || "1");
53
-
54
- //
55
- // Testing
56
- //
57
- /* prettier-ignore */ const GRIDDO_FIXTURES_DOMAIN_NAMES = process.env.GRIDDO_CX_FIXTURES_DOMAIN_NAMES;
58
- /* prettier-ignore */ const GRIDDO_FIXTURES_SITE_NAMES = process.env.GRIDDO_CX_FIXTURES_SITE_NAMES;
59
-
60
- export {
61
- GRIDDO_AI_EMBEDDINGS,
62
- GRIDDO_ALERT_FEATURE,
63
- GRIDDO_API_CONCURRENCY_COUNT,
64
- GRIDDO_API_MAX_RESPONSE_SIZE,
65
- GRIDDO_API_URL,
66
- GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS,
67
- GRIDDO_ASSET_PREFIX,
68
- GRIDDO_BOT_PASSWORD,
69
- GRIDDO_BOT_USER,
70
- GRIDDO_BUILD_LOGS,
71
- GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS,
72
- GRIDDO_CLOSE_LIFECYCLE_MAX_ATTEMPTS,
73
- GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS,
74
- GRIDDO_DEBUG_LOGS,
75
- GRIDDO_FIXTURES_DOMAIN_NAMES,
76
- GRIDDO_FIXTURES_SITE_NAMES,
77
- GRIDDO_INIT_LIFECYCLE_MAX_ATTEMPTS,
78
- GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS,
79
- GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS,
80
- GRIDDO_PUBLIC_API_URL,
81
- GRIDDO_REACT_APP_INSTANCE,
82
- GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS,
83
- GRIDDO_RENDER_ALL_SITES,
84
- GRIDDO_RENDER_BREAKPOINTS_FEATURE,
85
- GRIDDO_RENDER_PAGES,
86
- GRIDDO_RENDER_SITE,
87
- GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS,
88
- GRIDDO_SEARCH_FEATURE,
89
- GRIDDO_SKIP_BUILD_CHECKS,
90
- GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS,
91
- GRIDDO_SSG_MAX_PAGE_SIZE,
92
- GRIDDO_SSG_VERBOSE_LOGS,
93
- GRIDDO_VERBOSE_LOGS,
94
- };
@@ -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 };
@@ -1,40 +0,0 @@
1
- import type { ErrorsType } from "./errors-data";
2
-
3
- import kleur from "kleur";
4
-
5
- export type ErrorData = {
6
- error: ErrorsType;
7
- message: string;
8
- expected?: string;
9
- hint?: string;
10
- };
11
-
12
- export class RenderError extends Error {
13
- constructor() {
14
- super();
15
- this.name = "InternalCXError";
16
- this.stack = "";
17
- }
18
- }
19
-
20
- /**
21
- * Throws an error with the provided error message, expected value, and hint.
22
- */
23
- function throwError(options: ErrorData, stack?: unknown) {
24
- const { error, message, expected, hint } = options;
25
-
26
- const errorColor = kleur.red("[ " + error + " ]");
27
- const extraText = [expected, hint].filter(Boolean).join("\n");
28
-
29
- console.log(`
30
- ${errorColor}
31
- ${message}
32
- ${extraText}
33
-
34
- ${kleur.red("stack")}
35
- ${JSON.stringify(stack, null, 2)}`);
36
-
37
- throw new RenderError();
38
- }
39
-
40
- export { throwError };
@@ -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;