@cloudbase/toolbox 0.7.13 → 0.7.14

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.
Files changed (2) hide show
  1. package/lib/system/os.js +46 -9
  2. package/package.json +1 -1
package/lib/system/os.js CHANGED
@@ -6,6 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getOSInfo = exports.getPlatformRelease = void 0;
7
7
  const os_1 = __importDefault(require("os"));
8
8
  const macOSMap = new Map([
9
+ [24, 'Sequoia'],
10
+ [23, 'Sonoma'],
11
+ [22, 'Ventura'],
12
+ [21, 'Monterey'],
9
13
  [20, 'BigSur'],
10
14
  [19, 'Catalina'],
11
15
  [18, 'Mojave'],
@@ -21,9 +25,19 @@ const macOSMap = new Map([
21
25
  [8, 'Tiger'],
22
26
  [7, 'Panther'],
23
27
  [6, 'Jaguar'],
24
- [5, 'Puma']
28
+ [5, 'Puma'] // macOS 10.1 Puma (2001)
25
29
  ]);
26
30
  const winMap = new Map([
31
+ ['10.0.22000', '11'],
32
+ ['10.0.19041', '10'],
33
+ ['10.0.18363', '10'],
34
+ ['10.0.17763', '10'],
35
+ ['10.0.17134', '10'],
36
+ ['10.0.16299', '10'],
37
+ ['10.0.15063', '10'],
38
+ ['10.0.14393', '10'],
39
+ ['10.0.10586', '10'],
40
+ ['10.0.10240', '10'],
27
41
  ['10.0', '10'],
28
42
  ['6.3', '8.1'],
29
43
  ['6.2', '8'],
@@ -34,26 +48,49 @@ const winMap = new Map([
34
48
  ['5.0', '2000'],
35
49
  ['4.9', 'ME'],
36
50
  ['4.1', '98'],
37
- ['4.0', '95']
51
+ ['4.0', '95'] // Windows 95 (1995)
38
52
  ]);
39
53
  function getPlatformRelease(platform, release) {
40
54
  // macOS
41
55
  if (platform === 'darwin') {
42
- const releaseNum = Number(release.split('.')[0]);
43
- const name = macOSMap.get(releaseNum);
56
+ const releaseParts = release.split('.');
57
+ const majorNum = Number(releaseParts[0]);
58
+ const minorNum = Number(releaseParts[1]) || 0;
59
+ const name = macOSMap.get(majorNum);
44
60
  let version;
45
- if (releaseNum >= 20) {
46
- version = '11.' + (releaseNum - 20);
61
+ // macOS 11 及以上版本 (majorNum >= 20)
62
+ if (majorNum >= 20) {
63
+ // releaseNum 20 -> macOS 11, 21 -> macOS 12, etc.
64
+ const majorVersion = majorNum - 9;
65
+ version = `${majorVersion}.${minorNum}`;
66
+ // macOS 10.x 版本 (majorNum < 20)
47
67
  }
48
68
  else {
49
- version = '10.' + (releaseNum - 4);
69
+ // releaseNum 19 -> 10.15, 18 -> 10.14, etc.
70
+ const minorVersion = majorNum - 4;
71
+ version = `10.${minorVersion}`;
50
72
  }
51
73
  return `${name} ${version}`;
52
74
  }
53
75
  // windows
54
76
  if (platform === 'win32') {
55
- const version = (/\d+\.\d/.exec(release) || [])[0];
56
- return `Windows ${winMap.get(version)}`;
77
+ // 尝试精确匹配完整版本号
78
+ let windowsVersion = winMap.get(release);
79
+ if (!windowsVersion) {
80
+ // 如果没有精确匹配,尝试匹配主版本号
81
+ const majorVersion = (/^\d+\.\d+/.exec(release) || [])[0];
82
+ windowsVersion = winMap.get(majorVersion);
83
+ }
84
+ if (!windowsVersion) {
85
+ // 如果还是没有匹配,尝试只匹配第一部分
86
+ const firstPart = (/^\d+/.exec(release) || [])[0];
87
+ if (firstPart === '10') {
88
+ windowsVersion = '10';
89
+ }
90
+ }
91
+ // 显示完整的版本信息
92
+ const versionDisplay = windowsVersion || release;
93
+ return `Windows ${versionDisplay}`;
57
94
  }
58
95
  // 其他 Linux
59
96
  return 'Linux';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/toolbox",
3
- "version": "0.7.13",
3
+ "version": "0.7.14",
4
4
  "description": "The toolbox for cloudbase",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {