bkper 4.3.0 → 4.4.1
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/lib/cli.js +10 -0
- package/lib/cli.js.map +1 -1
- package/lib/commands/accounts/list.js +1 -1
- package/lib/commands/accounts/list.js.map +1 -1
- package/lib/commands/groups/list.d.ts +3 -0
- package/lib/commands/groups/list.d.ts.map +1 -1
- package/lib/commands/groups/list.js +4 -1
- package/lib/commands/groups/list.js.map +1 -1
- package/lib/commands/transactions/list.d.ts +5 -0
- package/lib/commands/transactions/list.d.ts.map +1 -1
- package/lib/commands/transactions/list.js +6 -1
- package/lib/commands/transactions/list.js.map +1 -1
- package/lib/commands/upgrade.d.ts +3 -0
- package/lib/commands/upgrade.d.ts.map +1 -0
- package/lib/commands/upgrade.js +20 -0
- package/lib/commands/upgrade.js.map +1 -0
- package/lib/upgrade/index.d.ts +5 -0
- package/lib/upgrade/index.d.ts.map +1 -0
- package/lib/upgrade/index.js +4 -0
- package/lib/upgrade/index.js.map +1 -0
- package/lib/upgrade/installation.d.ts +24 -0
- package/lib/upgrade/installation.d.ts.map +1 -0
- package/lib/upgrade/installation.js +90 -0
- package/lib/upgrade/installation.js.map +1 -0
- package/lib/upgrade/upgrade.d.ts +23 -0
- package/lib/upgrade/upgrade.d.ts.map +1 -0
- package/lib/upgrade/upgrade.js +99 -0
- package/lib/upgrade/upgrade.js.map +1 -0
- package/package.json +2 -2
package/lib/cli.js
CHANGED
|
@@ -18,6 +18,10 @@ import { registerGroupCommands } from './commands/groups/register.js';
|
|
|
18
18
|
import { registerTransactionCommands } from './commands/transactions/register.js';
|
|
19
19
|
import { registerBalanceCommands } from './commands/balances/register.js';
|
|
20
20
|
import { registerCollectionCommands } from './commands/collections/register.js';
|
|
21
|
+
import { registerUpgradeCommand } from './commands/upgrade.js';
|
|
22
|
+
import { VERSION, autoUpgrade } from './upgrade/index.js';
|
|
23
|
+
// Version
|
|
24
|
+
program.version(VERSION, '-v, --version');
|
|
21
25
|
// Global output format options
|
|
22
26
|
program.option('--format <format>', 'Output format: table, json, or csv', 'table');
|
|
23
27
|
program.option('--json', 'Output as JSON (alias for --format json)');
|
|
@@ -42,5 +46,11 @@ registerGroupCommands(program);
|
|
|
42
46
|
registerTransactionCommands(program);
|
|
43
47
|
registerBalanceCommands(program);
|
|
44
48
|
registerCollectionCommands(program);
|
|
49
|
+
// Upgrade command
|
|
50
|
+
registerUpgradeCommand(program);
|
|
51
|
+
// Trigger silent auto-upgrade in the background (non-blocking, never fails)
|
|
52
|
+
if (!process.env.BKPER_DISABLE_AUTOUPDATE) {
|
|
53
|
+
autoUpgrade().catch(() => { });
|
|
54
|
+
}
|
|
45
55
|
program.parse(process.argv);
|
|
46
56
|
//# sourceMappingURL=cli.js.map
|
package/lib/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;AAEA,OAAO,eAAe,CAAC,CAAC,sDAAsD;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;AAEA,O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AC,CAAC;AAC7B,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC9B,uBAAuB,CAAC,OAAO,CAAC,CAAC;AACjC,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAC/B,2BAA2B,CAAC,OAAO,CAAC,CAAC;AACrC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AACjC,0BAA0B,CAAC,OAAO,CAAC,CAAC;AAEpC,kBAAkB;AAClB,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAEhC,4EAA4E;AAC5E,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,CAAC;IACxC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -18,7 +18,7 @@ import { AccountsDataTableBuilder } from 'bkper-js';
|
|
|
18
18
|
export function listAccounts(bookId) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
const bkper = getBkperInstance();
|
|
21
|
-
const book = yield bkper.getBook(bookId);
|
|
21
|
+
const book = yield bkper.getBook(bookId, true, true);
|
|
22
22
|
const accounts = yield book.getAccounts();
|
|
23
23
|
return accounts || [];
|
|
24
24
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/accounts/list.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAW,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAG7D;;;;;GAKG;AACH,MAAM,UAAgB,YAAY,CAAC,MAAc;;QAC7C,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"list.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 @@ import type { OutputFormat, ListResult } from '../../render/output.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves all groups from the specified book.
|
|
5
5
|
*
|
|
6
|
+
* Fetches the book with groups pre-loaded in a single API call,
|
|
7
|
+
* so that subsequent operations work from the in-memory cache.
|
|
8
|
+
*
|
|
6
9
|
* @param bookId - The ID of the book to list groups from
|
|
7
10
|
* @returns Array of groups in the book, or an empty array if none exist
|
|
8
11
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/groups/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAA0B,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEvE
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/groups/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAA0B,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEvE;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAKjE;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACrC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,GACrB,OAAO,CAAC,UAAU,CAAC,CAarB"}
|
|
@@ -12,13 +12,16 @@ import { GroupsDataTableBuilder } from 'bkper-js';
|
|
|
12
12
|
/**
|
|
13
13
|
* Retrieves all groups from the specified book.
|
|
14
14
|
*
|
|
15
|
+
* Fetches the book with groups pre-loaded in a single API call,
|
|
16
|
+
* so that subsequent operations work from the in-memory cache.
|
|
17
|
+
*
|
|
15
18
|
* @param bookId - The ID of the book to list groups from
|
|
16
19
|
* @returns Array of groups in the book, or an empty array if none exist
|
|
17
20
|
*/
|
|
18
21
|
export function listGroups(bookId) {
|
|
19
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
23
|
const bkper = getBkperInstance();
|
|
21
|
-
const book = yield bkper.getBook(bookId);
|
|
24
|
+
const book = yield bkper.getBook(bookId, false, true);
|
|
22
25
|
const groups = yield book.getGroups();
|
|
23
26
|
return groups || [];
|
|
24
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/groups/list.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAS,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGzD
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/groups/list.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAS,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGzD;;;;;;;;GAQG;AACH,MAAM,UAAgB,UAAU,CAAC,MAAc;;QAC3C,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,OAAO,MAAM,IAAI,EAAE,CAAC;IACxB,CAAC;CAAA;AAED;;;GAGG;AACH,MAAM,UAAgB,mBAAmB,CACrC,MAAc,EACd,MAAoB;;QAEpB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;QAExC,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACpB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAC7D,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxE,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;YACnB,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;QAC/B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACtC,CAAC;CAAA"}
|
|
@@ -21,6 +21,11 @@ export interface ListTransactionsResult {
|
|
|
21
21
|
/**
|
|
22
22
|
* Queries transactions from a book using the provided search options.
|
|
23
23
|
*
|
|
24
|
+
* Fetches the book with accounts pre-loaded in a single API call, so that
|
|
25
|
+
* account name resolution during table building (getCreditAccountName,
|
|
26
|
+
* getDebitAccountName) resolves from the in-memory cache instead of making
|
|
27
|
+
* individual API calls per transaction.
|
|
28
|
+
*
|
|
24
29
|
* @param bookId - The book ID to query
|
|
25
30
|
* @param options - Query parameters including search string, limit, and cursor
|
|
26
31
|
* @returns The matching transactions with book context and pagination cursor
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/transactions/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,GACjC,OAAO,CAAC,sBAAsB,CAAC,CAYjC;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC3C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,YAAY,GACrB,OAAO,CAAC,UAAU,CAAC,CA2BrB"}
|
|
@@ -11,6 +11,11 @@ import { getBkperInstance } from '../../bkper-factory.js';
|
|
|
11
11
|
/**
|
|
12
12
|
* Queries transactions from a book using the provided search options.
|
|
13
13
|
*
|
|
14
|
+
* Fetches the book with accounts pre-loaded in a single API call, so that
|
|
15
|
+
* account name resolution during table building (getCreditAccountName,
|
|
16
|
+
* getDebitAccountName) resolves from the in-memory cache instead of making
|
|
17
|
+
* individual API calls per transaction.
|
|
18
|
+
*
|
|
14
19
|
* @param bookId - The book ID to query
|
|
15
20
|
* @param options - Query parameters including search string, limit, and cursor
|
|
16
21
|
* @returns The matching transactions with book context and pagination cursor
|
|
@@ -18,7 +23,7 @@ import { getBkperInstance } from '../../bkper-factory.js';
|
|
|
18
23
|
export function listTransactions(bookId, options) {
|
|
19
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
25
|
const bkper = getBkperInstance();
|
|
21
|
-
const book = yield bkper.getBook(bookId);
|
|
26
|
+
const book = yield bkper.getBook(bookId, true);
|
|
22
27
|
const result = yield book.listTransactions(options.query, options.limit, options.cursor);
|
|
23
28
|
const items = result.getItems();
|
|
24
29
|
const account = yield result.getAccount();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/transactions/list.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAwB1D
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/transactions/list.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAwB1D;;;;;;;;;;;GAWG;AACH,MAAM,UAAgB,gBAAgB,CAClC,MAAc,EACd,OAAgC;;QAEhC,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACzF,MAAM,KAAK,GAAG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;QACL,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC9C,CAAC;CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAQ7D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { foregroundUpgrade } from '../upgrade/index.js';
|
|
11
|
+
export function registerUpgradeCommand(program) {
|
|
12
|
+
program
|
|
13
|
+
.command('upgrade [version]')
|
|
14
|
+
.description('Upgrade bkper CLI to the latest version')
|
|
15
|
+
.option('--method <method>', 'Override install method detection (npm, bun, yarn)')
|
|
16
|
+
.action((version, options) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
yield foregroundUpgrade(version, options.method);
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=upgrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACnD,OAAO;SACF,OAAO,CAAC,mBAAmB,CAAC;SAC5B,WAAW,CAAC,yCAAyC,CAAC;SACtD,MAAM,CAAC,mBAAmB,EAAE,oDAAoD,CAAC;SACjF,MAAM,CAAC,CAAO,OAA2B,EAAE,OAA4B,EAAE,EAAE;QACxE,MAAM,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC,CAAA,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { VERSION } from './installation.js';
|
|
2
|
+
export { autoUpgrade, foregroundUpgrade, isNewerVersion } from './upgrade.js';
|
|
3
|
+
export { detectMethod, fetchLatestVersion, getUpgradeCommand } from './installation.js';
|
|
4
|
+
export type { InstallMethod } from './installation.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upgrade/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxF,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/upgrade/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Current installed version of the CLI. */
|
|
2
|
+
export declare const VERSION: string;
|
|
3
|
+
/** Supported installation methods. */
|
|
4
|
+
export type InstallMethod = 'npm' | 'bun' | 'yarn' | 'unknown';
|
|
5
|
+
/**
|
|
6
|
+
* Detects how the CLI was installed by checking global package lists
|
|
7
|
+
* for each supported package manager.
|
|
8
|
+
*/
|
|
9
|
+
export declare function detectMethod(): InstallMethod;
|
|
10
|
+
/**
|
|
11
|
+
* Fetches the latest published version from the npm registry.
|
|
12
|
+
* Returns null if the fetch fails.
|
|
13
|
+
*/
|
|
14
|
+
export declare function fetchLatestVersion(): Promise<string | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the shell command to upgrade the CLI for a given install method and version.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getUpgradeCommand(method: InstallMethod, version: string): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Executes the upgrade to the specified version using the given install method.
|
|
21
|
+
* Throws if the upgrade command fails.
|
|
22
|
+
*/
|
|
23
|
+
export declare function executeUpgrade(method: InstallMethod, version: string): void;
|
|
24
|
+
//# sourceMappingURL=installation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installation.d.ts","sourceRoot":"","sources":["../../src/upgrade/installation.ts"],"names":[],"mappings":"AAMA,4CAA4C;AAC5C,eAAO,MAAM,OAAO,EAAE,MAAoB,CAAC;AAK3C,sCAAsC;AACtC,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,YAAY,IAAI,aAAa,CAmB5C;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAYjE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWvF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAS3E"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { execSync } from 'child_process';
|
|
11
|
+
import { createRequire } from 'module';
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const pkg = require('../../package.json');
|
|
14
|
+
/** Current installed version of the CLI. */
|
|
15
|
+
export const VERSION = pkg.version;
|
|
16
|
+
/** Package name on npm. */
|
|
17
|
+
const PACKAGE_NAME = 'bkper';
|
|
18
|
+
/**
|
|
19
|
+
* Detects how the CLI was installed by checking global package lists
|
|
20
|
+
* for each supported package manager.
|
|
21
|
+
*/
|
|
22
|
+
export function detectMethod() {
|
|
23
|
+
const checks = [
|
|
24
|
+
{ method: 'bun', command: `bun pm ls -g 2>/dev/null` },
|
|
25
|
+
{ method: 'npm', command: `npm list -g ${PACKAGE_NAME} --depth=0 2>/dev/null` },
|
|
26
|
+
{ method: 'yarn', command: `yarn global list --depth=0 2>/dev/null` },
|
|
27
|
+
];
|
|
28
|
+
for (const { method, command } of checks) {
|
|
29
|
+
try {
|
|
30
|
+
const output = execSync(command, { encoding: 'utf-8', timeout: 10000 });
|
|
31
|
+
if (output.includes(PACKAGE_NAME)) {
|
|
32
|
+
return method;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (_a) {
|
|
36
|
+
// Package manager not available or command failed — try next
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return 'unknown';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Fetches the latest published version from the npm registry.
|
|
43
|
+
* Returns null if the fetch fails.
|
|
44
|
+
*/
|
|
45
|
+
export function fetchLatestVersion() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
var _a;
|
|
48
|
+
try {
|
|
49
|
+
const response = yield fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, {
|
|
50
|
+
headers: { Accept: 'application/json' },
|
|
51
|
+
signal: AbortSignal.timeout(5000),
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok)
|
|
54
|
+
return null;
|
|
55
|
+
const data = (yield response.json());
|
|
56
|
+
return (_a = data.version) !== null && _a !== void 0 ? _a : null;
|
|
57
|
+
}
|
|
58
|
+
catch (_b) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns the shell command to upgrade the CLI for a given install method and version.
|
|
65
|
+
*/
|
|
66
|
+
export function getUpgradeCommand(method, version) {
|
|
67
|
+
switch (method) {
|
|
68
|
+
case 'npm':
|
|
69
|
+
return `npm install -g ${PACKAGE_NAME}@${version}`;
|
|
70
|
+
case 'bun':
|
|
71
|
+
return `bun add -g ${PACKAGE_NAME}@${version}`;
|
|
72
|
+
case 'yarn':
|
|
73
|
+
return `yarn global add ${PACKAGE_NAME}@${version}`;
|
|
74
|
+
default:
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Executes the upgrade to the specified version using the given install method.
|
|
80
|
+
* Throws if the upgrade command fails.
|
|
81
|
+
*/
|
|
82
|
+
export function executeUpgrade(method, version) {
|
|
83
|
+
const command = getUpgradeCommand(method, version);
|
|
84
|
+
if (!command) {
|
|
85
|
+
throw new Error(`Unable to auto-upgrade: unknown installation method. ` +
|
|
86
|
+
`Please upgrade manually: npm install -g ${PACKAGE_NAME}@${version}`);
|
|
87
|
+
}
|
|
88
|
+
execSync(command, { stdio: 'pipe', timeout: 60000 });
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=installation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installation.js","sourceRoot":"","sources":["../../src/upgrade/installation.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAE1C,4CAA4C;AAC5C,MAAM,CAAC,MAAM,OAAO,GAAW,GAAG,CAAC,OAAO,CAAC;AAE3C,2BAA2B;AAC3B,MAAM,YAAY,GAAG,OAAO,CAAC;AAK7B;;;GAGG;AACH,MAAM,UAAU,YAAY;IACxB,MAAM,MAAM,GAAsD;QAC9D,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,0BAA0B,EAAE;QACtD,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,YAAY,wBAAwB,EAAE;QAC/E,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EA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,IAAI,OAAO,EAAE,CAAC;QACxD;YACI,OAAO,IAAI,CAAC;IACpB,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAqB,EAAE,OAAe;IACjE,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnD,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACX,uDAAuD;YACnD,2CAA2C,YAAY,IAAI,OAAO,EAAE,CAC3E,CAAC;IACN,CAAC;IACD,QAAQ,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two semver version strings.
|
|
3
|
+
* Returns true if `latest` is newer than `current`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isNewerVersion(current: string, latest: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Runs the silent auto-upgrade check in the background.
|
|
8
|
+
*
|
|
9
|
+
* Called on every CLI invocation. This function:
|
|
10
|
+
* 1. Fetches the latest version from npm
|
|
11
|
+
* 2. Compares with the current installed version
|
|
12
|
+
* 3. If newer, silently upgrades using the detected install method
|
|
13
|
+
* 4. Prints a brief message to stderr on success
|
|
14
|
+
*
|
|
15
|
+
* All errors are swallowed silently to never disrupt the user's command.
|
|
16
|
+
*/
|
|
17
|
+
export declare function autoUpgrade(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Runs an explicit foreground upgrade with user-facing output.
|
|
20
|
+
* Used by the `bkper upgrade` command.
|
|
21
|
+
*/
|
|
22
|
+
export declare function foregroundUpgrade(targetVersion?: string, methodOverride?: string): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=upgrade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/upgrade/upgrade.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAQvE;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAsBjD;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACnC,aAAa,CAAC,EAAE,MAAM,EACtB,cAAc,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,IAAI,CAAC,CAsCf"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { VERSION, fetchLatestVersion, detectMethod, executeUpgrade, getUpgradeCommand, } from './installation.js';
|
|
11
|
+
/**
|
|
12
|
+
* Compares two semver version strings.
|
|
13
|
+
* Returns true if `latest` is newer than `current`.
|
|
14
|
+
*/
|
|
15
|
+
export function isNewerVersion(current, latest) {
|
|
16
|
+
const parse = (v) => v.split('.').map(Number);
|
|
17
|
+
const [cMajor, cMinor, cPatch] = parse(current);
|
|
18
|
+
const [lMajor, lMinor, lPatch] = parse(latest);
|
|
19
|
+
if (lMajor !== cMajor)
|
|
20
|
+
return lMajor > cMajor;
|
|
21
|
+
if (lMinor !== cMinor)
|
|
22
|
+
return lMinor > cMinor;
|
|
23
|
+
return lPatch > cPatch;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Runs the silent auto-upgrade check in the background.
|
|
27
|
+
*
|
|
28
|
+
* Called on every CLI invocation. This function:
|
|
29
|
+
* 1. Fetches the latest version from npm
|
|
30
|
+
* 2. Compares with the current installed version
|
|
31
|
+
* 3. If newer, silently upgrades using the detected install method
|
|
32
|
+
* 4. Prints a brief message to stderr on success
|
|
33
|
+
*
|
|
34
|
+
* All errors are swallowed silently to never disrupt the user's command.
|
|
35
|
+
*/
|
|
36
|
+
export function autoUpgrade() {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
try {
|
|
39
|
+
const latest = yield fetchLatestVersion();
|
|
40
|
+
if (!latest)
|
|
41
|
+
return;
|
|
42
|
+
if (!isNewerVersion(VERSION, latest))
|
|
43
|
+
return;
|
|
44
|
+
const method = detectMethod();
|
|
45
|
+
if (method === 'unknown') {
|
|
46
|
+
// Can't auto-upgrade if we don't know how it was installed.
|
|
47
|
+
// Print a hint to stderr so it doesn't pollute stdout.
|
|
48
|
+
process.stderr.write(`\nbkper ${latest} available (current: ${VERSION}). ` +
|
|
49
|
+
`Upgrade manually: npm install -g bkper@${latest}\n`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
executeUpgrade(method, latest);
|
|
53
|
+
process.stderr.write(`\nbkper upgraded: ${VERSION} \u2192 ${latest} (restart to use)\n`);
|
|
54
|
+
}
|
|
55
|
+
catch (_a) {
|
|
56
|
+
// Silent failure — never break the user's command
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Runs an explicit foreground upgrade with user-facing output.
|
|
62
|
+
* Used by the `bkper upgrade` command.
|
|
63
|
+
*/
|
|
64
|
+
export function foregroundUpgrade(targetVersion, methodOverride) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const latest = targetVersion !== null && targetVersion !== void 0 ? targetVersion : (yield fetchLatestVersion());
|
|
67
|
+
if (!latest) {
|
|
68
|
+
console.error('Could not determine the latest version. Check your network connection.');
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
if (!isNewerVersion(VERSION, latest) && !targetVersion) {
|
|
72
|
+
console.log(`Already on the latest version (${VERSION}).`);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const method = methodOverride && isValidMethod(methodOverride) ? methodOverride : detectMethod();
|
|
76
|
+
if (method === 'unknown') {
|
|
77
|
+
console.error(`Could not detect how bkper was installed.\n` +
|
|
78
|
+
`Please upgrade manually: npm install -g bkper@${latest}\n` +
|
|
79
|
+
`Or specify the method: bkper upgrade --method npm`);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
const command = getUpgradeCommand(method, latest);
|
|
83
|
+
console.log(`Upgrading bkper: ${VERSION} \u2192 ${latest}`);
|
|
84
|
+
console.log(`Running: ${command}`);
|
|
85
|
+
try {
|
|
86
|
+
executeUpgrade(method, latest);
|
|
87
|
+
console.log(`Successfully upgraded to bkper@${latest}. Restart your terminal to use the new version.`);
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
console.error(`Upgrade failed:`, err);
|
|
91
|
+
console.error(`\nTry upgrading manually: ${command}`);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function isValidMethod(method) {
|
|
97
|
+
return ['npm', 'bun', 'yarn'].includes(method);
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=upgrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../src/upgrade/upgrade.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACH,OAAO,EACP,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,iBAAiB,GACpB,MAAM,mBAAmB,CAAC;AAG3B;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,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AAC,6BAA6B,OAAO,EAAE,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACL,CAAC;CAAA;AAED,SAAS,aAAa,CAAC,MAAc;IACjC,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACnD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.1",
|
|
4
4
|
"description": "Command line client for Bkper",
|
|
5
5
|
"bin": {
|
|
6
6
|
"bkper": "./lib/cli.js"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"bkper-js": "^2.29.
|
|
48
|
+
"bkper-js": "^2.29.1",
|
|
49
49
|
"chokidar": "^5.0.0",
|
|
50
50
|
"commander": "^13.1.0",
|
|
51
51
|
"dotenv": "^8.2.0",
|