@griddo/cx 10.6.3 → 10.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +0 -2
  2. package/build/adapters/gatsby/index.d.ts +1 -1
  3. package/build/build-complete.js +69 -30
  4. package/build/constants/endpoints.d.ts +18 -0
  5. package/build/constants/envs.d.ts +33 -0
  6. package/build/constants/index.d.ts +53 -0
  7. package/build/index.d.ts +4 -3
  8. package/build/index.js +90 -49
  9. package/build/reset-render.js +69 -30
  10. package/build/run-start-render.js +90 -49
  11. package/build/services/settings.d.ts +3 -22
  12. package/build/services/sites.d.ts +34 -36
  13. package/build/start-render.js +90 -49
  14. package/build/types/global.d.ts +1 -1
  15. package/build/upload-search-content.js +70 -31
  16. package/build/utils/core-utils.d.ts +9 -60
  17. package/build/utils/domains.d.ts +5 -1
  18. package/build/utils/loggin.d.ts +49 -0
  19. package/build/utils/render.d.ts +11 -0
  20. package/cx.config.js +3 -4
  21. package/exporter/adapters/gatsby/index.ts +95 -257
  22. package/exporter/adapters/gatsby/utils.ts +11 -10
  23. package/exporter/browser/index.ts +4 -4
  24. package/exporter/constants/endpoints.ts +42 -0
  25. package/exporter/constants/envs.ts +86 -0
  26. package/exporter/constants/index.ts +120 -0
  27. package/exporter/errors/index.ts +2 -2
  28. package/exporter/index.ts +11 -10
  29. package/exporter/react/GriddoIntegrations/index.tsx +3 -3
  30. package/exporter/{build-complete.ts → scripts/build-complete.ts} +4 -4
  31. package/exporter/{reset-render.ts → scripts/reset-render.ts} +3 -3
  32. package/exporter/scripts/start-render.ts +26 -0
  33. package/exporter/{upload-search-content.ts → scripts/upload-search-content.ts} +3 -3
  34. package/exporter/services/auth.ts +7 -5
  35. package/exporter/services/distributors.ts +12 -18
  36. package/exporter/services/domains.ts +2 -12
  37. package/exporter/services/navigation.ts +10 -8
  38. package/exporter/services/robots.ts +2 -6
  39. package/exporter/services/settings.ts +7 -44
  40. package/exporter/services/sites.ts +115 -159
  41. package/exporter/services/store.ts +24 -29
  42. package/exporter/types/api.ts +1 -1
  43. package/exporter/types/global.ts +1 -0
  44. package/exporter/utils/api.ts +11 -10
  45. package/exporter/utils/core-utils.ts +49 -180
  46. package/exporter/utils/domains.ts +21 -3
  47. package/exporter/utils/folders.ts +3 -3
  48. package/exporter/utils/health-checks.ts +4 -4
  49. package/exporter/utils/instance.ts +3 -3
  50. package/exporter/utils/integrations.ts +12 -12
  51. package/exporter/utils/loggin.ts +159 -0
  52. package/exporter/utils/pages.ts +15 -15
  53. package/exporter/utils/render.ts +49 -0
  54. package/exporter/utils/searches.ts +5 -5
  55. package/exporter/utils/sites.ts +42 -48
  56. package/exporter/utils/store.ts +9 -9
  57. package/gatsby-browser.tsx +46 -48
  58. package/gatsby-config.ts +5 -5
  59. package/gatsby-node.ts +7 -7
  60. package/package.json +21 -26
  61. package/src/components/Head.tsx +1 -1
  62. package/src/gatsby-node-utils.ts +1 -1
  63. package/src/utils.ts +1 -1
  64. package/exporter/start-render.ts +0 -18
  65. /package/build/{build-complete.d.ts → scripts/build-complete.d.ts} +0 -0
  66. /package/build/{move-assets.d.ts → scripts/move-assets.d.ts} +0 -0
  67. /package/build/{reset-render.d.ts → scripts/reset-render.d.ts} +0 -0
  68. /package/build/{run-start-render.d.ts → scripts/run-start-render.d.ts} +0 -0
  69. /package/build/{start-render.d.ts → scripts/start-render.d.ts} +0 -0
  70. /package/build/{upload-search-content.d.ts → scripts/upload-search-content.d.ts} +0 -0
  71. /package/exporter/{move-assets.ts → scripts/move-assets.ts} +0 -0
  72. /package/exporter/{run-start-render.ts → scripts/run-start-render.ts} +0 -0
@@ -1,18 +1,7 @@
1
- import type { Adapters } from "../adapters";
2
1
  import type { APIResponses } from "../types/api";
3
2
  import type { CXConfig, LifeCyclesNames } from "../types/global";
4
3
  import type { Site } from "../types/sites";
5
4
  declare const instanceRootDir: string;
6
- declare const attempts: {
7
- clean: any;
8
- prepare: any;
9
- restore: any;
10
- data: any;
11
- ssg: any;
12
- relocation: any;
13
- meta: any;
14
- archive: any;
15
- };
16
5
  /**
17
6
  * Returns the configuration file content.
18
7
  *
@@ -34,12 +23,6 @@ declare function exporterCreateInitialDirectories(domain: string): Promise<void>
34
23
  * @param domain The current domain in render.
35
24
  */
36
25
  declare function exporterCleanDisposableDirectories(domain: string): Promise<void>;
37
- /**
38
- * Custom basic logging function controlled by a environment variable.
39
- *
40
- * @param str The string to be logged.
41
- */
42
- declare function verbose(str: string): void;
43
26
  /**
44
27
  * Returns true for "true", "on", true and positive numbers.
45
28
  * Returns false for "false", "off", false, 0, negative integers and anything else.
@@ -51,39 +34,12 @@ declare function isTruthy(value: any): boolean;
51
34
  * @param dir A directory path.
52
35
  */
53
36
  declare function walk(dir: string): string[];
54
- /**
55
- * Custom log inside a line-box.
56
- *
57
- * @param stringValue The string to be logged.
58
- * @param paddingInline The number of white spaces inside the box at left and right.
59
- * @param paddingBlock The number of white spaces inside the box at top and bottom.
60
- */
61
- declare function logBox(stringValue: string, title?: string, paddingInline?: number, paddingBlock?: number): void;
62
- /**
63
- * Custom basic logging function controlled by a environment variable.
64
- * Strip double spaces.
65
- *
66
- * @param str The string to be logged.
67
- */
68
- declare function logInfo(str: string): void;
69
- /**
70
- * Internal log
71
- * @param values The values to be logged.
72
- */
73
- declare function debug(...values: Array<unknown>): void;
74
37
  /**
75
38
  * Custom delay using the "promise hack",
76
39
  *
77
40
  * @param ms Amount of miliseconds to be delayed
78
41
  */
79
42
  declare function delay(ms: number): Promise<unknown>;
80
- /**
81
- * Return a scale size colors with a number and a measure string (KB by default).
82
- *
83
- * @param size The page size in KB.
84
- * @param measure The measure string to be added in the log.
85
- */
86
- declare function logPageSize(size: number, measure?: string): string;
87
43
  /**
88
44
  * Converts milliseconds to seconds with a fixed number of decimals.
89
45
  *
@@ -110,10 +66,6 @@ declare function removeProperties(obj: Record<string, unknown>, props: Array<str
110
66
  * @param sites An array of sites objects
111
67
  */
112
68
  declare function siteList(sites: Array<Site>): string;
113
- /**
114
- * Print the great Griddo Exporter logo in ASCII.
115
- */
116
- declare function printExporterLogo(adapter: Adapters): void;
117
69
  /**
118
70
  * Remove unused files (old) inside the `apiCache` dir
119
71
  *
@@ -125,28 +77,25 @@ declare function sanitizeAPICacheDir(): void;
125
77
  * @param functions - Functions to be executed to measure their execution time.
126
78
  * @returns A promise that resolves with the total execution time in seconds.
127
79
  */
128
- declare function measureExecutionTime(...functions: Array<(...args: Array<unknown>) => unknown | Promise<any>>): Promise<number>;
80
+ declare function measureExecutionTime(functions: Array<(...args: Array<unknown>) => unknown | Promise<unknown>>, delayInMS?: number): Promise<number>;
129
81
  declare function pause(title: string): Promise<void> | undefined;
130
- declare function startLifeCycle(lifeCyleName: string): void;
131
- declare function successLifeCyle(value: string): void;
132
82
  /**
133
83
  * Executes a life cycle process, which involves executing an array of
134
84
  * functions, printing to the console, and handling errors with optional
135
85
  * retries.
136
86
  *
137
87
  * @async
138
- * @param args - The arguments object.
139
- * @param args.steps - An array of functions to execute.
140
- * @param args.name - The name of the life cycle.
141
- * @param args.attempts=1 - The number of retry attempts allowed in case of errors.
142
- * @param args.bypass - Skip the step functions.
88
+ * @param options - The arguments object.
89
+ * @param options.steps - An array of functions to execute.
90
+ * @param options.delay - Delay between steps functions.
91
+ * @param options.bypass - Skip the step functions.
143
92
  * @returns - A promise that resolves when the life cycle process is completed.
144
93
  */
145
- declare function doLifeCycle(args: {
94
+ declare function doLifeCycle(name: LifeCyclesNames, options: {
146
95
  steps: Array<(...args: Array<unknown>) => unknown | Promise<any>>;
147
- name: LifeCyclesNames;
148
- attempts?: number;
96
+ delay?: number;
97
+ bypass?: boolean;
149
98
  }): Promise<void>;
150
99
  declare function isVersionGreaterThan(versionA: string, versionB: string): boolean;
151
100
  declare function isVersionLowerThan(versionA: string, versionB: string): boolean;
152
- export { attempts, debug, delay, doLifeCycle, exporterCleanDisposableDirectories, exporterCreateInitialDirectories, getConfig, instanceRootDir, isTruthy, isVersionGreaterThan, isVersionLowerThan, logBox, logInfo, logPageSize, measureExecutionTime, pause, printExporterLogo, removeProperties, sanitizeAPICacheDir, siteList, startLifeCycle, successLifeCyle, verbose, walk, };
101
+ export { delay, doLifeCycle, exporterCleanDisposableDirectories, exporterCreateInitialDirectories, getConfig, instanceRootDir, isTruthy, isVersionGreaterThan, isVersionLowerThan, measureExecutionTime, pause, removeProperties, sanitizeAPICacheDir, siteList, walk, };
@@ -1,5 +1,9 @@
1
+ /**
2
+ * Return an array of domains name (string) of the current instance.
3
+ */
4
+ declare function getInstanceDomainsOrThrow(): Promise<string[]>;
1
5
  /**
2
6
  * Return an array of domains name (string) of the current instance.
3
7
  */
4
8
  declare function getInstanceDomains(): Promise<string[]>;
5
- export { getInstanceDomains };
9
+ export { getInstanceDomains, getInstanceDomainsOrThrow };
@@ -0,0 +1,49 @@
1
+ import type { Adapters } from "../adapters";
2
+ /**
3
+ * Custom basic logging function controlled by a environment variable.
4
+ *
5
+ * @param str The string to be logged.
6
+ */
7
+ declare function verboseLog(str: string): void;
8
+ /**
9
+ * Custom log inside a line-box.
10
+ *
11
+ * @param stringValue The string to be logged.
12
+ * @param paddingInline The number of white spaces inside the box at left and right.
13
+ * @param paddingBlock The number of white spaces inside the box at top and bottom.
14
+ */
15
+ declare function boxLog(stringValue: string, title?: string, paddingInline?: number, paddingBlock?: number): void;
16
+ /**
17
+ * Custom basic logging function controlled by a environment variable.
18
+ * Strip double spaces.
19
+ *
20
+ * @param str The string to be logged.
21
+ */
22
+ declare function buildLog(str: string): void;
23
+ /**
24
+ * Console log with a blue color in the info prefix.
25
+ * @param str The string to be logged.
26
+ */
27
+ declare function infoLog(str: string): void;
28
+ /**
29
+ * Console log with a green color in the success prefix.
30
+ * @param str The string to be logged.
31
+ */
32
+ declare function successLog(str: string): void;
33
+ /**
34
+ * Internal log
35
+ * @param values The values to be logged.
36
+ */
37
+ declare function debugLog(...values: Array<unknown>): void;
38
+ /**
39
+ * Return a scale size colors with a number and a measure string (KB by default).
40
+ *
41
+ * @param size The page size in KB.
42
+ * @param measure The measure string to be added in the log.
43
+ */
44
+ declare function pageSizeLog(size: number, measure?: string): string;
45
+ /**
46
+ * Print Griddo, adapter and Node version.
47
+ */
48
+ declare function printExporterLogo(adapter: Adapters): void;
49
+ export { boxLog, buildLog, debugLog, infoLog, pageSizeLog, printExporterLogo, successLog, verboseLog, };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Creates a sentinel file with the current date and time.
3
+ * This file is used to track later if node_modules/@griddo/cx was cleaned by a
4
+ * npm install from a deploy.
5
+ */
6
+ declare function createSentinelDomainRenderFile(): void;
7
+ declare function deleteSentinelFile(): void;
8
+ declare function isValidRenderProcessOrThrow(): void;
9
+ declare function initRender(): void;
10
+ declare function finishRender(): undefined;
11
+ export { finishRender, initRender, isValidRenderProcessOrThrow, createSentinelDomainRenderFile, deleteSentinelFile, };
package/cx.config.js CHANGED
@@ -13,10 +13,9 @@ const COMPONENTS_DIR = resolveComponentsPath();
13
13
  const EXPORTS_DIR = path.join(REPO_ROOT_DIR, "exports/sites");
14
14
 
15
15
  // eslint-disable-next-line @typescript-eslint/no-var-requires
16
- const { version: griddoVersion } = require(path.join(
17
- CX_ROOT_DIR,
18
- "package.json"
19
- ));
16
+ const { version: griddoVersion } = require(
17
+ path.join(CX_ROOT_DIR, "package.json"),
18
+ );
20
19
 
21
20
  const config = {
22
21
  proDomain: "pro-",
@@ -1,268 +1,106 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
 
4
- import {
5
- getGatsbyAssetPrefixWithDomain,
6
- legacy__createDistFromGatsbyPublic,
7
- runGatsbyBuildCommand,
8
- } from "./utils";
9
- import { throwError } from "../../errors";
10
- import { NoDomainsFoundError, RenderUUIDError } from "../../errors/errors-data";
11
- import { RobotsService } from "../../services/robots";
12
- import {
13
- attempts,
14
- doLifeCycle,
15
- getConfig,
16
- logBox,
17
- pause,
18
- printExporterLogo,
19
- verbose,
20
- } from "../../utils/core-utils";
21
- import { createBuildData } from "../../utils/create-build-data";
22
- import { getInstanceDomains } from "../../utils/domains";
23
- import {
24
- clearEmptyDirs,
25
- copyDirsSync,
26
- createDirsSync,
27
- moveDirsSync,
28
- removeDirsSync,
29
- removeVirtualPagesFromStore,
30
- } from "../../utils/folders";
31
- import { generateBuildReport, generateSitemaps } from "../../utils/sites";
4
+ /* prettier-ignore */ import { getGatsbyAssetPrefixWithDomain, legacy__createDistFromGatsbyPublic, runGatsbyBuildCommand, } from "./utils";
5
+ /* prettier-ignore */ import { RobotsService } from "../../services/robots";
6
+ /* prettier-ignore */ import { doLifeCycle, getConfig, pause } from "../../utils/core-utils";
7
+ /* prettier-ignore */ import { createBuildData } from "../../utils/create-build-data";
8
+ /* prettier-ignore */ import { clearEmptyDirs, copyDirsSync, createDirsSync, moveDirsSync, removeDirsSync, removeVirtualPagesFromStore, } from "../../utils/folders";
9
+ /* prettier-ignore */ import { boxLog, printExporterLogo } from "../../utils/loggin";
10
+ /* prettier-ignore */ import { createSentinelDomainRenderFile, isValidRenderProcessOrThrow, } from "../../utils/render";
11
+ /* prettier-ignore */ import { generateBuildReport, generateSitemaps } from "../../utils/sites";
32
12
 
33
13
  const config = getConfig();
34
- const { __cx } = config.paths();
35
- const renderSentinelFile = path.join(__cx, ".render-sentinel");
36
14
 
37
- async function runGatsbyAdapter() {
38
- printExporterLogo("gatsby");
39
-
40
- fs.writeFileSync(renderSentinelFile, new Date().toISOString());
41
-
42
- const domains: Array<string> = await getInstanceDomains();
43
-
44
- if (!domains.length) {
45
- throwError(NoDomainsFoundError);
46
- }
15
+ async function renderDomain(domain: string) {
16
+ boxLog(`Initializing render for the domain ${domain}`, "", 1, 0);
17
+
18
+ createSentinelDomainRenderFile();
19
+
20
+ const { __ssg, __exports, __caches, __cx, __components } =
21
+ config.paths(domain);
22
+
23
+ // This variables are for both, create the dist directory from public
24
+ // and pass to the gatsby-build command via spawnSync.
25
+ const assetPrefix = getGatsbyAssetPrefixWithDomain(domain);
26
+ const needsAssetPrefix = !!assetPrefix && assetPrefix !== "";
27
+
28
+ await doLifeCycle("Clean", {
29
+ steps: [
30
+ () => removeDirsSync(__cx, ["store", "apiCache", "dist"]),
31
+ () => removeDirsSync(__ssg, ["dist", "public", "static", ".cache"]),
32
+ ],
33
+ });
34
+
35
+ await doLifeCycle("Prepare", {
36
+ steps: [
37
+ () => createDirsSync([__exports]),
38
+ () => createDirsSync([__caches]),
39
+ ],
40
+ });
41
+
42
+ await doLifeCycle("Restore", {
43
+ steps: [
44
+ () => copyDirsSync(__components, __ssg, ["static"]),
45
+ () => copyDirsSync(__exports, __cx, ["assets"]),
46
+ () => copyDirsSync(__exports, __ssg, ["dist"]),
47
+ () => {
48
+ if (fs.existsSync(path.join(__ssg, "dist"))) {
49
+ fs.renameSync(path.join(__ssg, "dist"), path.join(__ssg, "public"));
50
+ }
51
+ },
52
+ () => moveDirsSync(__caches, __cx, ["apiCache", "store"]),
53
+ () => moveDirsSync(__caches, __ssg, [".cache"]),
54
+ ],
55
+ });
56
+
57
+ await doLifeCycle("Data", {
58
+ steps: [() => createBuildData(domain)],
59
+ });
60
+
61
+ await doLifeCycle("SSG", {
62
+ steps: [() => runGatsbyBuildCommand(assetPrefix)],
63
+ });
64
+
65
+ await doLifeCycle("Relocation", {
66
+ steps: [() => legacy__createDistFromGatsbyPublic(domain, needsAssetPrefix)],
67
+ });
68
+
69
+ await doLifeCycle("Meta", {
70
+ steps: [
71
+ () => generateBuildReport(),
72
+ () => RobotsService.writeFiles(domain),
73
+ () => generateSitemaps(),
74
+ () => pause("Meta LifeCycle"),
75
+ ],
76
+ });
77
+
78
+ await doLifeCycle("Archive", {
79
+ steps: [
80
+ () => removeVirtualPagesFromStore(),
81
+ () => clearEmptyDirs(path.join(__cx, "dist")),
82
+ () =>
83
+ moveDirsSync(__cx, __exports, ["dist", "assets"], {
84
+ withBackup: true,
85
+ }),
86
+ () => moveDirsSync(__cx, __caches, ["apiCache", "store"]),
87
+ () => moveDirsSync(__ssg, __caches, [".cache"]),
88
+ ],
89
+ });
90
+
91
+ await doLifeCycle("Clean", {
92
+ steps: [() => removeDirsSync(__ssg, ["static", "public", "dist"])],
93
+ });
94
+
95
+ await doLifeCycle("HealthCheck", {
96
+ steps: [() => isValidRenderProcessOrThrow()],
97
+ });
98
+ }
47
99
 
100
+ async function runGatsbyAdapter(domains: Array<string>) {
101
+ printExporterLogo("gatsby");
48
102
  for (const domain of domains) {
49
- const { __ssg, __exports, __caches, __cx, __components } = config.paths(
50
- domain
51
- );
52
-
53
- logBox(`Initializing render for the domain ${domain}`, "", 1, 0);
54
-
55
- // This variables are for both, create the dist directory from public
56
- // and pass to the gatsby-build command via spawnSync.
57
- const assetPrefix = getGatsbyAssetPrefixWithDomain(domain);
58
- const needsAssetPrefix = !!assetPrefix && assetPrefix !== "";
59
-
60
- /*
61
- * Clean LifeCycle.
62
- *
63
- * We first secure the stage by removing artifacts from previous failed
64
- * render. Both, griddo and gatsby artifacts.
65
- */
66
- await doLifeCycle({
67
- name: "Clean",
68
- attempts: attempts.clean,
69
- steps: [
70
- () => removeDirsSync(__cx, ["store", "apiCache", "dist"]),
71
- () =>
72
- verbose(
73
- "clean `store`, `apiCache` and `dist` directories from `__cx`"
74
- ),
75
- () => removeDirsSync(__ssg, ["dist", "public", "static", ".cache"]),
76
- () =>
77
- verbose(
78
- "clean `dist`, `public`, `static` and `.cache` directories from `__ssg`"
79
- ),
80
- () => pause("Clean LifeCycle"),
81
- ],
82
- });
83
-
84
- /*
85
- * Prepare LifeCycle.
86
- *
87
- * We prepare the stage creating necessary directories: exports and
88
- * caches.
89
- */
90
- await doLifeCycle({
91
- name: "Prepare",
92
- attempts: attempts.prepare,
93
- steps: [
94
- () => createDirsSync([__exports]),
95
- () => verbose("create `exports/sites/<domain>` directory"),
96
- () => createDirsSync([__caches]),
97
- () => verbose("create `caches/<domain>` directory"),
98
- () => pause("prepare LifeCycle"),
99
- ],
100
- });
101
-
102
- /*
103
- * Restore LifeCycle.
104
- */
105
- await doLifeCycle({
106
- name: "Restore",
107
- attempts: attempts.restore,
108
- steps: [
109
- // Copy instance static directory into the gatsby one.
110
- () => copyDirsSync(__components, __ssg, ["static"]),
111
- () => verbose("copy `static` directory from `__components` to `__ssg`"),
112
- () => copyDirsSync(__exports, __cx, ["assets"]),
113
- () => verbose("copy `assets` directory from `__exports` to `__cx`"),
114
- () => copyDirsSync(__exports, __ssg, ["dist"]),
115
- // Eliminamos archivos de sitemaps para que Gatsby no los tenga
116
- // en cuenta y evitar que se invalide el caché de HTMLs.
117
- // De todas maneras estos .xml se generan siempre en cada
118
- // render, y si hay algún problema no pasa nada porque se están
119
- // eliminando los sitemaps de la copia de dist en el directorio
120
- // de __cx.
121
- // () => clearSitemapsFromDirs(path.join(__cx, "dist")),
122
- // Renames dist to public.
123
- // En este paso de dist to public también se sacan los "assets"
124
- // de public si el dominio es "pro-". Este proceso es sacar
125
- // elementos del public y guardarlos en una carpeta "assets"
126
- // para que infra los suba un subdominio.
127
- () => {
128
- if (fs.existsSync(path.join(__ssg, "dist"))) {
129
- fs.renameSync(path.join(__ssg, "dist"), path.join(__ssg, "public"));
130
- }
131
- },
132
- () => verbose("rename `__ssg/dist` to `__ssg/public` directory."),
133
- () => moveDirsSync(__caches, __cx, ["apiCache", "store"]),
134
- () =>
135
- verbose(
136
- "move `apiCache` and `store` directories from `__caches` to `__cx`"
137
- ),
138
- () => moveDirsSync(__caches, __ssg, [".cache"]),
139
- () => verbose("move `.cache` directory from `__caches` to `__ssg`"),
140
- () => pause("Restore LifeCycle"),
141
- ],
142
- });
143
-
144
- /*
145
- * Data LifeCycle.
146
- */
147
- await doLifeCycle({
148
- name: "Data",
149
- attempts: attempts.data,
150
- steps: [
151
- // API -> Store
152
- () => createBuildData(domain),
153
- () => pause("Data LifeCycle"),
154
- ],
155
- });
156
-
157
- /*
158
- * SSG LifeCycle.
159
- */
160
- await doLifeCycle({
161
- name: "SSG",
162
- attempts: attempts.ssg,
163
- steps: [
164
- () => runGatsbyBuildCommand(assetPrefix),
165
- () => pause("SSG LifeCycle"),
166
- ],
167
- });
168
-
169
- /*
170
- * Relocation LifeCycle.
171
- */
172
- await doLifeCycle({
173
- name: "Relocation",
174
- attempts: attempts.relocation,
175
- steps: [
176
- () => legacy__createDistFromGatsbyPublic(domain, needsAssetPrefix),
177
- () => verbose("create an `assets` directory from `public`"),
178
- () => pause("Relocation LifeCycle"),
179
- ],
180
- });
181
-
182
- /*
183
- * Meta LifeCycle.
184
- */
185
- await doLifeCycle({
186
- name: "Meta",
187
- attempts: attempts.meta,
188
- steps: [
189
- () => generateBuildReport(),
190
- () =>
191
- verbose("create build report from `store/metadata/render-info.json`"),
192
- () => RobotsService.writeFiles(domain),
193
- () => verbose("create Robots.txt"),
194
- () => generateSitemaps(),
195
- () => verbose("generate sitemaps"),
196
- () => pause("Meta LifeCycle"),
197
- ],
198
- });
199
-
200
- /*
201
- * Archive LifeCycle.
202
- */
203
- await doLifeCycle({
204
- name: "Archive",
205
- attempts: attempts.archive,
206
- steps: [
207
- // Elimina las páginas de MultiPages y de templates de listados
208
- // estáticos (mode: list) del `store`. De este modo nos
209
- // aseguramos que se vuelven a crear por Gatsby siempre
210
- // actualizadas. Esto es debido a que estas páinas son creadas
211
- // en el contexto de CX y no tienen id único por lo que no son
212
- // tenidas en cuenta por la API y por lo tanto escapan a la
213
- // lógica de `changedPages` y la persistencia del store.
214
- () => removeVirtualPagesFromStore(),
215
- () =>
216
- verbose(
217
- "remove virtual pages from store (multipage and static list)"
218
- ),
219
- // Eliminamos carpetas vacías que puedan quedar de sites
220
- // despublicados. Incluye aquellas que solo tengan archivos .xml
221
- () => clearEmptyDirs(path.join(__cx, "dist")),
222
- () => verbose("remove empty site directories from `__cx/dist`"),
223
- () =>
224
- moveDirsSync(__cx, __exports, ["dist", "assets"], {
225
- withBackup: true,
226
- }),
227
-
228
- () =>
229
- verbose(
230
- "move `dist` and `assets` directories from `__cx` to `__exports`"
231
- ),
232
- () => moveDirsSync(__cx, __caches, ["apiCache", "store"]),
233
- () =>
234
- verbose(
235
- "move `apiCache` and `store` directories from `__cx` to `__caches`"
236
- ),
237
- () => moveDirsSync(__ssg, __caches, [".cache"]),
238
- () => verbose("move `.cache` directory from `__ssg` to `__caches`"),
239
- () => pause("Archive LifeCycle"),
240
- ],
241
- });
242
-
243
- /*
244
- * Clean LifeCycle.
245
- */
246
- await doLifeCycle({
247
- name: "Clean",
248
- attempts: attempts.clean,
249
- steps: [
250
- () => removeDirsSync(__ssg, ["static", "public", "dist"]),
251
- () => pause("Clean LifeCycle"),
252
- ],
253
- });
254
-
255
- await doLifeCycle({
256
- name: "HealthCheck",
257
- attempts: 1,
258
- steps: [
259
- () => {
260
- if (!fs.existsSync(renderSentinelFile)) {
261
- throwError(RenderUUIDError);
262
- }
263
- },
264
- ],
265
- });
103
+ await renderDomain(domain);
266
104
  }
267
105
  }
268
106
 
@@ -6,7 +6,8 @@ import path from "node:path";
6
6
  import dotenv from "dotenv";
7
7
  import fsx from "fs-extra";
8
8
 
9
- import { getConfig, verbose } from "../../utils/core-utils";
9
+ import { getConfig } from "../../utils/core-utils";
10
+ import { verboseLog } from "../../utils/loggin";
10
11
 
11
12
  dotenv.config();
12
13
 
@@ -31,11 +32,11 @@ function getGatsbyAssetPrefixWithDomain(domain: string) {
31
32
 
32
33
  const assetPrefixWithDomain = `${assetPrefix}/${domain}`;
33
34
 
34
- verbose(
35
- `Reading env.GRIDDO_ASSET_PREFIX, ${process.env.GRIDDO_ASSET_PREFIX}`
35
+ verboseLog(
36
+ `Reading env.GRIDDO_ASSET_PREFIX, ${process.env.GRIDDO_ASSET_PREFIX}`,
36
37
  );
37
- verbose(
38
- `Setting the asset prefix with the domain concatenated, ${assetPrefixWithDomain}`
38
+ verboseLog(
39
+ `Setting the asset prefix with the domain concatenated, ${assetPrefixWithDomain}`,
39
40
  );
40
41
 
41
42
  return assetPrefixWithDomain;
@@ -54,7 +55,7 @@ function formatImage(
54
55
  image: Fields.Image | string,
55
56
  width: number,
56
57
  height: number,
57
- format = "jpg"
58
+ format = "jpg",
58
59
  ) {
59
60
  const url = typeof image === "string" ? image : image?.url;
60
61
 
@@ -97,7 +98,7 @@ function addCloudinaryParams(image: string, params: string) {
97
98
  * `process.env` so it needs variables passed to it via the `env` prop.
98
99
  */
99
100
  function runGatsbyBuildCommand(assetPrefixWithDomain: string) {
100
- verbose(`read assetPrefixWithDomain, ${assetPrefixWithDomain}`);
101
+ verboseLog(`read assetPrefixWithDomain, ${assetPrefixWithDomain}`);
101
102
 
102
103
  const { __ssg } = config.paths();
103
104
 
@@ -113,7 +114,7 @@ function runGatsbyBuildCommand(assetPrefixWithDomain: string) {
113
114
  GRIDDO_EXPORTER: "true",
114
115
  SPAWN_ASSET_PREFIX_WITH_DOMAIN: assetPrefixWithDomain,
115
116
  }),
116
- }
117
+ },
117
118
  );
118
119
 
119
120
  if (command.status !== 0) {
@@ -127,7 +128,7 @@ function runGatsbyBuildCommand(assetPrefixWithDomain: string) {
127
128
  */
128
129
  async function legacy__createDistFromGatsbyPublic(
129
130
  domain: string,
130
- needsAssetPrefix: boolean
131
+ needsAssetPrefix: boolean,
131
132
  ) {
132
133
  const { __cx, __ssg } = config.paths(domain);
133
134
 
@@ -142,7 +143,7 @@ async function legacy__createDistFromGatsbyPublic(
142
143
  (file) =>
143
144
  path.extname(file) === ".js" ||
144
145
  path.extname(file) === ".json" ||
145
- path.extname(file) === ".css"
146
+ path.extname(file) === ".css",
146
147
  );
147
148
 
148
149
  const pageDataSrc = `${publicDir}/page-data`;
@@ -2,7 +2,7 @@ import type { Core } from "@griddo/core";
2
2
 
3
3
  function filterBodyIntegrationFromPosition(
4
4
  integrations: Array<Core.PageIntegration>,
5
- position: "start" | "end"
5
+ position: "start" | "end",
6
6
  ) {
7
7
  return (
8
8
  integrations
@@ -10,7 +10,7 @@ function filterBodyIntegrationFromPosition(
10
10
  (integration) =>
11
11
  integration.contentBody !== null &&
12
12
  integration.contentBody !== "" &&
13
- integration.contentBodyPosition === position
13
+ integration.contentBodyPosition === position,
14
14
  )
15
15
  .map((integration) => integration.contentBody!) || []
16
16
  );
@@ -21,7 +21,7 @@ function filterHeadIntegrations(integrations: Array<Core.PageIntegration>) {
21
21
  integrations
22
22
  ?.filter(
23
23
  (integration) =>
24
- integration.contentHead !== null && integration.contentHead !== ""
24
+ integration.contentHead !== null && integration.contentHead !== "",
25
25
  )
26
26
  .map((integration) => integration.contentHead!) || []
27
27
  );
@@ -29,7 +29,7 @@ function filterHeadIntegrations(integrations: Array<Core.PageIntegration>) {
29
29
 
30
30
  function filterPositionIntegrations(
31
31
  integrations: Array<Core.PageIntegration>,
32
- position: "head" | "start" | "end"
32
+ position: "head" | "start" | "end",
33
33
  ) {
34
34
  switch (position) {
35
35
  case "head":