@lazy-node/semver-ampersand 3.0.3 → 3.0.8
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/CHANGELOG.md +82 -0
- package/README.md +277 -4
- package/index.d.ts +33 -0
- package/index.js +33 -0
- package/index.js.map +1 -1
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,88 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.0.8](https://github.com/bluelovers/ws-yarn-workspaces/compare/@lazy-node/semver-ampersand@3.0.7...@lazy-node/semver-ampersand@3.0.8) (2026-03-09)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @lazy-node/semver-ampersand
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.0.7](https://github.com/bluelovers/ws-yarn-workspaces/compare/@lazy-node/semver-ampersand@3.0.4...@lazy-node/semver-ampersand@3.0.7) (2026-03-09)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### ♻️ Chores
|
|
19
|
+
|
|
20
|
+
* **deps:** 更新 ts-type 和 @ts-type/package-dts 依賴版本 ([eb3e3db](https://github.com/bluelovers/ws-yarn-workspaces/commit/eb3e3dbe330398235ea99e64f3561db73d95b7fc))
|
|
21
|
+
* **deps:** 更新 monorepo 依賴版本 ([e44dff2](https://github.com/bluelovers/ws-yarn-workspaces/commit/e44dff29d5d6b7eb7c77acb8414e73f70feff649))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### 🔖 Miscellaneous
|
|
25
|
+
|
|
26
|
+
* . ([385c013](https://github.com/bluelovers/ws-yarn-workspaces/commit/385c0135c0ed714ef3d1daf053a0072fc1433f47))
|
|
27
|
+
* . ([cae7515](https://github.com/bluelovers/ws-yarn-workspaces/commit/cae7515d4a8befe93ca0baee8f6aeb9ae7cbad79))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## [3.0.6](https://github.com/bluelovers/ws-yarn-workspaces/compare/@lazy-node/semver-ampersand@3.0.4...@lazy-node/semver-ampersand@3.0.6) (2026-03-09)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### ♻️ Chores
|
|
36
|
+
|
|
37
|
+
* **deps:** 更新 ts-type 和 @ts-type/package-dts 依賴版本 ([eb3e3db](https://github.com/bluelovers/ws-yarn-workspaces/commit/eb3e3dbe330398235ea99e64f3561db73d95b7fc))
|
|
38
|
+
* **deps:** 更新 monorepo 依賴版本 ([e44dff2](https://github.com/bluelovers/ws-yarn-workspaces/commit/e44dff29d5d6b7eb7c77acb8414e73f70feff649))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### 🔖 Miscellaneous
|
|
42
|
+
|
|
43
|
+
* . ([cae7515](https://github.com/bluelovers/ws-yarn-workspaces/commit/cae7515d4a8befe93ca0baee8f6aeb9ae7cbad79))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## [3.0.5](https://github.com/bluelovers/ws-yarn-workspaces/compare/@lazy-node/semver-ampersand@3.0.4...@lazy-node/semver-ampersand@3.0.5) (2026-03-08)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### ♻️ Chores
|
|
52
|
+
|
|
53
|
+
* **deps:** 更新 ts-type 和 @ts-type/package-dts 依賴版本 ([eb3e3db](https://github.com/bluelovers/ws-yarn-workspaces/commit/eb3e3dbe330398235ea99e64f3561db73d95b7fc))
|
|
54
|
+
* **deps:** 更新 monorepo 依賴版本 ([e44dff2](https://github.com/bluelovers/ws-yarn-workspaces/commit/e44dff29d5d6b7eb7c77acb8414e73f70feff649))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## [3.0.4](https://github.com/bluelovers/ws-yarn-workspaces/compare/@lazy-node/semver-ampersand@3.0.3...@lazy-node/semver-ampersand@3.0.4) (2026-03-02)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### 📚 Documentation
|
|
63
|
+
|
|
64
|
+
* **semver:** 新增 semver-* 套件完整文件與測試案例 ([a89a944](https://github.com/bluelovers/ws-yarn-workspaces/commit/a89a944880ce53ac0678351df4b6744a5feb0b08))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### 🚨 Tests
|
|
68
|
+
|
|
69
|
+
* 修正測試斷言並完善測試工具文檔 ([8abcb1f](https://github.com/bluelovers/ws-yarn-workspaces/commit/8abcb1f23b0e4fa99ae957bad13a09136ef3bad0))
|
|
70
|
+
* 改用快照測試驗證錯誤並簡化斷言語法 ([25a5c62](https://github.com/bluelovers/ws-yarn-workspaces/commit/25a5c627a1df5756cf78fb9312d8e47a9de2bd6c))
|
|
71
|
+
* **semver-ampersand:** 新增連字號範圍測試案例與測試規格 ([4614f01](https://github.com/bluelovers/ws-yarn-workspaces/commit/4614f011be611fe0f803883f18a6780d21498b56))
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
### 🛠 Build System
|
|
75
|
+
|
|
76
|
+
* Introduce new utility packages for semantic versioning and Yarn tooling, and add CI/CD workflows. ([905a979](https://github.com/bluelovers/ws-yarn-workspaces/commit/905a9795333addd0fe802cad8068d5c5b414a992))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### ♻️ Chores
|
|
80
|
+
|
|
81
|
+
* Add test config and global types for tsdx ([88a8df6](https://github.com/bluelovers/ws-yarn-workspaces/commit/88a8df6eef5dc59d9e0d9268b21706dceb5ab2a1))
|
|
82
|
+
* 更新 Jest 快照連結並增強類型定義與文件 ([b663b97](https://github.com/bluelovers/ws-yarn-workspaces/commit/b663b97d78d223dc8b3927ea2433938350144de7))
|
|
83
|
+
* add __root.ts test utility to workspace packages ([a771727](https://github.com/bluelovers/ws-yarn-workspaces/commit/a7717278883c86d9ed8ab89f42070d3385c173a7))
|
|
84
|
+
* **deps:** 升級多項依賴套件版本 ([1382602](https://github.com/bluelovers/ws-yarn-workspaces/commit/1382602ca94ff236b251fd1481b6332468de4621))
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
6
88
|
## [3.0.3](https://github.com/bluelovers/ws-yarn-workspaces/compare/@lazy-node/semver-ampersand@3.0.2...@lazy-node/semver-ampersand@3.0.3) (2025-09-07)
|
|
7
89
|
|
|
8
90
|
|
package/README.md
CHANGED
|
@@ -1,12 +1,285 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @lazy-node/semver-ampersand
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> 支援 ampersand (&) 語法的 semver 範圍處理工具庫 / Semver range handling utilities with ampersand (&) syntax support
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@lazy-node/semver-ampersand)
|
|
6
|
+
[](https://github.com/bluelovers/ws-yarn-workspaces/blob/master/packages/@lazy-node/semver-ampersand/LICENSE)
|
|
7
|
+
|
|
8
|
+
## 簡介 / Introduction
|
|
9
|
+
|
|
10
|
+
此模組擴展了標準 `semver` 套件的範圍處理功能,支援使用 `&` 符號來表示「且」的條件。這在處理 yarn 或 npm workspaces 的依賴版本時特別有用,因為某些情境下需要更明確的版本範圍表達方式。
|
|
11
|
+
|
|
12
|
+
This module extends the standard `semver` package's range handling with support for the `&` symbol to represent "AND" conditions. This is particularly useful when handling dependency versions in yarn or npm workspaces, where more explicit version range expressions are sometimes needed.
|
|
13
|
+
|
|
14
|
+
## 安裝 / Installation
|
|
6
15
|
|
|
7
16
|
```bash
|
|
17
|
+
# 使用 yarn / Using yarn
|
|
8
18
|
yarn add @lazy-node/semver-ampersand
|
|
19
|
+
|
|
20
|
+
# 使用 yarn-tool / Using yarn-tool
|
|
9
21
|
yarn-tool add @lazy-node/semver-ampersand
|
|
10
|
-
|
|
22
|
+
|
|
23
|
+
# 使用 npm / Using npm
|
|
24
|
+
npm install @lazy-node/semver-ampersand
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 功能特色 / Features
|
|
28
|
+
|
|
29
|
+
- 🔗 **Ampersand 支援** - 使用 `&` 符號組合多個版本條件 / Use `&` symbol to combine multiple version conditions
|
|
30
|
+
- ✅ **satisfies** - 檢查版本是否符合範圍 / Check if version satisfies range
|
|
31
|
+
- 🔍 **maxSatisfying / minSatisfying** - 找出最大/最小符合版本 / Find max/min satisfying version
|
|
32
|
+
- 📝 **validRange** - 驗證範圍字串是否有效 / Validate if range string is valid
|
|
33
|
+
- 🔄 **simplifyRange** - 簡化版本範圍 / Simplify version range
|
|
34
|
+
- 🏗️ **Range 類別** - 類似 semver.Range 的增強版 / Enhanced Range class similar to semver.Range
|
|
35
|
+
|
|
36
|
+
## Ampersand (`&`) 語法說明 / Ampersand (`&`) Syntax Explanation
|
|
37
|
+
|
|
38
|
+
標準 semver 使用空格來表示「且」的條件,例如 `>=1.0.0 <2.0.0`。此模組額外支援使用 `&` 符號,讓範圍表達更明確:
|
|
39
|
+
|
|
40
|
+
Standard semver uses spaces to represent "AND" conditions, e.g., `>=1.0.0 <2.0.0`. This module additionally supports the `&` symbol for more explicit range expressions:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// 標準 semver 語法 / Standard semver syntax
|
|
44
|
+
'>=1.0.0 <2.0.0'
|
|
45
|
+
|
|
46
|
+
// Ampersand 語法(功能相同)/ Ampersand syntax (functionally equivalent)
|
|
47
|
+
'>=1.0.0 & <2.0.0'
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## API 文件 / API Documentation
|
|
51
|
+
|
|
52
|
+
### `satisfies(version, range, options?)`
|
|
53
|
+
|
|
54
|
+
檢查版本是否符合指定的範圍。
|
|
55
|
+
|
|
56
|
+
Check if a version satisfies the specified range.
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { satisfies } from '@lazy-node/semver-ampersand';
|
|
60
|
+
|
|
61
|
+
// 標準 semver 範圍 / Standard semver range
|
|
62
|
+
satisfies('1.2.3', '>=1.0.0 <2.0.0'); // true
|
|
63
|
+
satisfies('2.0.0', '>=1.0.0 <2.0.0'); // false
|
|
64
|
+
|
|
65
|
+
// 使用 ampersand / Using ampersand
|
|
66
|
+
satisfies('1.2.3', '>=1.0.0 & <2.0.0'); // true
|
|
67
|
+
satisfies('1.2.3', '^1.0.0 & >=1.2.0'); // true
|
|
68
|
+
|
|
69
|
+
// 多條件組合 / Multiple conditions
|
|
70
|
+
satisfies('1.2.3', '>=1.0.0 & <2.0.0 || >=3.0.0'); // true
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### `validRange(range, options?)`
|
|
74
|
+
|
|
75
|
+
驗證範圍字串是否有效,返回規範化後的範圍或 `null`。
|
|
76
|
+
|
|
77
|
+
Validate if a range string is valid, returns normalized range or `null`.
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { validRange } from '@lazy-node/semver-ampersand';
|
|
81
|
+
|
|
82
|
+
validRange('>=1.0.0 & <2.0.0'); // true (返回規範化的範圍)
|
|
83
|
+
validRange('invalid-range'); // null
|
|
84
|
+
validRange('>=1.0.0 & invalid'); // null
|
|
11
85
|
```
|
|
12
86
|
|
|
87
|
+
### `maxSatisfying(versions, range, options?)`
|
|
88
|
+
|
|
89
|
+
從版本陣列中找出符合範圍的最大版本。
|
|
90
|
+
|
|
91
|
+
Find the maximum version that satisfies the range from an array of versions.
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { maxSatisfying } from '@lazy-node/semver-ampersand';
|
|
95
|
+
|
|
96
|
+
const versions = ['1.0.0', '1.2.3', '2.0.0', '2.1.0'];
|
|
97
|
+
maxSatisfying(versions, '>=1.0.0 & <2.0.0'); // '1.2.3'
|
|
98
|
+
maxSatisfying(versions, '^2.0.0'); // '2.1.0'
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### `minSatisfying(versions, range, options?)`
|
|
102
|
+
|
|
103
|
+
從版本陣列中找出符合範圍的最小版本。
|
|
104
|
+
|
|
105
|
+
Find the minimum version that satisfies the range from an array of versions.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { minSatisfying } from '@lazy-node/semver-ampersand';
|
|
109
|
+
|
|
110
|
+
const versions = ['1.0.0', '1.2.3', '2.0.0', '2.1.0'];
|
|
111
|
+
minSatisfying(versions, '>=1.0.0 & <2.0.0'); // '1.0.0'
|
|
112
|
+
minSatisfying(versions, '^2.0.0'); // '2.0.0'
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### `simplifyRange(versions, range, options?)`
|
|
116
|
+
|
|
117
|
+
簡化版本範圍。
|
|
118
|
+
|
|
119
|
+
Simplify version range.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { simplifyRange } from '@lazy-node/semver-ampersand';
|
|
123
|
+
|
|
124
|
+
const versions = ['1.0.0', '1.0.1', '1.0.2'];
|
|
125
|
+
simplifyRange(versions, '>=1.0.0 & <2.0.0');
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### `handleAmpersandAndSpaces(range)`
|
|
129
|
+
|
|
130
|
+
處理範圍字串中的 ampersand 和空格。
|
|
131
|
+
|
|
132
|
+
Handle ampersand and spaces in range string.
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { handleAmpersandAndSpaces } from '@lazy-node/semver-ampersand';
|
|
136
|
+
|
|
137
|
+
handleAmpersandAndSpaces('>=1.0.0 & <2.0.0');
|
|
138
|
+
// 返回處理後的範圍字串
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### `Range` 類別 / `Range` Class
|
|
142
|
+
|
|
143
|
+
增強版的 semver Range 類別,支援 ampersand 語法。
|
|
144
|
+
|
|
145
|
+
Enhanced semver Range class with ampersand syntax support.
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { Range } from '@lazy-node/semver-ampersand';
|
|
149
|
+
|
|
150
|
+
const range = new Range('>=1.0.0 & <2.0.0');
|
|
151
|
+
|
|
152
|
+
// 測試版本是否符合 / Test if version satisfies
|
|
153
|
+
range.test('1.2.3'); // true
|
|
154
|
+
range.test('2.0.0'); // false
|
|
155
|
+
|
|
156
|
+
// 存取範圍結構 / Access range structure
|
|
157
|
+
console.log(range.set); // 比較器集合
|
|
158
|
+
|
|
159
|
+
// 格式化輸出 / Format output
|
|
160
|
+
console.log(range.toString()); // '>=1.0.0 <2.0.0'
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 選項 / Options
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
interface IOptions extends semver.Options, semver.RangeOptions {
|
|
167
|
+
/**
|
|
168
|
+
* 停用 ampersand 處理 / Disable ampersand handling
|
|
169
|
+
*/
|
|
170
|
+
noAmpersand?: boolean;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 啟用不安全優化 / Enable unsafe optimization
|
|
174
|
+
*/
|
|
175
|
+
unsafeOptimize?: boolean;
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## 使用案例 / Use Cases
|
|
180
|
+
|
|
181
|
+
### 1. Workspaces 版本管理 / Workspace Version Management
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
import { satisfies, validRange } from '@lazy-node/semver-ampersand';
|
|
185
|
+
|
|
186
|
+
const workspaceDeps = {
|
|
187
|
+
'package-a': '>=1.0.0 & <2.0.0',
|
|
188
|
+
'package-b': '^2.0.0 & >=2.1.0',
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
Object.entries(workspaceDeps).forEach(([pkg, range]) => {
|
|
192
|
+
if (validRange(range)) {
|
|
193
|
+
console.log(`${pkg}: ${range} is valid`);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### 2. 依賴版本檢查 / Dependency Version Checking
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
import { satisfies, maxSatisfying } from '@lazy-node/semver-ampersand';
|
|
202
|
+
|
|
203
|
+
const installedVersions = {
|
|
204
|
+
'lodash': '4.17.21',
|
|
205
|
+
'axios': '1.2.0',
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const requiredRanges = {
|
|
209
|
+
'lodash': '>=4.0.0 & <5.0.0',
|
|
210
|
+
'axios': '^1.0.0',
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
Object.entries(requiredRanges).forEach(([pkg, range]) => {
|
|
214
|
+
const version = installedVersions[pkg];
|
|
215
|
+
if (version && !satisfies(version, range)) {
|
|
216
|
+
console.log(`${pkg}@${version} does not satisfy ${range}`);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### 3. 版本選擇 / Version Selection
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { maxSatisfying, minSatisfying } from '@lazy-node/semver-ampersand';
|
|
225
|
+
|
|
226
|
+
const availableVersions = [
|
|
227
|
+
'1.0.0', '1.1.0', '1.2.0',
|
|
228
|
+
'2.0.0', '2.1.0', '3.0.0'
|
|
229
|
+
];
|
|
230
|
+
|
|
231
|
+
const range = '>=1.0.0 & <3.0.0';
|
|
232
|
+
|
|
233
|
+
console.log('Latest compatible:', maxSatisfying(availableVersions, range));
|
|
234
|
+
// '2.1.0'
|
|
235
|
+
|
|
236
|
+
console.log('Earliest compatible:', minSatisfying(availableVersions, range));
|
|
237
|
+
// '1.0.0'
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### 4. 複雜範圍處理 / Complex Range Handling
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import { Range, simplifyRange } from '@lazy-node/semver-ampersand';
|
|
244
|
+
|
|
245
|
+
// 複雜的版本需求 / Complex version requirements
|
|
246
|
+
const complexRange = '>=1.0.0 & <2.0.0 || >=3.0.0 & <4.0.0';
|
|
247
|
+
|
|
248
|
+
const range = new Range(complexRange);
|
|
249
|
+
|
|
250
|
+
// 檢查多個版本 / Check multiple versions
|
|
251
|
+
['1.5.0', '2.5.0', '3.5.0'].forEach(version => {
|
|
252
|
+
console.log(`${version}: ${range.test(version)}`);
|
|
253
|
+
// 1.5.0: true
|
|
254
|
+
// 2.5.0: false
|
|
255
|
+
// 3.5.0: true
|
|
256
|
+
});
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## 與 semver 套件的差異 / Differences from semver Package
|
|
260
|
+
|
|
261
|
+
| 功能 / Feature | `semver` | `@lazy-node/semver-ampersand` |
|
|
262
|
+
|---------------|----------|-------------------------------|
|
|
263
|
+
| 標準範圍語法 / Standard range syntax | ✅ | ✅ |
|
|
264
|
+
| Ampersand (`&`) 語法 / Ampersand syntax | ❌ | ✅ |
|
|
265
|
+
| 空格表示「且」/ Space as "AND" | ✅ | ✅ |
|
|
266
|
+
| Range 類別 / Range class | ✅ | ✅ (擴展版) |
|
|
267
|
+
| 快取機制 / Caching | ✅ | ✅ |
|
|
268
|
+
|
|
269
|
+
## 相關套件 / Related Packages
|
|
270
|
+
|
|
271
|
+
- [`@lazy-node/semver-part`](../semver-part) - 版本部分比較工具 / Version part comparison utilities
|
|
272
|
+
- [`@lazy-node/semver-parse`](../semver-parse) - semver 解析工具 / Semver parsing utilities
|
|
273
|
+
- [`semver`](https://www.npmjs.com/package/semver) - 語義化版本處理 / Semantic versioning
|
|
274
|
+
|
|
275
|
+
## 授權 / License
|
|
276
|
+
|
|
277
|
+
ISC © bluelovers
|
|
278
|
+
|
|
279
|
+
## 貢獻 / Contributing
|
|
280
|
+
|
|
281
|
+
歡迎提交 Issue 和 Pull Request!
|
|
282
|
+
|
|
283
|
+
Issues and Pull Requests are welcome!
|
|
284
|
+
|
|
285
|
+
請前往 [GitHub](https://github.com/bluelovers/ws-yarn-workspaces) 貢獻。
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @lazy-node/semver-ampersand
|
|
3
|
+
*
|
|
4
|
+
* 支援 ampersand (&) 語法的 semver 範圍處理工具庫
|
|
5
|
+
* Semver range handling utilities with ampersand (&) syntax support
|
|
6
|
+
*
|
|
7
|
+
* 此模組擴展了標準 semver 的範圍處理功能,支援使用 `&` 符號來表示「且」的條件,
|
|
8
|
+
* 這在處理 yarn 或 npm workspaces 的依賴版本時特別有用。
|
|
9
|
+
*
|
|
10
|
+
* This module extends standard semver range handling with support for the `&`
|
|
11
|
+
* symbol to represent "AND" conditions, which is particularly useful when
|
|
12
|
+
* handling dependency versions in yarn or npm workspaces.
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { satisfies, validRange, Range } from '@lazy-node/semver-ampersand';
|
|
19
|
+
*
|
|
20
|
+
* // 標準 semver 範圍 / Standard semver range
|
|
21
|
+
* satisfies('1.2.3', '>=1.0.0 <2.0.0'); // true
|
|
22
|
+
*
|
|
23
|
+
* // 使用 ampersand 的範圍 / Range with ampersand
|
|
24
|
+
* satisfies('1.2.3', '>=1.0.0 & <2.0.0'); // true
|
|
25
|
+
*
|
|
26
|
+
* // 驗證範圍 / Validate range
|
|
27
|
+
* validRange('>=1.0.0 & <2.0.0'); // true
|
|
28
|
+
*
|
|
29
|
+
* // 使用 Range 類別 / Using Range class
|
|
30
|
+
* const range = new Range('>=1.0.0 & <2.0.0');
|
|
31
|
+
* range.test('1.5.0'); // true
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
1
34
|
import { simplifyRange } from './lib/simplifyRange';
|
|
2
35
|
import { handleAmpersandAndSpaces } from './lib/handleAmpersandAndSpaces';
|
|
3
36
|
import { satisfies } from './lib/satisfies';
|
package/index.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @lazy-node/semver-ampersand
|
|
4
|
+
*
|
|
5
|
+
* 支援 ampersand (&) 語法的 semver 範圍處理工具庫
|
|
6
|
+
* Semver range handling utilities with ampersand (&) syntax support
|
|
7
|
+
*
|
|
8
|
+
* 此模組擴展了標準 semver 的範圍處理功能,支援使用 `&` 符號來表示「且」的條件,
|
|
9
|
+
* 這在處理 yarn 或 npm workspaces 的依賴版本時特別有用。
|
|
10
|
+
*
|
|
11
|
+
* This module extends standard semver range handling with support for the `&`
|
|
12
|
+
* symbol to represent "AND" conditions, which is particularly useful when
|
|
13
|
+
* handling dependency versions in yarn or npm workspaces.
|
|
14
|
+
*
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { satisfies, validRange, Range } from '@lazy-node/semver-ampersand';
|
|
20
|
+
*
|
|
21
|
+
* // 標準 semver 範圍 / Standard semver range
|
|
22
|
+
* satisfies('1.2.3', '>=1.0.0 <2.0.0'); // true
|
|
23
|
+
*
|
|
24
|
+
* // 使用 ampersand 的範圍 / Range with ampersand
|
|
25
|
+
* satisfies('1.2.3', '>=1.0.0 & <2.0.0'); // true
|
|
26
|
+
*
|
|
27
|
+
* // 驗證範圍 / Validate range
|
|
28
|
+
* validRange('>=1.0.0 & <2.0.0'); // true
|
|
29
|
+
*
|
|
30
|
+
* // 使用 Range 類別 / Using Range class
|
|
31
|
+
* const range = new Range('>=1.0.0 & <2.0.0');
|
|
32
|
+
* range.test('1.5.0'); // true
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.Range = exports.handleAmpersandAndSpaces = exports.simplifyRange = exports.validRange = exports.minSatisfying = exports.maxSatisfying = exports.satisfies = exports.reAmpersandAndSpaces = void 0;
|
|
4
37
|
const simplifyRange_1 = require("./lib/simplifyRange");
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;;AAEH,uDAAoD;AAmBnD,8FAnBQ,6BAAa,OAmBR;AAlBd,6EAA0E;AAoBzE,yGApBQ,mDAAwB,OAoBR;AAnBzB,+CAA4C;AAW3C,0FAXQ,qBAAS,OAWR;AAVV,uDAAoD;AAYnD,8FAZQ,6BAAa,OAYR;AAXd,uDAAoD;AAYnD,8FAZQ,6BAAa,OAYR;AAXd,iDAA8C;AAa7C,2FAbQ,uBAAU,OAaR;AAZX,uCAAoC;AAiBnC,sFAjBQ,aAAK,OAiBR;AAbN,qCAAmD;AAA1C,6GAAA,oBAAoB,OAAA;AAgB7B,kBAAe;IACd,SAAS,EAAT,qBAAS;IAET,aAAa,EAAb,6BAAa;IACb,aAAa,EAAb,6BAAa;IAEb,UAAU,EAAV,uBAAU;IACV,aAAa,EAAb,6BAAa;IAEb,wBAAwB,EAAxB,mDAAwB;IAExB,KAAK,EAAL,aAAK;CACL,CAAA","sourcesContent":["/**\n * @lazy-node/semver-ampersand\n * \n * 支援 ampersand (&) 語法的 semver 範圍處理工具庫\n * Semver range handling utilities with ampersand (&) syntax support\n * \n * 此模組擴展了標準 semver 的範圍處理功能,支援使用 `&` 符號來表示「且」的條件,\n * 這在處理 yarn 或 npm workspaces 的依賴版本時特別有用。\n * \n * This module extends standard semver range handling with support for the `&` \n * symbol to represent \"AND\" conditions, which is particularly useful when \n * handling dependency versions in yarn or npm workspaces.\n * \n * @packageDocumentation\n * \n * @example\n * ```typescript\n * import { satisfies, validRange, Range } from '@lazy-node/semver-ampersand';\n * \n * // 標準 semver 範圍 / Standard semver range\n * satisfies('1.2.3', '>=1.0.0 <2.0.0'); // true\n * \n * // 使用 ampersand 的範圍 / Range with ampersand\n * satisfies('1.2.3', '>=1.0.0 & <2.0.0'); // true\n * \n * // 驗證範圍 / Validate range\n * validRange('>=1.0.0 & <2.0.0'); // true\n * \n * // 使用 Range 類別 / Using Range class\n * const range = new Range('>=1.0.0 & <2.0.0');\n * range.test('1.5.0'); // true\n * ```\n */\n\nimport { simplifyRange } from './lib/simplifyRange';\nimport { handleAmpersandAndSpaces } from './lib/handleAmpersandAndSpaces';\nimport { satisfies } from './lib/satisfies';\nimport { maxSatisfying } from './lib/maxSatisfying';\nimport { minSatisfying } from './lib/minSatisfying';\nimport { validRange } from './lib/validRange';\nimport { Range } from './lib/Range';\n\nexport type { IOptions } from './lib/types';\n\nexport { reAmpersandAndSpaces } from './lib/const';\n\nexport {\n\tsatisfies,\n\n\tmaxSatisfying,\n\tminSatisfying,\n\n\tvalidRange,\n\tsimplifyRange,\n\n\thandleAmpersandAndSpaces,\n\n\tRange,\n}\n\nexport default {\n\tsatisfies,\n\n\tmaxSatisfying,\n\tminSatisfying,\n\n\tvalidRange,\n\tsimplifyRange,\n\n\thandleAmpersandAndSpaces,\n\n\tRange,\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lazy-node/semver-ampersand",
|
|
3
|
-
"version": "3.0.
|
|
4
|
-
"description": "semver with
|
|
3
|
+
"version": "3.0.8",
|
|
4
|
+
"description": "支援 ampersand (&) 語法的 semver 範圍處理工具庫 - Semver range handling utilities with ampersand (&) syntax support for yarn/npm workspaces",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"semver",
|
|
7
7
|
"ampersand",
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
"pkg",
|
|
15
15
|
"dependencies",
|
|
16
16
|
"packages",
|
|
17
|
-
"package"
|
|
17
|
+
"package",
|
|
18
|
+
"semver-range",
|
|
19
|
+
"version-range",
|
|
20
|
+
"satisfies"
|
|
18
21
|
],
|
|
19
22
|
"homepage": "https://github.com/bluelovers/ws-yarn-workspaces/tree/master/packages/@lazy-node/semver-ampersand#readme",
|
|
20
23
|
"bugs": {
|
|
@@ -49,14 +52,14 @@
|
|
|
49
52
|
"class-without-call-parent-constructor": "^2.0.5",
|
|
50
53
|
"lru-cache2": "^6.0.7",
|
|
51
54
|
"split-smartly2": "^2.0.1",
|
|
52
|
-
"ts-type": "^3.0.
|
|
55
|
+
"ts-type": "^3.0.8",
|
|
53
56
|
"tslib": ">=2"
|
|
54
57
|
},
|
|
55
58
|
"peerDependencies": {
|
|
56
|
-
"semver": "^7.7.
|
|
59
|
+
"semver": "^7.7.4"
|
|
57
60
|
},
|
|
58
61
|
"publishConfig": {
|
|
59
62
|
"access": "public"
|
|
60
63
|
},
|
|
61
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "ca3fae2bbdf31ed1ce9bab14793912026200767e"
|
|
62
65
|
}
|