mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
manager: fix secrets extraction for both modes
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"bin": "./dist/cli/index.js",
|
"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.",
|
"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",
|
"homepage": "https://bknd.io",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ export class ModuleManager {
|
|||||||
|
|
||||||
extractSecrets() {
|
extractSecrets() {
|
||||||
const moduleConfigs = structuredClone(this.configs());
|
const moduleConfigs = structuredClone(this.configs());
|
||||||
const secrets = this.options?.secrets || ({} as any);
|
const secrets = { ...this.options?.secrets };
|
||||||
const extractedKeys: string[] = [];
|
const extractedKeys: string[] = [];
|
||||||
|
|
||||||
for (const [key, module] of Object.entries(this.modules)) {
|
for (const [key, module] of Object.entries(this.modules)) {
|
||||||
@@ -221,11 +221,10 @@ export class ModuleManager {
|
|||||||
(n) => n.schema instanceof SecretSchema,
|
(n) => n.schema instanceof SecretSchema,
|
||||||
);
|
);
|
||||||
|
|
||||||
//console.log("extracted", key, extracted, config);
|
|
||||||
for (const n of extracted) {
|
for (const n of extracted) {
|
||||||
const path = [key, ...n.instancePath].join(".");
|
const path = [key, ...n.instancePath].join(".");
|
||||||
|
|
||||||
if (typeof n.data === "string" && n.data.length > 0) {
|
if (typeof n.data === "string") {
|
||||||
extractedKeys.push(path);
|
extractedKeys.push(path);
|
||||||
secrets[path] = n.data;
|
secrets[path] = n.data;
|
||||||
setPath(moduleConfigs, path, "");
|
setPath(moduleConfigs, path, "");
|
||||||
@@ -264,11 +263,11 @@ export class ModuleManager {
|
|||||||
// if secrets were provided, extract, merge and build again
|
// if secrets were provided, extract, merge and build again
|
||||||
const provided_secrets = this.options?.secrets ?? {};
|
const provided_secrets = this.options?.secrets ?? {};
|
||||||
if (Object.keys(provided_secrets).length > 0) {
|
if (Object.keys(provided_secrets).length > 0) {
|
||||||
const { configs, secrets, extractedKeys } = this.extractSecrets();
|
const { configs, extractedKeys } = this.extractSecrets();
|
||||||
|
|
||||||
for (const key of extractedKeys) {
|
for (const key of extractedKeys) {
|
||||||
if (key in provided_secrets) {
|
if (key in provided_secrets) {
|
||||||
setPath(configs, key, secrets[key]);
|
setPath(configs, key, provided_secrets[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user