@griddo/cx 11.0.22 → 11.0.23
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/build/adapters/gatsby/index.d.ts +4 -2
- package/build/artifacts/index.d.ts +4 -17
- package/build/end-render.js +21 -21
- package/build/end-render.js.map +2 -2
- package/build/index.js +36 -34
- package/build/index.js.map +4 -4
- package/build/react/GriddoIntegrations/utils.d.ts +1 -1
- package/build/reset-render.js +20 -20
- package/build/reset-render.js.map +2 -2
- package/build/run-start-render.js +40 -38
- package/build/run-start-render.js.map +4 -4
- package/build/start-render.js +40 -38
- package/build/start-render.js.map +4 -4
- package/build/upload-search-content.js +16 -16
- package/build/upload-search-content.js.map +2 -2
- package/build/utils/loggin.d.ts +4 -3
- package/build/utils/render.d.ts +5 -1
- package/build/utils/store.d.ts +7 -1
- package/cx.config.d.ts +1 -1
- package/exporter/adapters/gatsby/index.ts +110 -109
- package/exporter/adapters/gatsby/utils.ts +0 -3
- package/exporter/artifacts/index.ts +23 -31
- package/exporter/react/GriddoIntegrations/utils.ts +1 -2
- package/exporter/scripts/start-render.ts +9 -22
- package/exporter/services/store.ts +6 -0
- package/exporter/utils/loggin.ts +12 -5
- package/exporter/utils/render.ts +35 -3
- package/exporter/utils/store.ts +21 -0
- package/package.json +3 -3
- package/build/adapters/index.d.ts +0 -3
- package/build/artifacts/cx.d.ts +0 -6
- package/build/artifacts/gatsby.d.ts +0 -6
- package/exporter/adapters/index.ts +0 -4
- package/exporter/artifacts/cx.ts +0 -29
- package/exporter/artifacts/gatsby.ts +0 -28
package/build/utils/loggin.d.ts
CHANGED
|
@@ -43,8 +43,9 @@ declare function debugLog(...values: Array<unknown>): void;
|
|
|
43
43
|
*/
|
|
44
44
|
declare function pageSizeLog(size: number, measure?: string): string;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Console log the Griddo exporter version.
|
|
47
47
|
*/
|
|
48
|
-
declare function
|
|
48
|
+
declare function showExporterVersion(): void;
|
|
49
49
|
declare function listSitesLog(title: string, sites: Array<Site>): void;
|
|
50
|
-
|
|
50
|
+
declare function errorLabelLog(msg: string): void;
|
|
51
|
+
export { boxLog, buildLog, debugLog, errorLabelLog, infoLog, listSitesLog, pageSizeLog, showExporterVersion, successLog, verboseLog, };
|
package/build/utils/render.d.ts
CHANGED
|
@@ -8,4 +8,8 @@ declare function deleteSentinelRenderFile(): void;
|
|
|
8
8
|
declare function isValidRenderProcessOrThrow(): void;
|
|
9
9
|
declare function initRender(): void;
|
|
10
10
|
declare function finishRender(): undefined;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Send the default registers through Griddo alerts.
|
|
13
|
+
*/
|
|
14
|
+
declare function sendGriddoDefaultAlerts(): void;
|
|
15
|
+
export { createSentinelRenderFile, deleteSentinelRenderFile, finishRender, initRender, isValidRenderProcessOrThrow, sendGriddoDefaultAlerts, };
|
package/build/utils/store.d.ts
CHANGED
|
@@ -80,4 +80,10 @@ declare function getPagesToCreateOrDelete(sitePages: {
|
|
|
80
80
|
pagesToDeleteFromStore: number[];
|
|
81
81
|
pagesToWriteToStore: number[];
|
|
82
82
|
}>;
|
|
83
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Removes sites that exist in the store that should no longer be there because
|
|
85
|
+
* the domain has been changed. This is necessary because those sites will not
|
|
86
|
+
* be marked as `sitesToUnpublish` so they must be removed manually.
|
|
87
|
+
*/
|
|
88
|
+
declare function removeOrphanSites(sitesToPublish: Array<Site>, domain: string): void;
|
|
89
|
+
export { createStoreDir, getBuildMetadata, getBuildPagesFromCachedStore, getBuildPagesFromStore, getBuildPagesPath, getPageInStoreDir, getPagesToCreateOrDelete, removeOrphanSites, removePagesFromStore, savePagesInStore, saveRenderInfoInStore, };
|
package/cx.config.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Artifacts } from "../../types/global";
|
|
2
|
+
|
|
1
3
|
import path from "node:path";
|
|
2
4
|
|
|
3
5
|
import {
|
|
@@ -5,10 +7,7 @@ import {
|
|
|
5
7
|
getGatsbyAssetPrefixWithDomain,
|
|
6
8
|
runGatsbyBuildCommand,
|
|
7
9
|
} from "./utils";
|
|
8
|
-
import
|
|
9
|
-
import { envs } from "../../constants";
|
|
10
|
-
import { apiRegister } from "../../registers";
|
|
11
|
-
import { insertAlert } from "../../utils/alerts";
|
|
10
|
+
import getCxArtifacts from "../../artifacts";
|
|
12
11
|
import {
|
|
13
12
|
createRenderMetadata,
|
|
14
13
|
doLifeCycle,
|
|
@@ -25,7 +24,7 @@ import {
|
|
|
25
24
|
removeVirtualPagesFromStore,
|
|
26
25
|
renameArtifact,
|
|
27
26
|
} from "../../utils/folders";
|
|
28
|
-
import {
|
|
27
|
+
import { infoLog } from "../../utils/loggin";
|
|
29
28
|
import {
|
|
30
29
|
createSentinelRenderFile,
|
|
31
30
|
deleteSentinelRenderFile,
|
|
@@ -34,114 +33,116 @@ import {
|
|
|
34
33
|
|
|
35
34
|
const config = getConfig();
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Render every instance domain with the Gatsby adapter.
|
|
38
|
+
*/
|
|
39
|
+
export async function renderDomainsWithGatsbyAdapter() {
|
|
40
40
|
const domains = await getInstanceDomains();
|
|
41
41
|
|
|
42
42
|
for (const domain of domains) {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
infoLog(`Initializing render for the domain ${domain}`);
|
|
44
|
+
|
|
45
|
+
createSentinelRenderFile();
|
|
46
|
+
|
|
47
|
+
const {
|
|
48
|
+
//
|
|
49
|
+
__ssg,
|
|
50
|
+
__exports,
|
|
51
|
+
__cache,
|
|
52
|
+
__cx,
|
|
53
|
+
__components,
|
|
54
|
+
} = config.paths(domain);
|
|
55
|
+
|
|
56
|
+
// Griddo artifacts
|
|
57
|
+
const cxArtifacts = getCxArtifacts(domain);
|
|
58
|
+
|
|
59
|
+
// Gatsby artifacts
|
|
60
|
+
const gatsbyArtifacts: Artifacts = {
|
|
61
|
+
disposables: [
|
|
62
|
+
path.join(__ssg, "public"),
|
|
63
|
+
path.join(__ssg, "static"),
|
|
64
|
+
path.join(__ssg, ".cache"),
|
|
65
|
+
],
|
|
66
|
+
cacheables: [".cache"],
|
|
67
|
+
initials: [],
|
|
68
|
+
archivables: [],
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// These variables are involved in the build for create the dist directory
|
|
72
|
+
// from public and pass to the gatsby-build command via spawnSync.
|
|
73
|
+
const assetPrefix = getGatsbyAssetPrefixWithDomain(domain);
|
|
74
|
+
const needsAssetPrefix = !!assetPrefix && assetPrefix !== "";
|
|
75
|
+
|
|
76
|
+
// LifeCycles
|
|
77
|
+
|
|
78
|
+
await doLifeCycle("Clean", {
|
|
79
|
+
steps: [
|
|
80
|
+
() =>
|
|
81
|
+
removeArtifacts([
|
|
82
|
+
...cxArtifacts.disposables,
|
|
83
|
+
...gatsbyArtifacts.disposables,
|
|
84
|
+
]),
|
|
85
|
+
],
|
|
86
|
+
});
|
|
45
87
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (registerContent.entries.length < 1) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
debugLog("\nRender register report\n");
|
|
54
|
-
debugLog(registerContent);
|
|
55
|
-
debugLog();
|
|
56
|
-
|
|
57
|
-
insertAlert({
|
|
58
|
-
description: `API response size is too large (${envs.GRIDDO_API_MAX_RESPONSE_SIZE}KB).`,
|
|
59
|
-
area: "Griddo",
|
|
60
|
-
level: "W",
|
|
61
|
-
fullData: {
|
|
62
|
-
output: registerContent,
|
|
63
|
-
date: new Date().toISOString(),
|
|
64
|
-
},
|
|
88
|
+
await doLifeCycle("Prepare", {
|
|
89
|
+
steps: [() => createArtifacts(cxArtifacts.initials)],
|
|
65
90
|
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
91
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// LifeCycles
|
|
88
|
-
|
|
89
|
-
await doLifeCycle("Clean", {
|
|
90
|
-
steps: [() => removeArtifacts(ALL_ART.disposables)],
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
await doLifeCycle("Prepare", {
|
|
94
|
-
steps: [() => createArtifacts(ALL_ART.initials)],
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
await doLifeCycle("Restore", {
|
|
98
|
-
steps: [
|
|
99
|
-
() => copyArtifacts(__components, __ssg, ["static"]),
|
|
100
|
-
() => copyArtifacts(__exports, __cx, CX_ARTIFACTS.archivables),
|
|
101
|
-
() => renameArtifact(path.join(__cx, "dist"), path.join(__ssg, "public")),
|
|
102
|
-
() => moveArtifacts(__cache, __cx, CX_ARTIFACTS.cacheables),
|
|
103
|
-
() => moveArtifacts(__cache, __ssg, GATSBY_ARTIFACTS.cacheables),
|
|
104
|
-
],
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
await doLifeCycle("Data", {
|
|
108
|
-
steps: [() => createBuildData(domain)],
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
await doLifeCycle("SSG", {
|
|
112
|
-
steps: [() => runGatsbyBuildCommand(assetPrefix)],
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
await doLifeCycle("Relocation", {
|
|
116
|
-
steps: [() => createDistFromGatsbyPublic(domain, needsAssetPrefix)],
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
await doLifeCycle("Meta", {
|
|
120
|
-
steps: [() => createRenderMetadata(domain)],
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
await doLifeCycle("Archive", {
|
|
124
|
-
steps: [
|
|
125
|
-
() => removeVirtualPagesFromStore(),
|
|
126
|
-
() => clearEmptyDirs(path.join(__cx, "dist")),
|
|
127
|
-
() =>
|
|
128
|
-
moveArtifacts(__cx, __exports, CX_ARTIFACTS.archivables, {
|
|
129
|
-
withBackup: true,
|
|
130
|
-
}),
|
|
131
|
-
() => moveArtifacts(__cx, __cache, CX_ARTIFACTS.cacheables),
|
|
132
|
-
() => moveArtifacts(__ssg, __cache, GATSBY_ARTIFACTS.cacheables),
|
|
133
|
-
],
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
await doLifeCycle("Close", {
|
|
137
|
-
steps: [() => removeArtifacts(ALL_ART.disposables)],
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
await doLifeCycle("HealthCheck", {
|
|
141
|
-
steps: [() => isValidRenderProcessOrThrow()],
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
deleteSentinelRenderFile();
|
|
145
|
-
}
|
|
92
|
+
await doLifeCycle("Restore", {
|
|
93
|
+
steps: [
|
|
94
|
+
() => copyArtifacts(__components, __ssg, ["static"]),
|
|
95
|
+
() => copyArtifacts(__exports, __cx, cxArtifacts.archivables),
|
|
96
|
+
() =>
|
|
97
|
+
renameArtifact(path.join(__cx, "dist"), path.join(__ssg, "public")),
|
|
98
|
+
() => moveArtifacts(__cache, __cx, cxArtifacts.cacheables),
|
|
99
|
+
() => moveArtifacts(__cache, __ssg, gatsbyArtifacts.cacheables),
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
await doLifeCycle("Data", {
|
|
104
|
+
steps: [() => createBuildData(domain)],
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
await doLifeCycle("SSG", {
|
|
108
|
+
steps: [() => runGatsbyBuildCommand(assetPrefix)],
|
|
109
|
+
});
|
|
146
110
|
|
|
147
|
-
|
|
111
|
+
await doLifeCycle("Relocation", {
|
|
112
|
+
steps: [() => createDistFromGatsbyPublic(domain, needsAssetPrefix)],
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
await doLifeCycle("Meta", {
|
|
116
|
+
steps: [() => createRenderMetadata(domain)],
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
await doLifeCycle("Archive", {
|
|
120
|
+
steps: [
|
|
121
|
+
() => removeVirtualPagesFromStore(),
|
|
122
|
+
() => clearEmptyDirs(path.join(__cx, "dist")),
|
|
123
|
+
() =>
|
|
124
|
+
moveArtifacts(__cx, __exports, cxArtifacts.archivables, {
|
|
125
|
+
withBackup: true,
|
|
126
|
+
}),
|
|
127
|
+
() => moveArtifacts(__cx, __cache, cxArtifacts.cacheables),
|
|
128
|
+
() => moveArtifacts(__ssg, __cache, gatsbyArtifacts.cacheables),
|
|
129
|
+
],
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
await doLifeCycle("Close", {
|
|
133
|
+
steps: [
|
|
134
|
+
() =>
|
|
135
|
+
removeArtifacts([
|
|
136
|
+
...cxArtifacts.disposables,
|
|
137
|
+
...gatsbyArtifacts.disposables,
|
|
138
|
+
]),
|
|
139
|
+
],
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
await doLifeCycle("HealthCheck", {
|
|
143
|
+
steps: [() => isValidRenderProcessOrThrow()],
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
deleteSentinelRenderFile();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
-
import dotenv from "dotenv";
|
|
5
4
|
import fsx from "fs-extra";
|
|
6
5
|
|
|
7
6
|
import { envs } from "../../constants";
|
|
@@ -10,8 +9,6 @@ import { ErrorInSSGBuildProcess } from "../../errors/errors-data";
|
|
|
10
9
|
import { getConfig } from "../../utils/core-utils";
|
|
11
10
|
import { verboseLog } from "../../utils/loggin";
|
|
12
11
|
|
|
13
|
-
dotenv.config();
|
|
14
|
-
|
|
15
12
|
const config = getConfig();
|
|
16
13
|
|
|
17
14
|
/**
|
|
@@ -1,40 +1,32 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { PlaceholderPath } from "../types/global";
|
|
1
|
+
import type { Artifacts } from "../types/global";
|
|
3
2
|
|
|
4
|
-
import
|
|
5
|
-
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { getConfig } from "../utils/core-utils";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Returns the artifacts of
|
|
9
|
-
*
|
|
10
|
-
* @param adapter - The adapter for which to get the artifacts.
|
|
11
|
-
* @param options.cxPaths - The cx-paths.
|
|
8
|
+
* Returns the artifacts of CX.
|
|
12
9
|
*/
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
cxPaths: Record<PlaceholderPath, string>;
|
|
17
|
-
},
|
|
18
|
-
) {
|
|
19
|
-
const { cxPaths } = options;
|
|
20
|
-
const ssgArtifacts = {
|
|
21
|
-
gatsby: getGatsbyArtifacts(cxPaths),
|
|
22
|
-
};
|
|
10
|
+
function getCxArtifacts(domain: string): Artifacts {
|
|
11
|
+
const config = getConfig();
|
|
12
|
+
const { __cx, __exports, __cache } = config.paths(domain);
|
|
23
13
|
|
|
24
14
|
return {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
initials: [
|
|
16
|
+
__exports, // `/exports/<domain>`
|
|
17
|
+
__cache, // `__cx/.cx-cache/<domain>`
|
|
18
|
+
path.join(__cx, "store"),
|
|
19
|
+
path.join(__cx, "apiCache"),
|
|
20
|
+
],
|
|
21
|
+
disposables: [
|
|
22
|
+
path.join(__cx, "store"),
|
|
23
|
+
path.join(__cx, "apiCache"),
|
|
24
|
+
path.join(__cx, "render-metadata.json"),
|
|
25
|
+
path.join(__cx, "dist"),
|
|
26
|
+
],
|
|
27
|
+
cacheables: ["apiCache", "store"],
|
|
28
|
+
archivables: ["dist", "assets"],
|
|
37
29
|
};
|
|
38
30
|
}
|
|
39
31
|
|
|
40
|
-
export
|
|
32
|
+
export default getCxArtifacts;
|
|
@@ -1,37 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* eslint-disable node/shebang */
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import { runGatsbyAdapter } from "../adapters";
|
|
4
|
+
import { renderDomainsWithGatsbyAdapter } from "../adapters/gatsby";
|
|
7
5
|
import { RenderError } from "../errors";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { errorLabelLog, showExporterVersion } from "../utils/loggin";
|
|
7
|
+
import { sendGriddoDefaultAlerts } from "../utils/render";
|
|
10
8
|
|
|
11
9
|
async function startRender() {
|
|
12
10
|
try {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
process.exit(0);
|
|
11
|
+
showExporterVersion();
|
|
12
|
+
await renderDomainsWithGatsbyAdapter();
|
|
13
|
+
sendGriddoDefaultAlerts();
|
|
18
14
|
} catch (error) {
|
|
19
|
-
// Errors using the `throwError` function.
|
|
20
|
-
// In this case it does not log the stack error here because it is
|
|
21
|
-
// already logged in the `throwError` function.
|
|
22
15
|
if (error instanceof RenderError) {
|
|
23
|
-
|
|
24
|
-
console.log(kleur.black().bgRed(" GRIDDO InternalCXError "));
|
|
25
|
-
console.log();
|
|
16
|
+
errorLabelLog("GRIDDO_ERROR InternalCXError");
|
|
26
17
|
process.exit(1);
|
|
27
18
|
}
|
|
28
19
|
|
|
29
|
-
|
|
30
|
-
console.
|
|
31
|
-
console.log(kleur.black().bgRed(" GRIDDO UnknownError "));
|
|
32
|
-
console.log();
|
|
33
|
-
console.log(error);
|
|
34
|
-
console.log();
|
|
20
|
+
errorLabelLog("GRIDDO_ERROR UnknownError");
|
|
21
|
+
console.error(error);
|
|
35
22
|
process.exit(1);
|
|
36
23
|
}
|
|
37
24
|
}
|
|
@@ -31,6 +31,7 @@ import { checkSites, getSiteData, unpublishSites } from "../utils/sites";
|
|
|
31
31
|
import {
|
|
32
32
|
createStoreDir,
|
|
33
33
|
getPagesToCreateOrDelete,
|
|
34
|
+
removeOrphanSites,
|
|
34
35
|
removePagesFromStore,
|
|
35
36
|
savePagesInStore,
|
|
36
37
|
saveRenderInfoInStore,
|
|
@@ -78,6 +79,11 @@ async function createStore(domain: string) {
|
|
|
78
79
|
// store de los sites para despublicar.
|
|
79
80
|
await unpublishSites(sitesToUnpublish);
|
|
80
81
|
|
|
82
|
+
// Eliminamos posibles sites que estén en el store pero que no deberían
|
|
83
|
+
// porque han sido cambiados de dominio. Si han sido despublicados ya se
|
|
84
|
+
// despublican bien porque entran en `sitesToUnpublish`
|
|
85
|
+
removeOrphanSites(sitesToPublish, domain);
|
|
86
|
+
|
|
81
87
|
// Solo los sites to publish...
|
|
82
88
|
for (const site of sitesToPublish) {
|
|
83
89
|
const {
|
package/exporter/utils/loggin.ts
CHANGED
|
@@ -127,14 +127,16 @@ function pageSizeLog(size: number, measure = "KB") {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
|
-
*
|
|
130
|
+
* Console log the Griddo exporter version.
|
|
131
131
|
*/
|
|
132
|
-
function
|
|
132
|
+
function showExporterVersion() {
|
|
133
133
|
console.clear();
|
|
134
134
|
const config = getConfig();
|
|
135
|
-
const nodeVersion = process.version;
|
|
136
135
|
const { griddoVersion } = config;
|
|
137
|
-
const logo = `\n${kleur
|
|
136
|
+
const logo = `\n ${kleur
|
|
137
|
+
.bgYellow()
|
|
138
|
+
.black()
|
|
139
|
+
.bold(" Griddo Exporter " + griddoVersion + " ")}\n`;
|
|
138
140
|
|
|
139
141
|
console.log(logo);
|
|
140
142
|
}
|
|
@@ -156,14 +158,19 @@ ${title}
|
|
|
156
158
|
${sitesStr.join("\n") || "---"}`);
|
|
157
159
|
}
|
|
158
160
|
|
|
161
|
+
function errorLabelLog(msg: string) {
|
|
162
|
+
console.error("\n" + kleur.black().bgRed(" " + msg + " ") + "\n");
|
|
163
|
+
}
|
|
164
|
+
|
|
159
165
|
export {
|
|
160
166
|
boxLog,
|
|
161
167
|
buildLog,
|
|
162
168
|
debugLog,
|
|
169
|
+
errorLabelLog,
|
|
163
170
|
infoLog,
|
|
164
171
|
listSitesLog,
|
|
165
172
|
pageSizeLog,
|
|
166
|
-
|
|
173
|
+
showExporterVersion,
|
|
167
174
|
successLog,
|
|
168
175
|
verboseLog,
|
|
169
176
|
};
|
package/exporter/utils/render.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { envs } from "../constants";
|
|
5
5
|
import { throwError } from "../errors";
|
|
6
6
|
import { RenderUUIDError } from "../errors/errors-data";
|
|
7
|
+
import { apiRegister } from "../registers";
|
|
8
|
+
import { insertAlert } from "./alerts";
|
|
9
|
+
import { getConfig } from "./core-utils";
|
|
10
|
+
import { debugLog } from "./loggin";
|
|
7
11
|
|
|
8
12
|
const config = getConfig();
|
|
9
13
|
|
|
@@ -40,10 +44,38 @@ function finishRender() {
|
|
|
40
44
|
return undefined;
|
|
41
45
|
}
|
|
42
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Send the default registers through Griddo alerts.
|
|
49
|
+
*/
|
|
50
|
+
function sendGriddoDefaultAlerts() {
|
|
51
|
+
if (envs.GRIDDO_ALERT_FEATURE) {
|
|
52
|
+
const registerContent = apiRegister.get("API_RESPONSE_TOO_BIG");
|
|
53
|
+
|
|
54
|
+
if (registerContent.entries.length < 1) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
debugLog("\nRender register report\n");
|
|
59
|
+
debugLog(registerContent);
|
|
60
|
+
debugLog();
|
|
61
|
+
|
|
62
|
+
insertAlert({
|
|
63
|
+
description: `API response size is too large (${envs.GRIDDO_API_MAX_RESPONSE_SIZE}KB).`,
|
|
64
|
+
area: "Griddo",
|
|
65
|
+
level: "W",
|
|
66
|
+
fullData: {
|
|
67
|
+
output: registerContent,
|
|
68
|
+
date: new Date().toISOString(),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
43
74
|
export {
|
|
75
|
+
createSentinelRenderFile,
|
|
76
|
+
deleteSentinelRenderFile,
|
|
44
77
|
finishRender,
|
|
45
78
|
initRender,
|
|
46
79
|
isValidRenderProcessOrThrow,
|
|
47
|
-
|
|
48
|
-
deleteSentinelRenderFile,
|
|
80
|
+
sendGriddoDefaultAlerts,
|
|
49
81
|
};
|
package/exporter/utils/store.ts
CHANGED
|
@@ -10,6 +10,7 @@ import fsx from "fs-extra";
|
|
|
10
10
|
|
|
11
11
|
import { throwError } from "../errors";
|
|
12
12
|
import { getConfig, removeProperties, walk, walkStore } from "./core-utils";
|
|
13
|
+
import { verboseLog } from "./loggin";
|
|
13
14
|
import { ReadFromStoreError, WriteToStoreError } from "../errors/errors-data";
|
|
14
15
|
|
|
15
16
|
const config = getConfig();
|
|
@@ -302,6 +303,25 @@ async function getPagesToCreateOrDelete(sitePages: {
|
|
|
302
303
|
};
|
|
303
304
|
}
|
|
304
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Removes sites that exist in the store that should no longer be there because
|
|
308
|
+
* the domain has been changed. This is necessary because those sites will not
|
|
309
|
+
* be marked as `sitesToUnpublish` so they must be removed manually.
|
|
310
|
+
*/
|
|
311
|
+
function removeOrphanSites(sitesToPublish: Array<Site>, domain: string) {
|
|
312
|
+
const { __cx } = getConfig().paths(domain);
|
|
313
|
+
const currentSitesInStore = fs.readdirSync(path.join(__cx, "store"));
|
|
314
|
+
const sitesFromAPI = sitesToPublish.map(({ id }) => `${id}`);
|
|
315
|
+
const sitesToDelete = currentSitesInStore.filter(
|
|
316
|
+
(site) => !sitesFromAPI.includes(site),
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
for (const site of sitesToDelete) {
|
|
320
|
+
fs.rmSync(path.join(__cx, "store", site), { recursive: true, force: true });
|
|
321
|
+
verboseLog(`Removed orphan site id: ${site}`);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
305
325
|
export {
|
|
306
326
|
createStoreDir,
|
|
307
327
|
getBuildMetadata,
|
|
@@ -310,6 +330,7 @@ export {
|
|
|
310
330
|
getBuildPagesPath,
|
|
311
331
|
getPageInStoreDir,
|
|
312
332
|
getPagesToCreateOrDelete,
|
|
333
|
+
removeOrphanSites,
|
|
313
334
|
removePagesFromStore,
|
|
314
335
|
savePagesInStore,
|
|
315
336
|
saveRenderInfoInStore,
|
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.0.
|
|
4
|
+
"version": "11.0.23",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@babel/preset-env": "7.26.0",
|
|
61
61
|
"@babel/preset-react": "7.26.3",
|
|
62
62
|
"@babel/preset-typescript": "7.26.0",
|
|
63
|
-
"@griddo/core": "11.0.
|
|
63
|
+
"@griddo/core": "11.0.23",
|
|
64
64
|
"@svgr/webpack": "5.5.0",
|
|
65
65
|
"axios": "1.7.9",
|
|
66
66
|
"babel-loader": "9.2.1",
|
|
@@ -126,5 +126,5 @@
|
|
|
126
126
|
"publishConfig": {
|
|
127
127
|
"access": "public"
|
|
128
128
|
},
|
|
129
|
-
"gitHead": "
|
|
129
|
+
"gitHead": "eec9df5df565f610ec25cfb4b48bf737e9073990"
|
|
130
130
|
}
|
package/build/artifacts/cx.d.ts
DELETED
package/exporter/artifacts/cx.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Artifacts, PlaceholderPath } from "../types/global";
|
|
2
|
-
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns the artifacts of CX.
|
|
7
|
-
*/
|
|
8
|
-
function getCxArtifacts(paths: Record<PlaceholderPath, string>): Artifacts {
|
|
9
|
-
const { __cx, __exports, __cache } = paths;
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
initials: [
|
|
13
|
-
__exports, // `/exports/<domain>`
|
|
14
|
-
__cache, // `__cx/.cx-cache/<domain>`
|
|
15
|
-
path.join(__cx, "store"),
|
|
16
|
-
path.join(__cx, "apiCache"),
|
|
17
|
-
],
|
|
18
|
-
disposables: [
|
|
19
|
-
path.join(__cx, "store"),
|
|
20
|
-
path.join(__cx, "apiCache"),
|
|
21
|
-
path.join(__cx, "render-metadata.json"),
|
|
22
|
-
path.join(__cx, "dist"),
|
|
23
|
-
],
|
|
24
|
-
cacheables: ["apiCache", "store"],
|
|
25
|
-
archivables: ["dist", "assets"],
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default getCxArtifacts;
|