@griddo/cx 11.9.12 → 11.9.14-rc.0

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.
@@ -4,12 +4,15 @@ import type {
4
4
  LifeCycleSteps,
5
5
  } from "../../types/global";
6
6
 
7
+ import fs from "node:fs";
7
8
  import path from "node:path";
8
9
 
9
10
  import {
10
11
  createDistFromGatsbyPublic,
11
12
  getGatsbyAssetPrefixWithDomain,
13
+ hasNewCommit,
12
14
  runGatsbyBuildCommand,
15
+ updateCommitFile,
13
16
  } from "./utils";
14
17
  import getCxArtifacts from "../../artifacts";
15
18
  import { AuthService } from "../../services/auth";
@@ -108,6 +111,20 @@ export async function renderDomainsWithGatsbyAdapter(domain: string) {
108
111
  renameArtifact(path.join(__cx, "dist"), path.join(__ssg, "public")),
109
112
  () => moveArtifacts(__cache, __cx, cxArtifacts.cacheables),
110
113
  () => moveArtifacts(__cache, __ssg, gatsbyArtifacts.cacheables),
114
+ // Remove .cache if new deploy detected
115
+ () => {
116
+ if (hasNewCommit(__cache)) {
117
+ if (fs.existsSync(path.join(__ssg, ".cache"))) {
118
+ infoLog(
119
+ "New deploy detected, removing Gatsby `.cache` directory to prevent data corruption",
120
+ );
121
+ fs.rmSync(path.join(__ssg, ".cache"), {
122
+ recursive: true,
123
+ force: true,
124
+ });
125
+ }
126
+ }
127
+ },
111
128
  ],
112
129
  },
113
130
 
@@ -147,7 +164,10 @@ export async function renderDomainsWithGatsbyAdapter(domain: string) {
147
164
 
148
165
  {
149
166
  name: "Close",
150
- steps: [() => removeArtifacts(disposableArtifacts)],
167
+ steps: [
168
+ () => removeArtifacts(disposableArtifacts),
169
+ () => updateCommitFile({ basePath: __cache }),
170
+ ],
151
171
  },
152
172
 
153
173
  {
@@ -1,4 +1,5 @@
1
- import { spawnSync } from "node:child_process";
1
+ import { execSync, spawnSync } from "node:child_process";
2
+ import fs from "node:fs";
2
3
  import path from "node:path";
3
4
 
4
5
  import fsx from "fs-extra";
@@ -154,8 +155,32 @@ async function createDistFromGatsbyPublic(
154
155
  }
155
156
  }
156
157
 
158
+ function hasNewCommit(basePath: string) {
159
+ const commitFile = path.join(basePath, "commit");
160
+ const currentCommit = execSync("git rev-parse HEAD").toString().trim();
161
+
162
+ if (fs.existsSync(commitFile)) {
163
+ const savedCommit = fs.readFileSync(commitFile, "utf-8").trim();
164
+ if (savedCommit === currentCommit) {
165
+ return false; // No hay nuevo commit
166
+ }
167
+
168
+ return true;
169
+ }
170
+
171
+ return true;
172
+ }
173
+
174
+ function updateCommitFile(options: { basePath: string }) {
175
+ const { basePath } = options;
176
+ const currentCommit = execSync("git rev-parse HEAD").toString().trim();
177
+ fs.writeFileSync(path.join(basePath, "commit"), currentCommit);
178
+ }
179
+
157
180
  export {
158
181
  createDistFromGatsbyPublic,
159
182
  getGatsbyAssetPrefixWithDomain,
183
+ hasNewCommit,
160
184
  runGatsbyBuildCommand,
185
+ updateCommitFile,
161
186
  };
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": "11.9.12",
4
+ "version": "11.9.14-rc.0",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -65,7 +65,7 @@
65
65
  "@babel/preset-env": "7.26.0",
66
66
  "@babel/preset-react": "7.26.3",
67
67
  "@babel/preset-typescript": "7.26.0",
68
- "@griddo/core": "11.9.12",
68
+ "@griddo/core": "11.9.14-rc.0",
69
69
  "@svgr/webpack": "5.5.0",
70
70
  "axios": "1.7.9",
71
71
  "babel-loader": "9.2.1",
@@ -130,5 +130,5 @@
130
130
  "publishConfig": {
131
131
  "access": "public"
132
132
  },
133
- "gitHead": "84fe61a326894742c48b3e82956928042e563a5b"
133
+ "gitHead": "b93b054f91576423db159f439b369d3bab4153fb"
134
134
  }