@tachybase/module-backup 0.23.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.
Files changed (125) hide show
  1. package/.turbo/turbo-build.log +12 -0
  2. package/README.md +118 -0
  3. package/README.zh-CN.md +118 -0
  4. package/client.d.ts +2 -0
  5. package/client.js +1 -0
  6. package/dist/client/Configuration.d.ts +2 -0
  7. package/dist/client/DuplicatorProvider.d.ts +5 -0
  8. package/dist/client/index.d.ts +5 -0
  9. package/dist/client/index.js +1 -0
  10. package/dist/client/locale/index.d.ts +4 -0
  11. package/dist/externalVersion.js +14 -0
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.js +39 -0
  14. package/dist/locale/en-US.json +44 -0
  15. package/dist/locale/ja-JP.d.ts +25 -0
  16. package/dist/locale/ja-JP.js +46 -0
  17. package/dist/locale/ko_KR.json +50 -0
  18. package/dist/locale/pt-BR.d.ts +26 -0
  19. package/dist/locale/pt-BR.js +48 -0
  20. package/dist/locale/zh-CN.json +50 -0
  21. package/dist/node_modules/@hapi/topo/lib/index.d.ts +60 -0
  22. package/dist/node_modules/@hapi/topo/lib/index.js +1 -0
  23. package/dist/node_modules/@hapi/topo/package.json +1 -0
  24. package/dist/node_modules/archiver/LICENSE +22 -0
  25. package/dist/node_modules/archiver/index.js +68 -0
  26. package/dist/node_modules/archiver/lib/core.js +974 -0
  27. package/dist/node_modules/archiver/lib/error.js +40 -0
  28. package/dist/node_modules/archiver/lib/plugins/json.js +110 -0
  29. package/dist/node_modules/archiver/lib/plugins/tar.js +167 -0
  30. package/dist/node_modules/archiver/lib/plugins/zip.js +120 -0
  31. package/dist/node_modules/archiver/package.json +1 -0
  32. package/dist/node_modules/decompress/index.js +16 -0
  33. package/dist/node_modules/decompress/license +9 -0
  34. package/dist/node_modules/decompress/package.json +1 -0
  35. package/dist/node_modules/mkdirp/LICENSE +21 -0
  36. package/dist/node_modules/mkdirp/bin/cmd.js +68 -0
  37. package/dist/node_modules/mkdirp/index.js +1 -0
  38. package/dist/node_modules/mkdirp/lib/find-made.js +29 -0
  39. package/dist/node_modules/mkdirp/lib/mkdirp-manual.js +64 -0
  40. package/dist/node_modules/mkdirp/lib/mkdirp-native.js +39 -0
  41. package/dist/node_modules/mkdirp/lib/opts-arg.js +23 -0
  42. package/dist/node_modules/mkdirp/lib/path-arg.js +29 -0
  43. package/dist/node_modules/mkdirp/lib/use-native.js +10 -0
  44. package/dist/node_modules/mkdirp/package.json +1 -0
  45. package/dist/node_modules/mkdirp/readme.markdown +266 -0
  46. package/dist/node_modules/semver/LICENSE +15 -0
  47. package/dist/node_modules/semver/bin/semver.js +188 -0
  48. package/dist/node_modules/semver/classes/comparator.js +141 -0
  49. package/dist/node_modules/semver/classes/index.js +5 -0
  50. package/dist/node_modules/semver/classes/range.js +554 -0
  51. package/dist/node_modules/semver/classes/semver.js +302 -0
  52. package/dist/node_modules/semver/functions/clean.js +6 -0
  53. package/dist/node_modules/semver/functions/cmp.js +52 -0
  54. package/dist/node_modules/semver/functions/coerce.js +60 -0
  55. package/dist/node_modules/semver/functions/compare-build.js +7 -0
  56. package/dist/node_modules/semver/functions/compare-loose.js +3 -0
  57. package/dist/node_modules/semver/functions/compare.js +5 -0
  58. package/dist/node_modules/semver/functions/diff.js +65 -0
  59. package/dist/node_modules/semver/functions/eq.js +3 -0
  60. package/dist/node_modules/semver/functions/gt.js +3 -0
  61. package/dist/node_modules/semver/functions/gte.js +3 -0
  62. package/dist/node_modules/semver/functions/inc.js +19 -0
  63. package/dist/node_modules/semver/functions/lt.js +3 -0
  64. package/dist/node_modules/semver/functions/lte.js +3 -0
  65. package/dist/node_modules/semver/functions/major.js +3 -0
  66. package/dist/node_modules/semver/functions/minor.js +3 -0
  67. package/dist/node_modules/semver/functions/neq.js +3 -0
  68. package/dist/node_modules/semver/functions/parse.js +16 -0
  69. package/dist/node_modules/semver/functions/patch.js +3 -0
  70. package/dist/node_modules/semver/functions/prerelease.js +6 -0
  71. package/dist/node_modules/semver/functions/rcompare.js +3 -0
  72. package/dist/node_modules/semver/functions/rsort.js +3 -0
  73. package/dist/node_modules/semver/functions/satisfies.js +10 -0
  74. package/dist/node_modules/semver/functions/sort.js +3 -0
  75. package/dist/node_modules/semver/functions/valid.js +6 -0
  76. package/dist/node_modules/semver/index.js +1 -0
  77. package/dist/node_modules/semver/internal/constants.js +35 -0
  78. package/dist/node_modules/semver/internal/debug.js +9 -0
  79. package/dist/node_modules/semver/internal/identifiers.js +23 -0
  80. package/dist/node_modules/semver/internal/lrucache.js +40 -0
  81. package/dist/node_modules/semver/internal/parse-options.js +15 -0
  82. package/dist/node_modules/semver/internal/re.js +217 -0
  83. package/dist/node_modules/semver/package.json +1 -0
  84. package/dist/node_modules/semver/preload.js +2 -0
  85. package/dist/node_modules/semver/range.bnf +16 -0
  86. package/dist/node_modules/semver/ranges/gtr.js +4 -0
  87. package/dist/node_modules/semver/ranges/intersects.js +7 -0
  88. package/dist/node_modules/semver/ranges/ltr.js +4 -0
  89. package/dist/node_modules/semver/ranges/max-satisfying.js +25 -0
  90. package/dist/node_modules/semver/ranges/min-satisfying.js +24 -0
  91. package/dist/node_modules/semver/ranges/min-version.js +61 -0
  92. package/dist/node_modules/semver/ranges/outside.js +80 -0
  93. package/dist/node_modules/semver/ranges/simplify.js +47 -0
  94. package/dist/node_modules/semver/ranges/subset.js +247 -0
  95. package/dist/node_modules/semver/ranges/to-comparators.js +8 -0
  96. package/dist/node_modules/semver/ranges/valid.js +11 -0
  97. package/dist/server/app-migrator.d.ts +16 -0
  98. package/dist/server/app-migrator.js +61 -0
  99. package/dist/server/collection-group-manager.d.ts +4 -0
  100. package/dist/server/collection-group-manager.js +29 -0
  101. package/dist/server/commands/restore-command.d.ts +2 -0
  102. package/dist/server/commands/restore-command.js +67 -0
  103. package/dist/server/dumper.d.ts +71 -0
  104. package/dist/server/dumper.js +421 -0
  105. package/dist/server/errors/restore-check-error.d.ts +3 -0
  106. package/dist/server/errors/restore-check-error.js +32 -0
  107. package/dist/server/field-value-writer.d.ts +9 -0
  108. package/dist/server/field-value-writer.js +99 -0
  109. package/dist/server/index.d.ts +1 -0
  110. package/dist/server/index.js +33 -0
  111. package/dist/server/locale/zh-CN.d.ts +9 -0
  112. package/dist/server/locale/zh-CN.js +30 -0
  113. package/dist/server/resourcers/backup-files.d.ts +25 -0
  114. package/dist/server/resourcers/backup-files.js +206 -0
  115. package/dist/server/restorer.d.ts +35 -0
  116. package/dist/server/restorer.js +320 -0
  117. package/dist/server/server.d.ts +8 -0
  118. package/dist/server/server.js +52 -0
  119. package/dist/server/utils.d.ts +5 -0
  120. package/dist/server/utils.js +78 -0
  121. package/dist/swagger/index.d.ts +392 -0
  122. package/dist/swagger/index.js +447 -0
  123. package/package.json +48 -0
  124. package/server.d.ts +2 -0
  125. package/server.js +1 -0
@@ -0,0 +1,302 @@
1
+ const debug = require('../internal/debug')
2
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
3
+ const { safeRe: re, t } = require('../internal/re')
4
+
5
+ const parseOptions = require('../internal/parse-options')
6
+ const { compareIdentifiers } = require('../internal/identifiers')
7
+ class SemVer {
8
+ constructor (version, options) {
9
+ options = parseOptions(options)
10
+
11
+ if (version instanceof SemVer) {
12
+ if (version.loose === !!options.loose &&
13
+ version.includePrerelease === !!options.includePrerelease) {
14
+ return version
15
+ } else {
16
+ version = version.version
17
+ }
18
+ } else if (typeof version !== 'string') {
19
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
20
+ }
21
+
22
+ if (version.length > MAX_LENGTH) {
23
+ throw new TypeError(
24
+ `version is longer than ${MAX_LENGTH} characters`
25
+ )
26
+ }
27
+
28
+ debug('SemVer', version, options)
29
+ this.options = options
30
+ this.loose = !!options.loose
31
+ // this isn't actually relevant for versions, but keep it so that we
32
+ // don't run into trouble passing this.options around.
33
+ this.includePrerelease = !!options.includePrerelease
34
+
35
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])
36
+
37
+ if (!m) {
38
+ throw new TypeError(`Invalid Version: ${version}`)
39
+ }
40
+
41
+ this.raw = version
42
+
43
+ // these are actually numbers
44
+ this.major = +m[1]
45
+ this.minor = +m[2]
46
+ this.patch = +m[3]
47
+
48
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
49
+ throw new TypeError('Invalid major version')
50
+ }
51
+
52
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
53
+ throw new TypeError('Invalid minor version')
54
+ }
55
+
56
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
57
+ throw new TypeError('Invalid patch version')
58
+ }
59
+
60
+ // numberify any prerelease numeric ids
61
+ if (!m[4]) {
62
+ this.prerelease = []
63
+ } else {
64
+ this.prerelease = m[4].split('.').map((id) => {
65
+ if (/^[0-9]+$/.test(id)) {
66
+ const num = +id
67
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
68
+ return num
69
+ }
70
+ }
71
+ return id
72
+ })
73
+ }
74
+
75
+ this.build = m[5] ? m[5].split('.') : []
76
+ this.format()
77
+ }
78
+
79
+ format () {
80
+ this.version = `${this.major}.${this.minor}.${this.patch}`
81
+ if (this.prerelease.length) {
82
+ this.version += `-${this.prerelease.join('.')}`
83
+ }
84
+ return this.version
85
+ }
86
+
87
+ toString () {
88
+ return this.version
89
+ }
90
+
91
+ compare (other) {
92
+ debug('SemVer.compare', this.version, this.options, other)
93
+ if (!(other instanceof SemVer)) {
94
+ if (typeof other === 'string' && other === this.version) {
95
+ return 0
96
+ }
97
+ other = new SemVer(other, this.options)
98
+ }
99
+
100
+ if (other.version === this.version) {
101
+ return 0
102
+ }
103
+
104
+ return this.compareMain(other) || this.comparePre(other)
105
+ }
106
+
107
+ compareMain (other) {
108
+ if (!(other instanceof SemVer)) {
109
+ other = new SemVer(other, this.options)
110
+ }
111
+
112
+ return (
113
+ compareIdentifiers(this.major, other.major) ||
114
+ compareIdentifiers(this.minor, other.minor) ||
115
+ compareIdentifiers(this.patch, other.patch)
116
+ )
117
+ }
118
+
119
+ comparePre (other) {
120
+ if (!(other instanceof SemVer)) {
121
+ other = new SemVer(other, this.options)
122
+ }
123
+
124
+ // NOT having a prerelease is > having one
125
+ if (this.prerelease.length && !other.prerelease.length) {
126
+ return -1
127
+ } else if (!this.prerelease.length && other.prerelease.length) {
128
+ return 1
129
+ } else if (!this.prerelease.length && !other.prerelease.length) {
130
+ return 0
131
+ }
132
+
133
+ let i = 0
134
+ do {
135
+ const a = this.prerelease[i]
136
+ const b = other.prerelease[i]
137
+ debug('prerelease compare', i, a, b)
138
+ if (a === undefined && b === undefined) {
139
+ return 0
140
+ } else if (b === undefined) {
141
+ return 1
142
+ } else if (a === undefined) {
143
+ return -1
144
+ } else if (a === b) {
145
+ continue
146
+ } else {
147
+ return compareIdentifiers(a, b)
148
+ }
149
+ } while (++i)
150
+ }
151
+
152
+ compareBuild (other) {
153
+ if (!(other instanceof SemVer)) {
154
+ other = new SemVer(other, this.options)
155
+ }
156
+
157
+ let i = 0
158
+ do {
159
+ const a = this.build[i]
160
+ const b = other.build[i]
161
+ debug('build compare', i, a, b)
162
+ if (a === undefined && b === undefined) {
163
+ return 0
164
+ } else if (b === undefined) {
165
+ return 1
166
+ } else if (a === undefined) {
167
+ return -1
168
+ } else if (a === b) {
169
+ continue
170
+ } else {
171
+ return compareIdentifiers(a, b)
172
+ }
173
+ } while (++i)
174
+ }
175
+
176
+ // preminor will bump the version up to the next minor release, and immediately
177
+ // down to pre-release. premajor and prepatch work the same way.
178
+ inc (release, identifier, identifierBase) {
179
+ switch (release) {
180
+ case 'premajor':
181
+ this.prerelease.length = 0
182
+ this.patch = 0
183
+ this.minor = 0
184
+ this.major++
185
+ this.inc('pre', identifier, identifierBase)
186
+ break
187
+ case 'preminor':
188
+ this.prerelease.length = 0
189
+ this.patch = 0
190
+ this.minor++
191
+ this.inc('pre', identifier, identifierBase)
192
+ break
193
+ case 'prepatch':
194
+ // If this is already a prerelease, it will bump to the next version
195
+ // drop any prereleases that might already exist, since they are not
196
+ // relevant at this point.
197
+ this.prerelease.length = 0
198
+ this.inc('patch', identifier, identifierBase)
199
+ this.inc('pre', identifier, identifierBase)
200
+ break
201
+ // If the input is a non-prerelease version, this acts the same as
202
+ // prepatch.
203
+ case 'prerelease':
204
+ if (this.prerelease.length === 0) {
205
+ this.inc('patch', identifier, identifierBase)
206
+ }
207
+ this.inc('pre', identifier, identifierBase)
208
+ break
209
+
210
+ case 'major':
211
+ // If this is a pre-major version, bump up to the same major version.
212
+ // Otherwise increment major.
213
+ // 1.0.0-5 bumps to 1.0.0
214
+ // 1.1.0 bumps to 2.0.0
215
+ if (
216
+ this.minor !== 0 ||
217
+ this.patch !== 0 ||
218
+ this.prerelease.length === 0
219
+ ) {
220
+ this.major++
221
+ }
222
+ this.minor = 0
223
+ this.patch = 0
224
+ this.prerelease = []
225
+ break
226
+ case 'minor':
227
+ // If this is a pre-minor version, bump up to the same minor version.
228
+ // Otherwise increment minor.
229
+ // 1.2.0-5 bumps to 1.2.0
230
+ // 1.2.1 bumps to 1.3.0
231
+ if (this.patch !== 0 || this.prerelease.length === 0) {
232
+ this.minor++
233
+ }
234
+ this.patch = 0
235
+ this.prerelease = []
236
+ break
237
+ case 'patch':
238
+ // If this is not a pre-release version, it will increment the patch.
239
+ // If it is a pre-release it will bump up to the same patch version.
240
+ // 1.2.0-5 patches to 1.2.0
241
+ // 1.2.0 patches to 1.2.1
242
+ if (this.prerelease.length === 0) {
243
+ this.patch++
244
+ }
245
+ this.prerelease = []
246
+ break
247
+ // This probably shouldn't be used publicly.
248
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
249
+ case 'pre': {
250
+ const base = Number(identifierBase) ? 1 : 0
251
+
252
+ if (!identifier && identifierBase === false) {
253
+ throw new Error('invalid increment argument: identifier is empty')
254
+ }
255
+
256
+ if (this.prerelease.length === 0) {
257
+ this.prerelease = [base]
258
+ } else {
259
+ let i = this.prerelease.length
260
+ while (--i >= 0) {
261
+ if (typeof this.prerelease[i] === 'number') {
262
+ this.prerelease[i]++
263
+ i = -2
264
+ }
265
+ }
266
+ if (i === -1) {
267
+ // didn't increment anything
268
+ if (identifier === this.prerelease.join('.') && identifierBase === false) {
269
+ throw new Error('invalid increment argument: identifier already exists')
270
+ }
271
+ this.prerelease.push(base)
272
+ }
273
+ }
274
+ if (identifier) {
275
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
276
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
277
+ let prerelease = [identifier, base]
278
+ if (identifierBase === false) {
279
+ prerelease = [identifier]
280
+ }
281
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
282
+ if (isNaN(this.prerelease[1])) {
283
+ this.prerelease = prerelease
284
+ }
285
+ } else {
286
+ this.prerelease = prerelease
287
+ }
288
+ }
289
+ break
290
+ }
291
+ default:
292
+ throw new Error(`invalid increment argument: ${release}`)
293
+ }
294
+ this.raw = this.format()
295
+ if (this.build.length) {
296
+ this.raw += `+${this.build.join('.')}`
297
+ }
298
+ return this
299
+ }
300
+ }
301
+
302
+ module.exports = SemVer
@@ -0,0 +1,6 @@
1
+ const parse = require('./parse')
2
+ const clean = (version, options) => {
3
+ const s = parse(version.trim().replace(/^[=v]+/, ''), options)
4
+ return s ? s.version : null
5
+ }
6
+ module.exports = clean
@@ -0,0 +1,52 @@
1
+ const eq = require('./eq')
2
+ const neq = require('./neq')
3
+ const gt = require('./gt')
4
+ const gte = require('./gte')
5
+ const lt = require('./lt')
6
+ const lte = require('./lte')
7
+
8
+ const cmp = (a, op, b, loose) => {
9
+ switch (op) {
10
+ case '===':
11
+ if (typeof a === 'object') {
12
+ a = a.version
13
+ }
14
+ if (typeof b === 'object') {
15
+ b = b.version
16
+ }
17
+ return a === b
18
+
19
+ case '!==':
20
+ if (typeof a === 'object') {
21
+ a = a.version
22
+ }
23
+ if (typeof b === 'object') {
24
+ b = b.version
25
+ }
26
+ return a !== b
27
+
28
+ case '':
29
+ case '=':
30
+ case '==':
31
+ return eq(a, b, loose)
32
+
33
+ case '!=':
34
+ return neq(a, b, loose)
35
+
36
+ case '>':
37
+ return gt(a, b, loose)
38
+
39
+ case '>=':
40
+ return gte(a, b, loose)
41
+
42
+ case '<':
43
+ return lt(a, b, loose)
44
+
45
+ case '<=':
46
+ return lte(a, b, loose)
47
+
48
+ default:
49
+ throw new TypeError(`Invalid operator: ${op}`)
50
+ }
51
+ }
52
+ module.exports = cmp
@@ -0,0 +1,60 @@
1
+ const SemVer = require('../classes/semver')
2
+ const parse = require('./parse')
3
+ const { safeRe: re, t } = require('../internal/re')
4
+
5
+ const coerce = (version, options) => {
6
+ if (version instanceof SemVer) {
7
+ return version
8
+ }
9
+
10
+ if (typeof version === 'number') {
11
+ version = String(version)
12
+ }
13
+
14
+ if (typeof version !== 'string') {
15
+ return null
16
+ }
17
+
18
+ options = options || {}
19
+
20
+ let match = null
21
+ if (!options.rtl) {
22
+ match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE])
23
+ } else {
24
+ // Find the right-most coercible string that does not share
25
+ // a terminus with a more left-ward coercible string.
26
+ // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
27
+ // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'
28
+ //
29
+ // Walk through the string checking with a /g regexp
30
+ // Manually set the index so as to pick up overlapping matches.
31
+ // Stop when we get a match that ends at the string end, since no
32
+ // coercible string can be more right-ward without the same terminus.
33
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL]
34
+ let next
35
+ while ((next = coerceRtlRegex.exec(version)) &&
36
+ (!match || match.index + match[0].length !== version.length)
37
+ ) {
38
+ if (!match ||
39
+ next.index + next[0].length !== match.index + match[0].length) {
40
+ match = next
41
+ }
42
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length
43
+ }
44
+ // leave it in a clean state
45
+ coerceRtlRegex.lastIndex = -1
46
+ }
47
+
48
+ if (match === null) {
49
+ return null
50
+ }
51
+
52
+ const major = match[2]
53
+ const minor = match[3] || '0'
54
+ const patch = match[4] || '0'
55
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ''
56
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : ''
57
+
58
+ return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)
59
+ }
60
+ module.exports = coerce
@@ -0,0 +1,7 @@
1
+ const SemVer = require('../classes/semver')
2
+ const compareBuild = (a, b, loose) => {
3
+ const versionA = new SemVer(a, loose)
4
+ const versionB = new SemVer(b, loose)
5
+ return versionA.compare(versionB) || versionA.compareBuild(versionB)
6
+ }
7
+ module.exports = compareBuild
@@ -0,0 +1,3 @@
1
+ const compare = require('./compare')
2
+ const compareLoose = (a, b) => compare(a, b, true)
3
+ module.exports = compareLoose
@@ -0,0 +1,5 @@
1
+ const SemVer = require('../classes/semver')
2
+ const compare = (a, b, loose) =>
3
+ new SemVer(a, loose).compare(new SemVer(b, loose))
4
+
5
+ module.exports = compare
@@ -0,0 +1,65 @@
1
+ const parse = require('./parse.js')
2
+
3
+ const diff = (version1, version2) => {
4
+ const v1 = parse(version1, null, true)
5
+ const v2 = parse(version2, null, true)
6
+ const comparison = v1.compare(v2)
7
+
8
+ if (comparison === 0) {
9
+ return null
10
+ }
11
+
12
+ const v1Higher = comparison > 0
13
+ const highVersion = v1Higher ? v1 : v2
14
+ const lowVersion = v1Higher ? v2 : v1
15
+ const highHasPre = !!highVersion.prerelease.length
16
+ const lowHasPre = !!lowVersion.prerelease.length
17
+
18
+ if (lowHasPre && !highHasPre) {
19
+ // Going from prerelease -> no prerelease requires some special casing
20
+
21
+ // If the low version has only a major, then it will always be a major
22
+ // Some examples:
23
+ // 1.0.0-1 -> 1.0.0
24
+ // 1.0.0-1 -> 1.1.1
25
+ // 1.0.0-1 -> 2.0.0
26
+ if (!lowVersion.patch && !lowVersion.minor) {
27
+ return 'major'
28
+ }
29
+
30
+ // Otherwise it can be determined by checking the high version
31
+
32
+ if (highVersion.patch) {
33
+ // anything higher than a patch bump would result in the wrong version
34
+ return 'patch'
35
+ }
36
+
37
+ if (highVersion.minor) {
38
+ // anything higher than a minor bump would result in the wrong version
39
+ return 'minor'
40
+ }
41
+
42
+ // bumping major/minor/patch all have same result
43
+ return 'major'
44
+ }
45
+
46
+ // add the `pre` prefix if we are going to a prerelease version
47
+ const prefix = highHasPre ? 'pre' : ''
48
+
49
+ if (v1.major !== v2.major) {
50
+ return prefix + 'major'
51
+ }
52
+
53
+ if (v1.minor !== v2.minor) {
54
+ return prefix + 'minor'
55
+ }
56
+
57
+ if (v1.patch !== v2.patch) {
58
+ return prefix + 'patch'
59
+ }
60
+
61
+ // high and low are preleases
62
+ return 'prerelease'
63
+ }
64
+
65
+ module.exports = diff
@@ -0,0 +1,3 @@
1
+ const compare = require('./compare')
2
+ const eq = (a, b, loose) => compare(a, b, loose) === 0
3
+ module.exports = eq
@@ -0,0 +1,3 @@
1
+ const compare = require('./compare')
2
+ const gt = (a, b, loose) => compare(a, b, loose) > 0
3
+ module.exports = gt
@@ -0,0 +1,3 @@
1
+ const compare = require('./compare')
2
+ const gte = (a, b, loose) => compare(a, b, loose) >= 0
3
+ module.exports = gte
@@ -0,0 +1,19 @@
1
+ const SemVer = require('../classes/semver')
2
+
3
+ const inc = (version, release, options, identifier, identifierBase) => {
4
+ if (typeof (options) === 'string') {
5
+ identifierBase = identifier
6
+ identifier = options
7
+ options = undefined
8
+ }
9
+
10
+ try {
11
+ return new SemVer(
12
+ version instanceof SemVer ? version.version : version,
13
+ options
14
+ ).inc(release, identifier, identifierBase).version
15
+ } catch (er) {
16
+ return null
17
+ }
18
+ }
19
+ module.exports = inc
@@ -0,0 +1,3 @@
1
+ const compare = require('./compare')
2
+ const lt = (a, b, loose) => compare(a, b, loose) < 0
3
+ module.exports = lt
@@ -0,0 +1,3 @@
1
+ const compare = require('./compare')
2
+ const lte = (a, b, loose) => compare(a, b, loose) <= 0
3
+ module.exports = lte
@@ -0,0 +1,3 @@
1
+ const SemVer = require('../classes/semver')
2
+ const major = (a, loose) => new SemVer(a, loose).major
3
+ module.exports = major
@@ -0,0 +1,3 @@
1
+ const SemVer = require('../classes/semver')
2
+ const minor = (a, loose) => new SemVer(a, loose).minor
3
+ module.exports = minor
@@ -0,0 +1,3 @@
1
+ const compare = require('./compare')
2
+ const neq = (a, b, loose) => compare(a, b, loose) !== 0
3
+ module.exports = neq
@@ -0,0 +1,16 @@
1
+ const SemVer = require('../classes/semver')
2
+ const parse = (version, options, throwErrors = false) => {
3
+ if (version instanceof SemVer) {
4
+ return version
5
+ }
6
+ try {
7
+ return new SemVer(version, options)
8
+ } catch (er) {
9
+ if (!throwErrors) {
10
+ return null
11
+ }
12
+ throw er
13
+ }
14
+ }
15
+
16
+ module.exports = parse
@@ -0,0 +1,3 @@
1
+ const SemVer = require('../classes/semver')
2
+ const patch = (a, loose) => new SemVer(a, loose).patch
3
+ module.exports = patch
@@ -0,0 +1,6 @@
1
+ const parse = require('./parse')
2
+ const prerelease = (version, options) => {
3
+ const parsed = parse(version, options)
4
+ return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
5
+ }
6
+ module.exports = prerelease
@@ -0,0 +1,3 @@
1
+ const compare = require('./compare')
2
+ const rcompare = (a, b, loose) => compare(b, a, loose)
3
+ module.exports = rcompare
@@ -0,0 +1,3 @@
1
+ const compareBuild = require('./compare-build')
2
+ const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose))
3
+ module.exports = rsort
@@ -0,0 +1,10 @@
1
+ const Range = require('../classes/range')
2
+ const satisfies = (version, range, options) => {
3
+ try {
4
+ range = new Range(range, options)
5
+ } catch (er) {
6
+ return false
7
+ }
8
+ return range.test(version)
9
+ }
10
+ module.exports = satisfies
@@ -0,0 +1,3 @@
1
+ const compareBuild = require('./compare-build')
2
+ const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))
3
+ module.exports = sort
@@ -0,0 +1,6 @@
1
+ const parse = require('./parse')
2
+ const valid = (version, options) => {
3
+ const v = parse(version, options)
4
+ return v ? v.version : null
5
+ }
6
+ module.exports = valid