@griddo/cx 10.4.5 → 10.4.7
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 +7 -0
- package/build/build-complete.js +13 -13
- package/build/create-build-data.js +16 -16
- package/build/index.js +30 -30
- package/build/reset-render.js +16 -16
- package/exporter/adapters/gatsby/index.ts +14 -4
- package/exporter/adapters/gatsby/utils.ts +16 -17
- package/exporter/utils/folders.ts +17 -0
- package/exporter/utils/pages.ts +13 -6
- package/exporter/utils/runners.ts +2 -3
- package/exporter/utils/shared.ts +1 -2
- package/exporter/utils/store.ts +1 -0
- package/package.json +2 -12
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getGatsbyDomainRunner } from "./utils";
|
|
1
|
+
import { attempts, getGatsbyDomainRunner } from "./utils";
|
|
2
2
|
import { getInstanceDomains } from "../../utils/domains";
|
|
3
3
|
import { createBuildData } from "../../utils/download-build-data";
|
|
4
|
-
import { clearEmptyDirs } from "../../utils/folders";
|
|
4
|
+
import { clearEmptyDirs, removeMultiPagesFromStore } from "../../utils/folders";
|
|
5
5
|
import { uploadSearchContentToAPI } from "../../utils/searches";
|
|
6
6
|
import { doLifeCycle, pause, printExporterLogo } from "../../utils/shared";
|
|
7
7
|
|
|
@@ -20,6 +20,7 @@ async function runGatsbyAdapter() {
|
|
|
20
20
|
*/
|
|
21
21
|
await doLifeCycle({
|
|
22
22
|
name: "Restore",
|
|
23
|
+
attempts: attempts.restore,
|
|
23
24
|
steps: [
|
|
24
25
|
runner.init,
|
|
25
26
|
() => pause("init done!"),
|
|
@@ -38,9 +39,10 @@ async function runGatsbyAdapter() {
|
|
|
38
39
|
*/
|
|
39
40
|
await doLifeCycle({
|
|
40
41
|
name: "Data",
|
|
42
|
+
attempts: attempts.data,
|
|
41
43
|
steps: [
|
|
42
|
-
|
|
43
|
-
() => pause("Download data from API to `store`
|
|
44
|
+
() => createBuildData(domain),
|
|
45
|
+
() => pause("Download data from API to `store` done!"),
|
|
44
46
|
],
|
|
45
47
|
});
|
|
46
48
|
|
|
@@ -53,6 +55,7 @@ async function runGatsbyAdapter() {
|
|
|
53
55
|
*/
|
|
54
56
|
await doLifeCycle({
|
|
55
57
|
name: "SSG",
|
|
58
|
+
attempts: attempts.ssg,
|
|
56
59
|
steps: [runner.runGatsbyBuild, () => pause("Gatsby build done!")],
|
|
57
60
|
});
|
|
58
61
|
|
|
@@ -67,6 +70,7 @@ async function runGatsbyAdapter() {
|
|
|
67
70
|
);
|
|
68
71
|
await doLifeCycle({
|
|
69
72
|
name: "Meta",
|
|
73
|
+
attempts: attempts.meta,
|
|
70
74
|
steps: [
|
|
71
75
|
() => (shouldUploadSearchData ? uploadSearchContentToAPI() : undefined),
|
|
72
76
|
],
|
|
@@ -80,7 +84,13 @@ async function runGatsbyAdapter() {
|
|
|
80
84
|
*/
|
|
81
85
|
await doLifeCycle({
|
|
82
86
|
name: "Archive",
|
|
87
|
+
attempts: attempts.archive,
|
|
83
88
|
steps: [
|
|
89
|
+
// Elimina las páginas MultiPage del `store`. De este modo nos
|
|
90
|
+
// aseguramos que se vuelven a crear por Gatsby siempre
|
|
91
|
+
// actualizadas.
|
|
92
|
+
removeMultiPagesFromStore,
|
|
93
|
+
() => pause("MultiPages removed from `store`"),
|
|
84
94
|
() => clearEmptyDirs(),
|
|
85
95
|
() => pause("Clean empty dirs done!"),
|
|
86
96
|
runner.removeDisposableArtifacts,
|
|
@@ -11,6 +11,20 @@ import { checkSites } from "../../utils/sites";
|
|
|
11
11
|
|
|
12
12
|
dotenv.config();
|
|
13
13
|
|
|
14
|
+
const attempts = {
|
|
15
|
+
prepare: JSON.parse(process.env.GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
16
|
+
restore: JSON.parse(process.env.GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
17
|
+
data: JSON.parse(process.env.GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
18
|
+
ssg: JSON.parse(process.env.GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
19
|
+
relocation: JSON.parse(
|
|
20
|
+
process.env.GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS || "1"
|
|
21
|
+
),
|
|
22
|
+
meta: JSON.parse(process.env.GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
23
|
+
archive: JSON.parse(process.env.GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
24
|
+
clean: JSON.parse(process.env.GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
14
28
|
/**
|
|
15
29
|
* Return a runner, a serie of functions to manage the Gatsby render artifacts.
|
|
16
30
|
*/
|
|
@@ -317,17 +331,6 @@ function getGatsbyDomainRunner(domain: string) {
|
|
|
317
331
|
}
|
|
318
332
|
};
|
|
319
333
|
|
|
320
|
-
// TODO: Esto no debería hacerse desde infra
|
|
321
|
-
// const movePublicToDist = () => {
|
|
322
|
-
// const { currentExportWorkingPath: publicPath } = getArtifactPaths("public");
|
|
323
|
-
// const { currentExportWorkingPath: distPath } = getArtifactPaths("dist");
|
|
324
|
-
|
|
325
|
-
// if (fs.existsSync(publicPath)) {
|
|
326
|
-
// console.log(`Moving ${publicPath} to ${distPath}`);
|
|
327
|
-
// run(`mv ${publicPath} ${distPath}`);
|
|
328
|
-
// }
|
|
329
|
-
// };
|
|
330
|
-
|
|
331
334
|
/**
|
|
332
335
|
* Delete disposable artifacts between renders.
|
|
333
336
|
*/
|
|
@@ -344,11 +347,6 @@ function getGatsbyDomainRunner(domain: string) {
|
|
|
344
347
|
}
|
|
345
348
|
};
|
|
346
349
|
|
|
347
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
348
|
-
const cleanAfterFail = () => {
|
|
349
|
-
cleanDirtyArtifactPaths();
|
|
350
|
-
};
|
|
351
|
-
|
|
352
350
|
return {
|
|
353
351
|
init,
|
|
354
352
|
getArtifactPaths,
|
|
@@ -379,4 +377,5 @@ function getGatsbyAssetPrefixSlug(domain: string) {
|
|
|
379
377
|
return `${assetPrefix}/${domain}`;
|
|
380
378
|
}
|
|
381
379
|
|
|
382
|
-
export { getGatsbyDomainRunner };
|
|
380
|
+
export { attempts, getGatsbyDomainRunner };
|
|
381
|
+
|
|
@@ -7,6 +7,7 @@ import path from "node:path";
|
|
|
7
7
|
import fs from "fs-extra";
|
|
8
8
|
|
|
9
9
|
import { CXRootDir, instanceRootDir, logInfo } from "./shared";
|
|
10
|
+
import { getPageInStoreDir, removePagesFromStore } from "./store";
|
|
10
11
|
// eslint-disable-next-line node/no-unpublished-import
|
|
11
12
|
import config from "../../cx.config";
|
|
12
13
|
|
|
@@ -318,10 +319,26 @@ function createBackup(src: string, suffix = "-BACKUP") {
|
|
|
318
319
|
}
|
|
319
320
|
}
|
|
320
321
|
|
|
322
|
+
function isMultiPageId(id: number) {
|
|
323
|
+
return Number.isInteger(id) && id < 0;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function removeMultiPagesFromStore() {
|
|
327
|
+
const dirs = config.dirs("");
|
|
328
|
+
const storePath = path.join(dirs.__cx, "store");
|
|
329
|
+
try {
|
|
330
|
+
const multiPageFiles = getPageInStoreDir(storePath).filter(isMultiPageId);
|
|
331
|
+
removePagesFromStore(storePath, multiPageFiles);
|
|
332
|
+
} catch (e) {
|
|
333
|
+
console.info("`store` folder does not exist. Skipping multipage clean up.");
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
321
337
|
export {
|
|
322
338
|
clearEmptyDirs,
|
|
323
339
|
copyArtifacts,
|
|
324
340
|
deleteSites,
|
|
325
341
|
moveArtifacts,
|
|
326
342
|
removeArtifacts,
|
|
343
|
+
removeMultiPagesFromStore,
|
|
327
344
|
};
|
package/exporter/utils/pages.ts
CHANGED
|
@@ -269,11 +269,7 @@ async function createGriddoListPages(
|
|
|
269
269
|
defaultLang,
|
|
270
270
|
};
|
|
271
271
|
|
|
272
|
-
return await createGriddoPageObject(
|
|
273
|
-
paginatedPage,
|
|
274
|
-
additionalInfo,
|
|
275
|
-
!isFirstPage
|
|
276
|
-
);
|
|
272
|
+
return await createGriddoPageObject(paginatedPage, additionalInfo);
|
|
277
273
|
});
|
|
278
274
|
|
|
279
275
|
return Promise.all(allPages);
|
|
@@ -302,7 +298,7 @@ function createGriddoMultiPages(
|
|
|
302
298
|
}
|
|
303
299
|
|
|
304
300
|
// Creates each page based on `multiPageElements` from the schema.
|
|
305
|
-
const allPages = multiPageElements.map(async (pageElement) => {
|
|
301
|
+
const allPages = multiPageElements.map(async (pageElement, idx) => {
|
|
306
302
|
// TODO: Use structuredClone() when node 18 is available.
|
|
307
303
|
const paginatedPage: APIPageObject = JSON.parse(JSON.stringify(cleanPage));
|
|
308
304
|
const {
|
|
@@ -334,6 +330,17 @@ function createGriddoMultiPages(
|
|
|
334
330
|
paginatedPage.metaDescription = metaDescription;
|
|
335
331
|
}
|
|
336
332
|
|
|
333
|
+
// Crea un id como número negativo y añadiendo un sufijo para las multipages.
|
|
334
|
+
// Esto es así para marcarlas y posteriormente borrarlas siempre en cada
|
|
335
|
+
// nuevo render desde el Adapter.
|
|
336
|
+
//
|
|
337
|
+
// id de página con hasMultipageTrue: 1546
|
|
338
|
+
// ids de las "sub-páginas": -15460, -15461, -1546n, (-)id(idx)
|
|
339
|
+
//
|
|
340
|
+
// @todo eliminar el concepto multipage de CX, debería ser algo core de
|
|
341
|
+
// Griddo itself: API/AX, que fuesen páginas con sus ids, etc..
|
|
342
|
+
paginatedPage.id = parseInt("-" + paginatedPage.id + idx);
|
|
343
|
+
|
|
337
344
|
paginatedPage.fullUrl = `${fullUrl}/${rightSectionSlug}`;
|
|
338
345
|
paginatedPage.fullPath.compose = newCompose;
|
|
339
346
|
paginatedPage.slug = newCompose;
|
|
@@ -41,12 +41,11 @@ function runner(command: string, env: Env) {
|
|
|
41
41
|
|
|
42
42
|
if (error) {
|
|
43
43
|
console.error(error);
|
|
44
|
-
|
|
44
|
+
throw new Error(error.toString());
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
if (status !== 0) {
|
|
48
|
-
|
|
49
|
-
process.exit(1);
|
|
48
|
+
throw new Error(`Command \`${command}\` exited with code ${status}`);
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
|
package/exporter/utils/shared.ts
CHANGED
|
@@ -327,8 +327,7 @@ async function doLifeCycle(args: {
|
|
|
327
327
|
}) {
|
|
328
328
|
const { steps, name, attempts } = args;
|
|
329
329
|
let trysCount = 0;
|
|
330
|
-
const maxTrysAccepted =
|
|
331
|
-
Number(process.env.GRIDDO_LIFECYCLE_MAX_RETRY_ATTEMPTS) || attempts || 1;
|
|
330
|
+
const maxTrysAccepted = attempts || 1;
|
|
332
331
|
|
|
333
332
|
while (trysCount < maxTrysAccepted) {
|
|
334
333
|
try {
|
package/exporter/utils/store.ts
CHANGED
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": "10.4.
|
|
4
|
+
"version": "10.4.7",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -47,22 +47,16 @@
|
|
|
47
47
|
"babel-plugin-styled-components": "^1.10.7",
|
|
48
48
|
"babel-plugin-transform-runtime": "^6.23.0",
|
|
49
49
|
"babel-polyfill": "^6.26.0",
|
|
50
|
-
"branch-name": "^1.0.0",
|
|
51
50
|
"chalk": "^2.4.2",
|
|
52
|
-
"csvtojson": "^2.0.10",
|
|
53
51
|
"dotenv": "^8.1.0",
|
|
54
52
|
"find-up": "^5.0.0",
|
|
55
53
|
"fs-extra": "^9.0.1",
|
|
56
54
|
"gatsby": "^4.8.0",
|
|
57
|
-
"gatsby-plugin-polyfill-io": "^1.1.0",
|
|
58
55
|
"gatsby-plugin-react-helmet": "^5.8.0",
|
|
59
|
-
"gatsby-plugin-sass": "^5.21.0",
|
|
60
|
-
"gatsby-plugin-styled-components": "^5.8.0",
|
|
61
56
|
"gatsby-plugin-svgr-loader": "^0.1.0",
|
|
62
57
|
"gradient-string": "^2.0.2",
|
|
63
58
|
"html-react-parser": "^1.4.10",
|
|
64
59
|
"js2xmlparser": "^4.0.1",
|
|
65
|
-
"opn": "^6.0.0",
|
|
66
60
|
"p-limit": "^3.0.0",
|
|
67
61
|
"path-browserify": "^1.0.1",
|
|
68
62
|
"pkg-dir": "^5.0.0",
|
|
@@ -70,10 +64,6 @@
|
|
|
70
64
|
"react-helmet": "^6.0.0"
|
|
71
65
|
},
|
|
72
66
|
"devDependencies": {
|
|
73
|
-
"@griddo/eslint-config-back": "^10.4.5",
|
|
74
|
-
"@types/babel__core": "^7.20.0",
|
|
75
|
-
"@types/babel__preset-env": "^7.9.2",
|
|
76
|
-
"@types/csvtojson": "^2.0.0",
|
|
77
67
|
"@types/eslint": "^7.29.0",
|
|
78
68
|
"@types/fs-extra": "^9.0.13",
|
|
79
69
|
"@types/gradient-string": "^1.1.2",
|
|
@@ -117,5 +107,5 @@
|
|
|
117
107
|
"publishConfig": {
|
|
118
108
|
"access": "public"
|
|
119
109
|
},
|
|
120
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "0280c78de79a2b1f534c9aaaf16e6bb72bd5b652"
|
|
121
111
|
}
|