@lazy-node/semver-ampersand 3.0.2 → 3.0.4

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 CHANGED
@@ -3,6 +3,51 @@
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.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)
7
+
8
+
9
+
10
+ ### 📚 Documentation
11
+
12
+ * **semver:** 新增 semver-* 套件完整文件與測試案例 ([a89a944](https://github.com/bluelovers/ws-yarn-workspaces/commit/a89a944880ce53ac0678351df4b6744a5feb0b08))
13
+
14
+
15
+ ### 🚨 Tests
16
+
17
+ * 修正測試斷言並完善測試工具文檔 ([8abcb1f](https://github.com/bluelovers/ws-yarn-workspaces/commit/8abcb1f23b0e4fa99ae957bad13a09136ef3bad0))
18
+ * 改用快照測試驗證錯誤並簡化斷言語法 ([25a5c62](https://github.com/bluelovers/ws-yarn-workspaces/commit/25a5c627a1df5756cf78fb9312d8e47a9de2bd6c))
19
+ * **semver-ampersand:** 新增連字號範圍測試案例與測試規格 ([4614f01](https://github.com/bluelovers/ws-yarn-workspaces/commit/4614f011be611fe0f803883f18a6780d21498b56))
20
+
21
+
22
+ ### 🛠 Build System
23
+
24
+ * 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))
25
+
26
+
27
+ ### ♻️ Chores
28
+
29
+ * Add test config and global types for tsdx ([88a8df6](https://github.com/bluelovers/ws-yarn-workspaces/commit/88a8df6eef5dc59d9e0d9268b21706dceb5ab2a1))
30
+ * 更新 Jest 快照連結並增強類型定義與文件 ([b663b97](https://github.com/bluelovers/ws-yarn-workspaces/commit/b663b97d78d223dc8b3927ea2433938350144de7))
31
+ * add __root.ts test utility to workspace packages ([a771727](https://github.com/bluelovers/ws-yarn-workspaces/commit/a7717278883c86d9ed8ab89f42070d3385c173a7))
32
+ * **deps:** 升級多項依賴套件版本 ([1382602](https://github.com/bluelovers/ws-yarn-workspaces/commit/1382602ca94ff236b251fd1481b6332468de4621))
33
+
34
+
35
+
36
+ ## [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)
37
+
38
+
39
+
40
+ ### 🐛 Bug Fixes
41
+
42
+ * override readonly range ([f5cf67e](https://github.com/bluelovers/ws-yarn-workspaces/commit/f5cf67eae86eb61892ca814d7fc24ecb076c769f))
43
+
44
+
45
+ ### 📌 Dependencies
46
+
47
+ * fix and update deps avoid use yargs@18 ([5ed9a5c](https://github.com/bluelovers/ws-yarn-workspaces/commit/5ed9a5cd953eeebd28d4ee970e99bed6fb966317))
48
+
49
+
50
+
6
51
  ## [3.0.2](https://github.com/bluelovers/ws-yarn-workspaces/compare/@lazy-node/semver-ampersand@3.0.1...@lazy-node/semver-ampersand@3.0.2) (2024-05-03)
7
52
 
8
53
 
package/README.md CHANGED
@@ -1,12 +1,285 @@
1
- # README.md
1
+ # @lazy-node/semver-ampersand
2
2
 
3
- semver with support (&)ampersand
3
+ > 支援 ampersand (&) 語法的 semver 範圍處理工具庫 / Semver range handling utilities with ampersand (&) syntax support
4
4
 
5
- ## install
5
+ [![NPM version](https://img.shields.io/npm/v/@lazy-node/semver-ampersand.svg)](https://www.npmjs.com/package/@lazy-node/semver-ampersand)
6
+ [![License](https://img.shields.io/npm/l/@lazy-node/semver-ampersand.svg)](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
- yt add @lazy-node/semver-ampersand
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":";;;AAAA,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":["import { 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"]}
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/lib/Range.d.ts CHANGED
@@ -4,12 +4,12 @@ import { Comparator } from 'semver';
4
4
  declare const SemverRange_base: typeof semverRange & (new () => semverRange);
5
5
  export declare class SemverRange<RAW extends ISemverRangeInput> extends SemverRange_base {
6
6
  readonly rawSource?: RAW;
7
- readonly range: string;
8
7
  readonly raw: string;
9
8
  readonly set: IComparatorSet;
10
9
  readonly options: IOptions;
11
10
  readonly loose: boolean;
12
11
  readonly includePrerelease: boolean;
12
+ protected readonly formatted: string;
13
13
  constructor(rawSource: RAW, optionsOrLoose?: IOptionsOrLoose<IOptions>);
14
14
  protected _buildComparatorsSet(range: string, options: IOptions): IComparatorSetInput;
15
15
  parseRange(range: string): readonly Comparator[];
@@ -19,7 +19,7 @@ export declare class SemverRange<RAW extends ISemverRangeInput> extends SemverRa
19
19
  set: readonly (readonly Comparator[])[];
20
20
  };
21
21
  protected _inheritOptions(options: IOptions): void;
22
- format(): string;
22
+ get range(): string;
23
23
  /**
24
24
  * Return '*' instead of '' so that truthiness works.
25
25
  */
package/lib/Range.js CHANGED
@@ -85,10 +85,16 @@ class SemverRange extends (0, class_without_call_parent_constructor_1.classWitho
85
85
  this.options = options;
86
86
  (0, options_1._copyOptions)(this, options);
87
87
  }
88
- format() {
89
- this.range = (0, stringifyComparators_1.stringifyComparatorsSet)(this.set);
90
- return this.range;
88
+ // @ts-ignore
89
+ get range() {
90
+ // @ts-ignore
91
+ this.formatted = (0, stringifyComparators_1.stringifyComparatorsSet)(this.set);
92
+ return this.formatted;
91
93
  }
94
+ // override format()
95
+ // {
96
+ // return this.range
97
+ // }
92
98
  /**
93
99
  * Return '*' instead of '' so that truthiness works.
94
100
  */
package/lib/Range.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Range.js","sourceRoot":"","sources":["Range.ts"],"names":[],"mappings":";;;;AAAA,yEAA+C;AAC/C,yEAAsE;AAQtE,sEAAsE;AACtE,2EAA2C;AAC3C,iGAA0F;AAC1F,mCAAoC;AACpC,6CAAkF;AAClF,yDAAsD;AACtD,0CAA2D;AAC3D,+DAA4D;AAC5D,wEAAqE;AACrE,wCAAsD;AACtD,mDAAgD;AAEhD,MAAa,WAA2C,SAAQ,IAAA,yEAAiC,EAAC,eAAW,CAAC;IAY7G,YAAY,SAAc,EAAE,cAA0C;QAErE,wCAAwC;QACxC,KAAK,EAAE,CAAC;QAER,cAAc,GAAG,IAAA,yCAAmB,EAAC,cAAc,CAAC,CAAC;QAErD,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,IAA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,CAAC,KAAK,CAAA;IAClB,CAAC;IAED;;OAEG;IACH,aAAa;QAEZ,OAAO,IAAA,6BAAa,EAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACjC,CAAC;CAED;AAtID,kCAsIC;AAEuB,4BAAK;AAE7B,kBAAe,WAAW,CAAA","sourcesContent":["import semverRange from 'semver/classes/range';\nimport { handleAmpersandAndSpaces } from './handleAmpersandAndSpaces';\nimport {\n\tIComparatorSet,\n\tIComparatorSetInput,\n\tIOptions,\n\tIOptionsOrLoose,\n\tISemverRangeInput,\n} from './types';\nimport { stringifyComparatorsSet } from './util/stringifyComparators';\nimport SemVer from 'semver/classes/semver';\nimport { classWithoutCallParentConstructor } from 'class-without-call-parent-constructor';\nimport { Comparator } from 'semver';\nimport { _copyOptions, _isSameOptions, _normalizeOptions } from './range/options';\nimport { toRangeString } from './range/toRangeString';\nimport { assertInvalidComparatorSet } from './util/assert';\nimport { fixComparatorSet } from './range/fixComparatorSet';\nimport { parseOptionsOrLoose } from './internal/parseOptionsOrLoose';\nimport { splitDoubleVerticalBar } from './util/split';\nimport { parseRange } from './range/parseRange';\n\nexport class SemverRange<RAW extends ISemverRangeInput> extends classWithoutCallParentConstructor(semverRange)\n{\n\treadonly rawSource?: RAW;\n\n\toverride readonly range: string;\n\toverride readonly raw: string;\n\toverride readonly set: IComparatorSet;\n\n\toverride readonly options: IOptions;\n\toverride readonly loose: boolean;\n\toverride readonly includePrerelease: boolean;\n\n\tconstructor(rawSource: RAW, optionsOrLoose?: IOptionsOrLoose<IOptions>)\n\t{\n\t\t// skip original semverRange constructor\n\t\tsuper();\n\n\t\toptionsOrLoose = parseOptionsOrLoose(optionsOrLoose);\n\n\t\tlet { range, options, set } = this._inherit(rawSource, optionsOrLoose);\n\n\t\tif (typeof rawSource === 'string' && range !== rawSource)\n\t\t{\n\t\t\tthis.rawSource = rawSource;\n\t\t}\n\n\t\tthis._inheritOptions(options);\n\n\t\tif (!set)\n\t\t{\n\n\t\t\tset = this._buildComparatorsSet(range, options);\n\t\t}\n\n\t\tassertInvalidComparatorSet(set, `Invalid SemVer Range: ${range}`);\n\n\t\tset = fixComparatorSet(set, options.unsafeOptimize);\n\n\t\tassertInvalidComparatorSet(set);\n\n\t\tthis.raw = range;\n\t\tthis.set = set;\n\n\t\tthis.format()\n\t}\n\n\tprotected _buildComparatorsSet(range: string, options: IOptions): IComparatorSetInput\n\t{\n\t\tlet comparatorsSet = splitDoubleVerticalBar(range)\n\t\t\t// map the range to a 2d array of comparators\n\t\t\t.map(range => this.parseRange(range))\n\t\t\t// throw out any comparator lists that are empty\n\t\t\t// this generally means that it was not a valid range, which is allowed\n\t\t\t// in loose mode, but will still throw if the WHOLE range is invalid.\n\t\t\t.filter(c => c.length)\n\t\t;\n\n\t\treturn comparatorsSet\n\t}\n\n\toverride parseRange(range: string)\n\t{\n\t\treturn parseRange(range, this.options)\n\t}\n\n\tprotected _inherit(range: ISemverRangeInput, options: IOptions)\n\t{\n\t\tlet set: IComparatorSet;\n\n\t\tif (range instanceof semverRange)\n\t\t{\n\t\t\toptions = {\n\t\t\t\tloose: range.loose,\n\t\t\t\tincludePrerelease: range.includePrerelease,\n\t\t\t\t...range.options,\n\t\t\t\t...options,\n\t\t\t}\n\n\t\t\toptions = _normalizeOptions(options);\n\n\t\t\tif (_isSameOptions(range, options))\n\t\t\t{\n\t\t\t\tset = range.set;\n\t\t\t}\n\n\t\t\trange = range.raw;\n\t\t}\n\n\t\tif (range instanceof Comparator)\n\t\t{\n\t\t\tset = [[range]];\n\t\t\trange = range.value\n\t\t}\n\t\telse if (range instanceof SemVer)\n\t\t{\n\t\t\trange = range.format();\n\t\t}\n\n\t\tif (set?.length === 0)\n\t\t{\n\t\t\tassertInvalidComparatorSet(set);\n\t\t}\n\n\t\toptions = _normalizeOptions(options);\n\n\t\trange = handleAmpersandAndSpaces(range, options);\n\n\t\treturn {\n\t\t\trange,\n\t\t\toptions,\n\t\t\tset,\n\t\t}\n\t}\n\n\tprotected _inheritOptions(options: IOptions)\n\t{\n\t\t(this as any as semverRange).options = options;\n\t\t_copyOptions(this, options);\n\t}\n\n\toverride format()\n\t{\n\t\t(this as any as semverRange).range = stringifyComparatorsSet(this.set);\n\t\treturn this.range\n\t}\n\n\t/**\n\t * Return '*' instead of '' so that truthiness works.\n\t */\n\ttoRangeString()\n\t{\n\t\treturn toRangeString(this.range)\n\t}\n\n}\n\nexport { SemverRange as Range }\n\nexport default SemverRange\n"]}
1
+ {"version":3,"file":"Range.js","sourceRoot":"","sources":["Range.ts"],"names":[],"mappings":";;;;AAAA,yEAA+C;AAC/C,yEAAsE;AAQtE,sEAAsE;AACtE,2EAA2C;AAC3C,iGAA0F;AAC1F,mCAAoC;AACpC,6CAAkF;AAClF,yDAAsD;AACtD,0CAA2D;AAC3D,+DAA4D;AAC5D,wEAAqE;AACrE,wCAAsD;AACtD,mDAAgD;AAEhD,MAAa,WAA2C,SAAQ,IAAA,yEAAiC,EAAC,eAAW,CAAC;IAa7G,YAAY,SAAc,EAAE,cAA0C;QAErE,wCAAwC;QACxC,KAAK,EAAE,CAAC;QAER,cAAc,GAAG,IAAA,yCAAmB,EAAC,cAAc,CAAC,CAAC;QAErD,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QAEvE,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,KAAK,KAAK,SAAS,EACxD,CAAC;YACA,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAE9B,IAAI,CAAC,GAAG,EACR,CAAC;YAEA,GAAG,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC;QAED,IAAA,mCAA0B,EAAC,GAAG,EAAE,yBAAyB,KAAK,EAAE,CAAC,CAAC;QAElE,GAAG,GAAG,IAA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;YACA,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAChB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QACpB,CAAC;aACI,IAAI,KAAK,YAAY,gBAAM,EAChC,CAAC;YACA,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACxB,CAAC;QAED,IAAI,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,MAAK,CAAC,EACrB,CAAC;YACA,IAAA,mCAA0B,EAAC,GAAG,CAAC,CAAC;QACjC,CAAC;QAED,OAAO,GAAG,IAAA,2BAAiB,EAAC,OAAO,CAAC,CAAC;QAErC,KAAK,GAAG,IAAA,mDAAwB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEjD,OAAO;YACN,KAAK;YACL,OAAO;YACP,GAAG;SACH,CAAA;IACF,CAAC;IAES,eAAe,CAAC,OAAiB;QAEzC,IAA2B,CAAC,OAAO,GAAG,OAAO,CAAC;QAC/C,IAAA,sBAAY,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED,aAAa;IACb,IAAa,KAAK;QAEjB,aAAa;QACb,IAAI,CAAC,SAAS,GAAG,IAAA,8CAAuB,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,SAAS,CAAA;IACtB,CAAC;IAEF,oBAAoB;IACpB,IAAI;IACJ,qBAAqB;IACrB,IAAI;IAEH;;OAEG;IACH,aAAa;QAEZ,OAAO,IAAA,6BAAa,EAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACjC,CAAC;CAED;AA9ID,kCA8IC;AAEuB,4BAAK;AAE7B,kBAAe,WAAW,CAAA","sourcesContent":["import semverRange from 'semver/classes/range';\nimport { handleAmpersandAndSpaces } from './handleAmpersandAndSpaces';\nimport {\n\tIComparatorSet,\n\tIComparatorSetInput,\n\tIOptions,\n\tIOptionsOrLoose,\n\tISemverRangeInput,\n} from './types';\nimport { stringifyComparatorsSet } from './util/stringifyComparators';\nimport SemVer from 'semver/classes/semver';\nimport { classWithoutCallParentConstructor } from 'class-without-call-parent-constructor';\nimport { Comparator } from 'semver';\nimport { _copyOptions, _isSameOptions, _normalizeOptions } from './range/options';\nimport { toRangeString } from './range/toRangeString';\nimport { assertInvalidComparatorSet } from './util/assert';\nimport { fixComparatorSet } from './range/fixComparatorSet';\nimport { parseOptionsOrLoose } from './internal/parseOptionsOrLoose';\nimport { splitDoubleVerticalBar } from './util/split';\nimport { parseRange } from './range/parseRange';\n\nexport class SemverRange<RAW extends ISemverRangeInput> extends classWithoutCallParentConstructor(semverRange)\n{\n\treadonly rawSource?: RAW;\n\n\toverride readonly raw: string;\n\toverride readonly set: IComparatorSet;\n\n\toverride readonly options: IOptions;\n\toverride readonly loose: boolean;\n\toverride readonly includePrerelease: boolean;\n\n\tprotected readonly formatted: string;\n\n\tconstructor(rawSource: RAW, optionsOrLoose?: IOptionsOrLoose<IOptions>)\n\t{\n\t\t// skip original semverRange constructor\n\t\tsuper();\n\n\t\toptionsOrLoose = parseOptionsOrLoose(optionsOrLoose);\n\n\t\tlet { range, options, set } = this._inherit(rawSource, optionsOrLoose);\n\n\t\tif (typeof rawSource === 'string' && range !== rawSource)\n\t\t{\n\t\t\tthis.rawSource = rawSource;\n\t\t}\n\n\t\tthis._inheritOptions(options);\n\n\t\tif (!set)\n\t\t{\n\n\t\t\tset = this._buildComparatorsSet(range, options);\n\t\t}\n\n\t\tassertInvalidComparatorSet(set, `Invalid SemVer Range: ${range}`);\n\n\t\tset = fixComparatorSet(set, options.unsafeOptimize);\n\n\t\tassertInvalidComparatorSet(set);\n\n\t\tthis.raw = range;\n\t\tthis.set = set;\n\n\t\tthis.format()\n\t}\n\n\tprotected _buildComparatorsSet(range: string, options: IOptions): IComparatorSetInput\n\t{\n\t\tlet comparatorsSet = splitDoubleVerticalBar(range)\n\t\t\t// map the range to a 2d array of comparators\n\t\t\t.map(range => this.parseRange(range))\n\t\t\t// throw out any comparator lists that are empty\n\t\t\t// this generally means that it was not a valid range, which is allowed\n\t\t\t// in loose mode, but will still throw if the WHOLE range is invalid.\n\t\t\t.filter(c => c.length)\n\t\t;\n\n\t\treturn comparatorsSet\n\t}\n\n\toverride parseRange(range: string)\n\t{\n\t\treturn parseRange(range, this.options)\n\t}\n\n\tprotected _inherit(range: ISemverRangeInput, options: IOptions)\n\t{\n\t\tlet set: IComparatorSet;\n\n\t\tif (range instanceof semverRange)\n\t\t{\n\t\t\toptions = {\n\t\t\t\tloose: range.loose,\n\t\t\t\tincludePrerelease: range.includePrerelease,\n\t\t\t\t...range.options,\n\t\t\t\t...options,\n\t\t\t}\n\n\t\t\toptions = _normalizeOptions(options);\n\n\t\t\tif (_isSameOptions(range, options))\n\t\t\t{\n\t\t\t\tset = range.set;\n\t\t\t}\n\n\t\t\trange = range.raw;\n\t\t}\n\n\t\tif (range instanceof Comparator)\n\t\t{\n\t\t\tset = [[range]];\n\t\t\trange = range.value\n\t\t}\n\t\telse if (range instanceof SemVer)\n\t\t{\n\t\t\trange = range.format();\n\t\t}\n\n\t\tif (set?.length === 0)\n\t\t{\n\t\t\tassertInvalidComparatorSet(set);\n\t\t}\n\n\t\toptions = _normalizeOptions(options);\n\n\t\trange = handleAmpersandAndSpaces(range, options);\n\n\t\treturn {\n\t\t\trange,\n\t\t\toptions,\n\t\t\tset,\n\t\t}\n\t}\n\n\tprotected _inheritOptions(options: IOptions)\n\t{\n\t\t(this as any as semverRange).options = options;\n\t\t_copyOptions(this, options);\n\t}\n\n\t// @ts-ignore\n\toverride get range()\n\t{\n\t\t// @ts-ignore\n\t\tthis.formatted = stringifyComparatorsSet(this.set);\n\t\treturn this.formatted\n\t}\n\n//\toverride format()\n//\t{\n//\t\treturn this.range\n//\t}\n\n\t/**\n\t * Return '*' instead of '' so that truthiness works.\n\t */\n\ttoRangeString()\n\t{\n\t\treturn toRangeString(this.range)\n\t}\n\n}\n\nexport { SemverRange as Range }\n\nexport default SemverRange\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lazy-node/semver-ampersand",
3
- "version": "3.0.2",
4
- "description": "semver with support (&)ampersand",
3
+ "version": "3.0.4",
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": {
@@ -48,15 +51,15 @@
48
51
  "array-hyper-unique": "^2.1.6",
49
52
  "class-without-call-parent-constructor": "^2.0.5",
50
53
  "lru-cache2": "^6.0.7",
51
- "split-smartly2": "^1.1.15",
54
+ "split-smartly2": "^2.0.1",
52
55
  "ts-type": "^3.0.1",
53
56
  "tslib": ">=2"
54
57
  },
55
58
  "peerDependencies": {
56
- "semver": "*"
59
+ "semver": "^7.7.4"
57
60
  },
58
61
  "publishConfig": {
59
62
  "access": "public"
60
63
  },
61
- "gitHead": "089606f66f3c5501a8f3fdfc42e5a85b57f4d0e9"
64
+ "gitHead": "ae9b0817b25b1019ba68c88e541bbffc7d84047c"
62
65
  }