@griddo/ax 11.1.13 → 11.1.15
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "11.1.
|
|
4
|
+
"version": "11.1.15",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -225,5 +225,5 @@
|
|
|
225
225
|
"publishConfig": {
|
|
226
226
|
"access": "public"
|
|
227
227
|
},
|
|
228
|
-
"gitHead": "
|
|
228
|
+
"gitHead": "0a37b975b12080895e7705a99f338d3543ba14a8"
|
|
229
229
|
}
|
|
@@ -14,6 +14,9 @@ dotenv.config({ path: findUp.sync(".env") });
|
|
|
14
14
|
const { API_URL, REACT_APP_API_ENDPOINT, GRIDDO_API_URL, developerKey } = process.env;
|
|
15
15
|
const apiURL = API_URL || REACT_APP_API_ENDPOINT || GRIDDO_API_URL;
|
|
16
16
|
const tempFile = "__griddo_config_parsed__.js";
|
|
17
|
+
const REQUIRED_API_VERSION = "11.1.1";
|
|
18
|
+
let failedCount = 0;
|
|
19
|
+
const maximumFailedAttempts = 5;
|
|
17
20
|
|
|
18
21
|
(async () => {
|
|
19
22
|
console.clear();
|
|
@@ -23,6 +26,9 @@ const tempFile = "__griddo_config_parsed__.js";
|
|
|
23
26
|
const outputFile = `${__dirname}/${tempFile}`;
|
|
24
27
|
|
|
25
28
|
try {
|
|
29
|
+
// Check if the API is in the correct version. If not, it waits for a minute and checks again.
|
|
30
|
+
await checkIfAPIisInCorrectVersion();
|
|
31
|
+
|
|
26
32
|
if (fs.existsSync(outputFile)) {
|
|
27
33
|
fs.unlinkSync(outputFile);
|
|
28
34
|
}
|
|
@@ -106,3 +112,52 @@ function parseComputedPropInStructuredDataSchemas(schemas) {
|
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Check if the API is in the correct version. If not, it waits for a minute and checks again.
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
async function checkIfAPIisInCorrectVersion() {
|
|
121
|
+
const actualVersion = await getCurrentAPIVersion();
|
|
122
|
+
const isCorrect = checkNewVersionIsGreaterThanLast(actualVersion, REQUIRED_API_VERSION);
|
|
123
|
+
|
|
124
|
+
if (!isCorrect) {
|
|
125
|
+
console.log(failedCount);
|
|
126
|
+
failedCount++;
|
|
127
|
+
|
|
128
|
+
console.log(
|
|
129
|
+
chalk.yellow(
|
|
130
|
+
`API is not in the correct version. Expected version greater than "${REQUIRED_API_VERSION}" and got "${actualVersion}".\n Retry in a minute...\n`
|
|
131
|
+
)
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
if (failedCount >= maximumFailedAttempts) {
|
|
135
|
+
console.log(chalk.red(`API is not in the correct version after ${maximumFailedAttempts} attempts. Exiting...`));
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
await new Promise((resolve) => setTimeout(resolve, 60000)); // Waits for a minute
|
|
140
|
+
await checkIfAPIisInCorrectVersion();
|
|
141
|
+
} else {
|
|
142
|
+
console.log(chalk.green("✓ API is in the correct version."));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Compare two versions and return true if the actual version is greater than the required version.
|
|
148
|
+
*/
|
|
149
|
+
const checkNewVersionIsGreaterThanLast = (actualVersion, requiredVersion) => {
|
|
150
|
+
const [majorA, minorA, patchA] = actualVersion.split(".").map(Number);
|
|
151
|
+
const [majorB, minorB, patchB] = requiredVersion.split(".").map(Number);
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
majorA > majorB ||
|
|
155
|
+
(majorA === majorB && minorA > minorB) ||
|
|
156
|
+
(majorA === majorB && minorA === minorB && patchA >= patchB) // Asegura que 11.1.1 sea válido
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
async function getCurrentAPIVersion() {
|
|
161
|
+
const response = await axios.get(`${apiURL}/settings`);
|
|
162
|
+
return response.data.apiVersion;
|
|
163
|
+
}
|