@griddo/cx 11.7.10 → 11.7.12-rc.0
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 +27 -226
- package/build/adapters/gatsby/actions/clean.js +10 -0
- package/build/adapters/gatsby/actions/clean.js.map +1 -0
- package/build/adapters/gatsby/actions/close.js +14 -0
- package/build/adapters/gatsby/actions/close.js.map +1 -0
- package/build/adapters/gatsby/actions/data.js +18 -0
- package/build/adapters/gatsby/actions/data.js.map +1 -0
- package/build/adapters/gatsby/actions/healthCheck.js +10 -0
- package/build/adapters/gatsby/actions/healthCheck.js.map +1 -0
- package/build/adapters/gatsby/actions/init.js +22 -0
- package/build/adapters/gatsby/actions/init.js.map +1 -0
- package/build/adapters/gatsby/actions/logs.js +9 -0
- package/build/adapters/gatsby/actions/logs.js.map +1 -0
- package/build/adapters/gatsby/actions/meta.js +13 -0
- package/build/adapters/gatsby/actions/meta.js.map +1 -0
- package/build/adapters/gatsby/actions/prepare.js +9 -0
- package/build/adapters/gatsby/actions/prepare.js.map +1 -0
- package/build/adapters/gatsby/actions/relocation.js +15 -0
- package/build/adapters/gatsby/actions/relocation.js.map +1 -0
- package/build/adapters/gatsby/actions/restore.js +26 -0
- package/build/adapters/gatsby/actions/restore.js.map +1 -0
- package/build/adapters/gatsby/actions/ssg.js +9 -0
- package/build/adapters/gatsby/actions/ssg.js.map +1 -0
- package/build/adapters/gatsby/actions/sync.js +51 -0
- package/build/adapters/gatsby/actions/sync.js.map +1 -0
- package/build/adapters/gatsby/index.js +78 -0
- package/build/adapters/gatsby/index.js.map +1 -0
- package/build/adapters/gatsby/shared/artifacts.js +20 -0
- package/build/adapters/gatsby/shared/artifacts.js.map +1 -0
- package/build/adapters/gatsby/shared/context.js +31 -0
- package/build/adapters/gatsby/shared/context.js.map +1 -0
- package/build/adapters/gatsby/shared/diff-assets.js +101 -0
- package/build/adapters/gatsby/shared/diff-assets.js.map +1 -0
- package/build/adapters/gatsby/shared/extract-assets.js +58 -0
- package/build/adapters/gatsby/shared/extract-assets.js.map +1 -0
- package/build/adapters/gatsby/shared/gatsby-build.js +55 -0
- package/build/adapters/gatsby/shared/gatsby-build.js.map +1 -0
- package/build/adapters/gatsby/shared/sync-render.js +210 -0
- package/build/adapters/gatsby/shared/sync-render.js.map +1 -0
- package/build/adapters/gatsby/shared/types.js +3 -0
- package/build/adapters/gatsby/shared/types.js.map +1 -0
- package/build/commands/end-render.js +87 -0
- package/build/commands/end-render.js.map +1 -0
- package/build/commands/prepare-assets-directory.js +30 -0
- package/build/commands/prepare-assets-directory.js.map +1 -0
- package/build/commands/prepare-domains-render.js +133 -0
- package/build/commands/prepare-domains-render.js.map +1 -0
- package/build/commands/reset-render.js +21 -0
- package/build/commands/reset-render.js.map +1 -0
- package/build/commands/start-render.js +44 -0
- package/build/commands/start-render.js.map +1 -0
- package/build/commands/upload-search-content.js +180 -0
- package/build/commands/upload-search-content.js.map +1 -0
- package/build/constants/endpoints.js +43 -0
- package/build/constants/endpoints.js.map +1 -0
- package/build/constants/envs.js +68 -0
- package/build/constants/envs.js.map +1 -0
- package/build/constants/errors.js +81 -0
- package/build/constants/errors.js.map +1 -0
- package/build/services/auth.js +40 -0
- package/build/services/auth.js.map +1 -0
- package/build/services/db-class.js +49 -0
- package/build/services/db-class.js.map +1 -0
- package/build/services/db.js +34 -0
- package/build/services/db.js.map +1 -0
- package/build/services/navigation.js +96 -0
- package/build/services/navigation.js.map +1 -0
- package/build/services/reference-fields.js +131 -0
- package/build/services/reference-fields.js.map +1 -0
- package/build/services/robots.js +60 -0
- package/build/services/robots.js.map +1 -0
- package/build/services/sites.js +110 -0
- package/build/services/sites.js.map +1 -0
- package/build/services/store.js +257 -0
- package/build/services/store.js.map +1 -0
- package/build/types/api.js +3 -0
- package/build/types/api.js.map +1 -0
- package/build/types/global.js +3 -0
- package/build/types/global.js.map +1 -0
- package/build/types/navigation.js +3 -0
- package/build/types/navigation.js.map +1 -0
- package/build/types/pages.js +3 -0
- package/build/types/pages.js.map +1 -0
- package/build/types/render.js +10 -0
- package/build/types/render.js.map +1 -0
- package/build/types/sites.js +3 -0
- package/build/types/sites.js.map +1 -0
- package/build/types/templates.js +3 -0
- package/build/types/templates.js.map +1 -0
- package/build/utils/api.js +165 -0
- package/build/utils/api.js.map +1 -0
- package/build/utils/artifacts.js +38 -0
- package/build/utils/artifacts.js.map +1 -0
- package/build/utils/brush.js +30 -0
- package/build/utils/brush.js.map +1 -0
- package/build/utils/cache.js +106 -0
- package/build/utils/cache.js.map +1 -0
- package/build/utils/check-environment-health.js +69 -0
- package/build/utils/check-environment-health.js.map +1 -0
- package/build/utils/core-utils.js +270 -0
- package/build/utils/core-utils.js.map +1 -0
- package/build/utils/domains.js +37 -0
- package/build/utils/domains.js.map +1 -0
- package/build/utils/errors.js +30 -0
- package/build/utils/errors.js.map +1 -0
- package/build/utils/folders.js +341 -0
- package/build/utils/folders.js.map +1 -0
- package/build/utils/images.js +45 -0
- package/build/utils/images.js.map +1 -0
- package/build/utils/instance.js +66 -0
- package/build/utils/instance.js.map +1 -0
- package/build/utils/loggin.js +119 -0
- package/build/utils/loggin.js.map +1 -0
- package/build/utils/npm-deps/find-up-simple.js +75 -0
- package/build/utils/npm-deps/find-up-simple.js.map +1 -0
- package/build/utils/npm-deps/pkg-dir.js +20 -0
- package/build/utils/npm-deps/pkg-dir.js.map +1 -0
- package/build/utils/npm-deps/xml-parser.js +49 -0
- package/build/utils/npm-deps/xml-parser.js.map +1 -0
- package/build/utils/pages.js +359 -0
- package/build/utils/pages.js.map +1 -0
- package/build/utils/render.js +168 -0
- package/build/utils/render.js.map +1 -0
- package/build/utils/sitemaps.js +110 -0
- package/build/utils/sitemaps.js.map +1 -0
- package/build/utils/sites.js +105 -0
- package/build/utils/sites.js.map +1 -0
- package/build/utils/store.js +193 -0
- package/build/utils/store.js.map +1 -0
- package/exporter/adapters/gatsby/actions/clean.ts +14 -0
- package/exporter/adapters/gatsby/actions/close.ts +20 -0
- package/exporter/adapters/gatsby/actions/data.ts +25 -0
- package/exporter/adapters/gatsby/actions/healthCheck.ts +10 -0
- package/exporter/adapters/gatsby/actions/init.ts +26 -0
- package/exporter/adapters/gatsby/actions/logs.ts +10 -0
- package/exporter/adapters/gatsby/actions/meta.ts +16 -0
- package/exporter/adapters/gatsby/actions/prepare.ts +9 -0
- package/exporter/adapters/gatsby/actions/relocation.ts +15 -0
- package/exporter/adapters/gatsby/actions/restore.ts +36 -0
- package/exporter/adapters/gatsby/actions/ssg.ts +12 -0
- package/exporter/adapters/gatsby/actions/sync.ts +71 -0
- package/exporter/adapters/gatsby/index.ts +73 -153
- package/exporter/adapters/gatsby/shared/artifacts.ts +16 -0
- package/exporter/adapters/gatsby/shared/context.ts +50 -0
- package/exporter/adapters/gatsby/shared/diff-assets.ts +113 -0
- package/exporter/adapters/gatsby/shared/extract-assets.ts +61 -0
- package/exporter/adapters/gatsby/shared/gatsby-build.ts +58 -0
- package/exporter/adapters/gatsby/shared/sync-render.ts +276 -0
- package/exporter/adapters/gatsby/shared/types.ts +35 -0
- package/exporter/build-esbuild.noop +42 -0
- package/exporter/build.sh +4 -38
- package/exporter/commands/end-render.ts +72 -70
- package/exporter/commands/prepare-assets-directory.ts +30 -0
- package/exporter/commands/prepare-domains-render.ts +143 -31
- package/exporter/commands/reset-render.ts +10 -3
- package/exporter/commands/start-render.ts +22 -45
- package/exporter/commands/upload-search-content.ts +194 -21
- package/exporter/constants/endpoints.ts +2 -1
- package/exporter/constants/envs.ts +57 -55
- package/exporter/{errors/errors-data.ts → constants/errors.ts} +24 -14
- package/exporter/services/auth.ts +7 -6
- package/exporter/services/db-class.ts +54 -0
- package/exporter/services/db.ts +32 -0
- package/exporter/services/navigation.ts +4 -10
- package/exporter/services/reference-fields.ts +9 -24
- package/exporter/services/robots.ts +9 -16
- package/exporter/services/sites.ts +36 -24
- package/exporter/services/store.ts +107 -96
- package/exporter/types/api.ts +27 -28
- package/exporter/types/global.ts +8 -11
- package/exporter/types/navigation.ts +1 -1
- package/exporter/types/pages.ts +2 -3
- package/exporter/types/render.ts +59 -0
- package/exporter/types/sites.ts +1 -2
- package/exporter/utils/api.ts +55 -75
- package/exporter/utils/artifacts.ts +38 -0
- package/exporter/utils/brush.ts +34 -0
- package/exporter/utils/cache.ts +37 -62
- package/exporter/utils/check-environment-health.ts +80 -0
- package/exporter/utils/core-utils.ts +133 -272
- package/exporter/utils/domains.ts +10 -7
- package/exporter/{errors/index.ts → utils/errors.ts} +10 -9
- package/exporter/utils/folders.ts +163 -98
- package/exporter/utils/images.ts +1 -6
- package/exporter/utils/instance.ts +9 -13
- package/exporter/utils/loggin.ts +44 -91
- package/exporter/utils/npm-deps/find-up-simple.ts +100 -0
- package/exporter/utils/npm-deps/pkg-dir.ts +17 -0
- package/exporter/utils/npm-deps/xml-parser.ts +57 -0
- package/exporter/utils/pages.ts +23 -88
- package/exporter/utils/render.ts +180 -48
- package/exporter/utils/sitemaps.ts +129 -0
- package/exporter/utils/sites.ts +19 -197
- package/exporter/utils/store.ts +87 -180
- package/gatsby-browser.tsx +41 -58
- package/gatsby-config.ts +10 -17
- package/gatsby-node.ts +17 -78
- package/gatsby-ssr.tsx +2 -1
- package/package.json +35 -86
- 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 → react}/Favicon/index.tsx +1 -7
- package/{exporter/react → react}/GriddoIntegrations/index.tsx +16 -22
- package/{exporter/react → react}/GriddoIntegrations/utils.ts +21 -9
- package/{build/react/index.d.ts → react/index.tsx} +1 -0
- package/src/components/Head.tsx +13 -46
- package/src/components/template.tsx +8 -30
- package/src/gatsby-node-utils.ts +73 -2
- package/src/html.tsx +2 -11
- package/src/types.ts +5 -5
- package/tsconfig.commands.json +36 -0
- package/tsconfig.exporter.json +19 -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/endpoints.d.ts +0 -19
- 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/errors/errors-data.d.ts +0 -22
- package/build/errors/index.d.ts +0 -15
- package/build/index.d.ts +0 -29
- package/build/index.js +0 -73
- 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.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/auth.d.ts +0 -10
- 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/api.d.ts +0 -142
- package/build/types/global.d.ts +0 -84
- package/build/types/navigation.d.ts +0 -28
- package/build/types/pages.d.ts +0 -144
- package/build/types/sites.d.ts +0 -57
- 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/instance.d.ts +0 -21
- 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/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/index.ts +0 -129
- package/exporter/index.ts +0 -82
- 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/domains.ts +0 -16
- package/exporter/services/register.ts +0 -113
- package/exporter/services/settings.ts +0 -17
- package/exporter/utils/alerts.ts +0 -29
- package/exporter/utils/create-build-data.ts +0 -17
- package/exporter/utils/health-checks.ts +0 -64
- package/exporter/utils/searches.ts +0 -156
- package/src/README.md +0 -7
- package/start-render.js +0 -7
- /package/{exporter/react → react}/Favicon/utils.ts +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { Core, Fields } from "@griddo/core";
|
|
1
2
|
import type { FetchDataProps } from "../types/global";
|
|
2
3
|
import type { APIPageObject } from "../types/pages";
|
|
3
|
-
import type { Core, Fields } from "@griddo/core";
|
|
4
4
|
|
|
5
|
-
import { getReferenceFieldSiteData } from "./sites";
|
|
6
5
|
import { boxLog } from "../utils/loggin";
|
|
6
|
+
import { getReferenceFieldSiteData } from "./sites";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Get the body data from a ReferenceField.
|
|
@@ -54,9 +54,7 @@ function getBody(data: Fields.Reference<unknown>, page: Core.Page) {
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
console.log(
|
|
58
|
-
`Error: ReferenceField mode: ${mode} is not recognized on page ${page?.id}.`,
|
|
59
|
-
);
|
|
57
|
+
console.log(`Error: ReferenceField mode: ${mode} is not recognized on page ${page?.id}.`);
|
|
60
58
|
|
|
61
59
|
return data;
|
|
62
60
|
}
|
|
@@ -71,11 +69,8 @@ function getBody(data: Fields.Reference<unknown>, page: Core.Page) {
|
|
|
71
69
|
* @returns The ContentType data.
|
|
72
70
|
*/
|
|
73
71
|
async function fetchContentTypeData(props: FetchDataProps) {
|
|
74
|
-
const {
|
|
75
|
-
|
|
76
|
-
component: { data },
|
|
77
|
-
cacheKey,
|
|
78
|
-
} = props;
|
|
72
|
+
const { page, component, cacheKey } = props;
|
|
73
|
+
const { data } = component;
|
|
79
74
|
|
|
80
75
|
// Distrubutor with `hasDistributorData: true` / `getStaticData: true` but without `data` prop
|
|
81
76
|
if (!data) {
|
|
@@ -109,13 +104,7 @@ async function fetchContentTypeData(props: FetchDataProps) {
|
|
|
109
104
|
|
|
110
105
|
const body = getBody(data, page);
|
|
111
106
|
|
|
112
|
-
const response = await getReferenceFieldSiteData(
|
|
113
|
-
page,
|
|
114
|
-
body,
|
|
115
|
-
cacheKey,
|
|
116
|
-
site,
|
|
117
|
-
lang,
|
|
118
|
-
);
|
|
107
|
+
const response = await getReferenceFieldSiteData(page, body, cacheKey, site, lang);
|
|
119
108
|
|
|
120
109
|
return response;
|
|
121
110
|
}
|
|
@@ -165,10 +154,7 @@ async function getReferenceFieldData({
|
|
|
165
154
|
continue;
|
|
166
155
|
}
|
|
167
156
|
|
|
168
|
-
const _key = key as
|
|
169
|
-
| "hasDistributorData"
|
|
170
|
-
| "queriedItems"
|
|
171
|
-
| "getStaticData";
|
|
157
|
+
const _key = key as "hasDistributorData" | "queriedItems" | "getStaticData";
|
|
172
158
|
const component = templateChunk[_key] as unknown as {
|
|
173
159
|
data: Fields.Reference<unknown>;
|
|
174
160
|
queriedItems: Fields.QueriedData<unknown>;
|
|
@@ -181,8 +167,7 @@ async function getReferenceFieldData({
|
|
|
181
167
|
continue;
|
|
182
168
|
}
|
|
183
169
|
|
|
184
|
-
const componentHasRequestForData =
|
|
185
|
-
component.hasDistributorData || component.getStaticData;
|
|
170
|
+
const componentHasRequestForData = component.hasDistributorData || component.getStaticData;
|
|
186
171
|
|
|
187
172
|
if (componentHasRequestForData) {
|
|
188
173
|
component.queriedItems = await fetchContentTypeData({
|
|
@@ -210,7 +195,7 @@ async function getReferenceFieldData({
|
|
|
210
195
|
} catch (err) {
|
|
211
196
|
console.error(`Error in getReferenceFieldData ${err}`);
|
|
212
197
|
|
|
213
|
-
|
|
198
|
+
throw err;
|
|
214
199
|
}
|
|
215
200
|
}
|
|
216
201
|
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import type { Robots } from "../types/global";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import fsp from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { ROBOTS } from "../constants/endpoints";
|
|
7
7
|
import { get } from "../utils/api";
|
|
8
|
-
import {
|
|
8
|
+
import { pathExists } from "../utils/folders";
|
|
9
9
|
import { verboseLog } from "../utils/loggin";
|
|
10
|
+
import { getRenderPathsFromDB } from "../utils/render";
|
|
10
11
|
|
|
11
|
-
const config = getConfig();
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* TODO: JSDoc
|
|
15
|
-
*/
|
|
16
12
|
class RobotsService {
|
|
17
13
|
robots: Robots;
|
|
18
14
|
settings: Record<string, unknown>;
|
|
@@ -22,12 +18,9 @@ class RobotsService {
|
|
|
22
18
|
this.settings = {};
|
|
23
19
|
}
|
|
24
20
|
|
|
25
|
-
/**
|
|
26
|
-
* TODO: JSDoc
|
|
27
|
-
*/
|
|
28
21
|
private async getRobots() {
|
|
29
22
|
try {
|
|
30
|
-
const apiRobots = await get<Robots>({ endpoint:
|
|
23
|
+
const apiRobots = await get<Robots>({ endpoint: ROBOTS });
|
|
31
24
|
this.robots =
|
|
32
25
|
apiRobots
|
|
33
26
|
?.filter((r) => !!r.path)
|
|
@@ -44,8 +37,8 @@ class RobotsService {
|
|
|
44
37
|
* Write robots.txt files for the domain.
|
|
45
38
|
*/
|
|
46
39
|
async writeFiles(domain: string) {
|
|
47
|
-
const {
|
|
48
|
-
const distDirectory = path.join(
|
|
40
|
+
const { __root } = await getRenderPathsFromDB({ domain });
|
|
41
|
+
const distDirectory = path.join(__root, "dist");
|
|
49
42
|
|
|
50
43
|
await this.getRobots();
|
|
51
44
|
|
|
@@ -56,9 +49,9 @@ class RobotsService {
|
|
|
56
49
|
return;
|
|
57
50
|
}
|
|
58
51
|
|
|
59
|
-
if (
|
|
52
|
+
if (await pathExists(distDirectory)) {
|
|
60
53
|
const fileLocation = path.join(distDirectory, "robots.txt");
|
|
61
|
-
|
|
54
|
+
await fsp.writeFile(fileLocation, robot?.content);
|
|
62
55
|
verboseLog(`wrote robots.txt to ${fileLocation}`);
|
|
63
56
|
} else {
|
|
64
57
|
console.log(`${distDirectory} not found`);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Core } from "@griddo/core";
|
|
1
2
|
import type {
|
|
2
3
|
AllSitesReponse,
|
|
3
4
|
EndPageInfoResponse,
|
|
@@ -11,17 +12,26 @@ import type {
|
|
|
11
12
|
StartPageRenderResponse,
|
|
12
13
|
} from "../types/api";
|
|
13
14
|
import type { Site } from "../types/sites";
|
|
14
|
-
import type { Core } from "@griddo/core";
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
BUILD_END,
|
|
18
|
+
BUILD_START,
|
|
19
|
+
GET_ALL,
|
|
20
|
+
GET_PAGE,
|
|
21
|
+
GET_REFERENCE_FIELD_DATA,
|
|
22
|
+
GET_SITEMAP,
|
|
23
|
+
INFO,
|
|
24
|
+
LANGUAGES,
|
|
25
|
+
SOCIALS,
|
|
26
|
+
} from "../constants/endpoints";
|
|
17
27
|
import { get, post } from "../utils/api";
|
|
18
28
|
|
|
19
29
|
/**
|
|
20
30
|
* Get a list of site objects.
|
|
21
31
|
*/
|
|
22
32
|
async function getAllSites(domain: string) {
|
|
23
|
-
return
|
|
24
|
-
endpoint: `${
|
|
33
|
+
return get<AllSitesReponse>({
|
|
34
|
+
endpoint: `${GET_ALL}?domainSlug=${domain}`,
|
|
25
35
|
});
|
|
26
36
|
}
|
|
27
37
|
|
|
@@ -29,7 +39,7 @@ async function getAllSites(domain: string) {
|
|
|
29
39
|
* Get a list of site objects from a domain.
|
|
30
40
|
*/
|
|
31
41
|
async function getAllSitesFromDomain(domain: string) {
|
|
32
|
-
const allSites = await get<AllSitesReponse>({ endpoint:
|
|
42
|
+
const allSites = await get<AllSitesReponse>({ endpoint: GET_ALL });
|
|
33
43
|
|
|
34
44
|
if (allSites.length) {
|
|
35
45
|
for (const site of allSites) {
|
|
@@ -40,8 +50,7 @@ async function getAllSitesFromDomain(domain: string) {
|
|
|
40
50
|
site.domains = items
|
|
41
51
|
.filter(
|
|
42
52
|
(item) =>
|
|
43
|
-
item.domain &&
|
|
44
|
-
(item.domain.slug === domain || item.domain.slug === `/${domain}`),
|
|
53
|
+
item.domain && (item.domain.slug === domain || item.domain.slug === `/${domain}`),
|
|
45
54
|
)
|
|
46
55
|
.map((item) => ({ [item.id]: `${item.domain.slug}${item.path}` }));
|
|
47
56
|
}
|
|
@@ -54,8 +63,8 @@ async function getAllSitesFromDomain(domain: string) {
|
|
|
54
63
|
* Fetch a page object from API.
|
|
55
64
|
*/
|
|
56
65
|
async function getPage(id: number, cacheKey: string) {
|
|
57
|
-
return
|
|
58
|
-
endpoint: `${
|
|
66
|
+
return get<PageResponse>({
|
|
67
|
+
endpoint: `${GET_PAGE}/${id}`,
|
|
59
68
|
cacheKey,
|
|
60
69
|
});
|
|
61
70
|
}
|
|
@@ -64,27 +73,27 @@ async function getPage(id: number, cacheKey: string) {
|
|
|
64
73
|
* Get site info
|
|
65
74
|
*/
|
|
66
75
|
async function getSiteInfo(id: number, cacheKey = "") {
|
|
67
|
-
const [prefix, suffix] =
|
|
76
|
+
const [prefix, suffix] = INFO;
|
|
68
77
|
|
|
69
|
-
return
|
|
78
|
+
return get<Site>({
|
|
70
79
|
endpoint: `${prefix}${id}${suffix}`,
|
|
71
80
|
cacheKey,
|
|
72
81
|
});
|
|
73
82
|
}
|
|
74
83
|
|
|
75
84
|
async function getSiteLanguages(id: number, cacheKey = "") {
|
|
76
|
-
const [prefix, suffix] =
|
|
85
|
+
const [prefix, suffix] = LANGUAGES;
|
|
77
86
|
|
|
78
|
-
return
|
|
87
|
+
return get<LanguagesResponse>({
|
|
79
88
|
endpoint: `${prefix}${id}${suffix}`,
|
|
80
89
|
cacheKey,
|
|
81
90
|
});
|
|
82
91
|
}
|
|
83
92
|
|
|
84
93
|
async function startSiteRender(id: number) {
|
|
85
|
-
const [prefix, suffix] =
|
|
94
|
+
const [prefix, suffix] = BUILD_START;
|
|
86
95
|
|
|
87
|
-
return
|
|
96
|
+
return get<StartPageRenderResponse>({
|
|
88
97
|
endpoint: `${prefix}${id}${suffix}`,
|
|
89
98
|
});
|
|
90
99
|
}
|
|
@@ -93,12 +102,13 @@ async function startSiteRender(id: number) {
|
|
|
93
102
|
* Send the end signal to API for a render site.
|
|
94
103
|
*/
|
|
95
104
|
async function endSiteRender(id: number, body: EndSiteRenderBody) {
|
|
96
|
-
const [prefix, suffix] =
|
|
105
|
+
const [prefix, suffix] = BUILD_END;
|
|
97
106
|
|
|
98
|
-
return
|
|
107
|
+
return post<EndPageInfoResponse>({
|
|
99
108
|
endpoint: `${prefix}${id}${suffix}`,
|
|
100
109
|
body,
|
|
101
110
|
useApiCacheDir: false,
|
|
111
|
+
logToFile: false,
|
|
102
112
|
});
|
|
103
113
|
}
|
|
104
114
|
|
|
@@ -109,11 +119,11 @@ async function getReferenceFieldSiteData(
|
|
|
109
119
|
dataSiteId?: number,
|
|
110
120
|
dataLangID?: number,
|
|
111
121
|
) {
|
|
112
|
-
const [prefix, suffix] =
|
|
122
|
+
const [prefix, suffix] = GET_REFERENCE_FIELD_DATA;
|
|
113
123
|
const site = dataSiteId || page.site;
|
|
114
124
|
const lang = dataLangID || page.language;
|
|
115
125
|
|
|
116
|
-
return
|
|
126
|
+
return post<ReferenceFieldResponse>({
|
|
117
127
|
endpoint: `${prefix}${site}${suffix}`,
|
|
118
128
|
body,
|
|
119
129
|
headers: { lang },
|
|
@@ -121,18 +131,20 @@ async function getReferenceFieldSiteData(
|
|
|
121
131
|
});
|
|
122
132
|
}
|
|
123
133
|
|
|
124
|
-
async function getSitemap(
|
|
125
|
-
const
|
|
134
|
+
async function getSitemap(options: { siteId: number; headers?: Record<string, string> }) {
|
|
135
|
+
const { siteId, headers } = options;
|
|
136
|
+
const [prefix, suffix] = GET_SITEMAP;
|
|
126
137
|
|
|
127
138
|
return get<SitemapAPIResponse>({
|
|
128
|
-
endpoint: `${prefix}${
|
|
139
|
+
endpoint: `${prefix}${siteId}${suffix}`,
|
|
140
|
+
headers,
|
|
129
141
|
});
|
|
130
142
|
}
|
|
131
143
|
|
|
132
144
|
async function getSiteSocials(id: number, cacheKey = "") {
|
|
133
|
-
const [prefix, suffix] =
|
|
145
|
+
const [prefix, suffix] = SOCIALS;
|
|
134
146
|
|
|
135
|
-
return
|
|
147
|
+
return get<SocialsResponse>({
|
|
136
148
|
endpoint: `${prefix}${id}${suffix}`,
|
|
137
149
|
cacheKey,
|
|
138
150
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BuildProcessData } from "../types/global";
|
|
1
|
+
import type { BuildProcessData, Settings } from "../types/global";
|
|
2
2
|
import type {
|
|
3
3
|
GriddoListPage,
|
|
4
4
|
GriddoMultiPage,
|
|
@@ -6,20 +6,23 @@ import type {
|
|
|
6
6
|
GriddoSinglePage,
|
|
7
7
|
PageAdditionalInfo,
|
|
8
8
|
} from "../types/pages";
|
|
9
|
+
import type { RenderMode } from "../types/render";
|
|
9
10
|
|
|
10
|
-
import
|
|
11
|
+
import fsp from "node:fs/promises";
|
|
11
12
|
import path from "node:path";
|
|
12
13
|
|
|
13
14
|
import pLimit from "p-limit";
|
|
14
15
|
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
import { SETTINGS } from "../constants/endpoints";
|
|
17
|
+
import {
|
|
18
|
+
GRIDDO_API_CONCURRENCY_COUNT,
|
|
19
|
+
GRIDDO_API_URL,
|
|
20
|
+
GRIDDO_PUBLIC_API_URL,
|
|
21
|
+
GRIDDO_REACT_APP_INSTANCE,
|
|
22
|
+
} from "../constants/envs";
|
|
23
|
+
import { get } from "../utils/api";
|
|
20
24
|
import { updatedSiteHash } from "../utils/cache";
|
|
21
|
-
import {
|
|
22
|
-
import { buildLog, listSitesLog } from "../utils/loggin";
|
|
25
|
+
import { infoLog, listSitesLog } from "../utils/loggin";
|
|
23
26
|
import {
|
|
24
27
|
createGriddoListPages,
|
|
25
28
|
createGriddoMultiPages,
|
|
@@ -29,26 +32,38 @@ import {
|
|
|
29
32
|
} from "../utils/pages";
|
|
30
33
|
import { getSiteData, getSitesToRender, unpublishSites } from "../utils/sites";
|
|
31
34
|
import {
|
|
32
|
-
getMissingPublishedPagesInStore,
|
|
33
35
|
getZombiePagesInStore,
|
|
34
36
|
removeOrphanSites,
|
|
35
37
|
removeSitePagesFromStore,
|
|
36
38
|
saveRenderInfoInStore,
|
|
37
39
|
saveSitePagesInStore,
|
|
38
40
|
} from "../utils/store";
|
|
41
|
+
import { NavigationService } from "./navigation";
|
|
42
|
+
import { getReferenceFieldData } from "./reference-fields";
|
|
43
|
+
import { getPage } from "./sites";
|
|
39
44
|
|
|
40
|
-
const renderId =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
const renderId = Date.now().toString();
|
|
46
|
+
|
|
47
|
+
function guessSiteNeedsToBeRenderedFromScratch() {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
44
50
|
|
|
45
51
|
/**
|
|
46
52
|
* Fetch, process and save object pages and sites data into the file system to
|
|
47
53
|
* be consumed by other services (Griddo itself, Adapters, etc.)
|
|
48
54
|
*/
|
|
49
|
-
async function createStore(
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
async function createStore(options: {
|
|
56
|
+
domain: string;
|
|
57
|
+
renderMode: RenderMode;
|
|
58
|
+
griddoVersion: string;
|
|
59
|
+
basePath: string;
|
|
60
|
+
}) {
|
|
61
|
+
console.info(`API calls with ${GRIDDO_API_CONCURRENCY_COUNT} threads`);
|
|
62
|
+
console.info(`API URL ${GRIDDO_API_URL as string}`);
|
|
63
|
+
|
|
64
|
+
const { renderMode, domain, griddoVersion, basePath } = options;
|
|
65
|
+
const renderFromScratch = renderMode === "FROM_SCRATCH";
|
|
66
|
+
const storeDir = path.join(basePath, "store");
|
|
52
67
|
|
|
53
68
|
try {
|
|
54
69
|
// Vars to save later in the report file
|
|
@@ -58,31 +73,43 @@ async function createStore(domain: string) {
|
|
|
58
73
|
// Get sites objects to publish and unpublish from this domain
|
|
59
74
|
const { sitesToPublish, sitesToUnpublish } = await getSitesToRender(domain);
|
|
60
75
|
|
|
61
|
-
const domainHasSites =
|
|
62
|
-
sitesToPublish.length > 0 || sitesToUnpublish.length > 0;
|
|
63
|
-
|
|
64
|
-
if (!domainHasSites) {
|
|
65
|
-
console.warn(`There are no sites to update in the domain ${domain}`);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
76
|
listSitesLog("Sites to publish:", sitesToPublish);
|
|
69
77
|
listSitesLog("Sites to unpublish:", sitesToUnpublish);
|
|
70
78
|
|
|
71
79
|
// Send unpublished sites to API.
|
|
72
|
-
// @todo ¿mover esta llamada al final del proceso de render?
|
|
73
|
-
// Aquí también se están eliminado físicamente los archivos json del
|
|
74
|
-
// store de los sites para despublicar.
|
|
75
80
|
await unpublishSites(sitesToUnpublish);
|
|
76
81
|
|
|
77
82
|
// Eliminamos posibles sites que estén en el store pero que no deberían
|
|
78
83
|
// porque han sido cambiados de dominio. Si han sido despublicados ya se
|
|
79
84
|
// despublican bien porque entran en `sitesToUnpublish`
|
|
80
|
-
removeOrphanSites(sitesToPublish, domain);
|
|
85
|
+
await removeOrphanSites(sitesToPublish, domain);
|
|
86
|
+
|
|
87
|
+
const allPagesToRemoveFromBuild: Array<number> = [];
|
|
88
|
+
// let numberOfFinalActivePages: Array<number> = [];
|
|
89
|
+
|
|
90
|
+
for (const site of sitesToUnpublish) {
|
|
91
|
+
const { pagesStatus } = site;
|
|
92
|
+
|
|
93
|
+
// Añadimos a allPagesToRemoveFromBuild todas las páginas de un site
|
|
94
|
+
// para despublicar.
|
|
95
|
+
allPagesToRemoveFromBuild.push(
|
|
96
|
+
...pagesStatus.active,
|
|
97
|
+
...pagesStatus.offlinePending,
|
|
98
|
+
...pagesStatus.uploadPending,
|
|
99
|
+
...pagesStatus.deleted,
|
|
100
|
+
...pagesStatus.offline,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
81
103
|
|
|
82
|
-
// Solo los sites to publish...
|
|
83
104
|
for (const site of sitesToPublish) {
|
|
84
105
|
const { id: siteId, slug: siteSlug, theme, favicon, pagesStatus } = site;
|
|
85
106
|
const siteDirName = siteId.toString();
|
|
107
|
+
// numberOfFinalActivePages.push(
|
|
108
|
+
// ...pagesStatus.active,
|
|
109
|
+
// ...pagesStatus.uploadPending,
|
|
110
|
+
// );
|
|
111
|
+
|
|
112
|
+
allPagesToRemoveFromBuild.push(...pagesStatus.offlinePending, ...pagesStatus.deleted);
|
|
86
113
|
|
|
87
114
|
const {
|
|
88
115
|
siteInfo,
|
|
@@ -104,7 +131,7 @@ async function createStore(domain: string) {
|
|
|
104
131
|
avoidSelfReferenceCanonicals,
|
|
105
132
|
avoidHrefLangXDefault,
|
|
106
133
|
avoidDebugMetas,
|
|
107
|
-
} = await
|
|
134
|
+
} = await get<Settings>({ endpoint: SETTINGS });
|
|
108
135
|
|
|
109
136
|
buildProcessData[siteId] = {
|
|
110
137
|
siteHash,
|
|
@@ -118,7 +145,7 @@ async function createStore(domain: string) {
|
|
|
118
145
|
|
|
119
146
|
site.languages = siteLangs;
|
|
120
147
|
|
|
121
|
-
const shouldUpdateSite = updatedSiteHash(siteId, siteHash);
|
|
148
|
+
const shouldUpdateSite = await updatedSiteHash(siteId, siteHash);
|
|
122
149
|
|
|
123
150
|
const siteScript = siteInfo.siteScript;
|
|
124
151
|
|
|
@@ -129,9 +156,9 @@ async function createStore(domain: string) {
|
|
|
129
156
|
};
|
|
130
157
|
|
|
131
158
|
const additionalInfo = {
|
|
132
|
-
baseUrl:
|
|
133
|
-
publicBaseUrl:
|
|
134
|
-
instance:
|
|
159
|
+
baseUrl: GRIDDO_API_URL,
|
|
160
|
+
publicBaseUrl: GRIDDO_PUBLIC_API_URL,
|
|
161
|
+
instance: GRIDDO_REACT_APP_INSTANCE,
|
|
135
162
|
siteSlug,
|
|
136
163
|
theme,
|
|
137
164
|
siteMetadata,
|
|
@@ -151,10 +178,10 @@ async function createStore(domain: string) {
|
|
|
151
178
|
siteScript,
|
|
152
179
|
};
|
|
153
180
|
|
|
154
|
-
|
|
181
|
+
infoLog(`Getting pages from ${site.name} site`);
|
|
155
182
|
|
|
156
183
|
/// Creates the store directory for each site using the id
|
|
157
|
-
|
|
184
|
+
await fsp.mkdir(path.join(storeDir, siteDirName), {
|
|
158
185
|
recursive: true,
|
|
159
186
|
});
|
|
160
187
|
|
|
@@ -163,10 +190,7 @@ async function createStore(domain: string) {
|
|
|
163
190
|
// -------------------------------------------------------------------------
|
|
164
191
|
// Async function that process every page for one site to use later in the
|
|
165
192
|
// `Promise.all` with pLimit.
|
|
166
|
-
const fetchSitePageAndSaveInStore = async (
|
|
167
|
-
siteIdName: string,
|
|
168
|
-
pageId: number,
|
|
169
|
-
) => {
|
|
193
|
+
const fetchSitePageAndSaveInStore = async (siteIdName: string, pageId: number) => {
|
|
170
194
|
// Here will be store every page returned by the API and processed
|
|
171
195
|
let griddoPageObjects: Array<GriddoPageObject> = [];
|
|
172
196
|
|
|
@@ -185,9 +209,7 @@ async function createStore(domain: string) {
|
|
|
185
209
|
// SHAME: This new pageAdditionalInfo needs to be a copy because
|
|
186
210
|
// additionalInfo referenced from outside this function and
|
|
187
211
|
// its used by other pages.
|
|
188
|
-
const pageAdditionalInfo = JSON.parse(
|
|
189
|
-
JSON.stringify(additionalInfo),
|
|
190
|
-
) as PageAdditionalInfo;
|
|
212
|
+
const pageAdditionalInfo = JSON.parse(JSON.stringify(additionalInfo)) as PageAdditionalInfo;
|
|
191
213
|
|
|
192
214
|
// Updated with navigations (header & footer)
|
|
193
215
|
pageAdditionalInfo.navigations = NavService.getPageNavigations(page);
|
|
@@ -217,8 +239,7 @@ async function createStore(domain: string) {
|
|
|
217
239
|
// - Single: just one page
|
|
218
240
|
|
|
219
241
|
// Griddo page types
|
|
220
|
-
const isStaticListPage =
|
|
221
|
-
page?.mode === "list" || page?.mode === "paginated-data";
|
|
242
|
+
const isStaticListPage = page?.mode === "list" || page?.mode === "paginated-data";
|
|
222
243
|
const isMultiPage = !isStaticListPage && multiPageElements;
|
|
223
244
|
const isSinglePage = !isMultiPage && !isStaticListPage;
|
|
224
245
|
|
|
@@ -234,10 +255,12 @@ async function createStore(domain: string) {
|
|
|
234
255
|
} as GriddoListPage;
|
|
235
256
|
|
|
236
257
|
// pageObjects = await createGriddoListPages({ adapter: "Gatsby" })
|
|
237
|
-
griddoPageObjects = await createGriddoListPages(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
258
|
+
griddoPageObjects = await createGriddoListPages(griddoListPage, pageAdditionalInfo);
|
|
259
|
+
|
|
260
|
+
// ¿Por qué la añadimos a las páginas para borrar?
|
|
261
|
+
// Porque este tipo de páginas no está manejada por API y se crean varias páginas con el mismo ID.
|
|
262
|
+
// Esto hace que no se pueda rastrear bien el render.
|
|
263
|
+
allPagesToRemoveFromBuild.push(page.id);
|
|
241
264
|
}
|
|
242
265
|
|
|
243
266
|
// >> Multi-page <<
|
|
@@ -249,10 +272,12 @@ async function createStore(domain: string) {
|
|
|
249
272
|
griddoMultipage.multiPageElements = multiPageElements;
|
|
250
273
|
griddoMultipage.defaultLang = defaultLang;
|
|
251
274
|
|
|
252
|
-
griddoPageObjects = await createGriddoMultiPages(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
275
|
+
griddoPageObjects = await createGriddoMultiPages(griddoMultipage, pageAdditionalInfo);
|
|
276
|
+
|
|
277
|
+
// ¿Por qué la añadimos a las páginas para borrar?
|
|
278
|
+
// Porque este tipo de páginas no está manejada por API y se crean varias páginas con el mismo ID.
|
|
279
|
+
// Esto hace que no se pueda rastrear bien el render.
|
|
280
|
+
allPagesToRemoveFromBuild.push(page.id);
|
|
256
281
|
}
|
|
257
282
|
|
|
258
283
|
// >> Single template <<
|
|
@@ -263,9 +288,7 @@ async function createStore(domain: string) {
|
|
|
263
288
|
griddoSinglePage.template = template;
|
|
264
289
|
griddoSinglePage.defaultLang = defaultLang;
|
|
265
290
|
|
|
266
|
-
griddoPageObjects = [
|
|
267
|
-
await createGriddoSinglePage(griddoSinglePage, pageAdditionalInfo),
|
|
268
|
-
];
|
|
291
|
+
griddoPageObjects = [await createGriddoSinglePage(griddoSinglePage, pageAdditionalInfo)];
|
|
269
292
|
}
|
|
270
293
|
|
|
271
294
|
// Upload only the valid pages hashes or ids of pages that has
|
|
@@ -276,25 +299,26 @@ async function createStore(domain: string) {
|
|
|
276
299
|
}
|
|
277
300
|
|
|
278
301
|
// Save build data to store
|
|
279
|
-
saveSitePagesInStore(siteIdName, griddoPageObjects);
|
|
302
|
+
await saveSitePagesInStore(siteIdName, griddoPageObjects);
|
|
280
303
|
};
|
|
281
304
|
|
|
282
|
-
// Pages that needs to be fetched from the API and written to the
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
305
|
+
// Pages that needs to be fetched from the API and written to the store.
|
|
306
|
+
const pagesToFetchFromAPI = pagesStatus.uploadPending;
|
|
307
|
+
|
|
308
|
+
// Esto es necesario porque en la BBDD las páginas pueden estar
|
|
309
|
+
// marcadas como activas (online) pero si es una máquina nueva hace
|
|
310
|
+
// falta hacerlas de nuevo...
|
|
311
|
+
// const sitePendingOfPublishing = site.isPublished && site.shouldBeUpdated;
|
|
312
|
+
const sitePendingOfPublishing = guessSiteNeedsToBeRenderedFromScratch();
|
|
313
|
+
// @todo: necesito tener un sistema par publicar todo de un site (cuando un site esté pending to publish)
|
|
314
|
+
// algo como site.status = pending | published | unpublished...
|
|
315
|
+
if (renderFromScratch || sitePendingOfPublishing) {
|
|
316
|
+
pagesToFetchFromAPI.push(...pagesStatus.active);
|
|
317
|
+
}
|
|
294
318
|
|
|
295
319
|
// Create pages to the store. First requesting from API,
|
|
296
320
|
// transform, etc., and then writing them to disk.
|
|
297
|
-
const limit = pLimit(
|
|
321
|
+
const limit = pLimit(GRIDDO_API_CONCURRENCY_COUNT);
|
|
298
322
|
const pagesToStore = pagesToFetchFromAPI.map((id: number) =>
|
|
299
323
|
limit(() => fetchSitePageAndSaveInStore(siteDirName, id)),
|
|
300
324
|
);
|
|
@@ -302,13 +326,13 @@ async function createStore(domain: string) {
|
|
|
302
326
|
await Promise.all(pagesToStore);
|
|
303
327
|
|
|
304
328
|
// @ts-expect-error Mutate pagesStatus for reading pourposes.
|
|
305
|
-
pagesStatus.zombie = getZombiePagesInStore(siteDirName, [
|
|
329
|
+
pagesStatus.zombie = await getZombiePagesInStore(siteDirName, [
|
|
306
330
|
...pagesStatus.active,
|
|
307
331
|
...pagesStatus.uploadPending,
|
|
308
332
|
]);
|
|
309
333
|
|
|
310
334
|
// Delete pages from the store removing them from disk.
|
|
311
|
-
removeSitePagesFromStore(siteDirName, [
|
|
335
|
+
await removeSitePagesFromStore(siteDirName, [
|
|
312
336
|
pagesStatus.deleted,
|
|
313
337
|
pagesStatus.offline,
|
|
314
338
|
pagesStatus.offlinePending,
|
|
@@ -321,35 +345,22 @@ async function createStore(domain: string) {
|
|
|
321
345
|
// sean que hayan cambiado etc.) guardamos un archivo con la información
|
|
322
346
|
// del render para usos posteriores.
|
|
323
347
|
|
|
324
|
-
//
|
|
325
|
-
|
|
326
|
-
// ( 1 ) - Render de dominios con sites para publicar o despublicar. Se
|
|
348
|
+
// Render de dominios con sites para publicar o despublicar. Se
|
|
327
349
|
// guarda la infor del render normalmente.
|
|
328
350
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
// Entonces se eliminan las páginas "huérfanas" de la carpeta `store`
|
|
332
|
-
// así el proceso de SSG se encontrará efectivamente con un dominio "sin
|
|
333
|
-
// páginas" y "borrará" lo que exista en ese momento en el store para
|
|
334
|
-
// ese dominio y se guarda la información del render con arrays vacíos
|
|
335
|
-
// directamente en `createdPages` y `sitesToPublish`.
|
|
336
|
-
|
|
337
|
-
if (domainHasSites) {
|
|
338
|
-
// ( 1 )
|
|
339
|
-
saveRenderInfoInStore({
|
|
351
|
+
await saveRenderInfoInStore(
|
|
352
|
+
{
|
|
340
353
|
buildProcessData,
|
|
341
354
|
createdPages,
|
|
342
355
|
sitesToPublish,
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
});
|
|
352
|
-
}
|
|
356
|
+
},
|
|
357
|
+
domain,
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
return {
|
|
361
|
+
pagesToCreate: createdPages,
|
|
362
|
+
pagesToDelete: allPagesToRemoveFromBuild,
|
|
363
|
+
};
|
|
353
364
|
} catch (e) {
|
|
354
365
|
const error = e as { message: string };
|
|
355
366
|
console.error(error.message);
|