@griddo/cx 11.9.7 → 11.9.8-rc.1
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/README.md +78 -193
- package/build/commands/end-render.js +31 -0
- package/build/commands/end-render.js.map +7 -0
- package/build/commands/prepare-assets-directory.js +9 -0
- package/build/commands/prepare-assets-directory.js.map +7 -0
- package/build/commands/prepare-domains-render.js +38 -0
- package/build/commands/prepare-domains-render.js.map +7 -0
- package/build/commands/reset-render.js +31 -0
- package/build/commands/reset-render.js.map +7 -0
- package/build/commands/start-embeddings.js +31 -0
- package/build/commands/start-embeddings.js.map +7 -0
- package/build/commands/start-render.js +66 -0
- package/build/commands/start-render.js.map +7 -0
- package/build/commands/upload-search-content.js +31 -0
- package/build/commands/upload-search-content.js.map +7 -0
- package/build/core/GriddoLog.d.ts +16 -0
- package/build/core/db.d.ts +4 -0
- package/build/core/dist-rollback.d.ts +2 -0
- package/build/{errors/index.d.ts → core/errors.d.ts} +5 -4
- package/build/core/fs.d.ts +69 -0
- package/build/core/logger.d.ts +18 -0
- package/build/index.d.ts +10 -29
- package/build/index.js +406 -73
- package/build/services/auth.d.ts +2 -5
- package/build/services/manage-store.d.ts +48 -0
- package/build/services/render.d.ts +70 -0
- package/build/shared/envs.d.ts +19 -0
- package/build/{errors/errors-data.d.ts → shared/errors.d.ts} +5 -3
- package/build/shared/npm-modules/brush.d.ts +18 -0
- package/build/shared/npm-modules/find-up-simple.d.ts +34 -0
- package/build/shared/npm-modules/pkg-dir.d.ts +7 -0
- package/build/{types → shared/types}/api.d.ts +18 -18
- package/build/{types → shared/types}/global.d.ts +15 -16
- package/build/{types → shared/types}/navigation.d.ts +5 -5
- package/build/{types → shared/types}/pages.d.ts +9 -9
- package/build/shared/types/render.d.ts +54 -0
- package/build/{types → shared/types}/sites.d.ts +18 -19
- package/cli.mjs +239 -0
- package/exporter/build-esbuild.noop +42 -0
- package/exporter/build.sh +17 -28
- package/exporter/commands/README.md +151 -0
- package/exporter/commands/end-render.ts +65 -86
- package/exporter/commands/prepare-assets-directory.ts +34 -0
- package/exporter/commands/prepare-domains-render.ts +143 -35
- package/exporter/commands/reset-render.ts +12 -7
- package/exporter/commands/single-domain-upload-search-content.noop +206 -0
- package/exporter/commands/start-embeddings.ts +29 -0
- package/exporter/commands/start-render.ts +26 -64
- package/exporter/commands/upload-search-content.ts +201 -26
- package/exporter/core/GriddoLog.ts +45 -0
- package/exporter/core/check-env-health.ts +200 -0
- package/exporter/core/db-class.ts +54 -0
- package/exporter/core/db.ts +33 -0
- package/exporter/core/dist-rollback.ts +40 -0
- package/exporter/core/errors.ts +82 -0
- package/exporter/core/fs.ts +385 -0
- package/exporter/{utils → core}/images.ts +1 -6
- package/exporter/{utils → core}/instance.ts +9 -13
- package/exporter/core/life-cycle.ts +73 -0
- package/exporter/core/logger.ts +141 -0
- package/exporter/core/objects.ts +37 -0
- package/exporter/core/print-logos.ts +21 -0
- package/exporter/index.ts +14 -56
- package/exporter/services/api.ts +306 -0
- package/exporter/services/auth.ts +8 -10
- package/exporter/services/domains.ts +23 -8
- package/exporter/services/manage-sites.ts +116 -0
- package/exporter/services/manage-store.ts +235 -0
- package/exporter/services/navigation.ts +12 -18
- package/exporter/{utils → services}/pages.ts +27 -92
- package/exporter/services/reference-fields.ts +14 -32
- package/exporter/services/render-artifacts.ts +44 -0
- package/exporter/services/render.ts +229 -0
- package/exporter/services/robots.ts +33 -61
- package/exporter/services/sitemaps.ts +129 -0
- package/exporter/services/sites.ts +40 -28
- package/exporter/services/store.ts +386 -319
- package/exporter/shared/context.ts +49 -0
- package/exporter/{constants → shared}/endpoints.ts +12 -11
- package/exporter/shared/envs.ts +62 -0
- package/exporter/{errors/errors-data.ts → shared/errors.ts} +24 -14
- package/exporter/shared/npm-modules/README.md +36 -0
- package/exporter/shared/npm-modules/brush.ts +34 -0
- package/exporter/shared/npm-modules/find-up-simple.ts +100 -0
- package/exporter/shared/npm-modules/pkg-dir.ts +17 -0
- package/exporter/shared/npm-modules/xml-parser.ts +57 -0
- package/exporter/{types → shared/types}/api.ts +40 -41
- package/exporter/{types → shared/types}/global.ts +17 -21
- package/exporter/{types → shared/types}/navigation.ts +3 -3
- package/exporter/{types → shared/types}/pages.ts +10 -11
- package/exporter/shared/types/render.ts +63 -0
- package/exporter/{types → shared/types}/sites.ts +18 -19
- package/exporter/ssg-adapters/gatsby/actions/clean.ts +26 -0
- package/exporter/ssg-adapters/gatsby/actions/close.ts +17 -0
- package/exporter/ssg-adapters/gatsby/actions/data.ts +22 -0
- package/exporter/ssg-adapters/gatsby/actions/healthCheck.ts +10 -0
- package/exporter/ssg-adapters/gatsby/actions/init.ts +12 -0
- package/exporter/ssg-adapters/gatsby/actions/logs.ts +10 -0
- package/exporter/ssg-adapters/gatsby/actions/meta.ts +13 -0
- package/exporter/ssg-adapters/gatsby/actions/prepare.ts +9 -0
- package/exporter/ssg-adapters/gatsby/actions/relocation.ts +15 -0
- package/exporter/ssg-adapters/gatsby/actions/restore.ts +21 -0
- package/exporter/ssg-adapters/gatsby/actions/ssg.ts +12 -0
- package/exporter/ssg-adapters/gatsby/actions/sync.ts +65 -0
- package/exporter/ssg-adapters/gatsby/index.ts +114 -0
- package/exporter/ssg-adapters/gatsby/shared/artifacts.ts +16 -0
- package/exporter/ssg-adapters/gatsby/shared/diff-assets.ts +128 -0
- package/exporter/ssg-adapters/gatsby/shared/extract-assets.ts +75 -0
- package/exporter/ssg-adapters/gatsby/shared/gatsby-build.ts +58 -0
- package/exporter/ssg-adapters/gatsby/shared/sync-render.ts +300 -0
- package/exporter/ssg-adapters/gatsby/shared/types.ts +35 -0
- package/exporter/ssg-adapters/gatsby/shared/utils.ts +33 -0
- package/gatsby-browser.tsx +41 -58
- package/gatsby-config.ts +10 -17
- package/gatsby-node.ts +20 -80
- package/gatsby-ssr.tsx +2 -1
- package/package.json +41 -92
- package/plugins/gatsby-plugin-svgr-loader/gatsby-node.js +55 -0
- package/plugins/gatsby-plugin-svgr-loader/package.json +8 -0
- package/react/DynamicScript/index.tsx +33 -0
- package/{exporter/react/Favicon → react/GriddoFavicon}/index.tsx +3 -9
- package/{exporter/react → react}/GriddoIntegrations/index.tsx +17 -23
- package/{exporter/react → react}/GriddoIntegrations/utils.ts +24 -12
- package/react/GriddoOpenGraph/index.tsx +39 -0
- package/src/components/Head.tsx +30 -73
- package/src/components/template.tsx +8 -30
- package/src/gatsby-node-utils.ts +76 -2
- package/src/html.tsx +2 -11
- package/src/types.ts +5 -5
- package/tsconfig.commands.json +36 -0
- package/tsconfig.exporter.json +20 -0
- package/tsconfig.json +5 -3
- package/build/adapters/gatsby/index.d.ts +0 -4
- package/build/adapters/gatsby/utils.d.ts +0 -22
- package/build/artifacts/index.d.ts +0 -6
- package/build/commands/end-render.d.ts +0 -2
- package/build/commands/move-assets.d.ts +0 -1
- package/build/commands/prepare-domains-render.d.ts +0 -1
- package/build/commands/reset-render.d.ts +0 -2
- package/build/commands/start-render.d.ts +0 -2
- package/build/commands/upload-search-content.d.ts +0 -2
- package/build/constants/envs.d.ts +0 -37
- package/build/constants/index.d.ts +0 -57
- package/build/end-render.js +0 -74
- package/build/end-render.js.map +0 -7
- package/build/index.js.map +0 -7
- package/build/prepare-domains-render.js +0 -73
- package/build/prepare-domains-render.js.map +0 -7
- package/build/react/Favicon/index.d.ts +0 -5
- package/build/react/Favicon/utils.d.ts +0 -9
- package/build/react/GriddoIntegrations/index.d.ts +0 -20
- package/build/react/GriddoIntegrations/utils.d.ts +0 -26
- package/build/react/index.d.ts +0 -3
- package/build/react/index.js +0 -3
- package/build/registers/api.d.ts +0 -9
- package/build/registers/gatsby.d.ts +0 -9
- package/build/registers/index.d.ts +0 -3
- package/build/reset-render.js +0 -74
- package/build/reset-render.js.map +0 -7
- package/build/services/domains.d.ts +0 -6
- package/build/services/navigation.d.ts +0 -50
- package/build/services/reference-fields.d.ts +0 -20
- package/build/services/register.d.ts +0 -36
- package/build/services/robots.d.ts +0 -19
- package/build/services/settings.d.ts +0 -4
- package/build/services/sites.d.ts +0 -29
- package/build/services/store.d.ts +0 -6
- package/build/start-render.js +0 -100
- package/build/start-render.js.map +0 -7
- package/build/types/templates.d.ts +0 -8
- package/build/upload-search-content.js +0 -74
- package/build/upload-search-content.js.map +0 -7
- package/build/utils/alerts.d.ts +0 -3
- package/build/utils/api.d.ts +0 -23
- package/build/utils/cache.d.ts +0 -35
- package/build/utils/core-utils.d.ts +0 -107
- package/build/utils/create-build-data.d.ts +0 -8
- package/build/utils/domains.d.ts +0 -13
- package/build/utils/folders.d.ts +0 -53
- package/build/utils/health-checks.d.ts +0 -7
- package/build/utils/images.d.ts +0 -16
- package/build/utils/loggin.d.ts +0 -51
- package/build/utils/pages.d.ts +0 -34
- package/build/utils/render.d.ts +0 -13
- package/build/utils/searches.d.ts +0 -15
- package/build/utils/sites.d.ts +0 -31
- package/build/utils/store.d.ts +0 -81
- package/cx.config.d.ts +0 -5
- package/cx.config.js +0 -36
- package/exporter/adapters/gatsby/index.ts +0 -162
- package/exporter/adapters/gatsby/utils.ts +0 -161
- package/exporter/artifacts/README.md +0 -34
- package/exporter/artifacts/index.ts +0 -33
- package/exporter/commands/move-assets.ts +0 -11
- package/exporter/constants/envs.ts +0 -94
- package/exporter/constants/index.ts +0 -129
- package/exporter/errors/index.ts +0 -40
- package/exporter/react/index.tsx +0 -11
- package/exporter/registers/api.ts +0 -14
- package/exporter/registers/gatsby.ts +0 -14
- package/exporter/registers/index.ts +0 -4
- package/exporter/services/register.ts +0 -113
- package/exporter/services/settings.ts +0 -17
- package/exporter/utils/alerts.ts +0 -29
- package/exporter/utils/api.ts +0 -243
- package/exporter/utils/cache.ts +0 -142
- package/exporter/utils/core-utils.ts +0 -458
- package/exporter/utils/create-build-data.ts +0 -17
- package/exporter/utils/domains.ts +0 -39
- package/exporter/utils/folders.ts +0 -320
- package/exporter/utils/health-checks.ts +0 -64
- package/exporter/utils/loggin.ts +0 -184
- package/exporter/utils/render.ts +0 -71
- package/exporter/utils/searches.ts +0 -156
- package/exporter/utils/sites.ts +0 -312
- package/exporter/utils/store.ts +0 -314
- package/src/README.md +0 -7
- package/start-render.js +0 -7
- /package/build/{utils → core}/instance.d.ts +0 -0
- /package/build/{constants → shared}/endpoints.d.ts +0 -0
- /package/exporter/{types → shared/types}/templates.ts +0 -0
- /package/{exporter/react/Favicon → react/GriddoFavicon}/utils.ts +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
interface SSG {
|
|
2
|
+
assetPrefix: string;
|
|
3
|
+
ssgArtifacts: {
|
|
4
|
+
disposables: string[];
|
|
5
|
+
cacheables: string[];
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Minimal representation of the page structure
|
|
10
|
+
interface GatsbyPageData {
|
|
11
|
+
path: string;
|
|
12
|
+
result: {
|
|
13
|
+
pageContext: {
|
|
14
|
+
id: number;
|
|
15
|
+
title: string;
|
|
16
|
+
path: string;
|
|
17
|
+
openGraph: any;
|
|
18
|
+
pageMetadata: any;
|
|
19
|
+
page: {
|
|
20
|
+
site: number;
|
|
21
|
+
id: number;
|
|
22
|
+
fullPath: { compose: string };
|
|
23
|
+
language: number;
|
|
24
|
+
title: string;
|
|
25
|
+
fullUrl: string;
|
|
26
|
+
templateId: string;
|
|
27
|
+
template: {
|
|
28
|
+
templateType: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type { GatsbyPageData, SSG };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { readDB, writeDB } from "../../../core/db";
|
|
2
|
+
import { GriddoLog } from "../../../core/GriddoLog";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Enables the rollback-on-error feature for subsequent render lifecycles.
|
|
6
|
+
* When this feature is active, if an error occurs during a render process,
|
|
7
|
+
* the application will automatically restore the 'exports' directory to its
|
|
8
|
+
* state before the render began. This function updates the configuration
|
|
9
|
+
* in the database to reflect this change.
|
|
10
|
+
* @async
|
|
11
|
+
*/
|
|
12
|
+
async function enableRollbackOnError() {
|
|
13
|
+
const data = await readDB();
|
|
14
|
+
data.needsRollbackOnError = true;
|
|
15
|
+
await writeDB(data);
|
|
16
|
+
GriddoLog.info("Render lifecycles that follow will restore the exports dir on error if needed\n");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Disables the rollback-on-error feature for subsequent render lifecycles.
|
|
21
|
+
* When this feature is inactive, the application will not restore the
|
|
22
|
+
* 'exports' directory if a render process fails. This is the default behavior.
|
|
23
|
+
* This function updates the configuration in the database.
|
|
24
|
+
* @async
|
|
25
|
+
*/
|
|
26
|
+
async function disableRollbackOnError() {
|
|
27
|
+
const data = await readDB();
|
|
28
|
+
data.needsRollbackOnError = false;
|
|
29
|
+
await writeDB(data);
|
|
30
|
+
GriddoLog.info("Render lifecycles that follow will not restore the exports dir on error\n");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { disableRollbackOnError, enableRollbackOnError };
|
package/gatsby-browser.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import type { GatsbyBrowser } from "gatsby";
|
|
|
2
2
|
|
|
3
3
|
import { SessionProvider } from "@griddo/core";
|
|
4
4
|
import { browser } from "@griddo-instance";
|
|
5
|
-
import * as React from "react";
|
|
6
5
|
|
|
7
6
|
export const disableCorePrefetching = () => {
|
|
8
7
|
if (browser.disableCorePrefetching) {
|
|
@@ -22,9 +21,7 @@ export const onInitialClientRender = () => {
|
|
|
22
21
|
}
|
|
23
22
|
};
|
|
24
23
|
|
|
25
|
-
export const onPostPrefetchPathname: GatsbyBrowser["onPostPrefetchPathname"] = (
|
|
26
|
-
props,
|
|
27
|
-
) => {
|
|
24
|
+
export const onPostPrefetchPathname: GatsbyBrowser["onPostPrefetchPathname"] = (props) => {
|
|
28
25
|
if (browser.onPostPrefetchPathname) {
|
|
29
26
|
browser.onPostPrefetchPathname(props);
|
|
30
27
|
}
|
|
@@ -36,75 +33,61 @@ export const onPreRouteUpdate: GatsbyBrowser["onPreRouteUpdate"] = (props) => {
|
|
|
36
33
|
}
|
|
37
34
|
};
|
|
38
35
|
|
|
39
|
-
export const onPrefetchPathname: GatsbyBrowser["onPrefetchPathname"] = (
|
|
40
|
-
props,
|
|
41
|
-
) => {
|
|
36
|
+
export const onPrefetchPathname: GatsbyBrowser["onPrefetchPathname"] = (props) => {
|
|
42
37
|
if (browser.onPrefetchPathname) {
|
|
43
38
|
browser.onPrefetchPathname(props);
|
|
44
39
|
}
|
|
45
40
|
};
|
|
46
41
|
|
|
47
|
-
export const onRouteUpdateDelayed: GatsbyBrowser["onRouteUpdateDelayed"] = (
|
|
48
|
-
props,
|
|
49
|
-
) => {
|
|
42
|
+
export const onRouteUpdateDelayed: GatsbyBrowser["onRouteUpdateDelayed"] = (props) => {
|
|
50
43
|
if (browser.onServiceWorkerActive) {
|
|
51
44
|
browser.onRouteUpdateDelayed(props);
|
|
52
45
|
}
|
|
53
46
|
};
|
|
54
47
|
|
|
55
|
-
export const onServiceWorkerActive: GatsbyBrowser["onServiceWorkerActive"] = (
|
|
56
|
-
props,
|
|
57
|
-
) => {
|
|
48
|
+
export const onServiceWorkerActive: GatsbyBrowser["onServiceWorkerActive"] = (props) => {
|
|
58
49
|
if (browser.onServiceWorkerActive) {
|
|
59
50
|
browser.onServiceWorkerActive(props);
|
|
60
51
|
}
|
|
61
52
|
};
|
|
62
53
|
|
|
63
|
-
export const onServiceWorkerInstalled: GatsbyBrowser["onServiceWorkerInstalled"] =
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (browser.replaceHydrateFunction) {
|
|
101
|
-
return browser.replaceHydrateFunction();
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const shouldUpdateScroll: GatsbyBrowser["shouldUpdateScroll"] = (
|
|
106
|
-
props,
|
|
107
|
-
) => {
|
|
54
|
+
export const onServiceWorkerInstalled: GatsbyBrowser["onServiceWorkerInstalled"] = (props) => {
|
|
55
|
+
if (browser.onServiceWorkerInstalled) {
|
|
56
|
+
browser.onServiceWorkerInstalled(props);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const onServiceWorkerRedundant: GatsbyBrowser["onServiceWorkerRedundant"] = (props) => {
|
|
61
|
+
if (browser.onServiceWorkerRedundant) {
|
|
62
|
+
browser.onServiceWorkerRedundant(props);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const onServiceWorkerUpdateFound: GatsbyBrowser["onServiceWorkerUpdateFound"] = (props) => {
|
|
67
|
+
if (browser.onServiceWorkerUpdateFound) {
|
|
68
|
+
browser.onServiceWorkerUpdateFound(props);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const onServiceWorkerUpdateReady: GatsbyBrowser["onServiceWorkerUpdateReady"] = (props) => {
|
|
73
|
+
if (browser.onServiceWorkerUpdateReady) {
|
|
74
|
+
browser.onServiceWorkerUpdateReady(props);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const registerServiceWorker: GatsbyBrowser["registerServiceWorker"] = () => {
|
|
79
|
+
if (browser.registerServiceWorker) {
|
|
80
|
+
return browser.registerServiceWorker();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const replaceHydrateFunction: GatsbyBrowser["replaceHydrateFunction"] = () => {
|
|
85
|
+
if (browser.replaceHydrateFunction) {
|
|
86
|
+
return browser.replaceHydrateFunction();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const shouldUpdateScroll: GatsbyBrowser["shouldUpdateScroll"] = (props) => {
|
|
108
91
|
if (browser.shouldUpdateScroll) {
|
|
109
92
|
return browser.shouldUpdateScroll(props);
|
|
110
93
|
}
|
package/gatsby-config.ts
CHANGED
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
import type { GatsbyConfig } from "gatsby";
|
|
2
2
|
|
|
3
|
-
import { resolveComponentsPath
|
|
4
|
-
import dotenv from "dotenv";
|
|
5
|
-
|
|
6
|
-
dotenv.config();
|
|
3
|
+
import { resolveComponentsPath } from "./build";
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Este process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN se lee porque
|
|
10
|
-
* se ha introducido en el spawnSync del la función
|
|
7
|
+
* se ha introducido en el spawnSync del la función gatsbyBuild.
|
|
11
8
|
*
|
|
12
9
|
* ...
|
|
13
|
-
* env:
|
|
14
|
-
*
|
|
10
|
+
* env: {
|
|
11
|
+
* ...process.env,
|
|
15
12
|
* SPAWN_ASSET_PREFIX_WITH_DOMAIN: assetPrefixWithDomain, <--------------
|
|
16
13
|
* NODE_OPTIONS: undefined,
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* @see runGatsbyBuildCommand()
|
|
20
|
-
* @todo quiar el `... || undefined`
|
|
14
|
+
* },
|
|
21
15
|
*/
|
|
22
|
-
const griddoAssetPrefixWithDomain =
|
|
23
|
-
process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN || undefined;
|
|
16
|
+
const griddoAssetPrefixWithDomain = process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN || undefined;
|
|
24
17
|
|
|
25
|
-
|
|
18
|
+
if (process.env.GRIDDO_SSG_VERBOSE_LOGS) {
|
|
19
|
+
console.log(`set config.assetPrefix=${griddoAssetPrefixWithDomain}`);
|
|
20
|
+
}
|
|
26
21
|
|
|
27
22
|
// Gatsby configuration file from client
|
|
28
|
-
const { plugins, ...gatsbyConfig } = require(
|
|
29
|
-
resolveComponentsPath("builder.config.js"),
|
|
30
|
-
);
|
|
23
|
+
const { plugins, ...gatsbyConfig } = require(resolveComponentsPath("builder.config.js"));
|
|
31
24
|
|
|
32
25
|
const config: GatsbyConfig = {
|
|
33
26
|
// Client config
|
package/gatsby-node.ts
CHANGED
|
@@ -1,49 +1,33 @@
|
|
|
1
|
-
import type { GatsbyPageObject } from "./src/types";
|
|
2
1
|
import type { GatsbyNode } from "gatsby";
|
|
2
|
+
import type { GatsbyPageObject } from "./src/types";
|
|
3
3
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
debugLog,
|
|
9
|
-
envs,
|
|
10
|
-
getBuildPagesFromStore,
|
|
11
|
-
getConfig,
|
|
12
|
-
pageSizeLog,
|
|
13
|
-
verboseLog,
|
|
14
|
-
} from "@griddo/cx";
|
|
15
|
-
|
|
16
|
-
import { gatsbyRegister } from "./exporter/registers";
|
|
17
|
-
import { insertAlert } from "./exporter/utils/alerts";
|
|
18
|
-
|
|
19
|
-
const showGriddoBuildLogs = envs.GRIDDO_BUILD_LOGS;
|
|
6
|
+
import { addLogToBuffer, isComponentLibrary } from "./build";
|
|
7
|
+
import { getBuildPagesFromStore, pageSizeLog } from "./src/gatsby-node-utils";
|
|
20
8
|
|
|
21
9
|
// process.env available through gatsbyBuildCommand.
|
|
10
|
+
const showGriddoBuildLogs = JSON.parse(process.env.GRIDDO_BUILD_LOGS || "false");
|
|
11
|
+
const showSSGVerboseLogs = JSON.parse(process.env.GRIDDO_VERBOSE_SSG || "false");
|
|
22
12
|
const assetPrefixWithDomain = process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN;
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
process.env.GRIDDO_EXPERIMENTAL_DO_NOT_USE_MATCH_PATH || "false",
|
|
26
|
-
);
|
|
27
|
-
const useMatchPaths = !avoidMatchPath;
|
|
28
|
-
const needsAssetDomainPrefix =
|
|
29
|
-
!!assetPrefixWithDomain && assetPrefixWithDomain !== "";
|
|
13
|
+
const needsAssetDomainPrefix = !!assetPrefixWithDomain && assetPrefixWithDomain !== "";
|
|
14
|
+
const nodeOptions = process.env.NODE_OPTIONS;
|
|
30
15
|
|
|
31
|
-
const
|
|
32
|
-
const
|
|
16
|
+
const template = path.resolve("./src/components/template.tsx");
|
|
17
|
+
const dbFilePath = isComponentLibrary
|
|
18
|
+
? path.resolve(__dirname, "../../..", ".griddo/cache/db.json")
|
|
19
|
+
: path.resolve(__dirname, "../..", ".griddo/cache/db.json");
|
|
33
20
|
|
|
34
21
|
const pages = getBuildPagesFromStore<GatsbyPageObject>({
|
|
35
22
|
withSizeProp: showGriddoBuildLogs,
|
|
23
|
+
dbFilePath,
|
|
36
24
|
});
|
|
37
25
|
|
|
38
26
|
const createPages: GatsbyNode["createPages"] = async ({ actions }) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
`using
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
if (avoidMatchPath) {
|
|
46
|
-
console.log(`[!] GRIDDO EXPERIMENTAL: Avoiding use of matchPath`);
|
|
27
|
+
if (showSSGVerboseLogs) {
|
|
28
|
+
console.log(`read assetPrefixWithDomain=${assetPrefixWithDomain}`);
|
|
29
|
+
console.log(`set needsAssetDomainPrefix=${needsAssetDomainPrefix}`);
|
|
30
|
+
console.log(`using NODE_OPTIONS in gatsby-node.ts: ${nodeOptions}`);
|
|
47
31
|
}
|
|
48
32
|
|
|
49
33
|
for await (const page of pages) {
|
|
@@ -51,60 +35,16 @@ const createPages: GatsbyNode["createPages"] = async ({ actions }) => {
|
|
|
51
35
|
return;
|
|
52
36
|
}
|
|
53
37
|
|
|
54
|
-
const matchPath =
|
|
55
|
-
needsAssetDomainPrefix && useMatchPaths
|
|
56
|
-
? page.context.fullPath.compose
|
|
57
|
-
: "";
|
|
58
|
-
|
|
59
38
|
page.component = template;
|
|
60
|
-
page.matchPath = matchPath;
|
|
61
39
|
|
|
62
40
|
actions.createPage(page);
|
|
63
41
|
|
|
64
|
-
const path = page.path;
|
|
65
|
-
const id = page.context.id;
|
|
66
|
-
const size = pageSizeLog(Math.round(page.size || 0));
|
|
67
|
-
|
|
68
|
-
if (sendAlertActive && page.size) {
|
|
69
|
-
const pageMaxSizeReached =
|
|
70
|
-
page.size >
|
|
71
|
-
Number.parseInt(process.env.GRIDDO_SSG_MAX_PAGE_SIZE || "524288") /
|
|
72
|
-
1024;
|
|
73
|
-
|
|
74
|
-
if (pageMaxSizeReached) {
|
|
75
|
-
gatsbyRegister.insert("GATSBY_PAGE_SIZE_TOO_BIG", {
|
|
76
|
-
path: page.path,
|
|
77
|
-
size: `${Math.round(page.size)}KB`,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
42
|
if (showGriddoBuildLogs) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (sendAlertActive) {
|
|
88
|
-
const registerContent = gatsbyRegister.get("GATSBY_PAGE_SIZE_TOO_BIG");
|
|
89
|
-
|
|
90
|
-
if (registerContent.entries.length < 1) {
|
|
91
|
-
return;
|
|
43
|
+
const id = page.context.id;
|
|
44
|
+
const path = page.path;
|
|
45
|
+
const size = pageSizeLog(Math.round(page.size || 0));
|
|
46
|
+
addLogToBuffer(`Creating page ${path} - ${id} - ${size}`);
|
|
92
47
|
}
|
|
93
|
-
|
|
94
|
-
debugLog("\nRender register report\n");
|
|
95
|
-
debugLog(registerContent);
|
|
96
|
-
debugLog();
|
|
97
|
-
|
|
98
|
-
await insertAlert({
|
|
99
|
-
description: "Render register report",
|
|
100
|
-
area: "Griddo",
|
|
101
|
-
level: "W",
|
|
102
|
-
fullData: {
|
|
103
|
-
output: registerContent,
|
|
104
|
-
date: new Date().toISOString(),
|
|
105
|
-
},
|
|
106
|
-
instantNotification: false,
|
|
107
|
-
});
|
|
108
48
|
}
|
|
109
49
|
};
|
|
110
50
|
|
package/gatsby-ssr.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { GatsbySSR } from "gatsby";
|
|
2
2
|
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
3
5
|
import { SessionProvider } from "@griddo/core";
|
|
4
6
|
import { ssr } from "@griddo-instance";
|
|
5
|
-
import * as React from "react";
|
|
6
7
|
|
|
7
8
|
export const wrapPageElement: GatsbySSR["wrapPageElement"] = (props) => {
|
|
8
9
|
if (ssr.wrapPageElement) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/cx",
|
|
3
3
|
"description": "Griddo SSG based on Gatsby",
|
|
4
|
-
"version": "11.9.
|
|
4
|
+
"version": "11.9.8-rc.1",
|
|
5
5
|
"authors": [
|
|
6
|
-
"
|
|
7
|
-
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
8
|
-
"Francis Vega <francis.vega@secuoyas.com>",
|
|
9
|
-
"Gonzalo Hernández <gonzalo.hernandez@secuoyas.com>",
|
|
10
|
-
"Sergio Ródenas <sergio.rodenas@secuoyas.com>"
|
|
6
|
+
"Hisco <francis.vega@griddo.io>"
|
|
11
7
|
],
|
|
12
8
|
"license": "UNLICENSED",
|
|
13
9
|
"homepage": "https://griddo.io",
|
|
@@ -15,120 +11,73 @@
|
|
|
15
11
|
"type": "git",
|
|
16
12
|
"url": "https://github.com/griddo/griddo"
|
|
17
13
|
},
|
|
18
|
-
"bin": {
|
|
19
|
-
"griddo-cx": "./start-render.js",
|
|
20
|
-
"griddo-start-render": "./start-render.js"
|
|
21
|
-
},
|
|
22
|
-
"exports": {
|
|
23
|
-
".": {
|
|
24
|
-
"import": "./build/index.js",
|
|
25
|
-
"require": "./build/index.js",
|
|
26
|
-
"types": "./build/index.d.ts"
|
|
27
|
-
},
|
|
28
|
-
"./react": {
|
|
29
|
-
"import": "./build/react/index.js",
|
|
30
|
-
"require": "./build/react/index.js",
|
|
31
|
-
"types": "./build/react/index.d.ts"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
14
|
"scripts": {
|
|
35
15
|
"// NPM": "",
|
|
36
16
|
"prepare": "yarn run build",
|
|
37
17
|
"// BUILD": "",
|
|
38
|
-
"build": "sh ./exporter/build.sh",
|
|
39
|
-
"build:debug": "sh ./exporter/build.sh --debug",
|
|
18
|
+
"build": "rm -rf build && sh ./exporter/build.sh",
|
|
19
|
+
"build:debug": "rm -rf build && sh ./exporter/build.sh --debug",
|
|
40
20
|
"// TESTS": "",
|
|
41
|
-
"test": "
|
|
42
|
-
"test
|
|
43
|
-
"test:
|
|
21
|
+
"test": "npm run test:compile && npm run test:create-render-fixtures && node --env-file=.env --test ./build/__tests__/* && npm run test:remove-render-fixtures",
|
|
22
|
+
"test-exporter": "npm run test:compile && node --env-file=.env --test ./build/__tests__exporter__/",
|
|
23
|
+
"test:create-render-fixtures": "node --env-file=.env ./build/__tests__/utils/create-fixtures",
|
|
24
|
+
"test:remove-render-fixtures": "node --env-file=.env ./build/__tests__/utils/remove-fixtures",
|
|
25
|
+
"test:compile": "tsgo --project tsconfig.tests.json",
|
|
44
26
|
"// INFRA SCRIPTS": "",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"end-render": "node ./build/end-render
|
|
48
|
-
"
|
|
49
|
-
"reset-render": "node ./build/reset-render
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"// LINTER": "",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"run:format": "prettier --write ."
|
|
27
|
+
"prepare-domains-render": "node ./build/commands/prepare-domains-render",
|
|
28
|
+
"start-render": "node ./build/commands/start-render",
|
|
29
|
+
"end-render": "node ./build/commands/end-render",
|
|
30
|
+
"upload-search-content": "node ./build/commands/upload-search-content",
|
|
31
|
+
"reset-render": "node ./build/commands/reset-render",
|
|
32
|
+
"// ONLY LOCAL SCRIPTS": "",
|
|
33
|
+
"prepare-assets-directory": "node ./build/commands/prepare-assets-directory",
|
|
34
|
+
"create-rollback-copy": "rm -rf ../../exports-backup && cp -r ../../exports ../../exports-backup",
|
|
35
|
+
"render": "npm run build && node --env-file=.env cli.mjs render",
|
|
36
|
+
"// LINTER & FORMATTER": "",
|
|
37
|
+
"lint": "biome check --write",
|
|
38
|
+
"format": "biome format --write",
|
|
39
|
+
"flint": "npm run lint && npm run format",
|
|
40
|
+
"ts-lint": "tsgo --noEmit",
|
|
41
|
+
"watch:ts-lint": "tsc --noEmit --watch"
|
|
61
42
|
},
|
|
62
43
|
"dependencies": {
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"@babel/preset-env": "7.26.0",
|
|
66
|
-
"@babel/preset-react": "7.26.3",
|
|
67
|
-
"@babel/preset-typescript": "7.26.0",
|
|
68
|
-
"@griddo/core": "11.9.7",
|
|
69
|
-
"@svgr/webpack": "5.5.0",
|
|
70
|
-
"axios": "1.7.9",
|
|
71
|
-
"babel-loader": "9.2.1",
|
|
72
|
-
"babel-plugin-transform-runtime": "6.23.0",
|
|
73
|
-
"babel-polyfill": "6.26.0",
|
|
74
|
-
"dotenv": "16.4.5",
|
|
75
|
-
"esbuild": "0.24.0",
|
|
76
|
-
"find-up": "5.0.0",
|
|
77
|
-
"fs-extra": "11.2.0",
|
|
78
|
-
"gatsby": "5.14.0",
|
|
79
|
-
"gatsby-plugin-svgr-loader": "0.1.0",
|
|
80
|
-
"html-react-parser": "5.2.0",
|
|
81
|
-
"js2xmlparser": "5.0.0",
|
|
82
|
-
"kleur": "4.1.5",
|
|
83
|
-
"p-limit": "3.1.0",
|
|
84
|
-
"path-browserify": "1.0.1",
|
|
85
|
-
"pkg-dir": "5.0.0",
|
|
86
|
-
"typescript": "5.7.2",
|
|
87
|
-
"webpack": "5.76.1"
|
|
44
|
+
"gatsby": "5.15.0",
|
|
45
|
+
"typescript": "4.9.5"
|
|
88
46
|
},
|
|
89
47
|
"devDependencies": {
|
|
90
|
-
"@
|
|
91
|
-
"@types/
|
|
92
|
-
"@
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"@typescript-eslint/parser": "^8.0.0",
|
|
97
|
-
"cheerio": "1.0.0",
|
|
98
|
-
"eslint": "^9.0.0",
|
|
99
|
-
"eslint-plugin-import": "2.31.0",
|
|
100
|
-
"eslint-plugin-node": "11.1.0",
|
|
101
|
-
"eslint-plugin-react": "7.37.4",
|
|
102
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
103
|
-
"eslint-plugin-testing-library": "^6.2.0",
|
|
104
|
-
"globals": "^16.0.0",
|
|
105
|
-
"prettier": "3.4.2"
|
|
48
|
+
"@biomejs/biome": "2.2.6",
|
|
49
|
+
"@types/node": "20.19.4",
|
|
50
|
+
"@typescript/native-preview": "latest",
|
|
51
|
+
"cheerio": "1.1.2",
|
|
52
|
+
"esbuild": "0.25.11",
|
|
53
|
+
"p-limit": "7.2.0"
|
|
106
54
|
},
|
|
107
55
|
"peerDependencies": {
|
|
108
|
-
"@
|
|
109
|
-
"@types/react-dom": ">=18 <19",
|
|
56
|
+
"@griddo/core": "*",
|
|
110
57
|
"react": ">=18 <19",
|
|
111
58
|
"react-dom": ">=18 <19"
|
|
112
59
|
},
|
|
113
60
|
"engines": {
|
|
114
|
-
"node": ">=20"
|
|
61
|
+
"node": ">=20.19"
|
|
115
62
|
},
|
|
116
63
|
"files": [
|
|
117
64
|
"build",
|
|
118
65
|
"exporter",
|
|
119
66
|
"src",
|
|
120
|
-
"
|
|
121
|
-
"cx.config.js",
|
|
67
|
+
"react",
|
|
122
68
|
"gatsby-browser.tsx",
|
|
123
69
|
"gatsby-config.ts",
|
|
124
70
|
"gatsby-node.ts",
|
|
125
71
|
"gatsby-ssr.tsx",
|
|
126
72
|
"global.d.ts",
|
|
127
|
-
"
|
|
128
|
-
"tsconfig.json"
|
|
73
|
+
"tsconfig.commands.json",
|
|
74
|
+
"tsconfig.exporter.json",
|
|
75
|
+
"tsconfig.json",
|
|
76
|
+
"plugins",
|
|
77
|
+
"cli.mjs"
|
|
129
78
|
],
|
|
130
79
|
"publishConfig": {
|
|
131
80
|
"access": "public"
|
|
132
81
|
},
|
|
133
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "69d82b3b9c3f25bb54e502439b81d2c6009652d7"
|
|
134
83
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
exports.onCreateWebpackConfig = (
|
|
2
|
+
{ stage, actions, getConfig, rules },
|
|
3
|
+
{ rule: ruleProps = {} },
|
|
4
|
+
) => {
|
|
5
|
+
const { include, exclude, options, ...otherProps } = ruleProps;
|
|
6
|
+
|
|
7
|
+
if (["develop", "develop-html", "build-html", "build-javascript"].includes(stage)) {
|
|
8
|
+
// Add the react-svg-loader rule
|
|
9
|
+
actions.setWebpackConfig({
|
|
10
|
+
module: {
|
|
11
|
+
rules: [
|
|
12
|
+
{
|
|
13
|
+
test: /\.svg$/,
|
|
14
|
+
include,
|
|
15
|
+
exclude,
|
|
16
|
+
...otherProps,
|
|
17
|
+
use: [
|
|
18
|
+
{
|
|
19
|
+
loader: "@svgr/webpack",
|
|
20
|
+
options,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const cfg = getConfig();
|
|
28
|
+
const imgsRule = rules.images();
|
|
29
|
+
|
|
30
|
+
const newUrlLoaderRule =
|
|
31
|
+
include || exclude
|
|
32
|
+
? {
|
|
33
|
+
...imgsRule,
|
|
34
|
+
include: exclude,
|
|
35
|
+
exclude: include,
|
|
36
|
+
}
|
|
37
|
+
: {
|
|
38
|
+
...imgsRule,
|
|
39
|
+
test: new RegExp(imgsRule.test.toString().replace("svg|", "").slice(1, -1)),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
cfg.module.rules = [
|
|
43
|
+
// Remove the base url-loader images rule entirely
|
|
44
|
+
...cfg.module.rules.filter((rule) => {
|
|
45
|
+
if (rule.test) {
|
|
46
|
+
return rule.test.toString() !== imgsRule.test.toString();
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}),
|
|
50
|
+
// Put it back without SVG loading
|
|
51
|
+
newUrlLoaderRule,
|
|
52
|
+
];
|
|
53
|
+
actions.replaceWebpackConfig(cfg);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
const DynamicScript = (props: { scriptContent: string }) => {
|
|
4
|
+
const { scriptContent } = props;
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (!scriptContent) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const scriptText = scriptContent.replace(/<script>|<\/script>/g, "");
|
|
12
|
+
if (!scriptText.trim()) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const script = document.createElement("script");
|
|
17
|
+
script.innerHTML = scriptText;
|
|
18
|
+
script.async = true;
|
|
19
|
+
|
|
20
|
+
document.body.appendChild(script);
|
|
21
|
+
|
|
22
|
+
return () => {
|
|
23
|
+
// Hacemos un chequeo por si el script ya fue removido por otro proceso.
|
|
24
|
+
if (document.body.contains(script)) {
|
|
25
|
+
document.body.removeChild(script);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}, [scriptContent]);
|
|
29
|
+
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { DynamicScript };
|