@griddo/cx 1.75.178 → 1.75.180
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/README.md +22 -14
- package/build/index.js +49 -0
- package/gatsby-browser.tsx +140 -0
- package/gatsby-config.ts +40 -0
- package/gatsby-node.ts +130 -0
- package/gatsby-ssr.tsx +63 -0
- package/index.js +4 -0
- package/package.json +119 -100
- package/scripts/build-reset.ts +9 -0
- package/scripts/griddo-exporter.ts +302 -0
- package/src/components/Head.tsx +207 -0
- package/src/components/template.tsx +90 -0
- package/src/components/types.ts +35 -0
- package/src/components/utils.ts +138 -0
- package/src/html.tsx +31 -0
- package/src/services/auth.ts +64 -0
- package/src/services/distributors.ts +153 -0
- package/src/services/domains.ts +27 -0
- package/src/services/navigation.ts +169 -0
- package/src/services/robots.ts +64 -0
- package/src/services/settings.ts +52 -0
- package/src/services/sites.ts +199 -0
- package/src/services/store-with-for-loop.ts +513 -0
- package/src/services/store-with-promise-all.ts +515 -0
- package/src/services/store.ts +513 -0
- package/src/types/api.ts +155 -0
- package/src/types/global.ts +72 -0
- package/src/types/navigation.ts +25 -0
- package/src/types/pages.ts +145 -0
- package/src/types/sites.ts +64 -0
- package/src/types/templates.ts +11 -0
- package/src/utils/api.ts +326 -0
- package/src/utils/cache.ts +114 -0
- package/src/utils/domains.ts +32 -0
- package/src/utils/folders.ts +147 -0
- package/src/utils/instance.ts +71 -0
- package/src/utils/pages.ts +534 -0
- package/src/utils/searches.ts +102 -0
- package/src/utils/shared.ts +131 -0
- package/src/utils/sites.ts +280 -0
- package/.babelrc +0 -7
- package/LICENSE +0 -1
- package/gatsby-browser.js +0 -115
- package/gatsby-config.js +0 -38
- package/gatsby-node.js +0 -273
- package/gatsby-ssr.js +0 -43
- package/scripts/griddo-exporter.js +0 -133
- package/src/api/index.js +0 -172
- package/src/components/template.js +0 -261
- package/src/html.js +0 -30
- package/src/images/readme.md +0 -1
- package/src/scripts/build-reset.js +0 -12
- package/src/services/auth.js +0 -44
- package/src/services/distributors.js +0 -85
- package/src/services/domains.js +0 -16
- package/src/services/navigation.js +0 -104
- package/src/services/robots.js +0 -37
- package/src/services/settings.js +0 -25
- package/src/services/sites.js +0 -110
- package/src/utils/cache.js +0 -70
- package/src/utils/component-lib-helpers.js +0 -56
- package/src/utils/dataLayer.js +0 -47
- package/src/utils/delay.js +0 -5
- package/src/utils/domains.js +0 -24
- package/src/utils/folders.js +0 -123
- package/src/utils/helpers.js +0 -144
- package/src/utils/index.js +0 -44
- package/src/utils/package.js +0 -20
- package/src/utils/pages.js +0 -236
- package/src/utils/searches.js +0 -62
- package/src/utils/sites.js +0 -207
- package/static/griddo-full-logo.png +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// External libraries
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import gradient from "gradient-string";
|
|
6
|
+
import { APIResponses } from "../types/api";
|
|
7
|
+
|
|
8
|
+
dotenv.config();
|
|
9
|
+
|
|
10
|
+
// Envs
|
|
11
|
+
const GRIDDO_BUILD_LOGS =
|
|
12
|
+
!!process.env.GRIDDO_BUILD_LOGS &&
|
|
13
|
+
!!JSON.parse(process.env.GRIDDO_BUILD_LOGS);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Walk a directory and returns the file pathts.
|
|
17
|
+
*
|
|
18
|
+
* @param dir A directory path.
|
|
19
|
+
*/
|
|
20
|
+
function walk(dir: string) {
|
|
21
|
+
const results: Array<string> = [];
|
|
22
|
+
const list = fs.readdirSync(dir);
|
|
23
|
+
list.forEach((file) => {
|
|
24
|
+
const newLocalFile = `${dir}/${file}`;
|
|
25
|
+
results.push(newLocalFile);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return results;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Custom log inside a line-box.
|
|
33
|
+
*
|
|
34
|
+
* @param str The string to be logged.
|
|
35
|
+
*/
|
|
36
|
+
function logBox(str: string) {
|
|
37
|
+
const len = str.length;
|
|
38
|
+
const minWidth = str.length + 2;
|
|
39
|
+
const margin = " ".repeat(Math.floor((minWidth - len) / 2));
|
|
40
|
+
const borderTop = `╭${"─".repeat(minWidth)}╮\n`;
|
|
41
|
+
const borderBottom = `\n╰${"─".repeat(minWidth)}╯`;
|
|
42
|
+
const content = `│${margin}${str}${margin}│`;
|
|
43
|
+
|
|
44
|
+
console.log(`${borderTop}${content}${borderBottom}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Custom basic logging function controlled by a environment variable.
|
|
49
|
+
*
|
|
50
|
+
* @params str The string or strings separated by commans to be logged.
|
|
51
|
+
*/
|
|
52
|
+
function logInfo(...str: Array<unknown>) {
|
|
53
|
+
if (GRIDDO_BUILD_LOGS) {
|
|
54
|
+
console.info(...str);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Custom delay using the "promise hack",
|
|
60
|
+
*
|
|
61
|
+
* @param ms Amount of miliseconds to be delayed
|
|
62
|
+
*/
|
|
63
|
+
function delay(ms: number) {
|
|
64
|
+
return new Promise((res) => setTimeout(res, ms));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Return a scale size colors with a number and a measure string (KB by default).
|
|
69
|
+
*
|
|
70
|
+
* @param size The page size in KB.
|
|
71
|
+
* @param measure The measure string to be added in the log.
|
|
72
|
+
*/
|
|
73
|
+
function logPageSize(size: number, measure = "KB") {
|
|
74
|
+
const sizeScale = {
|
|
75
|
+
low: 50,
|
|
76
|
+
mid: 80,
|
|
77
|
+
large: 130,
|
|
78
|
+
extraLarge: 210,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Ternary pawa!
|
|
82
|
+
const color =
|
|
83
|
+
size > sizeScale.large
|
|
84
|
+
? "red"
|
|
85
|
+
: size > sizeScale.mid
|
|
86
|
+
? "magenta"
|
|
87
|
+
: size > sizeScale.low
|
|
88
|
+
? "blue"
|
|
89
|
+
: "green";
|
|
90
|
+
|
|
91
|
+
return chalk[color].bold(`${size}${measure}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Converts milliseconds to seconds with a fixed number of decimals.
|
|
96
|
+
*
|
|
97
|
+
* @param ms The number in milliseconds.
|
|
98
|
+
* @param fixed The amount of fixed decimals.
|
|
99
|
+
* @returns The converted number in seconds with the fixed number of decimals.
|
|
100
|
+
*/
|
|
101
|
+
export function msToSec(ms: number, decimals = 3) {
|
|
102
|
+
return (ms / 1000).toFixed(decimals);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Return a siteID from a response object if exist
|
|
107
|
+
* @param response A response object
|
|
108
|
+
*/
|
|
109
|
+
export function getSafeSiteId(response: APIResponses) {
|
|
110
|
+
return "site" in response && response.site ? response?.site : undefined;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Print a f**king great Griddo builder logo.
|
|
115
|
+
*/
|
|
116
|
+
function splash() {
|
|
117
|
+
const logo = `
|
|
118
|
+
|
|
119
|
+
______ ______ _____ ______ ______ _____
|
|
120
|
+
| ____ |_____/ | | \\ | \\ | |
|
|
121
|
+
|_____| | \\_ __|__ |_____/ |_____/ |_____|
|
|
122
|
+
______ _ _ _____ ______ _______ ______
|
|
123
|
+
|_____] | | | | | \\ |______ |_____/
|
|
124
|
+
|_____] |_____| __|__ |_____ |_____/ |______ | \\_
|
|
125
|
+
|
|
126
|
+
`;
|
|
127
|
+
|
|
128
|
+
console.log(gradient.mind(logo));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { delay, logBox, logInfo, logPageSize, splash, walk };
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
// Types
|
|
2
|
+
import type { BuildProcessData } from "../types/global";
|
|
3
|
+
import type { Site, SiteData } from "../types/sites";
|
|
4
|
+
|
|
5
|
+
// External libraries
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import fs from "fs-extra";
|
|
8
|
+
import { parse } from "js2xmlparser";
|
|
9
|
+
import pLimit from "p-limit";
|
|
10
|
+
import path from "path";
|
|
11
|
+
|
|
12
|
+
// Services
|
|
13
|
+
import { AuthService } from "../services/auth";
|
|
14
|
+
import { SitesService } from "../services/sites";
|
|
15
|
+
|
|
16
|
+
// Utils
|
|
17
|
+
import { AllPagesResponse } from "../types/api";
|
|
18
|
+
import { deleteSites } from "./folders";
|
|
19
|
+
import { logInfo } from "./shared";
|
|
20
|
+
|
|
21
|
+
// Envs
|
|
22
|
+
const API_URL = process.env.API_URL;
|
|
23
|
+
const GRIDDO_RENDER_ALL_SITES = !!process.env.GRIDDO_RENDER_ALL_SITES;
|
|
24
|
+
const GRIDDO_RENDER_SITE =
|
|
25
|
+
process.env.GRIDDO_RENDER_SITE && parseInt(process.env.GRIDDO_RENDER_SITE);
|
|
26
|
+
const GRIDDO_RENDER_PAGES = (process.env.GRIDDO_RENDER_PAGES || "")
|
|
27
|
+
.split(",")
|
|
28
|
+
.map((item) => parseInt(item))
|
|
29
|
+
.filter(Boolean);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Check the instance sites and returns site prepared to be published and unpublished.
|
|
33
|
+
*/
|
|
34
|
+
async function checkSites() {
|
|
35
|
+
console.log(`🔗 API URL ${chalk.underline(API_URL as string)}`);
|
|
36
|
+
|
|
37
|
+
// Login to API
|
|
38
|
+
await AuthService.login();
|
|
39
|
+
|
|
40
|
+
// Get all sites. An array of Site
|
|
41
|
+
const allSites = await SitesService.getAll();
|
|
42
|
+
// Filter the array of sites to get only the ones to build/render
|
|
43
|
+
const validSites = GRIDDO_RENDER_ALL_SITES
|
|
44
|
+
? allSites.filter(
|
|
45
|
+
(site) => !GRIDDO_RENDER_SITE || site.id === GRIDDO_RENDER_SITE
|
|
46
|
+
)
|
|
47
|
+
: allSites.filter((site) =>
|
|
48
|
+
GRIDDO_RENDER_SITE
|
|
49
|
+
? site.id === GRIDDO_RENDER_SITE
|
|
50
|
+
: !!site.shouldBeUpdated
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
// If there are valid sites...
|
|
54
|
+
if (validSites.length) {
|
|
55
|
+
const promisesOfValidSites = validSites.map(async (site) => {
|
|
56
|
+
const langResponse = await SitesService.getLanguages(site.id);
|
|
57
|
+
|
|
58
|
+
return (site.domains = langResponse.items
|
|
59
|
+
.filter((item) => {
|
|
60
|
+
return (
|
|
61
|
+
item.domain &&
|
|
62
|
+
(!process.env.DOMAIN ||
|
|
63
|
+
item.domain.slug.indexOf(process.env.DOMAIN) > 0)
|
|
64
|
+
);
|
|
65
|
+
})
|
|
66
|
+
.map((item) => ({ [item.id]: `${item.domain.slug}${item.path}` })));
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
await Promise.all(promisesOfValidSites);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Save sites object to publish
|
|
73
|
+
const sitesToPublish = validSites.filter((site) =>
|
|
74
|
+
GRIDDO_RENDER_SITE
|
|
75
|
+
? site.id === GRIDDO_RENDER_SITE
|
|
76
|
+
: !!site.isPublished && site.domains.length > 0
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// Save sites object to unpublish
|
|
80
|
+
const sitesToUnpublish = validSites.filter(
|
|
81
|
+
(site) => !site.isPublished && site.shouldBeUpdated
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
sitesToPublish,
|
|
86
|
+
sitesToUnpublish,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Unpublish an array of sites in two steps:
|
|
92
|
+
* - Sending the information to the API
|
|
93
|
+
* - Removing the files from the file system
|
|
94
|
+
*
|
|
95
|
+
* @param sites An array of sites
|
|
96
|
+
*/
|
|
97
|
+
async function unpublishSites(sites: Array<Site>) {
|
|
98
|
+
for (const site of sites) {
|
|
99
|
+
const buildInfo = await SitesService.startSiteRender(site.id);
|
|
100
|
+
const { siteHash } = buildInfo;
|
|
101
|
+
const body = {
|
|
102
|
+
siteHash,
|
|
103
|
+
publishHashes: [],
|
|
104
|
+
unpublishHashes: [],
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
logInfo("Unpublish site starts", buildInfo);
|
|
108
|
+
|
|
109
|
+
await SitesService.endSiteRender(site.id, body);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
await deleteSites(sites);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Return a single site generic data.
|
|
117
|
+
*
|
|
118
|
+
* @param siteID The site id.
|
|
119
|
+
* @param cached Boolean that indicates if we want to get cache version.
|
|
120
|
+
*
|
|
121
|
+
* @see SiteData
|
|
122
|
+
*/
|
|
123
|
+
async function getSiteData(siteID: number, cached: boolean) {
|
|
124
|
+
const buildData = await SitesService.startSiteRender(siteID);
|
|
125
|
+
const siteInfo = await SitesService.getInfo(siteID, cached);
|
|
126
|
+
const siteLangs = await SitesService.getLanguages(siteID, cached);
|
|
127
|
+
const socials = await SitesService.getSocials(siteID, cached);
|
|
128
|
+
const siteLangsInfo = siteLangs.items;
|
|
129
|
+
const defaultLang = siteLangsInfo.find((lang) => lang.isDefault);
|
|
130
|
+
// eliminado para validar que efectivamente no rompe nada
|
|
131
|
+
// si el cambio es correcto, hay que eliminar las 7 líneas que contienen "sitePages"
|
|
132
|
+
// const sitePages = await SitesService.getPages(siteID, cached);
|
|
133
|
+
const sitePages: AllPagesResponse = [];
|
|
134
|
+
|
|
135
|
+
const { siteHash, unpublishHashes, publishIds } = buildData;
|
|
136
|
+
const { headers, footers } = siteInfo;
|
|
137
|
+
const validPagesIds = GRIDDO_RENDER_PAGES.length
|
|
138
|
+
? GRIDDO_RENDER_PAGES.filter((item) => publishIds.includes(item))
|
|
139
|
+
: publishIds;
|
|
140
|
+
|
|
141
|
+
const siteData: SiteData = {
|
|
142
|
+
siteInfo,
|
|
143
|
+
validPagesIds,
|
|
144
|
+
siteHash,
|
|
145
|
+
unpublishHashes,
|
|
146
|
+
siteLangs: siteLangsInfo,
|
|
147
|
+
defaultLang,
|
|
148
|
+
headers,
|
|
149
|
+
footers,
|
|
150
|
+
socials,
|
|
151
|
+
sitePages,
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return siteData;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Send end render signal to the API for all pages.
|
|
159
|
+
*
|
|
160
|
+
* @param buildProcessData The whole build process data.
|
|
161
|
+
* @param createdPages An array of pages ids.
|
|
162
|
+
*/
|
|
163
|
+
async function setPagesRenderEnd(
|
|
164
|
+
buildProcessData: BuildProcessData,
|
|
165
|
+
createdPages: Array<number>
|
|
166
|
+
) {
|
|
167
|
+
const promises = Object.keys(buildProcessData).map(async (siteID) => {
|
|
168
|
+
const body = buildProcessData[siteID];
|
|
169
|
+
|
|
170
|
+
logInfo(`Deploying ending call to site ${siteID}:`);
|
|
171
|
+
|
|
172
|
+
return SitesService.endSiteRender(parseInt(siteID), body);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
await Promise.all(promises);
|
|
176
|
+
|
|
177
|
+
logInfo(`Set pages as deployed. Total ${createdPages.length}`);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Generate sitemaps and save them into file system.
|
|
182
|
+
*
|
|
183
|
+
* @param sites An array of sites
|
|
184
|
+
*/
|
|
185
|
+
async function generateSitemaps(sites: Array<Site>) {
|
|
186
|
+
const promisesOfSites = sites.map(async (site) => {
|
|
187
|
+
const { id: siteID, languages } = site;
|
|
188
|
+
|
|
189
|
+
const promisesOfLanguages = languages.map(async (lang) => {
|
|
190
|
+
if (AuthService.headers) AuthService.headers["lang"] = lang.id.toString();
|
|
191
|
+
|
|
192
|
+
const response = await SitesService.getSitemap(siteID);
|
|
193
|
+
|
|
194
|
+
if (!response) return;
|
|
195
|
+
|
|
196
|
+
const {
|
|
197
|
+
items: sitemapPagesGroup,
|
|
198
|
+
url: { home },
|
|
199
|
+
} = response;
|
|
200
|
+
|
|
201
|
+
if (!home) return;
|
|
202
|
+
|
|
203
|
+
const langDomain = site.domains.find(
|
|
204
|
+
(domain) => Object.keys(domain)[0] == lang.id.toString()
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
if (!langDomain) return;
|
|
208
|
+
|
|
209
|
+
const slug = Object.values(langDomain)[0];
|
|
210
|
+
const sitemaps = [];
|
|
211
|
+
const sitemapPageGroupKeys = Object.keys(sitemapPagesGroup);
|
|
212
|
+
|
|
213
|
+
for (const templateId of sitemapPageGroupKeys) {
|
|
214
|
+
const sitemapPages = sitemapPagesGroup[templateId];
|
|
215
|
+
|
|
216
|
+
if (!sitemapPages.length) continue;
|
|
217
|
+
|
|
218
|
+
const siteMap = parse("urlset", {
|
|
219
|
+
"@": {
|
|
220
|
+
xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9",
|
|
221
|
+
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
|
|
222
|
+
"xsi:schemaLocation":
|
|
223
|
+
"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd",
|
|
224
|
+
},
|
|
225
|
+
url: sitemapPages,
|
|
226
|
+
});
|
|
227
|
+
const sitemapName = `/sitemap-${templateId.toLowerCase()}.xml`;
|
|
228
|
+
const exactPath = path.resolve(
|
|
229
|
+
__dirname,
|
|
230
|
+
`../../public/${slug}${sitemapName}`
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
saveFile(exactPath, siteMap);
|
|
234
|
+
|
|
235
|
+
sitemaps.push(
|
|
236
|
+
`${home.endsWith("/") ? home.slice(0, -1) : home}${sitemapName}`
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (!sitemaps.length) return;
|
|
241
|
+
|
|
242
|
+
const siteMap = parse("sitemapindex", {
|
|
243
|
+
"@": { xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9" },
|
|
244
|
+
sitemap: sitemaps.map((loc) => ({ loc })),
|
|
245
|
+
});
|
|
246
|
+
const exactPath = path.resolve(
|
|
247
|
+
__dirname,
|
|
248
|
+
`../../public/${slug}/sitemap.xml`
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
saveFile(exactPath, siteMap);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return Promise.all(promisesOfLanguages);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
await Promise.all(promisesOfSites);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Saves the content to a file specified by its path. If the file exists, it will be overwritten.
|
|
262
|
+
*
|
|
263
|
+
* @param filePath The path of the file to save the content to.
|
|
264
|
+
* @param content The content to save to the file.
|
|
265
|
+
*/
|
|
266
|
+
function saveFile(filePath: string, content: string) {
|
|
267
|
+
try {
|
|
268
|
+
fs.writeFileSync(filePath, content);
|
|
269
|
+
} catch (err) {
|
|
270
|
+
console.error(`Error saving file: ${err}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export {
|
|
275
|
+
checkSites,
|
|
276
|
+
unpublishSites,
|
|
277
|
+
setPagesRenderEnd,
|
|
278
|
+
getSiteData,
|
|
279
|
+
generateSitemaps,
|
|
280
|
+
};
|
package/.babelrc
DELETED
package/LICENSE
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
NO LICENSE YET
|
package/gatsby-browser.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/* eslint-disable node/no-extraneous-require */
|
|
2
|
-
/* eslint-disable node/no-missing-require */
|
|
3
|
-
const React = require('react');
|
|
4
|
-
const { browser } = require('components');
|
|
5
|
-
const { SessionProvider } = require('@griddo/core');
|
|
6
|
-
|
|
7
|
-
exports.disableCorePrefetching = () => {
|
|
8
|
-
if (browser.disableCorePrefetching) {
|
|
9
|
-
browser.disableCorePrefetching();
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
exports.onClientEntry = () => {
|
|
14
|
-
if (browser.onClientEntry) {
|
|
15
|
-
browser.onClientEntry();
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.onInitialClientRender = () => {
|
|
20
|
-
if (browser.onInitialClientRender) {
|
|
21
|
-
browser.onInitialClientRender();
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
exports.onPostPrefetchPathname = props => {
|
|
26
|
-
if (browser.onPostPrefetchPathname) {
|
|
27
|
-
browser.onPostPrefetchPathname(props);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
exports.onPreRouteUpdate = props => {
|
|
32
|
-
if (browser.onPreRouteUpdate) {
|
|
33
|
-
browser.onPreRouteUpdate(props);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
exports.onPrefetchPathname = props => {
|
|
38
|
-
if (browser.onPrefetchPathname) {
|
|
39
|
-
browser.onPrefetchPathname(props);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
exports.onRouteUpdateDelayed = props => {
|
|
44
|
-
if (browser.onServiceWorkerActive) {
|
|
45
|
-
browser.onRouteUpdateDelayed(props);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
exports.onServiceWorkerActive = props => {
|
|
50
|
-
if (browser.onServiceWorkerActive) {
|
|
51
|
-
browser.onServiceWorkerActive(props);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
exports.onServiceWorkerInstalled = props => {
|
|
56
|
-
if (browser.onServiceWorkerInstalled) {
|
|
57
|
-
browser.onServiceWorkerInstalled(props);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
exports.onServiceWorkerRedundant = props => {
|
|
62
|
-
if (browser.onServiceWorkerRedundant) {
|
|
63
|
-
browser.onServiceWorkerRedundant(props);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
exports.onServiceWorkerUpdateFound = props => {
|
|
68
|
-
if (browser.onServiceWorkerUpdateFound) {
|
|
69
|
-
browser.onServiceWorkerUpdateFound(props);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
exports.onServiceWorkerUpdateReady = props => {
|
|
74
|
-
if (browser.onServiceWorkerUpdateReady) {
|
|
75
|
-
browser.onServiceWorkerUpdateReady(props);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
exports.registerServiceWorker = () => {
|
|
80
|
-
if (browser.registerServiceWorker) {
|
|
81
|
-
browser.registerServiceWorker();
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
exports.replaceHydrateFunction = () => {
|
|
86
|
-
if (browser.replaceHydrateFunction) {
|
|
87
|
-
browser.replaceHydrateFunction();
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
exports.shouldUpdateScroll = props => {
|
|
92
|
-
if (browser.shouldUpdateScroll) {
|
|
93
|
-
browser.shouldUpdateScroll(props);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
exports.wrapPageElement = props => {
|
|
98
|
-
if (browser.wrapPageElement) {
|
|
99
|
-
return browser.wrapPageElement(props);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
exports.wrapRootElement = props => {
|
|
104
|
-
return (
|
|
105
|
-
<SessionProvider>
|
|
106
|
-
{browser.wrapRootElement ? browser.wrapRootElement(props) : props.element}
|
|
107
|
-
</SessionProvider>
|
|
108
|
-
);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
exports.onRouteUpdate = props => {
|
|
112
|
-
if (browser.onRouteUpdate) {
|
|
113
|
-
browser.onRouteUpdate(props);
|
|
114
|
-
}
|
|
115
|
-
};
|
package/gatsby-config.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const computils = require('./src/utils/component-lib-helpers');
|
|
2
|
-
|
|
3
|
-
require('dotenv').config();
|
|
4
|
-
|
|
5
|
-
const assetPrefix = process.env.ASSET_PREFIX || undefined;
|
|
6
|
-
|
|
7
|
-
// Gatsby configuration file from client
|
|
8
|
-
const { plugins, ...gatsbyConfig } = require(computils.resolveComponentsPath(
|
|
9
|
-
'builder.config.js'
|
|
10
|
-
));
|
|
11
|
-
|
|
12
|
-
const CONFIG = {
|
|
13
|
-
// cliente config
|
|
14
|
-
...gatsbyConfig,
|
|
15
|
-
plugins: [
|
|
16
|
-
// client plugins
|
|
17
|
-
...plugins,
|
|
18
|
-
|
|
19
|
-
// defaults plugins
|
|
20
|
-
'gatsby-plugin-provide-react',
|
|
21
|
-
'gatsby-plugin-react-svg',
|
|
22
|
-
'gatsby-plugin-react-helmet',
|
|
23
|
-
'gatsby-plugin-no-sourcemaps',
|
|
24
|
-
{
|
|
25
|
-
resolve: 'gatsby-plugin-remove-generator',
|
|
26
|
-
options: {
|
|
27
|
-
content: 'Griddo',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
if (assetPrefix) {
|
|
34
|
-
CONFIG.assetPrefix = assetPrefix;
|
|
35
|
-
CONFIG.pathPrefix = null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = CONFIG;
|