@griddo/cx 11.7.7-rc.0 → 11.7.7-rc.1
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 +226 -27
- package/build/adapters/gatsby/index.d.ts +4 -0
- package/build/adapters/gatsby/utils.d.ts +22 -0
- package/build/artifacts/index.d.ts +6 -0
- package/build/commands/end-render.d.ts +2 -0
- package/build/commands/move-assets.d.ts +1 -0
- package/build/commands/prepare-domains-render.d.ts +1 -0
- package/build/commands/reset-render.d.ts +2 -0
- package/build/commands/start-render.d.ts +2 -0
- package/build/commands/upload-search-content.d.ts +2 -0
- package/build/constants/endpoints.d.ts +19 -0
- package/build/constants/envs.d.ts +37 -0
- package/build/constants/index.d.ts +57 -0
- package/build/end-render.js +74 -0
- package/build/end-render.js.map +7 -0
- package/build/errors/errors-data.d.ts +22 -0
- package/build/errors/index.d.ts +15 -0
- package/build/index.d.ts +29 -0
- package/build/index.js +73 -0
- package/build/index.js.map +7 -0
- package/build/prepare-domains-render.js +73 -0
- package/build/prepare-domains-render.js.map +7 -0
- package/build/react/Favicon/index.d.ts +5 -0
- package/build/react/Favicon/utils.d.ts +9 -0
- package/build/react/GriddoIntegrations/index.d.ts +20 -0
- package/build/react/GriddoIntegrations/utils.d.ts +26 -0
- package/{react/index.tsx → build/react/index.d.ts} +0 -1
- package/build/react/index.js +3 -0
- package/build/registers/api.d.ts +9 -0
- package/build/registers/gatsby.d.ts +9 -0
- package/build/registers/index.d.ts +3 -0
- package/build/reset-render.js +74 -0
- package/build/reset-render.js.map +7 -0
- package/build/services/auth.d.ts +10 -0
- package/build/services/domains.d.ts +6 -0
- package/build/services/navigation.d.ts +50 -0
- package/build/services/reference-fields.d.ts +20 -0
- package/build/services/register.d.ts +36 -0
- package/build/services/robots.d.ts +19 -0
- package/build/services/settings.d.ts +4 -0
- package/build/services/sites.d.ts +29 -0
- package/build/services/store.d.ts +6 -0
- package/build/start-render.js +100 -0
- package/build/start-render.js.map +7 -0
- package/build/types/api.d.ts +142 -0
- package/build/types/global.d.ts +84 -0
- package/build/types/navigation.d.ts +28 -0
- package/build/types/pages.d.ts +144 -0
- package/build/types/sites.d.ts +57 -0
- package/build/types/templates.d.ts +8 -0
- package/build/upload-search-content.js +74 -0
- package/build/upload-search-content.js.map +7 -0
- package/build/utils/alerts.d.ts +3 -0
- package/build/utils/api.d.ts +23 -0
- package/build/utils/cache.d.ts +35 -0
- package/build/utils/core-utils.d.ts +107 -0
- package/build/utils/create-build-data.d.ts +8 -0
- package/build/utils/domains.d.ts +13 -0
- package/build/utils/folders.d.ts +53 -0
- package/build/utils/health-checks.d.ts +7 -0
- package/build/utils/images.d.ts +16 -0
- package/build/utils/instance.d.ts +21 -0
- package/build/utils/loggin.d.ts +51 -0
- package/build/utils/pages.d.ts +34 -0
- package/build/utils/render.d.ts +13 -0
- package/build/utils/searches.d.ts +15 -0
- package/build/utils/sites.d.ts +31 -0
- package/build/utils/store.d.ts +81 -0
- package/cx.config.d.ts +5 -0
- package/cx.config.js +36 -0
- package/exporter/adapters/gatsby/index.ts +147 -67
- package/exporter/adapters/gatsby/utils.ts +161 -0
- package/exporter/artifacts/README.md +34 -0
- package/exporter/artifacts/index.ts +33 -0
- package/exporter/build.sh +38 -4
- package/exporter/commands/end-render.ts +69 -73
- package/exporter/commands/move-assets.ts +11 -0
- package/exporter/commands/prepare-domains-render.ts +31 -144
- package/exporter/commands/reset-render.ts +1 -10
- package/exporter/commands/start-render.ts +44 -23
- package/exporter/commands/upload-search-content.ts +20 -194
- package/exporter/constants/envs.ts +55 -57
- package/exporter/constants/index.ts +129 -0
- package/exporter/{constants/errors.ts → errors/errors-data.ts} +14 -24
- package/exporter/{utils/errors.ts → errors/index.ts} +9 -10
- package/exporter/index.ts +82 -0
- package/{react → exporter/react}/Favicon/index.tsx +7 -1
- package/{react → exporter/react}/GriddoIntegrations/index.tsx +14 -6
- package/{react → exporter/react}/GriddoIntegrations/utils.ts +9 -4
- package/exporter/react/index.tsx +11 -0
- package/exporter/registers/api.ts +14 -0
- package/exporter/registers/gatsby.ts +14 -0
- package/exporter/registers/index.ts +4 -0
- package/exporter/services/auth.ts +6 -7
- package/exporter/services/domains.ts +16 -0
- package/exporter/services/navigation.ts +10 -4
- package/exporter/services/reference-fields.ts +23 -8
- package/exporter/services/register.ts +113 -0
- package/exporter/services/robots.ts +16 -9
- package/exporter/services/settings.ts +17 -0
- package/exporter/services/sites.ts +24 -35
- package/exporter/services/store.ts +78 -120
- package/exporter/types/api.ts +27 -24
- package/exporter/types/global.ts +10 -7
- package/exporter/types/navigation.ts +1 -1
- package/exporter/types/pages.ts +3 -2
- package/exporter/types/sites.ts +2 -1
- package/exporter/utils/alerts.ts +29 -0
- package/exporter/utils/api.ts +82 -46
- package/exporter/utils/cache.ts +62 -37
- package/exporter/utils/core-utils.ts +248 -129
- package/exporter/utils/create-build-data.ts +17 -0
- package/exporter/utils/domains.ts +7 -10
- package/exporter/utils/folders.ts +95 -187
- package/exporter/utils/health-checks.ts +64 -0
- package/exporter/utils/images.ts +6 -1
- package/exporter/utils/instance.ts +12 -9
- package/exporter/utils/loggin.ts +91 -32
- package/exporter/utils/pages.ts +88 -23
- package/exporter/utils/render.ts +48 -149
- package/exporter/utils/searches.ts +156 -0
- package/exporter/utils/sites.ts +90 -81
- package/exporter/utils/store.ts +180 -87
- package/gatsby-browser.tsx +58 -41
- package/gatsby-config.ts +12 -6
- package/gatsby-node.ts +77 -15
- package/gatsby-ssr.tsx +1 -2
- package/package.json +78 -36
- package/src/README.md +7 -0
- package/src/components/Head.tsx +46 -13
- package/src/components/template.tsx +30 -8
- package/src/gatsby-node-utils.ts +2 -91
- package/src/html.tsx +11 -2
- package/src/types.ts +5 -5
- package/start-render.js +7 -0
- package/tsconfig.json +3 -5
- package/build/adapters/gatsby/actions/clean.js +0 -10
- package/build/adapters/gatsby/actions/clean.js.map +0 -1
- package/build/adapters/gatsby/actions/close.js +0 -12
- package/build/adapters/gatsby/actions/close.js.map +0 -1
- package/build/adapters/gatsby/actions/data.js +0 -18
- package/build/adapters/gatsby/actions/data.js.map +0 -1
- package/build/adapters/gatsby/actions/healthCheck.js +0 -10
- package/build/adapters/gatsby/actions/healthCheck.js.map +0 -1
- package/build/adapters/gatsby/actions/init.js +0 -9
- package/build/adapters/gatsby/actions/init.js.map +0 -1
- package/build/adapters/gatsby/actions/meta.js +0 -14
- package/build/adapters/gatsby/actions/meta.js.map +0 -1
- package/build/adapters/gatsby/actions/prepare.js +0 -9
- package/build/adapters/gatsby/actions/prepare.js.map +0 -1
- package/build/adapters/gatsby/actions/relocation.js +0 -15
- package/build/adapters/gatsby/actions/relocation.js.map +0 -1
- package/build/adapters/gatsby/actions/restore.js +0 -26
- package/build/adapters/gatsby/actions/restore.js.map +0 -1
- package/build/adapters/gatsby/actions/ssg.js +0 -9
- package/build/adapters/gatsby/actions/ssg.js.map +0 -1
- package/build/adapters/gatsby/actions/sync.js +0 -51
- package/build/adapters/gatsby/actions/sync.js.map +0 -1
- package/build/adapters/gatsby/index.js +0 -79
- package/build/adapters/gatsby/index.js.map +0 -1
- package/build/adapters/gatsby/shared/context.js +0 -31
- package/build/adapters/gatsby/shared/context.js.map +0 -1
- package/build/adapters/gatsby/shared/diff-assets.js +0 -101
- package/build/adapters/gatsby/shared/diff-assets.js.map +0 -1
- package/build/adapters/gatsby/shared/extract-assets.js +0 -58
- package/build/adapters/gatsby/shared/extract-assets.js.map +0 -1
- package/build/adapters/gatsby/shared/gatsby-build.js +0 -49
- package/build/adapters/gatsby/shared/gatsby-build.js.map +0 -1
- package/build/adapters/gatsby/shared/sync-render.js +0 -210
- package/build/adapters/gatsby/shared/sync-render.js.map +0 -1
- package/build/adapters/gatsby/shared/types.js +0 -3
- package/build/adapters/gatsby/shared/types.js.map +0 -1
- package/build/commands/end-render.js +0 -88
- package/build/commands/end-render.js.map +0 -1
- package/build/commands/prepare-assets-directory.js +0 -32
- package/build/commands/prepare-assets-directory.js.map +0 -1
- package/build/commands/prepare-domains-render.js +0 -133
- package/build/commands/prepare-domains-render.js.map +0 -1
- package/build/commands/reset-render.js +0 -22
- package/build/commands/reset-render.js.map +0 -1
- package/build/commands/start-render.js +0 -45
- package/build/commands/start-render.js.map +0 -1
- package/build/commands/upload-search-content.js +0 -180
- package/build/commands/upload-search-content.js.map +0 -1
- package/build/constants/endpoints.js +0 -42
- package/build/constants/endpoints.js.map +0 -1
- package/build/constants/envs.js +0 -68
- package/build/constants/envs.js.map +0 -1
- package/build/constants/errors.js +0 -81
- package/build/constants/errors.js.map +0 -1
- package/build/services/auth.js +0 -40
- package/build/services/auth.js.map +0 -1
- package/build/services/db-class.js +0 -49
- package/build/services/db-class.js.map +0 -1
- package/build/services/db.js +0 -34
- package/build/services/db.js.map +0 -1
- package/build/services/navigation.js +0 -96
- package/build/services/navigation.js.map +0 -1
- package/build/services/reference-fields.js +0 -131
- package/build/services/reference-fields.js.map +0 -1
- package/build/services/robots.js +0 -60
- package/build/services/robots.js.map +0 -1
- package/build/services/sites.js +0 -109
- package/build/services/sites.js.map +0 -1
- package/build/services/store.js +0 -282
- package/build/services/store.js.map +0 -1
- package/build/types/api.js +0 -3
- package/build/types/api.js.map +0 -1
- package/build/types/global.js +0 -3
- package/build/types/global.js.map +0 -1
- package/build/types/navigation.js +0 -3
- package/build/types/navigation.js.map +0 -1
- package/build/types/pages.js +0 -3
- package/build/types/pages.js.map +0 -1
- package/build/types/render.js +0 -10
- package/build/types/render.js.map +0 -1
- package/build/types/sites.js +0 -3
- package/build/types/sites.js.map +0 -1
- package/build/types/templates.js +0 -3
- package/build/types/templates.js.map +0 -1
- package/build/utils/api.js +0 -161
- package/build/utils/api.js.map +0 -1
- package/build/utils/artifacts.js +0 -34
- package/build/utils/artifacts.js.map +0 -1
- package/build/utils/brush.js +0 -30
- package/build/utils/brush.js.map +0 -1
- package/build/utils/cache.js +0 -106
- package/build/utils/cache.js.map +0 -1
- package/build/utils/check-health.js +0 -68
- package/build/utils/check-health.js.map +0 -1
- package/build/utils/core-utils.js +0 -283
- package/build/utils/core-utils.js.map +0 -1
- package/build/utils/domains.js +0 -37
- package/build/utils/domains.js.map +0 -1
- package/build/utils/errors.js +0 -30
- package/build/utils/errors.js.map +0 -1
- package/build/utils/folders.js +0 -362
- package/build/utils/folders.js.map +0 -1
- package/build/utils/images.js +0 -45
- package/build/utils/images.js.map +0 -1
- package/build/utils/instance.js +0 -66
- package/build/utils/instance.js.map +0 -1
- package/build/utils/loggin.js +0 -108
- package/build/utils/loggin.js.map +0 -1
- package/build/utils/pages.js +0 -359
- package/build/utils/pages.js.map +0 -1
- package/build/utils/render.js +0 -144
- package/build/utils/render.js.map +0 -1
- package/build/utils/sites.js +0 -240
- package/build/utils/sites.js.map +0 -1
- package/build/utils/store.js +0 -193
- package/build/utils/store.js.map +0 -1
- package/exporter/adapters/gatsby/actions/clean.ts +0 -14
- package/exporter/adapters/gatsby/actions/close.ts +0 -17
- package/exporter/adapters/gatsby/actions/data.ts +0 -25
- package/exporter/adapters/gatsby/actions/healthCheck.ts +0 -10
- package/exporter/adapters/gatsby/actions/init.ts +0 -12
- package/exporter/adapters/gatsby/actions/meta.ts +0 -18
- package/exporter/adapters/gatsby/actions/prepare.ts +0 -9
- package/exporter/adapters/gatsby/actions/relocation.ts +0 -15
- package/exporter/adapters/gatsby/actions/restore.ts +0 -36
- package/exporter/adapters/gatsby/actions/ssg.ts +0 -12
- package/exporter/adapters/gatsby/actions/sync.ts +0 -71
- package/exporter/adapters/gatsby/shared/context.ts +0 -50
- package/exporter/adapters/gatsby/shared/diff-assets.ts +0 -113
- package/exporter/adapters/gatsby/shared/extract-assets.ts +0 -61
- package/exporter/adapters/gatsby/shared/gatsby-build.ts +0 -54
- package/exporter/adapters/gatsby/shared/sync-render.ts +0 -276
- package/exporter/adapters/gatsby/shared/types.ts +0 -35
- package/exporter/build-esbuild.noop +0 -42
- package/exporter/commands/prepare-assets-directory.ts +0 -33
- package/exporter/services/db-class.ts +0 -54
- package/exporter/services/db.ts +0 -32
- package/exporter/types/render.ts +0 -59
- package/exporter/utils/artifacts.ts +0 -34
- package/exporter/utils/brush.ts +0 -34
- package/exporter/utils/check-health.ts +0 -79
- package/plugins/gatsby-plugin-svgr-loader/gatsby-node.js +0 -55
- package/plugins/gatsby-plugin-svgr-loader/package.json +0 -8
- /package/{react → exporter/react}/Favicon/utils.ts +0 -0
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
# Build CX script file
|
|
4
|
-
#
|
|
5
|
-
# This file generates the necessary builds for CX.
|
|
6
|
-
# - Setup, to generate necessary elements (tsconfig, etc..)
|
|
7
|
-
# - Library, CX library that will be used by the SSG framework.
|
|
8
|
-
# - Scripts, CX scripts that will be used by infra during the render process.
|
|
9
|
-
#
|
|
10
|
-
# @todo:
|
|
11
|
-
# In the future, we will try to eliminate the bundling processes and use
|
|
12
|
-
# TypeScript or ESModules directly.
|
|
13
|
-
|
|
14
|
-
# start
|
|
15
|
-
echo "📦 Building ..."
|
|
16
|
-
|
|
17
|
-
# CLI options
|
|
18
|
-
log="--log-level=error"
|
|
19
|
-
production_node_opts="--bundle --platform=node --minify --sourcemap"
|
|
20
|
-
debugging_node_opts="--bundle --platform=node --sourcemap"
|
|
21
|
-
# react_opts="--platform=node --external:@griddo-instance --external:react --external:react-dom --bundle --minify"
|
|
22
|
-
|
|
23
|
-
# Manage --minify for debugging
|
|
24
|
-
bundle_node_opts=$production_node_opts
|
|
25
|
-
if [ "$1" = "--debug" ]; then
|
|
26
|
-
bundle_node_opts=$debugging_node_opts
|
|
27
|
-
fi
|
|
28
|
-
|
|
29
|
-
# library
|
|
30
|
-
# esbuild ${log} ./exporter/index.ts ${bundle_node_opts} --outfile=./build/index.js
|
|
31
|
-
# esbuild ${log} ./exporter/react/index.tsx ${react_opts} --outfile=./build/react/index.js
|
|
32
|
-
|
|
33
|
-
# scripts
|
|
34
|
-
esbuild ${log} ./exporter/commands/end-render.ts ${bundle_node_opts} --outfile=./build/end-render.js
|
|
35
|
-
esbuild ${log} ./exporter/commands/upload-search-content.ts ${bundle_node_opts} --outfile=./build/upload-search-content.js
|
|
36
|
-
esbuild ${log} ./exporter/commands/reset-render.ts ${bundle_node_opts} --outfile=./build/reset-render.js
|
|
37
|
-
esbuild ${log} ./exporter/commands/start-render.ts ${bundle_node_opts} --outfile=./build/start-render.js
|
|
38
|
-
esbuild ${log} ./exporter/commands/prepare-domains-render.ts ${bundle_node_opts} --outfile=./build/prepare-domains-render.js
|
|
39
|
-
esbuild ${log} ./exporter/commands/prepare-assets-directory.ts ${bundle_node_opts} --outfile=./build/prepare-assets-directory.js
|
|
40
|
-
|
|
41
|
-
# types
|
|
42
|
-
tsc --emitDeclarationOnly --declaration --outDir build --project tsconfig.exporter.json
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import childProcess from "node:child_process";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
|
|
6
|
-
import { pathExists } from "../utils/folders";
|
|
7
|
-
import { localLog } from "../utils/loggin";
|
|
8
|
-
import { getRenderPathsFromDB } from "../utils/render";
|
|
9
|
-
|
|
10
|
-
async function prepareAssetsDir() {
|
|
11
|
-
const [domain] = process.argv.slice(2);
|
|
12
|
-
|
|
13
|
-
const { __exports } = await getRenderPathsFromDB({ domain });
|
|
14
|
-
|
|
15
|
-
const assetsDir = path.join(__exports, "assets");
|
|
16
|
-
const domainAssetsDir = path.join(__exports, domain);
|
|
17
|
-
|
|
18
|
-
if (await pathExists(assetsDir)) {
|
|
19
|
-
childProcess.execSync(`rm -rf ${domainAssetsDir}`);
|
|
20
|
-
childProcess.execSync(`mv ${assetsDir} ${domainAssetsDir}`);
|
|
21
|
-
} else {
|
|
22
|
-
localLog("Assets directory not found");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async function main() {
|
|
27
|
-
await prepareAssetsDir();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
main().catch((err) => {
|
|
31
|
-
console.error("Error", err?.stdout?.toString() || err);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { RenderDB } from "../types/render";
|
|
2
|
-
|
|
3
|
-
import fsp from "node:fs/promises";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
|
|
6
|
-
import { pkgDirSync } from "../utils/folders";
|
|
7
|
-
|
|
8
|
-
// Interfaz para abstraer la DB
|
|
9
|
-
export interface Database {
|
|
10
|
-
read(): Promise<RenderDB>;
|
|
11
|
-
write(renderDB: RenderDB): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class JsonDatabase implements Database {
|
|
15
|
-
private readonly dbFilePath: string;
|
|
16
|
-
|
|
17
|
-
constructor(customDBPath?: string) {
|
|
18
|
-
this.dbFilePath =
|
|
19
|
-
customDBPath ??
|
|
20
|
-
path.join(
|
|
21
|
-
pkgDirSync({ cwd: path.resolve(__dirname, "../../..") }) ?? "",
|
|
22
|
-
".cx-cache",
|
|
23
|
-
"db.json",
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async read(customDBFilePath?: string): Promise<RenderDB> {
|
|
28
|
-
try {
|
|
29
|
-
const raw = await fsp.readFile(customDBFilePath || this.dbFilePath, "utf-8");
|
|
30
|
-
return JSON.parse(raw) as RenderDB;
|
|
31
|
-
} catch (error) {
|
|
32
|
-
if (error instanceof Error) {
|
|
33
|
-
console.error(`Error reading DB file at ${this.dbFilePath}:`, error.message);
|
|
34
|
-
} else {
|
|
35
|
-
console.error(`Unknown error reading DB file at ${this.dbFilePath}:`, error);
|
|
36
|
-
}
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async write(renderDB: RenderDB): Promise<void> {
|
|
42
|
-
try {
|
|
43
|
-
await fsp.mkdir(path.dirname(this.dbFilePath), { recursive: true });
|
|
44
|
-
await fsp.writeFile(this.dbFilePath, JSON.stringify(renderDB, null, 2));
|
|
45
|
-
} catch (error) {
|
|
46
|
-
if (error instanceof Error) {
|
|
47
|
-
console.error(`Error writing to DB file at ${this.dbFilePath}:`, error.message);
|
|
48
|
-
} else {
|
|
49
|
-
console.error(`Unknown error writing to DB file at ${this.dbFilePath}:`, error);
|
|
50
|
-
}
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
package/exporter/services/db.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { RenderDB } from "../types/render";
|
|
2
|
-
|
|
3
|
-
import fsp from "node:fs/promises";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
|
|
6
|
-
import { pkgDirSync } from "../utils/folders";
|
|
7
|
-
|
|
8
|
-
const root = pkgDirSync({ cwd: path.resolve(__dirname, "../../..") }) || "";
|
|
9
|
-
const cache = path.join(root, ".cx-cache");
|
|
10
|
-
const dbFilePath = path.join(cache, "db.json");
|
|
11
|
-
|
|
12
|
-
async function readDB(customDBPath = "") {
|
|
13
|
-
const file = customDBPath || dbFilePath;
|
|
14
|
-
try {
|
|
15
|
-
return JSON.parse(await fsp.readFile(file, "utf-8")) as RenderDB;
|
|
16
|
-
} catch (error) {
|
|
17
|
-
console.error(`Failed to read DB file at ${file}:`, error);
|
|
18
|
-
throw error;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async function writeDB(renderDB: RenderDB, customDBPath = "") {
|
|
23
|
-
const file = customDBPath || dbFilePath;
|
|
24
|
-
try {
|
|
25
|
-
await fsp.writeFile(file, JSON.stringify(renderDB));
|
|
26
|
-
} catch (error) {
|
|
27
|
-
console.error(`Failed to write DB file at ${file}:`, error);
|
|
28
|
-
throw error;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { readDB, writeDB };
|
package/exporter/types/render.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { RenderInfo } from "./global";
|
|
2
|
-
|
|
3
|
-
const RENDER_MODE = {
|
|
4
|
-
FROM_SCRATCH: "FROM_SCRATCH",
|
|
5
|
-
INCREMENTAL: "INCREMENTAL",
|
|
6
|
-
IDLE: "IDLE",
|
|
7
|
-
} as const;
|
|
8
|
-
|
|
9
|
-
type RenderMode = (typeof RENDER_MODE)[keyof typeof RENDER_MODE];
|
|
10
|
-
|
|
11
|
-
export interface RenderModeTuple {
|
|
12
|
-
renderMode: RenderMode;
|
|
13
|
-
reason?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type DomainLike = string;
|
|
17
|
-
|
|
18
|
-
type RenderDB = {
|
|
19
|
-
proDomain: string;
|
|
20
|
-
griddoVersion: string;
|
|
21
|
-
buildReportFileName: string;
|
|
22
|
-
sortedDomains: Array<DomainLike>;
|
|
23
|
-
paths: {
|
|
24
|
-
root: string;
|
|
25
|
-
cx: string;
|
|
26
|
-
ssg: string;
|
|
27
|
-
cxCache: string;
|
|
28
|
-
components: string;
|
|
29
|
-
exportsDir: string;
|
|
30
|
-
};
|
|
31
|
-
domains: {
|
|
32
|
-
[key: DomainLike]: {
|
|
33
|
-
renderMode?: RenderMode;
|
|
34
|
-
shouldBeRendered?: boolean;
|
|
35
|
-
isRendering?: boolean;
|
|
36
|
-
renderInfo?: RenderInfo;
|
|
37
|
-
renderModeReason?: string;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
interface Report {
|
|
43
|
-
authControl:
|
|
44
|
-
| {
|
|
45
|
-
Authorization: string;
|
|
46
|
-
"Cache-Control": string;
|
|
47
|
-
lang?: string | undefined;
|
|
48
|
-
}
|
|
49
|
-
| undefined;
|
|
50
|
-
sites: Array<{
|
|
51
|
-
siteId: number;
|
|
52
|
-
publishHashes: Array<string>;
|
|
53
|
-
siteHash: string | null;
|
|
54
|
-
unpublishHashes: Array<string>;
|
|
55
|
-
publishPagesIds: Array<number>;
|
|
56
|
-
}>;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export { RENDER_MODE, type RenderDB, type RenderMode, type Report };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Artifacts } from "../types/global";
|
|
2
|
-
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
|
|
5
|
-
import { getRenderPathsFromDB } from "./render";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Returns the artifacts of CX.
|
|
9
|
-
*/
|
|
10
|
-
async function getCxArtifacts(domain: string): Promise<Artifacts> {
|
|
11
|
-
const { __exports, __cache, __root } = await getRenderPathsFromDB({ domain });
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
initials: [
|
|
15
|
-
__exports, // `<root>/exports/<domain>`
|
|
16
|
-
__cache, // `<root>/.cx-cache/<domain>`
|
|
17
|
-
path.join(__root, "store"),
|
|
18
|
-
path.join(__root, "apiCache"),
|
|
19
|
-
],
|
|
20
|
-
disposables: [
|
|
21
|
-
path.join(__root, "store"),
|
|
22
|
-
path.join(__root, "apiCache"),
|
|
23
|
-
path.join(__root, "dist"),
|
|
24
|
-
path.join(__root, "dist-restored"),
|
|
25
|
-
path.join(__root, "debug"),
|
|
26
|
-
path.join(__root, "assets"),
|
|
27
|
-
],
|
|
28
|
-
cacheables: [],
|
|
29
|
-
archivables: ["dist", "debug", "assets"],
|
|
30
|
-
restaurable: ["dist", "debug"],
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { getCxArtifacts };
|
package/exporter/utils/brush.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Brush adds color to a string|number, it does not print it!
|
|
3
|
-
// Its simple, no log, no chains, just color in a string|number
|
|
4
|
-
// usage:
|
|
5
|
-
// console.log(brush.green("sucess!"))
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
const RESET = "\x1b[0m";
|
|
9
|
-
const CODES = {
|
|
10
|
-
black: "\x1b[30m",
|
|
11
|
-
red: "\x1b[31m",
|
|
12
|
-
green: "\x1b[32m",
|
|
13
|
-
yellow: "\x1b[33m",
|
|
14
|
-
blue: "\x1b[34m",
|
|
15
|
-
magenta: "\x1b[35m",
|
|
16
|
-
cyan: "\x1b[36m",
|
|
17
|
-
white: "\x1b[37m",
|
|
18
|
-
gray: "\x1b[90m",
|
|
19
|
-
bold: "\x1b[1m",
|
|
20
|
-
dim: "\x1b[2m",
|
|
21
|
-
} as const;
|
|
22
|
-
|
|
23
|
-
type ColorFunction = (text: string | number) => string;
|
|
24
|
-
type ColorName = keyof typeof CODES;
|
|
25
|
-
type Brush = Record<ColorName, ColorFunction>;
|
|
26
|
-
|
|
27
|
-
const brush = {} as Brush;
|
|
28
|
-
|
|
29
|
-
for (const color in CODES) {
|
|
30
|
-
const key = color as ColorName;
|
|
31
|
-
brush[key] = (text: string | number) => `${CODES[key]}${text}${RESET}`;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { brush };
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { CheckHealthError } from "../constants/errors";
|
|
4
|
-
import { isTruthy } from "./core-utils";
|
|
5
|
-
import { throwError } from "./errors";
|
|
6
|
-
|
|
7
|
-
const GRIDDO_ENVS_VARS: ReadonlyArray<string> = [];
|
|
8
|
-
const GRIDDO_SKIP_BUILD_CHECKS = isTruthy(process.env.GRIDDO_SKIP_BUILD_CHECKS);
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Check if a list of environments variables exist with any value.
|
|
12
|
-
*
|
|
13
|
-
* @todo Also check the value.
|
|
14
|
-
* @param envs An array of environments variables
|
|
15
|
-
* @returns exists with (1) if there are missing envs vars
|
|
16
|
-
*/
|
|
17
|
-
function checkEnvsVars(envs: ReadonlyArray<string>) {
|
|
18
|
-
const missingEnvs = envs.filter((envName) => {
|
|
19
|
-
return !process.env[envName];
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
if (missingEnvs.length) {
|
|
23
|
-
const missingEnvsMsg = missingEnvs.join("\n");
|
|
24
|
-
console.error(`Env check failed. These envs vars are missing: \n\n${missingEnvsMsg}`);
|
|
25
|
-
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function checkEnvsVarsAndValues(envs: Array<Record<string, string>>): boolean {
|
|
33
|
-
for (const env of envs) {
|
|
34
|
-
const [key, expected] = Object.entries(env)[0];
|
|
35
|
-
const actual = process.env[key];
|
|
36
|
-
|
|
37
|
-
if (actual !== expected) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Check if the environment is secure to launch a render.
|
|
46
|
-
* If something fails then log an error message and exit from the process.
|
|
47
|
-
* Otherwise just return true.
|
|
48
|
-
*/
|
|
49
|
-
export function checkHealth() {
|
|
50
|
-
// Bypass the check using this env var, handy for local renders.
|
|
51
|
-
if (GRIDDO_SKIP_BUILD_CHECKS) {
|
|
52
|
-
console.info("Build health check skipped");
|
|
53
|
-
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Checklist
|
|
58
|
-
// check if it's setted
|
|
59
|
-
const areRequiredEnvsSet = checkEnvsVars(GRIDDO_ENVS_VARS);
|
|
60
|
-
// check if it's setted and the value
|
|
61
|
-
const areEnvsMatchingExpected = checkEnvsVarsAndValues([
|
|
62
|
-
{
|
|
63
|
-
GRIDDO_RENDER_BY_DOMAINS: "true",
|
|
64
|
-
},
|
|
65
|
-
]);
|
|
66
|
-
|
|
67
|
-
// Render is safe if...
|
|
68
|
-
const isSafeToRender = areRequiredEnvsSet && areEnvsMatchingExpected;
|
|
69
|
-
|
|
70
|
-
// The environment is suitable for a build-render
|
|
71
|
-
if (isSafeToRender) {
|
|
72
|
-
console.info("\nBuild health check passed\n");
|
|
73
|
-
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Error
|
|
78
|
-
throwError(CheckHealthError);
|
|
79
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
exports.onCreateWebpackConfig = (
|
|
2
|
-
{ stage, actions, getConfig, rules },
|
|
3
|
-
{ rule: ruleProps = {} },
|
|
4
|
-
) => {
|
|
5
|
-
const { include, exclude, options, ...otherProps } = ruleProps;
|
|
6
|
-
|
|
7
|
-
if (["develop", "develop-html", "build-html", "build-javascript"].includes(stage)) {
|
|
8
|
-
// Add the react-svg-loader rule
|
|
9
|
-
actions.setWebpackConfig({
|
|
10
|
-
module: {
|
|
11
|
-
rules: [
|
|
12
|
-
{
|
|
13
|
-
test: /\.svg$/,
|
|
14
|
-
include,
|
|
15
|
-
exclude,
|
|
16
|
-
...otherProps,
|
|
17
|
-
use: [
|
|
18
|
-
{
|
|
19
|
-
loader: "@svgr/webpack",
|
|
20
|
-
options,
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
const cfg = getConfig();
|
|
28
|
-
const imgsRule = rules.images();
|
|
29
|
-
|
|
30
|
-
const newUrlLoaderRule =
|
|
31
|
-
include || exclude
|
|
32
|
-
? {
|
|
33
|
-
...imgsRule,
|
|
34
|
-
include: exclude,
|
|
35
|
-
exclude: include,
|
|
36
|
-
}
|
|
37
|
-
: {
|
|
38
|
-
...imgsRule,
|
|
39
|
-
test: new RegExp(imgsRule.test.toString().replace("svg|", "").slice(1, -1)),
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
cfg.module.rules = [
|
|
43
|
-
// Remove the base url-loader images rule entirely
|
|
44
|
-
...cfg.module.rules.filter((rule) => {
|
|
45
|
-
if (rule.test) {
|
|
46
|
-
return rule.test.toString() !== imgsRule.test.toString();
|
|
47
|
-
}
|
|
48
|
-
return true;
|
|
49
|
-
}),
|
|
50
|
-
// Put it back without SVG loading
|
|
51
|
-
newUrlLoaderRule,
|
|
52
|
-
];
|
|
53
|
-
actions.replaceWebpackConfig(cfg);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
File without changes
|