recker 1.0.37 → 1.0.39-next.a1fa57f

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.
@@ -1,6 +1,7 @@
1
1
  import { ClientOptions, Middleware, ReckerRequest, ReckerResponse, RequestOptions, CacheStorage, PageResult } from '../types/index.js';
2
2
  import type { ClientAI, ClientOptionsWithAI } from '../types/ai-client.js';
3
3
  import { RequestPromise } from './request-promise.js';
4
+ import { type VersionInfo } from '../version.js';
4
5
  import { PaginationOptions } from '../plugins/pagination.js';
5
6
  import { RetryOptions } from '../plugins/retry.js';
6
7
  import { CacheOptions } from '../plugins/cache.js';
@@ -20,6 +21,9 @@ export interface ExtendedClientOptions extends ClientOptions {
20
21
  dedup?: DedupOptions;
21
22
  }
22
23
  export declare class Client {
24
+ static get version(): string;
25
+ static getVersion(): Promise<string>;
26
+ static getVersionInfo(): Promise<VersionInfo>;
23
27
  private baseUrl;
24
28
  private middlewares;
25
29
  private hooks;
@@ -9,6 +9,7 @@ import { AgentManager } from '../utils/agent-manager.js';
9
9
  import { RequestPool } from '../utils/request-pool.js';
10
10
  import { normalizeConcurrency } from '../utils/concurrency.js';
11
11
  import { getDefaultUserAgent } from '../utils/user-agent.js';
12
+ import { getVersion, getVersionSync, getVersionInfo } from '../version.js';
12
13
  import { paginate, streamPages } from '../plugins/pagination.js';
13
14
  import { retryPlugin } from '../plugins/retry.js';
14
15
  import { cachePlugin } from '../plugins/cache.js';
@@ -27,6 +28,15 @@ import { MemoryCookieJar } from '../cookies/memory-cookie-jar.js';
27
28
  import { scrape as scrapeHelper } from '../plugins/scrape.js';
28
29
  import { HlsPromise } from '../plugins/hls.js';
29
30
  export class Client {
31
+ static get version() {
32
+ return getVersionSync();
33
+ }
34
+ static getVersion() {
35
+ return getVersion();
36
+ }
37
+ static getVersionInfo() {
38
+ return getVersionInfo();
39
+ }
30
40
  baseUrl;
31
41
  middlewares;
32
42
  hooks;
@@ -0,0 +1,11 @@
1
+ export declare function getVersion(): Promise<string>;
2
+ export declare function getVersionSync(): string;
3
+ export interface VersionInfo {
4
+ version: string;
5
+ name: string;
6
+ nodeVersion: string;
7
+ platform: string;
8
+ arch: string;
9
+ }
10
+ export declare function getVersionInfo(): Promise<VersionInfo>;
11
+ export declare function formatVersionInfo(verbose?: boolean): Promise<string>;
@@ -0,0 +1,46 @@
1
+ const VERSION = '__INJECT_VERSION__';
2
+ let _version = null;
3
+ export async function getVersion() {
4
+ if (_version)
5
+ return _version;
6
+ if (VERSION !== '__INJECT_VERSION__') {
7
+ _version = VERSION;
8
+ return _version;
9
+ }
10
+ try {
11
+ const pkg = await import('../package.json', { with: { type: 'json' } });
12
+ _version = pkg.default?.version || '0.0.0-dev';
13
+ }
14
+ catch {
15
+ _version = '0.0.0-dev';
16
+ }
17
+ return _version;
18
+ }
19
+ export function getVersionSync() {
20
+ if (_version)
21
+ return _version;
22
+ if (VERSION !== '__INJECT_VERSION__')
23
+ return VERSION;
24
+ return '0.0.0-dev';
25
+ }
26
+ export async function getVersionInfo() {
27
+ const version = await getVersion();
28
+ return {
29
+ version,
30
+ name: 'recker',
31
+ nodeVersion: process.version,
32
+ platform: process.platform,
33
+ arch: process.arch,
34
+ };
35
+ }
36
+ export async function formatVersionInfo(verbose = false) {
37
+ const info = await getVersionInfo();
38
+ if (verbose) {
39
+ return [
40
+ `recker/${info.version}`,
41
+ `node/${info.nodeVersion.replace('v', '')}`,
42
+ `${info.platform}/${info.arch}`,
43
+ ].join(' ');
44
+ }
45
+ return info.version;
46
+ }
@@ -1,6 +1,6 @@
1
1
  import { classifyError as classifyErrorCore, ClassifiedError } from '../core/error-handler.js';
2
2
  export { classifyErrorCore as classifyError };
3
- import colors from 'picocolors';
3
+ import colors from '../utils/colors.js';
4
4
  export { colors };
5
5
  export declare function formatCliError(error: Error | string | unknown, context?: Record<string, unknown>): string;
6
6
  export declare function printError(error: Error | string | unknown, context?: Record<string, unknown>): void;
@@ -1,6 +1,6 @@
1
1
  import { classifyError as classifyErrorCore, formatErrorForTerminal, } from '../core/error-handler.js';
2
2
  export { classifyErrorCore as classifyError };
3
- import colors from 'picocolors';
3
+ import colors from '../utils/colors.js';
4
4
  export { colors };
5
5
  export function formatCliError(error, context) {
6
6
  const classified = classifyErrorCore(error, context);