@griddo/cx 1.75.227 → 1.75.229
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 +28 -28
- package/package.json +3 -3
- package/scripts/build-complete.ts +1 -1
- package/scripts/griddo-exporter.ts +93 -14
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.229",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -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.229",
|
|
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": "7637584235f644f7164054bdddd1bce8d745b84a"
|
|
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,27 +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"];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const INFRA_COMPLETES_BUILD = !!process.env.GRIDDO_INFRA_BUILD_COMPLETES;
|
|
25
|
+
// Artifacts to make exports faster
|
|
26
|
+
const artifactsCache = ["apiCache" /* , ".cache" */];
|
|
26
27
|
|
|
27
28
|
// TODO: Remove STRIP_DOMAIN_FROM_PATH behaviour when all instances are over 1.75.219
|
|
28
29
|
const STRIP_DOMAIN_FROM_PATH =
|
|
29
30
|
!!process.env.GRIDDO_EXPORT_STRIP_DOMAIN_FROM_PATH;
|
|
30
31
|
|
|
31
32
|
if (STRIP_DOMAIN_FROM_PATH) {
|
|
32
|
-
|
|
33
|
+
artifactsCache.push(".cache");
|
|
33
34
|
} else {
|
|
34
35
|
artifactsDisposable.push(".cache");
|
|
35
36
|
}
|
|
36
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
|
+
|
|
37
41
|
// Where we are going to find export folders
|
|
38
42
|
const execBasePath = pkgDir.sync()!;
|
|
39
43
|
|
|
40
44
|
// Where we are going to find archived exports
|
|
41
45
|
const exportArchiveBasePath = path.resolve(execBasePath, "exports/sites");
|
|
46
|
+
const exportCachesArchivePath = path.resolve(__dirname, "../caches");
|
|
42
47
|
|
|
43
48
|
// Where we are going to run the export command
|
|
44
49
|
const workingPath = pkgDir.sync(__dirname)!;
|
|
@@ -89,14 +94,21 @@ const logWarning = (...message: Array<any>) => console.log(...message);
|
|
|
89
94
|
const domainExport = async (domain: string) => {
|
|
90
95
|
const runner = getDomainRunner(domain);
|
|
91
96
|
// onPreExporter
|
|
92
|
-
const endRestore = measureFunctions(
|
|
93
|
-
|
|
97
|
+
const endRestore = measureFunctions(
|
|
98
|
+
runner.init,
|
|
99
|
+
runner.restoreArtifacts,
|
|
100
|
+
runner.restoreCacheArtifacts
|
|
101
|
+
);
|
|
102
|
+
logInfo(`\n⌛️ Domain ${domain} restored: ${endRestore}s`);
|
|
94
103
|
|
|
95
104
|
// Gatsby
|
|
96
105
|
runner.runExporter();
|
|
97
106
|
|
|
98
107
|
// onPostExporter
|
|
99
|
-
const endArchive = measureFunctions(
|
|
108
|
+
const endArchive = measureFunctions(
|
|
109
|
+
runner.archiveArtifacts,
|
|
110
|
+
runner.archiveCacheArtifacts
|
|
111
|
+
);
|
|
100
112
|
logInfo(`\n⌛️ Domain ${domain} archived: ${endArchive}s`);
|
|
101
113
|
};
|
|
102
114
|
|
|
@@ -114,7 +126,7 @@ const launchExports = async () => {
|
|
|
114
126
|
// TODO: Remove when all instances are over 1.75.227 and infra calls export:complete
|
|
115
127
|
if (!INFRA_COMPLETES_BUILD) {
|
|
116
128
|
const runner = getEnvRunner({ cwd: __dirname });
|
|
117
|
-
runner("
|
|
129
|
+
runner("node ./build/build-complete.js");
|
|
118
130
|
}
|
|
119
131
|
};
|
|
120
132
|
|
|
@@ -136,6 +148,10 @@ const getDomainRunner = (domain: string) => {
|
|
|
136
148
|
};
|
|
137
149
|
|
|
138
150
|
const getArtifactPaths = (artifact = "") => {
|
|
151
|
+
if (artifact === "/")
|
|
152
|
+
throw new Error(`Artifact path cannot be root: ${artifact}`);
|
|
153
|
+
|
|
154
|
+
// Archives
|
|
139
155
|
const domainExportArchiveBasePath = path.resolve(
|
|
140
156
|
exportArchiveBasePath,
|
|
141
157
|
domain
|
|
@@ -148,6 +164,21 @@ const getDomainRunner = (domain: string) => {
|
|
|
148
164
|
currentExportArchivePath,
|
|
149
165
|
domain
|
|
150
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
|
+
|
|
151
182
|
const currentExportBackupPath = `${currentExportArchivePath}-BACKUP`;
|
|
152
183
|
const currentExportWorkingPath = path.resolve(workingPath, artifact);
|
|
153
184
|
|
|
@@ -157,11 +188,18 @@ const getDomainRunner = (domain: string) => {
|
|
|
157
188
|
currentExportBackupPath,
|
|
158
189
|
currentExportWorkingPath,
|
|
159
190
|
currentExportArchivePathInDomain,
|
|
191
|
+
domainCacheArchiveBasePath,
|
|
192
|
+
currentExportArchiveCachePath,
|
|
193
|
+
currentExportArchiveCachePathInDomain,
|
|
160
194
|
};
|
|
161
195
|
};
|
|
162
196
|
|
|
163
197
|
const cleanDirtyArtifactPaths = () => {
|
|
164
|
-
for (const artifact of [
|
|
198
|
+
for (const artifact of [
|
|
199
|
+
...artifactsArchivable,
|
|
200
|
+
...artifactsDisposable,
|
|
201
|
+
...artifactsCache,
|
|
202
|
+
]) {
|
|
165
203
|
const { currentExportWorkingPath } = getArtifactPaths(artifact);
|
|
166
204
|
|
|
167
205
|
if (fs.existsSync(currentExportWorkingPath)) {
|
|
@@ -172,11 +210,17 @@ const getDomainRunner = (domain: string) => {
|
|
|
172
210
|
};
|
|
173
211
|
|
|
174
212
|
const createBaseExportPaths = () => {
|
|
175
|
-
const { domainExportArchiveBasePath } =
|
|
213
|
+
const { domainExportArchiveBasePath, domainCacheArchiveBasePath } =
|
|
214
|
+
getArtifactPaths();
|
|
176
215
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
+
}
|
|
180
224
|
}
|
|
181
225
|
};
|
|
182
226
|
|
|
@@ -264,6 +308,39 @@ const getDomainRunner = (domain: string) => {
|
|
|
264
308
|
run(`rm -rf ${currentExportBackupPath}`);
|
|
265
309
|
};
|
|
266
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
|
+
|
|
267
344
|
const runExporter = () => {
|
|
268
345
|
console.log(`\n${chalk.black(chalk.bgGreen(" Gatsby (start) "))}\n`);
|
|
269
346
|
|
|
@@ -326,6 +403,8 @@ const getDomainRunner = (domain: string) => {
|
|
|
326
403
|
createArtifactBackup,
|
|
327
404
|
restoreArtifactBackup,
|
|
328
405
|
deleteArtifactBackup,
|
|
406
|
+
archiveCacheArtifacts,
|
|
407
|
+
restoreCacheArtifacts,
|
|
329
408
|
runExporter,
|
|
330
409
|
};
|
|
331
410
|
};
|