@griddo/cx 10.4.21 → 10.4.23

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 (49) hide show
  1. package/build/adapters/gatsby/utils.d.ts +21 -15
  2. package/build/browser/index.d.ts +1 -1
  3. package/build/browser/index.js +1 -1
  4. package/build/build-complete.js +21 -21
  5. package/build/index.d.ts +2 -3
  6. package/build/index.js +30 -34
  7. package/build/react/Foo/index.d.ts +3 -0
  8. package/build/react/index.d.ts +1 -1
  9. package/build/react/index.js +1 -0
  10. package/build/reset-render.js +21 -21
  11. package/build/run-start-render.js +29 -33
  12. package/build/start-render.js +30 -34
  13. package/build/types/global.d.ts +1 -0
  14. package/build/upload-search-content.js +22 -22
  15. package/build/utils/{shared.d.ts → core-utils.d.ts} +44 -2
  16. package/build/utils/folders.d.ts +6 -1
  17. package/build/utils/store.d.ts +1 -1
  18. package/cx.config.js +7 -0
  19. package/exporter/adapters/gatsby/index.ts +67 -14
  20. package/exporter/adapters/gatsby/utils.ts +116 -31
  21. package/exporter/browser/index.ts +1 -1
  22. package/exporter/build-complete.ts +5 -5
  23. package/exporter/index.ts +6 -5
  24. package/exporter/react/Foo/index.tsx +7 -0
  25. package/exporter/react/index.tsx +3 -0
  26. package/exporter/services/distributors.ts +1 -1
  27. package/exporter/services/robots.ts +1 -1
  28. package/exporter/services/store.ts +9 -16
  29. package/exporter/start-render.ts +1 -1
  30. package/exporter/types/global.ts +1 -0
  31. package/exporter/utils/api.ts +1 -1
  32. package/exporter/utils/cache.ts +1 -1
  33. package/exporter/utils/{shared.ts → core-utils.ts} +120 -20
  34. package/exporter/utils/create-build-data.ts +1 -1
  35. package/exporter/utils/domains.ts +3 -0
  36. package/exporter/utils/folders.ts +38 -2
  37. package/exporter/utils/health-checks.ts +1 -1
  38. package/exporter/utils/searches.ts +1 -1
  39. package/exporter/utils/sites.ts +12 -18
  40. package/exporter/utils/store.ts +2 -3
  41. package/gatsby-config.ts +10 -6
  42. package/gatsby-node.ts +20 -11
  43. package/package.json +8 -5
  44. package/src/components/template.tsx +2 -1
  45. package/src/gatsby-node-utils.ts +2 -39
  46. package/src/types.ts +6 -7
  47. package/build/utils/temp-utils.d.ts +0 -10
  48. package/exporter/react/index.ts +0 -5
  49. package/exporter/utils/temp-utils.ts +0 -103
@@ -1,32 +1,127 @@
1
1
  import type { Adapters } from "../adapters";
2
2
  import type { APIResponses } from "../types/api";
3
- import type { LifeCyclesNames } from "../types/global";
3
+ import type { CXConfig, LifeCyclesNames } from "../types/global";
4
4
  import type { APIPageObject } from "../types/pages";
5
5
  import type { Site } from "../types/sites";
6
6
 
7
+ import fs from "node:fs";
7
8
  import path from "node:path";
8
9
 
9
10
  import chalk from "chalk";
10
11
  import dotenv from "dotenv";
11
- import fs from "fs-extra";
12
+ import fsx from "fs-extra";
12
13
  import gradient from "gradient-string";
13
14
  import pkgDir from "pkg-dir";
14
15
 
15
- import { getConfig } from "./temp-utils";
16
+ import { createDirsSync, removeDirsSync } from "./folders";
17
+
18
+ dotenv.config();
16
19
 
17
20
  const config = getConfig();
18
21
 
19
- dotenv.config();
22
+ const GRIDDO_DEBUG_LOGS = isTruthy(process.env.GRIDDO_DEBUG_LOGS);
23
+ const GRIDDO_BUILD_LOGS = isTruthy(process.env.GRIDDO_BUILD_LOGS);
20
24
 
21
- const GRIDDO_DEBUG_LOGS =
22
- !!process.env.GRIDDO_DEBUG_LOGS &&
23
- !!JSON.parse(process.env.GRIDDO_DEBUG_LOGS);
24
- const GRIDDO_BUILD_LOGS =
25
- (!!process.env.GRIDDO_BUILD_LOGS &&
26
- !!JSON.parse(process.env.GRIDDO_BUILD_LOGS)) ||
27
- (!!process.env.LOGS && !!JSON.parse(process.env.LOGS));
28
25
  const instanceRootDir = pkgDir.sync()!; // instance root dir
29
26
 
27
+ const attempts = {
28
+ clean: JSON.parse(process.env.GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS || "1"),
29
+ prepare: JSON.parse(process.env.GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS || "1"),
30
+ restore: JSON.parse(process.env.GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS || "1"),
31
+ data: JSON.parse(process.env.GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS || "1"),
32
+ ssg: JSON.parse(process.env.GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS || "2"),
33
+ relocation: JSON.parse(
34
+ process.env.GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS || "1"
35
+ ),
36
+ meta: JSON.parse(process.env.GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS || "4"),
37
+ archive: JSON.parse(process.env.GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS || "1"),
38
+ };
39
+
40
+ /**
41
+ * Returns the configuration file content.
42
+ *
43
+ * @example
44
+ * const config = getConfig()
45
+ * const { __cx } = config.paths()
46
+ * const { griddoVersion, proDomain } = config
47
+ */
48
+ function getConfig(): CXConfig {
49
+ try {
50
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, node/no-missing-require, node/no-unpublished-require
51
+ const configModule = require("../../cx.config.js");
52
+ const config = configModule.default;
53
+
54
+ return config;
55
+ } catch (error) {
56
+ console.log("Error while reading configuration file");
57
+ process.exit(1);
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Create the initial mandatory directories for a render.
63
+ *
64
+ * @param domain The current domain in render.
65
+ */
66
+ async function exporterCreateInitialDirectories(domain: string) {
67
+ const { __exports, __caches } = config.paths(domain);
68
+
69
+ createDirsSync([__exports]);
70
+ verbose("create `exports/sites/<domain>` directory");
71
+ createDirsSync([__caches]);
72
+ verbose("create `caches/<domain>` directory");
73
+ }
74
+
75
+ /**
76
+ * Remove trash directories from __cx, maybe from a failed render.
77
+ *
78
+ * @param domain The current domain in render.
79
+ */
80
+ async function exporterCleanDisposableDirectories(domain: string) {
81
+ const { __cx } = config.paths(domain);
82
+
83
+ removeDirsSync(__cx, ["store", "apiCache", "dist"]);
84
+ verbose("clean `store`, `apiCache` and `dist` directories from `__cx`");
85
+ }
86
+
87
+ /**
88
+ * Custom basic logging function controlled by a environment variable.
89
+ *
90
+ * @param str The string to be logged.
91
+ */
92
+ function verbose(str: string) {
93
+ if (GRIDDO_DEBUG_LOGS) {
94
+ console.log(
95
+ chalk.hex("#ffff33")("verbose"),
96
+ chalk.gray(str.replace(/(\s)\s+/g, "$1").trim())
97
+ );
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Returns true for `true`, true, positive numbers
103
+ * Returns false for `false`, false, 0, negative integers and anything else
104
+ */
105
+ function isTruthy(value: any): boolean {
106
+ // Return if Boolean
107
+ if (typeof value === `boolean`) return value;
108
+
109
+ // Return false if null or undefined
110
+ if (value === undefined || value === null) return false;
111
+
112
+ // If the String is true or false
113
+ if (value.toLowerCase() === `true`) return true;
114
+ if (value.toLowerCase() === `false`) return false;
115
+
116
+ // Now check if it's a number
117
+ const number = parseInt(value, 10);
118
+ if (isNaN(number)) return false;
119
+ if (number > 0) return true;
120
+
121
+ // Default to false
122
+ return false;
123
+ }
124
+
30
125
  /**
31
126
  * Walk a directory and returns the file pathts.
32
127
  *
@@ -92,7 +187,7 @@ function logBox(
92
187
  */
93
188
  function logInfo(str: string) {
94
189
  if (GRIDDO_BUILD_LOGS) {
95
- console.info(str.replace(/(\s)\s+/g, "$1"));
190
+ console.info(str.replace(/(\s)\s+/g, "$1").trim());
96
191
  }
97
192
  }
98
193
 
@@ -191,14 +286,13 @@ function siteList(sites: Array<Site>) {
191
286
  * Print the great Griddo Exporter logo in ASCII.
192
287
  */
193
288
  function printExporterLogo(adapter: Adapters) {
194
- const { __cx } = config.paths();
195
- const { version } = JSON.parse(
196
- fs.readFileSync(path.join(__cx, "package.json"), "utf-8")
197
- );
289
+ const nodeVersion = process.version;
290
+ const { griddoVersion } = config;
198
291
  const logo = `
199
292
  ··
200
- ·· Griddo Exporter ${version}
293
+ ·· Griddo Exporter ${griddoVersion}
201
294
  ·· Adapter: ${adapter}
295
+ ·· Node: ${nodeVersion}
202
296
  ··
203
297
  `;
204
298
 
@@ -224,7 +318,7 @@ function sanitizeAPICacheDir() {
224
318
  // We only need files that describes a page object.
225
319
  const pageFilePaths = allCachedFiles.filter((fileName) => {
226
320
  const filePath = `${dirPath}/${fileName}`;
227
- const fileObject = fs.readJSONSync(filePath, "utf-8") as APIPageObject;
321
+ const fileObject = fsx.readJSONSync(filePath, "utf-8") as APIPageObject;
228
322
  const { id, entity, fullUrl } = fileObject;
229
323
 
230
324
  // Is a page file if has id, entity and fullUrl
@@ -234,7 +328,7 @@ function sanitizeAPICacheDir() {
234
328
  // Fill the filesById object
235
329
  for (const fileName of pageFilePaths) {
236
330
  const filePath = `${dirPath}/${fileName}`;
237
- const fileObject = fs.readJSONSync(filePath, "utf-8") as APIPageObject;
331
+ const fileObject = fsx.readJSONSync(filePath, "utf-8") as APIPageObject;
238
332
  const fileCreationDate = fs.statSync(filePath).mtimeMs;
239
333
 
240
334
  const { id } = fileObject;
@@ -254,7 +348,7 @@ function sanitizeAPICacheDir() {
254
348
  // Delete files using the store object filesById as reference map.
255
349
  for (const fileName of pageFilePaths) {
256
350
  const filePath = `${dirPath}/${fileName}`;
257
- const fileObject = fs.readJSONSync(filePath, "utf-8") as APIPageObject;
351
+ const fileObject = fsx.readJSONSync(filePath, "utf-8") as APIPageObject;
258
352
 
259
353
  const { id } = fileObject;
260
354
 
@@ -382,10 +476,15 @@ function isVersionLowerThan(versionA: string, versionB: string) {
382
476
  }
383
477
 
384
478
  export {
479
+ attempts,
385
480
  debug,
386
481
  delay,
387
482
  doLifeCycle,
483
+ exporterCleanDisposableDirectories,
484
+ exporterCreateInitialDirectories,
485
+ getConfig,
388
486
  instanceRootDir,
487
+ isTruthy,
389
488
  isVersionGreaterThan,
390
489
  isVersionLowerThan,
391
490
  logBox,
@@ -399,5 +498,6 @@ export {
399
498
  siteList,
400
499
  startLifeCycle,
401
500
  successLifeCyle,
501
+ verbose,
402
502
  walk,
403
503
  };
@@ -1,5 +1,5 @@
1
1
  import { createAPICacheDir } from "./cache";
2
- import { sanitizeAPICacheDir } from "./shared";
2
+ import { sanitizeAPICacheDir } from "./core-utils";
3
3
  import { createStore } from "../services/store";
4
4
 
5
5
  /**
@@ -1,5 +1,6 @@
1
1
  import type { Domains } from "../types/global";
2
2
 
3
+ import { verbose } from "./core-utils";
3
4
  import { AuthService } from "../services/auth";
4
5
  import { DomainsService } from "../services/domains";
5
6
 
@@ -10,6 +11,8 @@ async function getInstanceDomains() {
10
11
  await AuthService.login();
11
12
  const domains = await DomainsService.getAll();
12
13
 
14
+ verbose(`Getting domains slugs (${domains.length})`);
15
+
13
16
  return getDomainSlugs(domains);
14
17
  }
15
18
 
@@ -3,8 +3,8 @@ import path from "node:path";
3
3
 
4
4
  import fsx, { MakeDirectoryOptions } from "fs-extra";
5
5
 
6
+ import { getConfig } from "./core-utils";
6
7
  import { getPageInStoreDir, removePagesFromStore } from "./store";
7
- import { getConfig } from "./temp-utils";
8
8
 
9
9
  const config = getConfig();
10
10
 
@@ -115,7 +115,9 @@ function copyDirsSync(
115
115
  fs.rmSync(dstCompose, { recursive: true, force: true });
116
116
  }
117
117
  // Then copy src to dst
118
- fs.cpSync(srcCompose, dstCompose, { recursive: true });
118
+ fs.cpSync(srcCompose, dstCompose, {
119
+ recursive: true,
120
+ });
119
121
  if (withBackup) {
120
122
  deleteBackup(dstCompose);
121
123
  }
@@ -257,8 +259,42 @@ async function removeVirtualPagesFromStore() {
257
259
  }
258
260
  }
259
261
 
262
+ /**
263
+ * Remove every .xml file in the directories in a recursive way
264
+ * @param initialFolder - The initial folder to start the searching...
265
+ */
266
+ function clearSitemapsFromDirs(initialFolder: string) {
267
+ // Recursively remove .xml files
268
+
269
+ function removeXmlFiles(folder: string): void {
270
+ try {
271
+ // Read the content of the directory
272
+ const files = fs.readdirSync(folder);
273
+ // Iterate over each file/folder in the directory
274
+ for (const file of files) {
275
+ const fullPath = path.join(folder, file);
276
+ // Check if the current path is a directory or file
277
+ const stats = fs.statSync(fullPath);
278
+ if (stats.isDirectory()) {
279
+ // Recursively call removeXmlFiles if it's a directory
280
+ removeXmlFiles(fullPath);
281
+ } else if (stats.isFile() && path.extname(fullPath) === ".xml") {
282
+ // Remove the file if it's an .xml file
283
+ fs.unlinkSync(fullPath);
284
+ }
285
+ }
286
+ } catch (err) {
287
+ console.error(`Error processing directory: ${folder}`, err);
288
+ }
289
+ }
290
+
291
+ // Start the process from the initial folder
292
+ removeXmlFiles(initialFolder);
293
+ }
294
+
260
295
  export {
261
296
  clearEmptyDirs,
297
+ clearSitemapsFromDirs,
262
298
  copyDirsSync,
263
299
  createDirsSync,
264
300
  moveDirsSync,
@@ -1,4 +1,4 @@
1
- import { logBox } from "./shared";
1
+ import { logBox } from "./core-utils";
2
2
 
3
3
  const GRIDDO_SKIP_BUILD_CHECKS = process.env.GRIDDO_SKIP_BUILD_CHECKS;
4
4
  const GRIDDO_ENVS_VARS: ReadonlyArray<string> = [];
@@ -5,8 +5,8 @@ import fs from "node:fs";
5
5
  import path from "node:path";
6
6
 
7
7
  import { post } from "./api";
8
+ import { getConfig } from "./core-utils";
8
9
  import { getBuildPagesFromCachedStore } from "./store";
9
- import { getConfig } from "./temp-utils";
10
10
 
11
11
  // Envs
12
12
  const API_URL = process.env.API_URL as string;
@@ -5,9 +5,8 @@ import path from "node:path";
5
5
  import fs from "fs-extra";
6
6
  import { parse } from "js2xmlparser";
7
7
 
8
- import { logInfo } from "./shared";
8
+ import { getConfig, logInfo } from "./core-utils";
9
9
  import { getBuildMetadata } from "./store";
10
- import { getConfig } from "./temp-utils";
11
10
  import { AuthService } from "../services/auth";
12
11
  import { SitesService } from "../services/sites";
13
12
 
@@ -184,33 +183,32 @@ async function generateSitemaps() {
184
183
  const { __cx } = config.paths();
185
184
  const distDir = path.join(__cx, "dist");
186
185
 
187
- const promisesOfSites = sitesToPublish.map(async (site) => {
186
+ for (const site of sitesToPublish) {
188
187
  const { id: siteID, languages } = site;
189
188
 
190
- const promisesOfLanguages = languages.map(async (lang) => {
189
+ for (const lang of languages) {
191
190
  if (AuthService.headers) AuthService.headers["lang"] = lang.id.toString();
192
191
 
193
192
  const response = await SitesService.getSitemap(siteID);
194
193
 
195
- if (!response) return;
194
+ if (!response) continue;
196
195
 
197
196
  const {
198
197
  items: sitemapPagesGroup,
199
198
  url: { home, domain },
200
199
  } = response;
201
200
 
202
- if (!home) return;
201
+ if (!home) continue;
203
202
 
204
203
  const langDomain = site.domains.find(
205
204
  (domain) => Object.keys(domain)[0] == lang.id.toString()
206
205
  );
207
206
 
208
- if (!langDomain) return;
207
+ if (!langDomain) continue;
209
208
 
210
209
  const slug = Object.values(langDomain)[0];
211
210
  const sitemaps: Array<string> = [];
212
211
  const sitemapPageGroupKeys = Object.keys(sitemapPagesGroup);
213
-
214
212
  const sitemapBasePath = path.join(distDir, slug.replace(domain, ""));
215
213
 
216
214
  for (const templateId of sitemapPageGroupKeys) {
@@ -227,9 +225,9 @@ async function generateSitemaps() {
227
225
  },
228
226
  url: sitemapPages,
229
227
  });
230
- const sitemapName = `/sitemap-${templateId.toLowerCase()}.xml`;
231
228
 
232
- const exactPath = `${sitemapBasePath}${sitemapName}`;
229
+ const sitemapName = `/sitemap-${templateId.toLowerCase()}.xml`;
230
+ const exactPath = path.join(sitemapBasePath, sitemapName);
233
231
 
234
232
  saveFile(exactPath, siteMap);
235
233
 
@@ -238,22 +236,18 @@ async function generateSitemaps() {
238
236
  );
239
237
  }
240
238
 
241
- if (!sitemaps.length) return;
239
+ if (!sitemaps.length) continue;
242
240
 
243
241
  const siteMap = parse("sitemapindex", {
244
242
  "@": { xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9" },
245
243
  sitemap: sitemaps.map((loc) => ({ loc })),
246
244
  });
247
245
 
248
- const exactPath = `${sitemapBasePath}/sitemap.xml`;
246
+ const exactPath = path.join(sitemapBasePath, "sitemap.xml");
249
247
 
250
248
  saveFile(exactPath, siteMap);
251
- });
252
-
253
- return Promise.all(promisesOfLanguages);
254
- });
255
-
256
- await Promise.all(promisesOfSites);
249
+ }
250
+ }
257
251
  }
258
252
 
259
253
  /**
@@ -8,8 +8,7 @@ import path from "node:path";
8
8
 
9
9
  import fsx from "fs-extra";
10
10
 
11
- import { removeProperties, walk } from "./shared";
12
- import { getConfig } from "./temp-utils";
11
+ import { getConfig, removeProperties, walk } from "./core-utils";
13
12
 
14
13
  const config = getConfig();
15
14
 
@@ -295,9 +294,9 @@ async function getPagesToCreateOrDelete(
295
294
  export {
296
295
  createStoreDir,
297
296
  getBuildMetadata,
298
- getBuildPagesPath,
299
297
  getBuildPagesFromCachedStore,
300
298
  getBuildPagesFromStore,
299
+ getBuildPagesPath,
301
300
  getPageInStoreDir,
302
301
  getPagesToCreateOrDelete,
303
302
  removePagesFromStore,
package/gatsby-config.ts CHANGED
@@ -2,13 +2,17 @@ import type { GatsbyConfig } from "gatsby";
2
2
 
3
3
  import dotenv from "dotenv";
4
4
 
5
- import { resolveComponentsPath } from "./build";
5
+ import { resolveComponentsPath, verbose } from "./build";
6
6
 
7
7
  dotenv.config();
8
8
 
9
- // Este process.env.GRIDDO_ASSET_PREFIX se lee porque se ha introducido en
10
- // `getEnvRunner()`.
11
- const GRIDDO_ASSET_PREFIX = process.env.LOCAL_GRIDDO_ASSET_PREFIX || undefined;
9
+ // Este process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN se lee porque
10
+ // se ha introducido en el spawnSync.
11
+ // @todo quiar el `... || undefined`
12
+ const griddoAssetPrefixWithDomain =
13
+ process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN || undefined;
14
+
15
+ verbose(`set config.assetPrefix=${griddoAssetPrefixWithDomain}`);
12
16
 
13
17
  // Gatsby configuration file from client
14
18
  // eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -40,8 +44,8 @@ const config: GatsbyConfig = {
40
44
  ],
41
45
  };
42
46
 
43
- if (GRIDDO_ASSET_PREFIX) {
44
- config.assetPrefix = GRIDDO_ASSET_PREFIX;
47
+ if (griddoAssetPrefixWithDomain) {
48
+ config.assetPrefix = griddoAssetPrefixWithDomain;
45
49
  // @ts-expect-error Must be null to exist, but must be different from assetPrefix
46
50
  config.pathPrefix = null;
47
51
  }
package/gatsby-node.ts CHANGED
@@ -3,33 +3,42 @@ import type { GatsbyNode } from "gatsby";
3
3
 
4
4
  import path from "node:path";
5
5
 
6
- import { getConfig, logInfo, logPageSize } from "./build";
7
- import { getBuildPagesFromStore } from "./exporter/utils/store";
8
- import { getMatchPath } from "./src/gatsby-node-utils";
9
-
10
- const GRIDDO_BUILD_LOGS = JSON.parse(process.env.GRIDDO_BUILD_LOGS || "false");
6
+ import {
7
+ getBuildPagesFromStore,
8
+ getConfig,
9
+ logInfo,
10
+ logPageSize,
11
+ verbose,
12
+ } from "./build";
13
+
14
+ const griddoBuildLogs = JSON.parse(process.env.GRIDDO_BUILD_LOGS || "false");
15
+ const assetPrefixWithDomain = process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN;
16
+ const needsAssetDomainPrefix =
17
+ !!assetPrefixWithDomain && assetPrefixWithDomain !== "";
11
18
 
12
19
  const { __ssg } = getConfig().paths();
13
20
  const template = path.join(__ssg, "src/components/template.tsx");
14
21
  const pages = getBuildPagesFromStore<GatsbyPageObject>({
15
- withSizeProp: GRIDDO_BUILD_LOGS,
22
+ withSizeProp: griddoBuildLogs,
16
23
  });
17
24
 
18
25
  const createPages: GatsbyNode["createPages"] = async ({ actions }) => {
26
+ verbose(`read assetPrefixWithDomain=${assetPrefixWithDomain}`);
27
+ verbose(`set needsAssetDomainPrefix=${needsAssetDomainPrefix}`);
28
+
19
29
  for await (const page of pages) {
20
30
  if (!page) return;
21
31
 
22
- const matchPath = getMatchPath(
23
- page.context.fullPath.domain,
24
- page.context.fullPath.compose
25
- );
32
+ const matchPath = needsAssetDomainPrefix
33
+ ? page.context.fullPath.compose
34
+ : "";
26
35
 
27
36
  page.component = template;
28
37
  page.matchPath = matchPath;
29
38
 
30
39
  actions.createPage(page);
31
40
 
32
- if (GRIDDO_BUILD_LOGS) {
41
+ if (griddoBuildLogs) {
33
42
  const path = page.path;
34
43
  const id = page.context.id;
35
44
  const size = logPageSize(Math.round(page.size || 0));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/cx",
3
3
  "description": "Griddo SSG based on Gatsby",
4
- "version": "10.4.21",
4
+ "version": "10.4.23",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -19,7 +19,7 @@
19
19
  "griddo-cx": "./start-render.js"
20
20
  },
21
21
  "scripts": {
22
- "build": "yarn build:exporter && yarn build:reset-render && yarn build:build-complete && yarn build:start-render && yarn build:run-start-render && yarn build:browser && yarn build:upload-search-content && yarn build:types",
22
+ "build": "yarn build:exporter && yarn build:reset-render && yarn build:build-complete && yarn build:start-render && yarn build:run-start-render && yarn build:browser && yarn build:upload-search-content && yarn build:react && yarn build:types",
23
23
  "build:upload-search-content": "esbuild ./exporter/upload-search-content.ts --bundle --platform=node --minify --outfile=./build/upload-search-content.js",
24
24
  "build:exporter": "esbuild ./exporter/index.ts --bundle --platform=node --minify --outfile=./build/index.js",
25
25
  "build:build-complete": "esbuild ./exporter/build-complete.ts --bundle --platform=node --minify --outfile=./build/build-complete.js",
@@ -27,6 +27,7 @@
27
27
  "build:start-render": "esbuild ./exporter/start-render.ts --bundle --platform=node --minify --outfile=./build/start-render.js",
28
28
  "build:run-start-render": "esbuild ./exporter/run-start-render.ts --bundle --platform=node --minify --outfile=./build/run-start-render.js",
29
29
  "build:browser": "esbuild ./exporter/browser/index.ts --platform=node --bundle --minify --outfile=./build/browser/index.js",
30
+ "build:react": "esbuild ./exporter/react/index.tsx --platform=node --external:@griddo-instance --external:react --external:react-dom --bundle --minify --outfile=./build/react/index.js",
30
31
  "build:types": "npx tsc --emitDeclarationOnly --declaration --outDir build --project tsconfig.exporter.json",
31
32
  "export:complete": "node ./build/build-complete.js",
32
33
  "export:reset": "node ./build/reset-render.js",
@@ -34,7 +35,9 @@
34
35
  "watch:tscheck": "tsc --noEmit --watch",
35
36
  "complete-render": "node ./build/build-complete.js",
36
37
  "reset-render": "node ./build/reset-render.js",
37
- "test": "tsx ./__tests__/tests-health.ts && jest --verbose",
38
+ "test:create-render-fixtures": "tsx ./__tests__/utils/create-fixtures.ts",
39
+ "test:remove-render-fixtures": "tsx ./__tests__/utils/remove-fixtures.ts",
40
+ "test": "tsx ./__tests__/utils/tests-health.ts && jest --verbose",
38
41
  "upload-search-content": "node ./build/upload-search-content.js",
39
42
  "clean": "gatsby clean; rm -rf .cache public assets",
40
43
  "gatsby-build": "gatsby telemetry --disable && gatsby build --prefix-paths"
@@ -45,7 +48,7 @@
45
48
  "@babel/preset-env": "^7.14.5",
46
49
  "@babel/preset-react": "^7.14.5",
47
50
  "@babel/preset-typescript": "^7.16.5",
48
- "@griddo/core": "^10.4.21",
51
+ "@griddo/core": "^10.4.23",
49
52
  "@svgr/webpack": "^5.5.0",
50
53
  "@types/cheerio": "^0.22.35",
51
54
  "babel-loader": "^8.0.6",
@@ -120,5 +123,5 @@
120
123
  "resolutions": {
121
124
  "memoizee": "0.4.15"
122
125
  },
123
- "gitHead": "e9ee5308a0c6829e0e3c0c82d28f5e580d0bb804"
126
+ "gitHead": "f9661d6520228413159145fc76f70e0c6c358512"
124
127
  }
@@ -1,6 +1,7 @@
1
1
  import type { TemplateProps } from "../types";
2
+ import type { Core } from "@griddo/core";
2
3
 
3
- import { Core, Page as RenderGriddoPage } from "@griddo/core";
4
+ import { Page as RenderGriddoPage } from "@griddo/core";
4
5
  import { components, SiteProvider, templates } from "@griddo-instance";
5
6
  import { Link, navigate } from "gatsby";
6
7
  import parse from "html-react-parser";
@@ -2,12 +2,11 @@ import type { GatsbyNode } from "gatsby";
2
2
 
3
3
  import fs from "fs-extra";
4
4
 
5
- import { getConfig } from "../build";
6
5
  import {
7
6
  IS_COMPONENT_LIBRARY,
8
7
  PROJECT_ALIASES,
9
8
  resolveComponentsPath,
10
- } from "../exporter/utils/instance";
9
+ } from "../build";
11
10
 
12
11
  /**
13
12
  * Copy the instance's `/static` dir into the Gatsby's to include it in the render assets.
@@ -72,40 +71,4 @@ const onCreateWebpackConfig: GatsbyNode["onCreateWebpackConfig"] = ({
72
71
  }
73
72
  };
74
73
 
75
- function getGatsbyAssetPrefixSlug(domain: string) {
76
- const { proDomain } = getConfig();
77
-
78
- const assetPrefix =
79
- process.env.GRIDDO_ASSET_PREFIX || process.env.ASSET_PREFIX;
80
- if (!assetPrefix || !domain) return "";
81
- if (!domain.startsWith(proDomain)) return "";
82
-
83
- return `${assetPrefix}/${domain}`;
84
- }
85
-
86
- // @todo: Arreglar esta movida de variables de entorno locales solo para Gatsby
87
- function getLocalGatsbyAssetPrefixSlug(domain: string) {
88
- const { proDomain } = getConfig();
89
-
90
- const assetPrefix = process.env.LOCAL_GRIDDO_ASSET_PREFIX;
91
- if (!assetPrefix || !domain) return "";
92
- if (!domain.startsWith(proDomain)) return "";
93
-
94
- return `${assetPrefix}/${domain}`;
95
- }
96
-
97
- function getMatchPath(domain: string, compose: string) {
98
- const domainWithNoSlashes = domain.replace("/", "");
99
- const assetPrefix = getLocalGatsbyAssetPrefixSlug(domainWithNoSlashes);
100
- const needsAssetDomainPrefix = assetPrefix && assetPrefix !== "";
101
- const matchPath = needsAssetDomainPrefix ? compose : "";
102
-
103
- return matchPath;
104
- }
105
-
106
- export {
107
- getGatsbyAssetPrefixSlug,
108
- getMatchPath,
109
- onCreateWebpackConfig,
110
- prepareStaticDir,
111
- };
74
+ export { onCreateWebpackConfig, prepareStaticDir };
package/src/types.ts CHANGED
@@ -1,15 +1,14 @@
1
- import type { Core } from "@griddo/core";
2
- import type { HeadProps } from "gatsby";
3
-
4
- import { SocialsResponse } from "../build";
5
- import {
1
+ import type {
6
2
  AdditionalInfo,
7
3
  GriddoListPage,
8
4
  GriddoMultiPage,
9
5
  GriddoPageObject,
10
6
  GriddoSinglePage,
11
- } from "../exporter/types/pages";
12
- import { Site } from "../exporter/types/sites";
7
+ Site,
8
+ SocialsResponse,
9
+ } from "../build";
10
+ import type { Core } from "@griddo/core";
11
+ import type { HeadProps } from "gatsby";
13
12
 
14
13
  interface CustomHeadProps extends HeadProps {
15
14
  pageContext: GriddoPageObject["context"] & {
@@ -1,10 +0,0 @@
1
- import { CXConfig } from "../types/global";
2
- declare function getConfig(): CXConfig;
3
- /**
4
- * Update the Griddo's `/dist` dir with the contents from `public` dir only
5
- * with files of type: js, json and css.
6
- */
7
- declare function legacy__createDistFromGatsbyPublic(domain: string, needsAssetPrefix: boolean): Promise<void>;
8
- declare function griddoCreateInitialDirectories(domain: string): Promise<void>;
9
- declare function griddoCleanDisposableDirectories(domain: string): Promise<void>;
10
- export { getConfig, griddoCleanDisposableDirectories, griddoCreateInitialDirectories, legacy__createDistFromGatsbyPublic, };
@@ -1,5 +0,0 @@
1
- function Foo() {
2
- return null;
3
- }
4
-
5
- export { Foo };