@griddo/cx 1.75.180 → 1.75.182
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/index.js +41 -25
- package/gatsby-node.ts +5 -1
- package/package.json +4 -4
- package/scripts/griddo-exporter.ts +36 -33
- package/src/services/distributors.ts +38 -17
- package/src/services/sites.ts +4 -7
- package/src/types/api.ts +34 -4
- package/src/types/global.ts +2 -10
- package/src/utils/api.ts +0 -1
- package/src/utils/searches.ts +2 -1
- package/src/utils/shared.ts +35 -11
- package/src/utils/sites.ts +0 -1
package/gatsby-node.ts
CHANGED
|
@@ -30,12 +30,16 @@ const GRIDDO_STORE_MODE = (process.env.GRIDDO_STORE_MODE ||
|
|
|
30
30
|
|
|
31
31
|
// Consts
|
|
32
32
|
const storeDirPath = path.resolve(__dirname, "./.store/");
|
|
33
|
+
const isMonorepo = !isComponentLibraryEnv;
|
|
33
34
|
|
|
34
35
|
// -----------------------------------------------------------------------------
|
|
35
36
|
// onPreInit
|
|
36
37
|
// -----------------------------------------------------------------------------
|
|
37
38
|
export const onPreInit = async () => {
|
|
38
|
-
|
|
39
|
+
if (isMonorepo) {
|
|
40
|
+
splash();
|
|
41
|
+
}
|
|
42
|
+
|
|
39
43
|
initCache();
|
|
40
44
|
prepareStaticFolder();
|
|
41
45
|
StoreService.init(storeDirPath, { mode: GRIDDO_STORE_MODE });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/cx",
|
|
3
3
|
"description": "Griddo SSG based on Gatsby",
|
|
4
|
-
"version": "1.75.
|
|
4
|
+
"version": "1.75.182",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@babel/preset-env": "^7.14.5",
|
|
38
38
|
"@babel/preset-react": "^7.14.5",
|
|
39
39
|
"@babel/preset-typescript": "^7.16.5",
|
|
40
|
-
"@griddo/core": "^1.75.
|
|
40
|
+
"@griddo/core": "^1.75.182",
|
|
41
41
|
"@svgr/webpack": "^5.5.0",
|
|
42
42
|
"babel-loader": "^8.0.6",
|
|
43
43
|
"babel-plugin-styled-components": "^1.10.7",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"react-helmet": "^6.0.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@griddo/eslint-config-back": "^1.75.
|
|
72
|
+
"@griddo/eslint-config-back": "^1.75.182",
|
|
73
73
|
"@types/babel__core": "^7.20.0",
|
|
74
74
|
"@types/babel__preset-env": "^7.9.2",
|
|
75
75
|
"@types/csvtojson": "^2.0.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"publishConfig": {
|
|
118
118
|
"access": "public"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "888dd2eeef46c60b7f0e9139198eb57bb7253b5f"
|
|
121
121
|
}
|
|
@@ -5,14 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
require("dotenv").config();
|
|
7
7
|
|
|
8
|
+
// External libraries
|
|
9
|
+
import chalk from "chalk";
|
|
8
10
|
import { execSync } from "child_process";
|
|
9
11
|
import fs from "fs";
|
|
10
12
|
import path from "path";
|
|
11
13
|
import pkgDir from "pkg-dir";
|
|
12
14
|
|
|
15
|
+
// Utils
|
|
13
16
|
import { initCache } from "../src/utils/cache";
|
|
14
17
|
import { findDomains } from "../src/utils/domains";
|
|
18
|
+
import { exporterLogo as splash } from "../src/utils/shared";
|
|
15
19
|
|
|
20
|
+
// Envs
|
|
16
21
|
const artifactsArchivable = ["dist", "assets", "apiCache", ".cache"];
|
|
17
22
|
const artifactsDisposable = ["public", ".store"];
|
|
18
23
|
|
|
@@ -25,6 +30,7 @@ const exportArchiveBasePath = path.resolve(execBasePath, "exports/sites");
|
|
|
25
30
|
// Where we are going to run the export command
|
|
26
31
|
const workingPath = pkgDir.sync(__dirname)!;
|
|
27
32
|
|
|
33
|
+
// Types
|
|
28
34
|
type Env = Record<string, unknown>;
|
|
29
35
|
|
|
30
36
|
// -----------------------------------------------------------------------------
|
|
@@ -56,12 +62,10 @@ const getAssetPrefix = (domain: string) => {
|
|
|
56
62
|
// -----------------------------------------------------------------------------
|
|
57
63
|
// Loggers
|
|
58
64
|
// -----------------------------------------------------------------------------
|
|
59
|
-
const logError = (...message: Array<any>) => console.
|
|
60
|
-
const logInfo = (...message: Array<any>) => console.
|
|
61
|
-
const logSuccess = (...message: Array<any>) =>
|
|
62
|
-
|
|
63
|
-
const logWarning = (...message: Array<any>) =>
|
|
64
|
-
console.info("warning", ...message);
|
|
65
|
+
const logError = (...message: Array<any>) => console.log(...message);
|
|
66
|
+
const logInfo = (...message: Array<any>) => console.log(...message);
|
|
67
|
+
const logSuccess = (...message: Array<any>) => console.log(...message);
|
|
68
|
+
const logWarning = (...message: Array<any>) => console.log(...message);
|
|
65
69
|
|
|
66
70
|
// -----------------------------------------------------------------------------
|
|
67
71
|
// Main Stuff
|
|
@@ -75,14 +79,13 @@ const domainExport = async (domain: string) => {
|
|
|
75
79
|
};
|
|
76
80
|
|
|
77
81
|
const launchExports = async () => {
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
splash();
|
|
80
83
|
initCache();
|
|
81
84
|
|
|
82
85
|
const domains = await findDomains();
|
|
83
86
|
|
|
84
87
|
for (const domain of domains) {
|
|
85
|
-
logInfo(
|
|
88
|
+
logInfo(`️🚢 Exporting domain ${chalk.underline(domain)}`);
|
|
86
89
|
await domainExport(domain);
|
|
87
90
|
}
|
|
88
91
|
};
|
|
@@ -98,7 +101,7 @@ const getDomainRunner = (domain: string) => {
|
|
|
98
101
|
});
|
|
99
102
|
|
|
100
103
|
const init = () => {
|
|
101
|
-
logInfo(
|
|
104
|
+
logInfo(`🚀 Initializing ${chalk.underline(domain)} exporter`);
|
|
102
105
|
|
|
103
106
|
cleanDirtyArtifactPaths();
|
|
104
107
|
createBaseExportPaths();
|
|
@@ -129,7 +132,7 @@ const getDomainRunner = (domain: string) => {
|
|
|
129
132
|
const { currentExportWorkingPath } = getArtifactPaths(artifact);
|
|
130
133
|
|
|
131
134
|
if (fs.existsSync(currentExportWorkingPath)) {
|
|
132
|
-
logWarning(
|
|
135
|
+
logWarning(`🧹 Cleanup dirty ${chalk.gray(currentExportWorkingPath)}`);
|
|
133
136
|
run(`rm -rf ${currentExportWorkingPath}`);
|
|
134
137
|
}
|
|
135
138
|
}
|
|
@@ -139,7 +142,7 @@ const getDomainRunner = (domain: string) => {
|
|
|
139
142
|
const { domainExportArchiveBasePath } = getArtifactPaths();
|
|
140
143
|
|
|
141
144
|
if (!fs.existsSync(domainExportArchiveBasePath)) {
|
|
142
|
-
logInfo(
|
|
145
|
+
logInfo(`✨ Creating ${domainExportArchiveBasePath}`);
|
|
143
146
|
run(`mkdir -p ${domainExportArchiveBasePath}`);
|
|
144
147
|
}
|
|
145
148
|
};
|
|
@@ -149,7 +152,9 @@ const getDomainRunner = (domain: string) => {
|
|
|
149
152
|
getArtifactPaths(artifact);
|
|
150
153
|
|
|
151
154
|
logInfo(
|
|
152
|
-
|
|
155
|
+
`🚚 Moving files from ${chalk.gray(
|
|
156
|
+
currentExportWorkingPath
|
|
157
|
+
)} to ${chalk.gray(currentExportArchivePath)}`
|
|
153
158
|
);
|
|
154
159
|
run(`mv ${currentExportWorkingPath} ${currentExportArchivePath}`);
|
|
155
160
|
};
|
|
@@ -161,7 +166,7 @@ const getDomainRunner = (domain: string) => {
|
|
|
161
166
|
|
|
162
167
|
if (!fs.existsSync(currentExportWorkingPath)) {
|
|
163
168
|
logError(
|
|
164
|
-
"Source directory has not been created:",
|
|
169
|
+
"📁 Source directory has not been created:",
|
|
165
170
|
currentExportWorkingPath
|
|
166
171
|
);
|
|
167
172
|
continue;
|
|
@@ -173,7 +178,7 @@ const getDomainRunner = (domain: string) => {
|
|
|
173
178
|
deleteArtifactBackup(artifact);
|
|
174
179
|
} catch (error) {
|
|
175
180
|
logError(
|
|
176
|
-
|
|
181
|
+
`🚚 Error moving files to ${currentExportArchivePath}`,
|
|
177
182
|
error.message
|
|
178
183
|
);
|
|
179
184
|
restoreArtifactBackup(artifact);
|
|
@@ -188,7 +193,7 @@ const getDomainRunner = (domain: string) => {
|
|
|
188
193
|
getArtifactPaths(artifact);
|
|
189
194
|
|
|
190
195
|
if (fs.existsSync(currentExportArchivePath)) {
|
|
191
|
-
logWarning(
|
|
196
|
+
logWarning(`️♻️ Restoring ${chalk.gray(currentExportArchivePath)}`);
|
|
192
197
|
run(`cp -R ${currentExportArchivePath} ${currentExportWorkingPath}`);
|
|
193
198
|
}
|
|
194
199
|
}
|
|
@@ -201,7 +206,7 @@ const getDomainRunner = (domain: string) => {
|
|
|
201
206
|
getArtifactPaths(artifact);
|
|
202
207
|
|
|
203
208
|
if (fs.existsSync(currentExportArchivePath)) {
|
|
204
|
-
logInfo(
|
|
209
|
+
logInfo(`💿 Creating backup of ${chalk.gray(currentExportArchivePath)}`);
|
|
205
210
|
run(`mv ${currentExportArchivePath} ${currentExportBackupPath}`);
|
|
206
211
|
}
|
|
207
212
|
};
|
|
@@ -211,7 +216,9 @@ const getDomainRunner = (domain: string) => {
|
|
|
211
216
|
getArtifactPaths(artifact);
|
|
212
217
|
|
|
213
218
|
if (fs.existsSync(currentExportBackupPath)) {
|
|
214
|
-
logWarning(
|
|
219
|
+
logWarning(
|
|
220
|
+
`️♻️ Restoring backup ${chalk.gray(currentExportArchivePath)}`
|
|
221
|
+
);
|
|
215
222
|
run(`mv ${currentExportBackupPath} ${currentExportArchivePath}`);
|
|
216
223
|
}
|
|
217
224
|
};
|
|
@@ -220,23 +227,17 @@ const getDomainRunner = (domain: string) => {
|
|
|
220
227
|
const { currentExportArchivePath, currentExportBackupPath } =
|
|
221
228
|
getArtifactPaths(artifact);
|
|
222
229
|
|
|
223
|
-
|
|
230
|
+
logWarning(`️❌ Removing backup ${chalk.gray(currentExportArchivePath)}`);
|
|
224
231
|
run(`rm -rf ${currentExportBackupPath}`);
|
|
225
232
|
};
|
|
226
233
|
|
|
227
234
|
const runExporter = () => {
|
|
228
|
-
console.log(
|
|
229
|
-
|
|
230
|
-
"****************************<GATSBY>*********************",
|
|
231
|
-
"\n"
|
|
232
|
-
);
|
|
235
|
+
console.log(`\n${chalk.black(chalk.bgGreen(" Gatsby (start) "))}\n`);
|
|
236
|
+
|
|
233
237
|
run("yarn export");
|
|
234
238
|
logSuccess("Your sites have been exported correctly");
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
"****************************</GATSBY>*********************",
|
|
238
|
-
"\n"
|
|
239
|
-
);
|
|
239
|
+
|
|
240
|
+
console.log(`\n${chalk.black(chalk.bgGreen(" Gatsby (end) "))}\n`);
|
|
240
241
|
|
|
241
242
|
removeDisposableArtifacts();
|
|
242
243
|
};
|
|
@@ -247,7 +248,9 @@ const getDomainRunner = (domain: string) => {
|
|
|
247
248
|
const { currentExportWorkingPath: publicPath } = getArtifactPaths("public");
|
|
248
249
|
|
|
249
250
|
if (fs.existsSync(distPath)) {
|
|
250
|
-
logWarning(
|
|
251
|
+
logWarning(
|
|
252
|
+
`🚚 Moving ${chalk.gray(distPath)} to ${chalk.gray(publicPath)}`
|
|
253
|
+
);
|
|
251
254
|
run(`mv ${distPath} ${publicPath}`);
|
|
252
255
|
}
|
|
253
256
|
};
|
|
@@ -259,7 +262,7 @@ const getDomainRunner = (domain: string) => {
|
|
|
259
262
|
const { currentExportWorkingPath: distPath } = getArtifactPaths("dist");
|
|
260
263
|
|
|
261
264
|
if (fs.existsSync(publicPath)) {
|
|
262
|
-
logWarning(
|
|
265
|
+
logWarning(`🚚 Moving ${publicPath} to ${distPath}`);
|
|
263
266
|
run(`mv ${publicPath} ${distPath}`);
|
|
264
267
|
}
|
|
265
268
|
};
|
|
@@ -270,7 +273,7 @@ const getDomainRunner = (domain: string) => {
|
|
|
270
273
|
getArtifactPaths(artifact);
|
|
271
274
|
|
|
272
275
|
if (fs.existsSync(artifactPath)) {
|
|
273
|
-
logWarning(
|
|
276
|
+
logWarning(`❌ Removing ${chalk.gray(artifactPath)}`);
|
|
274
277
|
run(`rm -rf ${artifactPath}`);
|
|
275
278
|
}
|
|
276
279
|
}
|
|
@@ -297,6 +300,6 @@ const getDomainRunner = (domain: string) => {
|
|
|
297
300
|
console.clear();
|
|
298
301
|
|
|
299
302
|
launchExports().catch((err) => {
|
|
300
|
-
console.error("ERROR", err?.stdout?.toString() || err);
|
|
303
|
+
console.error("❌ ERROR", err?.stdout?.toString() || err);
|
|
301
304
|
process.exit(1);
|
|
302
305
|
});
|
|
@@ -18,7 +18,7 @@ class DistributorService {
|
|
|
18
18
|
* @param data The ReferenceField props.
|
|
19
19
|
* @returns The props for one of the ReferenceField mode.
|
|
20
20
|
*/
|
|
21
|
-
static getBody(data: Fields.Reference<unknown
|
|
21
|
+
static getBody(data: Fields.Reference<unknown>, page: Core.Page) {
|
|
22
22
|
const {
|
|
23
23
|
order,
|
|
24
24
|
source,
|
|
@@ -28,23 +28,44 @@ class DistributorService {
|
|
|
28
28
|
filter,
|
|
29
29
|
fullRelations = false,
|
|
30
30
|
allLanguages = false,
|
|
31
|
+
referenceId,
|
|
31
32
|
} = data;
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
if (mode === "auto") {
|
|
35
|
+
return {
|
|
36
|
+
mode,
|
|
37
|
+
order,
|
|
38
|
+
source,
|
|
39
|
+
quantity,
|
|
40
|
+
filter,
|
|
41
|
+
fullRelations,
|
|
42
|
+
allLanguages,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (mode === "manual") {
|
|
47
|
+
return {
|
|
48
|
+
mode,
|
|
49
|
+
fixed,
|
|
50
|
+
fullRelations,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (mode === "navigation") {
|
|
55
|
+
return {
|
|
56
|
+
mode,
|
|
57
|
+
order,
|
|
58
|
+
quantity,
|
|
59
|
+
fullRelations,
|
|
60
|
+
referenceId: referenceId || page?.structuredDataContent?.id,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log(
|
|
65
|
+
`ERROR: Distribuidor mode: ${mode} is not recognized on page ${page?.id}.`
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return data;
|
|
48
69
|
}
|
|
49
70
|
|
|
50
71
|
/**
|
|
@@ -72,7 +93,7 @@ class DistributorService {
|
|
|
72
93
|
return [];
|
|
73
94
|
}
|
|
74
95
|
|
|
75
|
-
const body = this.getBody(data);
|
|
96
|
+
const body = this.getBody(data, page);
|
|
76
97
|
const response = await SitesService.getDistributorData(page, body, cached);
|
|
77
98
|
|
|
78
99
|
return response;
|
package/src/services/sites.ts
CHANGED
|
@@ -3,8 +3,10 @@ import type { Core } from "@griddo/core";
|
|
|
3
3
|
import type {
|
|
4
4
|
AllPagesResponse,
|
|
5
5
|
AllSitesReponse,
|
|
6
|
+
DistributorBody,
|
|
6
7
|
DistributorResponse,
|
|
7
8
|
EndPageInfoResponse,
|
|
9
|
+
EndSiteRenderBody,
|
|
8
10
|
LanguagesResponse,
|
|
9
11
|
PageResponse,
|
|
10
12
|
SitemapAPIResponse,
|
|
@@ -59,7 +61,6 @@ class SitesService {
|
|
|
59
61
|
} = ENDPOINTS;
|
|
60
62
|
const response = await get<PageResponse>({
|
|
61
63
|
endpoint: `${prefix}${id}${suffix}`,
|
|
62
|
-
body: undefined,
|
|
63
64
|
cached,
|
|
64
65
|
});
|
|
65
66
|
|
|
@@ -75,7 +76,6 @@ class SitesService {
|
|
|
75
76
|
} = ENDPOINTS;
|
|
76
77
|
const response = await get<Site>({
|
|
77
78
|
endpoint: `${prefix}${id}${suffix}`,
|
|
78
|
-
body: undefined,
|
|
79
79
|
cached,
|
|
80
80
|
});
|
|
81
81
|
|
|
@@ -91,7 +91,6 @@ class SitesService {
|
|
|
91
91
|
} = ENDPOINTS;
|
|
92
92
|
const response = await get<LanguagesResponse>({
|
|
93
93
|
endpoint: `${prefix}${id}${suffix}`,
|
|
94
|
-
body: undefined,
|
|
95
94
|
cached,
|
|
96
95
|
});
|
|
97
96
|
|
|
@@ -115,7 +114,7 @@ class SitesService {
|
|
|
115
114
|
/**
|
|
116
115
|
* Send the end signal to API for a render site.
|
|
117
116
|
*/
|
|
118
|
-
static async endSiteRender(id: number, body:
|
|
117
|
+
static async endSiteRender(id: number, body: EndSiteRenderBody) {
|
|
119
118
|
const {
|
|
120
119
|
BUILD_END: [prefix, suffix],
|
|
121
120
|
} = ENDPOINTS;
|
|
@@ -132,7 +131,7 @@ class SitesService {
|
|
|
132
131
|
*/
|
|
133
132
|
static async getDistributorData(
|
|
134
133
|
page: Core.Page,
|
|
135
|
-
body:
|
|
134
|
+
body: DistributorBody,
|
|
136
135
|
cached: boolean
|
|
137
136
|
) {
|
|
138
137
|
const {
|
|
@@ -172,7 +171,6 @@ class SitesService {
|
|
|
172
171
|
} = ENDPOINTS;
|
|
173
172
|
const response = await get<SocialsResponse>({
|
|
174
173
|
endpoint: `${prefix}${id}${suffix}`,
|
|
175
|
-
body: undefined,
|
|
176
174
|
cached,
|
|
177
175
|
});
|
|
178
176
|
|
|
@@ -188,7 +186,6 @@ class SitesService {
|
|
|
188
186
|
} = ENDPOINTS;
|
|
189
187
|
const response = await get<AllPagesResponse>({
|
|
190
188
|
endpoint: `${prefix}${id}${suffix}`,
|
|
191
|
-
body: undefined,
|
|
192
189
|
cached,
|
|
193
190
|
});
|
|
194
191
|
|
package/src/types/api.ts
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
// Types
|
|
2
2
|
import type { Core, Fields } from "@griddo/core";
|
|
3
|
-
import { Domains, Robots, Settings } from "./global";
|
|
3
|
+
import type { Domains, Robots, Settings } from "./global";
|
|
4
4
|
import type { APIPageObject } from "./pages";
|
|
5
5
|
import type { Site } from "./sites";
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/** EndSiteRender Body */
|
|
8
|
+
export type EndSiteRenderBody = {
|
|
9
|
+
/** Site hashes to publish. */
|
|
10
|
+
publishHashes: Array<string>;
|
|
11
|
+
/** Current site hash. */
|
|
12
|
+
siteHash: string | null;
|
|
13
|
+
/** Site hashes to unpublish. */
|
|
14
|
+
unpublishHashes: Array<string>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Distributor Body */
|
|
18
|
+
export interface DistributorBody {
|
|
19
|
+
mode: "auto" | "manual" | "navigation";
|
|
20
|
+
order?: string;
|
|
21
|
+
source?: Array<string>;
|
|
22
|
+
quantity?: number;
|
|
23
|
+
filter?: Array<any>;
|
|
24
|
+
fullRelations?: boolean;
|
|
25
|
+
allLanguages?: boolean;
|
|
26
|
+
fixed?: Array<number>;
|
|
27
|
+
referenceId?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Describes the props of the body object for the get page */
|
|
31
|
+
interface PageBody {
|
|
9
32
|
/** The title of the page. */
|
|
10
33
|
title?: string;
|
|
11
34
|
/** The description of the page. */
|
|
@@ -57,6 +80,12 @@ export type DistributorResponse = Fields.QueriedData<unknown>;
|
|
|
57
80
|
/** Describes the response object returned by socials from Griddo. */
|
|
58
81
|
export type SocialsResponse = Record<Core.SocialName, string>;
|
|
59
82
|
|
|
83
|
+
/** Describes the response object returned by post search info post. */
|
|
84
|
+
export type PostSearchInfoResponse = {
|
|
85
|
+
code: number;
|
|
86
|
+
message: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
60
89
|
/** Describes the response object returned by a sitemap. */
|
|
61
90
|
export interface SitemapAPIResponse {
|
|
62
91
|
/** Number of items */
|
|
@@ -82,7 +111,7 @@ interface APIRequest {
|
|
|
82
111
|
/** The URL of the API endpoint. */
|
|
83
112
|
endpoint: string;
|
|
84
113
|
/** The parameters to be sent in the request body. */
|
|
85
|
-
body?:
|
|
114
|
+
body?: any;
|
|
86
115
|
/** Indicates whether to use the cache to get the response from the API. */
|
|
87
116
|
cached?: unknown;
|
|
88
117
|
/** Number of connection attempts (in case it fails on the first attempt). */
|
|
@@ -152,4 +181,5 @@ export type APIResponses =
|
|
|
152
181
|
| PageResponse
|
|
153
182
|
| EndPageInfoResponse
|
|
154
183
|
| DistributorResponse
|
|
184
|
+
| PostSearchInfoResponse
|
|
155
185
|
| AllPagesResponse;
|
package/src/types/global.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Types
|
|
2
2
|
import type { Core, Fields } from "@griddo/core";
|
|
3
|
+
import type { EndSiteRenderBody } from "./api";
|
|
3
4
|
|
|
4
5
|
export type StoreMode = "memory" | "file";
|
|
5
6
|
|
|
@@ -55,17 +56,8 @@ export type Domains = Array<{
|
|
|
55
56
|
url: string;
|
|
56
57
|
}>;
|
|
57
58
|
|
|
58
|
-
export type StartPageInfo = {
|
|
59
|
-
/** Site hashes to publish. */
|
|
60
|
-
publishHashes: Array<string>;
|
|
61
|
-
/** Current site hash. */
|
|
62
|
-
siteHash: string | null;
|
|
63
|
-
/** Site hashes to unpublish. */
|
|
64
|
-
unpublishHashes: Array<string>;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
59
|
/** Describes the type of build process data object. */
|
|
68
|
-
export type BuildProcessData = Record<string,
|
|
60
|
+
export type BuildProcessData = Record<string, EndSiteRenderBody>;
|
|
69
61
|
|
|
70
62
|
export type Robot = { path: string; content: string };
|
|
71
63
|
|
package/src/utils/api.ts
CHANGED
package/src/utils/searches.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Types
|
|
2
|
+
import type { PostSearchInfoResponse } from "../types/api";
|
|
2
3
|
import type { PostSearchInfoProps } from "../types/global";
|
|
3
4
|
|
|
4
5
|
// API
|
|
@@ -25,7 +26,7 @@ async function postSearchInfo(props: PostSearchInfoProps) {
|
|
|
25
26
|
template,
|
|
26
27
|
} = props;
|
|
27
28
|
|
|
28
|
-
const response = await post({
|
|
29
|
+
const response = await post<PostSearchInfoResponse>({
|
|
29
30
|
endpoint: `${API_URL}/search`,
|
|
30
31
|
body: {
|
|
31
32
|
title,
|
package/src/utils/shared.ts
CHANGED
|
@@ -4,6 +4,7 @@ import dotenv from "dotenv";
|
|
|
4
4
|
import fs from "fs-extra";
|
|
5
5
|
import gradient from "gradient-string";
|
|
6
6
|
import { APIResponses } from "../types/api";
|
|
7
|
+
import { version } from "../../package.json";
|
|
7
8
|
|
|
8
9
|
dotenv.config();
|
|
9
10
|
|
|
@@ -115,17 +116,40 @@ export function getSafeSiteId(response: APIResponses) {
|
|
|
115
116
|
*/
|
|
116
117
|
function splash() {
|
|
117
118
|
const logo = `
|
|
119
|
+
··
|
|
120
|
+
·· ______ ______ _____ ______ ______ _____
|
|
121
|
+
·· | ____ |_____/ | | \\ | \\ | |
|
|
122
|
+
·· |_____| | \\_ __|__ |_____/ |_____/ |_____|
|
|
123
|
+
·· ______ _ _ _____ ______ _______ ______
|
|
124
|
+
·· |_____] | | | | | \\ |______ |_____/
|
|
125
|
+
·· |_____] |_____| __|__ |_____ |_____/ |______ | \\_
|
|
126
|
+
··
|
|
127
|
+
·· ${version}
|
|
128
|
+
`;
|
|
129
|
+
|
|
130
|
+
console.log(gradient.cristal(logo));
|
|
131
|
+
}
|
|
118
132
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
function exporterLogo() {
|
|
134
|
+
const logo = `
|
|
135
|
+
··
|
|
136
|
+
·· /
|
|
137
|
+
·· / //
|
|
138
|
+
·· ______ ______ _____ ______ ______ _____ /· /
|
|
139
|
+
·· | ____ |_____/ | | \\ | \\ | | / · / /
|
|
140
|
+
·· |_____| | \\_ __|__ |_____/ |_____/ |_____| · · / / · /
|
|
141
|
+
·· _______ _ _ _____ _____ ______ _______ _______ ______
|
|
142
|
+
·· |______ \\___/ |_____] | | |_____/ | |______ |_____/
|
|
143
|
+
·· |______ _/ \\_ | |_____| | \\_ | |______ | \\_
|
|
144
|
+
··
|
|
145
|
+
·· Griddo exporter orchestrator / / / · / /
|
|
146
|
+
·· ${version} / / /· /
|
|
147
|
+
·· /· /
|
|
148
|
+
·· /
|
|
149
|
+
··
|
|
150
|
+
`;
|
|
151
|
+
|
|
152
|
+
console.log(gradient.cristal(logo));
|
|
129
153
|
}
|
|
130
154
|
|
|
131
|
-
export { delay, logBox, logInfo, logPageSize, splash, walk };
|
|
155
|
+
export { delay, exporterLogo, logBox, logInfo, logPageSize, splash, walk };
|