cursor-switch 1.0.2 → 1.0.3
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.
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 3. 智能包管理器探测 (自动适配 npm / pnpm / yarn / bun)
|
|
7
7
|
* 4. 零第三方依赖,纯 Node.js 原生轻量实现
|
|
8
8
|
*/
|
|
9
|
-
export declare const CURRENT_VERSION
|
|
9
|
+
export declare const CURRENT_VERSION: string;
|
|
10
10
|
export declare const PACKAGE_NAME = "cursor-switch";
|
|
11
11
|
export interface VersionCheckResult {
|
|
12
12
|
currentVersion: string;
|
|
@@ -6,10 +6,26 @@
|
|
|
6
6
|
* 3. 智能包管理器探测 (自动适配 npm / pnpm / yarn / bun)
|
|
7
7
|
* 4. 零第三方依赖,纯 Node.js 原生轻量实现
|
|
8
8
|
*/
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
9
12
|
import { spawn } from 'node:child_process';
|
|
10
13
|
import chalk from 'chalk';
|
|
11
14
|
import { ConfigStore } from './config-store.js';
|
|
12
|
-
|
|
15
|
+
function getPackageVersion() {
|
|
16
|
+
try {
|
|
17
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
const pkgPath = path.resolve(currentDir, '..', '..', 'package.json');
|
|
19
|
+
if (fs.existsSync(pkgPath)) {
|
|
20
|
+
const data = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
21
|
+
if (data?.version)
|
|
22
|
+
return data.version;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch { }
|
|
26
|
+
return '1.0.2';
|
|
27
|
+
}
|
|
28
|
+
export const CURRENT_VERSION = getPackageVersion();
|
|
13
29
|
export const PACKAGE_NAME = 'cursor-switch';
|
|
14
30
|
const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000; // 24 小时检查周期
|
|
15
31
|
/**
|