@griddo/cx 1.75.225 → 1.75.227
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/build-complete.js +42 -0
- package/build/index.js +23 -23
- package/build/reset-render.js +16 -16
- package/package.json +10 -6
- package/scripts/build-complete.ts +87 -0
- package/scripts/griddo-exporter.ts +10 -1
- package/src/utils/cache.ts +6 -1
- package/src/utils/sites.ts +0 -13
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": "1.75.
|
|
4
|
+
"version": "1.75.227",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -20,13 +20,17 @@
|
|
|
20
20
|
"griddo-cx": "./index.js"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"build": "yarn run build:exporter && yarn run build:reset-render",
|
|
24
|
-
"build:reset-render": "esbuild ./scripts/reset-render.ts --bundle --platform=node --minify --outfile=./build/reset-render.js",
|
|
23
|
+
"build": "yarn run build:exporter && yarn run build:reset-render && yarn run build:build-complete",
|
|
25
24
|
"build:exporter": "esbuild ./scripts/griddo-exporter.ts --bundle --platform=node --minify --outfile=./build/index.js",
|
|
26
|
-
"
|
|
25
|
+
"build:build-complete": "esbuild ./scripts/build-complete.ts --bundle --platform=node --minify --outfile=./build/build-complete.js",
|
|
26
|
+
"build:reset-render": "esbuild ./scripts/reset-render.ts --bundle --platform=node --minify --outfile=./build/reset-render.js",
|
|
27
27
|
"clean": "gatsby clean; rm -rf .cache public assets dist build store",
|
|
28
|
+
"export": "gatsby telemetry --disable && gatsby build --prefix-paths",
|
|
29
|
+
"export:complete": "node ./build/build-complete.js",
|
|
30
|
+
"export:reset": "node ./build/reset-render.js",
|
|
28
31
|
"prepare": "yarn run build",
|
|
29
32
|
"watch:tscheck": "tsc --noEmit --watch",
|
|
33
|
+
"complete-render": "node ./build/build-complete.js",
|
|
30
34
|
"reset-render": "node ./build/reset-render.js"
|
|
31
35
|
},
|
|
32
36
|
"dependencies": {
|
|
@@ -64,7 +68,7 @@
|
|
|
64
68
|
"react-helmet": "^6.0.0"
|
|
65
69
|
},
|
|
66
70
|
"devDependencies": {
|
|
67
|
-
"@griddo/eslint-config-back": "^1.75.
|
|
71
|
+
"@griddo/eslint-config-back": "^1.75.227",
|
|
68
72
|
"@types/babel__core": "^7.20.0",
|
|
69
73
|
"@types/babel__preset-env": "^7.9.2",
|
|
70
74
|
"@types/csvtojson": "^2.0.0",
|
|
@@ -112,5 +116,5 @@
|
|
|
112
116
|
"publishConfig": {
|
|
113
117
|
"access": "public"
|
|
114
118
|
},
|
|
115
|
-
"gitHead": "
|
|
119
|
+
"gitHead": "fd5fee42aaf938991fd8d51f24eecbe740c65cc4"
|
|
116
120
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import pkgDir from "pkg-dir";
|
|
5
|
+
|
|
6
|
+
import { AuthService } from "../src/services/auth";
|
|
7
|
+
import { SitesService } from "../src/services/sites";
|
|
8
|
+
import { logInfo } from "../src/utils/shared";
|
|
9
|
+
|
|
10
|
+
// Where we are going to find export folders
|
|
11
|
+
const execBasePath = pkgDir.sync()!;
|
|
12
|
+
|
|
13
|
+
// Where we are going to find archived exports
|
|
14
|
+
const exportArchiveBasePath = path.resolve(execBasePath, "exports/sites");
|
|
15
|
+
|
|
16
|
+
type Report = {
|
|
17
|
+
authControl:
|
|
18
|
+
| {
|
|
19
|
+
Authorization: string;
|
|
20
|
+
"Cache-Control": string;
|
|
21
|
+
lang?: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
| undefined;
|
|
24
|
+
sites: {
|
|
25
|
+
siteId: number;
|
|
26
|
+
publishHashes: string[];
|
|
27
|
+
siteHash: string | null;
|
|
28
|
+
unpublishHashes: string[];
|
|
29
|
+
}[];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export async function buildComplete(report: Report) {
|
|
33
|
+
await AuthService.login();
|
|
34
|
+
|
|
35
|
+
const promises = report.sites.map((site) => {
|
|
36
|
+
const { siteId, ...body } = site;
|
|
37
|
+
|
|
38
|
+
logInfo(`Deploying ending call to site ${siteId}:`);
|
|
39
|
+
|
|
40
|
+
return SitesService.endSiteRender(siteId, body);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
await Promise.all(promises);
|
|
44
|
+
|
|
45
|
+
logInfo(`Build end signal sent for ${report.sites.length} site(s)`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getExportedDomains() {
|
|
49
|
+
const domains = fs.readdirSync(exportArchiveBasePath);
|
|
50
|
+
|
|
51
|
+
return domains;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getBuildReports(domains: string[]) {
|
|
55
|
+
const reports = [];
|
|
56
|
+
|
|
57
|
+
for (const domain of domains) {
|
|
58
|
+
const buildReportFile = path.resolve(
|
|
59
|
+
exportArchiveBasePath,
|
|
60
|
+
domain,
|
|
61
|
+
"dist",
|
|
62
|
+
"__build-report__.json"
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
if (!fs.existsSync(buildReportFile)) {
|
|
66
|
+
console.log(`Build report "${buildReportFile}" not found.`);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const buildReport = JSON.parse(fs.readFileSync(buildReportFile, "utf-8"));
|
|
71
|
+
|
|
72
|
+
reports.push(buildReport);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return reports;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function main() {
|
|
79
|
+
const domains = getExportedDomains();
|
|
80
|
+
const reports = getBuildReports(domains);
|
|
81
|
+
|
|
82
|
+
for (const report of reports) {
|
|
83
|
+
await buildComplete(report);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
main();
|
|
@@ -21,6 +21,9 @@ dotenv.config();
|
|
|
21
21
|
const artifactsArchivable = ["dist", "assets", "apiCache"];
|
|
22
22
|
const artifactsDisposable = ["public", ".store"];
|
|
23
23
|
|
|
24
|
+
// TODO: Remove GRIDDO_INFRA_BUILD_COMPLETES behaviour when all instances are over 1.75.227 and infra calls export:complete
|
|
25
|
+
const INFRA_COMPLETES_BUILD = !!process.env.GRIDDO_INFRA_BUILD_COMPLETES;
|
|
26
|
+
|
|
24
27
|
// TODO: Remove STRIP_DOMAIN_FROM_PATH behaviour when all instances are over 1.75.219
|
|
25
28
|
const STRIP_DOMAIN_FROM_PATH =
|
|
26
29
|
!!process.env.GRIDDO_EXPORT_STRIP_DOMAIN_FROM_PATH;
|
|
@@ -107,6 +110,12 @@ const launchExports = async () => {
|
|
|
107
110
|
logInfo(`️🚢 Exporting domain ${chalk.underline(domain)}`);
|
|
108
111
|
await domainExport(domain);
|
|
109
112
|
}
|
|
113
|
+
|
|
114
|
+
// TODO: Remove when all instances are over 1.75.227 and infra calls export:complete
|
|
115
|
+
if (!INFRA_COMPLETES_BUILD) {
|
|
116
|
+
const runner = getEnvRunner({ cwd: __dirname });
|
|
117
|
+
runner("yarn export:complete");
|
|
118
|
+
}
|
|
110
119
|
};
|
|
111
120
|
|
|
112
121
|
const getDomainRunner = (domain: string) => {
|
|
@@ -203,7 +212,7 @@ const getDomainRunner = (domain: string) => {
|
|
|
203
212
|
} catch (error) {
|
|
204
213
|
logError(
|
|
205
214
|
`🚚 Error moving files to ${currentExportArchivePath}`,
|
|
206
|
-
error.message
|
|
215
|
+
(error as Error).message
|
|
207
216
|
);
|
|
208
217
|
restoreArtifactBackup(artifact);
|
|
209
218
|
continue;
|
package/src/utils/cache.ts
CHANGED
|
@@ -56,7 +56,12 @@ function createSha256(data: string) {
|
|
|
56
56
|
function saveCache<T>(petition: Petition, content: T) {
|
|
57
57
|
const stringContent =
|
|
58
58
|
typeof content === "string" ? content : JSON.stringify(content);
|
|
59
|
-
|
|
59
|
+
const filename = generateFilenameWithHash(petition);
|
|
60
|
+
const filepath = path.dirname(filename);
|
|
61
|
+
if (!fs.existsSync(filepath)) {
|
|
62
|
+
fs.mkdirSync(filepath, { recursive: true });
|
|
63
|
+
}
|
|
64
|
+
fs.writeFileSync(filename, stringContent, "utf8");
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
/**
|
package/src/utils/sites.ts
CHANGED
|
@@ -185,19 +185,6 @@ async function generateBuildReport(
|
|
|
185
185
|
fs.writeFileSync(filePathName, JSON.stringify(report));
|
|
186
186
|
|
|
187
187
|
logInfo(`Build report saved for ${buildSitesInfo.length} site(s)`);
|
|
188
|
-
|
|
189
|
-
// Tell API the build has finished
|
|
190
|
-
// TODO: Remove when the file version is implemented.
|
|
191
|
-
const promises = Object.keys(buildProcessData).map(async (siteID) => {
|
|
192
|
-
const body = buildProcessData[siteID];
|
|
193
|
-
logInfo(`Deploying ending call to site ${siteID}:`);
|
|
194
|
-
|
|
195
|
-
return SitesService.endSiteRender(parseInt(siteID), body);
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
await Promise.all(promises);
|
|
199
|
-
|
|
200
|
-
logInfo(`Build end signal sent for ${buildSitesInfo.length} site(s)`);
|
|
201
188
|
}
|
|
202
189
|
|
|
203
190
|
/**
|