@griddo/cx 11.0.8 → 11.0.9
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 +23 -23
- package/build/end-render.js.map +4 -4
- package/build/errors/errors-data.d.ts +12 -9
- package/build/index.js +30 -30
- package/build/index.js.map +3 -3
- package/build/reset-render.js +22 -22
- package/build/reset-render.js.map +4 -4
- package/build/run-start-render.js +28 -28
- package/build/run-start-render.js.map +3 -3
- package/build/start-render.js +28 -28
- package/build/start-render.js.map +3 -3
- package/build/upload-search-content.js +22 -22
- package/build/upload-search-content.js.map +3 -3
- package/build/utils/store.d.ts +2 -1
- package/exporter/build.sh +39 -0
- package/exporter/errors/errors-data.ts +59 -31
- package/exporter/utils/core-utils.ts +2 -3
- package/exporter/utils/folders.ts +22 -20
- package/exporter/utils/sites.ts +3 -2
- package/exporter/utils/store.ts +9 -5
- package/package.json +5 -5
- package/src/gatsby-node-utils.ts +3 -2
package/build/utils/store.d.ts
CHANGED
|
@@ -22,7 +22,8 @@ declare function getBuildPagesFromStore<PageType extends GriddoPageObject>(args?
|
|
|
22
22
|
withSizeProp?: boolean;
|
|
23
23
|
}): Generator<PageType, void, unknown>;
|
|
24
24
|
/**
|
|
25
|
-
* Read all pages stored in `store` Griddo directory and return the absolute
|
|
25
|
+
* Read all pages stored in `store` Griddo directory and return the absolute
|
|
26
|
+
* path.
|
|
26
27
|
*/
|
|
27
28
|
declare function getBuildPagesPath(): string[];
|
|
28
29
|
/**
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Build CX script file
|
|
2
|
+
#
|
|
3
|
+
# This file generates the necessary builds for CX.
|
|
4
|
+
# - Setup, to generate necessary elements (tsconfig, etc..)
|
|
5
|
+
# - Library, CX library that will be used by the SSG framework.
|
|
6
|
+
# - Scripts, CX scripts that will be used by infra during the render process.
|
|
7
|
+
#
|
|
8
|
+
# @todo:
|
|
9
|
+
# In the future, we will try to eliminate the bundling processes and use
|
|
10
|
+
# TypeScript or ESModules directly.
|
|
11
|
+
|
|
12
|
+
# start
|
|
13
|
+
echo "📦 Building ..."
|
|
14
|
+
|
|
15
|
+
# CLI options
|
|
16
|
+
log="--log-level=error"
|
|
17
|
+
production_node_opts="--bundle --platform=node --minify --sourcemap"
|
|
18
|
+
debugging_node_opts="--bundle --platform=node --sourcemap"
|
|
19
|
+
react_opts="--platform=node --external:@griddo-instance --external:react --external:react-dom --bundle --minify"
|
|
20
|
+
|
|
21
|
+
# Manage --minify for debugging
|
|
22
|
+
bundle_node_opts=$production_node_opts
|
|
23
|
+
if [ "$1" = "--debug" ]; then
|
|
24
|
+
bundle_node_opts=$debugging_node_opts
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
# library
|
|
28
|
+
esbuild ${log} ./exporter/index.ts ${bundle_node_opts} --outfile=./build/index.js
|
|
29
|
+
esbuild ${log} ./exporter/react/index.tsx ${react_opts} --outfile=./build/react/index.js
|
|
30
|
+
|
|
31
|
+
# scripts
|
|
32
|
+
esbuild ${log} ./exporter/scripts/run-start-render.ts ${bundle_node_opts} --outfile=./build/run-start-render.js
|
|
33
|
+
esbuild ${log} ./exporter/scripts/end-render.ts ${bundle_node_opts} --outfile=./build/end-render.js
|
|
34
|
+
esbuild ${log} ./exporter/scripts/upload-search-content.ts ${bundle_node_opts} --outfile=./build/upload-search-content.js
|
|
35
|
+
esbuild ${log} ./exporter/scripts/reset-render.ts ${bundle_node_opts} --outfile=./build/reset-render.js
|
|
36
|
+
esbuild ${log} ./exporter/scripts/start-render.ts ${bundle_node_opts} --outfile=./build/start-render.js
|
|
37
|
+
|
|
38
|
+
# types
|
|
39
|
+
tsc --emitDeclarationOnly --declaration --outDir build --project tsconfig.exporter.json
|
|
@@ -10,17 +10,19 @@
|
|
|
10
10
|
import type { ErrorData } from ".";
|
|
11
11
|
import type { SpawnSyncReturns } from "node:child_process";
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
| "NoDomainsFoundError"
|
|
15
|
-
| "RenderUUIDError"
|
|
13
|
+
type ErrorsType =
|
|
16
14
|
| "ArtifactError"
|
|
17
|
-
| "LoginError"
|
|
18
15
|
| "ErrorInSSGBuildProcess"
|
|
19
16
|
| "LifecycleExecutionError"
|
|
17
|
+
| "LoginError"
|
|
18
|
+
| "NoDomainsFoundError"
|
|
20
19
|
| "NoJSConfigFileFound"
|
|
21
|
-
| "
|
|
20
|
+
| "ReadFromStoreError"
|
|
21
|
+
| "ReferenceFieldSourcesNotFoundError"
|
|
22
|
+
| "RenderUUIDError"
|
|
23
|
+
| "WriteToStoreError";
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
const ArtifactError: ErrorData = {
|
|
24
26
|
error: "ArtifactError",
|
|
25
27
|
message: "There was a problem with an artifact",
|
|
26
28
|
expected:
|
|
@@ -28,14 +30,16 @@ export const ArtifactError: ErrorData = {
|
|
|
28
30
|
hint: "Have there been any recent deployments? These can delete directories from the current render.",
|
|
29
31
|
};
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const ErrorInSSGBuildProcess = (
|
|
34
|
+
command: SpawnSyncReturns<string>,
|
|
35
|
+
): ErrorData => ({
|
|
36
|
+
error: "ErrorInSSGBuildProcess",
|
|
37
|
+
message: `Error in SSG build process: ${JSON.stringify(command)}`,
|
|
34
38
|
expected:
|
|
35
|
-
"This can happen if
|
|
36
|
-
};
|
|
39
|
+
"This can happen if there was a problem with the SSG build process.",
|
|
40
|
+
});
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
const LifecycleExecutionError = (
|
|
39
43
|
attempts: number,
|
|
40
44
|
name: string,
|
|
41
45
|
): ErrorData => ({
|
|
@@ -43,16 +47,14 @@ export const LifecycleExecutionError = (
|
|
|
43
47
|
message: `Exceeded maximum retry attempts (${attempts}) for ${name} LifeCycle`,
|
|
44
48
|
});
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
error: "ErrorInSSGBuildProcess",
|
|
50
|
-
message: `Error in SSG build process: ${JSON.stringify(command)}`,
|
|
50
|
+
const LoginError: ErrorData = {
|
|
51
|
+
error: "LoginError",
|
|
52
|
+
message: "There was a problem logging in to the API",
|
|
51
53
|
expected:
|
|
52
|
-
"This
|
|
53
|
-
}
|
|
54
|
+
"This happens if the API is currently not working or the credentials are incorrect.",
|
|
55
|
+
};
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
const NoDomainsFoundError: ErrorData = {
|
|
56
58
|
error: "NoDomainsFoundError",
|
|
57
59
|
message:
|
|
58
60
|
"No domains were found in this instance. The process cannot continue.",
|
|
@@ -61,7 +63,27 @@ export const NoDomainsFoundError: ErrorData = {
|
|
|
61
63
|
hint: "You can contact the instance administrator.",
|
|
62
64
|
};
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
const NoJSConfigFileFound: ErrorData = {
|
|
67
|
+
error: "NoJSConfigFileFound",
|
|
68
|
+
message: "Could not find jsconfig.json or tsconfig.json",
|
|
69
|
+
expected:
|
|
70
|
+
"This can happen if the instance is not properly configured with a jsconfig.json or tsconfig.json file.",
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const ReadFromStoreError: ErrorData = {
|
|
74
|
+
error: "ReadFromStoreError",
|
|
75
|
+
message: "There was an error reading a file to the Store directory",
|
|
76
|
+
hint: "There may be an issue such as permissions preventing the file from being read.",
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const ReferenceFieldSourcesNotFoundError: ErrorData = {
|
|
80
|
+
error: "ReferenceFieldSourcesNotFoundError",
|
|
81
|
+
message: "The distributor has no sources defined.",
|
|
82
|
+
expected:
|
|
83
|
+
"It is expected to have at least one data source in the `sources` property, even if it is empty.",
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const RenderUUIDError: ErrorData = {
|
|
65
87
|
error: "RenderUUIDError",
|
|
66
88
|
message: `Render sentinel file does not exist.
|
|
67
89
|
The rendering UUID cannot be read safely.
|
|
@@ -70,16 +92,22 @@ There was probably an instance deployment during the render, and files were dele
|
|
|
70
92
|
The files generated in this render will not be published.`,
|
|
71
93
|
};
|
|
72
94
|
|
|
73
|
-
|
|
74
|
-
error: "
|
|
75
|
-
message: "
|
|
76
|
-
|
|
77
|
-
"It is expected to have at least one data source in the `sources` property, even if it is empty.",
|
|
95
|
+
const WriteToStoreError: ErrorData = {
|
|
96
|
+
error: "WriteToStoreError",
|
|
97
|
+
message: "There was an error writing a file to the Store directory",
|
|
98
|
+
hint: "There may be an issue such as lack of space or permissions preventing the file from being written.",
|
|
78
99
|
};
|
|
79
100
|
|
|
80
|
-
export
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
101
|
+
export {
|
|
102
|
+
ArtifactError,
|
|
103
|
+
ErrorInSSGBuildProcess,
|
|
104
|
+
LifecycleExecutionError,
|
|
105
|
+
LoginError,
|
|
106
|
+
NoDomainsFoundError,
|
|
107
|
+
NoJSConfigFileFound,
|
|
108
|
+
ReadFromStoreError,
|
|
109
|
+
ReferenceFieldSourcesNotFoundError,
|
|
110
|
+
RenderUUIDError,
|
|
111
|
+
WriteToStoreError,
|
|
112
|
+
type ErrorsType,
|
|
85
113
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { APIResponses } from "../types/api";
|
|
2
2
|
import type { CXConfig, LifeCyclesNames } from "../types/global";
|
|
3
3
|
import type { APIPageObject } from "../types/pages";
|
|
4
|
-
import type { Site } from "../types/sites";
|
|
5
4
|
|
|
6
5
|
import fs from "node:fs";
|
|
7
6
|
import path from "node:path";
|
|
@@ -38,8 +37,8 @@ function getConfig(): CXConfig {
|
|
|
38
37
|
|
|
39
38
|
return config;
|
|
40
39
|
} catch (error) {
|
|
41
|
-
console.log(
|
|
42
|
-
|
|
40
|
+
console.log(error);
|
|
41
|
+
throw new Error("Error while reading configuration file");
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
|
|
@@ -77,8 +77,8 @@ function createArtifacts(dirs: Array<string>, options?: MakeDirectoryOptions) {
|
|
|
77
77
|
fs.mkdirSync(dir, { recursive: true, ...options });
|
|
78
78
|
verboseLog(`create directory: ${dir}`);
|
|
79
79
|
}
|
|
80
|
-
} catch (
|
|
81
|
-
throwError(ArtifactError,
|
|
80
|
+
} catch (error) {
|
|
81
|
+
throwError(ArtifactError, error);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -89,8 +89,8 @@ function renameArtifact(src: string, dst: string) {
|
|
|
89
89
|
fs.renameSync(src, dst);
|
|
90
90
|
verboseLog(`rename ${src} to ${dst}`);
|
|
91
91
|
}
|
|
92
|
-
} catch (
|
|
93
|
-
throwError(ArtifactError,
|
|
92
|
+
} catch (error) {
|
|
93
|
+
throwError(ArtifactError, error);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -148,13 +148,13 @@ function copyArtifacts(
|
|
|
148
148
|
deleteBackup(dstCompose);
|
|
149
149
|
verboseLog(`delete backup: ${dstCompose}`);
|
|
150
150
|
}
|
|
151
|
-
} catch (
|
|
151
|
+
} catch (error) {
|
|
152
152
|
if (withBackup) {
|
|
153
153
|
restoreBackup(dstCompose);
|
|
154
154
|
console.log("Backup has been restored.");
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
throwError(ArtifactError,
|
|
157
|
+
throwError(ArtifactError, error);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
}
|
|
@@ -199,13 +199,13 @@ function moveArtifacts(
|
|
|
199
199
|
if (withBackup) {
|
|
200
200
|
deleteBackup(dstCompose);
|
|
201
201
|
}
|
|
202
|
-
} catch (
|
|
202
|
+
} catch (error) {
|
|
203
203
|
if (withBackup) {
|
|
204
204
|
restoreBackup(dstCompose);
|
|
205
205
|
console.log("Backup has been restored.");
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
throwError(ArtifactError,
|
|
208
|
+
throwError(ArtifactError, error);
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -226,8 +226,8 @@ function removeArtifacts(artifacts: Array<string>) {
|
|
|
226
226
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
227
227
|
verboseLog(`removed directory: ${dir}`);
|
|
228
228
|
}
|
|
229
|
-
} catch (
|
|
230
|
-
throwError(ArtifactError,
|
|
229
|
+
} catch (error) {
|
|
230
|
+
throwError(ArtifactError, error);
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
}
|
|
@@ -237,8 +237,9 @@ function restoreBackup(src: string, suffix = "-BACKUP") {
|
|
|
237
237
|
try {
|
|
238
238
|
fs.renameSync(dst, src);
|
|
239
239
|
console.log(`Backup ${dst} has been restored`);
|
|
240
|
-
} catch (
|
|
241
|
-
console.log(
|
|
240
|
+
} catch (error) {
|
|
241
|
+
console.log(error);
|
|
242
|
+
throw new Error(`Error while delete ${dst} backup`);
|
|
242
243
|
}
|
|
243
244
|
}
|
|
244
245
|
|
|
@@ -252,8 +253,9 @@ function deleteBackup(src: string, suffix = "-BACKUP") {
|
|
|
252
253
|
try {
|
|
253
254
|
fs.rmSync(dst, { recursive: true, force: true });
|
|
254
255
|
console.log(`Backup ${dst} has been deleted`);
|
|
255
|
-
} catch (
|
|
256
|
-
console.log(
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.log(error);
|
|
258
|
+
throw new Error(`Error while delete ${dst} backup`);
|
|
257
259
|
}
|
|
258
260
|
}
|
|
259
261
|
|
|
@@ -272,10 +274,9 @@ function createBackup(src: string, suffix = "-BACKUP") {
|
|
|
272
274
|
try {
|
|
273
275
|
fs.renameSync(src, dst);
|
|
274
276
|
console.log(`Backup of ${src} has been created in ${dst}`);
|
|
275
|
-
} catch (
|
|
277
|
+
} catch (error) {
|
|
276
278
|
console.log(`Error while coping ${src} to ${dst} backup`);
|
|
277
|
-
|
|
278
|
-
throwError(ArtifactError, e);
|
|
279
|
+
throwError(ArtifactError, error);
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
282
|
|
|
@@ -296,7 +297,7 @@ async function removeVirtualPagesFromStore() {
|
|
|
296
297
|
fs.unlinkSync(filePath);
|
|
297
298
|
}
|
|
298
299
|
}
|
|
299
|
-
} catch (
|
|
300
|
+
} catch (error) {
|
|
300
301
|
console.info(
|
|
301
302
|
"`store` folder does not exist. Skipping multipage or static list template cleaning.",
|
|
302
303
|
);
|
|
@@ -328,8 +329,9 @@ function clearSitemapsFromDirs(initialFolder: string) {
|
|
|
328
329
|
fs.unlinkSync(fullPath);
|
|
329
330
|
}
|
|
330
331
|
}
|
|
331
|
-
} catch (
|
|
332
|
-
console.error(
|
|
332
|
+
} catch (error) {
|
|
333
|
+
console.error(error);
|
|
334
|
+
throw new Error(`Error processing directory: ${folder}`);
|
|
333
335
|
}
|
|
334
336
|
}
|
|
335
337
|
|
package/exporter/utils/sites.ts
CHANGED
|
@@ -284,8 +284,9 @@ function saveFile(filePath: string, content: string) {
|
|
|
284
284
|
fs.mkdirSync(pathName, { recursive: true });
|
|
285
285
|
}
|
|
286
286
|
fs.writeFileSync(filePath, content);
|
|
287
|
-
} catch (
|
|
288
|
-
console.error
|
|
287
|
+
} catch (error) {
|
|
288
|
+
console.log(error);
|
|
289
|
+
throw new Error(`Error saving a file`);
|
|
289
290
|
}
|
|
290
291
|
}
|
|
291
292
|
|
package/exporter/utils/store.ts
CHANGED
|
@@ -8,7 +8,9 @@ import path from "node:path";
|
|
|
8
8
|
|
|
9
9
|
import fsx from "fs-extra";
|
|
10
10
|
|
|
11
|
+
import { throwError } from "../errors";
|
|
11
12
|
import { getConfig, removeProperties, walk, walkStore } from "./core-utils";
|
|
13
|
+
import { ReadFromStoreError, WriteToStoreError } from "../errors/errors-data";
|
|
12
14
|
|
|
13
15
|
const config = getConfig();
|
|
14
16
|
|
|
@@ -64,13 +66,14 @@ function* getBuildPagesFromStore<PageType extends GriddoPageObject>(args?: {
|
|
|
64
66
|
yield page;
|
|
65
67
|
}
|
|
66
68
|
} catch (error) {
|
|
67
|
-
|
|
69
|
+
throwError(ReadFromStoreError, error);
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
|
-
* Read all pages stored in `store` Griddo directory and return the absolute
|
|
75
|
+
* Read all pages stored in `store` Griddo directory and return the absolute
|
|
76
|
+
* path.
|
|
74
77
|
*/
|
|
75
78
|
function getBuildPagesPath() {
|
|
76
79
|
const config = getConfig();
|
|
@@ -198,8 +201,8 @@ function savePagesInStore(
|
|
|
198
201
|
const filePath = path.join(__cx, "store", siteFolderName, filename);
|
|
199
202
|
fsx.writeJSONSync(filePath, page);
|
|
200
203
|
}
|
|
201
|
-
} catch (
|
|
202
|
-
|
|
204
|
+
} catch (error) {
|
|
205
|
+
throwError(WriteToStoreError, error);
|
|
203
206
|
}
|
|
204
207
|
}
|
|
205
208
|
|
|
@@ -219,7 +222,8 @@ function removePagesFromStore(siteDirName: string, filenames: Array<number>) {
|
|
|
219
222
|
try {
|
|
220
223
|
fs.unlinkSync(filePath);
|
|
221
224
|
} catch (error) {
|
|
222
|
-
console.log(
|
|
225
|
+
console.log(error);
|
|
226
|
+
throw new Error(`Error removing file ${filename}`);
|
|
223
227
|
}
|
|
224
228
|
}
|
|
225
229
|
}
|
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.0.
|
|
4
|
+
"version": "11.0.9",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"// NPM": "",
|
|
35
35
|
"prepare": "yarn run build",
|
|
36
36
|
"// BUILD": "",
|
|
37
|
-
"build": "sh ./
|
|
38
|
-
"build:debug": "sh ./
|
|
37
|
+
"build": "sh ./exporter/build.sh",
|
|
38
|
+
"build:debug": "sh ./exporter/build.sh --debug",
|
|
39
39
|
"// TESTS": "",
|
|
40
40
|
"test": "tsx ./__tests__/utils/tests-health.ts && jest --verbose",
|
|
41
41
|
"test:create-render-fixtures": "tsx ./__tests__/utils/create-fixtures.ts",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@babel/preset-env": "7.24.7",
|
|
61
61
|
"@babel/preset-react": "7.24.7",
|
|
62
62
|
"@babel/preset-typescript": "7.24.7",
|
|
63
|
-
"@griddo/core": "11.0.
|
|
63
|
+
"@griddo/core": "11.0.9",
|
|
64
64
|
"@svgr/webpack": "8.1.0",
|
|
65
65
|
"axios": "^1.7.4",
|
|
66
66
|
"babel-loader": "9.1.3",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"publishConfig": {
|
|
128
128
|
"access": "public"
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "5b1d8199d3fed51e32cf0f47e5c65210f6b1eeef"
|
|
131
131
|
}
|
package/src/gatsby-node-utils.ts
CHANGED