@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,64 @@
1
+ const {dirname} = require('path')
2
+
3
+ const mkdirpManual = (path, opts, made) => {
4
+ opts.recursive = false
5
+ const parent = dirname(path)
6
+ if (parent === path) {
7
+ return opts.mkdirAsync(path, opts).catch(er => {
8
+ // swallowed by recursive implementation on posix systems
9
+ // any other error is a failure
10
+ if (er.code !== 'EISDIR')
11
+ throw er
12
+ })
13
+ }
14
+
15
+ return opts.mkdirAsync(path, opts).then(() => made || path, er => {
16
+ if (er.code === 'ENOENT')
17
+ return mkdirpManual(parent, opts)
18
+ .then(made => mkdirpManual(path, opts, made))
19
+ if (er.code !== 'EEXIST' && er.code !== 'EROFS')
20
+ throw er
21
+ return opts.statAsync(path).then(st => {
22
+ if (st.isDirectory())
23
+ return made
24
+ else
25
+ throw er
26
+ }, () => { throw er })
27
+ })
28
+ }
29
+
30
+ const mkdirpManualSync = (path, opts, made) => {
31
+ const parent = dirname(path)
32
+ opts.recursive = false
33
+
34
+ if (parent === path) {
35
+ try {
36
+ return opts.mkdirSync(path, opts)
37
+ } catch (er) {
38
+ // swallowed by recursive implementation on posix systems
39
+ // any other error is a failure
40
+ if (er.code !== 'EISDIR')
41
+ throw er
42
+ else
43
+ return
44
+ }
45
+ }
46
+
47
+ try {
48
+ opts.mkdirSync(path, opts)
49
+ return made || path
50
+ } catch (er) {
51
+ if (er.code === 'ENOENT')
52
+ return mkdirpManualSync(path, opts, mkdirpManualSync(parent, opts, made))
53
+ if (er.code !== 'EEXIST' && er.code !== 'EROFS')
54
+ throw er
55
+ try {
56
+ if (!opts.statSync(path).isDirectory())
57
+ throw er
58
+ } catch (_) {
59
+ throw er
60
+ }
61
+ }
62
+ }
63
+
64
+ module.exports = {mkdirpManual, mkdirpManualSync}
@@ -0,0 +1,39 @@
1
+ const {dirname} = require('path')
2
+ const {findMade, findMadeSync} = require('./find-made.js')
3
+ const {mkdirpManual, mkdirpManualSync} = require('./mkdirp-manual.js')
4
+
5
+ const mkdirpNative = (path, opts) => {
6
+ opts.recursive = true
7
+ const parent = dirname(path)
8
+ if (parent === path)
9
+ return opts.mkdirAsync(path, opts)
10
+
11
+ return findMade(opts, path).then(made =>
12
+ opts.mkdirAsync(path, opts).then(() => made)
13
+ .catch(er => {
14
+ if (er.code === 'ENOENT')
15
+ return mkdirpManual(path, opts)
16
+ else
17
+ throw er
18
+ }))
19
+ }
20
+
21
+ const mkdirpNativeSync = (path, opts) => {
22
+ opts.recursive = true
23
+ const parent = dirname(path)
24
+ if (parent === path)
25
+ return opts.mkdirSync(path, opts)
26
+
27
+ const made = findMadeSync(opts, path)
28
+ try {
29
+ opts.mkdirSync(path, opts)
30
+ return made
31
+ } catch (er) {
32
+ if (er.code === 'ENOENT')
33
+ return mkdirpManualSync(path, opts)
34
+ else
35
+ throw er
36
+ }
37
+ }
38
+
39
+ module.exports = {mkdirpNative, mkdirpNativeSync}
@@ -0,0 +1,23 @@
1
+ const { promisify } = require('util')
2
+ const fs = require('fs')
3
+ const optsArg = opts => {
4
+ if (!opts)
5
+ opts = { mode: 0o777, fs }
6
+ else if (typeof opts === 'object')
7
+ opts = { mode: 0o777, fs, ...opts }
8
+ else if (typeof opts === 'number')
9
+ opts = { mode: opts, fs }
10
+ else if (typeof opts === 'string')
11
+ opts = { mode: parseInt(opts, 8), fs }
12
+ else
13
+ throw new TypeError('invalid options argument')
14
+
15
+ opts.mkdir = opts.mkdir || opts.fs.mkdir || fs.mkdir
16
+ opts.mkdirAsync = promisify(opts.mkdir)
17
+ opts.stat = opts.stat || opts.fs.stat || fs.stat
18
+ opts.statAsync = promisify(opts.stat)
19
+ opts.statSync = opts.statSync || opts.fs.statSync || fs.statSync
20
+ opts.mkdirSync = opts.mkdirSync || opts.fs.mkdirSync || fs.mkdirSync
21
+ return opts
22
+ }
23
+ module.exports = optsArg
@@ -0,0 +1,29 @@
1
+ const platform = process.env.__TESTING_MKDIRP_PLATFORM__ || process.platform
2
+ const { resolve, parse } = require('path')
3
+ const pathArg = path => {
4
+ if (/\0/.test(path)) {
5
+ // simulate same failure that node raises
6
+ throw Object.assign(
7
+ new TypeError('path must be a string without null bytes'),
8
+ {
9
+ path,
10
+ code: 'ERR_INVALID_ARG_VALUE',
11
+ }
12
+ )
13
+ }
14
+
15
+ path = resolve(path)
16
+ if (platform === 'win32') {
17
+ const badWinChars = /[*|"<>?:]/
18
+ const {root} = parse(path)
19
+ if (badWinChars.test(path.substr(root.length))) {
20
+ throw Object.assign(new Error('Illegal characters in path.'), {
21
+ path,
22
+ code: 'EINVAL',
23
+ })
24
+ }
25
+ }
26
+
27
+ return path
28
+ }
29
+ module.exports = pathArg
@@ -0,0 +1,10 @@
1
+ const fs = require('fs')
2
+
3
+ const version = process.env.__TESTING_MKDIRP_NODE_VERSION__ || process.version
4
+ const versArr = version.replace(/^v/, '').split('.')
5
+ const hasNative = +versArr[0] > 10 || +versArr[0] === 10 && +versArr[1] >= 12
6
+
7
+ const useNative = !hasNative ? () => false : opts => opts.mkdir === fs.mkdir
8
+ const useNativeSync = !hasNative ? () => false : opts => opts.mkdirSync === fs.mkdirSync
9
+
10
+ module.exports = {useNative, useNativeSync}
@@ -0,0 +1 @@
1
+ {"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"1.0.4","main":"index.js","keywords":["mkdir","directory","make dir","make","dir","recursive","native"],"repository":{"type":"git","url":"https://github.com/isaacs/node-mkdirp.git"},"scripts":{"test":"tap","snap":"tap","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --follow-tags"},"tap":{"check-coverage":true,"coverage-map":"map.js"},"devDependencies":{"require-inject":"^1.4.4","tap":"^14.10.7"},"bin":"bin/cmd.js","license":"MIT","engines":{"node":">=10"},"files":["bin","lib","index.js"],"_lastModified":"2024-12-22T16:01:08.096Z"}
@@ -0,0 +1,266 @@
1
+ # mkdirp
2
+
3
+ Like `mkdir -p`, but in Node.js!
4
+
5
+ Now with a modern API and no\* bugs!
6
+
7
+ <small>\* may contain some bugs</small>
8
+
9
+ # example
10
+
11
+ ## pow.js
12
+
13
+ ```js
14
+ const mkdirp = require('mkdirp')
15
+
16
+ // return value is a Promise resolving to the first directory created
17
+ mkdirp('/tmp/foo/bar/baz').then(made =>
18
+ console.log(`made directories, starting with ${made}`))
19
+ ```
20
+
21
+ Output (where `/tmp/foo` already exists)
22
+
23
+ ```
24
+ made directories, starting with /tmp/foo/bar
25
+ ```
26
+
27
+ Or, if you don't have time to wait around for promises:
28
+
29
+ ```js
30
+ const mkdirp = require('mkdirp')
31
+
32
+ // return value is the first directory created
33
+ const made = mkdirp.sync('/tmp/foo/bar/baz')
34
+ console.log(`made directories, starting with ${made}`)
35
+ ```
36
+
37
+ And now /tmp/foo/bar/baz exists, huzzah!
38
+
39
+ # methods
40
+
41
+ ```js
42
+ const mkdirp = require('mkdirp')
43
+ ```
44
+
45
+ ## mkdirp(dir, [opts]) -> Promise<String | undefined>
46
+
47
+ Create a new directory and any necessary subdirectories at `dir` with octal
48
+ permission string `opts.mode`. If `opts` is a string or number, it will be
49
+ treated as the `opts.mode`.
50
+
51
+ If `opts.mode` isn't specified, it defaults to `0o777 &
52
+ (~process.umask())`.
53
+
54
+ Promise resolves to first directory `made` that had to be created, or
55
+ `undefined` if everything already exists. Promise rejects if any errors
56
+ are encountered. Note that, in the case of promise rejection, some
57
+ directories _may_ have been created, as recursive directory creation is not
58
+ an atomic operation.
59
+
60
+ You can optionally pass in an alternate `fs` implementation by passing in
61
+ `opts.fs`. Your implementation should have `opts.fs.mkdir(path, opts, cb)`
62
+ and `opts.fs.stat(path, cb)`.
63
+
64
+ You can also override just one or the other of `mkdir` and `stat` by
65
+ passing in `opts.stat` or `opts.mkdir`, or providing an `fs` option that
66
+ only overrides one of these.
67
+
68
+ ## mkdirp.sync(dir, opts) -> String|null
69
+
70
+ Synchronously create a new directory and any necessary subdirectories at
71
+ `dir` with octal permission string `opts.mode`. If `opts` is a string or
72
+ number, it will be treated as the `opts.mode`.
73
+
74
+ If `opts.mode` isn't specified, it defaults to `0o777 &
75
+ (~process.umask())`.
76
+
77
+ Returns the first directory that had to be created, or undefined if
78
+ everything already exists.
79
+
80
+ You can optionally pass in an alternate `fs` implementation by passing in
81
+ `opts.fs`. Your implementation should have `opts.fs.mkdirSync(path, mode)`
82
+ and `opts.fs.statSync(path)`.
83
+
84
+ You can also override just one or the other of `mkdirSync` and `statSync`
85
+ by passing in `opts.statSync` or `opts.mkdirSync`, or providing an `fs`
86
+ option that only overrides one of these.
87
+
88
+ ## mkdirp.manual, mkdirp.manualSync
89
+
90
+ Use the manual implementation (not the native one). This is the default
91
+ when the native implementation is not available or the stat/mkdir
92
+ implementation is overridden.
93
+
94
+ ## mkdirp.native, mkdirp.nativeSync
95
+
96
+ Use the native implementation (not the manual one). This is the default
97
+ when the native implementation is available and stat/mkdir are not
98
+ overridden.
99
+
100
+ # implementation
101
+
102
+ On Node.js v10.12.0 and above, use the native `fs.mkdir(p,
103
+ {recursive:true})` option, unless `fs.mkdir`/`fs.mkdirSync` has been
104
+ overridden by an option.
105
+
106
+ ## native implementation
107
+
108
+ - If the path is a root directory, then pass it to the underlying
109
+ implementation and return the result/error. (In this case, it'll either
110
+ succeed or fail, but we aren't actually creating any dirs.)
111
+ - Walk up the path statting each directory, to find the first path that
112
+ will be created, `made`.
113
+ - Call `fs.mkdir(path, { recursive: true })` (or `fs.mkdirSync`)
114
+ - If error, raise it to the caller.
115
+ - Return `made`.
116
+
117
+ ## manual implementation
118
+
119
+ - Call underlying `fs.mkdir` implementation, with `recursive: false`
120
+ - If error:
121
+ - If path is a root directory, raise to the caller and do not handle it
122
+ - If ENOENT, mkdirp parent dir, store result as `made`
123
+ - stat(path)
124
+ - If error, raise original `mkdir` error
125
+ - If directory, return `made`
126
+ - Else, raise original `mkdir` error
127
+ - else
128
+ - return `undefined` if a root dir, or `made` if set, or `path`
129
+
130
+ ## windows vs unix caveat
131
+
132
+ On Windows file systems, attempts to create a root directory (ie, a drive
133
+ letter or root UNC path) will fail. If the root directory exists, then it
134
+ will fail with `EPERM`. If the root directory does not exist, then it will
135
+ fail with `ENOENT`.
136
+
137
+ On posix file systems, attempts to create a root directory (in recursive
138
+ mode) will succeed silently, as it is treated like just another directory
139
+ that already exists. (In non-recursive mode, of course, it fails with
140
+ `EEXIST`.)
141
+
142
+ In order to preserve this system-specific behavior (and because it's not as
143
+ if we can create the parent of a root directory anyway), attempts to create
144
+ a root directory are passed directly to the `fs` implementation, and any
145
+ errors encountered are not handled.
146
+
147
+ ## native error caveat
148
+
149
+ The native implementation (as of at least Node.js v13.4.0) does not provide
150
+ appropriate errors in some cases (see
151
+ [nodejs/node#31481](https://github.com/nodejs/node/issues/31481) and
152
+ [nodejs/node#28015](https://github.com/nodejs/node/issues/28015)).
153
+
154
+ In order to work around this issue, the native implementation will fall
155
+ back to the manual implementation if an `ENOENT` error is encountered.
156
+
157
+ # choosing a recursive mkdir implementation
158
+
159
+ There are a few to choose from! Use the one that suits your needs best :D
160
+
161
+ ## use `fs.mkdir(path, {recursive: true}, cb)` if:
162
+
163
+ - You wish to optimize performance even at the expense of other factors.
164
+ - You don't need to know the first dir created.
165
+ - You are ok with getting `ENOENT` as the error when some other problem is
166
+ the actual cause.
167
+ - You can limit your platforms to Node.js v10.12 and above.
168
+ - You're ok with using callbacks instead of promises.
169
+ - You don't need/want a CLI.
170
+ - You don't need to override the `fs` methods in use.
171
+
172
+ ## use this module (mkdirp 1.x) if:
173
+
174
+ - You need to know the first directory that was created.
175
+ - You wish to use the native implementation if available, but fall back
176
+ when it's not.
177
+ - You prefer promise-returning APIs to callback-taking APIs.
178
+ - You want more useful error messages than the native recursive mkdir
179
+ provides (at least as of Node.js v13.4), and are ok with re-trying on
180
+ `ENOENT` to achieve this.
181
+ - You need (or at least, are ok with) a CLI.
182
+ - You need to override the `fs` methods in use.
183
+
184
+ ## use [`make-dir`](http://npm.im/make-dir) if:
185
+
186
+ - You do not need to know the first dir created (and wish to save a few
187
+ `stat` calls when using the native implementation for this reason).
188
+ - You wish to use the native implementation if available, but fall back
189
+ when it's not.
190
+ - You prefer promise-returning APIs to callback-taking APIs.
191
+ - You are ok with occasionally getting `ENOENT` errors for failures that
192
+ are actually related to something other than a missing file system entry.
193
+ - You don't need/want a CLI.
194
+ - You need to override the `fs` methods in use.
195
+
196
+ ## use mkdirp 0.x if:
197
+
198
+ - You need to know the first directory that was created.
199
+ - You need (or at least, are ok with) a CLI.
200
+ - You need to override the `fs` methods in use.
201
+ - You're ok with using callbacks instead of promises.
202
+ - You are not running on Windows, where the root-level ENOENT errors can
203
+ lead to infinite regress.
204
+ - You think vinyl just sounds warmer and richer for some weird reason.
205
+ - You are supporting truly ancient Node.js versions, before even the advent
206
+ of a `Promise` language primitive. (Please don't. You deserve better.)
207
+
208
+ # cli
209
+
210
+ This package also ships with a `mkdirp` command.
211
+
212
+ ```
213
+ $ mkdirp -h
214
+
215
+ usage: mkdirp [DIR1,DIR2..] {OPTIONS}
216
+
217
+ Create each supplied directory including any necessary parent directories
218
+ that don't yet exist.
219
+
220
+ If the directory already exists, do nothing.
221
+
222
+ OPTIONS are:
223
+
224
+ -m<mode> If a directory needs to be created, set the mode as an octal
225
+ --mode=<mode> permission string.
226
+
227
+ -v --version Print the mkdirp version number
228
+
229
+ -h --help Print this helpful banner
230
+
231
+ -p --print Print the first directories created for each path provided
232
+
233
+ --manual Use manual implementation, even if native is available
234
+ ```
235
+
236
+ # install
237
+
238
+ With [npm](http://npmjs.org) do:
239
+
240
+ ```
241
+ npm install mkdirp
242
+ ```
243
+
244
+ to get the library locally, or
245
+
246
+ ```
247
+ npm install -g mkdirp
248
+ ```
249
+
250
+ to get the command everywhere, or
251
+
252
+ ```
253
+ npx mkdirp ...
254
+ ```
255
+
256
+ to run the command without installing it globally.
257
+
258
+ # platform support
259
+
260
+ This module works on node v8, but only v10 and above are officially
261
+ supported, as Node v8 reached its LTS end of life 2020-01-01, which is in
262
+ the past, as of this writing.
263
+
264
+ # license
265
+
266
+ MIT
@@ -0,0 +1,15 @@
1
+ The ISC License
2
+
3
+ Copyright (c) Isaac Z. Schlueter and Contributors
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15
+ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,188 @@
1
+ #!/usr/bin/env node
2
+ // Standalone semver comparison program.
3
+ // Exits successfully and prints matching version(s) if
4
+ // any supplied version is valid and passes all tests.
5
+
6
+ const argv = process.argv.slice(2)
7
+
8
+ let versions = []
9
+
10
+ const range = []
11
+
12
+ let inc = null
13
+
14
+ const version = require('../package.json').version
15
+
16
+ let loose = false
17
+
18
+ let includePrerelease = false
19
+
20
+ let coerce = false
21
+
22
+ let rtl = false
23
+
24
+ let identifier
25
+
26
+ let identifierBase
27
+
28
+ const semver = require('../')
29
+ const parseOptions = require('../internal/parse-options')
30
+
31
+ let reverse = false
32
+
33
+ let options = {}
34
+
35
+ const main = () => {
36
+ if (!argv.length) {
37
+ return help()
38
+ }
39
+ while (argv.length) {
40
+ let a = argv.shift()
41
+ const indexOfEqualSign = a.indexOf('=')
42
+ if (indexOfEqualSign !== -1) {
43
+ const value = a.slice(indexOfEqualSign + 1)
44
+ a = a.slice(0, indexOfEqualSign)
45
+ argv.unshift(value)
46
+ }
47
+ switch (a) {
48
+ case '-rv': case '-rev': case '--rev': case '--reverse':
49
+ reverse = true
50
+ break
51
+ case '-l': case '--loose':
52
+ loose = true
53
+ break
54
+ case '-p': case '--include-prerelease':
55
+ includePrerelease = true
56
+ break
57
+ case '-v': case '--version':
58
+ versions.push(argv.shift())
59
+ break
60
+ case '-i': case '--inc': case '--increment':
61
+ switch (argv[0]) {
62
+ case 'major': case 'minor': case 'patch': case 'prerelease':
63
+ case 'premajor': case 'preminor': case 'prepatch':
64
+ inc = argv.shift()
65
+ break
66
+ default:
67
+ inc = 'patch'
68
+ break
69
+ }
70
+ break
71
+ case '--preid':
72
+ identifier = argv.shift()
73
+ break
74
+ case '-r': case '--range':
75
+ range.push(argv.shift())
76
+ break
77
+ case '-n':
78
+ identifierBase = argv.shift()
79
+ if (identifierBase === 'false') {
80
+ identifierBase = false
81
+ }
82
+ break
83
+ case '-c': case '--coerce':
84
+ coerce = true
85
+ break
86
+ case '--rtl':
87
+ rtl = true
88
+ break
89
+ case '--ltr':
90
+ rtl = false
91
+ break
92
+ case '-h': case '--help': case '-?':
93
+ return help()
94
+ default:
95
+ versions.push(a)
96
+ break
97
+ }
98
+ }
99
+
100
+ options = parseOptions({ loose, includePrerelease, rtl })
101
+
102
+ versions = versions.map((v) => {
103
+ return coerce ? (semver.coerce(v, options) || { version: v }).version : v
104
+ }).filter((v) => {
105
+ return semver.valid(v)
106
+ })
107
+ if (!versions.length) {
108
+ return fail()
109
+ }
110
+ if (inc && (versions.length !== 1 || range.length)) {
111
+ return failInc()
112
+ }
113
+
114
+ for (let i = 0, l = range.length; i < l; i++) {
115
+ versions = versions.filter((v) => {
116
+ return semver.satisfies(v, range[i], options)
117
+ })
118
+ if (!versions.length) {
119
+ return fail()
120
+ }
121
+ }
122
+ versions
123
+ .sort((a, b) => semver[reverse ? 'rcompare' : 'compare'](a, b, options))
124
+ .map(v => semver.clean(v, options))
125
+ .map(v => inc ? semver.inc(v, inc, options, identifier, identifierBase) : v)
126
+ .forEach(v => console.log(v))
127
+ }
128
+
129
+ const failInc = () => {
130
+ console.error('--inc can only be used on a single version with no range')
131
+ fail()
132
+ }
133
+
134
+ const fail = () => process.exit(1)
135
+
136
+ const help = () => console.log(
137
+ `SemVer ${version}
138
+
139
+ A JavaScript implementation of the https://semver.org/ specification
140
+ Copyright Isaac Z. Schlueter
141
+
142
+ Usage: semver [options] <version> [<version> [...]]
143
+ Prints valid versions sorted by SemVer precedence
144
+
145
+ Options:
146
+ -r --range <range>
147
+ Print versions that match the specified range.
148
+
149
+ -i --increment [<level>]
150
+ Increment a version by the specified level. Level can
151
+ be one of: major, minor, patch, premajor, preminor,
152
+ prepatch, or prerelease. Default level is 'patch'.
153
+ Only one version may be specified.
154
+
155
+ --preid <identifier>
156
+ Identifier to be used to prefix premajor, preminor,
157
+ prepatch or prerelease version increments.
158
+
159
+ -l --loose
160
+ Interpret versions and ranges loosely
161
+
162
+ -p --include-prerelease
163
+ Always include prerelease versions in range matching
164
+
165
+ -c --coerce
166
+ Coerce a string into SemVer if possible
167
+ (does not imply --loose)
168
+
169
+ --rtl
170
+ Coerce version strings right to left
171
+
172
+ --ltr
173
+ Coerce version strings left to right (default)
174
+
175
+ -n <base>
176
+ Base number to be used for the prerelease identifier.
177
+ Can be either 0 or 1, or false to omit the number altogether.
178
+ Defaults to 0.
179
+
180
+ Program exits successfully if any valid version satisfies
181
+ all supplied ranges, and prints all satisfying versions.
182
+
183
+ If no satisfying versions are found, then exits failure.
184
+
185
+ Versions are printed in ascending order, so supplying
186
+ multiple versions to the utility will just sort them.`)
187
+
188
+ main()