@stoker-platform/cli 0.5.109 → 0.5.110
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/lib/package.json
CHANGED
|
@@ -18,7 +18,9 @@ export const generateFirestoreRules = async () => {
|
|
|
18
18
|
body: JSON.stringify({ schema }),
|
|
19
19
|
method: "POST",
|
|
20
20
|
});
|
|
21
|
-
|
|
21
|
+
const result = await rulesResponse.json();
|
|
22
|
+
let { rules } = result;
|
|
23
|
+
const { message } = result;
|
|
22
24
|
const customRules = readFileSync(resolve(__dirname, process.cwd(), "firebase-rules", "firestore.custom.rules"), "utf8");
|
|
23
25
|
const trimLastTwoBraces = (input) => {
|
|
24
26
|
let trimmed = input.trimEnd();
|
|
@@ -32,4 +34,5 @@ export const generateFirestoreRules = async () => {
|
|
|
32
34
|
rules = trimLastTwoBraces(rules);
|
|
33
35
|
rules = `${rules}\n\n // CUSTOM SECURITY RULES\n\n ${customRules.split("\n").join("\n ")}\n }\n}`;
|
|
34
36
|
writeFileSync(resolve(__dirname, process.cwd(), "firebase-rules", "firestore.rules"), rules);
|
|
37
|
+
console.log(message);
|
|
35
38
|
};
|
|
@@ -19,6 +19,8 @@ export const generateStorageRules = async () => {
|
|
|
19
19
|
body: JSON.stringify({ schema, edition }),
|
|
20
20
|
method: "POST",
|
|
21
21
|
});
|
|
22
|
-
const
|
|
22
|
+
const result = await rulesResponse.json();
|
|
23
|
+
const { rules, message } = result;
|
|
23
24
|
writeFileSync(resolve(__dirname, process.cwd(), "firebase-rules", "storage.rules"), rules);
|
|
25
|
+
console.log(message);
|
|
24
26
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { generateSchema } from "../deploy/schema/generateSchema.js";
|
|
2
2
|
import { getAccessFields, getField, getDependencyIndexFields, isDependencyField, isRelationField, getRoleGroups, getFieldCustomization, } from "@stoker-platform/utils";
|
|
3
|
-
import { statSync } from "node:fs";
|
|
4
3
|
import { join } from "node:path";
|
|
5
4
|
import { pathToFileURL } from "node:url";
|
|
6
5
|
/* eslint-disable security/detect-object-injection */
|
|
@@ -200,19 +199,6 @@ export const securityReport = async () => {
|
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
201
|
}
|
|
203
|
-
const filePath = join(process.cwd(), "firebase-rules", "firestore.rules");
|
|
204
|
-
const fileStats = statSync(filePath);
|
|
205
|
-
const rulesetSize = fileStats.size / 1024;
|
|
206
|
-
if (rulesetSize > 256) {
|
|
207
|
-
console.error(`[ERROR] Size of ruleset: ${rulesetSize.toFixed(2)} KB - Exceeds Maximum of 256 KB.`);
|
|
208
|
-
isError = true;
|
|
209
|
-
}
|
|
210
|
-
else if (rulesetSize > 200) {
|
|
211
|
-
console.warn(`[WARN] Size of ruleset: ${rulesetSize.toFixed(2)} KB.`);
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
console.log(`Size of ruleset: ${rulesetSize.toFixed(2)} KB.`);
|
|
215
|
-
}
|
|
216
202
|
if (isError) {
|
|
217
203
|
throw new Error("Security errors found in schema.");
|
|
218
204
|
}
|