@griddo/cx 11.7.12-rc.4 → 11.7.12
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 +226 -27
- package/build/adapters/gatsby/index.d.ts +4 -0
- package/build/adapters/gatsby/utils.d.ts +22 -0
- package/build/artifacts/index.d.ts +6 -0
- package/build/commands/end-render.d.ts +2 -0
- package/build/commands/move-assets.d.ts +1 -0
- package/build/commands/prepare-domains-render.d.ts +1 -0
- package/build/commands/reset-render.d.ts +2 -0
- package/build/commands/start-render.d.ts +2 -0
- package/build/commands/upload-search-content.d.ts +2 -0
- package/build/constants/endpoints.d.ts +19 -0
- package/build/constants/envs.d.ts +37 -0
- package/build/constants/index.d.ts +57 -0
- package/build/end-render.js +74 -0
- package/build/end-render.js.map +7 -0
- package/build/errors/errors-data.d.ts +22 -0
- package/build/errors/index.d.ts +15 -0
- package/build/index.d.ts +29 -0
- package/build/index.js +73 -0
- package/build/index.js.map +7 -0
- package/build/prepare-domains-render.js +73 -0
- package/build/prepare-domains-render.js.map +7 -0
- package/build/react/Favicon/index.d.ts +5 -0
- package/build/react/Favicon/utils.d.ts +9 -0
- package/build/react/GriddoIntegrations/index.d.ts +20 -0
- package/build/react/GriddoIntegrations/utils.d.ts +26 -0
- package/{react/index.tsx → build/react/index.d.ts} +0 -1
- package/build/react/index.js +3 -0
- package/build/registers/api.d.ts +9 -0
- package/build/registers/gatsby.d.ts +9 -0
- package/build/registers/index.d.ts +3 -0
- package/build/reset-render.js +74 -0
- package/build/reset-render.js.map +7 -0
- package/build/services/auth.d.ts +10 -0
- package/build/services/domains.d.ts +6 -0
- package/build/services/navigation.d.ts +50 -0
- package/build/services/reference-fields.d.ts +20 -0
- package/build/services/register.d.ts +36 -0
- package/build/services/robots.d.ts +19 -0
- package/build/services/settings.d.ts +4 -0
- package/build/services/sites.d.ts +29 -0
- package/build/services/store.d.ts +6 -0
- package/build/start-render.js +100 -0
- package/build/start-render.js.map +7 -0
- package/build/types/api.d.ts +142 -0
- package/build/types/global.d.ts +84 -0
- package/build/types/navigation.d.ts +28 -0
- package/build/types/pages.d.ts +144 -0
- package/build/types/sites.d.ts +57 -0
- package/build/types/templates.d.ts +8 -0
- package/build/upload-search-content.js +74 -0
- package/build/upload-search-content.js.map +7 -0
- package/build/utils/alerts.d.ts +3 -0
- package/build/utils/api.d.ts +23 -0
- package/build/utils/cache.d.ts +35 -0
- package/build/utils/core-utils.d.ts +107 -0
- package/build/utils/create-build-data.d.ts +8 -0
- package/build/utils/domains.d.ts +13 -0
- package/build/utils/folders.d.ts +53 -0
- package/build/utils/health-checks.d.ts +7 -0
- package/build/utils/images.d.ts +16 -0
- package/build/utils/instance.d.ts +21 -0
- package/build/utils/loggin.d.ts +51 -0
- package/build/utils/pages.d.ts +34 -0
- package/build/utils/render.d.ts +13 -0
- package/build/utils/searches.d.ts +15 -0
- package/build/utils/sites.d.ts +31 -0
- package/build/utils/store.d.ts +81 -0
- package/cx.config.d.ts +5 -0
- package/cx.config.js +36 -0
- package/exporter/adapters/gatsby/index.ts +153 -73
- package/exporter/adapters/gatsby/utils.ts +161 -0
- package/exporter/artifacts/README.md +34 -0
- package/exporter/artifacts/index.ts +33 -0
- package/exporter/build.sh +38 -4
- package/exporter/commands/end-render.ts +70 -72
- package/exporter/commands/move-assets.ts +11 -0
- package/exporter/commands/prepare-domains-render.ts +31 -143
- package/exporter/commands/reset-render.ts +3 -10
- package/exporter/commands/start-render.ts +45 -22
- package/exporter/commands/upload-search-content.ts +21 -194
- package/exporter/constants/endpoints.ts +1 -2
- package/exporter/constants/envs.ts +55 -57
- package/exporter/constants/index.ts +129 -0
- package/exporter/{constants/errors.ts → errors/errors-data.ts} +14 -24
- package/exporter/{utils/errors.ts → errors/index.ts} +9 -10
- package/exporter/index.ts +82 -0
- package/{react → exporter/react}/Favicon/index.tsx +7 -1
- package/{react → exporter/react}/GriddoIntegrations/index.tsx +22 -16
- package/{react → exporter/react}/GriddoIntegrations/utils.ts +9 -21
- package/exporter/react/index.tsx +11 -0
- package/exporter/registers/api.ts +14 -0
- package/exporter/registers/gatsby.ts +14 -0
- package/exporter/registers/index.ts +4 -0
- package/exporter/services/auth.ts +6 -7
- package/exporter/services/domains.ts +16 -0
- package/exporter/services/navigation.ts +10 -4
- package/exporter/services/reference-fields.ts +24 -9
- package/exporter/services/register.ts +113 -0
- package/exporter/services/robots.ts +16 -9
- package/exporter/services/settings.ts +17 -0
- package/exporter/services/sites.ts +24 -36
- package/exporter/services/store.ts +96 -107
- package/exporter/types/api.ts +28 -27
- package/exporter/types/global.ts +11 -8
- package/exporter/types/navigation.ts +1 -1
- package/exporter/types/pages.ts +3 -2
- package/exporter/types/sites.ts +2 -1
- package/exporter/utils/alerts.ts +29 -0
- package/exporter/utils/api.ts +75 -55
- package/exporter/utils/cache.ts +62 -37
- package/exporter/utils/core-utils.ts +272 -133
- package/exporter/utils/create-build-data.ts +17 -0
- package/exporter/utils/domains.ts +7 -10
- package/exporter/utils/folders.ts +98 -163
- package/exporter/utils/health-checks.ts +64 -0
- package/exporter/utils/images.ts +6 -1
- package/exporter/utils/instance.ts +13 -9
- package/exporter/utils/loggin.ts +91 -44
- package/exporter/utils/pages.ts +88 -23
- package/exporter/utils/render.ts +48 -180
- package/exporter/utils/searches.ts +156 -0
- package/exporter/utils/sites.ts +197 -19
- package/exporter/utils/store.ts +180 -87
- package/gatsby-browser.tsx +58 -41
- package/gatsby-config.ts +17 -10
- package/gatsby-node.ts +78 -17
- package/gatsby-ssr.tsx +1 -2
- package/package.json +86 -36
- package/src/README.md +7 -0
- package/src/components/Head.tsx +46 -13
- package/src/components/template.tsx +30 -8
- package/src/gatsby-node-utils.ts +2 -73
- package/src/html.tsx +11 -2
- package/src/types.ts +5 -5
- package/start-render.js +7 -0
- package/tsconfig.json +3 -5
- package/build/adapters/gatsby/actions/clean.js +0 -10
- package/build/adapters/gatsby/actions/clean.js.map +0 -1
- package/build/adapters/gatsby/actions/close.js +0 -12
- package/build/adapters/gatsby/actions/close.js.map +0 -1
- package/build/adapters/gatsby/actions/data.js +0 -18
- package/build/adapters/gatsby/actions/data.js.map +0 -1
- package/build/adapters/gatsby/actions/healthCheck.js +0 -10
- package/build/adapters/gatsby/actions/healthCheck.js.map +0 -1
- package/build/adapters/gatsby/actions/init.js +0 -22
- package/build/adapters/gatsby/actions/init.js.map +0 -1
- package/build/adapters/gatsby/actions/logs.js +0 -12
- package/build/adapters/gatsby/actions/logs.js.map +0 -1
- package/build/adapters/gatsby/actions/meta.js +0 -13
- package/build/adapters/gatsby/actions/meta.js.map +0 -1
- package/build/adapters/gatsby/actions/prepare.js +0 -9
- package/build/adapters/gatsby/actions/prepare.js.map +0 -1
- package/build/adapters/gatsby/actions/relocation.js +0 -15
- package/build/adapters/gatsby/actions/relocation.js.map +0 -1
- package/build/adapters/gatsby/actions/restore.js +0 -26
- package/build/adapters/gatsby/actions/restore.js.map +0 -1
- package/build/adapters/gatsby/actions/ssg.js +0 -9
- package/build/adapters/gatsby/actions/ssg.js.map +0 -1
- package/build/adapters/gatsby/actions/sync.js +0 -51
- package/build/adapters/gatsby/actions/sync.js.map +0 -1
- package/build/adapters/gatsby/index.js +0 -78
- package/build/adapters/gatsby/index.js.map +0 -1
- package/build/adapters/gatsby/shared/artifacts.js +0 -20
- package/build/adapters/gatsby/shared/artifacts.js.map +0 -1
- package/build/adapters/gatsby/shared/context.js +0 -31
- package/build/adapters/gatsby/shared/context.js.map +0 -1
- package/build/adapters/gatsby/shared/diff-assets.js +0 -101
- package/build/adapters/gatsby/shared/diff-assets.js.map +0 -1
- package/build/adapters/gatsby/shared/extract-assets.js +0 -58
- package/build/adapters/gatsby/shared/extract-assets.js.map +0 -1
- package/build/adapters/gatsby/shared/gatsby-build.js +0 -55
- package/build/adapters/gatsby/shared/gatsby-build.js.map +0 -1
- package/build/adapters/gatsby/shared/sync-render.js +0 -210
- package/build/adapters/gatsby/shared/sync-render.js.map +0 -1
- package/build/adapters/gatsby/shared/types.js +0 -3
- package/build/adapters/gatsby/shared/types.js.map +0 -1
- package/build/commands/end-render.js +0 -87
- package/build/commands/end-render.js.map +0 -1
- package/build/commands/prepare-assets-directory.js +0 -30
- package/build/commands/prepare-assets-directory.js.map +0 -1
- package/build/commands/prepare-domains-render.js +0 -133
- package/build/commands/prepare-domains-render.js.map +0 -1
- package/build/commands/reset-render.js +0 -21
- package/build/commands/reset-render.js.map +0 -1
- package/build/commands/start-render.js +0 -44
- package/build/commands/start-render.js.map +0 -1
- package/build/commands/upload-search-content.js +0 -180
- package/build/commands/upload-search-content.js.map +0 -1
- package/build/constants/endpoints.js +0 -43
- package/build/constants/endpoints.js.map +0 -1
- package/build/constants/envs.js +0 -68
- package/build/constants/envs.js.map +0 -1
- package/build/constants/errors.js +0 -81
- package/build/constants/errors.js.map +0 -1
- package/build/services/auth.js +0 -40
- package/build/services/auth.js.map +0 -1
- package/build/services/db-class.js +0 -49
- package/build/services/db-class.js.map +0 -1
- package/build/services/db.js +0 -34
- package/build/services/db.js.map +0 -1
- package/build/services/navigation.js +0 -96
- package/build/services/navigation.js.map +0 -1
- package/build/services/reference-fields.js +0 -131
- package/build/services/reference-fields.js.map +0 -1
- package/build/services/robots.js +0 -60
- package/build/services/robots.js.map +0 -1
- package/build/services/sites.js +0 -110
- package/build/services/sites.js.map +0 -1
- package/build/services/store.js +0 -257
- package/build/services/store.js.map +0 -1
- package/build/types/api.js +0 -3
- package/build/types/api.js.map +0 -1
- package/build/types/global.js +0 -3
- package/build/types/global.js.map +0 -1
- package/build/types/navigation.js +0 -3
- package/build/types/navigation.js.map +0 -1
- package/build/types/pages.js +0 -3
- package/build/types/pages.js.map +0 -1
- package/build/types/render.js +0 -10
- package/build/types/render.js.map +0 -1
- package/build/types/sites.js +0 -3
- package/build/types/sites.js.map +0 -1
- package/build/types/templates.js +0 -3
- package/build/types/templates.js.map +0 -1
- package/build/utils/api.js +0 -165
- package/build/utils/api.js.map +0 -1
- package/build/utils/artifacts.js +0 -38
- package/build/utils/artifacts.js.map +0 -1
- package/build/utils/brush.js +0 -30
- package/build/utils/brush.js.map +0 -1
- package/build/utils/cache.js +0 -106
- package/build/utils/cache.js.map +0 -1
- package/build/utils/check-environment-health.js +0 -73
- package/build/utils/check-environment-health.js.map +0 -1
- package/build/utils/core-utils.js +0 -270
- package/build/utils/core-utils.js.map +0 -1
- package/build/utils/domains.js +0 -37
- package/build/utils/domains.js.map +0 -1
- package/build/utils/errors.js +0 -30
- package/build/utils/errors.js.map +0 -1
- package/build/utils/folders.js +0 -341
- package/build/utils/folders.js.map +0 -1
- package/build/utils/images.js +0 -45
- package/build/utils/images.js.map +0 -1
- package/build/utils/instance.js +0 -66
- package/build/utils/instance.js.map +0 -1
- package/build/utils/loggin.js +0 -119
- package/build/utils/loggin.js.map +0 -1
- package/build/utils/npm-deps/find-up-simple.js +0 -75
- package/build/utils/npm-deps/find-up-simple.js.map +0 -1
- package/build/utils/npm-deps/pkg-dir.js +0 -20
- package/build/utils/npm-deps/pkg-dir.js.map +0 -1
- package/build/utils/npm-deps/xml-parser.js +0 -49
- package/build/utils/npm-deps/xml-parser.js.map +0 -1
- package/build/utils/pages.js +0 -359
- package/build/utils/pages.js.map +0 -1
- package/build/utils/render.js +0 -168
- package/build/utils/render.js.map +0 -1
- package/build/utils/sitemaps.js +0 -110
- package/build/utils/sitemaps.js.map +0 -1
- package/build/utils/sites.js +0 -105
- package/build/utils/sites.js.map +0 -1
- package/build/utils/store.js +0 -193
- package/build/utils/store.js.map +0 -1
- package/cli.mjs +0 -136
- package/exporter/adapters/gatsby/actions/clean.ts +0 -14
- package/exporter/adapters/gatsby/actions/close.ts +0 -17
- package/exporter/adapters/gatsby/actions/data.ts +0 -25
- package/exporter/adapters/gatsby/actions/healthCheck.ts +0 -10
- package/exporter/adapters/gatsby/actions/init.ts +0 -26
- package/exporter/adapters/gatsby/actions/logs.ts +0 -13
- package/exporter/adapters/gatsby/actions/meta.ts +0 -16
- package/exporter/adapters/gatsby/actions/prepare.ts +0 -9
- package/exporter/adapters/gatsby/actions/relocation.ts +0 -15
- package/exporter/adapters/gatsby/actions/restore.ts +0 -36
- package/exporter/adapters/gatsby/actions/ssg.ts +0 -12
- package/exporter/adapters/gatsby/actions/sync.ts +0 -71
- package/exporter/adapters/gatsby/shared/artifacts.ts +0 -16
- package/exporter/adapters/gatsby/shared/context.ts +0 -50
- package/exporter/adapters/gatsby/shared/diff-assets.ts +0 -113
- package/exporter/adapters/gatsby/shared/extract-assets.ts +0 -61
- package/exporter/adapters/gatsby/shared/gatsby-build.ts +0 -58
- package/exporter/adapters/gatsby/shared/sync-render.ts +0 -276
- package/exporter/adapters/gatsby/shared/types.ts +0 -35
- package/exporter/build-esbuild.noop +0 -42
- package/exporter/commands/prepare-assets-directory.ts +0 -30
- package/exporter/services/db-class.ts +0 -54
- package/exporter/services/db.ts +0 -32
- package/exporter/types/render.ts +0 -59
- package/exporter/utils/artifacts.ts +0 -38
- package/exporter/utils/brush.ts +0 -34
- package/exporter/utils/check-environment-health.ts +0 -84
- package/exporter/utils/npm-deps/find-up-simple.ts +0 -100
- package/exporter/utils/npm-deps/pkg-dir.ts +0 -17
- package/exporter/utils/npm-deps/xml-parser.ts +0 -57
- package/exporter/utils/sitemaps.ts +0 -129
- package/plugins/gatsby-plugin-svgr-loader/gatsby-node.js +0 -55
- package/plugins/gatsby-plugin-svgr-loader/package.json +0 -8
- package/react/DynamicScript/index.tsx +0 -33
- package/tsconfig.commands.json +0 -36
- package/tsconfig.exporter.json +0 -19
- /package/{react → exporter/react}/Favicon/utils.ts +0 -0
|
@@ -1,211 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
import type { PostSearchInfoResponse } from "../types/api";
|
|
3
|
-
import type { AIEmbeddingsResponse, PostSearchInfoProps } from "../types/global";
|
|
1
|
+
#!/usr/bin/env node
|
|
4
2
|
|
|
5
|
-
import
|
|
6
|
-
import path from "node:path";
|
|
3
|
+
import fs from "node:fs";
|
|
7
4
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { ReadFromStoreError, UploadSearchError } from "../constants/errors";
|
|
11
|
-
import { AuthService } from "../services/auth";
|
|
12
|
-
import { post } from "../utils/api";
|
|
5
|
+
import { envs } from "../constants";
|
|
6
|
+
import { getConfig } from "../utils/core-utils";
|
|
13
7
|
import { getInstanceDomains } from "../utils/domains";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Save in the BBDD the content of a page parsed without HTML tags.
|
|
20
|
-
*
|
|
21
|
-
* @param props Object with parts of the final page object to be saved in the BBDD.
|
|
22
|
-
*/
|
|
23
|
-
async function postSearchInfo(props: PostSearchInfoProps) {
|
|
24
|
-
const { title, description, image, pageId, languageId, siteId, url, content, template } = props;
|
|
25
|
-
|
|
26
|
-
const response = await post<PostSearchInfoResponse>({
|
|
27
|
-
endpoint: SEARCH,
|
|
28
|
-
body: {
|
|
29
|
-
title,
|
|
30
|
-
description,
|
|
31
|
-
image,
|
|
32
|
-
pageId,
|
|
33
|
-
languageId,
|
|
34
|
-
siteId,
|
|
35
|
-
url,
|
|
36
|
-
template,
|
|
37
|
-
content,
|
|
38
|
-
},
|
|
39
|
-
useApiCacheDir: false,
|
|
40
|
-
logToFile: false,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
return response;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function prepareHTMLContentForSearch(content: string): string {
|
|
47
|
-
// 1. Remove script, style, and other unwanted block tags and their content.
|
|
48
|
-
// The regex looks for <tag...>...</tag> where tag is one of the specified ones.
|
|
49
|
-
const tagsToRemove = ["meta", "link", "style", "script", "noscript", "nav", "header", "footer"];
|
|
50
|
-
const removeTagsRegex = new RegExp(`<(${tagsToRemove.join("|")})\\b[^>]*>.*?<\\/\\1>`, "gis");
|
|
51
|
-
let processedContent = content.replace(removeTagsRegex, "");
|
|
52
|
-
|
|
53
|
-
// 2. Strip all remaining HTML tags.
|
|
54
|
-
processedContent = processedContent.replace(/<[^>]+>/g, " ");
|
|
55
|
-
|
|
56
|
-
// 3. Normalize whitespace: replace multiple spaces/newlines with a single space and trim.
|
|
57
|
-
processedContent = processedContent.replace(/\s+/g, " ").trim();
|
|
58
|
-
|
|
59
|
-
return processedContent;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Function that search in the `/public` dir the content info of the pages and
|
|
64
|
-
* send it to the search table in the ddbb using the API.
|
|
65
|
-
* @todo Utilizar la carpeta page-data en lugar de la carpeta store puesto que
|
|
66
|
-
* esta ya no es persistente.
|
|
67
|
-
*/
|
|
68
|
-
async function uploadRenderedSearchContentToAPI(options: {
|
|
69
|
-
htmlContentDir: string;
|
|
70
|
-
jsonContentDir: string;
|
|
71
|
-
}) {
|
|
72
|
-
const { htmlContentDir, jsonContentDir } = options;
|
|
73
|
-
|
|
74
|
-
if (!(await pathExists(jsonContentDir)) || !(await pathExists(htmlContentDir))) {
|
|
75
|
-
console.log(
|
|
76
|
-
`Skipping uploading content to the search endpoint because it has not exported sites.`,
|
|
77
|
-
);
|
|
8
|
+
import {
|
|
9
|
+
startAIEmbeddings,
|
|
10
|
+
uploadRenderedSearchContentToAPI,
|
|
11
|
+
} from "../utils/searches";
|
|
78
12
|
|
|
13
|
+
async function main() {
|
|
14
|
+
if (!envs.GRIDDO_SEARCH_FEATURE) {
|
|
79
15
|
return;
|
|
80
16
|
}
|
|
81
17
|
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const { result } = pageData;
|
|
87
|
-
const { pageContext } = result;
|
|
88
|
-
const { page, openGraph, pageMetadata } = pageContext;
|
|
89
|
-
|
|
90
|
-
const { compose } = page.fullPath;
|
|
91
|
-
|
|
92
|
-
const htmlPath = path.resolve(`${htmlContentDir}/${compose}/index.html`);
|
|
93
|
-
const htmlContent = await fsp.readFile(htmlPath, "utf-8");
|
|
94
|
-
|
|
95
|
-
const pageObject: PostSearchInfoProps = {
|
|
96
|
-
siteId: page.site,
|
|
97
|
-
pageId: page.id,
|
|
98
|
-
// `pageMetadata.title` has already a fallback `metatitle ||
|
|
99
|
-
// pageTitle` so probably `title` never will be take the
|
|
100
|
-
// `openGraph?.title` value. Only when the `metatitle` and
|
|
101
|
-
// `pageTitle` are empty.
|
|
102
|
-
title: pageMetadata?.title || openGraph?.title,
|
|
103
|
-
languageId: page.language,
|
|
104
|
-
url: page.fullUrl,
|
|
105
|
-
template: page.template.templateType || page.templateId,
|
|
106
|
-
description: pageMetadata?.description || openGraph?.description,
|
|
107
|
-
image: openGraph.image,
|
|
108
|
-
// _content: prepareHTMLContentForSearch(htmlContent),
|
|
109
|
-
content: prepareHTMLContentForSearch(htmlContent),
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
await postSearchInfo(pageObject);
|
|
114
|
-
} catch (error) {
|
|
115
|
-
throwError(UploadSearchError, error);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Walk recursively in a basePath and return an array of pages with json
|
|
122
|
-
* extension with the full absolute path and the path includes "page-data".
|
|
123
|
-
*
|
|
124
|
-
* @param basePath The path to walk recursively.
|
|
125
|
-
* @returns An array of pages with json extension with the full absolute path
|
|
126
|
-
* and the path includes "page-data".
|
|
127
|
-
*/
|
|
128
|
-
async function* walkRecursively(basePath: string): AsyncGenerator<string> {
|
|
129
|
-
const filesHandle = await fsp.opendir(basePath);
|
|
18
|
+
const domains = await getInstanceDomains();
|
|
19
|
+
const config = getConfig();
|
|
20
|
+
for (const domain of domains) {
|
|
21
|
+
const { __exports_dist } = config.paths(domain);
|
|
130
22
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
fileDirent.isFile() &&
|
|
136
|
-
path.extname(fileDirent.name) === ".json" &&
|
|
137
|
-
fileDirent.name.includes("page-data")
|
|
138
|
-
) {
|
|
139
|
-
yield path.join(basePath, fileDirent.name);
|
|
23
|
+
// If __exports_dist has not exported sites (directories), it does not
|
|
24
|
+
// upload search content.
|
|
25
|
+
if (fs.existsSync(__exports_dist)) {
|
|
26
|
+
await uploadRenderedSearchContentToAPI(__exports_dist, domain);
|
|
140
27
|
}
|
|
141
28
|
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Walk recursively in a basePath and return an array of pages with json
|
|
146
|
-
* extension with the full absolute path and the path includes "page-data".
|
|
147
|
-
*
|
|
148
|
-
* @param basePath The path to walk recursively.
|
|
149
|
-
* @returns An array of pages with json extension with the full absolute path
|
|
150
|
-
* and the path includes "page-data".
|
|
151
|
-
*/
|
|
152
|
-
async function* getPageDataPagesFromExports<PageType extends GatsbyPageData>(
|
|
153
|
-
basePath: string,
|
|
154
|
-
): AsyncGenerator<PageType> {
|
|
155
|
-
const jsonFiles = walkRecursively(basePath);
|
|
156
|
-
|
|
157
|
-
for await (const filePath of jsonFiles) {
|
|
158
|
-
try {
|
|
159
|
-
const fileContent = await fsp.readFile(filePath, "utf8");
|
|
160
|
-
const page = JSON.parse(fileContent) as PageType;
|
|
161
29
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
} catch (error) {
|
|
166
|
-
throwError(ReadFromStoreError, error);
|
|
167
|
-
}
|
|
30
|
+
// Solo una vez en cada render de todos los dominios...
|
|
31
|
+
if (envs.GRIDDO_AI_EMBEDDINGS) {
|
|
32
|
+
await startAIEmbeddings();
|
|
168
33
|
}
|
|
169
34
|
}
|
|
170
35
|
|
|
171
|
-
async function getContentDirectories(domain: string) {
|
|
172
|
-
const { __exports } = await getRenderPathsFromDB({ domain });
|
|
173
|
-
|
|
174
|
-
return {
|
|
175
|
-
htmlContentDir: path.join(__exports, "dist"),
|
|
176
|
-
jsonContentDir: path.join(__exports, "dist", "page-data"),
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
async function uploadSearchContent() {
|
|
181
|
-
if (GRIDDO_SEARCH_FEATURE) {
|
|
182
|
-
await AuthService.login();
|
|
183
|
-
const domains = await getInstanceDomains();
|
|
184
|
-
for (const domain of domains) {
|
|
185
|
-
const { htmlContentDir, jsonContentDir } = await getContentDirectories(domain);
|
|
186
|
-
await uploadRenderedSearchContentToAPI({
|
|
187
|
-
htmlContentDir,
|
|
188
|
-
jsonContentDir,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
async function aiEmbeddings() {
|
|
195
|
-
if (GRIDDO_SEARCH_FEATURE && GRIDDO_AI_EMBEDDINGS) {
|
|
196
|
-
await AuthService.login();
|
|
197
|
-
await post<AIEmbeddingsResponse>({
|
|
198
|
-
endpoint: AI_EMBEDDINGS,
|
|
199
|
-
useApiCacheDir: false,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
async function main() {
|
|
205
|
-
await uploadSearchContent();
|
|
206
|
-
await aiEmbeddings();
|
|
207
|
-
}
|
|
208
|
-
|
|
209
36
|
main().catch((err) => {
|
|
210
37
|
console.error("Error", err?.stdout?.toString() || err);
|
|
211
38
|
process.exit(1);
|
|
@@ -1,72 +1,67 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Here are all the environment variables that the CX code uses.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import dotenv from "dotenv";
|
|
2
6
|
|
|
3
7
|
import { isTruthy } from "../utils/core-utils";
|
|
4
8
|
|
|
9
|
+
dotenv.config();
|
|
10
|
+
|
|
11
|
+
//
|
|
5
12
|
// Credentials
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
13
|
+
//
|
|
14
|
+
/* prettier-ignore */ const GRIDDO_API_URL = process.env.GRIDDO_API_URL || process.env.API_URL;
|
|
15
|
+
/* prettier-ignore */ const GRIDDO_PUBLIC_API_URL = process.env.GRIDDO_PUBLIC_API_URL || process.env.PUBLIC_API_URL;
|
|
16
|
+
/* prettier-ignore */ const GRIDDO_BOT_USER = process.env.botEmail || process.env.GRIDDO_BOT_USER;
|
|
17
|
+
/* prettier-ignore */ const GRIDDO_BOT_PASSWORD = process.env.botPassword|| process.env.GRIDDO_BOT_PASSWORD;
|
|
10
18
|
|
|
19
|
+
//
|
|
11
20
|
// Rendering
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
)
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const GRIDDO_REACT_APP_INSTANCE =
|
|
31
|
-
process.env.GRIDDO_REACT_APP_INSTANCE || process.env.REACT_APP_INSTANCE;
|
|
32
|
-
const GRIDDO_AI_EMBEDDINGS = isTruthy(process.env.GRIDDO_AI_EMBEDDINGS);
|
|
33
|
-
const GRIDDO_VERBOSE_LOGS = isTruthy(process.env.GRIDDO_VERBOSE_LOGS);
|
|
21
|
+
//
|
|
22
|
+
/* prettier-ignore */ const GRIDDO_API_CONCURRENCY_COUNT = Number.parseInt( process.env.GRIDDO_API_CONCURRENCY_COUNT || "10");
|
|
23
|
+
/* prettier-ignore */ const GRIDDO_RENDER_ALL_SITES = isTruthy(process.env.GRIDDO_RENDER_ALL_SITES || process.env.updateAllSites);
|
|
24
|
+
/* prettier-ignore */ const GRIDDO_RENDER_SITE = Number.parseInt(process.env.GRIDDO_RENDER_SITE || "")
|
|
25
|
+
/* prettier-ignore */ const GRIDDO_RENDER_PAGES = (process.env.GRIDDO_RENDER_PAGES || "").split(",").map((item) => Number.parseInt(item)).filter(Boolean);
|
|
26
|
+
/* prettier-ignore */ const GRIDDO_SKIP_BUILD_CHECKS = isTruthy(process.env.GRIDDO_SKIP_BUILD_CHECKS)
|
|
27
|
+
/* prettier-ignore */ const GRIDDO_DEBUG_LOGS = isTruthy(process.env.GRIDDO_DEBUG_LOGS);
|
|
28
|
+
/* prettier-ignore */ const GRIDDO_BUILD_LOGS = isTruthy(process.env.GRIDDO_BUILD_LOGS);
|
|
29
|
+
/* prettier-ignore */ const GRIDDO_RENDER_BREAKPOINTS_FEATURE = isTruthy(process.env.GRIDDO_RENDER_BREAKPOINTS_FEATURE);
|
|
30
|
+
/* prettier-ignore */ const GRIDDO_SSG_VERBOSE_LOGS = isTruthy(process.env.GRIDDO_SSG_VERBOSE_LOGS)
|
|
31
|
+
/* prettier-ignore */ const GRIDDO_SEARCH_FEATURE = isTruthy(process.env.GRIDDO_SEARCH_FEATURE);
|
|
32
|
+
/* prettier-ignore */ const GRIDDO_ASSET_PREFIX = process.env.GRIDDO_ASSET_PREFIX || process.env.ASSET_PREFIX;
|
|
33
|
+
/* prettier-ignore */ const GRIDDO_REACT_APP_INSTANCE = process.env.GRIDDO_REACT_APP_INSTANCE || process.env.REACT_APP_INSTANCE;
|
|
34
|
+
/* prettier-ignore */ const GRIDDO_AI_EMBEDDINGS = isTruthy(process.env.GRIDDO_AI_EMBEDDINGS);
|
|
35
|
+
/* prettier-ignore */ const GRIDDO_VERBOSE_LOGS = isTruthy(process.env.GRIDDO_VERBOSE_LOGS);
|
|
36
|
+
/* prettier-ignore */ const GRIDDO_ALERT_FEATURE = isTruthy(process.env.GRIDDO_ALERT_FEATURE);
|
|
37
|
+
/* prettier-ignore */ const GRIDDO_API_MAX_RESPONSE_SIZE = Number.parseInt(process.env.GRIDDO_API_MAX_RESPONSE_SIZE || "81920") // 80KB
|
|
38
|
+
/* prettier-ignore */ const GRIDDO_SSG_MAX_PAGE_SIZE = Number.parseInt(process.env.GRIDDO_SSG_MAX_PAGE_SIZE || "524288") // 512KB
|
|
34
39
|
|
|
40
|
+
//
|
|
35
41
|
// LifeCycle
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
);
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
);
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
);
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
);
|
|
54
|
-
const GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(
|
|
55
|
-
process.env.GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS || "2",
|
|
56
|
-
);
|
|
57
|
-
const GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(
|
|
58
|
-
process.env.GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS || "1",
|
|
59
|
-
);
|
|
60
|
-
const GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(
|
|
61
|
-
process.env.GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS || "4",
|
|
62
|
-
);
|
|
63
|
-
const GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(
|
|
64
|
-
process.env.GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS || "1",
|
|
65
|
-
);
|
|
42
|
+
//
|
|
43
|
+
/* prettier-ignore */ const GRIDDO_INIT_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_INIT_LIFECYCLE_MAX_ATTEMPTS || "1");
|
|
44
|
+
/* prettier-ignore */ const GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS || "1");
|
|
45
|
+
/* prettier-ignore */ const GRIDDO_CLOSE_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_CLOSE_LIFECYCLE_MAX_ATTEMPTS || "1");
|
|
46
|
+
/* prettier-ignore */ const GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS || "1");
|
|
47
|
+
/* prettier-ignore */ const GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS || "1");
|
|
48
|
+
/* prettier-ignore */ const GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS || "1");
|
|
49
|
+
/* prettier-ignore */ const GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS || "2");
|
|
50
|
+
/* prettier-ignore */ const GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS || "1");
|
|
51
|
+
/* prettier-ignore */ const GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS || "4");
|
|
52
|
+
/* prettier-ignore */ const GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS = Number.parseInt(process.env.GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS || "1");
|
|
53
|
+
|
|
54
|
+
//
|
|
55
|
+
// Testing
|
|
56
|
+
//
|
|
57
|
+
/* prettier-ignore */ const GRIDDO_FIXTURES_DOMAIN_NAMES = process.env.GRIDDO_CX_FIXTURES_DOMAIN_NAMES;
|
|
58
|
+
/* prettier-ignore */ const GRIDDO_FIXTURES_SITE_NAMES = process.env.GRIDDO_CX_FIXTURES_SITE_NAMES;
|
|
66
59
|
|
|
67
60
|
export {
|
|
68
61
|
GRIDDO_AI_EMBEDDINGS,
|
|
62
|
+
GRIDDO_ALERT_FEATURE,
|
|
69
63
|
GRIDDO_API_CONCURRENCY_COUNT,
|
|
64
|
+
GRIDDO_API_MAX_RESPONSE_SIZE,
|
|
70
65
|
GRIDDO_API_URL,
|
|
71
66
|
GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS,
|
|
72
67
|
GRIDDO_ASSET_PREFIX,
|
|
@@ -77,6 +72,8 @@ export {
|
|
|
77
72
|
GRIDDO_CLOSE_LIFECYCLE_MAX_ATTEMPTS,
|
|
78
73
|
GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS,
|
|
79
74
|
GRIDDO_DEBUG_LOGS,
|
|
75
|
+
GRIDDO_FIXTURES_DOMAIN_NAMES,
|
|
76
|
+
GRIDDO_FIXTURES_SITE_NAMES,
|
|
80
77
|
GRIDDO_INIT_LIFECYCLE_MAX_ATTEMPTS,
|
|
81
78
|
GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS,
|
|
82
79
|
GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS,
|
|
@@ -91,6 +88,7 @@ export {
|
|
|
91
88
|
GRIDDO_SEARCH_FEATURE,
|
|
92
89
|
GRIDDO_SKIP_BUILD_CHECKS,
|
|
93
90
|
GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS,
|
|
91
|
+
GRIDDO_SSG_MAX_PAGE_SIZE,
|
|
94
92
|
GRIDDO_SSG_VERBOSE_LOGS,
|
|
95
93
|
GRIDDO_VERBOSE_LOGS,
|
|
96
94
|
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { LifeCyclesNames } from "../types/global";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AI_EMBEDDINGS,
|
|
5
|
+
ALERT,
|
|
6
|
+
BUILD_END,
|
|
7
|
+
BUILD_START,
|
|
8
|
+
DOMAINS,
|
|
9
|
+
GET_ALL,
|
|
10
|
+
GET_PAGE,
|
|
11
|
+
GET_PAGES,
|
|
12
|
+
GET_REFERENCE_FIELD_DATA,
|
|
13
|
+
GET_SITEMAP,
|
|
14
|
+
INFO,
|
|
15
|
+
LANGUAGES,
|
|
16
|
+
LOGIN,
|
|
17
|
+
RESET_RENDER,
|
|
18
|
+
ROBOTS,
|
|
19
|
+
SEARCH,
|
|
20
|
+
SETTINGS,
|
|
21
|
+
SOCIALS,
|
|
22
|
+
} from "./endpoints";
|
|
23
|
+
import {
|
|
24
|
+
GRIDDO_AI_EMBEDDINGS,
|
|
25
|
+
GRIDDO_ALERT_FEATURE,
|
|
26
|
+
GRIDDO_API_CONCURRENCY_COUNT,
|
|
27
|
+
GRIDDO_API_MAX_RESPONSE_SIZE,
|
|
28
|
+
GRIDDO_API_URL,
|
|
29
|
+
GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS,
|
|
30
|
+
GRIDDO_ASSET_PREFIX,
|
|
31
|
+
GRIDDO_BOT_PASSWORD,
|
|
32
|
+
GRIDDO_BOT_USER,
|
|
33
|
+
GRIDDO_BUILD_LOGS,
|
|
34
|
+
GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS,
|
|
35
|
+
GRIDDO_CLOSE_LIFECYCLE_MAX_ATTEMPTS,
|
|
36
|
+
GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS,
|
|
37
|
+
GRIDDO_DEBUG_LOGS,
|
|
38
|
+
GRIDDO_FIXTURES_DOMAIN_NAMES,
|
|
39
|
+
GRIDDO_FIXTURES_SITE_NAMES,
|
|
40
|
+
GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS,
|
|
41
|
+
GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS,
|
|
42
|
+
GRIDDO_PUBLIC_API_URL,
|
|
43
|
+
GRIDDO_REACT_APP_INSTANCE,
|
|
44
|
+
GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS,
|
|
45
|
+
GRIDDO_RENDER_ALL_SITES,
|
|
46
|
+
GRIDDO_RENDER_BREAKPOINTS_FEATURE,
|
|
47
|
+
GRIDDO_RENDER_PAGES,
|
|
48
|
+
GRIDDO_RENDER_SITE,
|
|
49
|
+
GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS,
|
|
50
|
+
GRIDDO_SEARCH_FEATURE,
|
|
51
|
+
GRIDDO_SKIP_BUILD_CHECKS,
|
|
52
|
+
GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS,
|
|
53
|
+
GRIDDO_SSG_MAX_PAGE_SIZE,
|
|
54
|
+
GRIDDO_SSG_VERBOSE_LOGS,
|
|
55
|
+
GRIDDO_VERBOSE_LOGS,
|
|
56
|
+
} from "./envs";
|
|
57
|
+
|
|
58
|
+
const endpoints = {
|
|
59
|
+
ALERT,
|
|
60
|
+
AI_EMBEDDINGS,
|
|
61
|
+
BUILD_END,
|
|
62
|
+
BUILD_START,
|
|
63
|
+
DOMAINS,
|
|
64
|
+
GET_ALL,
|
|
65
|
+
GET_PAGE,
|
|
66
|
+
GET_PAGES,
|
|
67
|
+
GET_REFERENCE_FIELD_DATA,
|
|
68
|
+
GET_SITEMAP,
|
|
69
|
+
INFO,
|
|
70
|
+
LANGUAGES,
|
|
71
|
+
LOGIN,
|
|
72
|
+
RESET_RENDER,
|
|
73
|
+
ROBOTS,
|
|
74
|
+
SEARCH,
|
|
75
|
+
SETTINGS,
|
|
76
|
+
SOCIALS,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const envs = {
|
|
80
|
+
GRIDDO_AI_EMBEDDINGS,
|
|
81
|
+
GRIDDO_ALERT_FEATURE,
|
|
82
|
+
GRIDDO_API_CONCURRENCY_COUNT,
|
|
83
|
+
GRIDDO_API_MAX_RESPONSE_SIZE,
|
|
84
|
+
GRIDDO_API_URL,
|
|
85
|
+
GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS,
|
|
86
|
+
GRIDDO_ASSET_PREFIX,
|
|
87
|
+
GRIDDO_BOT_PASSWORD,
|
|
88
|
+
GRIDDO_BOT_USER,
|
|
89
|
+
GRIDDO_BUILD_LOGS,
|
|
90
|
+
GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS,
|
|
91
|
+
GRIDDO_CLOSE_LIFECYCLE_MAX_ATTEMPTS,
|
|
92
|
+
GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS,
|
|
93
|
+
GRIDDO_DEBUG_LOGS,
|
|
94
|
+
GRIDDO_FIXTURES_DOMAIN_NAMES,
|
|
95
|
+
GRIDDO_FIXTURES_SITE_NAMES,
|
|
96
|
+
GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS,
|
|
97
|
+
GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS,
|
|
98
|
+
GRIDDO_PUBLIC_API_URL,
|
|
99
|
+
GRIDDO_REACT_APP_INSTANCE,
|
|
100
|
+
GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS,
|
|
101
|
+
GRIDDO_RENDER_ALL_SITES,
|
|
102
|
+
GRIDDO_RENDER_BREAKPOINTS_FEATURE,
|
|
103
|
+
GRIDDO_RENDER_PAGES,
|
|
104
|
+
GRIDDO_RENDER_SITE,
|
|
105
|
+
GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS,
|
|
106
|
+
GRIDDO_SEARCH_FEATURE,
|
|
107
|
+
GRIDDO_SKIP_BUILD_CHECKS,
|
|
108
|
+
GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS,
|
|
109
|
+
GRIDDO_SSG_MAX_PAGE_SIZE,
|
|
110
|
+
GRIDDO_SSG_VERBOSE_LOGS,
|
|
111
|
+
GRIDDO_VERBOSE_LOGS,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const lifeCycleNames: Record<LifeCyclesNames, LifeCyclesNames> = {
|
|
115
|
+
__DEBUG__: "__DEBUG__",
|
|
116
|
+
Archive: "Archive",
|
|
117
|
+
Clean: "Clean",
|
|
118
|
+
Close: "Close",
|
|
119
|
+
Data: "Data",
|
|
120
|
+
HealthCheck: "HealthCheck",
|
|
121
|
+
Init: "Init",
|
|
122
|
+
Meta: "Meta",
|
|
123
|
+
Prepare: "Prepare",
|
|
124
|
+
Relocation: "Relocation",
|
|
125
|
+
Restore: "Restore",
|
|
126
|
+
SSG: "SSG",
|
|
127
|
+
} as const;
|
|
128
|
+
|
|
129
|
+
export { endpoints, envs, lifeCycleNames };
|
|
@@ -7,13 +7,11 @@
|
|
|
7
7
|
* obligatorily.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import type { ErrorData } from ".";
|
|
10
11
|
import type { SpawnSyncReturns } from "node:child_process";
|
|
11
|
-
import type { ErrorData } from "../utils/errors";
|
|
12
12
|
|
|
13
13
|
type ErrorsType =
|
|
14
14
|
| "ArtifactError"
|
|
15
|
-
| "BundlesInconsistencyError"
|
|
16
|
-
| "CheckHealthError"
|
|
17
15
|
| "ErrorInSSGBuildProcess"
|
|
18
16
|
| "LifecycleExecutionError"
|
|
19
17
|
| "LoginError"
|
|
@@ -22,7 +20,6 @@ type ErrorsType =
|
|
|
22
20
|
| "ReadFromStoreError"
|
|
23
21
|
| "ReferenceFieldSourcesNotFoundError"
|
|
24
22
|
| "RenderUUIDError"
|
|
25
|
-
| "UploadSearchError"
|
|
26
23
|
| "WriteToStoreError";
|
|
27
24
|
|
|
28
25
|
const ArtifactError: ErrorData = {
|
|
@@ -33,13 +30,19 @@ const ArtifactError: ErrorData = {
|
|
|
33
30
|
hint: "Have there been any recent deployments? These can delete directories from the current render.",
|
|
34
31
|
};
|
|
35
32
|
|
|
36
|
-
const ErrorInSSGBuildProcess = (
|
|
33
|
+
const ErrorInSSGBuildProcess = (
|
|
34
|
+
command: SpawnSyncReturns<string>,
|
|
35
|
+
): ErrorData => ({
|
|
37
36
|
error: "ErrorInSSGBuildProcess",
|
|
38
37
|
message: `Error in SSG build process: ${JSON.stringify(command)}`,
|
|
39
|
-
expected:
|
|
38
|
+
expected:
|
|
39
|
+
"This can happen if there was a problem with the SSG build process.",
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
const LifecycleExecutionError = (
|
|
42
|
+
const LifecycleExecutionError = (
|
|
43
|
+
attempts: number,
|
|
44
|
+
name: string,
|
|
45
|
+
): ErrorData => ({
|
|
43
46
|
error: "LifecycleExecutionError",
|
|
44
47
|
message: `Exceeded maximum retry attempts (${attempts}) for ${name} LifeCycle`,
|
|
45
48
|
});
|
|
@@ -47,12 +50,14 @@ const LifecycleExecutionError = (attempts: number, name: string): ErrorData => (
|
|
|
47
50
|
const LoginError: ErrorData = {
|
|
48
51
|
error: "LoginError",
|
|
49
52
|
message: "There was a problem logging in to the API",
|
|
50
|
-
expected:
|
|
53
|
+
expected:
|
|
54
|
+
"This happens if the API is currently not working or the credentials are incorrect.",
|
|
51
55
|
};
|
|
52
56
|
|
|
53
57
|
const NoDomainsFoundError: ErrorData = {
|
|
54
58
|
error: "NoDomainsFoundError",
|
|
55
|
-
message:
|
|
59
|
+
message:
|
|
60
|
+
"No domains were found in this instance. The process cannot continue.",
|
|
56
61
|
expected:
|
|
57
62
|
"This may happen if the API is not functioning, or the site is not properly configured, or the domains are not registered.",
|
|
58
63
|
hint: "You can contact the instance administrator.",
|
|
@@ -93,22 +98,8 @@ const WriteToStoreError: ErrorData = {
|
|
|
93
98
|
hint: "There may be an issue such as lack of space or permissions preventing the file from being written.",
|
|
94
99
|
};
|
|
95
100
|
|
|
96
|
-
const UploadSearchError: ErrorData = {
|
|
97
|
-
error: "UploadSearchError",
|
|
98
|
-
message: "There was an error uploading content to API for search",
|
|
99
|
-
hint: "This happens if the API is currently not working or the credentials are incorrect.",
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const CheckHealthError: ErrorData = {
|
|
103
|
-
error: "CheckHealthError",
|
|
104
|
-
message: "There was a problem with environment vars configuration.",
|
|
105
|
-
expected: "Some of the required environment variables are not set correctly or are missing",
|
|
106
|
-
hint: "Are the environment variables correctly set?",
|
|
107
|
-
};
|
|
108
|
-
|
|
109
101
|
export {
|
|
110
102
|
ArtifactError,
|
|
111
|
-
CheckHealthError,
|
|
112
103
|
ErrorInSSGBuildProcess,
|
|
113
104
|
LifecycleExecutionError,
|
|
114
105
|
LoginError,
|
|
@@ -117,7 +108,6 @@ export {
|
|
|
117
108
|
ReadFromStoreError,
|
|
118
109
|
ReferenceFieldSourcesNotFoundError,
|
|
119
110
|
RenderUUIDError,
|
|
120
|
-
UploadSearchError,
|
|
121
111
|
WriteToStoreError,
|
|
122
112
|
type ErrorsType,
|
|
123
113
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ErrorsType } from "
|
|
1
|
+
import type { ErrorsType } from "./errors-data";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import kleur from "kleur";
|
|
4
4
|
|
|
5
5
|
export type ErrorData = {
|
|
6
6
|
error: ErrorsType;
|
|
@@ -10,21 +10,20 @@ export type ErrorData = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export class RenderError extends Error {
|
|
13
|
-
constructor(
|
|
14
|
-
super(
|
|
15
|
-
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
16
15
|
this.name = "InternalCXError";
|
|
17
|
-
this.stack =
|
|
16
|
+
this.stack = "";
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Throws an error with the provided error message, expected value, and hint.
|
|
23
22
|
*/
|
|
24
|
-
function throwError(options: ErrorData, stack?: unknown)
|
|
23
|
+
function throwError(options: ErrorData, stack?: unknown) {
|
|
25
24
|
const { error, message, expected, hint } = options;
|
|
26
25
|
|
|
27
|
-
const errorColor =
|
|
26
|
+
const errorColor = kleur.red("[ " + error + " ]");
|
|
28
27
|
const extraText = [expected, hint].filter(Boolean).join("\n");
|
|
29
28
|
|
|
30
29
|
console.log(`
|
|
@@ -32,10 +31,10 @@ ${errorColor}
|
|
|
32
31
|
${message}
|
|
33
32
|
${extraText}
|
|
34
33
|
|
|
35
|
-
${
|
|
34
|
+
${kleur.red("stack")}
|
|
36
35
|
${JSON.stringify(stack, null, 2)}`);
|
|
37
36
|
|
|
38
|
-
throw new RenderError(
|
|
37
|
+
throw new RenderError();
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
export { throwError };
|