@griddo/cx 10.4.22 → 10.4.23
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 +2 -2
- package/build/build-complete.js +19 -19
- package/build/index.d.ts +2 -3
- package/build/index.js +29 -33
- package/build/react/Foo/index.d.ts +3 -0
- package/build/react/index.d.ts +1 -1
- package/build/react/index.js +1 -0
- package/build/reset-render.js +19 -19
- package/build/run-start-render.js +28 -32
- package/build/start-render.js +27 -31
- package/build/types/global.d.ts +1 -0
- package/build/upload-search-content.js +24 -24
- package/build/utils/{shared.d.ts → core-utils.d.ts} +44 -2
- package/build/utils/folders.d.ts +6 -1
- package/build/utils/store.d.ts +1 -1
- package/cx.config.js +7 -0
- package/exporter/adapters/gatsby/index.ts +60 -10
- package/exporter/adapters/gatsby/utils.ts +33 -32
- package/exporter/index.ts +6 -5
- package/exporter/react/Foo/index.tsx +7 -0
- package/exporter/react/index.tsx +3 -0
- package/exporter/services/distributors.ts +1 -1
- package/exporter/services/robots.ts +1 -1
- package/exporter/services/store.ts +9 -16
- package/exporter/start-render.ts +1 -1
- package/exporter/types/global.ts +1 -0
- package/exporter/utils/api.ts +1 -1
- package/exporter/utils/cache.ts +1 -1
- package/exporter/utils/{shared.ts → core-utils.ts} +120 -20
- package/exporter/utils/create-build-data.ts +1 -1
- package/exporter/utils/domains.ts +3 -0
- package/exporter/utils/folders.ts +38 -2
- package/exporter/utils/health-checks.ts +1 -1
- package/exporter/utils/searches.ts +1 -1
- package/exporter/utils/sites.ts +12 -18
- package/exporter/utils/store.ts +2 -3
- package/gatsby-config.ts +2 -11
- package/gatsby-node.ts +13 -19
- package/package.json +8 -5
- package/build/utils/temp-utils.d.ts +0 -15
- package/exporter/react/index.ts +0 -5
- package/exporter/utils/temp-utils.ts +0 -52
|
@@ -1,8 +1,50 @@
|
|
|
1
1
|
import type { Adapters } from "../adapters";
|
|
2
2
|
import type { APIResponses } from "../types/api";
|
|
3
|
-
import type { LifeCyclesNames } from "../types/global";
|
|
3
|
+
import type { CXConfig, LifeCyclesNames } from "../types/global";
|
|
4
4
|
import type { Site } from "../types/sites";
|
|
5
5
|
declare const instanceRootDir: string;
|
|
6
|
+
declare const attempts: {
|
|
7
|
+
clean: any;
|
|
8
|
+
prepare: any;
|
|
9
|
+
restore: any;
|
|
10
|
+
data: any;
|
|
11
|
+
ssg: any;
|
|
12
|
+
relocation: any;
|
|
13
|
+
meta: any;
|
|
14
|
+
archive: any;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Returns the configuration file content.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const config = getConfig()
|
|
21
|
+
* const { __cx } = config.paths()
|
|
22
|
+
* const { griddoVersion, proDomain } = config
|
|
23
|
+
*/
|
|
24
|
+
declare function getConfig(): CXConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Create the initial mandatory directories for a render.
|
|
27
|
+
*
|
|
28
|
+
* @param domain The current domain in render.
|
|
29
|
+
*/
|
|
30
|
+
declare function exporterCreateInitialDirectories(domain: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Remove trash directories from __cx, maybe from a failed render.
|
|
33
|
+
*
|
|
34
|
+
* @param domain The current domain in render.
|
|
35
|
+
*/
|
|
36
|
+
declare function exporterCleanDisposableDirectories(domain: string): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Custom basic logging function controlled by a environment variable.
|
|
39
|
+
*
|
|
40
|
+
* @param str The string to be logged.
|
|
41
|
+
*/
|
|
42
|
+
declare function verbose(str: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Returns true for `true`, true, positive numbers
|
|
45
|
+
* Returns false for `false`, false, 0, negative integers and anything else
|
|
46
|
+
*/
|
|
47
|
+
declare function isTruthy(value: any): boolean;
|
|
6
48
|
/**
|
|
7
49
|
* Walk a directory and returns the file pathts.
|
|
8
50
|
*
|
|
@@ -107,4 +149,4 @@ declare function doLifeCycle(args: {
|
|
|
107
149
|
}): Promise<void>;
|
|
108
150
|
declare function isVersionGreaterThan(versionA: string, versionB: string): boolean;
|
|
109
151
|
declare function isVersionLowerThan(versionA: string, versionB: string): boolean;
|
|
110
|
-
export { debug, delay, doLifeCycle, instanceRootDir, isVersionGreaterThan, isVersionLowerThan, logBox, logInfo, logPageSize, measureExecutionTime, pause, printExporterLogo, removeProperties, sanitizeAPICacheDir, siteList, startLifeCycle, successLifeCyle, walk, };
|
|
152
|
+
export { attempts, debug, delay, doLifeCycle, exporterCleanDisposableDirectories, exporterCreateInitialDirectories, getConfig, instanceRootDir, isTruthy, isVersionGreaterThan, isVersionLowerThan, logBox, logInfo, logPageSize, measureExecutionTime, pause, printExporterLogo, removeProperties, sanitizeAPICacheDir, siteList, startLifeCycle, successLifeCyle, verbose, walk, };
|
package/build/utils/folders.d.ts
CHANGED
|
@@ -45,4 +45,9 @@ declare function moveDirsSync(src: string, dst: string, dirs: Array<string>, opt
|
|
|
45
45
|
*/
|
|
46
46
|
declare function removeDirsSync(basePath: string, dirs: Array<string>): void;
|
|
47
47
|
declare function removeVirtualPagesFromStore(): Promise<void>;
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Remove every .xml file in the directories in a recursive way
|
|
50
|
+
* @param initialFolder - The initial folder to start the searching...
|
|
51
|
+
*/
|
|
52
|
+
declare function clearSitemapsFromDirs(initialFolder: string): void;
|
|
53
|
+
export { clearEmptyDirs, clearSitemapsFromDirs, copyDirsSync, createDirsSync, moveDirsSync, removeDirsSync, removeVirtualPagesFromStore, };
|
package/build/utils/store.d.ts
CHANGED
|
@@ -76,4 +76,4 @@ declare function getPagesToCreateOrDelete(storeDir: string, sitePages: {
|
|
|
76
76
|
pagesToDeleteFromStore: number[];
|
|
77
77
|
pagesToWriteToStore: number[];
|
|
78
78
|
}>;
|
|
79
|
-
export { createStoreDir, getBuildMetadata,
|
|
79
|
+
export { createStoreDir, getBuildMetadata, getBuildPagesFromCachedStore, getBuildPagesFromStore, getBuildPagesPath, getPageInStoreDir, getPagesToCreateOrDelete, removePagesFromStore, savePagesInStore, saveRenderInfoInStore, };
|
package/cx.config.js
CHANGED
|
@@ -12,8 +12,15 @@ const CX_CACHE_DIR = path.resolve(CX_ROOT_DIR, "caches");
|
|
|
12
12
|
const COMPONENTS_DIR = resolveComponentsPath();
|
|
13
13
|
const EXPORTS_DIR = path.join(REPO_ROOT_DIR, "exports/sites");
|
|
14
14
|
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
16
|
+
const { version: griddoVersion } = require(path.join(
|
|
17
|
+
CX_ROOT_DIR,
|
|
18
|
+
"package.json"
|
|
19
|
+
));
|
|
20
|
+
|
|
15
21
|
const config = {
|
|
16
22
|
proDomain: "pro-",
|
|
23
|
+
griddoVersion,
|
|
17
24
|
CXDir: {
|
|
18
25
|
EXPORTS: "__exports",
|
|
19
26
|
CACHE: "__caches",
|
|
@@ -2,11 +2,20 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
gatsbyBuild,
|
|
6
5
|
getGatsbyAssetPrefixWithDomain,
|
|
7
6
|
legacy__createDistFromGatsbyPublic,
|
|
7
|
+
runGatsbyBuildCommand,
|
|
8
8
|
} from "./utils";
|
|
9
9
|
import { RobotsService } from "../../services/robots";
|
|
10
|
+
import {
|
|
11
|
+
attempts,
|
|
12
|
+
doLifeCycle,
|
|
13
|
+
getConfig,
|
|
14
|
+
logBox,
|
|
15
|
+
pause,
|
|
16
|
+
printExporterLogo,
|
|
17
|
+
verbose,
|
|
18
|
+
} from "../../utils/core-utils";
|
|
10
19
|
import { createBuildData } from "../../utils/create-build-data";
|
|
11
20
|
import { getInstanceDomains } from "../../utils/domains";
|
|
12
21
|
import {
|
|
@@ -17,14 +26,7 @@ import {
|
|
|
17
26
|
removeDirsSync,
|
|
18
27
|
removeVirtualPagesFromStore,
|
|
19
28
|
} from "../../utils/folders";
|
|
20
|
-
import {
|
|
21
|
-
doLifeCycle,
|
|
22
|
-
logBox,
|
|
23
|
-
pause,
|
|
24
|
-
printExporterLogo,
|
|
25
|
-
} from "../../utils/shared";
|
|
26
29
|
import { generateBuildReport, generateSitemaps } from "../../utils/sites";
|
|
27
|
-
import { attempts, getConfig } from "../../utils/temp-utils";
|
|
28
30
|
|
|
29
31
|
async function runGatsbyAdapter() {
|
|
30
32
|
printExporterLogo("gatsby");
|
|
@@ -55,7 +57,15 @@ async function runGatsbyAdapter() {
|
|
|
55
57
|
attempts: attempts.clean,
|
|
56
58
|
steps: [
|
|
57
59
|
() => removeDirsSync(__cx, ["store", "apiCache", "dist"]),
|
|
60
|
+
() =>
|
|
61
|
+
verbose(
|
|
62
|
+
"clean `store`, `apiCache` and `dist` directories from `__cx`"
|
|
63
|
+
),
|
|
58
64
|
() => removeDirsSync(__ssg, ["dist", "public", "static", ".cache"]),
|
|
65
|
+
() =>
|
|
66
|
+
verbose(
|
|
67
|
+
"clean `dist`, `public`, `static` and `.cache` directories from `__ssg`"
|
|
68
|
+
),
|
|
59
69
|
() => pause("Clean LifeCycle"),
|
|
60
70
|
],
|
|
61
71
|
});
|
|
@@ -71,8 +81,10 @@ async function runGatsbyAdapter() {
|
|
|
71
81
|
attempts: attempts.prepare,
|
|
72
82
|
steps: [
|
|
73
83
|
() => createDirsSync([__exports]),
|
|
84
|
+
() => verbose("create `exports/sites/<domain>` directory"),
|
|
74
85
|
() => createDirsSync([__caches]),
|
|
75
|
-
() =>
|
|
86
|
+
() => verbose("create `caches/<domain>` directory"),
|
|
87
|
+
() => pause("prepare LifeCycle"),
|
|
76
88
|
],
|
|
77
89
|
});
|
|
78
90
|
|
|
@@ -85,8 +97,17 @@ async function runGatsbyAdapter() {
|
|
|
85
97
|
steps: [
|
|
86
98
|
// Copy instance static directory into the gatsby one.
|
|
87
99
|
() => copyDirsSync(__components, __ssg, ["static"]),
|
|
100
|
+
() => verbose("copy `static` directory from `__components` to `__ssg`"),
|
|
88
101
|
() => copyDirsSync(__exports, __cx, ["assets"]),
|
|
102
|
+
() => verbose("copy `assets` directory from `__exports` to `__cx`"),
|
|
89
103
|
() => copyDirsSync(__exports, __ssg, ["dist"]),
|
|
104
|
+
// Eliminamos archivos de sitemaps para que Gatsby no los tenga
|
|
105
|
+
// en cuenta y evitar que se invalide el caché de HTMLs.
|
|
106
|
+
// De todas maneras estos .xml se generan siempre en cada
|
|
107
|
+
// render, y si hay algún problema no pasa nada porque se están
|
|
108
|
+
// eliminando los sitemaps de la copia de dist en el directorio
|
|
109
|
+
// de __cx.
|
|
110
|
+
// () => clearSitemapsFromDirs(path.join(__cx, "dist")),
|
|
90
111
|
// Renames dist to public.
|
|
91
112
|
// En este paso de dist to public también se sacan los "assets"
|
|
92
113
|
// de public si el dominio es "pro-". Este proceso es sacar
|
|
@@ -97,8 +118,14 @@ async function runGatsbyAdapter() {
|
|
|
97
118
|
fs.renameSync(path.join(__ssg, "dist"), path.join(__ssg, "public"));
|
|
98
119
|
}
|
|
99
120
|
},
|
|
121
|
+
() => verbose("rename `__ssg/dist` to `__ssg/public` directory."),
|
|
100
122
|
() => moveDirsSync(__caches, __cx, ["apiCache", "store"]),
|
|
123
|
+
() =>
|
|
124
|
+
verbose(
|
|
125
|
+
"move `apiCache` and `store` directories from `__caches` to `__cx`"
|
|
126
|
+
),
|
|
101
127
|
() => moveDirsSync(__caches, __ssg, [".cache"]),
|
|
128
|
+
() => verbose("move `.cache` directory from `__caches` to `__ssg`"),
|
|
102
129
|
() => pause("Restore LifeCycle"),
|
|
103
130
|
],
|
|
104
131
|
});
|
|
@@ -122,7 +149,10 @@ async function runGatsbyAdapter() {
|
|
|
122
149
|
await doLifeCycle({
|
|
123
150
|
name: "SSG",
|
|
124
151
|
attempts: attempts.ssg,
|
|
125
|
-
steps: [
|
|
152
|
+
steps: [
|
|
153
|
+
() => runGatsbyBuildCommand(assetPrefix),
|
|
154
|
+
() => pause("SSG LifeCycle"),
|
|
155
|
+
],
|
|
126
156
|
});
|
|
127
157
|
|
|
128
158
|
/*
|
|
@@ -133,6 +163,7 @@ async function runGatsbyAdapter() {
|
|
|
133
163
|
attempts: attempts.relocation,
|
|
134
164
|
steps: [
|
|
135
165
|
() => legacy__createDistFromGatsbyPublic(domain, needsAssetPrefix),
|
|
166
|
+
() => verbose("create an `assets` directory from `public`"),
|
|
136
167
|
() => pause("Relocation LifeCycle"),
|
|
137
168
|
],
|
|
138
169
|
});
|
|
@@ -145,8 +176,12 @@ async function runGatsbyAdapter() {
|
|
|
145
176
|
attempts: attempts.meta,
|
|
146
177
|
steps: [
|
|
147
178
|
() => generateBuildReport(),
|
|
179
|
+
() =>
|
|
180
|
+
verbose("create build report from `store/metadata/render-info.json`"),
|
|
148
181
|
() => RobotsService.writeFiles(domain),
|
|
182
|
+
() => verbose("create Robots.txt"),
|
|
149
183
|
() => generateSitemaps(),
|
|
184
|
+
() => verbose("generate sitemaps"),
|
|
150
185
|
() => pause("Meta LifeCycle"),
|
|
151
186
|
],
|
|
152
187
|
});
|
|
@@ -166,15 +201,30 @@ async function runGatsbyAdapter() {
|
|
|
166
201
|
// tenidas en cuenta por la API y por lo tanto escapan a la
|
|
167
202
|
// lógica de `changedPages` y la persistencia del store.
|
|
168
203
|
() => removeVirtualPagesFromStore(),
|
|
204
|
+
() =>
|
|
205
|
+
verbose(
|
|
206
|
+
"remove virtual pages from store (multipage and static list)"
|
|
207
|
+
),
|
|
169
208
|
// Eliminamos carpetas vacías que puedan quedar de sites
|
|
170
209
|
// despublicados. Incluye aquellas que solo tengan archivos .xml
|
|
171
210
|
() => clearEmptyDirs(path.join(__cx, "dist")),
|
|
211
|
+
() => verbose("remove empty site directories from `__cx/dist`"),
|
|
172
212
|
() =>
|
|
173
213
|
moveDirsSync(__cx, __exports, ["dist", "assets"], {
|
|
174
214
|
withBackup: true,
|
|
175
215
|
}),
|
|
216
|
+
|
|
217
|
+
() =>
|
|
218
|
+
verbose(
|
|
219
|
+
"move `dist` and `assets` directories from `__cx` to `__exports`"
|
|
220
|
+
),
|
|
176
221
|
() => moveDirsSync(__cx, __caches, ["apiCache", "store"]),
|
|
222
|
+
() =>
|
|
223
|
+
verbose(
|
|
224
|
+
"move `apiCache` and `store` directories from `__cx` to `__caches`"
|
|
225
|
+
),
|
|
177
226
|
() => moveDirsSync(__ssg, __caches, [".cache"]),
|
|
227
|
+
() => verbose("move `.cache` directory from `__ssg` to `__caches`"),
|
|
178
228
|
() => pause("Archive LifeCycle"),
|
|
179
229
|
],
|
|
180
230
|
});
|
|
@@ -6,7 +6,7 @@ import path from "node:path";
|
|
|
6
6
|
import dotenv from "dotenv";
|
|
7
7
|
import fsx from "fs-extra";
|
|
8
8
|
|
|
9
|
-
import { getConfig } from "../../utils/
|
|
9
|
+
import { getConfig, verbose } from "../../utils/core-utils";
|
|
10
10
|
|
|
11
11
|
dotenv.config();
|
|
12
12
|
|
|
@@ -29,19 +29,16 @@ function getGatsbyAssetPrefixWithDomain(domain: string) {
|
|
|
29
29
|
if (!assetPrefix || !domain) return "";
|
|
30
30
|
if (!domain.startsWith(proDomain)) return "";
|
|
31
31
|
|
|
32
|
-
|
|
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
|
-
}
|
|
32
|
+
const assetPrefixWithDomain = `${assetPrefix}/${domain}`;
|
|
43
33
|
|
|
44
|
-
|
|
34
|
+
verbose(
|
|
35
|
+
`Reading env.GRIDDO_ASSET_PREFIX, ${process.env.GRIDDO_ASSET_PREFIX}`
|
|
36
|
+
);
|
|
37
|
+
verbose(
|
|
38
|
+
`Setting the asset prefix with the domain concatenated, ${assetPrefixWithDomain}`
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return assetPrefixWithDomain;
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
/**
|
|
@@ -99,24 +96,25 @@ function addCloudinaryParams(image: string, params: string) {
|
|
|
99
96
|
* @note This proccess (`yarn gatsby-build`) can not access to the custom Griddo
|
|
100
97
|
* `process.env` so it needs variables passed to it via the `env` prop.
|
|
101
98
|
*/
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
console.log("-- gatsbyBuild() --");
|
|
105
|
-
console.log("assetPrefixWithDomain", assetPrefixWithDomain);
|
|
106
|
-
}
|
|
99
|
+
function runGatsbyBuildCommand(assetPrefixWithDomain: string) {
|
|
100
|
+
verbose(`read assetPrefixWithDomain, ${assetPrefixWithDomain}`);
|
|
107
101
|
|
|
108
102
|
const { __ssg } = config.paths();
|
|
109
103
|
|
|
110
|
-
const command = spawnSync(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
104
|
+
const command = spawnSync(
|
|
105
|
+
"yarn",
|
|
106
|
+
["gatsby-build", process.env.GRIDDO_SSG_VERBOSE ? "--verbose" : ""],
|
|
107
|
+
{
|
|
108
|
+
cwd: __ssg,
|
|
109
|
+
stdio: ["ignore", "inherit", "ignore"],
|
|
110
|
+
encoding: "utf8",
|
|
111
|
+
shell: true,
|
|
112
|
+
env: Object.assign(process.env, {
|
|
113
|
+
GRIDDO_EXPORTER: "true",
|
|
114
|
+
SPAWN_ASSET_PREFIX_WITH_DOMAIN: assetPrefixWithDomain,
|
|
115
|
+
}),
|
|
116
|
+
}
|
|
117
|
+
);
|
|
120
118
|
|
|
121
119
|
if (command.status !== 0) {
|
|
122
120
|
throw new Error("Error in 'yarn gatsby-build'");
|
|
@@ -138,7 +136,6 @@ async function legacy__createDistFromGatsbyPublic(
|
|
|
138
136
|
const cxDistDirWithDomain = path.join(__cx, "dist", domain);
|
|
139
137
|
const publicDir = path.join(__ssg, "public");
|
|
140
138
|
|
|
141
|
-
console.log(publicDir);
|
|
142
139
|
const validFilesFromPublic = fsx
|
|
143
140
|
.readdirSync(publicDir)
|
|
144
141
|
.filter(
|
|
@@ -164,9 +161,13 @@ async function legacy__createDistFromGatsbyPublic(
|
|
|
164
161
|
if (needsAssetPrefix) {
|
|
165
162
|
fsx.copySync(pageDataSrc, pageDataDest);
|
|
166
163
|
if (fsx.existsSync(projectStaticSrc)) {
|
|
167
|
-
fsx.copySync(projectStaticSrc, projectStaticDest, {
|
|
164
|
+
fsx.copySync(projectStaticSrc, projectStaticDest, {
|
|
165
|
+
overwrite: false,
|
|
166
|
+
});
|
|
168
167
|
}
|
|
169
|
-
fsx.copySync(gatsbyStaticSrc, gatsbyStaticDest, {
|
|
168
|
+
fsx.copySync(gatsbyStaticSrc, gatsbyStaticDest, {
|
|
169
|
+
overwrite: false,
|
|
170
|
+
});
|
|
170
171
|
if (fsx.existsSync(projectStaticSrc)) {
|
|
171
172
|
fsx.copySync(projectStaticSrc, cxDistDirWithDomain, {
|
|
172
173
|
overwrite: false,
|
|
@@ -187,7 +188,7 @@ async function legacy__createDistFromGatsbyPublic(
|
|
|
187
188
|
|
|
188
189
|
export {
|
|
189
190
|
formatImage,
|
|
190
|
-
gatsbyBuild,
|
|
191
191
|
getGatsbyAssetPrefixWithDomain,
|
|
192
192
|
legacy__createDistFromGatsbyPublic,
|
|
193
|
+
runGatsbyBuildCommand,
|
|
193
194
|
};
|
package/exporter/index.ts
CHANGED
|
@@ -24,10 +24,9 @@
|
|
|
24
24
|
/* prettier-ignore */ import type { Site } from "./types/sites";
|
|
25
25
|
|
|
26
26
|
/* prettier-ignore */ import { startRender } from "./start-render";
|
|
27
|
+
/* prettier-ignore */ import { getConfig, logInfo, logPageSize, verbose, walk } from "./utils/core-utils";
|
|
27
28
|
/* prettier-ignore */ import { IS_COMPONENT_LIBRARY, PROJECT_ALIASES, resolveComponentsPath } from "./utils/instance";
|
|
28
|
-
/* prettier-ignore */ import { logInfo, logPageSize, walk } from "./utils/shared";
|
|
29
29
|
/* prettier-ignore */ import { getBuildPagesFromCachedStore, getBuildPagesFromStore, getBuildPagesPath } from "./utils/store";
|
|
30
|
-
/* prettier-ignore */ import { getConfig } from "./utils/temp-utils";
|
|
31
30
|
|
|
32
31
|
export {
|
|
33
32
|
AdditionalInfo,
|
|
@@ -40,11 +39,13 @@ export {
|
|
|
40
39
|
Site,
|
|
41
40
|
SocialsResponse,
|
|
42
41
|
getBuildPagesFromCachedStore,
|
|
43
|
-
getBuildPagesFromStore,
|
|
42
|
+
getBuildPagesFromStore,
|
|
43
|
+
getBuildPagesPath,
|
|
44
|
+
getConfig,
|
|
44
45
|
logInfo,
|
|
45
46
|
logPageSize,
|
|
46
47
|
resolveComponentsPath,
|
|
47
48
|
startRender,
|
|
48
|
-
|
|
49
|
+
verbose,
|
|
50
|
+
walk,
|
|
49
51
|
};
|
|
50
|
-
|
|
@@ -7,7 +7,6 @@ import type {
|
|
|
7
7
|
PageAdditionalInfo,
|
|
8
8
|
} from "../types/pages";
|
|
9
9
|
|
|
10
|
-
import fs from "node:fs";
|
|
11
10
|
import path from "node:path";
|
|
12
11
|
|
|
13
12
|
import dotenv from "dotenv";
|
|
@@ -18,6 +17,7 @@ import { NavigationService } from "./navigation";
|
|
|
18
17
|
import { SettingsService } from "./settings";
|
|
19
18
|
import { SitesService } from "./sites";
|
|
20
19
|
import { updatedSiteHash } from "../utils/cache";
|
|
20
|
+
import { getConfig, logInfo, siteList, verbose } from "../utils/core-utils";
|
|
21
21
|
import {
|
|
22
22
|
createGriddoListPages,
|
|
23
23
|
createGriddoMultiPages,
|
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
getMultiPageElements,
|
|
26
26
|
getPaginatedPages,
|
|
27
27
|
} from "../utils/pages";
|
|
28
|
-
import { logBox, logInfo, siteList } from "../utils/shared";
|
|
29
28
|
import { checkSites, getSiteData, unpublishSites } from "../utils/sites";
|
|
30
29
|
import {
|
|
31
30
|
createStoreDir,
|
|
@@ -34,7 +33,6 @@ import {
|
|
|
34
33
|
savePagesInStore,
|
|
35
34
|
saveRenderInfoInStore,
|
|
36
35
|
} from "../utils/store";
|
|
37
|
-
import { getConfig } from "../utils/temp-utils";
|
|
38
36
|
|
|
39
37
|
const config = getConfig();
|
|
40
38
|
|
|
@@ -57,10 +55,8 @@ async function createStore(domain: string) {
|
|
|
57
55
|
console.info(`API calls with ${API_CONCURRENCY_COUNT} threads`);
|
|
58
56
|
|
|
59
57
|
const { __cx } = config.paths();
|
|
58
|
+
const { griddoVersion } = config;
|
|
60
59
|
const storeDir = path.join(__cx, "store");
|
|
61
|
-
const { version: griddoVersion } = JSON.parse(
|
|
62
|
-
fs.readFileSync(path.join(__cx, "package.json"), "utf-8")
|
|
63
|
-
);
|
|
64
60
|
|
|
65
61
|
try {
|
|
66
62
|
// Vars to save later in the report file
|
|
@@ -293,16 +289,13 @@ async function createStore(domain: string) {
|
|
|
293
289
|
removePagesFromStore(pagesToDeleteFromStore);
|
|
294
290
|
|
|
295
291
|
// Debug time
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if (JSON.parse(process.env.GRIDDO_DEBUG_LOGS || "false")) {
|
|
304
|
-
logBox(changedPageLogs, `Site store: ${site.name}`, 1, 0);
|
|
305
|
-
}
|
|
292
|
+
|
|
293
|
+
verbose(`Store site: ${site.name}`);
|
|
294
|
+
verbose(`${validPagesIds.length} valid pages from API`);
|
|
295
|
+
verbose(`changed ${pagesToDeleteFromStore.length} pages from API`);
|
|
296
|
+
verbose(`deleted ${changedPages.length} pages in store`);
|
|
297
|
+
verbose(`missing ${pagesMissingInStore.length} pages in store`);
|
|
298
|
+
verbose(`write ${pagesToWriteToStore.length} pages to store`);
|
|
306
299
|
|
|
307
300
|
// Create (async)
|
|
308
301
|
const limit = pLimit(API_CONCURRENCY_COUNT);
|
package/exporter/start-render.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable node/shebang */
|
|
3
3
|
|
|
4
4
|
import { runGatsbyAdapter } from "./adapters";
|
|
5
|
-
import { logBox, measureExecutionTime } from "./utils/
|
|
5
|
+
import { logBox, measureExecutionTime } from "./utils/core-utils";
|
|
6
6
|
|
|
7
7
|
async function startRender() {
|
|
8
8
|
const exeTime = await measureExecutionTime(runGatsbyAdapter).catch(() => {
|
package/exporter/types/global.ts
CHANGED
package/exporter/utils/api.ts
CHANGED
|
@@ -13,7 +13,7 @@ import chalk from "chalk";
|
|
|
13
13
|
import dotenv from "dotenv";
|
|
14
14
|
|
|
15
15
|
import { saveCache, searchCacheData } from "./cache";
|
|
16
|
-
import { delay, getSafeSiteId, logInfo, msToSec } from "./
|
|
16
|
+
import { delay, getSafeSiteId, logInfo, msToSec } from "./core-utils";
|
|
17
17
|
import { AuthService } from "../services/auth";
|
|
18
18
|
|
|
19
19
|
dotenv.config();
|