@griddo/cx 10.4.21 → 10.4.22
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/adapters/gatsby/utils.d.ts +21 -15
- package/build/browser/index.d.ts +1 -1
- package/build/browser/index.js +1 -1
- package/build/build-complete.js +20 -20
- package/build/index.js +28 -28
- package/build/reset-render.js +20 -20
- package/build/run-start-render.js +28 -28
- package/build/start-render.js +28 -28
- package/build/upload-search-content.js +23 -23
- package/build/utils/temp-utils.d.ts +11 -6
- package/exporter/adapters/gatsby/index.ts +10 -7
- package/exporter/adapters/gatsby/utils.ts +104 -20
- package/exporter/browser/index.ts +1 -1
- package/exporter/build-complete.ts +5 -5
- package/exporter/utils/temp-utils.ts +16 -67
- package/gatsby-config.ts +18 -5
- package/gatsby-node.ts +25 -10
- package/package.json +3 -3
- package/src/components/template.tsx +2 -1
- package/src/gatsby-node-utils.ts +2 -39
- package/src/types.ts +6 -7
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { CXConfig } from "../types/global";
|
|
2
|
+
declare const attempts: {
|
|
3
|
+
prepare: any;
|
|
4
|
+
restore: any;
|
|
5
|
+
data: any;
|
|
6
|
+
ssg: any;
|
|
7
|
+
relocation: any;
|
|
8
|
+
meta: any;
|
|
9
|
+
archive: any;
|
|
10
|
+
clean: any;
|
|
11
|
+
};
|
|
2
12
|
declare function getConfig(): CXConfig;
|
|
3
|
-
/**
|
|
4
|
-
* Update the Griddo's `/dist` dir with the contents from `public` dir only
|
|
5
|
-
* with files of type: js, json and css.
|
|
6
|
-
*/
|
|
7
|
-
declare function legacy__createDistFromGatsbyPublic(domain: string, needsAssetPrefix: boolean): Promise<void>;
|
|
8
13
|
declare function griddoCreateInitialDirectories(domain: string): Promise<void>;
|
|
9
14
|
declare function griddoCleanDisposableDirectories(domain: string): Promise<void>;
|
|
10
|
-
export { getConfig, griddoCleanDisposableDirectories, griddoCreateInitialDirectories,
|
|
15
|
+
export { attempts, getConfig, griddoCleanDisposableDirectories, griddoCreateInitialDirectories, };
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
gatsbyBuild,
|
|
6
|
+
getGatsbyAssetPrefixWithDomain,
|
|
7
|
+
legacy__createDistFromGatsbyPublic,
|
|
8
|
+
} from "./utils";
|
|
5
9
|
import { RobotsService } from "../../services/robots";
|
|
6
10
|
import { createBuildData } from "../../utils/create-build-data";
|
|
7
11
|
import { getInstanceDomains } from "../../utils/domains";
|
|
@@ -20,10 +24,7 @@ import {
|
|
|
20
24
|
printExporterLogo,
|
|
21
25
|
} from "../../utils/shared";
|
|
22
26
|
import { generateBuildReport, generateSitemaps } from "../../utils/sites";
|
|
23
|
-
import {
|
|
24
|
-
getConfig,
|
|
25
|
-
legacy__createDistFromGatsbyPublic,
|
|
26
|
-
} from "../../utils/temp-utils";
|
|
27
|
+
import { attempts, getConfig } from "../../utils/temp-utils";
|
|
27
28
|
|
|
28
29
|
async function runGatsbyAdapter() {
|
|
29
30
|
printExporterLogo("gatsby");
|
|
@@ -38,7 +39,9 @@ async function runGatsbyAdapter() {
|
|
|
38
39
|
|
|
39
40
|
logBox(`Initializing render for the domain ${domain}`, "", 1, 0);
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
// This variables are for both, create the dist directory from public
|
|
43
|
+
// and pass to the gatsby-build command via spawnSync.
|
|
44
|
+
const assetPrefix = getGatsbyAssetPrefixWithDomain(domain);
|
|
42
45
|
const needsAssetPrefix = !!assetPrefix && assetPrefix !== "";
|
|
43
46
|
|
|
44
47
|
/*
|
|
@@ -119,7 +122,7 @@ async function runGatsbyAdapter() {
|
|
|
119
122
|
await doLifeCycle({
|
|
120
123
|
name: "SSG",
|
|
121
124
|
attempts: attempts.ssg,
|
|
122
|
-
steps: [() => gatsbyBuild(
|
|
125
|
+
steps: [() => gatsbyBuild(assetPrefix), () => pause("SSG LifeCycle")],
|
|
123
126
|
});
|
|
124
127
|
|
|
125
128
|
/*
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { Fields } from "@griddo/core";
|
|
2
|
+
|
|
1
3
|
import { spawnSync } from "node:child_process";
|
|
4
|
+
import path from "node:path";
|
|
2
5
|
|
|
3
|
-
import { Fields } from "@griddo/core";
|
|
4
6
|
import dotenv from "dotenv";
|
|
7
|
+
import fsx from "fs-extra";
|
|
5
8
|
|
|
6
9
|
import { getConfig } from "../../utils/temp-utils";
|
|
7
10
|
|
|
@@ -9,23 +12,16 @@ dotenv.config();
|
|
|
9
12
|
|
|
10
13
|
const config = getConfig();
|
|
11
14
|
|
|
12
|
-
const attempts = {
|
|
13
|
-
prepare: JSON.parse(process.env.GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
14
|
-
restore: JSON.parse(process.env.GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
15
|
-
data: JSON.parse(process.env.GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
16
|
-
ssg: JSON.parse(process.env.GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
17
|
-
relocation: JSON.parse(
|
|
18
|
-
process.env.GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS || "1"
|
|
19
|
-
),
|
|
20
|
-
meta: JSON.parse(process.env.GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
21
|
-
archive: JSON.parse(process.env.GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
22
|
-
clean: JSON.parse(process.env.GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
15
|
/**
|
|
26
|
-
* Return the assetPrefix
|
|
16
|
+
* Return the assetPrefix with the domain concatenated `assetPrefix/domain` only
|
|
17
|
+
* if the domain is "pro-" **and** there is a env `GRIDDO_ASSET_PREFIX` with any
|
|
18
|
+
* value different from `null`, `undefined` or `empty string`
|
|
19
|
+
*
|
|
20
|
+
* else...
|
|
21
|
+
* - If assetPrefix or domain is falsy, returns ""
|
|
22
|
+
* - If the domain is not "pro-", returns ""
|
|
27
23
|
*/
|
|
28
|
-
function
|
|
24
|
+
function getGatsbyAssetPrefixWithDomain(domain: string) {
|
|
29
25
|
const { proDomain } = getConfig();
|
|
30
26
|
const assetPrefix =
|
|
31
27
|
process.env.GRIDDO_ASSET_PREFIX || process.env.ASSET_PREFIX;
|
|
@@ -33,6 +29,18 @@ function getGatsbyAssetPrefixSlug(domain: string) {
|
|
|
33
29
|
if (!assetPrefix || !domain) return "";
|
|
34
30
|
if (!domain.startsWith(proDomain)) return "";
|
|
35
31
|
|
|
32
|
+
if (process.env.GRIDDO_DEBUG_LOGS) {
|
|
33
|
+
console.log();
|
|
34
|
+
console.log("-- getGatsbyAssetPrefixWithDomain() --");
|
|
35
|
+
console.log(
|
|
36
|
+
"process.env.GRIDDO_ASSET_PREFIX",
|
|
37
|
+
process.env.GRIDDO_ASSET_PREFIX
|
|
38
|
+
);
|
|
39
|
+
console.log("assetPrefix", assetPrefix);
|
|
40
|
+
console.log("return", `${assetPrefix}/${domain}`);
|
|
41
|
+
console.log();
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
return `${assetPrefix}/${domain}`;
|
|
37
45
|
}
|
|
38
46
|
|
|
@@ -86,8 +94,17 @@ function addCloudinaryParams(image: string, params: string) {
|
|
|
86
94
|
return `https://${head}/${params}${fullId}`;
|
|
87
95
|
}
|
|
88
96
|
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Spawn a new node process `yarn gatsby-build`
|
|
99
|
+
* @note This proccess (`yarn gatsby-build`) can not access to the custom Griddo
|
|
100
|
+
* `process.env` so it needs variables passed to it via the `env` prop.
|
|
101
|
+
*/
|
|
102
|
+
function gatsbyBuild(assetPrefixWithDomain: string) {
|
|
103
|
+
if (process.env.GRIDDO_DEBUG_LOGS) {
|
|
104
|
+
console.log("-- gatsbyBuild() --");
|
|
105
|
+
console.log("assetPrefixWithDomain", assetPrefixWithDomain);
|
|
106
|
+
}
|
|
107
|
+
|
|
91
108
|
const { __ssg } = config.paths();
|
|
92
109
|
|
|
93
110
|
const command = spawnSync("yarn", ["gatsby-build"], {
|
|
@@ -97,7 +114,7 @@ function gatsbyBuild(domain: string) {
|
|
|
97
114
|
shell: true,
|
|
98
115
|
env: Object.assign(process.env, {
|
|
99
116
|
GRIDDO_EXPORTER: "true",
|
|
100
|
-
|
|
117
|
+
SPAWN_ASSET_PREFIX_WITH_DOMAIN: assetPrefixWithDomain,
|
|
101
118
|
}),
|
|
102
119
|
});
|
|
103
120
|
|
|
@@ -106,4 +123,71 @@ function gatsbyBuild(domain: string) {
|
|
|
106
123
|
}
|
|
107
124
|
}
|
|
108
125
|
|
|
109
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Update the Griddo's `/dist` dir with the contents from `public` dir only
|
|
128
|
+
* with files of type: js, json and css.
|
|
129
|
+
*/
|
|
130
|
+
async function legacy__createDistFromGatsbyPublic(
|
|
131
|
+
domain: string,
|
|
132
|
+
needsAssetPrefix: boolean
|
|
133
|
+
) {
|
|
134
|
+
const { __cx, __ssg } = config.paths(domain);
|
|
135
|
+
|
|
136
|
+
const cxDistDir = path.join(__cx, "dist");
|
|
137
|
+
const cxAssetsDir = path.join(__cx, "assets");
|
|
138
|
+
const cxDistDirWithDomain = path.join(__cx, "dist", domain);
|
|
139
|
+
const publicDir = path.join(__ssg, "public");
|
|
140
|
+
|
|
141
|
+
console.log(publicDir);
|
|
142
|
+
const validFilesFromPublic = fsx
|
|
143
|
+
.readdirSync(publicDir)
|
|
144
|
+
.filter(
|
|
145
|
+
(file) =>
|
|
146
|
+
path.extname(file) === ".js" ||
|
|
147
|
+
path.extname(file) === ".json" ||
|
|
148
|
+
path.extname(file) === ".css"
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const pageDataSrc = `${publicDir}/page-data`;
|
|
152
|
+
const pageDataDest = `${cxAssetsDir}/page-data`;
|
|
153
|
+
|
|
154
|
+
const projectStaticSrc = path.join(__ssg, "static");
|
|
155
|
+
const projectStaticDest = cxAssetsDir;
|
|
156
|
+
|
|
157
|
+
const gatsbyStaticSrc = `${cxDistDir}/static`;
|
|
158
|
+
const gatsbyStaticDest = `${cxAssetsDir}/static`;
|
|
159
|
+
|
|
160
|
+
try {
|
|
161
|
+
fsx.mkdirSync(cxAssetsDir, { recursive: true });
|
|
162
|
+
fsx.copySync(publicDir, cxDistDir);
|
|
163
|
+
|
|
164
|
+
if (needsAssetPrefix) {
|
|
165
|
+
fsx.copySync(pageDataSrc, pageDataDest);
|
|
166
|
+
if (fsx.existsSync(projectStaticSrc)) {
|
|
167
|
+
fsx.copySync(projectStaticSrc, projectStaticDest, { overwrite: false });
|
|
168
|
+
}
|
|
169
|
+
fsx.copySync(gatsbyStaticSrc, gatsbyStaticDest, { overwrite: false });
|
|
170
|
+
if (fsx.existsSync(projectStaticSrc)) {
|
|
171
|
+
fsx.copySync(projectStaticSrc, cxDistDirWithDomain, {
|
|
172
|
+
overwrite: false,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Copia el resto de archivos...
|
|
177
|
+
validFilesFromPublic.map(async (file) => {
|
|
178
|
+
const fileSrc = `${publicDir}/${file}`;
|
|
179
|
+
const fileDest = `${cxAssetsDir}/${file}`;
|
|
180
|
+
fsx.copySync(fileSrc, fileDest);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
} catch (err) {
|
|
184
|
+
console.error(err);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export {
|
|
189
|
+
formatImage,
|
|
190
|
+
gatsbyBuild,
|
|
191
|
+
getGatsbyAssetPrefixWithDomain,
|
|
192
|
+
legacy__createDistFromGatsbyPublic,
|
|
193
|
+
};
|
|
@@ -34,15 +34,15 @@ type Report = {
|
|
|
34
34
|
export async function buildComplete(report: Report) {
|
|
35
35
|
await AuthService.login();
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const sites = report.sites;
|
|
38
|
+
|
|
39
|
+
for (const site of sites) {
|
|
38
40
|
const { siteId, ...body } = site;
|
|
39
41
|
|
|
40
42
|
console.info(`Deploying ending call to site ${siteId}:`);
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
await Promise.all(promises);
|
|
44
|
+
await SitesService.endSiteRender(siteId, body);
|
|
45
|
+
}
|
|
46
46
|
|
|
47
47
|
console.info(`Build end's signal sent for ${report.sites.length} site(s)`);
|
|
48
48
|
}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import fsx from "fs-extra";
|
|
1
|
+
import dotenv from "dotenv";
|
|
4
2
|
|
|
5
3
|
import { createDirsSync, removeDirsSync } from "./folders";
|
|
6
4
|
import { CXConfig } from "../types/global";
|
|
7
|
-
|
|
5
|
+
dotenv.config();
|
|
8
6
|
const config = getConfig();
|
|
9
7
|
|
|
8
|
+
const attempts = {
|
|
9
|
+
prepare: JSON.parse(process.env.GRIDDO_PREPARE_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
10
|
+
restore: JSON.parse(process.env.GRIDDO_RESTORE_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
11
|
+
data: JSON.parse(process.env.GRIDDO_DATA_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
12
|
+
ssg: JSON.parse(process.env.GRIDDO_SSG_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
13
|
+
relocation: JSON.parse(
|
|
14
|
+
process.env.GRIDDO_RELOCATION_LIFECYCLE_MAX_ATTEMPTS || "1"
|
|
15
|
+
),
|
|
16
|
+
meta: JSON.parse(process.env.GRIDDO_META_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
17
|
+
archive: JSON.parse(process.env.GRIDDO_ARCHIVE_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
18
|
+
clean: JSON.parse(process.env.GRIDDO_CLEAN_LIFECYCLE_MAX_ATTEMPTS || "1"),
|
|
19
|
+
};
|
|
20
|
+
|
|
10
21
|
function getConfig(): CXConfig {
|
|
11
22
|
try {
|
|
12
23
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, node/no-missing-require, node/no-unpublished-require
|
|
@@ -20,68 +31,6 @@ function getConfig(): CXConfig {
|
|
|
20
31
|
}
|
|
21
32
|
}
|
|
22
33
|
|
|
23
|
-
/**
|
|
24
|
-
* Update the Griddo's `/dist` dir with the contents from `public` dir only
|
|
25
|
-
* with files of type: js, json and css.
|
|
26
|
-
*/
|
|
27
|
-
async function legacy__createDistFromGatsbyPublic(
|
|
28
|
-
domain: string,
|
|
29
|
-
needsAssetPrefix: boolean
|
|
30
|
-
) {
|
|
31
|
-
const { __cx, __ssg } = config.paths(domain);
|
|
32
|
-
|
|
33
|
-
const cxDistDir = path.join(__cx, "dist");
|
|
34
|
-
const cxAssetsDir = path.join(__cx, "assets");
|
|
35
|
-
const cxDistDirWithDomain = path.join(__cx, "dist", domain);
|
|
36
|
-
const publicDir = path.join(__ssg, "public");
|
|
37
|
-
|
|
38
|
-
console.log(publicDir);
|
|
39
|
-
const validFilesFromPublic = fsx
|
|
40
|
-
.readdirSync(publicDir)
|
|
41
|
-
.filter(
|
|
42
|
-
(file) =>
|
|
43
|
-
path.extname(file) === ".js" ||
|
|
44
|
-
path.extname(file) === ".json" ||
|
|
45
|
-
path.extname(file) === ".css"
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const pageDataSrc = `${publicDir}/page-data`;
|
|
49
|
-
const pageDataDest = `${cxAssetsDir}/page-data`;
|
|
50
|
-
|
|
51
|
-
const projectStaticSrc = path.join(__ssg, "static");
|
|
52
|
-
const projectStaticDest = cxAssetsDir;
|
|
53
|
-
|
|
54
|
-
const gatsbyStaticSrc = `${cxDistDir}/static`;
|
|
55
|
-
const gatsbyStaticDest = `${cxAssetsDir}/static`;
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
fsx.mkdirSync(cxAssetsDir, { recursive: true });
|
|
59
|
-
fsx.copySync(publicDir, cxDistDir);
|
|
60
|
-
|
|
61
|
-
if (needsAssetPrefix) {
|
|
62
|
-
fsx.copySync(pageDataSrc, pageDataDest);
|
|
63
|
-
if (fsx.existsSync(projectStaticSrc)) {
|
|
64
|
-
fsx.copySync(projectStaticSrc, projectStaticDest, { overwrite: false });
|
|
65
|
-
}
|
|
66
|
-
fsx.copySync(gatsbyStaticSrc, gatsbyStaticDest, { overwrite: false });
|
|
67
|
-
if (fsx.existsSync(projectStaticSrc)) {
|
|
68
|
-
fsx.copySync(projectStaticSrc, cxDistDirWithDomain, {
|
|
69
|
-
overwrite: false,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Copia el resto de archivos...
|
|
74
|
-
validFilesFromPublic.map(async (file) => {
|
|
75
|
-
const fileSrc = `${publicDir}/${file}`;
|
|
76
|
-
const fileDest = `${cxAssetsDir}/${file}`;
|
|
77
|
-
fsx.copySync(fileSrc, fileDest);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
} catch (err) {
|
|
81
|
-
console.error(err);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
34
|
async function griddoCreateInitialDirectories(domain: string) {
|
|
86
35
|
const { __exports, __caches } = config.paths(domain);
|
|
87
36
|
|
|
@@ -96,8 +45,8 @@ async function griddoCleanDisposableDirectories(domain: string) {
|
|
|
96
45
|
}
|
|
97
46
|
|
|
98
47
|
export {
|
|
48
|
+
attempts,
|
|
99
49
|
getConfig,
|
|
100
50
|
griddoCleanDisposableDirectories,
|
|
101
51
|
griddoCreateInitialDirectories,
|
|
102
|
-
legacy__createDistFromGatsbyPublic,
|
|
103
52
|
};
|
package/gatsby-config.ts
CHANGED
|
@@ -6,9 +6,22 @@ import { resolveComponentsPath } from "./build";
|
|
|
6
6
|
|
|
7
7
|
dotenv.config();
|
|
8
8
|
|
|
9
|
-
// Este process.env.
|
|
10
|
-
//
|
|
11
|
-
|
|
9
|
+
// Este process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN se lee porque
|
|
10
|
+
// se ha introducido en el spawnSync.
|
|
11
|
+
// @todo quiar el `... || undefined`
|
|
12
|
+
const griddoAssetPrefixWithDomain =
|
|
13
|
+
process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN || undefined;
|
|
14
|
+
|
|
15
|
+
if (process.env.GRIDDO_DEBUG_LOGS) {
|
|
16
|
+
console.log();
|
|
17
|
+
console.log("-- gatsby-config.ts --");
|
|
18
|
+
console.log(
|
|
19
|
+
"process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN",
|
|
20
|
+
process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN
|
|
21
|
+
);
|
|
22
|
+
console.log("griddoAssetPrefixWithDomain", griddoAssetPrefixWithDomain);
|
|
23
|
+
console.log();
|
|
24
|
+
}
|
|
12
25
|
|
|
13
26
|
// Gatsby configuration file from client
|
|
14
27
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
@@ -40,8 +53,8 @@ const config: GatsbyConfig = {
|
|
|
40
53
|
],
|
|
41
54
|
};
|
|
42
55
|
|
|
43
|
-
if (
|
|
44
|
-
config.assetPrefix =
|
|
56
|
+
if (griddoAssetPrefixWithDomain) {
|
|
57
|
+
config.assetPrefix = griddoAssetPrefixWithDomain;
|
|
45
58
|
// @ts-expect-error Must be null to exist, but must be different from assetPrefix
|
|
46
59
|
config.pathPrefix = null;
|
|
47
60
|
}
|
package/gatsby-node.ts
CHANGED
|
@@ -5,31 +5,46 @@ import path from "node:path";
|
|
|
5
5
|
|
|
6
6
|
import { getConfig, logInfo, logPageSize } from "./build";
|
|
7
7
|
import { getBuildPagesFromStore } from "./exporter/utils/store";
|
|
8
|
-
import { getMatchPath } from "./src/gatsby-node-utils";
|
|
9
8
|
|
|
10
|
-
const
|
|
9
|
+
const griddoBuildLogs = JSON.parse(process.env.GRIDDO_BUILD_LOGS || "false");
|
|
10
|
+
const assetPrefixWithDomain = process.env.SPAWN_ASSET_PREFIX_WITH_DOMAIN;
|
|
11
|
+
const needsAssetDomainPrefix =
|
|
12
|
+
!!assetPrefixWithDomain && assetPrefixWithDomain !== "";
|
|
13
|
+
|
|
14
|
+
if (process.env.GRIDDO_DEBUG_LOGS) {
|
|
15
|
+
console.log();
|
|
16
|
+
console.log("-- gatsby-node.ts --");
|
|
17
|
+
console.log("assetPrefixWithDomain", assetPrefixWithDomain);
|
|
18
|
+
console.log("needsAssetDomainPrefix", needsAssetDomainPrefix);
|
|
19
|
+
console.log();
|
|
20
|
+
}
|
|
11
21
|
|
|
12
22
|
const { __ssg } = getConfig().paths();
|
|
13
23
|
const template = path.join(__ssg, "src/components/template.tsx");
|
|
14
24
|
const pages = getBuildPagesFromStore<GatsbyPageObject>({
|
|
15
|
-
withSizeProp:
|
|
25
|
+
withSizeProp: griddoBuildLogs,
|
|
16
26
|
});
|
|
17
27
|
|
|
18
28
|
const createPages: GatsbyNode["createPages"] = async ({ actions }) => {
|
|
19
29
|
for await (const page of pages) {
|
|
20
30
|
if (!page) return;
|
|
21
31
|
|
|
22
|
-
const matchPath = getMatchPath(
|
|
23
|
-
page.context.fullPath.domain,
|
|
24
|
-
page.context.fullPath.compose
|
|
25
|
-
);
|
|
26
|
-
|
|
27
32
|
page.component = template;
|
|
28
|
-
page.matchPath =
|
|
33
|
+
page.matchPath = needsAssetDomainPrefix
|
|
34
|
+
? page.context.fullPath.compose
|
|
35
|
+
: "";
|
|
36
|
+
|
|
37
|
+
if (process.env.GRIDDO_DEBUG_LOGS) {
|
|
38
|
+
console.log("-- createPages --");
|
|
39
|
+
console.log(
|
|
40
|
+
"matchPath",
|
|
41
|
+
needsAssetDomainPrefix ? page.context.fullPath.compose : ""
|
|
42
|
+
);
|
|
43
|
+
}
|
|
29
44
|
|
|
30
45
|
actions.createPage(page);
|
|
31
46
|
|
|
32
|
-
if (
|
|
47
|
+
if (griddoBuildLogs) {
|
|
33
48
|
const path = page.path;
|
|
34
49
|
const id = page.context.id;
|
|
35
50
|
const size = logPageSize(Math.round(page.size || 0));
|
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": "10.4.
|
|
4
|
+
"version": "10.4.22",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@babel/preset-env": "^7.14.5",
|
|
46
46
|
"@babel/preset-react": "^7.14.5",
|
|
47
47
|
"@babel/preset-typescript": "^7.16.5",
|
|
48
|
-
"@griddo/core": "^10.4.
|
|
48
|
+
"@griddo/core": "^10.4.22",
|
|
49
49
|
"@svgr/webpack": "^5.5.0",
|
|
50
50
|
"@types/cheerio": "^0.22.35",
|
|
51
51
|
"babel-loader": "^8.0.6",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"resolutions": {
|
|
121
121
|
"memoizee": "0.4.15"
|
|
122
122
|
},
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "dcf2ff097694c07588c2fc14c0e5934d2d675220"
|
|
124
124
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TemplateProps } from "../types";
|
|
2
|
+
import type { Core } from "@griddo/core";
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
+
import { Page as RenderGriddoPage } from "@griddo/core";
|
|
4
5
|
import { components, SiteProvider, templates } from "@griddo-instance";
|
|
5
6
|
import { Link, navigate } from "gatsby";
|
|
6
7
|
import parse from "html-react-parser";
|
package/src/gatsby-node-utils.ts
CHANGED
|
@@ -2,12 +2,11 @@ import type { GatsbyNode } from "gatsby";
|
|
|
2
2
|
|
|
3
3
|
import fs from "fs-extra";
|
|
4
4
|
|
|
5
|
-
import { getConfig } from "../build";
|
|
6
5
|
import {
|
|
7
6
|
IS_COMPONENT_LIBRARY,
|
|
8
7
|
PROJECT_ALIASES,
|
|
9
8
|
resolveComponentsPath,
|
|
10
|
-
} from "../
|
|
9
|
+
} from "../build";
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Copy the instance's `/static` dir into the Gatsby's to include it in the render assets.
|
|
@@ -72,40 +71,4 @@ const onCreateWebpackConfig: GatsbyNode["onCreateWebpackConfig"] = ({
|
|
|
72
71
|
}
|
|
73
72
|
};
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
const { proDomain } = getConfig();
|
|
77
|
-
|
|
78
|
-
const assetPrefix =
|
|
79
|
-
process.env.GRIDDO_ASSET_PREFIX || process.env.ASSET_PREFIX;
|
|
80
|
-
if (!assetPrefix || !domain) return "";
|
|
81
|
-
if (!domain.startsWith(proDomain)) return "";
|
|
82
|
-
|
|
83
|
-
return `${assetPrefix}/${domain}`;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// @todo: Arreglar esta movida de variables de entorno locales solo para Gatsby
|
|
87
|
-
function getLocalGatsbyAssetPrefixSlug(domain: string) {
|
|
88
|
-
const { proDomain } = getConfig();
|
|
89
|
-
|
|
90
|
-
const assetPrefix = process.env.LOCAL_GRIDDO_ASSET_PREFIX;
|
|
91
|
-
if (!assetPrefix || !domain) return "";
|
|
92
|
-
if (!domain.startsWith(proDomain)) return "";
|
|
93
|
-
|
|
94
|
-
return `${assetPrefix}/${domain}`;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function getMatchPath(domain: string, compose: string) {
|
|
98
|
-
const domainWithNoSlashes = domain.replace("/", "");
|
|
99
|
-
const assetPrefix = getLocalGatsbyAssetPrefixSlug(domainWithNoSlashes);
|
|
100
|
-
const needsAssetDomainPrefix = assetPrefix && assetPrefix !== "";
|
|
101
|
-
const matchPath = needsAssetDomainPrefix ? compose : "";
|
|
102
|
-
|
|
103
|
-
return matchPath;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export {
|
|
107
|
-
getGatsbyAssetPrefixSlug,
|
|
108
|
-
getMatchPath,
|
|
109
|
-
onCreateWebpackConfig,
|
|
110
|
-
prepareStaticDir,
|
|
111
|
-
};
|
|
74
|
+
export { onCreateWebpackConfig, prepareStaticDir };
|
package/src/types.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { HeadProps } from "gatsby";
|
|
3
|
-
|
|
4
|
-
import { SocialsResponse } from "../build";
|
|
5
|
-
import {
|
|
1
|
+
import type {
|
|
6
2
|
AdditionalInfo,
|
|
7
3
|
GriddoListPage,
|
|
8
4
|
GriddoMultiPage,
|
|
9
5
|
GriddoPageObject,
|
|
10
6
|
GriddoSinglePage,
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
Site,
|
|
8
|
+
SocialsResponse,
|
|
9
|
+
} from "../build";
|
|
10
|
+
import type { Core } from "@griddo/core";
|
|
11
|
+
import type { HeadProps } from "gatsby";
|
|
13
12
|
|
|
14
13
|
interface CustomHeadProps extends HeadProps {
|
|
15
14
|
pageContext: GriddoPageObject["context"] & {
|