@griddo/cx 11.1.3 → 11.1.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.
- package/build/end-render.js +18 -18
- package/build/end-render.js.map +3 -3
- package/build/index.js +38 -38
- package/build/index.js.map +3 -3
- package/build/reset-render.js +4 -4
- package/build/reset-render.js.map +3 -3
- package/build/run-start-render.js +33 -33
- package/build/run-start-render.js.map +3 -3
- package/build/services/robots.d.ts +1 -1
- package/build/start-render.js +33 -33
- package/build/start-render.js.map +3 -3
- package/build/types/api.d.ts +1 -0
- package/build/types/global.d.ts +2 -1
- package/build/upload-search-content.js +4 -4
- package/build/upload-search-content.js.map +3 -3
- package/build/utils/core-utils.d.ts +7 -2
- package/build/utils/sites.d.ts +1 -3
- package/exporter/adapters/gatsby/index.ts +86 -72
- package/exporter/services/domains.ts +4 -1
- package/exporter/services/robots.ts +1 -1
- package/exporter/services/settings.ts +4 -1
- package/exporter/services/sites.ts +1 -0
- package/exporter/types/api.ts +2 -0
- package/exporter/types/global.ts +5 -0
- package/exporter/utils/api.ts +12 -3
- package/exporter/utils/core-utils.ts +11 -2
- package/exporter/utils/searches.ts +2 -0
- package/exporter/utils/sites.ts +1 -3
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { APIResponses } from "../types/api";
|
|
2
|
-
import type { CXConfig, LifeCyclesNames } from "../types/global";
|
|
2
|
+
import type { CXConfig, LifeCyclesNames, LifeCycleSteps } from "../types/global";
|
|
3
3
|
declare const instanceRootDir: string;
|
|
4
4
|
/**
|
|
5
5
|
* Returns the configuration file content.
|
|
@@ -91,7 +91,7 @@ declare function pause(title: string): Promise<void> | undefined;
|
|
|
91
91
|
* @returns - A promise that resolves when the life cycle process is completed.
|
|
92
92
|
*/
|
|
93
93
|
declare function doLifeCycle(name: LifeCyclesNames, options: {
|
|
94
|
-
steps:
|
|
94
|
+
steps: LifeCycleSteps;
|
|
95
95
|
delay?: number;
|
|
96
96
|
bypass?: boolean;
|
|
97
97
|
}): Promise<void>;
|
|
@@ -104,5 +104,10 @@ declare function doLifeCycle(name: LifeCyclesNames, options: {
|
|
|
104
104
|
*/
|
|
105
105
|
declare function createRenderMetadata(domain: string): Promise<void>;
|
|
106
106
|
declare function removeAllSiteDirsFromStore(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Save render information to a file to use as debug log.
|
|
109
|
+
*
|
|
110
|
+
* This information will **not** be sent to any API.
|
|
111
|
+
*/
|
|
107
112
|
declare function saveBuildEndLogs(): void;
|
|
108
113
|
export { createRenderMetadata, delay, doLifeCycle, getConfig, getSafeSiteId, instanceRootDir, isTruthy, measureExecutionTime, msToSec, pause, removeAllSiteDirsFromStore, removeProperties, sanitizeAPICacheDir, saveBuildEndLogs, walk, walkStore, };
|
package/build/utils/sites.d.ts
CHANGED
|
@@ -21,13 +21,11 @@ declare function unpublishSites(sites: Array<Site>): Promise<void>;
|
|
|
21
21
|
*/
|
|
22
22
|
declare function getSiteData(siteID: number): Promise<SiteData>;
|
|
23
23
|
/**
|
|
24
|
-
* Save a file with the end of build process
|
|
24
|
+
* Save a file with the end of build process to use as `build-end` signal.
|
|
25
25
|
*/
|
|
26
26
|
declare function generateBuildReport(): Promise<void>;
|
|
27
27
|
/**
|
|
28
28
|
* Generate sitemaps and save them into file system.
|
|
29
|
-
*
|
|
30
|
-
* @param sites An array of sites
|
|
31
29
|
*/
|
|
32
30
|
declare function generateSitemaps(): Promise<void>;
|
|
33
31
|
export { checkSites, generateBuildReport, generateSitemaps, getSiteData, unpublishSites, };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
Artifacts,
|
|
3
|
+
LifeCyclesNames,
|
|
4
|
+
LifeCycleSteps,
|
|
5
|
+
} from "../../types/global";
|
|
2
6
|
|
|
3
7
|
import path from "node:path";
|
|
4
8
|
|
|
@@ -68,6 +72,11 @@ export async function renderDomainsWithGatsbyAdapter() {
|
|
|
68
72
|
initials: [],
|
|
69
73
|
archivables: [],
|
|
70
74
|
};
|
|
75
|
+
// Compose artifacts
|
|
76
|
+
const disposableArtifacts = [
|
|
77
|
+
...cxArtifacts.disposables,
|
|
78
|
+
...gatsbyArtifacts.disposables,
|
|
79
|
+
];
|
|
71
80
|
|
|
72
81
|
// These variables are involved in the build for create the dist directory
|
|
73
82
|
// from public and pass to the gatsby-build command via spawnSync.
|
|
@@ -76,77 +85,82 @@ export async function renderDomainsWithGatsbyAdapter() {
|
|
|
76
85
|
|
|
77
86
|
// LifeCycles
|
|
78
87
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
88
|
+
const allLifeCycles: Array<{
|
|
89
|
+
name: LifeCyclesNames;
|
|
90
|
+
steps: LifeCycleSteps;
|
|
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: [() => createBuildData(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: [() => createRenderMetadata(domain), () => saveBuildEndLogs()],
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
{
|
|
135
|
+
name: "Archive",
|
|
136
|
+
steps: [
|
|
137
|
+
() => removeVirtualPagesFromStore(),
|
|
138
|
+
() => clearEmptyDirs(path.join(__cx, "dist")),
|
|
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: [() => isValidRenderProcessOrThrow()],
|
|
156
|
+
},
|
|
157
|
+
];
|
|
158
|
+
|
|
159
|
+
for (const { name, steps } of allLifeCycles) {
|
|
160
|
+
await doLifeCycle(name, {
|
|
161
|
+
steps: steps,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
150
164
|
|
|
151
165
|
deleteSentinelRenderFile();
|
|
152
166
|
}
|
|
@@ -7,7 +7,10 @@ import { get } from "../utils/api";
|
|
|
7
7
|
* Get an array of available domain.
|
|
8
8
|
*/
|
|
9
9
|
async function getAllDomains() {
|
|
10
|
-
return await get<Domains>({
|
|
10
|
+
return await get<Domains>({
|
|
11
|
+
endpoint: endpoints.DOMAINS,
|
|
12
|
+
useApiCacheDir: false,
|
|
13
|
+
});
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export { getAllDomains };
|
|
@@ -8,7 +8,10 @@ async function getAllSettings() {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
async function resetRender() {
|
|
11
|
-
await post({
|
|
11
|
+
await post({
|
|
12
|
+
endpoint: endpoints.RESET_RENDER,
|
|
13
|
+
useApiCacheDir: false,
|
|
14
|
+
});
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
export { getAllSettings, resetRender };
|
package/exporter/types/api.ts
CHANGED
|
@@ -124,6 +124,8 @@ export interface APIRequest {
|
|
|
124
124
|
* @todo type this correctly from axios types
|
|
125
125
|
*/
|
|
126
126
|
headers?: any; // Record<string, unknown>;
|
|
127
|
+
/* Save results in apiCache folder */
|
|
128
|
+
useApiCacheDir?: boolean;
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
/** Type with the POST request properties. */
|
package/exporter/types/global.ts
CHANGED
|
@@ -68,6 +68,10 @@ interface RenderInfo {
|
|
|
68
68
|
sitesToPublish: Array<Site>;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
type LifeCycleSteps = Array<
|
|
72
|
+
(...args: Array<unknown>) => unknown | Promise<unknown>
|
|
73
|
+
>;
|
|
74
|
+
|
|
71
75
|
type LifeCyclesNames =
|
|
72
76
|
| "Prepare"
|
|
73
77
|
| "Restore"
|
|
@@ -126,4 +130,5 @@ export type {
|
|
|
126
130
|
Robot,
|
|
127
131
|
Robots,
|
|
128
132
|
Settings,
|
|
133
|
+
LifeCycleSteps,
|
|
129
134
|
};
|
package/exporter/utils/api.ts
CHANGED
|
@@ -44,11 +44,18 @@ async function requestAPI<T extends APIResponses>(
|
|
|
44
44
|
method: Method,
|
|
45
45
|
appendToLog = "",
|
|
46
46
|
): Promise<T> {
|
|
47
|
-
const {
|
|
47
|
+
const {
|
|
48
|
+
endpoint,
|
|
49
|
+
body,
|
|
50
|
+
cacheKey = "",
|
|
51
|
+
attempt = 1,
|
|
52
|
+
headers,
|
|
53
|
+
useApiCacheDir = true,
|
|
54
|
+
} = props;
|
|
48
55
|
const cacheOptions = { endpoint, body, headers, cacheKey };
|
|
49
56
|
|
|
50
57
|
// Cache
|
|
51
|
-
if (cacheKey) {
|
|
58
|
+
if (cacheKey && useApiCacheDir) {
|
|
52
59
|
const start = new Date();
|
|
53
60
|
const cacheData = searchCacheData<T>(cacheOptions);
|
|
54
61
|
|
|
@@ -83,7 +90,9 @@ async function requestAPI<T extends APIResponses>(
|
|
|
83
90
|
`${method} (fetch) ${siteIdMsg} ${endpoint} - ${duration}s ${appendToLog}`,
|
|
84
91
|
);
|
|
85
92
|
|
|
86
|
-
|
|
93
|
+
if (useApiCacheDir) {
|
|
94
|
+
saveCache(cacheOptions, data);
|
|
95
|
+
}
|
|
87
96
|
|
|
88
97
|
// Only save registers if alerts are enabled
|
|
89
98
|
if (envs.GRIDDO_ALERT_FEATURE) {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { APIResponses } from "../types/api";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
CXConfig,
|
|
4
|
+
LifeCyclesNames,
|
|
5
|
+
LifeCycleSteps,
|
|
6
|
+
} from "../types/global";
|
|
3
7
|
import type { APIPageObject } from "../types/pages";
|
|
4
8
|
|
|
5
9
|
import fs from "node:fs";
|
|
@@ -312,7 +316,7 @@ function pause(title: string) {
|
|
|
312
316
|
async function doLifeCycle(
|
|
313
317
|
name: LifeCyclesNames,
|
|
314
318
|
options: {
|
|
315
|
-
steps:
|
|
319
|
+
steps: LifeCycleSteps;
|
|
316
320
|
delay?: number;
|
|
317
321
|
bypass?: boolean;
|
|
318
322
|
},
|
|
@@ -411,6 +415,11 @@ function getFormattedDateTime() {
|
|
|
411
415
|
return `${date}_${time}`;
|
|
412
416
|
}
|
|
413
417
|
|
|
418
|
+
/**
|
|
419
|
+
* Save render information to a file to use as debug log.
|
|
420
|
+
*
|
|
421
|
+
* This information will **not** be sent to any API.
|
|
422
|
+
*/
|
|
414
423
|
function saveBuildEndLogs() {
|
|
415
424
|
const { __cx } = config.paths();
|
|
416
425
|
const { sitesToPublish, createdPages, buildProcessData } = fsx.readJSONSync(
|
|
@@ -43,6 +43,7 @@ async function postSearchInfo(props: PostSearchInfoProps) {
|
|
|
43
43
|
template,
|
|
44
44
|
content: prepareHTMLContentForSearch(content),
|
|
45
45
|
},
|
|
46
|
+
useApiCacheDir: false,
|
|
46
47
|
});
|
|
47
48
|
|
|
48
49
|
return response;
|
|
@@ -165,6 +166,7 @@ async function startAIEmbeddings() {
|
|
|
165
166
|
try {
|
|
166
167
|
await post<AIEmbeddingsResponse>({
|
|
167
168
|
endpoint: endpoints.AI_EMBEDDINGS,
|
|
169
|
+
useApiCacheDir: false,
|
|
168
170
|
});
|
|
169
171
|
} catch (error) {
|
|
170
172
|
console.warn(
|
package/exporter/utils/sites.ts
CHANGED
|
@@ -153,7 +153,7 @@ async function getSiteData(siteID: number) {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
|
-
* Save a file with the end of build process
|
|
156
|
+
* Save a file with the end of build process to use as `build-end` signal.
|
|
157
157
|
*/
|
|
158
158
|
async function generateBuildReport() {
|
|
159
159
|
const { __cx } = config.paths();
|
|
@@ -184,8 +184,6 @@ async function generateBuildReport() {
|
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
186
|
* Generate sitemaps and save them into file system.
|
|
187
|
-
*
|
|
188
|
-
* @param sites An array of sites
|
|
189
187
|
*/
|
|
190
188
|
async function generateSitemaps() {
|
|
191
189
|
const { sitesToPublish } = await getBuildMetadata();
|
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": "11.1.
|
|
4
|
+
"version": "11.1.5",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@babel/preset-env": "7.26.0",
|
|
61
61
|
"@babel/preset-react": "7.26.3",
|
|
62
62
|
"@babel/preset-typescript": "7.26.0",
|
|
63
|
-
"@griddo/core": "11.1.
|
|
63
|
+
"@griddo/core": "11.1.5",
|
|
64
64
|
"@svgr/webpack": "5.5.0",
|
|
65
65
|
"axios": "1.7.9",
|
|
66
66
|
"babel-loader": "9.2.1",
|
|
@@ -126,5 +126,5 @@
|
|
|
126
126
|
"publishConfig": {
|
|
127
127
|
"access": "public"
|
|
128
128
|
},
|
|
129
|
-
"gitHead": "
|
|
129
|
+
"gitHead": "3d7508419bdedbaa6dc6eae55fe73c10cb5bcdb8"
|
|
130
130
|
}
|