create-byan-agent 2.11.0 → 2.11.1
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/node_modules/byan-platform-config/README.md +107 -0
- package/node_modules/byan-platform-config/index.js +16 -0
- package/node_modules/byan-platform-config/lib/env-config.js +128 -0
- package/node_modules/byan-platform-config/lib/mcp-config.js +95 -0
- package/node_modules/byan-platform-config/lib/token-prompt.js +61 -0
- package/node_modules/byan-platform-config/lib/url-utils.js +27 -0
- package/node_modules/byan-platform-config/lib/validate.js +44 -0
- package/node_modules/byan-platform-config/package.json +42 -0
- package/node_modules/fs-extra/LICENSE +15 -0
- package/node_modules/fs-extra/README.md +294 -0
- package/node_modules/fs-extra/lib/copy/copy-sync.js +176 -0
- package/node_modules/fs-extra/lib/copy/copy.js +180 -0
- package/node_modules/fs-extra/lib/copy/index.js +7 -0
- package/node_modules/fs-extra/lib/empty/index.js +39 -0
- package/node_modules/fs-extra/lib/ensure/file.js +66 -0
- package/node_modules/fs-extra/lib/ensure/index.js +23 -0
- package/node_modules/fs-extra/lib/ensure/link.js +64 -0
- package/node_modules/fs-extra/lib/ensure/symlink-paths.js +101 -0
- package/node_modules/fs-extra/lib/ensure/symlink-type.js +34 -0
- package/node_modules/fs-extra/lib/ensure/symlink.js +92 -0
- package/node_modules/fs-extra/lib/esm.mjs +68 -0
- package/node_modules/fs-extra/lib/fs/index.js +146 -0
- package/node_modules/fs-extra/lib/index.js +16 -0
- package/node_modules/fs-extra/lib/json/index.js +16 -0
- package/node_modules/fs-extra/lib/json/jsonfile.js +11 -0
- package/node_modules/fs-extra/lib/json/output-json-sync.js +12 -0
- package/node_modules/fs-extra/lib/json/output-json.js +12 -0
- package/node_modules/fs-extra/lib/mkdirs/index.js +14 -0
- package/node_modules/fs-extra/lib/mkdirs/make-dir.js +27 -0
- package/node_modules/fs-extra/lib/mkdirs/utils.js +21 -0
- package/node_modules/fs-extra/lib/move/index.js +7 -0
- package/node_modules/fs-extra/lib/move/move-sync.js +55 -0
- package/node_modules/fs-extra/lib/move/move.js +59 -0
- package/node_modules/fs-extra/lib/output-file/index.js +31 -0
- package/node_modules/fs-extra/lib/path-exists/index.js +12 -0
- package/node_modules/fs-extra/lib/remove/index.js +17 -0
- package/node_modules/fs-extra/lib/util/async.js +29 -0
- package/node_modules/fs-extra/lib/util/stat.js +159 -0
- package/node_modules/fs-extra/lib/util/utimes.js +36 -0
- package/node_modules/fs-extra/package.json +71 -0
- package/node_modules/graceful-fs/LICENSE +15 -0
- package/node_modules/graceful-fs/README.md +143 -0
- package/node_modules/graceful-fs/clone.js +23 -0
- package/node_modules/graceful-fs/graceful-fs.js +448 -0
- package/node_modules/graceful-fs/legacy-streams.js +118 -0
- package/node_modules/graceful-fs/package.json +53 -0
- package/node_modules/graceful-fs/polyfills.js +355 -0
- package/node_modules/jsonfile/LICENSE +15 -0
- package/node_modules/jsonfile/README.md +230 -0
- package/node_modules/jsonfile/index.js +88 -0
- package/node_modules/jsonfile/package.json +40 -0
- package/node_modules/jsonfile/utils.js +18 -0
- package/node_modules/universalify/LICENSE +20 -0
- package/node_modules/universalify/README.md +76 -0
- package/node_modules/universalify/index.js +24 -0
- package/node_modules/universalify/package.json +34 -0
- package/package.json +4 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const u = require('universalify').fromPromise
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const fs = require('../fs')
|
|
6
|
+
const mkdir = require('../mkdirs')
|
|
7
|
+
|
|
8
|
+
async function createFile (file) {
|
|
9
|
+
let stats
|
|
10
|
+
try {
|
|
11
|
+
stats = await fs.stat(file)
|
|
12
|
+
} catch { }
|
|
13
|
+
if (stats && stats.isFile()) return
|
|
14
|
+
|
|
15
|
+
const dir = path.dirname(file)
|
|
16
|
+
|
|
17
|
+
let dirStats = null
|
|
18
|
+
try {
|
|
19
|
+
dirStats = await fs.stat(dir)
|
|
20
|
+
} catch (err) {
|
|
21
|
+
// if the directory doesn't exist, make it
|
|
22
|
+
if (err.code === 'ENOENT') {
|
|
23
|
+
await mkdir.mkdirs(dir)
|
|
24
|
+
await fs.writeFile(file, '')
|
|
25
|
+
return
|
|
26
|
+
} else {
|
|
27
|
+
throw err
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (dirStats.isDirectory()) {
|
|
32
|
+
await fs.writeFile(file, '')
|
|
33
|
+
} else {
|
|
34
|
+
// parent is not a directory
|
|
35
|
+
// This is just to cause an internal ENOTDIR error to be thrown
|
|
36
|
+
await fs.readdir(dir)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createFileSync (file) {
|
|
41
|
+
let stats
|
|
42
|
+
try {
|
|
43
|
+
stats = fs.statSync(file)
|
|
44
|
+
} catch { }
|
|
45
|
+
if (stats && stats.isFile()) return
|
|
46
|
+
|
|
47
|
+
const dir = path.dirname(file)
|
|
48
|
+
try {
|
|
49
|
+
if (!fs.statSync(dir).isDirectory()) {
|
|
50
|
+
// parent is not a directory
|
|
51
|
+
// This is just to cause an internal ENOTDIR error to be thrown
|
|
52
|
+
fs.readdirSync(dir)
|
|
53
|
+
}
|
|
54
|
+
} catch (err) {
|
|
55
|
+
// If the stat call above failed because the directory doesn't exist, create it
|
|
56
|
+
if (err && err.code === 'ENOENT') mkdir.mkdirsSync(dir)
|
|
57
|
+
else throw err
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
fs.writeFileSync(file, '')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = {
|
|
64
|
+
createFile: u(createFile),
|
|
65
|
+
createFileSync
|
|
66
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { createFile, createFileSync } = require('./file')
|
|
4
|
+
const { createLink, createLinkSync } = require('./link')
|
|
5
|
+
const { createSymlink, createSymlinkSync } = require('./symlink')
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
// file
|
|
9
|
+
createFile,
|
|
10
|
+
createFileSync,
|
|
11
|
+
ensureFile: createFile,
|
|
12
|
+
ensureFileSync: createFileSync,
|
|
13
|
+
// link
|
|
14
|
+
createLink,
|
|
15
|
+
createLinkSync,
|
|
16
|
+
ensureLink: createLink,
|
|
17
|
+
ensureLinkSync: createLinkSync,
|
|
18
|
+
// symlink
|
|
19
|
+
createSymlink,
|
|
20
|
+
createSymlinkSync,
|
|
21
|
+
ensureSymlink: createSymlink,
|
|
22
|
+
ensureSymlinkSync: createSymlinkSync
|
|
23
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const u = require('universalify').fromPromise
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const fs = require('../fs')
|
|
6
|
+
const mkdir = require('../mkdirs')
|
|
7
|
+
const { pathExists } = require('../path-exists')
|
|
8
|
+
const { areIdentical } = require('../util/stat')
|
|
9
|
+
|
|
10
|
+
async function createLink (srcpath, dstpath) {
|
|
11
|
+
let dstStat
|
|
12
|
+
try {
|
|
13
|
+
dstStat = await fs.lstat(dstpath)
|
|
14
|
+
} catch {
|
|
15
|
+
// ignore error
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let srcStat
|
|
19
|
+
try {
|
|
20
|
+
srcStat = await fs.lstat(srcpath)
|
|
21
|
+
} catch (err) {
|
|
22
|
+
err.message = err.message.replace('lstat', 'ensureLink')
|
|
23
|
+
throw err
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (dstStat && areIdentical(srcStat, dstStat)) return
|
|
27
|
+
|
|
28
|
+
const dir = path.dirname(dstpath)
|
|
29
|
+
|
|
30
|
+
const dirExists = await pathExists(dir)
|
|
31
|
+
|
|
32
|
+
if (!dirExists) {
|
|
33
|
+
await mkdir.mkdirs(dir)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
await fs.link(srcpath, dstpath)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function createLinkSync (srcpath, dstpath) {
|
|
40
|
+
let dstStat
|
|
41
|
+
try {
|
|
42
|
+
dstStat = fs.lstatSync(dstpath)
|
|
43
|
+
} catch {}
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
const srcStat = fs.lstatSync(srcpath)
|
|
47
|
+
if (dstStat && areIdentical(srcStat, dstStat)) return
|
|
48
|
+
} catch (err) {
|
|
49
|
+
err.message = err.message.replace('lstat', 'ensureLink')
|
|
50
|
+
throw err
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const dir = path.dirname(dstpath)
|
|
54
|
+
const dirExists = fs.existsSync(dir)
|
|
55
|
+
if (dirExists) return fs.linkSync(srcpath, dstpath)
|
|
56
|
+
mkdir.mkdirsSync(dir)
|
|
57
|
+
|
|
58
|
+
return fs.linkSync(srcpath, dstpath)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
createLink: u(createLink),
|
|
63
|
+
createLinkSync
|
|
64
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const fs = require('../fs')
|
|
5
|
+
const { pathExists } = require('../path-exists')
|
|
6
|
+
|
|
7
|
+
const u = require('universalify').fromPromise
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Function that returns two types of paths, one relative to symlink, and one
|
|
11
|
+
* relative to the current working directory. Checks if path is absolute or
|
|
12
|
+
* relative. If the path is relative, this function checks if the path is
|
|
13
|
+
* relative to symlink or relative to current working directory. This is an
|
|
14
|
+
* initiative to find a smarter `srcpath` to supply when building symlinks.
|
|
15
|
+
* This allows you to determine which path to use out of one of three possible
|
|
16
|
+
* types of source paths. The first is an absolute path. This is detected by
|
|
17
|
+
* `path.isAbsolute()`. When an absolute path is provided, it is checked to
|
|
18
|
+
* see if it exists. If it does it's used, if not an error is returned
|
|
19
|
+
* (callback)/ thrown (sync). The other two options for `srcpath` are a
|
|
20
|
+
* relative url. By default Node's `fs.symlink` works by creating a symlink
|
|
21
|
+
* using `dstpath` and expects the `srcpath` to be relative to the newly
|
|
22
|
+
* created symlink. If you provide a `srcpath` that does not exist on the file
|
|
23
|
+
* system it results in a broken symlink. To minimize this, the function
|
|
24
|
+
* checks to see if the 'relative to symlink' source file exists, and if it
|
|
25
|
+
* does it will use it. If it does not, it checks if there's a file that
|
|
26
|
+
* exists that is relative to the current working directory, if does its used.
|
|
27
|
+
* This preserves the expectations of the original fs.symlink spec and adds
|
|
28
|
+
* the ability to pass in `relative to current working direcotry` paths.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
async function symlinkPaths (srcpath, dstpath) {
|
|
32
|
+
if (path.isAbsolute(srcpath)) {
|
|
33
|
+
try {
|
|
34
|
+
await fs.lstat(srcpath)
|
|
35
|
+
} catch (err) {
|
|
36
|
+
err.message = err.message.replace('lstat', 'ensureSymlink')
|
|
37
|
+
throw err
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
toCwd: srcpath,
|
|
42
|
+
toDst: srcpath
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const dstdir = path.dirname(dstpath)
|
|
47
|
+
const relativeToDst = path.join(dstdir, srcpath)
|
|
48
|
+
|
|
49
|
+
const exists = await pathExists(relativeToDst)
|
|
50
|
+
if (exists) {
|
|
51
|
+
return {
|
|
52
|
+
toCwd: relativeToDst,
|
|
53
|
+
toDst: srcpath
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
await fs.lstat(srcpath)
|
|
59
|
+
} catch (err) {
|
|
60
|
+
err.message = err.message.replace('lstat', 'ensureSymlink')
|
|
61
|
+
throw err
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
toCwd: srcpath,
|
|
66
|
+
toDst: path.relative(dstdir, srcpath)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function symlinkPathsSync (srcpath, dstpath) {
|
|
71
|
+
if (path.isAbsolute(srcpath)) {
|
|
72
|
+
const exists = fs.existsSync(srcpath)
|
|
73
|
+
if (!exists) throw new Error('absolute srcpath does not exist')
|
|
74
|
+
return {
|
|
75
|
+
toCwd: srcpath,
|
|
76
|
+
toDst: srcpath
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const dstdir = path.dirname(dstpath)
|
|
81
|
+
const relativeToDst = path.join(dstdir, srcpath)
|
|
82
|
+
const exists = fs.existsSync(relativeToDst)
|
|
83
|
+
if (exists) {
|
|
84
|
+
return {
|
|
85
|
+
toCwd: relativeToDst,
|
|
86
|
+
toDst: srcpath
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const srcExists = fs.existsSync(srcpath)
|
|
91
|
+
if (!srcExists) throw new Error('relative srcpath does not exist')
|
|
92
|
+
return {
|
|
93
|
+
toCwd: srcpath,
|
|
94
|
+
toDst: path.relative(dstdir, srcpath)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = {
|
|
99
|
+
symlinkPaths: u(symlinkPaths),
|
|
100
|
+
symlinkPathsSync
|
|
101
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('../fs')
|
|
4
|
+
const u = require('universalify').fromPromise
|
|
5
|
+
|
|
6
|
+
async function symlinkType (srcpath, type) {
|
|
7
|
+
if (type) return type
|
|
8
|
+
|
|
9
|
+
let stats
|
|
10
|
+
try {
|
|
11
|
+
stats = await fs.lstat(srcpath)
|
|
12
|
+
} catch {
|
|
13
|
+
return 'file'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (stats && stats.isDirectory()) ? 'dir' : 'file'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function symlinkTypeSync (srcpath, type) {
|
|
20
|
+
if (type) return type
|
|
21
|
+
|
|
22
|
+
let stats
|
|
23
|
+
try {
|
|
24
|
+
stats = fs.lstatSync(srcpath)
|
|
25
|
+
} catch {
|
|
26
|
+
return 'file'
|
|
27
|
+
}
|
|
28
|
+
return (stats && stats.isDirectory()) ? 'dir' : 'file'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = {
|
|
32
|
+
symlinkType: u(symlinkType),
|
|
33
|
+
symlinkTypeSync
|
|
34
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const u = require('universalify').fromPromise
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const fs = require('../fs')
|
|
6
|
+
|
|
7
|
+
const { mkdirs, mkdirsSync } = require('../mkdirs')
|
|
8
|
+
|
|
9
|
+
const { symlinkPaths, symlinkPathsSync } = require('./symlink-paths')
|
|
10
|
+
const { symlinkType, symlinkTypeSync } = require('./symlink-type')
|
|
11
|
+
|
|
12
|
+
const { pathExists } = require('../path-exists')
|
|
13
|
+
|
|
14
|
+
const { areIdentical } = require('../util/stat')
|
|
15
|
+
|
|
16
|
+
async function createSymlink (srcpath, dstpath, type) {
|
|
17
|
+
let stats
|
|
18
|
+
try {
|
|
19
|
+
stats = await fs.lstat(dstpath)
|
|
20
|
+
} catch { }
|
|
21
|
+
|
|
22
|
+
if (stats && stats.isSymbolicLink()) {
|
|
23
|
+
// When srcpath is relative, resolve it relative to dstpath's directory
|
|
24
|
+
// (standard symlink behavior) or fall back to cwd if that doesn't exist
|
|
25
|
+
let srcStat
|
|
26
|
+
if (path.isAbsolute(srcpath)) {
|
|
27
|
+
srcStat = await fs.stat(srcpath)
|
|
28
|
+
} else {
|
|
29
|
+
const dstdir = path.dirname(dstpath)
|
|
30
|
+
const relativeToDst = path.join(dstdir, srcpath)
|
|
31
|
+
try {
|
|
32
|
+
srcStat = await fs.stat(relativeToDst)
|
|
33
|
+
} catch {
|
|
34
|
+
srcStat = await fs.stat(srcpath)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const dstStat = await fs.stat(dstpath)
|
|
39
|
+
if (areIdentical(srcStat, dstStat)) return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const relative = await symlinkPaths(srcpath, dstpath)
|
|
43
|
+
srcpath = relative.toDst
|
|
44
|
+
const toType = await symlinkType(relative.toCwd, type)
|
|
45
|
+
const dir = path.dirname(dstpath)
|
|
46
|
+
|
|
47
|
+
if (!(await pathExists(dir))) {
|
|
48
|
+
await mkdirs(dir)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return fs.symlink(srcpath, dstpath, toType)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function createSymlinkSync (srcpath, dstpath, type) {
|
|
55
|
+
let stats
|
|
56
|
+
try {
|
|
57
|
+
stats = fs.lstatSync(dstpath)
|
|
58
|
+
} catch { }
|
|
59
|
+
if (stats && stats.isSymbolicLink()) {
|
|
60
|
+
// When srcpath is relative, resolve it relative to dstpath's directory
|
|
61
|
+
// (standard symlink behavior) or fall back to cwd if that doesn't exist
|
|
62
|
+
let srcStat
|
|
63
|
+
if (path.isAbsolute(srcpath)) {
|
|
64
|
+
srcStat = fs.statSync(srcpath)
|
|
65
|
+
} else {
|
|
66
|
+
const dstdir = path.dirname(dstpath)
|
|
67
|
+
const relativeToDst = path.join(dstdir, srcpath)
|
|
68
|
+
try {
|
|
69
|
+
srcStat = fs.statSync(relativeToDst)
|
|
70
|
+
} catch {
|
|
71
|
+
srcStat = fs.statSync(srcpath)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const dstStat = fs.statSync(dstpath)
|
|
76
|
+
if (areIdentical(srcStat, dstStat)) return
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const relative = symlinkPathsSync(srcpath, dstpath)
|
|
80
|
+
srcpath = relative.toDst
|
|
81
|
+
type = symlinkTypeSync(relative.toCwd, type)
|
|
82
|
+
const dir = path.dirname(dstpath)
|
|
83
|
+
const exists = fs.existsSync(dir)
|
|
84
|
+
if (exists) return fs.symlinkSync(srcpath, dstpath, type)
|
|
85
|
+
mkdirsSync(dir)
|
|
86
|
+
return fs.symlinkSync(srcpath, dstpath, type)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = {
|
|
90
|
+
createSymlink: u(createSymlink),
|
|
91
|
+
createSymlinkSync
|
|
92
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _copy from './copy/index.js'
|
|
2
|
+
import _empty from './empty/index.js'
|
|
3
|
+
import _ensure from './ensure/index.js'
|
|
4
|
+
import _json from './json/index.js'
|
|
5
|
+
import _mkdirs from './mkdirs/index.js'
|
|
6
|
+
import _move from './move/index.js'
|
|
7
|
+
import _outputFile from './output-file/index.js'
|
|
8
|
+
import _pathExists from './path-exists/index.js'
|
|
9
|
+
import _remove from './remove/index.js'
|
|
10
|
+
|
|
11
|
+
// NOTE: Only exports fs-extra's functions; fs functions must be imported from "node:fs" or "node:fs/promises"
|
|
12
|
+
|
|
13
|
+
export const copy = _copy.copy
|
|
14
|
+
export const copySync = _copy.copySync
|
|
15
|
+
export const emptyDirSync = _empty.emptyDirSync
|
|
16
|
+
export const emptydirSync = _empty.emptydirSync
|
|
17
|
+
export const emptyDir = _empty.emptyDir
|
|
18
|
+
export const emptydir = _empty.emptydir
|
|
19
|
+
export const createFile = _ensure.createFile
|
|
20
|
+
export const createFileSync = _ensure.createFileSync
|
|
21
|
+
export const ensureFile = _ensure.ensureFile
|
|
22
|
+
export const ensureFileSync = _ensure.ensureFileSync
|
|
23
|
+
export const createLink = _ensure.createLink
|
|
24
|
+
export const createLinkSync = _ensure.createLinkSync
|
|
25
|
+
export const ensureLink = _ensure.ensureLink
|
|
26
|
+
export const ensureLinkSync = _ensure.ensureLinkSync
|
|
27
|
+
export const createSymlink = _ensure.createSymlink
|
|
28
|
+
export const createSymlinkSync = _ensure.createSymlinkSync
|
|
29
|
+
export const ensureSymlink = _ensure.ensureSymlink
|
|
30
|
+
export const ensureSymlinkSync = _ensure.ensureSymlinkSync
|
|
31
|
+
export const readJson = _json.readJson
|
|
32
|
+
export const readJSON = _json.readJSON
|
|
33
|
+
export const readJsonSync = _json.readJsonSync
|
|
34
|
+
export const readJSONSync = _json.readJSONSync
|
|
35
|
+
export const writeJson = _json.writeJson
|
|
36
|
+
export const writeJSON = _json.writeJSON
|
|
37
|
+
export const writeJsonSync = _json.writeJsonSync
|
|
38
|
+
export const writeJSONSync = _json.writeJSONSync
|
|
39
|
+
export const outputJson = _json.outputJson
|
|
40
|
+
export const outputJSON = _json.outputJSON
|
|
41
|
+
export const outputJsonSync = _json.outputJsonSync
|
|
42
|
+
export const outputJSONSync = _json.outputJSONSync
|
|
43
|
+
export const mkdirs = _mkdirs.mkdirs
|
|
44
|
+
export const mkdirsSync = _mkdirs.mkdirsSync
|
|
45
|
+
export const mkdirp = _mkdirs.mkdirp
|
|
46
|
+
export const mkdirpSync = _mkdirs.mkdirpSync
|
|
47
|
+
export const ensureDir = _mkdirs.ensureDir
|
|
48
|
+
export const ensureDirSync = _mkdirs.ensureDirSync
|
|
49
|
+
export const move = _move.move
|
|
50
|
+
export const moveSync = _move.moveSync
|
|
51
|
+
export const outputFile = _outputFile.outputFile
|
|
52
|
+
export const outputFileSync = _outputFile.outputFileSync
|
|
53
|
+
export const pathExists = _pathExists.pathExists
|
|
54
|
+
export const pathExistsSync = _pathExists.pathExistsSync
|
|
55
|
+
export const remove = _remove.remove
|
|
56
|
+
export const removeSync = _remove.removeSync
|
|
57
|
+
|
|
58
|
+
export default {
|
|
59
|
+
..._copy,
|
|
60
|
+
..._empty,
|
|
61
|
+
..._ensure,
|
|
62
|
+
..._json,
|
|
63
|
+
..._mkdirs,
|
|
64
|
+
..._move,
|
|
65
|
+
..._outputFile,
|
|
66
|
+
..._pathExists,
|
|
67
|
+
..._remove
|
|
68
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
// This is adapted from https://github.com/normalize/mz
|
|
3
|
+
// Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
|
|
4
|
+
const u = require('universalify').fromCallback
|
|
5
|
+
const fs = require('graceful-fs')
|
|
6
|
+
|
|
7
|
+
const api = [
|
|
8
|
+
'access',
|
|
9
|
+
'appendFile',
|
|
10
|
+
'chmod',
|
|
11
|
+
'chown',
|
|
12
|
+
'close',
|
|
13
|
+
'copyFile',
|
|
14
|
+
'cp',
|
|
15
|
+
'fchmod',
|
|
16
|
+
'fchown',
|
|
17
|
+
'fdatasync',
|
|
18
|
+
'fstat',
|
|
19
|
+
'fsync',
|
|
20
|
+
'ftruncate',
|
|
21
|
+
'futimes',
|
|
22
|
+
'glob',
|
|
23
|
+
'lchmod',
|
|
24
|
+
'lchown',
|
|
25
|
+
'lutimes',
|
|
26
|
+
'link',
|
|
27
|
+
'lstat',
|
|
28
|
+
'mkdir',
|
|
29
|
+
'mkdtemp',
|
|
30
|
+
'open',
|
|
31
|
+
'opendir',
|
|
32
|
+
'readdir',
|
|
33
|
+
'readFile',
|
|
34
|
+
'readlink',
|
|
35
|
+
'realpath',
|
|
36
|
+
'rename',
|
|
37
|
+
'rm',
|
|
38
|
+
'rmdir',
|
|
39
|
+
'stat',
|
|
40
|
+
'statfs',
|
|
41
|
+
'symlink',
|
|
42
|
+
'truncate',
|
|
43
|
+
'unlink',
|
|
44
|
+
'utimes',
|
|
45
|
+
'writeFile'
|
|
46
|
+
].filter(key => {
|
|
47
|
+
// Some commands are not available on some systems. Ex:
|
|
48
|
+
// fs.cp was added in Node.js v16.7.0
|
|
49
|
+
// fs.statfs was added in Node v19.6.0, v18.15.0
|
|
50
|
+
// fs.glob was added in Node.js v22.0.0
|
|
51
|
+
// fs.lchown is not available on at least some Linux
|
|
52
|
+
return typeof fs[key] === 'function'
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// Export cloned fs:
|
|
56
|
+
Object.assign(exports, fs)
|
|
57
|
+
|
|
58
|
+
// Universalify async methods:
|
|
59
|
+
api.forEach(method => {
|
|
60
|
+
exports[method] = u(fs[method])
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
// We differ from mz/fs in that we still ship the old, broken, fs.exists()
|
|
64
|
+
// since we are a drop-in replacement for the native module
|
|
65
|
+
exports.exists = function (filename, callback) {
|
|
66
|
+
if (typeof callback === 'function') {
|
|
67
|
+
return fs.exists(filename, callback)
|
|
68
|
+
}
|
|
69
|
+
return new Promise(resolve => {
|
|
70
|
+
return fs.exists(filename, resolve)
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// fs.read(), fs.write(), fs.readv(), & fs.writev() need special treatment due to multiple callback args
|
|
75
|
+
|
|
76
|
+
exports.read = function (fd, buffer, offset, length, position, callback) {
|
|
77
|
+
if (typeof callback === 'function') {
|
|
78
|
+
return fs.read(fd, buffer, offset, length, position, callback)
|
|
79
|
+
}
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
|
|
82
|
+
if (err) return reject(err)
|
|
83
|
+
resolve({ bytesRead, buffer })
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Function signature can be
|
|
89
|
+
// fs.write(fd, buffer[, offset[, length[, position]]], callback)
|
|
90
|
+
// OR
|
|
91
|
+
// fs.write(fd, string[, position[, encoding]], callback)
|
|
92
|
+
// We need to handle both cases, so we use ...args
|
|
93
|
+
exports.write = function (fd, buffer, ...args) {
|
|
94
|
+
if (typeof args[args.length - 1] === 'function') {
|
|
95
|
+
return fs.write(fd, buffer, ...args)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return new Promise((resolve, reject) => {
|
|
99
|
+
fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
|
|
100
|
+
if (err) return reject(err)
|
|
101
|
+
resolve({ bytesWritten, buffer })
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Function signature is
|
|
107
|
+
// s.readv(fd, buffers[, position], callback)
|
|
108
|
+
// We need to handle the optional arg, so we use ...args
|
|
109
|
+
exports.readv = function (fd, buffers, ...args) {
|
|
110
|
+
if (typeof args[args.length - 1] === 'function') {
|
|
111
|
+
return fs.readv(fd, buffers, ...args)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return new Promise((resolve, reject) => {
|
|
115
|
+
fs.readv(fd, buffers, ...args, (err, bytesRead, buffers) => {
|
|
116
|
+
if (err) return reject(err)
|
|
117
|
+
resolve({ bytesRead, buffers })
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Function signature is
|
|
123
|
+
// s.writev(fd, buffers[, position], callback)
|
|
124
|
+
// We need to handle the optional arg, so we use ...args
|
|
125
|
+
exports.writev = function (fd, buffers, ...args) {
|
|
126
|
+
if (typeof args[args.length - 1] === 'function') {
|
|
127
|
+
return fs.writev(fd, buffers, ...args)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return new Promise((resolve, reject) => {
|
|
131
|
+
fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers) => {
|
|
132
|
+
if (err) return reject(err)
|
|
133
|
+
resolve({ bytesWritten, buffers })
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// fs.realpath.native sometimes not available if fs is monkey-patched
|
|
139
|
+
if (typeof fs.realpath.native === 'function') {
|
|
140
|
+
exports.realpath.native = u(fs.realpath.native)
|
|
141
|
+
} else {
|
|
142
|
+
process.emitWarning(
|
|
143
|
+
'fs.realpath.native is not a function. Is fs being monkey-patched?',
|
|
144
|
+
'Warning', 'fs-extra-WARN0003'
|
|
145
|
+
)
|
|
146
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
// Export promiseified graceful-fs:
|
|
5
|
+
...require('./fs'),
|
|
6
|
+
// Export extra methods:
|
|
7
|
+
...require('./copy'),
|
|
8
|
+
...require('./empty'),
|
|
9
|
+
...require('./ensure'),
|
|
10
|
+
...require('./json'),
|
|
11
|
+
...require('./mkdirs'),
|
|
12
|
+
...require('./move'),
|
|
13
|
+
...require('./output-file'),
|
|
14
|
+
...require('./path-exists'),
|
|
15
|
+
...require('./remove')
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const u = require('universalify').fromPromise
|
|
4
|
+
const jsonFile = require('./jsonfile')
|
|
5
|
+
|
|
6
|
+
jsonFile.outputJson = u(require('./output-json'))
|
|
7
|
+
jsonFile.outputJsonSync = require('./output-json-sync')
|
|
8
|
+
// aliases
|
|
9
|
+
jsonFile.outputJSON = jsonFile.outputJson
|
|
10
|
+
jsonFile.outputJSONSync = jsonFile.outputJsonSync
|
|
11
|
+
jsonFile.writeJSON = jsonFile.writeJson
|
|
12
|
+
jsonFile.writeJSONSync = jsonFile.writeJsonSync
|
|
13
|
+
jsonFile.readJSON = jsonFile.readJson
|
|
14
|
+
jsonFile.readJSONSync = jsonFile.readJsonSync
|
|
15
|
+
|
|
16
|
+
module.exports = jsonFile
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { stringify } = require('jsonfile/utils')
|
|
4
|
+
const { outputFileSync } = require('../output-file')
|
|
5
|
+
|
|
6
|
+
function outputJsonSync (file, data, options) {
|
|
7
|
+
const str = stringify(data, options)
|
|
8
|
+
|
|
9
|
+
outputFileSync(file, str, options)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = outputJsonSync
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { stringify } = require('jsonfile/utils')
|
|
4
|
+
const { outputFile } = require('../output-file')
|
|
5
|
+
|
|
6
|
+
async function outputJson (file, data, options = {}) {
|
|
7
|
+
const str = stringify(data, options)
|
|
8
|
+
|
|
9
|
+
await outputFile(file, str, options)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = outputJson
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const u = require('universalify').fromPromise
|
|
3
|
+
const { makeDir: _makeDir, makeDirSync } = require('./make-dir')
|
|
4
|
+
const makeDir = u(_makeDir)
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
mkdirs: makeDir,
|
|
8
|
+
mkdirsSync: makeDirSync,
|
|
9
|
+
// alias
|
|
10
|
+
mkdirp: makeDir,
|
|
11
|
+
mkdirpSync: makeDirSync,
|
|
12
|
+
ensureDir: makeDir,
|
|
13
|
+
ensureDirSync: makeDirSync
|
|
14
|
+
}
|