@griddo/cx 11.7.6-rc.0 → 11.7.6-rc.2
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 +13 -9
- package/build/adapters/gatsby/actions/clean.js.map +1 -1
- package/build/adapters/gatsby/actions/close.js.map +1 -1
- package/build/adapters/gatsby/actions/data.js +3 -3
- package/build/adapters/gatsby/actions/data.js.map +1 -1
- package/build/adapters/gatsby/actions/healthCheck.js.map +1 -1
- package/build/adapters/gatsby/actions/init.js +2 -2
- package/build/adapters/gatsby/actions/init.js.map +1 -1
- package/build/adapters/gatsby/actions/meta.js +2 -2
- package/build/adapters/gatsby/actions/meta.js.map +1 -1
- package/build/adapters/gatsby/actions/prepare.js.map +1 -1
- package/build/adapters/gatsby/actions/relocation.js +2 -2
- package/build/adapters/gatsby/actions/relocation.js.map +1 -1
- package/build/adapters/gatsby/actions/restore.js +4 -4
- package/build/adapters/gatsby/actions/restore.js.map +1 -1
- package/build/adapters/gatsby/actions/ssg.js.map +1 -1
- package/build/adapters/gatsby/actions/sync.js +10 -9
- package/build/adapters/gatsby/actions/sync.js.map +1 -1
- package/build/adapters/gatsby/index.js +10 -6
- package/build/adapters/gatsby/index.js.map +1 -1
- package/build/adapters/gatsby/shared/context.js +8 -2
- package/build/adapters/gatsby/shared/context.js.map +1 -1
- 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 +11 -11
- package/build/adapters/gatsby/shared/extract-assets.js.map +1 -1
- package/build/adapters/gatsby/shared/gatsby-build.js.map +1 -1
- package/build/adapters/gatsby/shared/sync-render.js +162 -158
- package/build/adapters/gatsby/shared/sync-render.js.map +1 -1
- package/build/commands/end-render.js +44 -19
- package/build/commands/end-render.js.map +1 -1
- package/build/commands/prepare-assets-directory.js +4 -4
- package/build/commands/prepare-assets-directory.js.map +1 -1
- package/build/commands/prepare-domains-render.js +14 -19
- package/build/commands/prepare-domains-render.js.map +1 -1
- package/build/commands/reset-render.js +4 -4
- package/build/commands/reset-render.js.map +1 -1
- package/build/commands/start-render.js +20 -10
- package/build/commands/start-render.js.map +1 -1
- package/build/commands/upload-search-content.js +8 -17
- package/build/commands/upload-search-content.js.map +1 -1
- package/build/constants/endpoints.js.map +1 -1
- package/build/constants/envs.js +2 -7
- package/build/constants/envs.js.map +1 -1
- package/build/constants/errors.js +7 -9
- package/build/constants/errors.js.map +1 -1
- package/build/services/auth.js +1 -0
- package/build/services/auth.js.map +1 -1
- package/build/services/db-class.js +49 -0
- package/build/services/db-class.js.map +1 -0
- package/build/services/db.js.map +1 -1
- package/build/services/navigation.js +3 -0
- package/build/services/navigation.js.map +1 -1
- package/build/services/reference-fields.js.map +1 -1
- package/build/services/robots.js +4 -2
- package/build/services/robots.js.map +1 -1
- package/build/services/sites.js.map +1 -1
- package/build/services/store.js +2 -2
- package/build/services/store.js.map +1 -1
- package/build/types/render.js.map +1 -1
- package/build/utils/api.js.map +1 -1
- package/build/utils/artifacts.js +11 -11
- package/build/utils/artifacts.js.map +1 -1
- package/build/utils/brush.js +2 -2
- package/build/utils/brush.js.map +1 -1
- package/build/utils/cache.js +6 -6
- package/build/utils/cache.js.map +1 -1
- package/build/utils/check-health.js.map +1 -1
- package/build/utils/core-utils.js +35 -3
- package/build/utils/core-utils.js.map +1 -1
- package/build/utils/domains.js.map +1 -1
- package/build/utils/errors.js.map +1 -1
- package/build/utils/folders.js +30 -7
- package/build/utils/folders.js.map +1 -1
- package/build/utils/images.js.map +1 -1
- package/build/utils/instance.js.map +1 -1
- package/build/utils/loggin.js +9 -3
- package/build/utils/loggin.js.map +1 -1
- package/build/utils/pages.js.map +1 -1
- package/build/utils/render.js +1 -1
- package/build/utils/render.js.map +1 -1
- package/build/utils/sites.js +20 -19
- package/build/utils/sites.js.map +1 -1
- package/build/utils/store.js +8 -8
- package/build/utils/store.js.map +1 -1
- package/exporter/adapters/gatsby/actions/data.ts +3 -3
- package/exporter/adapters/gatsby/actions/init.ts +2 -2
- package/exporter/adapters/gatsby/actions/meta.ts +2 -2
- package/exporter/adapters/gatsby/actions/relocation.ts +2 -2
- package/exporter/adapters/gatsby/actions/restore.ts +4 -4
- package/exporter/adapters/gatsby/actions/sync.ts +10 -9
- package/exporter/adapters/gatsby/index.ts +13 -8
- package/exporter/adapters/gatsby/shared/diff-assets.ts +113 -0
- package/exporter/adapters/gatsby/shared/extract-assets.ts +11 -11
- package/exporter/adapters/gatsby/shared/sync-render.ts +195 -212
- package/exporter/build.sh +2 -3
- package/exporter/commands/end-render.ts +54 -25
- package/exporter/commands/prepare-assets-directory.ts +4 -4
- package/exporter/commands/prepare-domains-render.ts +15 -20
- package/exporter/commands/reset-render.ts +4 -4
- package/exporter/commands/start-render.ts +19 -11
- package/exporter/commands/upload-search-content.ts +9 -20
- package/exporter/constants/envs.ts +0 -6
- package/exporter/constants/errors.ts +12 -4
- package/exporter/services/db-class.ts +54 -0
- package/exporter/services/robots.ts +2 -2
- package/exporter/services/store.ts +2 -2
- package/exporter/types/global.ts +0 -1
- package/exporter/utils/artifacts.ts +11 -11
- package/exporter/utils/cache.ts +6 -6
- package/exporter/utils/core-utils.ts +46 -4
- package/exporter/utils/folders.ts +30 -7
- package/exporter/utils/loggin.ts +9 -3
- package/exporter/utils/render.ts +3 -1
- package/exporter/utils/sites.ts +18 -17
- package/exporter/utils/store.ts +8 -8
- package/gatsby-node.ts +22 -25
- package/package.json +10 -11
- package/src/gatsby-node-utils.ts +2 -2
- package/tsconfig.json +3 -2
- package/build/exporter/adapters/gatsby/actions/clean.d.ts +0 -3
- package/build/exporter/adapters/gatsby/actions/close.d.ts +0 -3
- package/build/exporter/adapters/gatsby/actions/data.d.ts +0 -2
- package/build/exporter/adapters/gatsby/actions/healthCheck.d.ts +0 -2
- package/build/exporter/adapters/gatsby/actions/init.d.ts +0 -2
- package/build/exporter/adapters/gatsby/actions/meta.d.ts +0 -2
- package/build/exporter/adapters/gatsby/actions/prepare.d.ts +0 -2
- package/build/exporter/adapters/gatsby/actions/relocation.d.ts +0 -2
- package/build/exporter/adapters/gatsby/actions/restore.d.ts +0 -3
- package/build/exporter/adapters/gatsby/actions/ssg.d.ts +0 -3
- package/build/exporter/adapters/gatsby/actions/sync.d.ts +0 -3
- package/build/exporter/adapters/gatsby/index.d.ts +0 -9
- package/build/exporter/adapters/gatsby/shared/context.d.ts +0 -38
- package/build/exporter/adapters/gatsby/shared/extract-assets.d.ts +0 -7
- package/build/exporter/adapters/gatsby/shared/gatsby-build.d.ts +0 -7
- package/build/exporter/adapters/gatsby/shared/sync-render.d.ts +0 -36
- package/build/exporter/adapters/gatsby/shared/types.d.ts +0 -34
- package/build/exporter/commands/end-render.d.ts +0 -2
- package/build/exporter/commands/prepare-assets-directory.d.ts +0 -2
- package/build/exporter/commands/prepare-domains-render.d.ts +0 -2
- package/build/exporter/commands/reset-render.d.ts +0 -2
- package/build/exporter/commands/start-render.d.ts +0 -2
- package/build/exporter/commands/upload-search-content.d.ts +0 -2
- package/build/exporter/constants/endpoints.d.ts +0 -19
- package/build/exporter/constants/envs.d.ts +0 -31
- package/build/exporter/constants/errors.d.ts +0 -24
- package/build/exporter/services/auth.d.ts +0 -10
- package/build/exporter/services/db.d.ts +0 -4
- package/build/exporter/services/navigation.d.ts +0 -50
- package/build/exporter/services/reference-fields.d.ts +0 -20
- package/build/exporter/services/robots.d.ts +0 -13
- package/build/exporter/services/sites.d.ts +0 -32
- package/build/exporter/services/store.d.ts +0 -15
- package/build/exporter/types/api.d.ts +0 -141
- package/build/exporter/types/global.d.ts +0 -84
- package/build/exporter/types/navigation.d.ts +0 -28
- package/build/exporter/types/pages.d.ts +0 -144
- package/build/exporter/types/render.d.ts +0 -50
- package/build/exporter/types/sites.d.ts +0 -56
- package/build/exporter/types/templates.d.ts +0 -8
- package/build/exporter/utils/api.d.ts +0 -23
- package/build/exporter/utils/artifacts.d.ts +0 -6
- package/build/exporter/utils/brush.d.ts +0 -18
- package/build/exporter/utils/cache.d.ts +0 -30
- package/build/exporter/utils/check-health.d.ts +0 -7
- package/build/exporter/utils/core-utils.d.ts +0 -77
- package/build/exporter/utils/domains.d.ts +0 -13
- package/build/exporter/utils/errors.d.ts +0 -15
- package/build/exporter/utils/folders.d.ts +0 -66
- package/build/exporter/utils/images.d.ts +0 -16
- package/build/exporter/utils/instance.d.ts +0 -21
- package/build/exporter/utils/loggin.d.ts +0 -37
- package/build/exporter/utils/pages.d.ts +0 -34
- package/build/exporter/utils/render.d.ts +0 -49
- package/build/exporter/utils/sites.d.ts +0 -31
- package/build/exporter/utils/store.d.ts +0 -53
- package/start-render.js +0 -5
package/exporter/utils/render.ts
CHANGED
|
@@ -92,6 +92,9 @@ async function resolveDomainRenderMode(options: { domain: string; shouldBeRender
|
|
|
92
92
|
return { renderMode: RENDER_MODE.IDLE, reason: "" };
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
console.log(
|
|
96
|
+
"[ DEBUG ] (INCREMENTAL) porque no se cumplen: missingExports (FROM_SCRATCH), wasRenderWithError (FROM_SCRATCH), isNewDeploy (FROM_SCRATCH) o !shouldBeRendered (IDLE)",
|
|
97
|
+
);
|
|
95
98
|
return { renderMode: RENDER_MODE.INCREMENTAL, reason: "" };
|
|
96
99
|
}
|
|
97
100
|
|
|
@@ -145,7 +148,6 @@ async function getRenderPathsFromDB(options?: { domain?: string; dbFilePath?: st
|
|
|
145
148
|
__exports: path.join(paths.exportsDir, domain || ""),
|
|
146
149
|
__ssg: paths.ssg,
|
|
147
150
|
__exports_dist: path.join(paths.exportsDir, domain || "", "dist"),
|
|
148
|
-
__cx_dist: path.join(paths.cx, "dist"),
|
|
149
151
|
};
|
|
150
152
|
}
|
|
151
153
|
|
package/exporter/utils/sites.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Site, SiteData } from "../types/sites";
|
|
|
3
3
|
import fsp from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { create } from "xmlbuilder2";
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
GRIDDO_API_URL,
|
|
@@ -84,7 +84,7 @@ async function getSitesToRender(domain: string) {
|
|
|
84
84
|
* @see https://griddoio.notion.site/Sites-d7bb0b7cb8d24894a5337e1139fc3d09#2019d3255bda4d219c7e19cf28d0c4fe
|
|
85
85
|
*/
|
|
86
86
|
async function unpublishSites(sites: Array<Site>) {
|
|
87
|
-
const {
|
|
87
|
+
const { __root } = await getRenderPathsFromDB();
|
|
88
88
|
|
|
89
89
|
for (const site of sites) {
|
|
90
90
|
// API
|
|
@@ -102,7 +102,7 @@ async function unpublishSites(sites: Array<Site>) {
|
|
|
102
102
|
// STORE
|
|
103
103
|
// Remove site directory from the Store
|
|
104
104
|
// @todo: quitar. Como ya no hay persistenci de store, esto debería eliminarse de forma segura.
|
|
105
|
-
await fsp.rm(path.join(
|
|
105
|
+
await fsp.rm(path.join(__root, "store", site.id.toString()), {
|
|
106
106
|
force: true,
|
|
107
107
|
recursive: true,
|
|
108
108
|
});
|
|
@@ -150,7 +150,7 @@ async function getSiteData(siteID: number) {
|
|
|
150
150
|
async function generateBuildReport(domain: string) {
|
|
151
151
|
const authControl = await AuthService.login();
|
|
152
152
|
|
|
153
|
-
const {
|
|
153
|
+
const { __root } = await getRenderPathsFromDB();
|
|
154
154
|
const { buildReportFileName } = await getRenderMetadataFromDB();
|
|
155
155
|
const { buildProcessData } = await getBuildMetadata(domain);
|
|
156
156
|
|
|
@@ -164,7 +164,7 @@ async function generateBuildReport(domain: string) {
|
|
|
164
164
|
sites: buildSitesInfo,
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
-
const reportFilePath = path.join(
|
|
167
|
+
const reportFilePath = path.join(__root, "dist", buildReportFileName);
|
|
168
168
|
|
|
169
169
|
await fsp.writeFile(reportFilePath, JSON.stringify(report));
|
|
170
170
|
|
|
@@ -175,9 +175,9 @@ async function generateBuildReport(domain: string) {
|
|
|
175
175
|
* Generate sitemaps and save them into file system.
|
|
176
176
|
*/
|
|
177
177
|
async function generateSitemaps(domain: string) {
|
|
178
|
-
const {
|
|
178
|
+
const { __root } = await getRenderPathsFromDB();
|
|
179
179
|
const { sitesToPublish } = await getBuildMetadata(domain);
|
|
180
|
-
const distDir = path.join(
|
|
180
|
+
const distDir = path.join(__root, "dist");
|
|
181
181
|
const templateSitemapPrefix = "sitemap-";
|
|
182
182
|
|
|
183
183
|
const isGriddoSitemapFile = (file: string) =>
|
|
@@ -245,15 +245,16 @@ async function generateSitemaps(domain: string) {
|
|
|
245
245
|
continue;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
const siteMap =
|
|
249
|
-
"
|
|
248
|
+
const siteMap = create({ version: "1.0", encoding: "UTF-8" })
|
|
249
|
+
.ele("urlset", {
|
|
250
250
|
xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9",
|
|
251
251
|
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
|
|
252
252
|
"xsi:schemaLocation":
|
|
253
|
-
"http://www.sitemaps.org/schemas/sitemap/0.9
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
253
|
+
"http://www.sitemaps.org/schemas/sitemap/0.9 " +
|
|
254
|
+
"http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd",
|
|
255
|
+
})
|
|
256
|
+
.ele(sitemapPages.map((page) => ({ url: page })))
|
|
257
|
+
.end({ prettyPrint: true });
|
|
257
258
|
|
|
258
259
|
const sitemapName = `/${templateSitemapPrefix}${templateId.toLowerCase()}.xml`;
|
|
259
260
|
const exactPath = path.join(sitemapBasePath, sitemapName);
|
|
@@ -267,10 +268,10 @@ async function generateSitemaps(domain: string) {
|
|
|
267
268
|
continue;
|
|
268
269
|
}
|
|
269
270
|
|
|
270
|
-
const siteMap =
|
|
271
|
-
"
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
const siteMap = create({ version: "1.0", encoding: "UTF-8" })
|
|
272
|
+
.ele("sitemapindex", { xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9" })
|
|
273
|
+
.ele(sitemaps.map((loc) => ({ sitemap: { loc } })))
|
|
274
|
+
.end({ prettyPrint: true });
|
|
274
275
|
|
|
275
276
|
const exactPath = path.join(sitemapBasePath, "sitemap.xml");
|
|
276
277
|
|
package/exporter/utils/store.ts
CHANGED
|
@@ -93,13 +93,13 @@ async function getPageInStoreDir(basePath: string) {
|
|
|
93
93
|
* @param pages - An array of Griddo page objects to be saved.
|
|
94
94
|
*/
|
|
95
95
|
async function saveSitePagesInStore(siteDirName: string, pages: Array<GriddoPageObject>) {
|
|
96
|
-
const {
|
|
96
|
+
const { __root } = await getRenderPathsFromDB();
|
|
97
97
|
|
|
98
98
|
try {
|
|
99
99
|
for (const page of pages) {
|
|
100
100
|
removeProperties(page, ["editorID", "parentEditorID"]);
|
|
101
101
|
const filename = `${page.context.page.id}.json`;
|
|
102
|
-
const filePath = path.join(
|
|
102
|
+
const filePath = path.join(__root, "store", siteDirName, filename);
|
|
103
103
|
// En los listados estáticos y multipage los ids de las páginas son iguales
|
|
104
104
|
await writeUniqueFileSync(filePath, JSON.stringify(page));
|
|
105
105
|
}
|
|
@@ -120,11 +120,11 @@ async function saveSitePagesInStore(siteDirName: string, pages: Array<GriddoPage
|
|
|
120
120
|
* @param pageIdsArray - A two-dimensional array where each inner array contains numbers representing page files to be removed.
|
|
121
121
|
*/
|
|
122
122
|
async function removeSitePagesFromStore(siteDirName: string, pageIdsArray: Array<Array<number>>) {
|
|
123
|
-
const {
|
|
123
|
+
const { __root } = await getRenderPathsFromDB();
|
|
124
124
|
|
|
125
125
|
const processPageIdsArray = async (pageIds: Array<number>) => {
|
|
126
126
|
for (const filename of pageIds) {
|
|
127
|
-
const filePath = path.join(
|
|
127
|
+
const filePath = path.join(__root, "store", siteDirName, `${filename}.json`);
|
|
128
128
|
try {
|
|
129
129
|
if (await pathExists(filePath)) {
|
|
130
130
|
await fsp.unlink(filePath);
|
|
@@ -148,8 +148,8 @@ async function removeSitePagesFromStore(siteDirName: string, pageIdsArray: Array
|
|
|
148
148
|
* be marked as `sitesToUnpublish` so they must be removed manually.
|
|
149
149
|
*/
|
|
150
150
|
async function removeOrphanSites(sitesToPublish: Array<Site>, domain: string) {
|
|
151
|
-
const {
|
|
152
|
-
const storePath = path.join(
|
|
151
|
+
const { __root } = await getRenderPathsFromDB({ domain });
|
|
152
|
+
const storePath = path.join(__root, "store");
|
|
153
153
|
|
|
154
154
|
if (!(await pathExists(storePath))) {
|
|
155
155
|
return;
|
|
@@ -169,8 +169,8 @@ async function removeOrphanSites(sitesToPublish: Array<Site>, domain: string) {
|
|
|
169
169
|
* Get pages that are not active anymore but are in the store.
|
|
170
170
|
*/
|
|
171
171
|
async function getZombiePagesInStore(siteDir: string, activePages: Array<number>) {
|
|
172
|
-
const {
|
|
173
|
-
const storeDir = path.join(
|
|
172
|
+
const { __root } = await getRenderPathsFromDB();
|
|
173
|
+
const storeDir = path.join(__root, "store", siteDir);
|
|
174
174
|
const sitePages = await fsp.readdir(storeDir);
|
|
175
175
|
|
|
176
176
|
const zombiePages: Array<number> = [];
|
package/gatsby-node.ts
CHANGED
|
@@ -7,46 +7,43 @@ import { isComponentLibrary } from "./exporter/utils/instance";
|
|
|
7
7
|
import { getBuildPagesFromStore, pageSizeLog } from "./src/gatsby-node-utils";
|
|
8
8
|
|
|
9
9
|
// process.env available through gatsbyBuildCommand.
|
|
10
|
-
const showGriddoBuildLogs = JSON.parse(
|
|
11
|
-
process.env.GRIDDO_BUILD_LOGS || "false"
|
|
12
|
-
);
|
|
10
|
+
const showGriddoBuildLogs = JSON.parse(process.env.GRIDDO_BUILD_LOGS || "false");
|
|
13
11
|
const assetPrefixWithDomain = process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN;
|
|
14
|
-
const needsAssetDomainPrefix =
|
|
15
|
-
!!assetPrefixWithDomain && assetPrefixWithDomain !== "";
|
|
12
|
+
const needsAssetDomainPrefix = !!assetPrefixWithDomain && assetPrefixWithDomain !== "";
|
|
16
13
|
const nodeOptions = process.env.NODE_OPTIONS;
|
|
17
14
|
|
|
18
15
|
const template = path.resolve("./src/components/template.tsx");
|
|
19
16
|
const dbFilePath = isComponentLibrary
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
? path.resolve(__dirname, "../../..", ".cx-cache", "db.json")
|
|
18
|
+
: path.resolve(__dirname, "../..", ".cx-cache", "db.json");
|
|
22
19
|
|
|
23
20
|
const pages = getBuildPagesFromStore<GatsbyPageObject>({
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
withSizeProp: showGriddoBuildLogs,
|
|
22
|
+
dbFilePath,
|
|
26
23
|
});
|
|
27
24
|
|
|
28
25
|
const createPages: GatsbyNode["createPages"] = async ({ actions }) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
console.log(`read assetPrefixWithDomain=${assetPrefixWithDomain}`);
|
|
27
|
+
console.log(`set needsAssetDomainPrefix=${needsAssetDomainPrefix}`);
|
|
28
|
+
console.log(`using NODE_OPTIONS in gatsby-node.ts: ${nodeOptions}`);
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
for await (const page of pages) {
|
|
31
|
+
if (!page) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
37
34
|
|
|
38
|
-
|
|
35
|
+
page.component = template;
|
|
39
36
|
|
|
40
|
-
|
|
37
|
+
actions.createPage(page);
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
const path = page.path;
|
|
40
|
+
const id = page.context.id;
|
|
41
|
+
const size = pageSizeLog(Math.round(page.size || 0));
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
if (showGriddoBuildLogs) {
|
|
44
|
+
console.log(`Creating page ${path} - ${id} - ${size}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
50
47
|
};
|
|
51
48
|
|
|
52
49
|
export { onCreateWebpackConfig } from "./src/gatsby-node-utils";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/cx",
|
|
3
3
|
"description": "Griddo SSG based on Gatsby",
|
|
4
|
-
"version": "11.7.6-rc.
|
|
4
|
+
"version": "11.7.6-rc.2",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -15,9 +15,6 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "https://github.com/griddo/griddo"
|
|
17
17
|
},
|
|
18
|
-
"bin": {
|
|
19
|
-
"griddo-cx": "./start-render.js"
|
|
20
|
-
},
|
|
21
18
|
"scripts": {
|
|
22
19
|
"// NPM": "",
|
|
23
20
|
"prepare": "yarn run build",
|
|
@@ -25,7 +22,7 @@
|
|
|
25
22
|
"build": "rm -rf build && sh ./exporter/build.sh",
|
|
26
23
|
"build:debug": "rm -rf build && sh ./exporter/build.sh --debug",
|
|
27
24
|
"// TESTS": "",
|
|
28
|
-
"test": "NODE_OPTIONS='--import tsx' env-cmd node --test ./__tests__/*",
|
|
25
|
+
"test": "npm run test:create-render-fixtures && NODE_OPTIONS='--import tsx' env-cmd node --test ./__tests__/* && npm run test:remove-render-fixtures",
|
|
29
26
|
"test:create-render-fixtures": "env-cmd tsx ./__tests__/utils/create-fixtures.ts",
|
|
30
27
|
"test:remove-render-fixtures": "env-cmd tsx ./__tests__/utils/remove-fixtures.ts",
|
|
31
28
|
"// INFRA SCRIPTS": "",
|
|
@@ -42,7 +39,7 @@
|
|
|
42
39
|
"lint": "biome check --write",
|
|
43
40
|
"format": "biome format --write",
|
|
44
41
|
"flint": "npm run lint && npm run format",
|
|
45
|
-
"ts-lint": "
|
|
42
|
+
"ts-lint": "tsgo --noEmit",
|
|
46
43
|
"watch:ts-lint": "tsc --noEmit --watch"
|
|
47
44
|
},
|
|
48
45
|
"dependencies": {
|
|
@@ -50,20 +47,22 @@
|
|
|
50
47
|
"find-up-simple": "1.0.1",
|
|
51
48
|
"gatsby": "5.15.0",
|
|
52
49
|
"html-react-parser": "5.2.6",
|
|
53
|
-
"js2xmlparser": "5.0.0",
|
|
54
50
|
"p-limit": "3.1.0",
|
|
55
51
|
"typescript": "5.9.2",
|
|
56
|
-
"webpack": "5.
|
|
52
|
+
"webpack": "5.101.3",
|
|
53
|
+
"xmlbuilder2": "3.1.1"
|
|
57
54
|
},
|
|
58
55
|
"devDependencies": {
|
|
59
|
-
"@biomejs/biome": "2.2.
|
|
56
|
+
"@biomejs/biome": "2.2.4",
|
|
60
57
|
"@types/cheerio": "1.0.0",
|
|
61
58
|
"@types/node": "20.19.2",
|
|
62
59
|
"@types/webpack": "5.28.5",
|
|
60
|
+
"@types/xml2js": "0.4.14",
|
|
61
|
+
"@typescript/native-preview": "7.0.0-dev.20250912.1",
|
|
63
62
|
"cheerio": "1.1.2"
|
|
64
63
|
},
|
|
65
64
|
"peerDependencies": {
|
|
66
|
-
"@griddo/core": "
|
|
65
|
+
"@griddo/core": "*",
|
|
67
66
|
"@types/react": ">=18 <19",
|
|
68
67
|
"@types/react-dom": ">=18 <19",
|
|
69
68
|
"react": ">=18 <19",
|
|
@@ -89,5 +88,5 @@
|
|
|
89
88
|
"publishConfig": {
|
|
90
89
|
"access": "public"
|
|
91
90
|
},
|
|
92
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "8f531ba518504804c62cf35972d384d5ddc7eaf0"
|
|
93
92
|
}
|
package/src/gatsby-node-utils.ts
CHANGED
|
@@ -106,10 +106,10 @@ async function* getBuildPagesFromStore<PageType extends GriddoPageObject>(args?:
|
|
|
106
106
|
dbFilePath?: string;
|
|
107
107
|
}): AsyncGenerator<PageType> {
|
|
108
108
|
const { basePath, withSizeProp, dbFilePath } = args || {};
|
|
109
|
-
const {
|
|
109
|
+
const { __root } = await getRenderPathsFromDB({
|
|
110
110
|
dbFilePath,
|
|
111
111
|
});
|
|
112
|
-
const pagesDirPath = basePath || path.join(
|
|
112
|
+
const pagesDirPath = basePath || path.join(__root, "store");
|
|
113
113
|
|
|
114
114
|
// Procesamos archivos JSON uno por uno sin cargar todos los paths en memoria
|
|
115
115
|
for await (const filePath of walkStore(pagesDirPath)) {
|
package/tsconfig.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "es2024",
|
|
4
4
|
"lib": ["dom", "esnext"],
|
|
5
5
|
"jsx": "react-jsx",
|
|
6
6
|
"module": "NodeNext",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"strict": true,
|
|
11
11
|
"skipLibCheck": true,
|
|
12
12
|
"resolveJsonModule": true,
|
|
13
|
-
"typeRoots": []
|
|
13
|
+
"typeRoots": [],
|
|
14
|
+
"sourceMap": true
|
|
14
15
|
},
|
|
15
16
|
"include": [
|
|
16
17
|
"./exporter/**/*.ts",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Executes a complete Gatsby render process for a given domain.
|
|
3
|
-
*
|
|
4
|
-
* The render process consists of multiple lifecycle steps that handle cleaning,
|
|
5
|
-
* preparing, building and syncing the site. It can run in two modes:
|
|
6
|
-
* - FROM_SCRATCH: Performs a complete rebuild of the site
|
|
7
|
-
* - INCREMENTAL: Only rebuilds changed pages while preserving the rest
|
|
8
|
-
*/
|
|
9
|
-
export declare function gatsbyRenderDomain(domain: string): Promise<void>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { Artifacts, PlaceholderPath } from "../../../types/global";
|
|
2
|
-
import type { RenderMode } from "../../../types/render";
|
|
3
|
-
interface RenderContextProps<T> {
|
|
4
|
-
domain: string;
|
|
5
|
-
renderMode: RenderMode;
|
|
6
|
-
paths: Record<string, string>;
|
|
7
|
-
ssg: T;
|
|
8
|
-
renderMetadata: {
|
|
9
|
-
proDomain: string;
|
|
10
|
-
griddoVersion: string;
|
|
11
|
-
buildReportFileName: string;
|
|
12
|
-
};
|
|
13
|
-
cxArtifacts: Artifacts;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Encapsulates the state, configuration, and artifacts for a single SSG
|
|
17
|
-
* render process.
|
|
18
|
-
*
|
|
19
|
-
* This class is instantiated at the beginning of a render and passed through
|
|
20
|
-
* each lifecycle step, providing a centralized and consistent context for all
|
|
21
|
-
* operations. It is agnostic to the specific SSG being used.
|
|
22
|
-
*/
|
|
23
|
-
export declare class RenderContext<T = unknown> {
|
|
24
|
-
readonly domain: string;
|
|
25
|
-
readonly renderMode: RenderMode;
|
|
26
|
-
readonly paths: Record<PlaceholderPath, string>;
|
|
27
|
-
pagesToCreate: number[];
|
|
28
|
-
pagesToDelete: number[];
|
|
29
|
-
ssg: T;
|
|
30
|
-
renderMetadata: {
|
|
31
|
-
proDomain: string;
|
|
32
|
-
griddoVersion: string;
|
|
33
|
-
buildReportFileName: string;
|
|
34
|
-
};
|
|
35
|
-
cxArtifacts: Artifacts;
|
|
36
|
-
constructor({ domain, renderMode, ssg, paths, renderMetadata, cxArtifacts, }: RenderContextProps<T>);
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Update the Griddo's `/dist` dir with the contents from `public` dir only
|
|
3
|
-
* with files of type: js, json and css.
|
|
4
|
-
* TODO: Explicar que el static se copia a assets porque el js va en el subdominio de assets.
|
|
5
|
-
*/
|
|
6
|
-
declare function extractAssetsFromDist(domain: string): Promise<void>;
|
|
7
|
-
export { extractAssetsFromDist };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Spawn a new node process `yarn gatsby-build`
|
|
3
|
-
* @note This proccess (`yarn gatsby-build`) can not access to the custom Griddo
|
|
4
|
-
* `process.env` so it needs variables passed to it via the `env` prop.
|
|
5
|
-
*/
|
|
6
|
-
declare function gatsbyBuild(assetPrefixWithDomain: string): Promise<void>;
|
|
7
|
-
export { gatsbyBuild };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
type SyncRenderConfig = {
|
|
2
|
-
src: string;
|
|
3
|
-
dst: string;
|
|
4
|
-
pagesToCreate: Array<number>;
|
|
5
|
-
pagesToDelete: Array<number>;
|
|
6
|
-
artifactsToCopyToExports: Array<string>;
|
|
7
|
-
};
|
|
8
|
-
declare class SyncRender {
|
|
9
|
-
private bundleDir;
|
|
10
|
-
private currentRenderDir;
|
|
11
|
-
private pagesToCreate;
|
|
12
|
-
private pagesToDelete;
|
|
13
|
-
private assetArtifacts;
|
|
14
|
-
private state;
|
|
15
|
-
constructor(config: SyncRenderConfig);
|
|
16
|
-
setPagesToDelete(): void;
|
|
17
|
-
setPagesToAdd(): void;
|
|
18
|
-
/**
|
|
19
|
-
* Realiza la sincronización de los archivos HTML y JSON entre el directorio
|
|
20
|
-
* actual de renderizado y el directorio de exportación.
|
|
21
|
-
*/
|
|
22
|
-
sync(): void;
|
|
23
|
-
/**
|
|
24
|
-
* Busca archivos por extensión de forma recursiva en un directorio.
|
|
25
|
-
* @param dir Directorio base.
|
|
26
|
-
* @param extension Extensión a buscar (ej: ".ts", ".js").
|
|
27
|
-
* @returns Lista de rutas absolutas de archivos encontrados.
|
|
28
|
-
*/
|
|
29
|
-
private findFilesByExtension;
|
|
30
|
-
private findAllPageDataJsons;
|
|
31
|
-
private getPageComposePaths;
|
|
32
|
-
private copyAppDataJsonFile;
|
|
33
|
-
private copyDirs;
|
|
34
|
-
private copySitemaps;
|
|
35
|
-
}
|
|
36
|
-
export { SyncRender };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
interface SSG {
|
|
2
|
-
assetPrefix: string;
|
|
3
|
-
ssgArtifacts: {
|
|
4
|
-
disposables: string[];
|
|
5
|
-
cacheables: string[];
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
interface GatsbyPageData {
|
|
9
|
-
path: string;
|
|
10
|
-
result: {
|
|
11
|
-
pageContext: {
|
|
12
|
-
id: number;
|
|
13
|
-
title: string;
|
|
14
|
-
path: string;
|
|
15
|
-
openGraph: any;
|
|
16
|
-
pageMetadata: any;
|
|
17
|
-
page: {
|
|
18
|
-
site: number;
|
|
19
|
-
id: number;
|
|
20
|
-
fullPath: {
|
|
21
|
-
compose: string;
|
|
22
|
-
};
|
|
23
|
-
language: number;
|
|
24
|
-
title: string;
|
|
25
|
-
fullUrl: string;
|
|
26
|
-
templateId: string;
|
|
27
|
-
template: {
|
|
28
|
-
templateType: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export type { GatsbyPageData, SSG };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare const AI_EMBEDDINGS: string;
|
|
2
|
-
declare const ALERT: string;
|
|
3
|
-
declare const DOMAINS: string;
|
|
4
|
-
declare const GET_ALL: string;
|
|
5
|
-
declare const GET_PAGE: string;
|
|
6
|
-
declare const LOGIN: string;
|
|
7
|
-
declare const RESET_RENDER: string;
|
|
8
|
-
declare const ROBOTS: string;
|
|
9
|
-
declare const SEARCH: string;
|
|
10
|
-
declare const SETTINGS: string;
|
|
11
|
-
declare const BUILD_END: string[];
|
|
12
|
-
declare const BUILD_START: string[];
|
|
13
|
-
declare const GET_PAGES: string[];
|
|
14
|
-
declare const GET_REFERENCE_FIELD_DATA: string[];
|
|
15
|
-
declare const GET_SITEMAP: string[];
|
|
16
|
-
declare const INFO: string[];
|
|
17
|
-
declare const LANGUAGES: string[];
|
|
18
|
-
declare const SOCIALS: string[];
|
|
19
|
-
export { AI_EMBEDDINGS, ALERT, BUILD_END, BUILD_START, DOMAINS, GET_ALL, GET_PAGE, GET_PAGES, GET_REFERENCE_FIELD_DATA, GET_SITEMAP, INFO, LANGUAGES, LOGIN, RESET_RENDER, ROBOTS, SEARCH, SETTINGS, SOCIALS, };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
declare const GRIDDO_API_URL: string | undefined;
|
|
2
|
-
declare const GRIDDO_PUBLIC_API_URL: string | undefined;
|
|
3
|
-
declare const GRIDDO_BOT_USER: string | undefined;
|
|
4
|
-
declare const GRIDDO_BOT_PASSWORD: string | undefined;
|
|
5
|
-
declare const GRIDDO_API_CONCURRENCY_COUNT: number;
|
|
6
|
-
declare const GRIDDO_RENDER_ALL_SITES: boolean;
|
|
7
|
-
declare const GRIDDO_RENDER_SITE: number;
|
|
8
|
-
declare const GRIDDO_RENDER_PAGES: number[];
|
|
9
|
-
declare const GRIDDO_SKIP_BUILD_CHECKS: boolean;
|
|
10
|
-
declare const GRIDDO_DEBUG_LOGS: boolean;
|
|
11
|
-
declare const GRIDDO_BUILD_LOGS: boolean;
|
|
12
|
-
declare const GRIDDO_RENDER_BREAKPOINTS_FEATURE: boolean;
|
|
13
|
-
declare const GRIDDO_SSG_VERBOSE_LOGS: boolean;
|
|
14
|
-
declare const GRIDDO_SEARCH_FEATURE: boolean;
|
|
15
|
-
declare const GRIDDO_ASSET_PREFIX: string | undefined;
|
|
16
|
-
declare const GRIDDO_REACT_APP_INSTANCE: string | undefined;
|
|
17
|
-
declare const GRIDDO_AI_EMBEDDINGS: boolean;
|
|
18
|
-
declare const GRIDDO_VERBOSE_LOGS: boolean;
|
|
19
|
-
declare const GRIDDO_INIT_LIFECYCLE_MAX_ATTEMPTS: number;
|
|
20
|
-
declare const GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS: number;
|
|
21
|
-
declare const GRIDDO_CLOSE_LIFECYCLE_MAX_ATTEMPTS: number;
|
|
22
|
-
declare const GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS: number;
|
|
23
|
-
declare const GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS: number;
|
|
24
|
-
declare const GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS: number;
|
|
25
|
-
declare const GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS: number;
|
|
26
|
-
declare const GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS: number;
|
|
27
|
-
declare const GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS: number;
|
|
28
|
-
declare const GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS: number;
|
|
29
|
-
declare const GRIDDO_FIXTURES_DOMAIN_NAMES: string | undefined;
|
|
30
|
-
declare const GRIDDO_FIXTURES_SITE_NAMES: string | undefined;
|
|
31
|
-
export { GRIDDO_AI_EMBEDDINGS, GRIDDO_API_CONCURRENCY_COUNT, GRIDDO_API_URL, GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS, GRIDDO_ASSET_PREFIX, GRIDDO_BOT_PASSWORD, GRIDDO_BOT_USER, GRIDDO_BUILD_LOGS, GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS, GRIDDO_CLOSE_LIFECYCLE_MAX_ATTEMPTS, GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS, GRIDDO_DEBUG_LOGS, GRIDDO_FIXTURES_DOMAIN_NAMES, GRIDDO_FIXTURES_SITE_NAMES, GRIDDO_INIT_LIFECYCLE_MAX_ATTEMPTS, GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS, GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS, GRIDDO_PUBLIC_API_URL, GRIDDO_REACT_APP_INSTANCE, GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS, GRIDDO_RENDER_ALL_SITES, GRIDDO_RENDER_BREAKPOINTS_FEATURE, GRIDDO_RENDER_PAGES, GRIDDO_RENDER_SITE, GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS, GRIDDO_SEARCH_FEATURE, GRIDDO_SKIP_BUILD_CHECKS, GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS, GRIDDO_SSG_VERBOSE_LOGS, GRIDDO_VERBOSE_LOGS, };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Do you want to add a new error to the list?
|
|
3
|
-
*
|
|
4
|
-
* 1 - Add the new error type name to the `ErrorsType` union type.
|
|
5
|
-
* 2 - Export a new ErrorData object (or a function that returns one) in this
|
|
6
|
-
* file by completing the `error` (ErrosType) and `message` (string) properties
|
|
7
|
-
* obligatorily.
|
|
8
|
-
*/
|
|
9
|
-
import type { SpawnSyncReturns } from "node:child_process";
|
|
10
|
-
import type { ErrorData } from "../utils/errors";
|
|
11
|
-
type ErrorsType = "UploadSearchError" | "ArtifactError" | "ErrorInSSGBuildProcess" | "LifecycleExecutionError" | "LoginError" | "NoDomainsFoundError" | "NoJSConfigFileFound" | "ReadFromStoreError" | "ReferenceFieldSourcesNotFoundError" | "RenderUUIDError" | "WriteToStoreError" | "CheckHealthError";
|
|
12
|
-
declare const ArtifactError: ErrorData;
|
|
13
|
-
declare const ErrorInSSGBuildProcess: (command: SpawnSyncReturns<string>) => ErrorData;
|
|
14
|
-
declare const LifecycleExecutionError: (attempts: number, name: string) => ErrorData;
|
|
15
|
-
declare const LoginError: ErrorData;
|
|
16
|
-
declare const NoDomainsFoundError: ErrorData;
|
|
17
|
-
declare const NoJSConfigFileFound: ErrorData;
|
|
18
|
-
declare const ReadFromStoreError: ErrorData;
|
|
19
|
-
declare const ReferenceFieldSourcesNotFoundError: ErrorData;
|
|
20
|
-
declare const RenderUUIDError: ErrorData;
|
|
21
|
-
declare const WriteToStoreError: ErrorData;
|
|
22
|
-
declare const UploadSearchError: ErrorData;
|
|
23
|
-
declare const CheckHealthError: ErrorData;
|
|
24
|
-
export { ArtifactError, ErrorInSSGBuildProcess, LifecycleExecutionError, LoginError, NoDomainsFoundError, NoJSConfigFileFound, ReadFromStoreError, ReferenceFieldSourcesNotFoundError, RenderUUIDError, UploadSearchError, WriteToStoreError, CheckHealthError, type ErrorsType, };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AuthHeaders } from "../types/api";
|
|
2
|
-
/**
|
|
3
|
-
* Service for authentication in the Griddo Private API
|
|
4
|
-
*/
|
|
5
|
-
declare class AuthService {
|
|
6
|
-
headers: AuthHeaders | undefined;
|
|
7
|
-
login(): Promise<AuthHeaders>;
|
|
8
|
-
}
|
|
9
|
-
declare const authService: AuthService;
|
|
10
|
-
export { authService as AuthService };
|