@griddo/cx 10.4.7 → 10.4.9

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.
Files changed (68) hide show
  1. package/build/create-build-data.js +18 -18
  2. package/build/index.js +42 -40
  3. package/exporter/adapters/gatsby/index.ts +67 -15
  4. package/exporter/adapters/gatsby/utils.ts +1 -5
  5. package/exporter/adapters/index.ts +2 -3
  6. package/exporter/services/robots.ts +12 -9
  7. package/exporter/services/store.ts +1 -1
  8. package/exporter/types/global.ts +10 -2
  9. package/exporter/utils/folders.ts +40 -65
  10. package/exporter/utils/instance.ts +5 -2
  11. package/exporter/utils/shared.ts +1 -1
  12. package/exporter/utils/sites.ts +21 -15
  13. package/exporter/utils/store.ts +7 -2
  14. package/exporter/utils/temp-utils.ts +86 -0
  15. package/gatsby-browser.tsx +1 -2
  16. package/gatsby-config.ts +2 -1
  17. package/gatsby-node.ts +18 -47
  18. package/gatsby-ssr.tsx +1 -2
  19. package/package.json +2 -2
  20. package/src/components/Head.tsx +1 -2
  21. package/src/components/template.tsx +1 -2
  22. package/src/gatsby-node-utils.ts +1 -57
  23. package/exporter/adapters/astro/index.ts +0 -36
  24. package/exporter/adapters/astro/utils.ts +0 -30
  25. package/exporter/index-width-adapter.ts +0 -25
  26. package/static/.gitkeep +0 -0
  27. package/static/README.md +0 -3
  28. package/static/fonts/dm-sans/dm-sans-v14-latin-500.woff2 +0 -0
  29. package/static/fonts/dm-sans/dm-sans-v14-latin-500italic.woff2 +0 -0
  30. package/static/fonts/dm-sans/dm-sans-v14-latin-600.woff2 +0 -0
  31. package/static/fonts/dm-sans/dm-sans-v14-latin-600italic.woff2 +0 -0
  32. package/static/fonts/dm-sans/dm-sans-v14-latin-700.woff2 +0 -0
  33. package/static/fonts/dm-sans/dm-sans-v14-latin-700italic.woff2 +0 -0
  34. package/static/fonts/dm-sans/dm-sans-v14-latin-800.woff2 +0 -0
  35. package/static/fonts/dm-sans/dm-sans-v14-latin-800italic.woff2 +0 -0
  36. package/static/fonts/dm-sans/dm-sans-v14-latin-900.woff2 +0 -0
  37. package/static/fonts/dm-sans/dm-sans-v14-latin-900italic.woff2 +0 -0
  38. package/static/fonts/dm-sans/dm-sans-v14-latin-italic.woff2 +0 -0
  39. package/static/fonts/dm-sans/dm-sans-v14-latin-regular.woff2 +0 -0
  40. package/static/fonts/dm-serif-display/dm-serif-display-v15-latin-italic.woff2 +0 -0
  41. package/static/fonts/dm-serif-display/dm-serif-display-v15-latin-regular.woff2 +0 -0
  42. package/static/fonts/gilroy/Gilroy-Black.woff2 +0 -0
  43. package/static/fonts/gilroy/Gilroy-BlackItalic.woff2 +0 -0
  44. package/static/fonts/gilroy/Gilroy-Bold.woff2 +0 -0
  45. package/static/fonts/gilroy/Gilroy-BoldItalic.woff2 +0 -0
  46. package/static/fonts/gilroy/Gilroy-ExtraBold.woff2 +0 -0
  47. package/static/fonts/gilroy/Gilroy-ExtraBoldItalic.woff2 +0 -0
  48. package/static/fonts/gilroy/Gilroy-Heavy.woff2 +0 -0
  49. package/static/fonts/gilroy/Gilroy-HeavyItalic.woff2 +0 -0
  50. package/static/fonts/gilroy/Gilroy-Light.woff2 +0 -0
  51. package/static/fonts/gilroy/Gilroy-LightItalic.woff2 +0 -0
  52. package/static/fonts/gilroy/Gilroy-Medium.woff2 +0 -0
  53. package/static/fonts/gilroy/Gilroy-MediumItalic.woff2 +0 -0
  54. package/static/fonts/gilroy/Gilroy-Regular.woff2 +0 -0
  55. package/static/fonts/gilroy/Gilroy-RegularItalic.woff2 +0 -0
  56. package/static/fonts/gilroy/Gilroy-SemiBold.woff2 +0 -0
  57. package/static/fonts/gilroy/Gilroy-SemiBoldItalic.woff2 +0 -0
  58. package/static/fonts/gilroy/Gilroy-Thin.woff2 +0 -0
  59. package/static/fonts/gilroy/Gilroy-ThinItalic.woff2 +0 -0
  60. package/static/fonts/gilroy/Gilroy-UltraLight.woff2 +0 -0
  61. package/static/fonts/gilroy/Gilroy-UltraLightItalic.woff2 +0 -0
  62. package/static/fonts/work-sans/work-sans-v17-latin-700.woff +0 -0
  63. package/static/fonts/work-sans/work-sans-v17-latin-700.woff2 +0 -0
  64. package/static/fonts/work-sans/work-sans-v17-latin-regular.woff +0 -0
  65. package/static/fonts/work-sans/work-sans-v17-latin-regular.woff2 +0 -0
  66. package/static/grisso.css +0 -1
  67. package/static/robots.txt +0 -3
  68. package/static/webfonts.css +0 -115
@@ -0,0 +1,86 @@
1
+ import path from "node:path";
2
+
3
+ import fsx from "fs-extra";
4
+
5
+ function getConfigSync() {
6
+ try {
7
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, node/no-missing-require, node/no-unpublished-require
8
+ const configModule = require("../../cx.config");
9
+ const config = configModule.default;
10
+
11
+ return config;
12
+ } catch (error) {
13
+ process.exit(1);
14
+ }
15
+ }
16
+
17
+ async function getConfig() {
18
+ try {
19
+ // eslint-disable-next-line node/no-unpublished-import
20
+ const configModule = await import("../../cx.config");
21
+ const config = configModule.default;
22
+
23
+ return config;
24
+ } catch (error) {
25
+ process.exit(1);
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Update the Griddo's `/dist` dir with the contents from `public` dir only
31
+ * with files of type: js, json and css.
32
+ */
33
+ async function legacy__createDistFromGatsbyPublic(
34
+ domain: string,
35
+ needsAssetPrefix: boolean
36
+ ) {
37
+ const config = await getConfig();
38
+ const dirs = config.dirs(domain);
39
+
40
+ const cxDistDir = path.resolve(dirs.__cx, "dist");
41
+ const cxAssetsDir = path.resolve(dirs.__cx, "assets");
42
+ const cxDistDirWithDomain = path.join(dirs.__cx, "dist", domain);
43
+ const publicDir = path.resolve(dirs.__ssg, "public");
44
+
45
+ const validFiles = fsx
46
+ .readdirSync(publicDir)
47
+ .filter(
48
+ (file) =>
49
+ path.extname(file) === ".js" ||
50
+ path.extname(file) === ".json" ||
51
+ path.extname(file) === ".css"
52
+ );
53
+
54
+ const pageDataSrc = `${publicDir}/page-data`;
55
+ const pageDataDest = `${cxAssetsDir}/page-data`;
56
+
57
+ const projectStaticSrc = path.resolve(dirs.__cx, "./static");
58
+ const projectStaticDest = cxAssetsDir;
59
+
60
+ const gatsbyStaticSrc = `${cxDistDir}/static`;
61
+ const gatsbyStaticDest = `${cxAssetsDir}/static`;
62
+
63
+ try {
64
+ fsx.mkdirSync(cxAssetsDir, { recursive: true });
65
+ fsx.copySync(publicDir, cxDistDir);
66
+
67
+ if (needsAssetPrefix) {
68
+ fsx.copySync(pageDataSrc, pageDataDest);
69
+ fsx.copySync(projectStaticSrc, projectStaticDest, { overwrite: false });
70
+ fsx.copySync(gatsbyStaticSrc, gatsbyStaticDest, { overwrite: false });
71
+ fsx.copySync(projectStaticSrc, cxDistDirWithDomain, {
72
+ overwrite: false,
73
+ });
74
+
75
+ validFiles.map(async (file) => {
76
+ const fileSrc = `${publicDir}/${file}`;
77
+ const fileDest = `${cxAssetsDir}/${file}`;
78
+ fsx.copySync(fileSrc, fileDest);
79
+ });
80
+ }
81
+ } catch (err) {
82
+ console.error(err);
83
+ }
84
+ }
85
+
86
+ export { legacy__createDistFromGatsbyPublic, getConfig, getConfigSync };
@@ -1,8 +1,7 @@
1
1
  import type { GatsbyBrowser } from "gatsby";
2
2
 
3
+ import { browser } from "@components";
3
4
  import { SessionProvider } from "@griddo/core";
4
- // @ts-expect-error components is unknown
5
- import { browser } from "components";
6
5
  import * as React from "react";
7
6
 
8
7
  export const disableCorePrefetching = () => {
package/gatsby-config.ts CHANGED
@@ -6,7 +6,8 @@ import { resolveComponentsPath } from "./exporter/utils/instance";
6
6
 
7
7
  dotenv.config();
8
8
 
9
- // Envs
9
+ // Este process.env.GRIDDO_ASSET_PREFIX se lee porque se ha introducido en
10
+ // `getEnvRunner()`.
10
11
  const GRIDDO_ASSET_PREFIX = process.env.GRIDDO_ASSET_PREFIX || undefined;
11
12
 
12
13
  // Gatsby configuration file from client
package/gatsby-node.ts CHANGED
@@ -2,67 +2,38 @@ import type { GatsbyNode } from "gatsby";
2
2
 
3
3
  import path from "node:path";
4
4
 
5
- import { RobotsService } from "./exporter/services/robots";
6
5
  import { logInfo, logPageSize } from "./exporter/utils/shared";
7
- import { generateBuildReport, generateSitemaps } from "./exporter/utils/sites";
8
- import { getBuildMetadata, getBuildPages } from "./exporter/utils/store";
9
- import {
10
- getMatchPath,
11
- prepareStaticDir,
12
- updateDist,
13
- } from "./src/gatsby-node-utils";
6
+ import { getBuildPages } from "./exporter/utils/store";
7
+ import { getConfigSync } from "./exporter/utils/temp-utils";
8
+ import { getMatchPath } from "./src/gatsby-node-utils";
14
9
  import { GatsbyPageObject } from "./src/types";
15
10
 
16
- const publicDirPath = path.resolve(__dirname, "./public");
17
- const storeDirPath = path.resolve(__dirname, "./store/");
18
- const reportFilePath = path.resolve(publicDirPath, "__build-report__.json");
19
- const gatsbyTemplateFile = path.resolve(
20
- __dirname,
21
- "./src/components/template.tsx"
22
- );
11
+ const dirs = getConfigSync().dirs();
12
+ const storeDir = path.join(dirs.__cx, "store");
13
+ const templateFile = path.join(dirs.__ssg, "src/components/template.tsx");
23
14
 
24
- // onPreInit
25
- const onPreInit = async () => {
26
- prepareStaticDir();
27
- };
28
-
29
- // createPages
30
- const createPages: GatsbyNode["createPages"] = async ({
31
- actions: { createPage },
32
- }) => {
33
- const pages = getBuildPages<GatsbyPageObject>(storeDirPath);
15
+ const createPages: GatsbyNode["createPages"] = async ({ actions }) => {
16
+ const pages = getBuildPages<GatsbyPageObject>(storeDir);
34
17
 
35
18
  for await (const page of pages) {
36
- // SECURITY
37
- if (!page) {
38
- return;
39
- }
19
+ if (!page) return;
20
+
40
21
  const { domain, compose } = page.context.fullPath;
41
22
  const matchPath = getMatchPath(domain, compose);
42
23
 
43
- page.component = gatsbyTemplateFile;
24
+ page.component = templateFile;
44
25
  page.matchPath = matchPath;
45
26
 
46
- createPage(page);
27
+ actions.createPage(page);
47
28
 
48
- logInfo(
49
- `Creating page ${page.path} - ${page.context.id} - ${logPageSize(
50
- Math.round(page.size || 0)
51
- )}`
52
- );
53
- }
54
- };
55
-
56
- // onPostBuild
57
- const onPostBuild = async () => {
58
- const { buildProcessData, sitesToPublish } = getBuildMetadata(storeDirPath);
29
+ const path = page.path;
30
+ const id = page.context.id;
31
+ const size = logPageSize(Math.round(page.size || 0));
59
32
 
60
- await generateBuildReport(reportFilePath, buildProcessData);
61
- await RobotsService.writeFiles(publicDirPath);
62
- await generateSitemaps(sitesToPublish);
63
- await updateDist();
33
+ logInfo(`Creating page ${path} - ${id} - ${size}`);
34
+ }
64
35
  };
65
36
 
66
37
  // onCreateWebpackConfig
67
38
  export { onCreateWebpackConfig } from "./src/gatsby-node-utils";
68
- export { createPages, onPostBuild, onPreInit };
39
+ export { createPages };
package/gatsby-ssr.tsx CHANGED
@@ -1,8 +1,7 @@
1
1
  import type { GatsbySSR } from "gatsby";
2
2
 
3
+ import { ssr } from "@components";
3
4
  import { SessionProvider } from "@griddo/core";
4
- // @ts-expect-error components is unknown
5
- import { ssr } from "components";
6
5
  import * as React from "react";
7
6
 
8
7
  export const wrapPageElement: GatsbySSR["wrapPageElement"] = ({ props }) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/cx",
3
3
  "description": "Griddo SSG based on Gatsby",
4
- "version": "10.4.7",
4
+ "version": "10.4.9",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -107,5 +107,5 @@
107
107
  "publishConfig": {
108
108
  "access": "public"
109
109
  },
110
- "gitHead": "0280c78de79a2b1f534c9aaaf16e6bb72bd5b652"
110
+ "gitHead": "798ce16f44f99f35c4eb372b04e54f8a1f433469"
111
111
  }
@@ -1,7 +1,6 @@
1
1
  import type { CustomHeadProps } from "../types";
2
2
 
3
- // @ts-expect-error components is unknown
4
- import { generateAutomaticDimensions } from "components";
3
+ import { generateAutomaticDimensions } from "@components";
5
4
  import parse from "html-react-parser";
6
5
  import * as React from "react";
7
6
 
@@ -1,8 +1,7 @@
1
1
  import type { TemplateProps } from "../types";
2
2
 
3
+ import { components, SiteProvider, templates } from "@components";
3
4
  import { Core, Page as RenderGriddoPage } from "@griddo/core";
4
- // @ts-expect-error components is unknown
5
- import { components, SiteProvider, templates } from "components";
6
5
  import { Link, navigate } from "gatsby";
7
6
  import parse from "html-react-parser";
8
7
  import * as React from "react";
@@ -1,7 +1,5 @@
1
1
  import type { GatsbyNode } from "gatsby";
2
2
 
3
- import path from "node:path";
4
-
5
3
  import fs from "fs-extra";
6
4
 
7
5
  import {
@@ -32,59 +30,6 @@ function prepareStaticDir() {
32
30
  }
33
31
  }
34
32
 
35
- /**
36
- * Update the Griddo's `/dist` dir with the contents from `/public` only with files of type:
37
- * - js
38
- * - json
39
- * - css
40
- */
41
- async function updateDist() {
42
- const src = "./public";
43
- const dest = "./dist";
44
-
45
- const domainDestPath = `${dest}/${process.env.DOMAIN}`;
46
-
47
- const files = fs
48
- .readdirSync(src)
49
- .filter(
50
- (file) =>
51
- path.extname(file) === ".js" ||
52
- path.extname(file) === ".json" ||
53
- path.extname(file) === ".css"
54
- );
55
-
56
- const assetsDest = "./assets";
57
-
58
- const pageDataSrc = `${src}/page-data`;
59
- const pageDataDest = `${assetsDest}/page-data`;
60
-
61
- const projectStaticSrc = "./static";
62
- const projectStaticDest = assetsDest;
63
-
64
- const gatsbyStaticSrc = `${dest}/static`;
65
- const gatsbyStaticDest = `${assetsDest}/static`;
66
-
67
- try {
68
- fs.mkdirSync(assetsDest, { recursive: true });
69
- fs.copySync(src, dest);
70
-
71
- if (process.env.NEEDS_ASSET_DOMAIN_PREFIX) {
72
- fs.copySync(pageDataSrc, pageDataDest);
73
- fs.copySync(projectStaticSrc, projectStaticDest, { overwrite: false });
74
- fs.copySync(gatsbyStaticSrc, gatsbyStaticDest, { overwrite: false });
75
- fs.copySync(projectStaticSrc, domainDestPath, { overwrite: false });
76
-
77
- files.map(async (file) => {
78
- const fileSrc = `${src}/${file}`;
79
- const fileDest = `${assetsDest}/${file}`;
80
- fs.copySync(fileSrc, fileDest);
81
- });
82
- }
83
- } catch (err) {
84
- console.error(err);
85
- }
86
- }
87
-
88
33
  const onCreateWebpackConfig: GatsbyNode["onCreateWebpackConfig"] = ({
89
34
  actions,
90
35
  plugins,
@@ -146,9 +91,8 @@ function getMatchPath(domain: string, compose: string) {
146
91
  }
147
92
 
148
93
  export {
94
+ getGatsbyAssetPrefixSlug,
149
95
  getMatchPath,
150
96
  onCreateWebpackConfig,
151
97
  prepareStaticDir,
152
- updateDist,
153
- getGatsbyAssetPrefixSlug,
154
98
  };
@@ -1,36 +0,0 @@
1
- import { getAstroDomainRunner } from "./utils";
2
- import { getInstanceDomains } from "../../utils/domains";
3
- import { createBuildData } from "../../utils/download-build-data";
4
- import { printExporterLogo } from "../../utils/shared";
5
-
6
- /**
7
- * Astro adapter for Griddo.
8
- */
9
- async function runAstroAdapter() {
10
- printExporterLogo("astro");
11
-
12
- const domains = await getInstanceDomains();
13
-
14
- for (const domain of domains) {
15
- const runner = getAstroDomainRunner(domain);
16
- // ---------------------------------------------------------------------- //
17
- // Init the render, restore Gatsby /.cache and /public dirs //
18
- // ---------------------------------------------------------------------- //
19
- runner.init();
20
- // runner.whatEverAction();
21
- // runner.otherAstroRelatedFunction();
22
-
23
- // ---------------------------------------------------------------------- //
24
- // Download domain build data (sites, pages, etc) and generator a dirs //
25
- // called `store` where all the domain render data is saved. //
26
- // ---------------------------------------------------------------------- //
27
- await createBuildData(domain);
28
-
29
- // ---------------------------------------------------------------------- //
30
- // Call the `astro build` command. //
31
- // ---------------------------------------------------------------------- //
32
- runner.runAstroBuild();
33
- }
34
- }
35
-
36
- export { runAstroAdapter };
@@ -1,30 +0,0 @@
1
- import dotenv from "dotenv";
2
-
3
- import { getEnvRunner } from "../../utils/runners";
4
-
5
- dotenv.config();
6
-
7
- /**
8
- * Return a runner, a serie of functions to manage the Astro render artifacts.
9
- */
10
- function getAstroDomainRunner(domain: string) {
11
- const run = getEnvRunner({
12
- DOMAIN: domain,
13
- GRIDDO_RENDERID: new Date().valueOf(),
14
- });
15
-
16
- const init = () => {
17
- console.info(`Initializing exporter for the domain ${domain}`);
18
- };
19
-
20
- const runAstroBuild = () => {
21
- run("yarn astro-build");
22
- };
23
-
24
- return {
25
- init,
26
- runAstroBuild,
27
- };
28
- }
29
-
30
- export { getAstroDomainRunner };
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env node
2
- /* eslint-disable node/shebang */
3
- import { Adapters, runGatsbyAdapter } from "./adapters";
4
-
5
- const adapter = process.env.GRIDDO_CX_ADAPTER as Adapters;
6
-
7
- async function main(adapter: Adapters) {
8
- if (adapter === "gatsby") {
9
- await runGatsbyAdapter();
10
- process.exit(0);
11
- }
12
-
13
- // if (adapter === "astro") {
14
- // await runAstroAdapter();
15
- // process.exit(0);
16
- // }
17
-
18
- throw new Error("Adapter not configured correctly");
19
- }
20
-
21
- // Go render, go!
22
- main(adapter).catch((err) => {
23
- console.error("Error in main():", err?.stdout?.toString() || err);
24
- process.exit(1);
25
- });
package/static/.gitkeep DELETED
File without changes
package/static/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Griddo static folder
2
-
3
- The assets in this folder will be handled "as is" and they will not get any kind of optimization at all.