@griddo/cx 10.4.20 → 10.4.22
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 +11 -76
- package/build/adapters/gatsby/utils.d.ts +21 -14
- package/build/browser/index.d.ts +1 -1
- package/build/browser/index.js +1 -1
- package/build/build-complete.js +20 -20
- package/build/errors/index.d.ts +1 -0
- package/build/index.js +29 -27
- package/build/reset-render.js +20 -20
- package/build/run-start-render.js +29 -27
- package/build/start-render.js +29 -27
- package/build/upload-search-content.js +23 -23
- package/build/utils/temp-utils.d.ts +11 -6
- package/exporter/adapters/gatsby/index.ts +12 -29
- package/exporter/adapters/gatsby/utils.ts +124 -16
- package/exporter/browser/index.ts +1 -1
- package/exporter/build-complete.ts +5 -5
- package/exporter/errors/index.ts +2 -0
- package/exporter/start-render.ts +1 -2
- package/exporter/utils/shared.ts +6 -1
- package/exporter/utils/temp-utils.ts +16 -67
- package/gatsby-config.ts +18 -5
- package/gatsby-node.ts +25 -10
- package/package.json +3 -3
- package/src/components/template.tsx +2 -1
- package/src/gatsby-node-utils.ts +2 -28
- package/src/types.ts +6 -7
package/README.md
CHANGED
|
@@ -1,93 +1,28 @@
|
|
|
1
1
|
# Griddo package
|
|
2
2
|
|
|
3
|
-
## TO-DO
|
|
4
|
-
|
|
5
|
-
- [ ] Crear el store utilizando un HASH como nombre de archivo y no el ID.
|
|
6
|
-
- [ ] Manejar el store teniendo en cuenta el ID de las páginas leyendo el objeto y no el nombre del archivo.
|
|
7
|
-
|
|
8
|
-
---
|
|
9
3
|
|
|
10
4
|
El package `griddo-cx` está dividido en dos carpetas principales: una para la lógica de negocio en `/exporter` y otra para Gatsby (builder) `/src`.
|
|
11
5
|
|
|
12
|
-
|
|
6
|
+
## `/exporter`
|
|
13
7
|
|
|
14
|
-
|
|
8
|
+
**Griddo Exporter** es el script _orquestador_ que debe llamar **una vez por cada dominio** a los distintos procesos que implican la realización de la publicación de una instancia.
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
En el exporter se desarrolla todo lo necesario para la conexión con API, post-procesado de los datos y generación de JSONS finales de los sites con "el estándar Griddo". Aquí es donde se ejecuta la mayor parte de la lógica: obtención de páginas, listados, distribuidores, idomas, etc. Todo está implementado como una _library_, nada se ejecuta por sí solo. Lo tiene que hacer el Adapter.
|
|
17
11
|
|
|
18
|
-
|
|
12
|
+
**Adapter**
|
|
19
13
|
|
|
20
|
-
|
|
14
|
+
El adapter es una parte del código de CX que orquesta un render, utilizando como servicios la _library_ de CX y el framework de SSG disponible. Actualmente hay un SSG, Gatsby. Por lo tanto hay un adapter a Gatsby. Lógica de negocio y SSG ya no están mezclados.
|
|
21
15
|
|
|
22
16
|
Si hay un requerimiento en CX es muy probable que sea en esta parte donde haya que trabajar.
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```text
|
|
27
|
-
| src/
|
|
28
|
-
| adapters/
|
|
29
|
-
| gatsby/ # Adapta la salida (JSON) de Griddo -> Gatsby
|
|
30
|
-
| services/
|
|
31
|
-
| types/
|
|
32
|
-
| utils/
|
|
33
|
-
| create-build-data.ts
|
|
34
|
-
| build-complete.ts
|
|
35
|
-
| index.ts
|
|
36
|
-
| reset-render.ts
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## 2. Rendering (Gatsby)
|
|
40
|
-
|
|
41
|
-
Esta fase se ejecuta inmediatamente después de la primera. Se ejecuta `yarn gatsby build` lo que generá un build utilizando todos los datos que se descargaron en la carpeta `store`.
|
|
42
|
-
|
|
43
|
-
El código de Gatsby (por ahora el único SSG usado por Griddo) está en la carpeta `./src` junto con los archivos en el root: `gatsby-config.ts`, `gastsby-node.ts`, `gatsby-browser.ts` y `gatsby-ssr.ts`.
|
|
44
|
-
|
|
45
|
-
```text
|
|
46
|
-
| src/
|
|
47
|
-
| components/
|
|
48
|
-
| Head.tsx
|
|
49
|
-
| template.tsx
|
|
50
|
-
| htm.tsx
|
|
51
|
-
| gatsby-node-utils.ts
|
|
52
|
-
| types.ts
|
|
53
|
-
| utils.ts
|
|
54
|
-
| gatsby-browser.ts
|
|
55
|
-
| gatsby-config.ts
|
|
56
|
-
| gatsby-node.ts
|
|
57
|
-
| gatsby-ssr.ts
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
# Griddo Exporter
|
|
61
|
-
|
|
62
|
-
El punto de entrada para CX está en `src/index.js` que ejecuta **Griddo Exporter**, publicado en `./build/index.js` del cual podemos encontrar el código TypeScript en `./scripts/griddo-exporter.ts`
|
|
18
|
+
## `/src`
|
|
63
19
|
|
|
64
|
-
|
|
20
|
+
Aquí es donde reside el SSG actual (Gatsby) junto a archivos en el raíz, como `gatsby-node`, etc. Este ssg será llamado por el Adapter dentro del `Data LifeCycle`. El SSG solo debe saber que hay una carpeta `/store/` con los .json que representan las páginas a renderizar. Desde la `cx-library` también podrá hacer uso de otras utilidades, servicios y componentes. Por ejemplo utilizará la función `getBuildPagesFromStore` para obtener las páginas anteriormente creadas desde el store. Es decir, El SSG "no sabe" dónde están las páginas, tan solo tiene una función que se las va a devolver.
|
|
65
21
|
|
|
66
|
-
`BUILD-COMPLETO = PROCESOS * DOMINIOS`
|
|
67
22
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Los distintos procesos llamados desde **Griddo Exporter** son:
|
|
71
|
-
|
|
72
|
-
### API Fetch
|
|
73
|
-
|
|
74
|
-
**`yarn run api-fetch`**
|
|
75
|
-
|
|
76
|
-
Realiza toda la consulta de datos a la API de los sites (páginas, distribuidores, etc...) de un dominio, post-procesa y construye los `pageObjets`. Estos `pageObjects` son guardados como archivos JSON en una carpeta del sistema de archivos, creando lo que llamamos un **Store**.
|
|
77
|
-
|
|
78
|
-
Este Store no está acoplado con ningún sistema de renderización (Gatsby), son solo archivos JSON que describen los sites y páginas con el estándar que hemos diseñado desde Griddo.
|
|
79
|
-
|
|
80
|
-
### Gatsby build
|
|
81
|
-
|
|
82
|
-
**`gatsby-build`**
|
|
83
|
-
|
|
84
|
-
Se leen los JSON del store y se crean las páginas pasándolos directamente (0 pre/post procesado) a la función `creatPages` de Gatsby.
|
|
85
|
-
|
|
86
|
-
### Post build
|
|
23
|
+
---
|
|
87
24
|
|
|
88
|
-
-
|
|
89
|
-
- Se crean sitemaps.xml del render
|
|
90
|
-
- Se crear un archivo **build_report**info.json para notificar a la API de la finalización del render
|
|
91
|
-
- Se mueven el bundle generado por Gatsby de /public a /dist (esto se debería deprecar)
|
|
25
|
+
## TO-DO
|
|
92
26
|
|
|
93
|
-
|
|
27
|
+
- [ ] Crear el store utilizando un HASH como nombre de archivo y no el ID.
|
|
28
|
+
- [ ] Manejar el store teniendo en cuenta el ID de las páginas leyendo el objeto y no el nombre del archivo.
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { Fields } from "@griddo/core";
|
|
2
|
-
declare const attempts: {
|
|
3
|
-
prepare: any;
|
|
4
|
-
restore: any;
|
|
5
|
-
data: any;
|
|
6
|
-
ssg: any;
|
|
7
|
-
relocation: any;
|
|
8
|
-
meta: any;
|
|
9
|
-
archive: any;
|
|
10
|
-
clean: any;
|
|
11
|
-
};
|
|
1
|
+
import type { Fields } from "@griddo/core";
|
|
12
2
|
/**
|
|
13
|
-
* Return the assetPrefix
|
|
3
|
+
* Return the assetPrefix with the domain concatenated `assetPrefix/domain` only
|
|
4
|
+
* if the domain is "pro-" **and** there is a env `GRIDDO_ASSET_PREFIX` with any
|
|
5
|
+
* value different from `null`, `undefined` or `empty string`
|
|
6
|
+
*
|
|
7
|
+
* else...
|
|
8
|
+
* - If assetPrefix or domain is falsy, returns ""
|
|
9
|
+
* - If the domain is not "pro-", returns ""
|
|
14
10
|
*/
|
|
15
|
-
declare function
|
|
11
|
+
declare function getGatsbyAssetPrefixWithDomain(domain: string): string;
|
|
16
12
|
/**
|
|
17
13
|
* Format Cloudinary or DAM URL
|
|
18
14
|
*
|
|
@@ -23,4 +19,15 @@ declare function getGatsbyAssetPrefixSlug(domain: string): string;
|
|
|
23
19
|
* @returns A composed URL for the Cloudinary or DAM service
|
|
24
20
|
*/
|
|
25
21
|
declare function formatImage(image: Fields.Image | string, width: number, height: number, format?: string): string | null;
|
|
26
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Spawn a new node process `yarn gatsby-build`
|
|
24
|
+
* @note This proccess (`yarn gatsby-build`) can not access to the custom Griddo
|
|
25
|
+
* `process.env` so it needs variables passed to it via the `env` prop.
|
|
26
|
+
*/
|
|
27
|
+
declare function gatsbyBuild(assetPrefixWithDomain: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Update the Griddo's `/dist` dir with the contents from `public` dir only
|
|
30
|
+
* with files of type: js, json and css.
|
|
31
|
+
*/
|
|
32
|
+
declare function legacy__createDistFromGatsbyPublic(domain: string, needsAssetPrefix: boolean): Promise<void>;
|
|
33
|
+
export { formatImage, gatsbyBuild, getGatsbyAssetPrefixWithDomain, legacy__createDistFromGatsbyPublic, };
|
package/build/browser/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Core } from "@griddo/core";
|
|
1
|
+
import type { Core } from "@griddo/core";
|
|
2
2
|
declare function filterBodyIntegrationFromPosition(integrations: Array<Core.PageIntegration>, position: "start" | "end"): string[];
|
|
3
3
|
declare function filterHeadIntegrations(integrations: Array<Core.PageIntegration>): string[];
|
|
4
4
|
declare function filterPositionIntegrations(integrations: Array<Core.PageIntegration>, position: "head" | "start" | "end"): string[];
|
package/build/browser/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var u=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},y=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!l.call(e,r)&&r!==n&&o(e,r,{get:()=>t[r],enumerable:!(a=i(t,r))||a.enumerable});return e};var s=e=>y(o({},"__esModule",{value:!0}),e);var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var u=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},y=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!l.call(e,r)&&r!==n&&o(e,r,{get:()=>t[r],enumerable:!(a=i(t,r))||a.enumerable});return e};var s=e=>y(o({},"__esModule",{value:!0}),e);var I={};u(I,{filterBodyIntegrationFromPosition:()=>d,filterHeadIntegrations:()=>c,filterPositionIntegrations:()=>g});module.exports=s(I);function d(e,t){return e?.filter(n=>n.contentBody!==null&&n.contentBody!==""&&n.contentBodyPosition===t).map(n=>n.contentBody)||[]}function c(e){return e?.filter(t=>t.contentHead!==null&&t.contentHead!=="").map(t=>t.contentHead)||[]}function g(e,t){switch(t){case"head":return c(e);default:return d(e,t)}}0&&(module.exports={filterBodyIntegrationFromPosition,filterHeadIntegrations,filterPositionIntegrations});
|