@griddo/cx 10.4.12 → 10.4.13

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.
Files changed (116) hide show
  1. package/README.md +1 -1
  2. package/build/adapters/gatsby/index.d.ts +2 -0
  3. package/build/adapters/gatsby/utils.d.ts +26 -0
  4. package/build/adapters/index.d.ts +3 -0
  5. package/build/browser/index.d.ts +5 -0
  6. package/build/browser/index.js +1 -0
  7. package/build/build-complete.d.ts +18 -0
  8. package/build/index.d.ts +29 -0
  9. package/build/index.js +37 -38
  10. package/build/move-assets.d.ts +1 -0
  11. package/build/react/index.d.ts +2 -0
  12. package/build/reset-render.d.ts +1 -0
  13. package/build/run-start-render.d.ts +1 -0
  14. package/build/run-start-render.js +69 -0
  15. package/build/services/auth.d.ts +21 -0
  16. package/build/services/distributors.d.ts +45 -0
  17. package/build/services/domains.d.ts +8 -0
  18. package/build/services/navigation.d.ts +77 -0
  19. package/build/services/robots.d.ts +21 -0
  20. package/build/services/settings.d.ts +23 -0
  21. package/build/services/sites.d.ts +42 -0
  22. package/build/services/store.d.ts +6 -0
  23. package/build/start-render.d.ts +3 -0
  24. package/build/start-render.js +70 -0
  25. package/build/types/api.d.ts +130 -0
  26. package/build/types/global.d.ts +78 -0
  27. package/build/types/navigation.d.ts +28 -0
  28. package/build/types/pages.d.ts +128 -0
  29. package/build/types/sites.d.ts +43 -0
  30. package/build/types/templates.d.ts +8 -0
  31. package/build/utils/api.d.ts +23 -0
  32. package/build/utils/cache.d.ts +35 -0
  33. package/build/utils/create-build-data.d.ts +8 -0
  34. package/build/utils/domains.d.ts +5 -0
  35. package/build/utils/folders.d.ts +48 -0
  36. package/build/utils/health-checks.d.ts +7 -0
  37. package/build/utils/instance.d.ts +21 -0
  38. package/build/utils/messages.d.ts +2 -0
  39. package/build/utils/pages.d.ts +34 -0
  40. package/build/utils/searches.d.ts +14 -0
  41. package/build/utils/shared.d.ts +109 -0
  42. package/build/utils/sites.d.ts +36 -0
  43. package/build/utils/store.d.ts +63 -0
  44. package/build/utils/temp-utils.d.ts +10 -0
  45. package/{exporter/cx.config.d.ts → cx.config.d.ts} +1 -2
  46. package/{exporter/cx.config.js → cx.config.js} +5 -8
  47. package/package.json +21 -29
  48. package/src/adapters/gatsby/index.ts +219 -0
  49. package/src/adapters/gatsby/utils.ts +85 -0
  50. package/src/browser/README.md +3 -0
  51. package/src/browser/index.ts +46 -0
  52. package/src/index.ts +48 -0
  53. package/src/move-assets.ts +8 -0
  54. package/src/react/index.ts +5 -0
  55. package/src/run-start-render.ts +3 -0
  56. package/{exporter → src}/services/robots.ts +1 -5
  57. package/{exporter → src}/services/store.ts +6 -1
  58. package/src/start-render.ts +19 -0
  59. package/{exporter → src}/types/global.ts +4 -3
  60. package/src/utils/folders.ts +268 -0
  61. package/{exporter → src}/utils/instance.ts +2 -2
  62. package/{exporter → src}/utils/pages.ts +2 -9
  63. package/{exporter → src}/utils/searches.ts +5 -8
  64. package/{exporter → src}/utils/shared.ts +5 -2
  65. package/{exporter → src}/utils/sites.ts +1 -8
  66. package/{exporter → src}/utils/temp-utils.ts +35 -8
  67. package/ssg/README.md +1 -0
  68. package/ssg/astro/.gitkeep +0 -0
  69. package/ssg/gatsby/.eslintrc.json +51 -0
  70. package/ssg/gatsby/.prettierignore +6 -0
  71. package/ssg/gatsby/.prettierrc.json +3 -0
  72. package/{gatsby-browser.tsx → ssg/gatsby/gatsby-browser.tsx} +42 -44
  73. package/{gatsby-config.ts → ssg/gatsby/gatsby-config.ts} +1 -2
  74. package/{gatsby-node.ts → ssg/gatsby/gatsby-node.ts} +11 -8
  75. package/{gatsby-ssr.tsx → ssg/gatsby/gatsby-ssr.tsx} +1 -1
  76. package/ssg/gatsby/global.d.ts +1 -0
  77. package/ssg/gatsby/package.json +85 -0
  78. package/{src → ssg/gatsby/src}/components/Head.tsx +2 -2
  79. package/{src → ssg/gatsby/src}/components/template.tsx +2 -3
  80. package/{src → ssg/gatsby/src}/gatsby-node-utils.ts +6 -5
  81. package/{src → ssg/gatsby/src}/types.ts +5 -4
  82. package/ssg/gatsby/tsconfig.json +15 -0
  83. package/start-render.js +7 -0
  84. package/build/create-build-data.js +0 -60
  85. package/exporter/adapters/gatsby/index.ts +0 -159
  86. package/exporter/adapters/gatsby/utils.ts +0 -377
  87. package/exporter/create-build-data.ts +0 -22
  88. package/exporter/index.ts +0 -23
  89. package/exporter/utils/folders.ts +0 -318
  90. package/exporter/utils/integrations.ts +0 -36
  91. package/exporter/utils/runners.ts +0 -52
  92. package/index.js +0 -7
  93. /package/{exporter → src}/adapters/index.ts +0 -0
  94. /package/{exporter → src}/build-complete.ts +0 -0
  95. /package/{exporter → src}/reset-render.ts +0 -0
  96. /package/{exporter → src}/services/auth.ts +0 -0
  97. /package/{exporter → src}/services/distributors.ts +0 -0
  98. /package/{exporter → src}/services/domains.ts +0 -0
  99. /package/{exporter → src}/services/navigation.ts +0 -0
  100. /package/{exporter → src}/services/settings.ts +0 -0
  101. /package/{exporter → src}/services/sites.ts +0 -0
  102. /package/{exporter → src}/types/api.ts +0 -0
  103. /package/{exporter → src}/types/navigation.ts +0 -0
  104. /package/{exporter → src}/types/pages.ts +0 -0
  105. /package/{exporter → src}/types/sites.ts +0 -0
  106. /package/{exporter → src}/types/templates.ts +0 -0
  107. /package/{exporter → src}/utils/api.ts +0 -0
  108. /package/{exporter → src}/utils/cache.ts +0 -0
  109. /package/{exporter/utils/download-build-data.ts → src/utils/create-build-data.ts} +0 -0
  110. /package/{exporter → src}/utils/domains.ts +0 -0
  111. /package/{exporter → src}/utils/health-checks.ts +0 -0
  112. /package/{exporter → src}/utils/messages.ts +0 -0
  113. /package/{exporter → src}/utils/store.ts +0 -0
  114. /package/{src → ssg/gatsby/src}/README.md +0 -0
  115. /package/{src → ssg/gatsby/src}/html.tsx +0 -0
  116. /package/{src → ssg/gatsby/src}/utils.ts +0 -0
@@ -1,159 +0,0 @@
1
- import { attempts, getGatsbyDomainRunner } from "./utils";
2
- import { getGatsbyAssetPrefixSlug } from "../../../src/gatsby-node-utils";
3
- import { RobotsService } from "../../services/robots";
4
- import { getInstanceDomains } from "../../utils/domains";
5
- import { createBuildData } from "../../utils/download-build-data";
6
- import {
7
- clearEmptyDirs,
8
- copyArtifacts,
9
- removeArtifacts,
10
- removeMultiPagesFromStore,
11
- } from "../../utils/folders";
12
- import { uploadSearchContentToAPI } from "../../utils/searches";
13
- import { doLifeCycle, pause, printExporterLogo } from "../../utils/shared";
14
- import { generateBuildReport, generateSitemaps } from "../../utils/sites";
15
- import {
16
- getConfig,
17
- legacy__createDistFromGatsbyPublic,
18
- } from "../../utils/temp-utils";
19
-
20
- async function runGatsbyAdapter() {
21
- printExporterLogo("gatsby");
22
-
23
- const domains = await getInstanceDomains();
24
- const config = getConfig();
25
-
26
- for (const domain of domains) {
27
- const runner = getGatsbyDomainRunner(domain);
28
- const { __components, __cx } = config.dirs(domain);
29
- const assetPrefix = getGatsbyAssetPrefixSlug(domain);
30
- const needsAssetPrefix = !!assetPrefix && assetPrefix !== "";
31
-
32
- /**
33
- * Prepare
34
- */
35
- await doLifeCycle({
36
- name: "Prepare",
37
- steps: [
38
- () =>
39
- copyArtifacts({
40
- artifacts: ["static"],
41
- from: __components,
42
- to: __cx,
43
- }),
44
- runner.init,
45
- () => pause("Prepared LifeCycle"),
46
- ],
47
- attempts: attempts.prepare,
48
- });
49
-
50
- /**
51
- * Restore
52
- *
53
- * Init the render, restore Gatsby `.cache` and `public` dirs.
54
- */
55
- await doLifeCycle({
56
- name: "Restore",
57
- attempts: attempts.restore,
58
- steps: [
59
- runner.restoreArtifacts,
60
- runner.restoreCacheArtifacts,
61
- () => pause("Restore LifeCycle"),
62
- ],
63
- });
64
-
65
- /**
66
- * Data
67
- *
68
- * Download domain build data (sites, pages, etc) and create a dir
69
- * called `store` where all the domain render data is saved.
70
- */
71
- await doLifeCycle({
72
- name: "Data",
73
- attempts: attempts.data,
74
- steps: [() => createBuildData(domain), () => pause("Data LifeCycle")],
75
- });
76
-
77
- /**
78
- * SSG
79
- *
80
- * Call the `gatsby build` command.
81
- * Gatsby will use the downloaded data and create the static build.
82
- * `gatsby-node.ts` is the main file where the stati generation happens.
83
- */
84
- await doLifeCycle({
85
- name: "SSG",
86
- attempts: attempts.ssg,
87
- steps: [runner.runGatsbyBuild, () => pause("SSG LifeCycle")],
88
- });
89
-
90
- /**
91
- * Relocation
92
- */
93
- await doLifeCycle({
94
- name: "Relocation",
95
- steps: [
96
- () => legacy__createDistFromGatsbyPublic(domain, needsAssetPrefix),
97
- () => pause("Relocation LifeCycle"),
98
- ],
99
- });
100
-
101
- /**
102
- * Meta
103
- *
104
- * Gatsby build is done, if the .env GRIDDO_SEARCH_FEATURE is set to
105
- * true we save the search data in the API.
106
- */
107
- const shouldUploadSearchData = JSON.parse(
108
- process.env.GRIDDO_SEARCH_FEATURE || "false"
109
- );
110
- await doLifeCycle({
111
- name: "Meta",
112
- attempts: attempts.meta,
113
- steps: [
114
- () => generateBuildReport(),
115
- () => RobotsService.writeFiles(domain),
116
- () => generateSitemaps(),
117
- () => (shouldUploadSearchData ? uploadSearchContentToAPI() : undefined),
118
- () => pause("Meta LifeCycle"),
119
- ],
120
- });
121
-
122
- /**
123
- * Archive
124
- *
125
- * When Gatsby ends, remove disposable artifacts and save .cache and
126
- * public foler to use in the next render.
127
- */
128
- await doLifeCycle({
129
- name: "Archive",
130
- attempts: attempts.archive,
131
- steps: [
132
- // Elimina las páginas MultiPage del `store`. De este modo nos
133
- // aseguramos que se vuelven a crear por Gatsby siempre
134
- // actualizadas.
135
- removeMultiPagesFromStore,
136
- () => clearEmptyDirs(),
137
- runner.removeDisposableArtifacts,
138
- runner.archiveArtifacts,
139
- runner.archiveCacheArtifacts,
140
- () => pause("Archive LifeCycle"),
141
- ],
142
- });
143
-
144
- await doLifeCycle({
145
- name: "Clean",
146
- steps: [
147
- () =>
148
- removeArtifacts({
149
- from: __cx,
150
- artifacts: ["static", "apiCache"],
151
- }),
152
- () => pause("Clean LifeCycle"),
153
- ],
154
- attempts: attempts.clean,
155
- });
156
- }
157
- }
158
-
159
- export { runGatsbyAdapter };
@@ -1,377 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
-
4
- import chalk from "chalk";
5
- import dotenv from "dotenv";
6
-
7
- import { deleteSites } from "../../utils/folders";
8
- import { getEnvRunner } from "../../utils/runners";
9
- import { CXRootDir, instanceRootDir } from "../../utils/shared";
10
- import { checkSites } from "../../utils/sites";
11
-
12
- dotenv.config();
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
- /**
28
- * Return a runner, a serie of functions to manage the Gatsby render artifacts.
29
- */
30
- function getGatsbyDomainRunner(domain: string) {
31
- // Artifacts to preserve between CX installs
32
- const artifactsArchivable = ["dist", "assets"];
33
-
34
- // Artifacts to remove after export
35
- // if STRIP_DOMAIN_FROM_PATH is false `.cache` will be added.
36
- const artifactsDisposable = ["public"];
37
-
38
- // Artifacts to make exports faster
39
- // if STRIP_DOMAIN_FROM_PATH is true `.cache` will be added.
40
- const artifactsCache = ["apiCache", "store" /* , ".cache" */];
41
-
42
- // TODO: Remove STRIP_DOMAIN_FROM_PATH behaviour when all instances are over 1.75.219
43
- const STRIP_DOMAIN_FROM_PATH = JSON.parse(
44
- process.env.GRIDDO_EXPORT_STRIP_DOMAIN_FROM_PATH || "false"
45
- );
46
-
47
- if (STRIP_DOMAIN_FROM_PATH) {
48
- artifactsCache.push(".cache");
49
- } else {
50
- artifactsDisposable.push(".cache");
51
- }
52
-
53
- // Where we are going to find archived exports
54
- const exportArchiveBasePath = path.resolve(instanceRootDir, "exports/sites");
55
- const exportCachesArchivePath = path.resolve(__dirname, "../caches");
56
-
57
- const assetPrefix = getGatsbyAssetPrefixSlug(domain);
58
-
59
- const run = getEnvRunner({
60
- GRIDDO_ASSET_PREFIX: assetPrefix,
61
- FOO: "true-and-false",
62
- });
63
-
64
- /**
65
- * Initialize exporter clearing artifacts data from a unsuccessful build and
66
- * creating necesary dirs to store a new build.
67
- */
68
- const init = () => {
69
- console.info(`Initializing exporter for the domain ${domain}`);
70
- cleanDirtyArtifactPaths();
71
- createBaseExportPaths();
72
- };
73
-
74
- /**
75
- * Restore Gatsby artifacts from a previous render to improve performance.
76
- */
77
- const restoreArtifacts = () => {
78
- for (const artifact of artifactsArchivable) {
79
- const {
80
- currentExportArchivePath,
81
- currentExportWorkingPath,
82
- } = getArtifactPaths(artifact);
83
-
84
- if (fs.existsSync(currentExportArchivePath)) {
85
- console.log(`️Restoring ${chalk.gray(currentExportArchivePath)}`);
86
- run(`cp -R ${currentExportArchivePath} ${currentExportWorkingPath}`);
87
- }
88
- }
89
-
90
- moveDistToPublic();
91
- };
92
-
93
- const getArtifactPaths = (artifact = "") => {
94
- if (artifact === "/")
95
- throw new Error(`Artifact path cannot be root: ${artifact}`);
96
-
97
- // Archives
98
- const domainExportArchiveBasePath = path.resolve(
99
- exportArchiveBasePath,
100
- domain
101
- );
102
- const currentExportArchivePath = path.resolve(
103
- domainExportArchiveBasePath,
104
- artifact
105
- );
106
- const currentExportArchivePathInDomain = path.resolve(
107
- currentExportArchivePath,
108
- domain
109
- );
110
-
111
- // Cachés
112
- const domainCacheArchiveBasePath = path.resolve(
113
- exportCachesArchivePath,
114
- domain
115
- );
116
- const currentExportArchiveCachePath = path.resolve(
117
- domainCacheArchiveBasePath,
118
- artifact
119
- );
120
- const currentExportArchiveCachePathInDomain = path.resolve(
121
- currentExportArchiveCachePath,
122
- domain
123
- );
124
-
125
- const currentExportBackupPath = `${currentExportArchivePath}-BACKUP`;
126
- const currentExportWorkingPath = path.resolve(CXRootDir, artifact);
127
-
128
- return {
129
- domainExportArchiveBasePath,
130
- currentExportArchivePath,
131
- currentExportBackupPath,
132
- currentExportWorkingPath,
133
- currentExportArchivePathInDomain,
134
- domainCacheArchiveBasePath,
135
- currentExportArchiveCachePath,
136
- currentExportArchiveCachePathInDomain,
137
- };
138
- };
139
-
140
- /**
141
- * Remove artifacts probably from a unsuccessful build.
142
- */
143
- const cleanDirtyArtifactPaths = () => {
144
- for (const artifact of [
145
- ...artifactsArchivable,
146
- ...artifactsDisposable,
147
- ...artifactsCache,
148
- ]) {
149
- const { currentExportWorkingPath } = getArtifactPaths(artifact);
150
-
151
- if (fs.existsSync(currentExportWorkingPath)) {
152
- console.log(`Cleanup dirty ${chalk.gray(currentExportWorkingPath)}`);
153
- run(`rm -rf ${currentExportWorkingPath}`);
154
- }
155
- }
156
- };
157
-
158
- /**
159
- * Creates necesary dirs.
160
- */
161
- const createBaseExportPaths = () => {
162
- const {
163
- domainExportArchiveBasePath,
164
- domainCacheArchiveBasePath,
165
- } = getArtifactPaths();
166
-
167
- for (const _path of [
168
- domainExportArchiveBasePath,
169
- domainCacheArchiveBasePath,
170
- ]) {
171
- if (!fs.existsSync(_path)) {
172
- console.info(`Creating ${_path}`);
173
- run(`mkdir -p ${_path}`);
174
- }
175
- }
176
- };
177
-
178
- const archiveExportArtifact = (artifact: string) => {
179
- const {
180
- currentExportArchivePath,
181
- currentExportWorkingPath,
182
- } = getArtifactPaths(artifact);
183
-
184
- console.info(
185
- `Moving files from ${chalk.gray(
186
- currentExportWorkingPath
187
- )} to ${chalk.gray(currentExportArchivePath)}`
188
- );
189
- run(`mv ${currentExportWorkingPath} ${currentExportArchivePath}`);
190
- };
191
-
192
- /** Archive archivable artifacts to reuse them in the next render */
193
- const archiveArtifacts = () => {
194
- for (const artifact of artifactsArchivable) {
195
- const {
196
- currentExportWorkingPath,
197
- currentExportArchivePath,
198
- } = getArtifactPaths(artifact);
199
-
200
- if (!fs.existsSync(currentExportWorkingPath)) {
201
- console.log(
202
- "Source directory has not been created:",
203
- currentExportWorkingPath
204
- );
205
- continue;
206
- }
207
-
208
- try {
209
- createArtifactBackup(artifact);
210
- archiveExportArtifact(artifact);
211
- deleteArtifactBackup(artifact);
212
- } catch (error) {
213
- console.log(
214
- `Error moving files to ${currentExportArchivePath}`,
215
- (error as Error).message
216
- );
217
- restoreArtifactBackup(artifact);
218
- continue;
219
- }
220
- }
221
- };
222
-
223
- const createArtifactBackup = (artifact: string) => {
224
- const {
225
- currentExportArchivePath,
226
- currentExportBackupPath,
227
- } = getArtifactPaths(artifact);
228
-
229
- if (fs.existsSync(currentExportArchivePath)) {
230
- console.info(
231
- `Creating backup of ${chalk.gray(currentExportArchivePath)}`
232
- );
233
- run(`mv ${currentExportArchivePath} ${currentExportBackupPath}`);
234
- }
235
- };
236
-
237
- const restoreArtifactBackup = (artifact: string) => {
238
- const {
239
- currentExportArchivePath,
240
- currentExportBackupPath,
241
- } = getArtifactPaths(artifact);
242
-
243
- if (fs.existsSync(currentExportBackupPath)) {
244
- console.log(`️Restoring backup ${chalk.gray(currentExportArchivePath)}`);
245
- run(`mv ${currentExportBackupPath} ${currentExportArchivePath}`);
246
- }
247
- };
248
-
249
- const deleteArtifactBackup = (artifact: string) => {
250
- const {
251
- currentExportArchivePath,
252
- currentExportBackupPath,
253
- } = getArtifactPaths(artifact);
254
-
255
- console.log(`️Removing backup ${chalk.gray(currentExportArchivePath)}`);
256
- run(`rm -rf ${currentExportBackupPath}`);
257
- };
258
-
259
- /** Archive archivable cache artifacts to reuse them in the next render */
260
- const archiveCacheArtifacts = () => {
261
- for (const artifact of artifactsCache) {
262
- const {
263
- currentExportArchiveCachePath,
264
- currentExportWorkingPath,
265
- } = getArtifactPaths(artifact);
266
-
267
- if (fs.existsSync(currentExportWorkingPath)) {
268
- console.info(
269
- `Moving files from ${chalk.gray(
270
- currentExportWorkingPath
271
- )} to ${chalk.gray(currentExportArchiveCachePath)}`
272
- );
273
- run(`mv ${currentExportWorkingPath} ${currentExportArchiveCachePath}`);
274
- } else {
275
- throw new Error(
276
- `Error moving files from ${currentExportWorkingPath}: Path does not exist.`
277
- );
278
- }
279
- }
280
- };
281
-
282
- /**
283
- * Remove sites dir from restoring phase.
284
- */
285
- const cleanUpSites = async () => {
286
- const { sitesToPublish, sitesToUnpublish } = await checkSites(domain);
287
-
288
- await deleteSites(sitesToUnpublish, domain);
289
- await deleteSites(sitesToPublish, domain);
290
- };
291
-
292
- /**
293
- * Restore Gatsby cache artifacts from a previous render to improve
294
- * performance.
295
- */
296
- const restoreCacheArtifacts = () => {
297
- for (const artifact of artifactsCache) {
298
- const {
299
- currentExportArchiveCachePath,
300
- currentExportWorkingPath,
301
- } = getArtifactPaths(artifact);
302
-
303
- if (fs.existsSync(currentExportArchiveCachePath)) {
304
- console.log(`️Restoring ${chalk.gray(currentExportArchiveCachePath)}`);
305
- run(`mv ${currentExportArchiveCachePath} ${currentExportWorkingPath}`);
306
- }
307
- }
308
- };
309
-
310
- /**
311
- * Call the gatsby build command.
312
- * This start the `yarn gatsby-build` command that will use the data downloaded.
313
- */
314
- const runGatsbyBuild = () => {
315
- run("yarn gatsby-build");
316
- };
317
-
318
- // TODO: Hacer que infra tire de `public` en vez de `dist` y quitar esto
319
- const moveDistToPublic = () => {
320
- const { currentExportWorkingPath: distPath } = getArtifactPaths("dist");
321
- const { currentExportWorkingPath: publicPath } = getArtifactPaths("public");
322
-
323
- if (fs.existsSync(distPath)) {
324
- console.log(
325
- `Moving ${chalk.gray(distPath)} to ${chalk.gray(publicPath)}`
326
- );
327
- run(`mv ${distPath} ${publicPath}`);
328
- }
329
- };
330
-
331
- /**
332
- * Delete disposable artifacts between renders.
333
- */
334
- const removeDisposableArtifacts = () => {
335
- for (const artifact of artifactsDisposable) {
336
- const { currentExportWorkingPath: artifactPath } = getArtifactPaths(
337
- artifact
338
- );
339
-
340
- if (fs.existsSync(artifactPath)) {
341
- console.log(`️Removing ${chalk.gray(artifactPath)}`);
342
- run(`rm -rf ${artifactPath}`);
343
- }
344
- }
345
- };
346
-
347
- return {
348
- init,
349
- getArtifactPaths,
350
- archiveExportArtifact,
351
- archiveArtifacts,
352
- restoreArtifacts,
353
- createArtifactBackup,
354
- restoreArtifactBackup,
355
- deleteArtifactBackup,
356
- archiveCacheArtifacts,
357
- restoreCacheArtifacts,
358
- cleanUpSites,
359
- runGatsbyBuild,
360
- removeDisposableArtifacts,
361
- };
362
- }
363
-
364
- /**
365
- * Return the assetPrefix url `assetPrefix/domain`
366
- */
367
- function getGatsbyAssetPrefixSlug(domain: string) {
368
- const assetPrefix =
369
- process.env.GRIDDO_ASSET_PREFIX || process.env.ASSET_PREFIX;
370
-
371
- if (!assetPrefix || !domain) return "";
372
- if (!domain.startsWith("pro-")) return "";
373
-
374
- return `${assetPrefix}/${domain}`;
375
- }
376
-
377
- export { attempts, getGatsbyDomainRunner };
@@ -1,22 +0,0 @@
1
- import { getInstanceDomains } from "./utils/domains";
2
- import { createBuildData } from "./utils/download-build-data";
3
-
4
- async function main() {
5
- const domains = await getInstanceDomains();
6
-
7
- for (const domain of domains) {
8
- createBuildData(domain).catch((err) => {
9
- console.error("Error", err?.stdout?.toString() || err);
10
- process.exit(1);
11
- });
12
- process.exit(0);
13
- }
14
- }
15
-
16
- main().catch((err) => {
17
- console.error(
18
- "Error in create-build-data.ts:",
19
- err?.stdout?.toString() || err
20
- );
21
- process.exit(1);
22
- });
package/exporter/index.ts DELETED
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env node
2
- /* eslint-disable node/shebang */
3
-
4
- import { runGatsbyAdapter } from "./adapters";
5
- import { logBox, measureExecutionTime } from "./utils/shared";
6
-
7
- async function main() {
8
- const exeTime = await measureExecutionTime(() => runGatsbyAdapter()).catch(
9
- (e) => {
10
- console.log(e);
11
- console.log("[[[ Render will be reset ]]]");
12
- process.exit(1);
13
- }
14
- );
15
- logBox(`All domains rendered in ${exeTime}s.`, "", 1, 0);
16
- process.exit(0);
17
- }
18
-
19
- // Go render, go!
20
- main().catch((err) => {
21
- console.error("Error in main():", err?.stdout?.toString() || err);
22
- process.exit(1);
23
- });