@griddo/cx 1.72.5 → 1.72.8

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/gatsby-config.js CHANGED
@@ -32,6 +32,7 @@ const CONFIG = {
32
32
 
33
33
  if (assetPrefix) {
34
34
  CONFIG.assetPrefix = assetPrefix;
35
+ CONFIG.pathPrefix = null;
35
36
  }
36
37
 
37
38
  module.exports = CONFIG;
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": "1.72.5",
4
+ "version": "1.72.8",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -65,7 +65,7 @@
65
65
  "react-helmet": "^6.0.0"
66
66
  },
67
67
  "devDependencies": {
68
- "@griddo/eslint-config-back": "^1.72.5",
68
+ "@griddo/eslint-config-back": "^1.72.8",
69
69
  "eslint": "^7.5.0",
70
70
  "eslint-plugin-node": "^11.1.0",
71
71
  "eslint-plugin-react": "7.14.3",
@@ -97,5 +97,5 @@
97
97
  "publishConfig": {
98
98
  "access": "public"
99
99
  },
100
- "gitHead": "d41bd7e743330e0523b1218c58f4b97763a25338"
100
+ "gitHead": "99d546c3c5ea6faddd36beb4ba874dfe61bfe322"
101
101
  }
@@ -1,36 +1,46 @@
1
1
  const fs = require('fs');
2
+ const path = require('path');
2
3
  const crypto = require('crypto');
3
4
 
4
5
  const apiCacheDirectory = './apiCache';
6
+ const gatsbyCacheDirectory = path.resolve(__dirname, './../../.cache');
5
7
 
6
8
  const initCache = () => {
7
- if (!fs.existsSync(apiCacheDirectory)) {
8
- fs.mkdirSync(apiCacheDirectory);
9
- }
9
+ // TODO: Make a domain-based cache to store and restore
10
+ if (fs.existsSync(gatsbyCacheDirectory)) {
11
+ fs.rmSync(gatsbyCacheDirectory, {
12
+ force: true,
13
+ recursive: true,
14
+ });
15
+ }
16
+ if (!fs.existsSync(apiCacheDirectory)) {
17
+ fs.mkdirSync(apiCacheDirectory);
18
+ }
10
19
  };
11
20
 
12
- const generateFilename = (petition) => {
13
- const hashSum = crypto.createHash('sha256');
14
- hashSum.update(JSON.stringify(petition));
15
- return `${apiCacheDirectory}/${hashSum.digest('hex')}`;
21
+ const generateFilename = petition => {
22
+ const hashSum = crypto.createHash('sha256');
23
+ hashSum.update(JSON.stringify(petition));
24
+ return `${apiCacheDirectory}/${hashSum.digest('hex')}`;
16
25
  };
17
26
 
18
27
  const saveCache = (petition, content = '') => {
19
- const rightContent = typeof (content) === 'object' ? JSON.stringify(content) : content;
20
- fs.writeFileSync(generateFilename(petition), rightContent, 'utf8');
28
+ const rightContent =
29
+ typeof content === 'object' ? JSON.stringify(content) : content;
30
+ fs.writeFileSync(generateFilename(petition), rightContent, 'utf8');
21
31
  };
22
32
 
23
- const getCache = (petition) => {
24
- try {
25
- const content = fs.readFileSync(generateFilename(petition));
26
- return JSON.parse(content);
27
- } catch {
28
- return null;
29
- }
33
+ const getCache = petition => {
34
+ try {
35
+ const content = fs.readFileSync(generateFilename(petition));
36
+ return JSON.parse(content);
37
+ } catch {
38
+ return null;
39
+ }
30
40
  };
31
41
 
32
42
  module.exports = {
33
- initCache,
34
- saveCache,
35
- getCache,
36
- };
43
+ initCache,
44
+ saveCache,
45
+ getCache,
46
+ };