@griddo/cx 10.4.2 → 10.4.4

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.
@@ -12,8 +12,8 @@ import { removeProperties, walk } from "./shared";
12
12
  import { Site } from "../types/sites";
13
13
 
14
14
  /**
15
- * Read all pages stored in `store` Griddo folder and return one by one with a
16
- * generator.
15
+ * Read all pages stored in `store` Griddo directory and return one by one with
16
+ * a generator.
17
17
  */
18
18
  async function* getBuildPages<PageType extends GriddoPageObject>(
19
19
  basePath: string
@@ -56,12 +56,12 @@ function getBuildMetadata(basePath: string): BuildMetaData {
56
56
  }
57
57
 
58
58
  /**
59
- * Creates an `store` folder to store pages transformed by createStore
59
+ * Creates an `store` dir to store pages transformed by createStore
60
60
  */
61
- function createStoreFolder(storeFolder: string) {
62
- if (!fs.existsSync(storeFolder)) {
63
- fs.mkdirSync(storeFolder);
64
- fs.mkdirSync(path.resolve(storeFolder, "metadata"));
61
+ function createStoreDir(storeDir: string) {
62
+ if (!fs.existsSync(storeDir)) {
63
+ fs.mkdirSync(storeDir);
64
+ fs.mkdirSync(path.resolve(storeDir, "metadata"));
65
65
  }
66
66
 
67
67
  console.info("Store initialized");
@@ -69,7 +69,7 @@ function createStoreFolder(storeFolder: string) {
69
69
 
70
70
  /**
71
71
  * Write render info into a file.
72
- * @param basePath - Absolute path of the folder from which files will be saved.
72
+ * @param basePath - Absolute path of the dir from which files will be saved.
73
73
  * @param renderInfo - Data that will be saved related to the render process.
74
74
  */
75
75
  function saveRenderInfoInStore(basePath: string, renderInfo: RenderInfo) {
@@ -80,26 +80,26 @@ function saveRenderInfoInStore(basePath: string, renderInfo: RenderInfo) {
80
80
  }
81
81
 
82
82
  /**
83
- * Return an array of ids only from `.json` files (no dirs) in the `basePath` folder based in the file name and filtered by the pages ids in a concrete site.
84
- * @param basePath - Absolute path of the folder from which files will be read.
85
- * @returns A Array<number> of pages ids in `basePath` folder filtered by pages ids in a concrete site.
83
+ * Return an array of ids only from `.json` files (no dirs) in the `basePath` dir based in the file name and filtered by the pages ids in a concrete site.
84
+ * @param basePath - Absolute path of the dir from which files will be read.
85
+ * @returns A Array<number> of pages ids in `basePath` dir filtered by pages ids in a concrete site.
86
86
  */
87
- function getPagesInStoreFolderBySitePages(
87
+ function getPagesInStoreDirBySitePages(
88
88
  basePath: string,
89
89
  pages: Array<number>
90
90
  ): Array<number> {
91
- const allPagesInStore = getPageInStoreFolder(basePath);
91
+ const allPagesInStore = getPageInStoreDir(basePath);
92
92
  const pagesBySite = allPagesInStore.filter((page) => pages.includes(page));
93
93
 
94
94
  return pagesBySite;
95
95
  }
96
96
 
97
97
  /**
98
- * Return an array of ids only from `.json` files (no dirs) in the `basePath` folder based in the file name.
99
- * @param basePath - Absolute path of the folder from which files will be read.
100
- * @returns A Array<number> of pages ids in `basePath` folder.
98
+ * Return an array of ids only from `.json` files (no dirs) in the `basePath` dir based in the file name.
99
+ * @param basePath - Absolute path of the dir from which files will be read.
100
+ * @returns A Array<number> of pages ids in `basePath` dir.
101
101
  */
102
- function getPageInStoreFolder(basePath: string): Array<number> {
102
+ function getPageInStoreDir(basePath: string): Array<number> {
103
103
  const filesInStore = fs.readdirSync(basePath);
104
104
 
105
105
  return (
@@ -134,7 +134,7 @@ function getPageInStoreFolder(basePath: string): Array<number> {
134
134
 
135
135
  /**
136
136
  * Save the pages into the file system.
137
- * @param basePath - Absolute path of the folder from which files will be saved.
137
+ * @param basePath - Absolute path of the dir from which files will be saved.
138
138
  * @param pages - An array of Griddo page objects to be saved.
139
139
  */
140
140
  function savePagesInStore(basePath: string, pages: Array<GriddoPageObject>) {
@@ -147,8 +147,8 @@ function savePagesInStore(basePath: string, pages: Array<GriddoPageObject>) {
147
147
  }
148
148
 
149
149
  /**
150
- * Remove files from folder.
151
- * @param basePath - Absolute path of the folder from which files will be removed.
150
+ * Remove files from dir.
151
+ * @param basePath - Absolute path of the dir from which files will be removed.
152
152
  * @param filenames - An array of ids representing file page names.
153
153
  */
154
154
  function removePagesFromStore(basePath: string, filenames: Array<number>) {
@@ -169,14 +169,14 @@ function removePagesFromStore(basePath: string, filenames: Array<number>) {
169
169
  /**
170
170
  * Returns pages that need to be created or deleted for a site in the store based on the provided arguments.
171
171
  * @param sitePages - Properties for page retrieval.
172
- * @param props.storeFolder - Absolute path of the Griddo store.
172
+ * @param props.storeDir - Absolute path of the Griddo store.
173
173
  * @param props.pages - Exhaustive array of all pages in the site.
174
174
  * @param props.validPagesIds - Array of valid pages in the site.
175
175
  * @param props.changedPages - Array of pages that have been modified in the site.
176
176
  * @returns - An object containing the pages to be created and deleted in the site.
177
177
  */
178
178
  async function getPagesToCreateOrDelete(
179
- storeFolder: string,
179
+ storeDir: string,
180
180
  sitePages: {
181
181
  sitesToPublish: Array<Site>;
182
182
  pages: Array<number>;
@@ -187,7 +187,7 @@ async function getPagesToCreateOrDelete(
187
187
  const { changedPages, pages, validPagesIds, sitesToPublish } = sitePages;
188
188
  // Array<ids> de las páginas que están físicamente en el store en el
189
189
  // site actual del bucle.
190
- const pagesInStore = getPagesInStoreFolderBySitePages(storeFolder, pages);
190
+ const pagesInStore = getPagesInStoreDirBySitePages(storeDir, pages);
191
191
 
192
192
  // Array<ids> que están el `validPagesIds` pero no están por algún
193
193
  // motivo en el store. Se incluyen porque deben ser creadas.
@@ -240,7 +240,7 @@ async function getPagesToCreateOrDelete(
240
240
  }
241
241
 
242
242
  export {
243
- createStoreFolder,
243
+ createStoreDir,
244
244
  getBuildMetadata,
245
245
  getBuildPages,
246
246
  getPagesToCreateOrDelete,
package/gatsby-node.ts CHANGED
@@ -8,14 +8,14 @@ import { generateBuildReport, generateSitemaps } from "./exporter/utils/sites";
8
8
  import { getBuildMetadata, getBuildPages } from "./exporter/utils/store";
9
9
  import {
10
10
  getMatchPath,
11
- prepareStaticFolder,
11
+ prepareStaticDir,
12
12
  updateDist,
13
13
  } from "./src/gatsby-node-utils";
14
14
  import { GatsbyPageObject } from "./src/types";
15
15
 
16
- const publicFolderPath = path.resolve(__dirname, "./public");
17
- const storeFolderPath = path.resolve(__dirname, "./store/");
18
- const reportFilePath = path.resolve(publicFolderPath, "__build-report__.json");
16
+ const publicDirPath = path.resolve(__dirname, "./public");
17
+ const storeDirPath = path.resolve(__dirname, "./store/");
18
+ const reportFilePath = path.resolve(publicDirPath, "__build-report__.json");
19
19
  const gatsbyTemplateFile = path.resolve(
20
20
  __dirname,
21
21
  "./src/components/template.tsx"
@@ -23,14 +23,14 @@ const gatsbyTemplateFile = path.resolve(
23
23
 
24
24
  // onPreInit
25
25
  const onPreInit = async () => {
26
- prepareStaticFolder();
26
+ prepareStaticDir();
27
27
  };
28
28
 
29
29
  // createPages
30
30
  const createPages: GatsbyNode["createPages"] = async ({
31
31
  actions: { createPage },
32
32
  }) => {
33
- const pages = getBuildPages<GatsbyPageObject>(storeFolderPath);
33
+ const pages = getBuildPages<GatsbyPageObject>(storeDirPath);
34
34
 
35
35
  for await (const page of pages) {
36
36
  // SECURITY
@@ -55,12 +55,10 @@ const createPages: GatsbyNode["createPages"] = async ({
55
55
 
56
56
  // onPostBuild
57
57
  const onPostBuild = async () => {
58
- const { buildProcessData, sitesToPublish } = getBuildMetadata(
59
- storeFolderPath
60
- );
58
+ const { buildProcessData, sitesToPublish } = getBuildMetadata(storeDirPath);
61
59
 
62
60
  await generateBuildReport(reportFilePath, buildProcessData);
63
- await RobotsService.writeFiles(publicFolderPath);
61
+ await RobotsService.writeFiles(publicDirPath);
64
62
  await generateSitemaps(sitesToPublish);
65
63
  await updateDist();
66
64
  };
package/index.js CHANGED
@@ -3,5 +3,5 @@
3
3
 
4
4
  // This is the griddo-cx package entry point.
5
5
  // `./build/index.js` is for the Griddo Exporter, where everything start.
6
- // The source code (TypeScript) is in ./exporter folder
6
+ // The source code (TypeScript) is in ./exporter dir
7
7
  require("./build/index.js");
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.2",
4
+ "version": "10.4.4",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -70,7 +70,7 @@
70
70
  "react-helmet": "^6.0.0"
71
71
  },
72
72
  "devDependencies": {
73
- "@griddo/eslint-config-back": "^10.4.2",
73
+ "@griddo/eslint-config-back": "^10.4.4",
74
74
  "@types/babel__core": "^7.20.0",
75
75
  "@types/babel__preset-env": "^7.9.2",
76
76
  "@types/csvtojson": "^2.0.0",
@@ -117,5 +117,5 @@
117
117
  "publishConfig": {
118
118
  "access": "public"
119
119
  },
120
- "gitHead": "f278d83131c144600de8ea769c466991f41311c4"
120
+ "gitHead": "1177d9b185f1b8768e69600651b07fb028d14b47"
121
121
  }
package/src/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Griddo CX + Gatsby
2
2
 
3
- The `/src` folder and almost every file in the root folder is now 100% Gatsby related code along with the historical `/public`, `/dist`, `/apiCache`, `/store`, etc.. render folders.
3
+ The `/src` dir and almost every file in the root dir is now 100% Gatsby related code along with the historical `/public`, `/dist`, `/apiCache`, `/store`, etc.. render dirs.
4
4
 
5
- Griddo CX code (the business logic) is now in `/exporter` folder.
5
+ Griddo CX code (the business logic) is now in `/exporter` dir.
6
6
 
7
- In the future, Griddo CX and Gatsby will split int their own packages folders inside the mono-repo.
7
+ In the future, Griddo CX and Gatsby will split int their own packages dirs inside the mono-repo.
@@ -11,9 +11,9 @@ import {
11
11
  } from "../exporter/utils/instance";
12
12
 
13
13
  /**
14
- * Copy the instance's `/static` folder into the Gatsby's to include it in the render assets.
14
+ * Copy the instance's `/static` dir into the Gatsby's to include it in the render assets.
15
15
  */
16
- function prepareStaticFolder() {
16
+ function prepareStaticDir() {
17
17
  const src = resolveComponentsPath("static");
18
18
  const dest = "./static";
19
19
 
@@ -26,14 +26,14 @@ function prepareStaticFolder() {
26
26
  fs.copySync(fileSrc, fileDest);
27
27
  });
28
28
 
29
- console.info("Components static folder copied");
29
+ console.info("Components `static` dir copied");
30
30
  } catch (err) {
31
31
  console.error(err);
32
32
  }
33
33
  }
34
34
 
35
35
  /**
36
- * Update the Griddo's `/dist` folder with the contents from `/public` only with files of type:
36
+ * Update the Griddo's `/dist` dir with the contents from `/public` only with files of type:
37
37
  * - js
38
38
  * - json
39
39
  * - css
@@ -148,7 +148,7 @@ function getMatchPath(domain: string, compose: string) {
148
148
  export {
149
149
  getMatchPath,
150
150
  onCreateWebpackConfig,
151
- prepareStaticFolder,
151
+ prepareStaticDir,
152
152
  updateDist,
153
153
  getGatsbyAssetPrefixSlug,
154
154
  };
package/src/types.ts CHANGED
@@ -10,7 +10,7 @@ import type { Site } from "../exporter/types/sites";
10
10
  import type { Core } from "@griddo/core";
11
11
  import type { HeadProps } from "gatsby";
12
12
 
13
- export interface CustomHeadProps extends HeadProps {
13
+ interface CustomHeadProps extends HeadProps {
14
14
  pageContext: GriddoPageObject["context"] & {
15
15
  page: Core.Page & {
16
16
  defaultLang: { id: number };
@@ -20,7 +20,7 @@ export interface CustomHeadProps extends HeadProps {
20
20
  };
21
21
  }
22
22
 
23
- export interface TemplateProps extends Omit<GriddoPageObject, "context"> {
23
+ interface TemplateProps extends Omit<GriddoPageObject, "context"> {
24
24
  pageContext: GriddoPageObject["context"] & {
25
25
  page: Core.Page;
26
26
  };
@@ -31,7 +31,7 @@ export interface TemplateProps extends Omit<GriddoPageObject, "context"> {
31
31
  };
32
32
  }
33
33
 
34
- export interface HtmlProps {
34
+ interface HtmlProps {
35
35
  body: string;
36
36
  bodyAttributes: React.HtmlHTMLAttributes<HTMLBodyElement>;
37
37
  headComponents: React.ReactNode;
@@ -40,7 +40,7 @@ export interface HtmlProps {
40
40
  preBodyComponents: React.ReactNode;
41
41
  }
42
42
 
43
- export interface Dimensions {
43
+ interface Dimensions {
44
44
  values: Record<string, string> | null;
45
45
  contentSelect?: "group" | "individual" | null;
46
46
  groupSelect?: string;
@@ -48,7 +48,7 @@ export interface Dimensions {
48
48
  }
49
49
 
50
50
  // TODO: JSDoc
51
- export type GatsbyPageObject = {
51
+ type GatsbyPageObject = {
52
52
  matchPath?: string;
53
53
  path: string;
54
54
  component: string;
@@ -95,3 +95,11 @@ export type GatsbyPageObject = {
95
95
  page: GriddoSinglePage | GriddoListPage | GriddoMultiPage;
96
96
  };
97
97
  };
98
+
99
+ export {
100
+ CustomHeadProps,
101
+ Dimensions,
102
+ GatsbyPageObject,
103
+ HtmlProps,
104
+ TemplateProps,
105
+ };
package/static/robots.txt CHANGED
@@ -1,3 +1,3 @@
1
- # This file comes from the /static folder
1
+ # This file comes from the /static dir
2
2
  User-agent: *
3
3
  Disallow: /