manager: fix secrets extraction for both modes

This commit is contained in:
dswbx
2025-09-05 14:14:12 +02:00
parent 7a0a7481c0
commit 3c5e3f9638
2 changed files with 5 additions and 6 deletions

View File

@@ -3,7 +3,7 @@
"type": "module",
"sideEffects": false,
"bin": "./dist/cli/index.js",
"version": "0.17.1",
"version": "0.18.0-rc.1",
"description": "Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.",
"homepage": "https://bknd.io",
"repository": {

View File

@@ -210,7 +210,7 @@ export class ModuleManager {
extractSecrets() {
const moduleConfigs = structuredClone(this.configs());
const secrets = this.options?.secrets || ({} as any);
const secrets = { ...this.options?.secrets };
const extractedKeys: string[] = [];
for (const [key, module] of Object.entries(this.modules)) {
@@ -221,11 +221,10 @@ export class ModuleManager {
(n) => n.schema instanceof SecretSchema,
);
//console.log("extracted", key, extracted, config);
for (const n of extracted) {
const path = [key, ...n.instancePath].join(".");
if (typeof n.data === "string" && n.data.length > 0) {
if (typeof n.data === "string") {
extractedKeys.push(path);
secrets[path] = n.data;
setPath(moduleConfigs, path, "");
@@ -264,11 +263,11 @@ export class ModuleManager {
// if secrets were provided, extract, merge and build again
const provided_secrets = this.options?.secrets ?? {};
if (Object.keys(provided_secrets).length > 0) {
const { configs, secrets, extractedKeys } = this.extractSecrets();
const { configs, extractedKeys } = this.extractSecrets();
for (const key of extractedKeys) {
if (key in provided_secrets) {
setPath(configs, key, secrets[key]);
setPath(configs, key, provided_secrets[key]);
}
}