@firela/billclaw-cli 0.1.5 → 0.2.0
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/LICENSE +21 -0
- package/bin/billclaw.js +0 -0
- package/dist/commands/index.d.ts +13 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +2 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/webhook.d.ts +11 -0
- package/dist/commands/webhook.d.ts.map +1 -0
- package/dist/commands/webhook.js +53 -0
- package/dist/commands/webhook.js.map +1 -0
- package/dist/runtime/config.d.ts +44 -4
- package/dist/runtime/config.d.ts.map +1 -1
- package/dist/runtime/config.js +73 -62
- package/dist/runtime/config.js.map +1 -1
- package/package.json +14 -14
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 fire-la
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/billclaw.js
CHANGED
|
File without changes
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { syncCommand } from "./sync.js";
|
|
|
9
9
|
export { statusCommand } from "./status.js";
|
|
10
10
|
export { configCommand } from "./config.js";
|
|
11
11
|
export { exportCommand } from "./export.js";
|
|
12
|
+
export { webhookTestCommand } from "./webhook.js";
|
|
12
13
|
/**
|
|
13
14
|
* All commands to register
|
|
14
15
|
*/
|
|
@@ -18,29 +19,41 @@ export declare const allCommands: ({
|
|
|
18
19
|
status?: undefined;
|
|
19
20
|
config?: undefined;
|
|
20
21
|
export?: undefined;
|
|
22
|
+
webhook?: undefined;
|
|
21
23
|
} | {
|
|
22
24
|
sync: () => Promise<import("./registry.js").CliCommand>;
|
|
23
25
|
setup?: undefined;
|
|
24
26
|
status?: undefined;
|
|
25
27
|
config?: undefined;
|
|
26
28
|
export?: undefined;
|
|
29
|
+
webhook?: undefined;
|
|
27
30
|
} | {
|
|
28
31
|
status: () => Promise<import("./registry.js").CliCommand>;
|
|
29
32
|
setup?: undefined;
|
|
30
33
|
sync?: undefined;
|
|
31
34
|
config?: undefined;
|
|
32
35
|
export?: undefined;
|
|
36
|
+
webhook?: undefined;
|
|
33
37
|
} | {
|
|
34
38
|
config: () => Promise<import("./registry.js").CliCommand>;
|
|
35
39
|
setup?: undefined;
|
|
36
40
|
sync?: undefined;
|
|
37
41
|
status?: undefined;
|
|
38
42
|
export?: undefined;
|
|
43
|
+
webhook?: undefined;
|
|
39
44
|
} | {
|
|
40
45
|
export: () => Promise<import("./registry.js").CliCommand>;
|
|
41
46
|
setup?: undefined;
|
|
42
47
|
sync?: undefined;
|
|
43
48
|
status?: undefined;
|
|
44
49
|
config?: undefined;
|
|
50
|
+
webhook?: undefined;
|
|
51
|
+
} | {
|
|
52
|
+
webhook: () => Promise<import("./registry.js").CliCommand>;
|
|
53
|
+
setup?: undefined;
|
|
54
|
+
sync?: undefined;
|
|
55
|
+
status?: undefined;
|
|
56
|
+
config?: undefined;
|
|
57
|
+
export?: undefined;
|
|
45
58
|
})[];
|
|
46
59
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C;;GAEG;AACH,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAOvB,CAAA"}
|
package/dist/commands/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { syncCommand } from "./sync.js";
|
|
|
9
9
|
export { statusCommand } from "./status.js";
|
|
10
10
|
export { configCommand } from "./config.js";
|
|
11
11
|
export { exportCommand } from "./export.js";
|
|
12
|
+
export { webhookTestCommand } from "./webhook.js";
|
|
12
13
|
/**
|
|
13
14
|
* All commands to register
|
|
14
15
|
*/
|
|
@@ -18,5 +19,6 @@ export const allCommands = [
|
|
|
18
19
|
{ status: () => import("./status.js").then((m) => m.statusCommand) },
|
|
19
20
|
{ config: () => import("./config.js").then((m) => m.configCommand) },
|
|
20
21
|
{ export: () => import("./export.js").then((m) => m.exportCommand) },
|
|
22
|
+
{ webhook: () => import("./webhook.js").then((m) => m.webhookTestCommand) },
|
|
21
23
|
];
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,GAIhB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE;IACjE,EAAE,IAAI,EAAE,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C,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE;IAC9D,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE;IACpE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE;IACpE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE;IACpE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE;CAC5E,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook command
|
|
3
|
+
*
|
|
4
|
+
* Send test webhooks to verify webhook configuration.
|
|
5
|
+
*/
|
|
6
|
+
import type { CliCommand } from "./registry.js";
|
|
7
|
+
/**
|
|
8
|
+
* Webhook test command definition
|
|
9
|
+
*/
|
|
10
|
+
export declare const webhookTestCommand: CliCommand;
|
|
11
|
+
//# sourceMappingURL=webhook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/commands/webhook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,eAAe,CAAA;AAsD3D;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAMhC,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook command
|
|
3
|
+
*
|
|
4
|
+
* Send test webhooks to verify webhook configuration.
|
|
5
|
+
*/
|
|
6
|
+
import { emitWebhookTest } from "@firela/billclaw-core";
|
|
7
|
+
import { success, error } from "../utils/format.js";
|
|
8
|
+
/**
|
|
9
|
+
* Run webhook test command
|
|
10
|
+
*/
|
|
11
|
+
async function runWebhookTest(context, _args) {
|
|
12
|
+
const { runtime } = context;
|
|
13
|
+
try {
|
|
14
|
+
// Get configured webhooks directly from config
|
|
15
|
+
const config = await runtime.config.getConfig();
|
|
16
|
+
const webhooks = config.webhooks || [];
|
|
17
|
+
if (webhooks.length === 0) {
|
|
18
|
+
console.log("No webhooks configured.");
|
|
19
|
+
console.log("To configure webhooks, add them to your config file:");
|
|
20
|
+
console.log(" ~/.billclaw/config.json");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const enabledWebhooks = webhooks.filter((w) => w.enabled && w.url);
|
|
24
|
+
if (enabledWebhooks.length === 0) {
|
|
25
|
+
console.log("No enabled webhooks found.");
|
|
26
|
+
console.log(`Total webhooks configured: ${webhooks.length}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
console.log(`Sending test webhook to ${enabledWebhooks.length} endpoint(s)...`);
|
|
30
|
+
// Send test webhook
|
|
31
|
+
await emitWebhookTest(runtime.logger, webhooks, "Test webhook from BillClaw CLI");
|
|
32
|
+
success("Test webhook sent successfully!");
|
|
33
|
+
console.log("\nEndpoints:");
|
|
34
|
+
for (const webhook of enabledWebhooks) {
|
|
35
|
+
console.log(` - ${webhook.url}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
error(`Failed to send test webhook: ${err.message}`);
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Webhook test command definition
|
|
45
|
+
*/
|
|
46
|
+
export const webhookTestCommand = {
|
|
47
|
+
name: "webhook",
|
|
48
|
+
description: "Send test webhook to verify configuration",
|
|
49
|
+
aliases: ["test-webhook"],
|
|
50
|
+
options: [],
|
|
51
|
+
handler: (context, args) => runWebhookTest(context, args),
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=webhook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/commands/webhook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAEnD;;GAEG;AACH,KAAK,UAAU,cAAc,CAC3B,OAAmB,EACnB,KAA8B;IAE9B,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAE3B,IAAI,CAAC;QACH,+CAA+C;QAC/C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,CAAA;QAC/C,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAA;QAEtC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;YACtC,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAA;YACnE,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;YACxC,OAAM;QACR,CAAC;QAED,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;QAEvE,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;YACzC,OAAO,CAAC,GAAG,CAAC,8BAA8B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;YAC5D,OAAM;QACR,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,2BAA2B,eAAe,CAAC,MAAM,iBAAiB,CAAC,CAAA;QAE/E,oBAAoB;QACpB,MAAM,eAAe,CACnB,OAAO,CAAC,MAAM,EACd,QAAQ,EACR,gCAAgC,CACjC,CAAA;QAED,OAAO,CAAC,iCAAiC,CAAC,CAAA;QAC1C,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;QAC3B,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;YACtC,OAAO,CAAC,GAAG,CAAC,OAAQ,OAAe,CAAC,GAAG,EAAE,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,KAAK,CAAC,gCAAiC,GAAa,CAAC,OAAO,EAAE,CAAC,CAAA;QAC/D,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAe;IAC5C,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,2CAA2C;IACxD,OAAO,EAAE,CAAC,cAAc,CAAC;IACzB,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,IAA+B,CAAC;CACrF,CAAA"}
|
package/dist/runtime/config.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CLI config provider implementation
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Refactored to use ConfigManager internally while maintaining
|
|
5
|
+
* backward compatibility with existing CLI code.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
5
8
|
*/
|
|
6
9
|
import type { ConfigProvider, BillclawConfig } from "@firela/billclaw-core";
|
|
10
|
+
import { ConfigManager } from "@firela/billclaw-core";
|
|
7
11
|
/**
|
|
8
12
|
* CLI config provider options
|
|
9
13
|
*/
|
|
@@ -13,20 +17,56 @@ export interface CliConfigOptions {
|
|
|
13
17
|
}
|
|
14
18
|
/**
|
|
15
19
|
* CLI config provider implementation
|
|
20
|
+
*
|
|
21
|
+
* This is now a thin wrapper around ConfigManager that:
|
|
22
|
+
* - Maintains backward compatibility with CLI code
|
|
23
|
+
* - Provides CLI-specific options interface
|
|
24
|
+
* - Delegates all config operations to ConfigManager
|
|
25
|
+
*
|
|
26
|
+
* @deprecated Use ConfigManager directly when possible
|
|
16
27
|
*/
|
|
17
28
|
export declare class CliConfigProvider implements ConfigProvider {
|
|
18
|
-
private
|
|
19
|
-
private cachedConfig?;
|
|
29
|
+
private configManager;
|
|
20
30
|
constructor(options?: CliConfigOptions);
|
|
21
31
|
getConfig(): Promise<BillclawConfig>;
|
|
22
32
|
getStorageConfig(): Promise<any>;
|
|
23
33
|
updateAccount(accountId: string, updates: Partial<any>): Promise<void>;
|
|
24
34
|
getAccount(accountId: string): Promise<any | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Save config (legacy method for backward compatibility)
|
|
37
|
+
*
|
|
38
|
+
* @deprecated Use updateConfig() instead
|
|
39
|
+
*/
|
|
25
40
|
saveConfig(config: BillclawConfig): Promise<void>;
|
|
26
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Update full configuration
|
|
43
|
+
*
|
|
44
|
+
* @param updates - Partial config to merge with existing config
|
|
45
|
+
*/
|
|
46
|
+
updateConfig(updates: Partial<BillclawConfig>): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Get the underlying ConfigManager instance
|
|
49
|
+
*
|
|
50
|
+
* This provides access to extended ConfigManager functionality
|
|
51
|
+
* like getEffectiveConfig() and reloadConfig().
|
|
52
|
+
*/
|
|
53
|
+
getConfigManager(): ConfigManager;
|
|
27
54
|
}
|
|
28
55
|
/**
|
|
29
56
|
* Create a default CLI config provider
|
|
57
|
+
*
|
|
58
|
+
* @param options - CLI-specific config options
|
|
59
|
+
* @returns CliConfigProvider instance
|
|
30
60
|
*/
|
|
31
61
|
export declare function createConfigProvider(options?: CliConfigOptions): CliConfigProvider;
|
|
62
|
+
/**
|
|
63
|
+
* Get the default ConfigManager instance with CLI defaults
|
|
64
|
+
*
|
|
65
|
+
* This is a convenience function for CLI code that needs direct
|
|
66
|
+
* access to ConfigManager features.
|
|
67
|
+
*
|
|
68
|
+
* @param options - CLI-specific config options
|
|
69
|
+
* @returns ConfigManager singleton instance
|
|
70
|
+
*/
|
|
71
|
+
export declare function getSharedConfigManager(options?: CliConfigOptions): ConfigManager;
|
|
32
72
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/runtime/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/runtime/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAErD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAUD;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,aAAa,CAAe;gBAExB,OAAO,GAAE,gBAAqB;IAMpC,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC;IAIpC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC;IAWhC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAItE,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IAIxD;;;;OAIG;IACG,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAInE;;;;;OAKG;IACH,gBAAgB,IAAI,aAAa;CAGlC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,CAAC,EAAE,gBAAgB,GACzB,iBAAiB,CAEnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,CAAC,EAAE,gBAAgB,GACzB,aAAa,CAoBf"}
|
package/dist/runtime/config.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CLI config provider implementation
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Refactored to use ConfigManager internally while maintaining
|
|
5
|
+
* backward compatibility with existing CLI code.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
5
8
|
*/
|
|
6
|
-
import * as fs from "node:fs";
|
|
7
9
|
import * as path from "node:path";
|
|
8
10
|
import * as os from "node:os";
|
|
11
|
+
import { ConfigManager } from "@firela/billclaw-core";
|
|
9
12
|
/**
|
|
10
13
|
* Default config directory path
|
|
11
14
|
*/
|
|
@@ -15,91 +18,99 @@ function getDefaultConfigDir() {
|
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
20
|
* CLI config provider implementation
|
|
21
|
+
*
|
|
22
|
+
* This is now a thin wrapper around ConfigManager that:
|
|
23
|
+
* - Maintains backward compatibility with CLI code
|
|
24
|
+
* - Provides CLI-specific options interface
|
|
25
|
+
* - Delegates all config operations to ConfigManager
|
|
26
|
+
*
|
|
27
|
+
* @deprecated Use ConfigManager directly when possible
|
|
18
28
|
*/
|
|
19
29
|
export class CliConfigProvider {
|
|
20
|
-
|
|
21
|
-
cachedConfig;
|
|
30
|
+
configManager;
|
|
22
31
|
constructor(options = {}) {
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
// Use getSharedConfigManager to handle singleton properly
|
|
33
|
+
// This ensures ConfigManager is initialized with correct path
|
|
34
|
+
this.configManager = getSharedConfigManager(options);
|
|
25
35
|
}
|
|
26
36
|
async getConfig() {
|
|
27
|
-
|
|
28
|
-
return this.cachedConfig;
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
const content = await fs.promises.readFile(this.configPath, "utf-8");
|
|
32
|
-
this.cachedConfig = JSON.parse(content);
|
|
33
|
-
return this.cachedConfig;
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
if (err.code === "ENOENT") {
|
|
37
|
-
// Return default config if file doesn't exist
|
|
38
|
-
this.cachedConfig = this.getDefaultConfig();
|
|
39
|
-
return this.cachedConfig;
|
|
40
|
-
}
|
|
41
|
-
throw err;
|
|
42
|
-
}
|
|
37
|
+
return this.configManager.getConfig();
|
|
43
38
|
}
|
|
44
39
|
async getStorageConfig() {
|
|
45
40
|
const config = await this.getConfig();
|
|
46
41
|
return (config.storage || {
|
|
47
|
-
path: "~/.billclaw
|
|
42
|
+
path: "~/.billclaw",
|
|
48
43
|
format: "json",
|
|
49
44
|
encryption: { enabled: false },
|
|
50
45
|
});
|
|
51
46
|
}
|
|
52
47
|
async updateAccount(accountId, updates) {
|
|
53
|
-
|
|
54
|
-
const accountIndex = config.accounts.findIndex((a) => a.id === accountId);
|
|
55
|
-
if (accountIndex === -1) {
|
|
56
|
-
throw new Error(`Account ${accountId} not found`);
|
|
57
|
-
}
|
|
58
|
-
config.accounts[accountIndex] = {
|
|
59
|
-
...config.accounts[accountIndex],
|
|
60
|
-
...updates,
|
|
61
|
-
};
|
|
62
|
-
await this.saveConfig(config);
|
|
63
|
-
this.cachedConfig = config;
|
|
48
|
+
return this.configManager.updateAccount(accountId, updates);
|
|
64
49
|
}
|
|
65
50
|
async getAccount(accountId) {
|
|
66
|
-
|
|
67
|
-
return config.accounts.find((a) => a.id === accountId) || null;
|
|
51
|
+
return this.configManager.getAccount(accountId);
|
|
68
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Save config (legacy method for backward compatibility)
|
|
55
|
+
*
|
|
56
|
+
* @deprecated Use updateConfig() instead
|
|
57
|
+
*/
|
|
69
58
|
async saveConfig(config) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
59
|
+
return this.configManager.updateConfig(config);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Update full configuration
|
|
63
|
+
*
|
|
64
|
+
* @param updates - Partial config to merge with existing config
|
|
65
|
+
*/
|
|
66
|
+
async updateConfig(updates) {
|
|
67
|
+
return this.configManager.updateConfig(updates);
|
|
78
68
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
sync: {
|
|
89
|
-
defaultFrequency: "manual",
|
|
90
|
-
maxRetries: 3,
|
|
91
|
-
retryOnFailure: true,
|
|
92
|
-
},
|
|
93
|
-
plaid: {
|
|
94
|
-
environment: "sandbox",
|
|
95
|
-
},
|
|
96
|
-
};
|
|
69
|
+
/**
|
|
70
|
+
* Get the underlying ConfigManager instance
|
|
71
|
+
*
|
|
72
|
+
* This provides access to extended ConfigManager functionality
|
|
73
|
+
* like getEffectiveConfig() and reloadConfig().
|
|
74
|
+
*/
|
|
75
|
+
getConfigManager() {
|
|
76
|
+
return this.configManager;
|
|
97
77
|
}
|
|
98
78
|
}
|
|
99
79
|
/**
|
|
100
80
|
* Create a default CLI config provider
|
|
81
|
+
*
|
|
82
|
+
* @param options - CLI-specific config options
|
|
83
|
+
* @returns CliConfigProvider instance
|
|
101
84
|
*/
|
|
102
85
|
export function createConfigProvider(options) {
|
|
103
86
|
return new CliConfigProvider(options);
|
|
104
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the default ConfigManager instance with CLI defaults
|
|
90
|
+
*
|
|
91
|
+
* This is a convenience function for CLI code that needs direct
|
|
92
|
+
* access to ConfigManager features.
|
|
93
|
+
*
|
|
94
|
+
* @param options - CLI-specific config options
|
|
95
|
+
* @returns ConfigManager singleton instance
|
|
96
|
+
*/
|
|
97
|
+
export function getSharedConfigManager(options) {
|
|
98
|
+
const configDir = options?.configDir ?? getDefaultConfigDir();
|
|
99
|
+
const configPath = options?.configPath ?? path.join(configDir, "config.json");
|
|
100
|
+
// Get or create singleton with the specified path
|
|
101
|
+
// Note: this requires resetting if a different path was used before
|
|
102
|
+
const existing = ConfigManager.getInstance();
|
|
103
|
+
if (existing["configPath"] !== configPath) {
|
|
104
|
+
// Reset singleton if path differs
|
|
105
|
+
ConfigManager.resetInstance();
|
|
106
|
+
return ConfigManager.getInstance({
|
|
107
|
+
configPath,
|
|
108
|
+
enableEnvOverrides: true,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return ConfigManager.getInstance({
|
|
112
|
+
configPath,
|
|
113
|
+
enableEnvOverrides: true,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
105
116
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/runtime/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/runtime/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAUrD;;GAEG;AACH,SAAS,mBAAmB;IAC1B,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAA;IACzB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;A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,CAAC,CAAA;AACvC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAA0B;IAE1B,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,mBAAmB,EAAE,CAAA;IAC7D,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAE7E,kDAAkD;IAClD,oEAAoE;IACpE,MAAM,QAAQ,GAAG,aAAa,CAAC,WAAW,EAAS,CAAA;IACnD,IAAI,QAAQ,CAAC,YAAY,CAAC,KAAK,UAAU,EAAE,CAAC;QAC1C,kCAAkC;QAClC,aAAa,CAAC,aAAa,EAAE,CAAA;QAC7B,OAAO,aAAa,CAAC,WAAW,CAAC;YAC/B,UAAU;YACV,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,aAAa,CAAC,WAAW,CAAC;QAC/B,UAAU;QACV,kBAAkB,EAAE,IAAI;KACzB,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firela/billclaw-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "BillClaw CLI - Standalone command-line interface for financial data management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,16 +23,6 @@
|
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
|
-
"scripts": {
|
|
27
|
-
"build": "tsc",
|
|
28
|
-
"dev": "tsc --watch",
|
|
29
|
-
"test": "vitest",
|
|
30
|
-
"test:coverage": "vitest --coverage",
|
|
31
|
-
"lint": "oxlint",
|
|
32
|
-
"format": "oxfmt src/",
|
|
33
|
-
"format:write": "oxfmt -w src/",
|
|
34
|
-
"clean": "rm -rf dist"
|
|
35
|
-
},
|
|
36
26
|
"keywords": [
|
|
37
27
|
"billclaw",
|
|
38
28
|
"cli",
|
|
@@ -59,14 +49,24 @@
|
|
|
59
49
|
"vitest": "^3.0.0"
|
|
60
50
|
},
|
|
61
51
|
"dependencies": {
|
|
62
|
-
"@firela/billclaw-core": "^0.1.5",
|
|
63
52
|
"chalk": "^5.4.0",
|
|
64
53
|
"cli-table3": "^0.6.5",
|
|
65
54
|
"commander": "^13.1.0",
|
|
66
55
|
"inquirer": "^12.0.0",
|
|
67
|
-
"ora": "^8.1.0"
|
|
56
|
+
"ora": "^8.1.0",
|
|
57
|
+
"@firela/billclaw-core": "0.2.0"
|
|
68
58
|
},
|
|
69
59
|
"engines": {
|
|
70
60
|
"node": ">=20.0.0"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "tsc",
|
|
64
|
+
"dev": "tsc --watch",
|
|
65
|
+
"test": "vitest",
|
|
66
|
+
"test:coverage": "vitest --coverage",
|
|
67
|
+
"lint": "oxlint",
|
|
68
|
+
"format": "oxfmt src/",
|
|
69
|
+
"format:write": "oxfmt -w src/",
|
|
70
|
+
"clean": "rm -rf dist"
|
|
71
71
|
}
|
|
72
|
-
}
|
|
72
|
+
}
|