Skip to content

Commit e822d5a

Browse files
Copilotal7566
andcommitted
Fix code review issues: encapsulation, module detection, and endpoint URL
Co-authored-by: al7566 <215473224+al7566@users.noreply.github.com>
1 parent 9fb214e commit e822d5a

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

key-manager.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"type": "api",
9797
"description": "External key finder service for retrieving missing keys",
9898
"authSecret": "KEYFINDER_SECRET",
99-
"endpoint": "https://api.keyfinder.example.com/v1/keys"
99+
"endpoint": "https://api.keyfinder.example/v1/keys"
100100
}
101101
],
102102
"injectionTargets": {

scripts/key-manager.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,13 @@ class KeyManager {
407407
console.log('ℹ️ Keys remain accessible in GitHub secrets for deployment');
408408
}
409409

410+
/**
411+
* Get configuration
412+
*/
413+
getConfig(): Config {
414+
return this.config;
415+
}
416+
410417
/**
411418
* Generate summary report
412419
*/
@@ -481,7 +488,8 @@ async function main() {
481488

482489
// Read keys from environment
483490
const envKeys = new Map<string, string>();
484-
for (const keyConfig of manager['config'].requiredKeys) {
491+
const config = manager.getConfig();
492+
for (const keyConfig of config.requiredKeys) {
485493
const value = process.env[keyConfig.name];
486494
if (value) {
487495
envKeys.set(keyConfig.name, value);
@@ -507,8 +515,9 @@ async function main() {
507515
}
508516
}
509517

510-
// Run if executed directly
511-
if (import.meta.url === `file://${process.argv[1]}`) {
518+
// Run if executed directly (ES module check)
519+
const isMainModule = process.argv[1] && import.meta.url.endsWith(process.argv[1]);
520+
if (isMainModule || process.argv[1]?.includes('key-manager.ts')) {
512521
main().catch((error) => {
513522
console.error('Fatal error:', error);
514523
exit(1);

0 commit comments

Comments
 (0)