@nocobase/plugin-field-markdown-vditor 1.5.8 → 1.5.10
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/dist/externalVersion.js +4 -4
- package/dist/node_modules/fs-extra/LICENSE +15 -0
- package/dist/node_modules/fs-extra/lib/copy/copy.js +232 -0
- package/dist/node_modules/fs-extra/lib/copy/index.js +6 -0
- package/dist/node_modules/fs-extra/lib/copy-sync/copy-sync.js +166 -0
- package/dist/node_modules/fs-extra/lib/copy-sync/index.js +5 -0
- package/dist/node_modules/fs-extra/lib/empty/index.js +48 -0
- package/dist/node_modules/fs-extra/lib/ensure/file.js +69 -0
- package/dist/node_modules/fs-extra/lib/ensure/index.js +23 -0
- package/dist/node_modules/fs-extra/lib/ensure/link.js +61 -0
- package/dist/node_modules/fs-extra/lib/ensure/symlink-paths.js +99 -0
- package/dist/node_modules/fs-extra/lib/ensure/symlink-type.js +31 -0
- package/dist/node_modules/fs-extra/lib/ensure/symlink.js +63 -0
- package/dist/node_modules/fs-extra/lib/fs/index.js +130 -0
- package/dist/node_modules/fs-extra/lib/index.js +1 -0
- package/dist/node_modules/fs-extra/lib/json/index.js +16 -0
- package/dist/node_modules/fs-extra/lib/json/jsonfile.js +11 -0
- package/dist/node_modules/fs-extra/lib/json/output-json-sync.js +12 -0
- package/dist/node_modules/fs-extra/lib/json/output-json.js +12 -0
- package/dist/node_modules/fs-extra/lib/mkdirs/index.js +14 -0
- package/dist/node_modules/fs-extra/lib/mkdirs/make-dir.js +141 -0
- package/dist/node_modules/fs-extra/lib/move/index.js +6 -0
- package/dist/node_modules/fs-extra/lib/move/move.js +65 -0
- package/dist/node_modules/fs-extra/lib/move-sync/index.js +5 -0
- package/dist/node_modules/fs-extra/lib/move-sync/move-sync.js +47 -0
- package/dist/node_modules/fs-extra/lib/output/index.js +40 -0
- package/dist/node_modules/fs-extra/lib/path-exists/index.js +12 -0
- package/dist/node_modules/fs-extra/lib/remove/index.js +9 -0
- package/dist/node_modules/fs-extra/lib/remove/rimraf.js +302 -0
- package/dist/node_modules/fs-extra/lib/util/stat.js +139 -0
- package/dist/node_modules/fs-extra/lib/util/utimes.js +26 -0
- package/dist/node_modules/fs-extra/package.json +1 -0
- package/dist/server/plugin.d.ts +1 -0
- package/dist/server/plugin.js +21 -0
- package/package.json +2 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('graceful-fs')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const copy = require('../copy').copy
|
|
6
|
+
const remove = require('../remove').remove
|
|
7
|
+
const mkdirp = require('../mkdirs').mkdirp
|
|
8
|
+
const pathExists = require('../path-exists').pathExists
|
|
9
|
+
const stat = require('../util/stat')
|
|
10
|
+
|
|
11
|
+
function move (src, dest, opts, cb) {
|
|
12
|
+
if (typeof opts === 'function') {
|
|
13
|
+
cb = opts
|
|
14
|
+
opts = {}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const overwrite = opts.overwrite || opts.clobber || false
|
|
18
|
+
|
|
19
|
+
stat.checkPaths(src, dest, 'move', (err, stats) => {
|
|
20
|
+
if (err) return cb(err)
|
|
21
|
+
const { srcStat } = stats
|
|
22
|
+
stat.checkParentPaths(src, srcStat, dest, 'move', err => {
|
|
23
|
+
if (err) return cb(err)
|
|
24
|
+
mkdirp(path.dirname(dest), err => {
|
|
25
|
+
if (err) return cb(err)
|
|
26
|
+
return doRename(src, dest, overwrite, cb)
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function doRename (src, dest, overwrite, cb) {
|
|
33
|
+
if (overwrite) {
|
|
34
|
+
return remove(dest, err => {
|
|
35
|
+
if (err) return cb(err)
|
|
36
|
+
return rename(src, dest, overwrite, cb)
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
pathExists(dest, (err, destExists) => {
|
|
40
|
+
if (err) return cb(err)
|
|
41
|
+
if (destExists) return cb(new Error('dest already exists.'))
|
|
42
|
+
return rename(src, dest, overwrite, cb)
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function rename (src, dest, overwrite, cb) {
|
|
47
|
+
fs.rename(src, dest, err => {
|
|
48
|
+
if (!err) return cb()
|
|
49
|
+
if (err.code !== 'EXDEV') return cb(err)
|
|
50
|
+
return moveAcrossDevice(src, dest, overwrite, cb)
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function moveAcrossDevice (src, dest, overwrite, cb) {
|
|
55
|
+
const opts = {
|
|
56
|
+
overwrite,
|
|
57
|
+
errorOnExist: true
|
|
58
|
+
}
|
|
59
|
+
copy(src, dest, opts, err => {
|
|
60
|
+
if (err) return cb(err)
|
|
61
|
+
return remove(src, cb)
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = move
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('graceful-fs')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const copySync = require('../copy-sync').copySync
|
|
6
|
+
const removeSync = require('../remove').removeSync
|
|
7
|
+
const mkdirpSync = require('../mkdirs').mkdirpSync
|
|
8
|
+
const stat = require('../util/stat')
|
|
9
|
+
|
|
10
|
+
function moveSync (src, dest, opts) {
|
|
11
|
+
opts = opts || {}
|
|
12
|
+
const overwrite = opts.overwrite || opts.clobber || false
|
|
13
|
+
|
|
14
|
+
const { srcStat } = stat.checkPathsSync(src, dest, 'move')
|
|
15
|
+
stat.checkParentPathsSync(src, srcStat, dest, 'move')
|
|
16
|
+
mkdirpSync(path.dirname(dest))
|
|
17
|
+
return doRename(src, dest, overwrite)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function doRename (src, dest, overwrite) {
|
|
21
|
+
if (overwrite) {
|
|
22
|
+
removeSync(dest)
|
|
23
|
+
return rename(src, dest, overwrite)
|
|
24
|
+
}
|
|
25
|
+
if (fs.existsSync(dest)) throw new Error('dest already exists.')
|
|
26
|
+
return rename(src, dest, overwrite)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function rename (src, dest, overwrite) {
|
|
30
|
+
try {
|
|
31
|
+
fs.renameSync(src, dest)
|
|
32
|
+
} catch (err) {
|
|
33
|
+
if (err.code !== 'EXDEV') throw err
|
|
34
|
+
return moveAcrossDevice(src, dest, overwrite)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function moveAcrossDevice (src, dest, overwrite) {
|
|
39
|
+
const opts = {
|
|
40
|
+
overwrite,
|
|
41
|
+
errorOnExist: true
|
|
42
|
+
}
|
|
43
|
+
copySync(src, dest, opts)
|
|
44
|
+
return removeSync(src)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = moveSync
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const u = require('universalify').fromCallback
|
|
4
|
+
const fs = require('graceful-fs')
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const mkdir = require('../mkdirs')
|
|
7
|
+
const pathExists = require('../path-exists').pathExists
|
|
8
|
+
|
|
9
|
+
function outputFile (file, data, encoding, callback) {
|
|
10
|
+
if (typeof encoding === 'function') {
|
|
11
|
+
callback = encoding
|
|
12
|
+
encoding = 'utf8'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const dir = path.dirname(file)
|
|
16
|
+
pathExists(dir, (err, itDoes) => {
|
|
17
|
+
if (err) return callback(err)
|
|
18
|
+
if (itDoes) return fs.writeFile(file, data, encoding, callback)
|
|
19
|
+
|
|
20
|
+
mkdir.mkdirs(dir, err => {
|
|
21
|
+
if (err) return callback(err)
|
|
22
|
+
|
|
23
|
+
fs.writeFile(file, data, encoding, callback)
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function outputFileSync (file, ...args) {
|
|
29
|
+
const dir = path.dirname(file)
|
|
30
|
+
if (fs.existsSync(dir)) {
|
|
31
|
+
return fs.writeFileSync(file, ...args)
|
|
32
|
+
}
|
|
33
|
+
mkdir.mkdirsSync(dir)
|
|
34
|
+
fs.writeFileSync(file, ...args)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = {
|
|
38
|
+
outputFile: u(outputFile),
|
|
39
|
+
outputFileSync
|
|
40
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const u = require('universalify').fromPromise
|
|
3
|
+
const fs = require('../fs')
|
|
4
|
+
|
|
5
|
+
function pathExists (path) {
|
|
6
|
+
return fs.access(path).then(() => true).catch(() => false)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
pathExists: u(pathExists),
|
|
11
|
+
pathExistsSync: fs.existsSync
|
|
12
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('graceful-fs')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const assert = require('assert')
|
|
6
|
+
|
|
7
|
+
const isWindows = (process.platform === 'win32')
|
|
8
|
+
|
|
9
|
+
function defaults (options) {
|
|
10
|
+
const methods = [
|
|
11
|
+
'unlink',
|
|
12
|
+
'chmod',
|
|
13
|
+
'stat',
|
|
14
|
+
'lstat',
|
|
15
|
+
'rmdir',
|
|
16
|
+
'readdir'
|
|
17
|
+
]
|
|
18
|
+
methods.forEach(m => {
|
|
19
|
+
options[m] = options[m] || fs[m]
|
|
20
|
+
m = m + 'Sync'
|
|
21
|
+
options[m] = options[m] || fs[m]
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
options.maxBusyTries = options.maxBusyTries || 3
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function rimraf (p, options, cb) {
|
|
28
|
+
let busyTries = 0
|
|
29
|
+
|
|
30
|
+
if (typeof options === 'function') {
|
|
31
|
+
cb = options
|
|
32
|
+
options = {}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
assert(p, 'rimraf: missing path')
|
|
36
|
+
assert.strictEqual(typeof p, 'string', 'rimraf: path should be a string')
|
|
37
|
+
assert.strictEqual(typeof cb, 'function', 'rimraf: callback function required')
|
|
38
|
+
assert(options, 'rimraf: invalid options argument provided')
|
|
39
|
+
assert.strictEqual(typeof options, 'object', 'rimraf: options should be object')
|
|
40
|
+
|
|
41
|
+
defaults(options)
|
|
42
|
+
|
|
43
|
+
rimraf_(p, options, function CB (er) {
|
|
44
|
+
if (er) {
|
|
45
|
+
if ((er.code === 'EBUSY' || er.code === 'ENOTEMPTY' || er.code === 'EPERM') &&
|
|
46
|
+
busyTries < options.maxBusyTries) {
|
|
47
|
+
busyTries++
|
|
48
|
+
const time = busyTries * 100
|
|
49
|
+
// try again, with the same exact callback as this one.
|
|
50
|
+
return setTimeout(() => rimraf_(p, options, CB), time)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// already gone
|
|
54
|
+
if (er.code === 'ENOENT') er = null
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
cb(er)
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Two possible strategies.
|
|
62
|
+
// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR
|
|
63
|
+
// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR
|
|
64
|
+
//
|
|
65
|
+
// Both result in an extra syscall when you guess wrong. However, there
|
|
66
|
+
// are likely far more normal files in the world than directories. This
|
|
67
|
+
// is based on the assumption that a the average number of files per
|
|
68
|
+
// directory is >= 1.
|
|
69
|
+
//
|
|
70
|
+
// If anyone ever complains about this, then I guess the strategy could
|
|
71
|
+
// be made configurable somehow. But until then, YAGNI.
|
|
72
|
+
function rimraf_ (p, options, cb) {
|
|
73
|
+
assert(p)
|
|
74
|
+
assert(options)
|
|
75
|
+
assert(typeof cb === 'function')
|
|
76
|
+
|
|
77
|
+
// sunos lets the root user unlink directories, which is... weird.
|
|
78
|
+
// so we have to lstat here and make sure it's not a dir.
|
|
79
|
+
options.lstat(p, (er, st) => {
|
|
80
|
+
if (er && er.code === 'ENOENT') {
|
|
81
|
+
return cb(null)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Windows can EPERM on stat. Life is suffering.
|
|
85
|
+
if (er && er.code === 'EPERM' && isWindows) {
|
|
86
|
+
return fixWinEPERM(p, options, er, cb)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (st && st.isDirectory()) {
|
|
90
|
+
return rmdir(p, options, er, cb)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
options.unlink(p, er => {
|
|
94
|
+
if (er) {
|
|
95
|
+
if (er.code === 'ENOENT') {
|
|
96
|
+
return cb(null)
|
|
97
|
+
}
|
|
98
|
+
if (er.code === 'EPERM') {
|
|
99
|
+
return (isWindows)
|
|
100
|
+
? fixWinEPERM(p, options, er, cb)
|
|
101
|
+
: rmdir(p, options, er, cb)
|
|
102
|
+
}
|
|
103
|
+
if (er.code === 'EISDIR') {
|
|
104
|
+
return rmdir(p, options, er, cb)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return cb(er)
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function fixWinEPERM (p, options, er, cb) {
|
|
113
|
+
assert(p)
|
|
114
|
+
assert(options)
|
|
115
|
+
assert(typeof cb === 'function')
|
|
116
|
+
|
|
117
|
+
options.chmod(p, 0o666, er2 => {
|
|
118
|
+
if (er2) {
|
|
119
|
+
cb(er2.code === 'ENOENT' ? null : er)
|
|
120
|
+
} else {
|
|
121
|
+
options.stat(p, (er3, stats) => {
|
|
122
|
+
if (er3) {
|
|
123
|
+
cb(er3.code === 'ENOENT' ? null : er)
|
|
124
|
+
} else if (stats.isDirectory()) {
|
|
125
|
+
rmdir(p, options, er, cb)
|
|
126
|
+
} else {
|
|
127
|
+
options.unlink(p, cb)
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function fixWinEPERMSync (p, options, er) {
|
|
135
|
+
let stats
|
|
136
|
+
|
|
137
|
+
assert(p)
|
|
138
|
+
assert(options)
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
options.chmodSync(p, 0o666)
|
|
142
|
+
} catch (er2) {
|
|
143
|
+
if (er2.code === 'ENOENT') {
|
|
144
|
+
return
|
|
145
|
+
} else {
|
|
146
|
+
throw er
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
try {
|
|
151
|
+
stats = options.statSync(p)
|
|
152
|
+
} catch (er3) {
|
|
153
|
+
if (er3.code === 'ENOENT') {
|
|
154
|
+
return
|
|
155
|
+
} else {
|
|
156
|
+
throw er
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (stats.isDirectory()) {
|
|
161
|
+
rmdirSync(p, options, er)
|
|
162
|
+
} else {
|
|
163
|
+
options.unlinkSync(p)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function rmdir (p, options, originalEr, cb) {
|
|
168
|
+
assert(p)
|
|
169
|
+
assert(options)
|
|
170
|
+
assert(typeof cb === 'function')
|
|
171
|
+
|
|
172
|
+
// try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
|
|
173
|
+
// if we guessed wrong, and it's not a directory, then
|
|
174
|
+
// raise the original error.
|
|
175
|
+
options.rmdir(p, er => {
|
|
176
|
+
if (er && (er.code === 'ENOTEMPTY' || er.code === 'EEXIST' || er.code === 'EPERM')) {
|
|
177
|
+
rmkids(p, options, cb)
|
|
178
|
+
} else if (er && er.code === 'ENOTDIR') {
|
|
179
|
+
cb(originalEr)
|
|
180
|
+
} else {
|
|
181
|
+
cb(er)
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function rmkids (p, options, cb) {
|
|
187
|
+
assert(p)
|
|
188
|
+
assert(options)
|
|
189
|
+
assert(typeof cb === 'function')
|
|
190
|
+
|
|
191
|
+
options.readdir(p, (er, files) => {
|
|
192
|
+
if (er) return cb(er)
|
|
193
|
+
|
|
194
|
+
let n = files.length
|
|
195
|
+
let errState
|
|
196
|
+
|
|
197
|
+
if (n === 0) return options.rmdir(p, cb)
|
|
198
|
+
|
|
199
|
+
files.forEach(f => {
|
|
200
|
+
rimraf(path.join(p, f), options, er => {
|
|
201
|
+
if (errState) {
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
if (er) return cb(errState = er)
|
|
205
|
+
if (--n === 0) {
|
|
206
|
+
options.rmdir(p, cb)
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// this looks simpler, and is strictly *faster*, but will
|
|
214
|
+
// tie up the JavaScript thread and fail on excessively
|
|
215
|
+
// deep directory trees.
|
|
216
|
+
function rimrafSync (p, options) {
|
|
217
|
+
let st
|
|
218
|
+
|
|
219
|
+
options = options || {}
|
|
220
|
+
defaults(options)
|
|
221
|
+
|
|
222
|
+
assert(p, 'rimraf: missing path')
|
|
223
|
+
assert.strictEqual(typeof p, 'string', 'rimraf: path should be a string')
|
|
224
|
+
assert(options, 'rimraf: missing options')
|
|
225
|
+
assert.strictEqual(typeof options, 'object', 'rimraf: options should be object')
|
|
226
|
+
|
|
227
|
+
try {
|
|
228
|
+
st = options.lstatSync(p)
|
|
229
|
+
} catch (er) {
|
|
230
|
+
if (er.code === 'ENOENT') {
|
|
231
|
+
return
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Windows can EPERM on stat. Life is suffering.
|
|
235
|
+
if (er.code === 'EPERM' && isWindows) {
|
|
236
|
+
fixWinEPERMSync(p, options, er)
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
// sunos lets the root user unlink directories, which is... weird.
|
|
242
|
+
if (st && st.isDirectory()) {
|
|
243
|
+
rmdirSync(p, options, null)
|
|
244
|
+
} else {
|
|
245
|
+
options.unlinkSync(p)
|
|
246
|
+
}
|
|
247
|
+
} catch (er) {
|
|
248
|
+
if (er.code === 'ENOENT') {
|
|
249
|
+
return
|
|
250
|
+
} else if (er.code === 'EPERM') {
|
|
251
|
+
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er)
|
|
252
|
+
} else if (er.code !== 'EISDIR') {
|
|
253
|
+
throw er
|
|
254
|
+
}
|
|
255
|
+
rmdirSync(p, options, er)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function rmdirSync (p, options, originalEr) {
|
|
260
|
+
assert(p)
|
|
261
|
+
assert(options)
|
|
262
|
+
|
|
263
|
+
try {
|
|
264
|
+
options.rmdirSync(p)
|
|
265
|
+
} catch (er) {
|
|
266
|
+
if (er.code === 'ENOTDIR') {
|
|
267
|
+
throw originalEr
|
|
268
|
+
} else if (er.code === 'ENOTEMPTY' || er.code === 'EEXIST' || er.code === 'EPERM') {
|
|
269
|
+
rmkidsSync(p, options)
|
|
270
|
+
} else if (er.code !== 'ENOENT') {
|
|
271
|
+
throw er
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function rmkidsSync (p, options) {
|
|
277
|
+
assert(p)
|
|
278
|
+
assert(options)
|
|
279
|
+
options.readdirSync(p).forEach(f => rimrafSync(path.join(p, f), options))
|
|
280
|
+
|
|
281
|
+
if (isWindows) {
|
|
282
|
+
// We only end up here once we got ENOTEMPTY at least once, and
|
|
283
|
+
// at this point, we are guaranteed to have removed all the kids.
|
|
284
|
+
// So, we know that it won't be ENOENT or ENOTDIR or anything else.
|
|
285
|
+
// try really hard to delete stuff on windows, because it has a
|
|
286
|
+
// PROFOUNDLY annoying habit of not closing handles promptly when
|
|
287
|
+
// files are deleted, resulting in spurious ENOTEMPTY errors.
|
|
288
|
+
const startTime = Date.now()
|
|
289
|
+
do {
|
|
290
|
+
try {
|
|
291
|
+
const ret = options.rmdirSync(p, options)
|
|
292
|
+
return ret
|
|
293
|
+
} catch {}
|
|
294
|
+
} while (Date.now() - startTime < 500) // give up after 500ms
|
|
295
|
+
} else {
|
|
296
|
+
const ret = options.rmdirSync(p, options)
|
|
297
|
+
return ret
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
module.exports = rimraf
|
|
302
|
+
rimraf.sync = rimrafSync
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('../fs')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const util = require('util')
|
|
6
|
+
const atLeastNode = require('at-least-node')
|
|
7
|
+
|
|
8
|
+
const nodeSupportsBigInt = atLeastNode('10.5.0')
|
|
9
|
+
const stat = (file) => nodeSupportsBigInt ? fs.stat(file, { bigint: true }) : fs.stat(file)
|
|
10
|
+
const statSync = (file) => nodeSupportsBigInt ? fs.statSync(file, { bigint: true }) : fs.statSync(file)
|
|
11
|
+
|
|
12
|
+
function getStats (src, dest) {
|
|
13
|
+
return Promise.all([
|
|
14
|
+
stat(src),
|
|
15
|
+
stat(dest).catch(err => {
|
|
16
|
+
if (err.code === 'ENOENT') return null
|
|
17
|
+
throw err
|
|
18
|
+
})
|
|
19
|
+
]).then(([srcStat, destStat]) => ({ srcStat, destStat }))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getStatsSync (src, dest) {
|
|
23
|
+
let destStat
|
|
24
|
+
const srcStat = statSync(src)
|
|
25
|
+
try {
|
|
26
|
+
destStat = statSync(dest)
|
|
27
|
+
} catch (err) {
|
|
28
|
+
if (err.code === 'ENOENT') return { srcStat, destStat: null }
|
|
29
|
+
throw err
|
|
30
|
+
}
|
|
31
|
+
return { srcStat, destStat }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function checkPaths (src, dest, funcName, cb) {
|
|
35
|
+
util.callbackify(getStats)(src, dest, (err, stats) => {
|
|
36
|
+
if (err) return cb(err)
|
|
37
|
+
const { srcStat, destStat } = stats
|
|
38
|
+
if (destStat && areIdentical(srcStat, destStat)) {
|
|
39
|
+
return cb(new Error('Source and destination must not be the same.'))
|
|
40
|
+
}
|
|
41
|
+
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
42
|
+
return cb(new Error(errMsg(src, dest, funcName)))
|
|
43
|
+
}
|
|
44
|
+
return cb(null, { srcStat, destStat })
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function checkPathsSync (src, dest, funcName) {
|
|
49
|
+
const { srcStat, destStat } = getStatsSync(src, dest)
|
|
50
|
+
if (destStat && areIdentical(srcStat, destStat)) {
|
|
51
|
+
throw new Error('Source and destination must not be the same.')
|
|
52
|
+
}
|
|
53
|
+
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
54
|
+
throw new Error(errMsg(src, dest, funcName))
|
|
55
|
+
}
|
|
56
|
+
return { srcStat, destStat }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// recursively check if dest parent is a subdirectory of src.
|
|
60
|
+
// It works for all file types including symlinks since it
|
|
61
|
+
// checks the src and dest inodes. It starts from the deepest
|
|
62
|
+
// parent and stops once it reaches the src parent or the root path.
|
|
63
|
+
function checkParentPaths (src, srcStat, dest, funcName, cb) {
|
|
64
|
+
const srcParent = path.resolve(path.dirname(src))
|
|
65
|
+
const destParent = path.resolve(path.dirname(dest))
|
|
66
|
+
if (destParent === srcParent || destParent === path.parse(destParent).root) return cb()
|
|
67
|
+
const callback = (err, destStat) => {
|
|
68
|
+
if (err) {
|
|
69
|
+
if (err.code === 'ENOENT') return cb()
|
|
70
|
+
return cb(err)
|
|
71
|
+
}
|
|
72
|
+
if (areIdentical(srcStat, destStat)) {
|
|
73
|
+
return cb(new Error(errMsg(src, dest, funcName)))
|
|
74
|
+
}
|
|
75
|
+
return checkParentPaths(src, srcStat, destParent, funcName, cb)
|
|
76
|
+
}
|
|
77
|
+
if (nodeSupportsBigInt) fs.stat(destParent, { bigint: true }, callback)
|
|
78
|
+
else fs.stat(destParent, callback)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function checkParentPathsSync (src, srcStat, dest, funcName) {
|
|
82
|
+
const srcParent = path.resolve(path.dirname(src))
|
|
83
|
+
const destParent = path.resolve(path.dirname(dest))
|
|
84
|
+
if (destParent === srcParent || destParent === path.parse(destParent).root) return
|
|
85
|
+
let destStat
|
|
86
|
+
try {
|
|
87
|
+
destStat = statSync(destParent)
|
|
88
|
+
} catch (err) {
|
|
89
|
+
if (err.code === 'ENOENT') return
|
|
90
|
+
throw err
|
|
91
|
+
}
|
|
92
|
+
if (areIdentical(srcStat, destStat)) {
|
|
93
|
+
throw new Error(errMsg(src, dest, funcName))
|
|
94
|
+
}
|
|
95
|
+
return checkParentPathsSync(src, srcStat, destParent, funcName)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function areIdentical (srcStat, destStat) {
|
|
99
|
+
if (destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev) {
|
|
100
|
+
if (nodeSupportsBigInt || destStat.ino < Number.MAX_SAFE_INTEGER) {
|
|
101
|
+
// definitive answer
|
|
102
|
+
return true
|
|
103
|
+
}
|
|
104
|
+
// Use additional heuristics if we can't use 'bigint'.
|
|
105
|
+
// Different 'ino' could be represented the same if they are >= Number.MAX_SAFE_INTEGER
|
|
106
|
+
// See issue 657
|
|
107
|
+
if (destStat.size === srcStat.size &&
|
|
108
|
+
destStat.mode === srcStat.mode &&
|
|
109
|
+
destStat.nlink === srcStat.nlink &&
|
|
110
|
+
destStat.atimeMs === srcStat.atimeMs &&
|
|
111
|
+
destStat.mtimeMs === srcStat.mtimeMs &&
|
|
112
|
+
destStat.ctimeMs === srcStat.ctimeMs &&
|
|
113
|
+
destStat.birthtimeMs === srcStat.birthtimeMs) {
|
|
114
|
+
// heuristic answer
|
|
115
|
+
return true
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return false
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// return true if dest is a subdir of src, otherwise false.
|
|
122
|
+
// It only checks the path strings.
|
|
123
|
+
function isSrcSubdir (src, dest) {
|
|
124
|
+
const srcArr = path.resolve(src).split(path.sep).filter(i => i)
|
|
125
|
+
const destArr = path.resolve(dest).split(path.sep).filter(i => i)
|
|
126
|
+
return srcArr.reduce((acc, cur, i) => acc && destArr[i] === cur, true)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function errMsg (src, dest, funcName) {
|
|
130
|
+
return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
module.exports = {
|
|
134
|
+
checkPaths,
|
|
135
|
+
checkPathsSync,
|
|
136
|
+
checkParentPaths,
|
|
137
|
+
checkParentPathsSync,
|
|
138
|
+
isSrcSubdir
|
|
139
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('graceful-fs')
|
|
4
|
+
|
|
5
|
+
function utimesMillis (path, atime, mtime, callback) {
|
|
6
|
+
// if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
|
|
7
|
+
fs.open(path, 'r+', (err, fd) => {
|
|
8
|
+
if (err) return callback(err)
|
|
9
|
+
fs.futimes(fd, atime, mtime, futimesErr => {
|
|
10
|
+
fs.close(fd, closeErr => {
|
|
11
|
+
if (callback) callback(futimesErr || closeErr)
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function utimesMillisSync (path, atime, mtime) {
|
|
18
|
+
const fd = fs.openSync(path, 'r+')
|
|
19
|
+
fs.futimesSync(fd, atime, mtime)
|
|
20
|
+
return fs.closeSync(fd)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
utimesMillis,
|
|
25
|
+
utimesMillisSync
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"fs-extra","version":"9.1.0","description":"fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.","engines":{"node":">=10"},"homepage":"https://github.com/jprichardson/node-fs-extra","repository":{"type":"git","url":"https://github.com/jprichardson/node-fs-extra"},"keywords":["fs","file","file system","copy","directory","extra","mkdirp","mkdir","mkdirs","recursive","json","read","write","extra","delete","remove","touch","create","text","output","move","promise"],"author":"JP Richardson <jprichardson@gmail.com>","license":"MIT","dependencies":{"at-least-node":"^1.0.0","graceful-fs":"^4.2.0","jsonfile":"^6.0.1","universalify":"^2.0.0"},"devDependencies":{"coveralls":"^3.0.0","klaw":"^2.1.1","klaw-sync":"^3.0.2","minimist":"^1.1.1","mocha":"^5.0.5","nyc":"^15.0.0","proxyquire":"^2.0.1","read-dir-files":"^0.1.1","standard":"^14.1.0"},"main":"./lib/index.js","files":["lib/","!lib/**/__tests__/"],"scripts":{"full-ci":"npm run lint && npm run coverage","coverage":"nyc -r lcovonly npm run unit","coveralls":"coveralls < coverage/lcov.info","lint":"standard","test-find":"find ./lib/**/__tests__ -name *.test.js | xargs mocha","test":"npm run lint && npm run unit","unit":"node test.js"},"_lastModified":"2025-02-17T17:47:12.241Z"}
|
package/dist/server/plugin.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare class PluginFieldMarkdownVditorServer extends Plugin {
|
|
|
11
11
|
afterAdd(): Promise<void>;
|
|
12
12
|
beforeLoad(): Promise<void>;
|
|
13
13
|
load(): Promise<void>;
|
|
14
|
+
copyVditorDist(): Promise<void>;
|
|
14
15
|
install(): Promise<void>;
|
|
15
16
|
afterEnable(): Promise<void>;
|
|
16
17
|
afterDisable(): Promise<void>;
|