@griddo/cx 10.4.10 → 10.4.12

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.
@@ -21,7 +21,7 @@ async function runGatsbyAdapter() {
21
21
  printExporterLogo("gatsby");
22
22
 
23
23
  const domains = await getInstanceDomains();
24
- const config = await getConfig();
24
+ const config = getConfig();
25
25
 
26
26
  for (const domain of domains) {
27
27
  const runner = getGatsbyDomainRunner(domain);
@@ -0,0 +1,24 @@
1
+ import { CXConfig } from "./src/types/global";
2
+
3
+ declare const artifacts: readonly ["public", ".cache", "static"];
4
+ declare const config: CXConfig;
5
+
6
+ export default config;
7
+
8
+ declare const CXDir: {
9
+ EXPORTS: "__exports";
10
+ CACHE: "__caches";
11
+ CX: "__cx";
12
+ SSG: "__ssg";
13
+ COMPONENTS: "__components";
14
+ ROOT: "__root";
15
+ };
16
+
17
+ export type Artifact =
18
+ | typeof artifacts[number]
19
+ | "store"
20
+ | "apiCache"
21
+ | "dist"
22
+ | "assets";
23
+
24
+ export { CXDir, artifacts };
@@ -0,0 +1,40 @@
1
+ import path from "node:path";
2
+
3
+ import pkgDir from "pkg-dir";
4
+
5
+ import { resolveComponentsPath } from "./utils/instance";
6
+
7
+ // Paths
8
+ const REPO_ROOT_DIR = pkgDir.sync(path.resolve(__dirname, "../.."));
9
+ const CX_ROOT_DIR = pkgDir.sync(__dirname);
10
+ const SSG_DIR = pkgDir.sync(__dirname);
11
+ const CX_CACHE_DIR = path.resolve(CX_ROOT_DIR, "caches");
12
+ const COMPONENTS_DIR = resolveComponentsPath();
13
+ const EXPORTS_DIR = path.join(REPO_ROOT_DIR, "exports/sites");
14
+
15
+ const artifacts = ["public", ".cache", "static"];
16
+
17
+ const config = {
18
+ proDomain: "pro-",
19
+ CXDir: {
20
+ EXPORTS: "__exports",
21
+ CACHE: "__cache",
22
+ CX: "__cx",
23
+ SSG: "__ssg",
24
+ COMPONENTS: "__components",
25
+ ROOT: "__root",
26
+ },
27
+ dirs: (domain) => ({
28
+ __cache: path.join(CX_CACHE_DIR, domain || ""),
29
+ __components: COMPONENTS_DIR,
30
+ __cx: CX_ROOT_DIR,
31
+ __exports: path.join(EXPORTS_DIR, domain || ""),
32
+ __root: REPO_ROOT_DIR,
33
+ __ssg: SSG_DIR,
34
+ }),
35
+ };
36
+
37
+ export default config;
38
+ const CXDir = config.CXDir;
39
+
40
+ export { CXDir, artifacts };
@@ -50,7 +50,7 @@ class RobotsService {
50
50
  * Write robots.txt files for the current rendering domain.
51
51
  */
52
52
  async writeFiles(domain: string) {
53
- const config = await getConfig();
53
+ const config = getConfig();
54
54
  const dirs = config.dirs(domain);
55
55
  const distDirectory = path.join(dirs.__cx, "dist");
56
56
 
@@ -1,4 +1,3 @@
1
- import type { CXDir } from "../types/global";
2
1
  import type { Site } from "../types/sites";
3
2
 
4
3
  import { spawnSync } from "node:child_process";
@@ -298,7 +297,7 @@ function isMultiPageId(id: number) {
298
297
  }
299
298
 
300
299
  async function removeMultiPagesFromStore() {
301
- const config = await getConfig();
300
+ const config = getConfig();
302
301
  const dirs = config.dirs();
303
302
  const storePath = path.join(dirs.__cx, "store");
304
303
  try {
@@ -62,9 +62,8 @@ function getComponentsLibAliases() {
62
62
  };
63
63
  },
64
64
  {
65
- // Por este motivo se puede hacer `... import from "@components" en
65
+ // Por este motivo se puede hacer `... import from "components" en
66
66
  // los packages del monorepo.
67
- "@components": `${resolveComponentsPath()}/src/index.js`,
68
67
  components: `${resolveComponentsPath()}/src/index.js`,
69
68
  }
70
69
  );
@@ -238,8 +238,19 @@ async function createGriddoListPages(
238
238
  const pageNumber = idx + 1;
239
239
  const { domainUrl, compose } = page.fullPath;
240
240
 
241
+ // Crea un id como número negativo y añadiendo un sufijo para los
242
+ // listados estáticos. Esto es así para marcarlas y posteriormente
243
+ // borrarlas siempre en cada nuevo render desde el Adapter.
244
+ //
245
+ // id de página con mode:"list": 1546
246
+ // ids de las "sub-páginas": -15460, -15461, -1546n, (-)id(idx)
247
+ //
248
+ // @todo eliminar el concepto multipage de CX, debería ser algo core de
249
+ // Griddo itself: API/AX, que fuesen páginas con sus ids, etc..
250
+
241
251
  const paginatedPage = {
242
252
  ...page,
253
+ id: parseInt("-" + page.id + idx),
243
254
  fullPath: {
244
255
  ...page.fullPath,
245
256
  // Add a page number (tailPageNumber) from page 2 onwards
@@ -151,7 +151,7 @@ async function getSiteData(siteID: number) {
151
151
  * Save a file with the end of build process
152
152
  */
153
153
  async function generateBuildReport() {
154
- const config = await getConfig();
154
+ const config = getConfig();
155
155
  const dirs = config.dirs();
156
156
 
157
157
  const DIST_FOLDER = path.join(dirs.__cx, "dist");
@@ -184,7 +184,7 @@ async function generateBuildReport() {
184
184
  */
185
185
  async function generateSitemaps() {
186
186
  const { sitesToPublish } = await getBuildMetadata();
187
- const config = await getConfig();
187
+ const config = getConfig();
188
188
  const dirs = config.dirs();
189
189
  const basePath = path.resolve(dirs.__cx, "dist");
190
190
 
@@ -46,7 +46,7 @@ async function* getBuildPages<PageType extends GriddoPageObject>(
46
46
  * TODO: Refactorizar para leer un solo archivo: __metadata__.json
47
47
  */
48
48
  async function getBuildMetadata(): Promise<BuildMetaData> {
49
- const config = await getConfig();
49
+ const config = getConfig();
50
50
  const dirs = config.dirs();
51
51
  const storePath = path.join(dirs.__cx, "store");
52
52
 
@@ -2,22 +2,10 @@ import path from "node:path";
2
2
 
3
3
  import fsx from "fs-extra";
4
4
 
5
- function getConfigSync() {
5
+ function getConfig() {
6
6
  try {
7
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");
8
+ const configModule = require("../cx.config.js");
21
9
  const config = configModule.default;
22
10
 
23
11
  return config;
@@ -34,7 +22,7 @@ async function legacy__createDistFromGatsbyPublic(
34
22
  domain: string,
35
23
  needsAssetPrefix: boolean
36
24
  ) {
37
- const config = await getConfig();
25
+ const config = getConfig();
38
26
  const dirs = config.dirs(domain);
39
27
 
40
28
  const cxDistDir = path.resolve(dirs.__cx, "dist");
@@ -83,4 +71,4 @@ async function legacy__createDistFromGatsbyPublic(
83
71
  }
84
72
  }
85
73
 
86
- export { legacy__createDistFromGatsbyPublic, getConfig, getConfigSync };
74
+ export { legacy__createDistFromGatsbyPublic, getConfig };
@@ -1,7 +1,7 @@
1
1
  import type { GatsbyBrowser } from "gatsby";
2
2
 
3
- import { browser } from "@components";
4
3
  import { SessionProvider } from "@griddo/core";
4
+ import { browser } from "components";
5
5
  import * as React from "react";
6
6
 
7
7
  export const disableCorePrefetching = () => {
package/gatsby-node.ts CHANGED
@@ -4,11 +4,11 @@ import path from "node:path";
4
4
 
5
5
  import { logInfo, logPageSize } from "./exporter/utils/shared";
6
6
  import { getBuildPages } from "./exporter/utils/store";
7
- import { getConfigSync } from "./exporter/utils/temp-utils";
7
+ import { getConfig } from "./exporter/utils/temp-utils";
8
8
  import { getMatchPath } from "./src/gatsby-node-utils";
9
9
  import { GatsbyPageObject } from "./src/types";
10
10
 
11
- const dirs = getConfigSync().dirs();
11
+ const dirs = getConfig().dirs();
12
12
  const storeDir = path.join(dirs.__cx, "store");
13
13
  const templateFile = path.join(dirs.__ssg, "src/components/template.tsx");
14
14
 
package/gatsby-ssr.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { GatsbySSR } from "gatsby";
2
2
 
3
- import { ssr } from "@components";
4
3
  import { SessionProvider } from "@griddo/core";
4
+ import { ssr } from "components";
5
5
  import * as React from "react";
6
6
 
7
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.10",
4
+ "version": "10.4.12",
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,8 @@
107
107
  "publishConfig": {
108
108
  "access": "public"
109
109
  },
110
- "gitHead": "5ebecf976ceff5858e8395eea3ec113a488a1876"
110
+ "resolutions": {
111
+ "memoizee": "0.4.15"
112
+ },
113
+ "gitHead": "0e1a43fd246d2a955b9d4040c1489ff733f4ed5e"
111
114
  }
@@ -1,6 +1,6 @@
1
1
  import type { CustomHeadProps } from "../types";
2
2
 
3
- import { generateAutomaticDimensions } from "@components";
3
+ import { generateAutomaticDimensions } from "components";
4
4
  import parse from "html-react-parser";
5
5
  import * as React from "react";
6
6
 
@@ -1,7 +1,7 @@
1
1
  import type { TemplateProps } from "../types";
2
2
 
3
- import { components, SiteProvider, templates } from "@components";
4
3
  import { Core, Page as RenderGriddoPage } from "@griddo/core";
4
+ import { components, SiteProvider, templates } from "components";
5
5
  import { Link, navigate } from "gatsby";
6
6
  import parse from "html-react-parser";
7
7
  import * as React from "react";