mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-21 15:36:50 -05:00
* [AI] Publish loot-core (@actual-app/core) nightly first in workflow * [autofix.ci] apply automated fixes * Refactor imports and update configuration - Updated .oxfmtrc.json to change "parent" to ["parent", "subpath"]. - Removed unnecessary blank lines in various TypeScript files to improve code readability. - Adjusted import order in reports and rules files for consistency. * Add workflow steps to pack and publish the core package nightly * Remove nightly tag from npm publish command in workflow for core package * Update post-build script comment to reflect correct workspace command for loot-core declarations --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import type {
|
|
RequestInfo as FetchInfo,
|
|
RequestInit as FetchInit,
|
|
} from 'node-fetch';
|
|
|
|
import { init as initLootCore } from '@actual-app/core/server/main';
|
|
import type { InitConfig, lib } from '@actual-app/core/server/main';
|
|
|
|
import { validateNodeVersion } from './validateNodeVersion';
|
|
|
|
export * from './methods';
|
|
export * as utils from './utils';
|
|
|
|
/** @deprecated Please use return value of `init` instead */
|
|
export let internal: typeof lib | null = null;
|
|
|
|
export async function init(config: InitConfig = {}) {
|
|
validateNodeVersion();
|
|
|
|
if (!globalThis.fetch) {
|
|
globalThis.fetch = (url: URL | RequestInfo, init?: RequestInit) => {
|
|
return import('node-fetch').then(({ default: fetch }) =>
|
|
fetch(url as unknown as FetchInfo, init as unknown as FetchInit),
|
|
) as unknown as Promise<Response>;
|
|
};
|
|
}
|
|
|
|
internal = await initLootCore(config);
|
|
return internal;
|
|
}
|
|
|
|
export async function shutdown() {
|
|
if (internal) {
|
|
try {
|
|
await internal.send('sync');
|
|
} catch {
|
|
// most likely that no budget is loaded, so the sync failed
|
|
}
|
|
|
|
await internal.send('close-budget');
|
|
internal = null;
|
|
}
|
|
}
|