Fix JSON output corruption from API log noise
- Redirect console.log to stderr before importing @actual-app/api so breadcrumb/sync messages don't mix with JSON output - Use groupId (not cloudFileId) for downloadBudget sync ID - Fix setup.sh to display and select groupId
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Redirect console.log to stderr so API noise doesn't corrupt JSON output
|
||||
const _origLog = console.log;
|
||||
console.log = (...args) => console.error(...args);
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as api from '@actual-app/api';
|
||||
|
||||
// Restore console.log only for our own output function
|
||||
function output(data) {
|
||||
_origLog(JSON.stringify(data, null, 2));
|
||||
}
|
||||
|
||||
const CONFIG_DIR = path.join(process.env.HOME, '.config', 'actual-budget');
|
||||
const CONFIG_FILE = path.join(CONFIG_DIR, 'config');
|
||||
const PASSWORD_FILE = path.join(CONFIG_DIR, 'password');
|
||||
@@ -53,10 +62,6 @@ async function initialize(config) {
|
||||
await api.downloadBudget(config.ACTUAL_SYNC_ID);
|
||||
}
|
||||
|
||||
function output(data) {
|
||||
console.log(JSON.stringify(data, null, 2));
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const [command, ...args] = process.argv.slice(2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user