@griddo/cx 11.7.6-rc.1 → 11.7.6
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 +228 -25
- 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/move-assets.d.ts +1 -0
- package/build/commands/prepare-domains-render.d.ts +1 -0
- package/build/{exporter/constants → constants}/envs.d.ts +7 -1
- 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/{exporter/constants/errors.d.ts → errors/errors-data.d.ts} +3 -5
- package/build/{exporter/utils/errors.d.ts → errors/index.d.ts} +3 -3
- 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/{exporter/services → services}/auth.d.ts +1 -1
- package/build/services/domains.d.ts +6 -0
- package/build/services/register.d.ts +36 -0
- package/build/{exporter/services → services}/robots.d.ts +6 -0
- package/build/services/settings.d.ts +4 -0
- package/build/{exporter/services → services}/sites.d.ts +2 -5
- 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/{exporter/types → types}/api.d.ts +4 -3
- package/build/{exporter/types → types}/global.d.ts +6 -6
- package/build/{exporter/types → types}/navigation.d.ts +1 -1
- package/build/{exporter/types → types}/sites.d.ts +2 -1
- 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/{exporter/utils → utils}/cache.d.ts +12 -7
- package/build/utils/core-utils.d.ts +107 -0
- package/build/utils/create-build-data.d.ts +8 -0
- package/build/{exporter/utils → utils}/domains.d.ts +1 -1
- package/build/utils/folders.d.ts +53 -0
- package/build/{exporter/utils/check-health.d.ts → utils/health-checks.d.ts} +2 -2
- package/build/{exporter/utils → utils}/loggin.d.ts +16 -2
- package/build/{exporter/utils → utils}/pages.d.ts +2 -2
- package/build/utils/render.d.ts +13 -0
- package/build/utils/searches.d.ts +15 -0
- package/build/{exporter/utils → utils}/sites.d.ts +3 -3
- package/build/{exporter/utils → utils}/store.d.ts +38 -10
- package/cx.config.d.ts +5 -0
- package/cx.config.js +36 -0
- package/exporter/adapters/gatsby/index.ts +146 -60
- package/exporter/adapters/gatsby/utils.ts +161 -0
- package/exporter/artifacts/README.md +34 -0
- package/exporter/{utils/artifacts.ts → artifacts/index.ts} +8 -9
- package/exporter/build.sh +38 -5
- package/exporter/commands/end-render.ts +81 -56
- package/exporter/commands/move-assets.ts +11 -0
- package/exporter/commands/prepare-domains-render.ts +31 -149
- package/exporter/commands/reset-render.ts +3 -12
- package/exporter/commands/start-render.ts +47 -18
- package/exporter/commands/upload-search-content.ts +21 -206
- package/exporter/constants/envs.ts +51 -59
- package/exporter/constants/index.ts +129 -0
- package/exporter/{constants/errors.ts → errors/errors-data.ts} +15 -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 +15 -8
- package/exporter/services/settings.ts +17 -0
- package/exporter/services/sites.ts +24 -35
- package/exporter/services/store.ts +76 -118
- package/exporter/types/api.ts +27 -24
- package/exporter/types/global.ts +10 -8
- 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 +59 -34
- package/exporter/utils/core-utils.ts +247 -86
- package/exporter/utils/create-build-data.ts +17 -0
- package/exporter/utils/domains.ts +7 -10
- package/exporter/utils/folders.ts +92 -161
- 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 +89 -24
- package/exporter/utils/pages.ts +88 -23
- package/exporter/utils/render.ts +48 -147
- package/exporter/utils/searches.ts +156 -0
- package/exporter/utils/sites.ts +77 -67
- package/exporter/utils/store.ts +178 -85
- 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 +74 -33
- 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 +3 -1
- package/tsconfig.json +2 -3
- 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 -50
- package/build/adapters/gatsby/actions/sync.js.map +0 -1
- package/build/adapters/gatsby/index.js +0 -74
- package/build/adapters/gatsby/index.js.map +0 -1
- package/build/adapters/gatsby/shared/context.js +0 -25
- package/build/adapters/gatsby/shared/context.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 -208
- 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 -63
- 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 -138
- 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 -35
- package/build/commands/start-render.js.map +0 -1
- package/build/commands/upload-search-content.js +0 -189
- 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 -73
- package/build/constants/envs.js.map +0 -1
- package/build/constants/errors.js +0 -89
- package/build/constants/errors.js.map +0 -1
- package/build/exporter/adapters/gatsby/actions/clean.d.ts +0 -3
- package/build/exporter/adapters/gatsby/actions/close.d.ts +0 -3
- package/build/exporter/adapters/gatsby/actions/data.d.ts +0 -2
- package/build/exporter/adapters/gatsby/actions/healthCheck.d.ts +0 -2
- package/build/exporter/adapters/gatsby/actions/init.d.ts +0 -2
- package/build/exporter/adapters/gatsby/actions/meta.d.ts +0 -2
- package/build/exporter/adapters/gatsby/actions/prepare.d.ts +0 -2
- package/build/exporter/adapters/gatsby/actions/relocation.d.ts +0 -2
- package/build/exporter/adapters/gatsby/actions/restore.d.ts +0 -3
- package/build/exporter/adapters/gatsby/actions/ssg.d.ts +0 -3
- package/build/exporter/adapters/gatsby/actions/sync.d.ts +0 -3
- package/build/exporter/adapters/gatsby/index.d.ts +0 -9
- package/build/exporter/adapters/gatsby/shared/context.d.ts +0 -38
- package/build/exporter/adapters/gatsby/shared/extract-assets.d.ts +0 -7
- package/build/exporter/adapters/gatsby/shared/gatsby-build.d.ts +0 -7
- package/build/exporter/adapters/gatsby/shared/sync-render.d.ts +0 -36
- package/build/exporter/adapters/gatsby/shared/types.d.ts +0 -34
- package/build/exporter/commands/prepare-assets-directory.d.ts +0 -2
- package/build/exporter/commands/prepare-domains-render.d.ts +0 -2
- package/build/exporter/services/db.d.ts +0 -4
- package/build/exporter/services/store.d.ts +0 -15
- package/build/exporter/types/render.d.ts +0 -50
- package/build/exporter/utils/artifacts.d.ts +0 -6
- package/build/exporter/utils/brush.d.ts +0 -18
- package/build/exporter/utils/core-utils.d.ts +0 -77
- package/build/exporter/utils/folders.d.ts +0 -66
- package/build/exporter/utils/render.d.ts +0 -49
- package/build/services/auth.js +0 -39
- package/build/services/auth.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 -93
- 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 -58
- 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 -251
- 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 -339
- 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 -102
- 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 -239
- 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 -70
- package/exporter/adapters/gatsby/shared/context.ts +0 -50
- 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 -294
- 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.ts +0 -32
- package/exporter/types/render.ts +0 -59
- 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/build/{exporter/commands → commands}/end-render.d.ts +0 -0
- package/build/{exporter/commands → commands}/reset-render.d.ts +0 -0
- package/build/{exporter/commands → commands}/start-render.d.ts +0 -0
- package/build/{exporter/commands → commands}/upload-search-content.d.ts +0 -0
- package/build/{exporter/constants → constants}/endpoints.d.ts +0 -0
- package/build/{exporter/services → services}/navigation.d.ts +0 -0
- package/build/{exporter/services → services}/reference-fields.d.ts +0 -0
- package/build/{exporter/types → types}/pages.d.ts +1 -1
- /package/build/{exporter/types → types}/templates.d.ts +0 -0
- /package/build/{exporter/utils → utils}/api.d.ts +0 -0
- /package/build/{exporter/utils → utils}/images.d.ts +0 -0
- /package/build/{exporter/utils → utils}/instance.d.ts +0 -0
- /package/{react → exporter/react}/Favicon/utils.ts +0 -0
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { RenderContext } from "../shared/context";
|
|
2
|
-
import type { SSG } from "../shared/types";
|
|
3
|
-
|
|
4
|
-
import fsp from "node:fs/promises";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
|
|
7
|
-
import { RENDER_MODE } from "../../../types/render";
|
|
8
|
-
import {
|
|
9
|
-
deleteDisposableSiteDirs,
|
|
10
|
-
deleteEmptyDirectories,
|
|
11
|
-
moveDirs,
|
|
12
|
-
removeVirtualPages,
|
|
13
|
-
} from "../../../utils/folders";
|
|
14
|
-
import { extractAssetsFromDist } from "../shared/extract-assets";
|
|
15
|
-
import { SyncRender } from "../shared/sync-render";
|
|
16
|
-
|
|
17
|
-
export async function syncAction(context: RenderContext<SSG>) {
|
|
18
|
-
const {
|
|
19
|
-
renderMode,
|
|
20
|
-
cxArtifacts,
|
|
21
|
-
domain,
|
|
22
|
-
pagesToCreate,
|
|
23
|
-
pagesToDelete,
|
|
24
|
-
paths: { __cx, __ssg, __cache, __exports },
|
|
25
|
-
ssg: { ssgArtifacts, assetPrefix },
|
|
26
|
-
} = context;
|
|
27
|
-
|
|
28
|
-
const needsAssetPrefix = !!assetPrefix && assetPrefix !== "";
|
|
29
|
-
const distDir = path.join(__cx, "dist");
|
|
30
|
-
const distRestoredDir = path.join(__cx, "dist-restored");
|
|
31
|
-
const storeDir = path.join(context.paths.__cx, "store");
|
|
32
|
-
|
|
33
|
-
await removeVirtualPages(storeDir);
|
|
34
|
-
// caching...
|
|
35
|
-
await moveDirs(__cx, __cache, cxArtifacts.cacheables);
|
|
36
|
-
await moveDirs(__ssg, __cache, ssgArtifacts.cacheables);
|
|
37
|
-
|
|
38
|
-
if (renderMode === RENDER_MODE.FROM_SCRATCH) {
|
|
39
|
-
await deleteDisposableSiteDirs(distDir);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (renderMode === RENDER_MODE.INCREMENTAL) {
|
|
43
|
-
await deleteDisposableSiteDirs(distRestoredDir);
|
|
44
|
-
|
|
45
|
-
const syncRender = new SyncRender({
|
|
46
|
-
src: distDir,
|
|
47
|
-
dst: distRestoredDir,
|
|
48
|
-
pagesToCreate,
|
|
49
|
-
pagesToDelete,
|
|
50
|
-
artifactsToCopyToExports: ["build-report.json"],
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
syncRender.setPagesToDelete();
|
|
54
|
-
syncRender.setPagesToAdd();
|
|
55
|
-
syncRender.sync();
|
|
56
|
-
|
|
57
|
-
await fsp.rm(distDir, { force: true, recursive: true });
|
|
58
|
-
await fsp.rename(distRestoredDir, distDir);
|
|
59
|
-
await deleteEmptyDirectories(distDir);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (needsAssetPrefix) {
|
|
63
|
-
await extractAssetsFromDist(domain);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// archiving...
|
|
67
|
-
await moveDirs(__cx, __exports, cxArtifacts.archivables, {
|
|
68
|
-
withBackup: true,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { Artifacts, PlaceholderPath } from "../../../types/global";
|
|
2
|
-
import type { RenderMode } from "../../../types/render";
|
|
3
|
-
|
|
4
|
-
interface RenderContextProps<T> {
|
|
5
|
-
domain: string;
|
|
6
|
-
renderMode: RenderMode;
|
|
7
|
-
paths: Record<string, string>;
|
|
8
|
-
ssg: T;
|
|
9
|
-
renderMetadata: {
|
|
10
|
-
proDomain: string;
|
|
11
|
-
griddoVersion: string;
|
|
12
|
-
buildReportFileName: string;
|
|
13
|
-
};
|
|
14
|
-
cxArtifacts: Artifacts;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Encapsulates the state, configuration, and artifacts for a single SSG
|
|
19
|
-
* render process.
|
|
20
|
-
*
|
|
21
|
-
* This class is instantiated at the beginning of a render and passed through
|
|
22
|
-
* each lifecycle step, providing a centralized and consistent context for all
|
|
23
|
-
* operations. It is agnostic to the specific SSG being used.
|
|
24
|
-
*/
|
|
25
|
-
export class RenderContext<T = unknown> {
|
|
26
|
-
readonly domain: string;
|
|
27
|
-
readonly renderMode: RenderMode;
|
|
28
|
-
readonly paths: Record<PlaceholderPath, string>;
|
|
29
|
-
pagesToCreate: number[] = [];
|
|
30
|
-
pagesToDelete: number[] = [];
|
|
31
|
-
ssg: T;
|
|
32
|
-
renderMetadata: { proDomain: string; griddoVersion: string; buildReportFileName: string };
|
|
33
|
-
cxArtifacts: Artifacts;
|
|
34
|
-
|
|
35
|
-
constructor({
|
|
36
|
-
domain,
|
|
37
|
-
renderMode,
|
|
38
|
-
ssg,
|
|
39
|
-
paths,
|
|
40
|
-
renderMetadata,
|
|
41
|
-
cxArtifacts,
|
|
42
|
-
}: RenderContextProps<T>) {
|
|
43
|
-
this.domain = domain;
|
|
44
|
-
this.renderMode = renderMode;
|
|
45
|
-
this.paths = paths;
|
|
46
|
-
this.renderMetadata = renderMetadata;
|
|
47
|
-
this.cxArtifacts = cxArtifacts;
|
|
48
|
-
this.ssg = ssg;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import fsp from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
import { pathExists } from "../../../utils/folders";
|
|
5
|
-
import { getRenderPathsFromDB } from "../../../utils/render";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Update the Griddo's `/dist` dir with the contents from `public` dir only
|
|
9
|
-
* with files of type: js, json and css.
|
|
10
|
-
* TODO: Explicar que el static se copia a assets porque el js va en el subdominio de assets.
|
|
11
|
-
*/
|
|
12
|
-
async function extractAssetsFromDist(domain: string) {
|
|
13
|
-
const { __cx } = await getRenderPathsFromDB({ domain });
|
|
14
|
-
|
|
15
|
-
// Archivos (no carpetas) válidos de public
|
|
16
|
-
const filesFromDist = (await fsp.readdir(path.join(__cx, "dist"))).filter(
|
|
17
|
-
(file) =>
|
|
18
|
-
path.extname(file) === ".js" ||
|
|
19
|
-
path.extname(file) === ".json" ||
|
|
20
|
-
path.extname(file) === ".css",
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
// Creamos assets si es necesario (needsAssetPrefix)
|
|
24
|
-
await fsp.mkdir(path.join(__cx, "assets"), { recursive: true });
|
|
25
|
-
// page-data folder
|
|
26
|
-
await fsp.cp(path.join(__cx, "dist", "page-data"), path.join(__cx, "assets", "page-data"), {
|
|
27
|
-
preserveTimestamps: true,
|
|
28
|
-
recursive: true,
|
|
29
|
-
});
|
|
30
|
-
// static folder si existe
|
|
31
|
-
if (await pathExists(path.join(__cx, "static"))) {
|
|
32
|
-
await fsp.cp(path.join(__cx, "static"), path.join(__cx, "assets"), {
|
|
33
|
-
force: false,
|
|
34
|
-
preserveTimestamps: true,
|
|
35
|
-
recursive: true,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
// dist/static -> assets/static
|
|
39
|
-
await fsp.cp(path.join(__cx, "dist", "static"), path.join(__cx, "assets", "static"), {
|
|
40
|
-
force: false,
|
|
41
|
-
preserveTimestamps: true,
|
|
42
|
-
recursive: true,
|
|
43
|
-
});
|
|
44
|
-
// otro static...
|
|
45
|
-
if (await pathExists(path.join(__cx, "static"))) {
|
|
46
|
-
await fsp.cp(path.join(__cx, "static"), path.join(__cx, "dist", domain), {
|
|
47
|
-
preserveTimestamps: true,
|
|
48
|
-
recursive: true,
|
|
49
|
-
force: false,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Copia el resto de archivos...
|
|
54
|
-
for (const file of filesFromDist) {
|
|
55
|
-
const fileSrc = path.join(__cx, "dist", file);
|
|
56
|
-
const fileDest = path.join(__cx, "assets", file);
|
|
57
|
-
await fsp.cp(fileSrc, fileDest, { preserveTimestamps: true, recursive: true });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export { extractAssetsFromDist };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
|
|
3
|
-
import { GRIDDO_SSG_VERBOSE_LOGS } from "../../../constants/envs";
|
|
4
|
-
import { verboseLog } from "../../../utils/loggin";
|
|
5
|
-
import { getRenderPathsFromDB } from "../../../utils/render";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Spawn a new node process `yarn gatsby-build`
|
|
9
|
-
* @note This proccess (`yarn gatsby-build`) can not access to the custom Griddo
|
|
10
|
-
* `process.env` so it needs variables passed to it via the `env` prop.
|
|
11
|
-
*/
|
|
12
|
-
async function gatsbyBuild(assetPrefixWithDomain: string): Promise<void> {
|
|
13
|
-
verboseLog(`read assetPrefixWithDomain, ${assetPrefixWithDomain}`);
|
|
14
|
-
verboseLog(`using this NODE_OPTIONS in gatsby command: ${process.env.NODE_OPTIONS}`);
|
|
15
|
-
|
|
16
|
-
const { __ssg } = await getRenderPathsFromDB();
|
|
17
|
-
|
|
18
|
-
// Remove `--openssl-legacy-provider` from NODE_OPTIONS because this value
|
|
19
|
-
// break Gatsby render.
|
|
20
|
-
const nodeOptionsWithoutLegacyOpenSSL = process.env.NODE_OPTIONS
|
|
21
|
-
? process.env.NODE_OPTIONS.replace(/--openssl-legacy-provider\s*/g, "").trim()
|
|
22
|
-
: "";
|
|
23
|
-
|
|
24
|
-
const args = ["gatsby-build"];
|
|
25
|
-
if (GRIDDO_SSG_VERBOSE_LOGS) {
|
|
26
|
-
args.push("--verbose");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
const child = spawn("yarn", args, {
|
|
31
|
-
cwd: __ssg,
|
|
32
|
-
stdio: ["ignore", "inherit", "inherit"], // stdout y stderr van a consola directamente
|
|
33
|
-
env: Object.assign(process.env, {
|
|
34
|
-
GRIDDO_EXPORTER: "true",
|
|
35
|
-
SPAWN_ASSET_PREFIX_WITH_DOMAIN: assetPrefixWithDomain,
|
|
36
|
-
NODE_OPTIONS: nodeOptionsWithoutLegacyOpenSSL,
|
|
37
|
-
}),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
child.on("close", (code) => {
|
|
41
|
-
if (code === 0) {
|
|
42
|
-
resolve();
|
|
43
|
-
} else {
|
|
44
|
-
reject(new Error(`Gatsby build failed with exit code ${code}`));
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
child.on("error", (error) => {
|
|
49
|
-
reject(new Error(`Failed to start Gatsby build process: ${error.message}`));
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { gatsbyBuild };
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
import { verboseLog } from "../../../utils/loggin";
|
|
5
|
-
|
|
6
|
-
type SyncRenderConfig = {
|
|
7
|
-
src: string;
|
|
8
|
-
dst: string;
|
|
9
|
-
pagesToCreate: Array<number>;
|
|
10
|
-
pagesToDelete: Array<number>;
|
|
11
|
-
artifactsToCopyToExports: Array<string>;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type CopyFilePath = {
|
|
15
|
-
from: string;
|
|
16
|
-
to: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type SyncState = {
|
|
20
|
-
htmlToAdd: Array<CopyFilePath>;
|
|
21
|
-
jsonToAdd: Array<CopyFilePath>;
|
|
22
|
-
htmlToDelete: Array<string>;
|
|
23
|
-
jsonToDelete: Array<string>;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
class SyncRender {
|
|
27
|
-
private bundleDir: string;
|
|
28
|
-
private currentRenderDir: string;
|
|
29
|
-
private pagesToCreate: Array<number>;
|
|
30
|
-
private pagesToDelete: Array<number>;
|
|
31
|
-
private assetArtifacts: Array<string>;
|
|
32
|
-
|
|
33
|
-
private state: SyncState = {
|
|
34
|
-
htmlToAdd: [],
|
|
35
|
-
jsonToAdd: [],
|
|
36
|
-
htmlToDelete: [],
|
|
37
|
-
jsonToDelete: [],
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
constructor(config: SyncRenderConfig) {
|
|
41
|
-
this.bundleDir = config.dst;
|
|
42
|
-
this.currentRenderDir = config.src;
|
|
43
|
-
this.pagesToCreate = config.pagesToCreate;
|
|
44
|
-
this.pagesToDelete = config.pagesToDelete;
|
|
45
|
-
this.assetArtifacts = config.artifactsToCopyToExports;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Se basa en los paths encontrados en page-data.json y no en recorrer físicamente el file-system
|
|
49
|
-
setPagesToDelete() {
|
|
50
|
-
// El set de ids están tanto las páginas que se van a crear como borrar.
|
|
51
|
-
// El por qué poner las que se van a crear es porque necesitamos quitar esas páginas con esos ids por si las que se van a crear tienen otro slug.
|
|
52
|
-
// Por ejemplo si se va crear la página id3 con slug /page-with-new-slug
|
|
53
|
-
// pero existía antes con el slug /page se borrará /page del sistema de
|
|
54
|
-
// ficheros y después se creará /page-with-new-slug ya que solo puede
|
|
55
|
-
// existir una página con el mismo id salvo que sea Multi-Page o
|
|
56
|
-
// Listado-Estático.
|
|
57
|
-
const idSet = new Set<number>([...this.pagesToDelete, ...this.pagesToCreate]);
|
|
58
|
-
const composePaths = this.getPageComposePaths(this.bundleDir);
|
|
59
|
-
|
|
60
|
-
for (const compose of composePaths) {
|
|
61
|
-
const normalizedCompose = compose === "/" ? "index" : compose;
|
|
62
|
-
const json = JSON.parse(
|
|
63
|
-
fs.readFileSync(
|
|
64
|
-
path.join(this.bundleDir, "page-data", normalizedCompose, "page-data.json"),
|
|
65
|
-
"utf8",
|
|
66
|
-
),
|
|
67
|
-
);
|
|
68
|
-
const id = json.result.pageContext.id;
|
|
69
|
-
const pagePath = json.result.pageContext.fullPath.compose as string;
|
|
70
|
-
// si el id de la página está en los ids para borrar (idSet) se añade
|
|
71
|
-
if (idSet.has(id)) {
|
|
72
|
-
try {
|
|
73
|
-
this.state.htmlToDelete.push(path.join(this.bundleDir, pagePath, "index.html"));
|
|
74
|
-
this.state.jsonToDelete.push(
|
|
75
|
-
path.join(
|
|
76
|
-
this.bundleDir,
|
|
77
|
-
"page-data",
|
|
78
|
-
pagePath === "/" ? "index" : pagePath,
|
|
79
|
-
"page-data.json",
|
|
80
|
-
),
|
|
81
|
-
);
|
|
82
|
-
} catch (e) {
|
|
83
|
-
console.log(e);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
verboseLog(`${this.state.htmlToDelete.length} pages HTML to delete`);
|
|
89
|
-
verboseLog(`${this.state.jsonToDelete.length} pages JSON to delete`);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Se basa en los paths encontrados en page-data.json y no en recorrer físicamente el file-system
|
|
93
|
-
// Cuando añadimos una página con id 3 (p.e.), hay que buscar todas las
|
|
94
|
-
// páginas con ese id en el bundle y borrar sus html/json. Esto va a pasar
|
|
95
|
-
// por ejemplo si cambiamos el slug de la página 3. Eso hará que se guarde
|
|
96
|
-
// en distintas carpetas pero no es una página que venga en "pagesToDelete"
|
|
97
|
-
setPagesToAdd() {
|
|
98
|
-
const idSet = new Set<number>(this.pagesToCreate);
|
|
99
|
-
const composePaths = this.getPageComposePaths(this.currentRenderDir);
|
|
100
|
-
|
|
101
|
-
for (const compose of composePaths) {
|
|
102
|
-
// 1 - leemos el page-data.json de la página para añadir
|
|
103
|
-
// Gatsby crea un directorio `index` para la página raíz `/`
|
|
104
|
-
const normalizedCompose = compose === "/" ? "index" : compose;
|
|
105
|
-
const json = JSON.parse(
|
|
106
|
-
fs.readFileSync(
|
|
107
|
-
path.join(this.currentRenderDir, "page-data", normalizedCompose, "page-data.json"),
|
|
108
|
-
"utf8",
|
|
109
|
-
),
|
|
110
|
-
);
|
|
111
|
-
// 2 - sacamos el id
|
|
112
|
-
const id = json.result.pageContext.id;
|
|
113
|
-
|
|
114
|
-
// 3 - obtenemos el src y dst del HTML
|
|
115
|
-
const htmlFrom = path.join(this.currentRenderDir, compose, "index.html");
|
|
116
|
-
const htmlTo = path.join(this.bundleDir, compose, "index.html");
|
|
117
|
-
// 4 - obtenemos el src/dst del JSON
|
|
118
|
-
const jsonFrom = path.join(
|
|
119
|
-
this.currentRenderDir,
|
|
120
|
-
"page-data",
|
|
121
|
-
normalizedCompose,
|
|
122
|
-
"page-data.json",
|
|
123
|
-
);
|
|
124
|
-
const jsonTo = path.join(this.bundleDir, "page-data", normalizedCompose, "page-data.json");
|
|
125
|
-
|
|
126
|
-
// Solo actuamos en la página si su id está en pagesToCreate
|
|
127
|
-
if (idSet.has(id)) {
|
|
128
|
-
try {
|
|
129
|
-
this.state.htmlToAdd.push({ from: htmlFrom, to: htmlTo });
|
|
130
|
-
this.state.jsonToAdd.push({ from: jsonFrom, to: jsonTo });
|
|
131
|
-
} catch (e) {
|
|
132
|
-
console.log(e);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
verboseLog(`${this.state.htmlToAdd.length} pages HTML to create`);
|
|
137
|
-
verboseLog(`${this.state.jsonToAdd.length} pages JSON to create`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Realiza la sincronización de los archivos HTML y JSON entre el directorio
|
|
143
|
-
* actual de renderizado y el directorio de exportación.
|
|
144
|
-
*/
|
|
145
|
-
sync() {
|
|
146
|
-
// remove html's
|
|
147
|
-
for (const html of this.state.htmlToDelete) {
|
|
148
|
-
try {
|
|
149
|
-
fs.rmSync(html);
|
|
150
|
-
verboseLog(`Sync (remove) : ${html}`);
|
|
151
|
-
} catch (e) {
|
|
152
|
-
console.log(`Does not exist ${html}`, e);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// remove json's
|
|
157
|
-
for (const json of this.state.jsonToDelete) {
|
|
158
|
-
try {
|
|
159
|
-
fs.rmSync(json);
|
|
160
|
-
verboseLog(`Sync (remove) : ${json}`);
|
|
161
|
-
} catch (e) {
|
|
162
|
-
console.log(`Does not exist ${json}`, e);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// copy html's
|
|
167
|
-
for (const html of this.state.htmlToAdd) {
|
|
168
|
-
fs.mkdirSync(path.dirname(html.to), { recursive: true });
|
|
169
|
-
fs.copyFileSync(html.from, html.to);
|
|
170
|
-
verboseLog(`Sync (copy) : ${html.from} -> ${html.to}`);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// copy json's
|
|
174
|
-
for (const json of this.state.jsonToAdd) {
|
|
175
|
-
fs.mkdirSync(path.dirname(json.to), { recursive: true });
|
|
176
|
-
fs.copyFileSync(json.from, json.to);
|
|
177
|
-
verboseLog(`Sync (copy) : ${json.from} -> ${json.to}`);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// update app-data.json (update the webpackCompilationHash)
|
|
181
|
-
this.copyAppDataJsonFile();
|
|
182
|
-
|
|
183
|
-
// copy artifacts
|
|
184
|
-
this.copyDirs();
|
|
185
|
-
|
|
186
|
-
// copy sitemaps
|
|
187
|
-
this.copySitemaps();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Busca archivos por extensión de forma recursiva en un directorio.
|
|
192
|
-
* @param dir Directorio base.
|
|
193
|
-
* @param extension Extensión a buscar (ej: ".ts", ".js").
|
|
194
|
-
* @returns Lista de rutas absolutas de archivos encontrados.
|
|
195
|
-
*/
|
|
196
|
-
private findFilesByExtension(dir: string, extension: string): Array<string> {
|
|
197
|
-
let results: Array<string> = [];
|
|
198
|
-
|
|
199
|
-
if (!fs.existsSync(dir)) {
|
|
200
|
-
return [];
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const list = fs.readdirSync(dir, { withFileTypes: true });
|
|
204
|
-
|
|
205
|
-
for (const item of list) {
|
|
206
|
-
const fullPath = path.join(dir, item.name);
|
|
207
|
-
|
|
208
|
-
if (item.isDirectory()) {
|
|
209
|
-
results = results.concat(this.findFilesByExtension(fullPath, extension));
|
|
210
|
-
} else if (item.isFile() && fullPath.endsWith(extension)) {
|
|
211
|
-
results.push(fullPath);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return results;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
private findAllPageDataJsons(dir: string) {
|
|
219
|
-
return this.findFilesByExtension(dir, ".json").filter((n) => n.endsWith("page-data.json"));
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
private getPageComposePaths(src: string) {
|
|
223
|
-
// [page-data/foo/bar/page-data.json, ...]
|
|
224
|
-
const allPageDataJson = this.findAllPageDataJsons(src);
|
|
225
|
-
|
|
226
|
-
// Array de fullPaths
|
|
227
|
-
// Entre ellos un fullPath puede ser: "/" (El root de la instancia)
|
|
228
|
-
|
|
229
|
-
// No sé si hacer esto en este momento...
|
|
230
|
-
// fullPath: "/foo/bar" => "foo/bar"
|
|
231
|
-
// fullPath: "/" => "index"
|
|
232
|
-
return allPageDataJson.map(
|
|
233
|
-
(p) => JSON.parse(fs.readFileSync(p, "utf-8")).result.pageContext.fullPath.compose,
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
private copyAppDataJsonFile() {
|
|
238
|
-
fs.copyFileSync(
|
|
239
|
-
path.join(this.currentRenderDir, "page-data", "app-data.json"),
|
|
240
|
-
path.join(this.bundleDir, "page-data", "app-data.json"),
|
|
241
|
-
);
|
|
242
|
-
verboseLog("Copied app-data.json");
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
private copyDirs() {
|
|
246
|
-
for (const assetArtifact of this.assetArtifacts) {
|
|
247
|
-
fs.copyFileSync(
|
|
248
|
-
path.join(this.currentRenderDir, assetArtifact),
|
|
249
|
-
path.join(this.bundleDir, assetArtifact),
|
|
250
|
-
);
|
|
251
|
-
verboseLog(
|
|
252
|
-
`Copied ${path.join(this.currentRenderDir, assetArtifact)} -> to -> ${path.join(
|
|
253
|
-
this.bundleDir,
|
|
254
|
-
assetArtifact,
|
|
255
|
-
)}`,
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
private copySitemaps() {
|
|
261
|
-
/*
|
|
262
|
-
1. buscar directorios que tengan como hijo un `sitemap.xml`
|
|
263
|
-
2. copiar todos los sitemap.xml y sitemap-* a /exports/sites/<domain>/<site>/ borrando previamente los .xmls que existan
|
|
264
|
-
*/
|
|
265
|
-
const renderSrc = path.resolve(this.currentRenderDir);
|
|
266
|
-
const renderDst = path.resolve(this.bundleDir);
|
|
267
|
-
const xmlFilesInSrc = this.findFilesByExtension(renderSrc, ".xml");
|
|
268
|
-
const xmlFilesInDst = this.findFilesByExtension(renderDst, ".xml");
|
|
269
|
-
|
|
270
|
-
// Eliminar los sitemaps de griddo que existan en el destino, se van a
|
|
271
|
-
// crear todos nuevos en la fase Meta.
|
|
272
|
-
for (const xmlFile of xmlFilesInDst) {
|
|
273
|
-
if (
|
|
274
|
-
path.basename(xmlFile).startsWith("sitemap-") ||
|
|
275
|
-
path.basename(xmlFile) === "sitemap.xml"
|
|
276
|
-
) {
|
|
277
|
-
fs.rmSync(xmlFile, { force: true });
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
for (const xmlFile of xmlFilesInSrc) {
|
|
282
|
-
const src = xmlFile;
|
|
283
|
-
// cambia la ruta, de src -> dst
|
|
284
|
-
const dst = xmlFile.replace(renderSrc, renderDst);
|
|
285
|
-
|
|
286
|
-
if (!fs.existsSync(path.dirname(dst))) {
|
|
287
|
-
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
288
|
-
}
|
|
289
|
-
fs.copyFileSync(src, dst);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export { SyncRender };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
interface SSG {
|
|
2
|
-
assetPrefix: string;
|
|
3
|
-
ssgArtifacts: {
|
|
4
|
-
disposables: string[];
|
|
5
|
-
cacheables: string[];
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// Minimal representation of the page structure
|
|
10
|
-
interface GatsbyPageData {
|
|
11
|
-
path: string;
|
|
12
|
-
result: {
|
|
13
|
-
pageContext: {
|
|
14
|
-
id: number;
|
|
15
|
-
title: string;
|
|
16
|
-
path: string;
|
|
17
|
-
openGraph: any;
|
|
18
|
-
pageMetadata: any;
|
|
19
|
-
page: {
|
|
20
|
-
site: number;
|
|
21
|
-
id: number;
|
|
22
|
-
fullPath: { compose: string };
|
|
23
|
-
language: number;
|
|
24
|
-
title: string;
|
|
25
|
-
fullUrl: string;
|
|
26
|
-
templateId: string;
|
|
27
|
-
template: {
|
|
28
|
-
templateType: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type { GatsbyPageData, SSG };
|
|
@@ -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 { doLifeCycle } from "../utils/core-utils";
|
|
7
|
-
import { pathExists } from "../utils/folders";
|
|
8
|
-
import { getRenderPathsFromDB } from "../utils/render";
|
|
9
|
-
|
|
10
|
-
async function prepareAssetsAction() {
|
|
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
|
-
console.log("Assets directory not found");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async function main() {
|
|
27
|
-
await doLifeCycle("PrepareAssets(Internal)", prepareAssetsAction);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
main().catch((err) => {
|
|
31
|
-
console.error("Error", err?.stdout?.toString() || err);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
});
|
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 };
|