@griddo/cx 1.75.226 → 1.75.228
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 +15 -15
- package/build/index.js +14 -47
- package/package.json +7 -7
- package/scripts/build-complete.ts +1 -1
- package/scripts/griddo-exporter.ts +103 -15
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.228",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"build:exporter": "esbuild ./scripts/griddo-exporter.ts --bundle --platform=node --minify --outfile=./build/index.js",
|
|
25
25
|
"build:build-complete": "esbuild ./scripts/build-complete.ts --bundle --platform=node --minify --outfile=./build/build-complete.js",
|
|
26
26
|
"build:reset-render": "esbuild ./scripts/reset-render.ts --bundle --platform=node --minify --outfile=./build/reset-render.js",
|
|
27
|
-
"export": "gatsby telemetry --disable && gatsby build --prefix-paths",
|
|
28
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",
|
|
29
31
|
"prepare": "yarn run build",
|
|
30
32
|
"watch:tscheck": "tsc --noEmit --watch",
|
|
31
33
|
"complete-render": "node ./build/build-complete.js",
|
|
32
|
-
"reset-render": "node ./build/reset-render.js"
|
|
33
|
-
"build:complete": "node ./build/build-complete.js",
|
|
34
|
-
"build:reset": "node ./build/reset-render.js"
|
|
34
|
+
"reset-render": "node ./build/reset-render.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@babel/core": "^7.21.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"react-helmet": "^6.0.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@griddo/eslint-config-back": "^1.75.
|
|
71
|
+
"@griddo/eslint-config-back": "^1.75.228",
|
|
72
72
|
"@types/babel__core": "^7.20.0",
|
|
73
73
|
"@types/babel__preset-env": "^7.9.2",
|
|
74
74
|
"@types/csvtojson": "^2.0.0",
|
|
@@ -116,5 +116,5 @@
|
|
|
116
116
|
"publishConfig": {
|
|
117
117
|
"access": "public"
|
|
118
118
|
},
|
|
119
|
-
"gitHead": "
|
|
119
|
+
"gitHead": "c0187f02712eadfb4a2f7632180a4276c126ef91"
|
|
120
120
|
}
|
|
@@ -8,7 +8,7 @@ import { SitesService } from "../src/services/sites";
|
|
|
8
8
|
import { logInfo } from "../src/utils/shared";
|
|
9
9
|
|
|
10
10
|
// Where we are going to find export folders
|
|
11
|
-
const execBasePath = pkgDir.sync()!;
|
|
11
|
+
const execBasePath = pkgDir.sync(path.resolve(__dirname, "../.."))!;
|
|
12
12
|
|
|
13
13
|
// Where we are going to find archived exports
|
|
14
14
|
const exportArchiveBasePath = path.resolve(execBasePath, "exports/sites");
|
|
@@ -18,24 +18,32 @@ import { exporterLogo as splash, measureFunctions } from "../src/utils/shared";
|
|
|
18
18
|
dotenv.config();
|
|
19
19
|
|
|
20
20
|
// Envs
|
|
21
|
-
|
|
21
|
+
// Artifacts to preserve between CX installs
|
|
22
|
+
const artifactsArchivable = ["dist", "assets"];
|
|
23
|
+
// Artifacts to remove after export
|
|
22
24
|
const artifactsDisposable = ["public", ".store"];
|
|
25
|
+
// Artifacts to make exports faster
|
|
26
|
+
const artifactsCache = ["apiCache" /* , ".cache" */];
|
|
23
27
|
|
|
24
28
|
// TODO: Remove STRIP_DOMAIN_FROM_PATH behaviour when all instances are over 1.75.219
|
|
25
29
|
const STRIP_DOMAIN_FROM_PATH =
|
|
26
30
|
!!process.env.GRIDDO_EXPORT_STRIP_DOMAIN_FROM_PATH;
|
|
27
31
|
|
|
28
32
|
if (STRIP_DOMAIN_FROM_PATH) {
|
|
29
|
-
|
|
33
|
+
artifactsCache.push(".cache");
|
|
30
34
|
} else {
|
|
31
35
|
artifactsDisposable.push(".cache");
|
|
32
36
|
}
|
|
33
37
|
|
|
38
|
+
// TODO: Remove GRIDDO_INFRA_BUILD_COMPLETES behaviour when all instances are over 1.75.227 and infra calls export:complete
|
|
39
|
+
const INFRA_COMPLETES_BUILD = !!process.env.GRIDDO_INFRA_BUILD_COMPLETES;
|
|
40
|
+
|
|
34
41
|
// Where we are going to find export folders
|
|
35
42
|
const execBasePath = pkgDir.sync()!;
|
|
36
43
|
|
|
37
44
|
// Where we are going to find archived exports
|
|
38
45
|
const exportArchiveBasePath = path.resolve(execBasePath, "exports/sites");
|
|
46
|
+
const exportCachesArchivePath = path.resolve(__dirname, "../caches");
|
|
39
47
|
|
|
40
48
|
// Where we are going to run the export command
|
|
41
49
|
const workingPath = pkgDir.sync(__dirname)!;
|
|
@@ -86,26 +94,39 @@ const logWarning = (...message: Array<any>) => console.log(...message);
|
|
|
86
94
|
const domainExport = async (domain: string) => {
|
|
87
95
|
const runner = getDomainRunner(domain);
|
|
88
96
|
// onPreExporter
|
|
89
|
-
const endRestore = measureFunctions(
|
|
90
|
-
|
|
97
|
+
const endRestore = measureFunctions(
|
|
98
|
+
runner.init,
|
|
99
|
+
runner.restoreArtifacts,
|
|
100
|
+
runner.restoreCacheArtifacts
|
|
101
|
+
);
|
|
102
|
+
logInfo(`\n⌛️ Domain ${domain} restored: ${endRestore}s`);
|
|
91
103
|
|
|
92
104
|
// Gatsby
|
|
93
105
|
runner.runExporter();
|
|
94
106
|
|
|
95
107
|
// onPostExporter
|
|
96
|
-
const endArchive = measureFunctions(
|
|
108
|
+
const endArchive = measureFunctions(
|
|
109
|
+
runner.archiveArtifacts,
|
|
110
|
+
runner.archiveCacheArtifacts
|
|
111
|
+
);
|
|
97
112
|
logInfo(`\n⌛️ Domain ${domain} archived: ${endArchive}s`);
|
|
98
113
|
};
|
|
99
114
|
|
|
100
115
|
const launchExports = async () => {
|
|
101
116
|
splash();
|
|
102
|
-
initCache();
|
|
117
|
+
// initCache();
|
|
118
|
+
|
|
119
|
+
// const domains = await findDomains();
|
|
103
120
|
|
|
104
|
-
const
|
|
121
|
+
// for (const domain of domains) {
|
|
122
|
+
// logInfo(`️🚢 Exporting domain ${chalk.underline(domain)}`);
|
|
123
|
+
// await domainExport(domain);
|
|
124
|
+
// }
|
|
105
125
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
126
|
+
// TODO: Remove when all instances are over 1.75.227 and infra calls export:complete
|
|
127
|
+
if (!INFRA_COMPLETES_BUILD) {
|
|
128
|
+
const runner = getEnvRunner({ cwd: __dirname });
|
|
129
|
+
runner("pwd; ls; node ./build/build-complete.js");
|
|
109
130
|
}
|
|
110
131
|
};
|
|
111
132
|
|
|
@@ -127,6 +148,10 @@ const getDomainRunner = (domain: string) => {
|
|
|
127
148
|
};
|
|
128
149
|
|
|
129
150
|
const getArtifactPaths = (artifact = "") => {
|
|
151
|
+
if (artifact === "/")
|
|
152
|
+
throw new Error(`Artifact path cannot be root: ${artifact}`);
|
|
153
|
+
|
|
154
|
+
// Archives
|
|
130
155
|
const domainExportArchiveBasePath = path.resolve(
|
|
131
156
|
exportArchiveBasePath,
|
|
132
157
|
domain
|
|
@@ -139,6 +164,21 @@ const getDomainRunner = (domain: string) => {
|
|
|
139
164
|
currentExportArchivePath,
|
|
140
165
|
domain
|
|
141
166
|
);
|
|
167
|
+
|
|
168
|
+
// Cachés
|
|
169
|
+
const domainCacheArchiveBasePath = path.resolve(
|
|
170
|
+
exportCachesArchivePath,
|
|
171
|
+
domain
|
|
172
|
+
);
|
|
173
|
+
const currentExportArchiveCachePath = path.resolve(
|
|
174
|
+
domainCacheArchiveBasePath,
|
|
175
|
+
artifact
|
|
176
|
+
);
|
|
177
|
+
const currentExportArchiveCachePathInDomain = path.resolve(
|
|
178
|
+
currentExportArchiveCachePath,
|
|
179
|
+
domain
|
|
180
|
+
);
|
|
181
|
+
|
|
142
182
|
const currentExportBackupPath = `${currentExportArchivePath}-BACKUP`;
|
|
143
183
|
const currentExportWorkingPath = path.resolve(workingPath, artifact);
|
|
144
184
|
|
|
@@ -148,11 +188,18 @@ const getDomainRunner = (domain: string) => {
|
|
|
148
188
|
currentExportBackupPath,
|
|
149
189
|
currentExportWorkingPath,
|
|
150
190
|
currentExportArchivePathInDomain,
|
|
191
|
+
domainCacheArchiveBasePath,
|
|
192
|
+
currentExportArchiveCachePath,
|
|
193
|
+
currentExportArchiveCachePathInDomain,
|
|
151
194
|
};
|
|
152
195
|
};
|
|
153
196
|
|
|
154
197
|
const cleanDirtyArtifactPaths = () => {
|
|
155
|
-
for (const artifact of [
|
|
198
|
+
for (const artifact of [
|
|
199
|
+
...artifactsArchivable,
|
|
200
|
+
...artifactsDisposable,
|
|
201
|
+
...artifactsCache,
|
|
202
|
+
]) {
|
|
156
203
|
const { currentExportWorkingPath } = getArtifactPaths(artifact);
|
|
157
204
|
|
|
158
205
|
if (fs.existsSync(currentExportWorkingPath)) {
|
|
@@ -163,11 +210,17 @@ const getDomainRunner = (domain: string) => {
|
|
|
163
210
|
};
|
|
164
211
|
|
|
165
212
|
const createBaseExportPaths = () => {
|
|
166
|
-
const { domainExportArchiveBasePath } =
|
|
213
|
+
const { domainExportArchiveBasePath, domainCacheArchiveBasePath } =
|
|
214
|
+
getArtifactPaths();
|
|
167
215
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
216
|
+
for (const _path of [
|
|
217
|
+
domainExportArchiveBasePath,
|
|
218
|
+
domainCacheArchiveBasePath,
|
|
219
|
+
]) {
|
|
220
|
+
if (!fs.existsSync(_path)) {
|
|
221
|
+
logInfo(`✨ Creating ${_path}`);
|
|
222
|
+
run(`mkdir -p ${_path}`);
|
|
223
|
+
}
|
|
171
224
|
}
|
|
172
225
|
};
|
|
173
226
|
|
|
@@ -255,6 +308,39 @@ const getDomainRunner = (domain: string) => {
|
|
|
255
308
|
run(`rm -rf ${currentExportBackupPath}`);
|
|
256
309
|
};
|
|
257
310
|
|
|
311
|
+
const archiveCacheArtifacts = () => {
|
|
312
|
+
for (const artifact of artifactsCache) {
|
|
313
|
+
const { currentExportArchiveCachePath, currentExportWorkingPath } =
|
|
314
|
+
getArtifactPaths(artifact);
|
|
315
|
+
|
|
316
|
+
if (fs.existsSync(currentExportWorkingPath)) {
|
|
317
|
+
logInfo(
|
|
318
|
+
`🚚 Moving files from ${chalk.gray(
|
|
319
|
+
currentExportWorkingPath
|
|
320
|
+
)} to ${chalk.gray(currentExportArchiveCachePath)}`
|
|
321
|
+
);
|
|
322
|
+
run(`mv ${currentExportWorkingPath} ${currentExportArchiveCachePath}`);
|
|
323
|
+
} else {
|
|
324
|
+
throw new Error(
|
|
325
|
+
`🚚 Error moving files from ${currentExportWorkingPath}: Path does not exist.`
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
const restoreCacheArtifacts = () => {
|
|
331
|
+
for (const artifact of artifactsCache) {
|
|
332
|
+
const { currentExportArchiveCachePath, currentExportWorkingPath } =
|
|
333
|
+
getArtifactPaths(artifact);
|
|
334
|
+
|
|
335
|
+
if (fs.existsSync(currentExportArchiveCachePath)) {
|
|
336
|
+
logWarning(
|
|
337
|
+
`️♻️ Restoring ${chalk.gray(currentExportArchiveCachePath)}`
|
|
338
|
+
);
|
|
339
|
+
run(`mv ${currentExportArchiveCachePath} ${currentExportWorkingPath}`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
258
344
|
const runExporter = () => {
|
|
259
345
|
console.log(`\n${chalk.black(chalk.bgGreen(" Gatsby (start) "))}\n`);
|
|
260
346
|
|
|
@@ -317,6 +403,8 @@ const getDomainRunner = (domain: string) => {
|
|
|
317
403
|
createArtifactBackup,
|
|
318
404
|
restoreArtifactBackup,
|
|
319
405
|
deleteArtifactBackup,
|
|
406
|
+
archiveCacheArtifacts,
|
|
407
|
+
restoreCacheArtifacts,
|
|
320
408
|
runExporter,
|
|
321
409
|
};
|
|
322
410
|
};
|