@appium/support 7.0.4 → 7.0.6
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/build/lib/console.d.ts +42 -88
- package/build/lib/console.d.ts.map +1 -1
- package/build/lib/console.js +25 -85
- package/build/lib/console.js.map +1 -1
- package/build/lib/doctor.d.ts +6 -18
- package/build/lib/doctor.d.ts.map +1 -1
- package/build/lib/doctor.js +0 -15
- package/build/lib/doctor.js.map +1 -1
- package/build/lib/env.d.ts +14 -20
- package/build/lib/env.d.ts.map +1 -1
- package/build/lib/env.js +24 -61
- package/build/lib/env.js.map +1 -1
- package/build/lib/fs.d.ts +109 -148
- package/build/lib/fs.d.ts.map +1 -1
- package/build/lib/fs.js +130 -230
- package/build/lib/fs.js.map +1 -1
- package/build/lib/image-util.d.ts +7 -6
- package/build/lib/image-util.d.ts.map +1 -1
- package/build/lib/image-util.js +9 -6
- package/build/lib/image-util.js.map +1 -1
- package/build/lib/index.d.ts +19 -17
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/logger.d.ts +1 -1
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +1 -1
- package/build/lib/logger.js.map +1 -1
- package/build/lib/logging.d.ts +7 -15
- package/build/lib/logging.d.ts.map +1 -1
- package/build/lib/logging.js +36 -62
- package/build/lib/logging.js.map +1 -1
- package/build/lib/mjpeg.d.ts +19 -56
- package/build/lib/mjpeg.d.ts.map +1 -1
- package/build/lib/mjpeg.js +55 -78
- package/build/lib/mjpeg.js.map +1 -1
- package/build/lib/mkdirp.d.ts +4 -1
- package/build/lib/mkdirp.d.ts.map +1 -1
- package/build/lib/mkdirp.js +1 -2
- package/build/lib/mkdirp.js.map +1 -1
- package/build/lib/net.d.ts +52 -90
- package/build/lib/net.d.ts.map +1 -1
- package/build/lib/net.js +104 -193
- package/build/lib/net.js.map +1 -1
- package/build/lib/node.d.ts +16 -17
- package/build/lib/node.d.ts.map +1 -1
- package/build/lib/node.js +115 -120
- package/build/lib/node.js.map +1 -1
- package/build/lib/npm.d.ts +65 -86
- package/build/lib/npm.d.ts.map +1 -1
- package/build/lib/npm.js +64 -122
- package/build/lib/npm.js.map +1 -1
- package/build/lib/plist.d.ts +36 -29
- package/build/lib/plist.d.ts.map +1 -1
- package/build/lib/plist.js +62 -59
- package/build/lib/plist.js.map +1 -1
- package/build/lib/process.d.ts +19 -2
- package/build/lib/process.d.ts.map +1 -1
- package/build/lib/process.js +24 -7
- package/build/lib/process.js.map +1 -1
- package/build/lib/system.d.ts +41 -6
- package/build/lib/system.d.ts.map +1 -1
- package/build/lib/system.js +49 -14
- package/build/lib/system.js.map +1 -1
- package/build/lib/tempdir.d.ts +26 -49
- package/build/lib/tempdir.d.ts.map +1 -1
- package/build/lib/tempdir.js +46 -78
- package/build/lib/tempdir.js.map +1 -1
- package/build/lib/timing.d.ts +28 -22
- package/build/lib/timing.d.ts.map +1 -1
- package/build/lib/timing.js +16 -17
- package/build/lib/timing.js.map +1 -1
- package/build/lib/util.d.ts +164 -181
- package/build/lib/util.d.ts.map +1 -1
- package/build/lib/util.js +198 -253
- package/build/lib/util.js.map +1 -1
- package/build/lib/zip.d.ts +81 -139
- package/build/lib/zip.d.ts.map +1 -1
- package/build/lib/zip.js +235 -283
- package/build/lib/zip.js.map +1 -1
- package/lib/console.ts +139 -0
- package/lib/{doctor.js → doctor.ts} +6 -20
- package/lib/{env.js → env.ts} +34 -62
- package/lib/fs.ts +453 -0
- package/lib/image-util.ts +40 -0
- package/lib/index.ts +1 -0
- package/lib/{logger.js → logger.ts} +1 -1
- package/lib/logging.ts +157 -0
- package/lib/mjpeg.ts +186 -0
- package/lib/{mkdirp.js → mkdirp.ts} +2 -2
- package/lib/net.ts +305 -0
- package/lib/{node.js → node.ts} +136 -135
- package/lib/npm.ts +291 -0
- package/lib/plist.ts +187 -0
- package/lib/process.ts +62 -0
- package/lib/system.ts +95 -0
- package/lib/tempdir.ts +115 -0
- package/lib/{timing.js → timing.ts} +28 -33
- package/lib/util.ts +561 -0
- package/lib/{zip.js → zip.ts} +344 -299
- package/package.json +24 -26
- package/tsconfig.json +3 -5
- package/index.js +0 -1
- package/lib/console.js +0 -173
- package/lib/fs.js +0 -496
- package/lib/image-util.js +0 -32
- package/lib/logging.js +0 -145
- package/lib/mjpeg.js +0 -207
- package/lib/net.js +0 -336
- package/lib/npm.js +0 -310
- package/lib/plist.js +0 -182
- package/lib/process.js +0 -46
- package/lib/system.js +0 -48
- package/lib/tempdir.js +0 -131
- package/lib/util.js +0 -585
package/build/lib/env.js
CHANGED
|
@@ -38,32 +38,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.resolveManifestPath = exports.resolveAppiumHome = exports.readPackageInDir = exports.findAppiumDependencyPackage = exports.MANIFEST_RELATIVE_PATH = exports.MANIFEST_BASENAME = exports.DEFAULT_APPIUM_HOME = void 0;
|
|
40
40
|
exports.hasAppiumDependency = hasAppiumDependency;
|
|
41
|
-
// @ts-check
|
|
42
41
|
const lodash_1 = __importDefault(require("lodash"));
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const read_pkg_1 =
|
|
42
|
+
const node_os_1 = require("node:os");
|
|
43
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
44
|
+
const read_pkg_1 = require("read-pkg");
|
|
46
45
|
const semver = __importStar(require("semver"));
|
|
47
46
|
/**
|
|
48
47
|
* Path to the default `APPIUM_HOME` dir (`~/.appium`).
|
|
49
|
-
* @type {string}
|
|
50
48
|
*/
|
|
51
|
-
exports.DEFAULT_APPIUM_HOME =
|
|
49
|
+
exports.DEFAULT_APPIUM_HOME = node_path_1.default.resolve((0, node_os_1.homedir)(), '.appium');
|
|
52
50
|
/**
|
|
53
51
|
* Basename of extension manifest file.
|
|
54
|
-
* @type {string}
|
|
55
52
|
*/
|
|
56
53
|
exports.MANIFEST_BASENAME = 'extensions.yaml';
|
|
57
54
|
/**
|
|
58
55
|
* Relative path to extension manifest file from `APPIUM_HOME`.
|
|
59
|
-
* @type {string}
|
|
60
56
|
*/
|
|
61
|
-
exports.MANIFEST_RELATIVE_PATH =
|
|
57
|
+
exports.MANIFEST_RELATIVE_PATH = node_path_1.default.join('node_modules', '.cache', 'appium', exports.MANIFEST_BASENAME);
|
|
62
58
|
/**
|
|
63
59
|
* Resolves `true` if an `appium` dependency can be found somewhere in the given `cwd`.
|
|
64
|
-
*
|
|
65
|
-
* @param {string} cwd
|
|
66
|
-
* @returns {Promise<boolean>}
|
|
67
60
|
*/
|
|
68
61
|
async function hasAppiumDependency(cwd) {
|
|
69
62
|
return Boolean(await (0, exports.findAppiumDependencyPackage)(cwd));
|
|
@@ -73,53 +66,38 @@ async function hasAppiumDependency(cwd) {
|
|
|
73
66
|
*
|
|
74
67
|
* Looks at `dependencies` and `devDependencies` for `appium`.
|
|
75
68
|
*/
|
|
76
|
-
exports.findAppiumDependencyPackage = lodash_1.default.memoize(
|
|
77
|
-
/**
|
|
78
|
-
* @param {string} [cwd]
|
|
79
|
-
* @param {string|semver.Range} [acceptableVersionRange='>=2.0.0-beta'] The expected
|
|
80
|
-
* semver-compatible range for the Appium dependency. Packages that have 'appium' dependency
|
|
81
|
-
* not satisfying this range will be skipped.
|
|
82
|
-
* @returns {Promise<string|undefined>}
|
|
83
|
-
*/
|
|
84
|
-
async function findAppiumDependencyPackage(cwd = process.cwd(), acceptableVersionRange = '>=2.0.0-beta') {
|
|
85
|
-
/**
|
|
86
|
-
* Tries to read `package.json` in `root` and resolves the identity if it depends on `appium`;
|
|
87
|
-
* otherwise resolves `undefined`.
|
|
88
|
-
* @param {string} root
|
|
89
|
-
* @returns {Promise<string|undefined>}
|
|
90
|
-
*/
|
|
69
|
+
exports.findAppiumDependencyPackage = lodash_1.default.memoize(async function findAppiumDependencyPackage(cwd = process.cwd(), acceptableVersionRange = '>=2.0.0-beta') {
|
|
91
70
|
const readPkg = async (root) => {
|
|
92
71
|
try {
|
|
93
72
|
const pkg = await (0, exports.readPackageInDir)(root);
|
|
94
73
|
const version = semver.minVersion(String(pkg?.dependencies?.appium ??
|
|
95
74
|
pkg?.devDependencies?.appium ??
|
|
96
75
|
pkg?.peerDependencies?.appium));
|
|
97
|
-
return version && semver.satisfies(version, acceptableVersionRange)
|
|
76
|
+
return version && semver.satisfies(version, acceptableVersionRange)
|
|
77
|
+
? root
|
|
78
|
+
: undefined;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return undefined;
|
|
98
82
|
}
|
|
99
|
-
catch { }
|
|
100
83
|
};
|
|
101
|
-
let currentDir =
|
|
84
|
+
let currentDir = node_path_1.default.resolve(cwd);
|
|
102
85
|
let isAtFsRoot = false;
|
|
103
86
|
while (!isAtFsRoot) {
|
|
104
87
|
const result = await readPkg(currentDir);
|
|
105
88
|
if (result) {
|
|
106
89
|
return result;
|
|
107
90
|
}
|
|
108
|
-
currentDir =
|
|
109
|
-
isAtFsRoot = currentDir.length <=
|
|
91
|
+
currentDir = node_path_1.default.dirname(currentDir);
|
|
92
|
+
isAtFsRoot = currentDir.length <= node_path_1.default.dirname(currentDir).length;
|
|
110
93
|
}
|
|
94
|
+
return undefined;
|
|
111
95
|
});
|
|
112
96
|
/**
|
|
113
97
|
* Read a `package.json` in dir `cwd`. If none found, return `undefined`.
|
|
114
98
|
*/
|
|
115
|
-
exports.readPackageInDir = lodash_1.default.memoize(
|
|
116
|
-
|
|
117
|
-
*
|
|
118
|
-
* @param {string} cwd - Directory ostensibly having a `package.json`
|
|
119
|
-
* @returns {Promise<import('read-pkg').NormalizedPackageJson|undefined>}
|
|
120
|
-
*/
|
|
121
|
-
async function _readPackageInDir(cwd) {
|
|
122
|
-
return await (0, read_pkg_1.default)({ cwd, normalize: true });
|
|
99
|
+
exports.readPackageInDir = lodash_1.default.memoize(async function _readPackageInDir(cwd) {
|
|
100
|
+
return await (0, read_pkg_1.readPackage)({ cwd, normalize: true });
|
|
123
101
|
});
|
|
124
102
|
/**
|
|
125
103
|
* Determines location of Appium's "home" dir
|
|
@@ -129,19 +107,14 @@ async function _readPackageInDir(cwd) {
|
|
|
129
107
|
*
|
|
130
108
|
* All returned paths will be absolute.
|
|
131
109
|
*/
|
|
132
|
-
exports.resolveAppiumHome = lodash_1.default.memoize(
|
|
133
|
-
|
|
134
|
-
* @param {string} [cwd] - Current working directory. _Must_ be absolute, if specified.
|
|
135
|
-
* @returns {Promise<string>}
|
|
136
|
-
*/
|
|
137
|
-
async function _resolveAppiumHome(cwd = process.cwd()) {
|
|
138
|
-
if (!path_1.default.isAbsolute(cwd)) {
|
|
110
|
+
exports.resolveAppiumHome = lodash_1.default.memoize(async function _resolveAppiumHome(cwd = process.cwd()) {
|
|
111
|
+
if (!node_path_1.default.isAbsolute(cwd)) {
|
|
139
112
|
throw new TypeError('`cwd` parameter must be an absolute path');
|
|
140
113
|
}
|
|
141
114
|
if (process.env.APPIUM_HOME) {
|
|
142
|
-
return
|
|
115
|
+
return node_path_1.default.resolve(cwd, process.env.APPIUM_HOME);
|
|
143
116
|
}
|
|
144
|
-
return await (0, exports.findAppiumDependencyPackage)(cwd) ?? exports.DEFAULT_APPIUM_HOME;
|
|
117
|
+
return (await (0, exports.findAppiumDependencyPackage)(cwd)) ?? exports.DEFAULT_APPIUM_HOME;
|
|
145
118
|
});
|
|
146
119
|
/**
|
|
147
120
|
* Figure out manifest path based on `appiumHome`.
|
|
@@ -149,17 +122,7 @@ async function _resolveAppiumHome(cwd = process.cwd()) {
|
|
|
149
122
|
* The assumption is that, if `appiumHome` has been provided, it was resolved via {@link resolveAppiumHome `resolveAppiumHome()`}! If unsure,
|
|
150
123
|
* don't pass a parameter and let `resolveAppiumHome()` handle it.
|
|
151
124
|
*/
|
|
152
|
-
exports.resolveManifestPath = lodash_1.default.memoize(
|
|
153
|
-
|
|
154
|
-
* @param {string} [appiumHome] - Appium home directory
|
|
155
|
-
* @returns {Promise<string>}
|
|
156
|
-
*/
|
|
157
|
-
async function _resolveManifestPath(appiumHome) {
|
|
158
|
-
// can you "await" in a default parameter? is that a good idea?
|
|
159
|
-
appiumHome = appiumHome ?? (await (0, exports.resolveAppiumHome)());
|
|
160
|
-
return path_1.default.join(appiumHome, exports.MANIFEST_RELATIVE_PATH);
|
|
125
|
+
exports.resolveManifestPath = lodash_1.default.memoize(async function _resolveManifestPath(appiumHome) {
|
|
126
|
+
return node_path_1.default.join(appiumHome ?? await (0, exports.resolveAppiumHome)(), exports.MANIFEST_RELATIVE_PATH);
|
|
161
127
|
});
|
|
162
|
-
/**
|
|
163
|
-
* @typedef {import('read-pkg').NormalizedPackageJson} NormalizedPackageJson
|
|
164
|
-
*/
|
|
165
128
|
//# sourceMappingURL=env.js.map
|
package/build/lib/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../lib/env.
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../lib/env.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,kDAEC;AA/BD,oDAAuB;AACvB,qCAAgC;AAChC,0DAA6B;AAC7B,uCAAiE;AACjE,+CAAiC;AAEjC;;GAEG;AACU,QAAA,mBAAmB,GAAW,mBAAI,CAAC,OAAO,CAAC,IAAA,iBAAO,GAAE,EAAE,SAAS,CAAC,CAAC;AAE9E;;GAEG;AACU,QAAA,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD;;GAEG;AACU,QAAA,sBAAsB,GAAG,mBAAI,CAAC,IAAI,CAC7C,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,yBAAiB,CAClB,CAAC;AAEF;;GAEG;AACI,KAAK,UAAU,mBAAmB,CAAC,GAAW;IACnD,OAAO,OAAO,CAAC,MAAM,IAAA,mCAA2B,EAAC,GAAG,CAAC,CAAC,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACU,QAAA,2BAA2B,GAAG,gBAAC,CAAC,OAAO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,EAAC,EAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;AACnD,CAAC,CACF,CAAC;AAEF;;;;;;;GAOG;AACU,QAAA,iBAAiB,GAAG,gBAAC,CAAC,OAAO,CACxC,KAAK,UAAU,kBAAkB,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;IAC3D,IAAI,CAAC,mBAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,SAAS,CAAC,0CAA0C,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QAC5B,OAAO,mBAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,CAAC,MAAM,IAAA,mCAA2B,EAAC,GAAG,CAAC,CAAC,IAAI,2BAAmB,CAAC;AACzE,CAAC,CACF,CAAC;AAEF;;;;;GAKG;AACU,QAAA,mBAAmB,GAAG,gBAAC,CAAC,OAAO,CAC1C,KAAK,UAAU,oBAAoB,CACjC,UAAmB;IAEnB,OAAO,mBAAI,CAAC,IAAI,CACd,UAAU,IAAI,MAAM,IAAA,yBAAiB,GAAE,EAAE,8BAAsB,CAChE,CAAC;AACJ,CAAC,CACF,CAAC"}
|
package/build/lib/fs.d.ts
CHANGED
|
@@ -1,187 +1,148 @@
|
|
|
1
|
-
|
|
1
|
+
import B from 'bluebird';
|
|
2
|
+
import { close, constants, createReadStream, createWriteStream, promises as fsPromises, read, open, type PathLike, type MakeDirectoryOptions, type ReadAsyncOptions } from 'node:fs';
|
|
3
|
+
import type { GlobOptions } from 'glob';
|
|
4
|
+
import klaw from 'klaw';
|
|
5
|
+
import type { Walker } from 'klaw';
|
|
6
|
+
import ncp from 'ncp';
|
|
7
|
+
import { type NormalizeOptions, type NormalizedPackageJson } from 'read-pkg';
|
|
8
|
+
import sanitize from 'sanitize-filename';
|
|
9
|
+
import which from 'which';
|
|
10
|
+
/** Options for {@linkcode fs.mv} */
|
|
11
|
+
export interface MvOptions {
|
|
12
|
+
/** Whether to automatically create the destination folder structure */
|
|
13
|
+
mkdirp?: boolean;
|
|
14
|
+
/** Set to false to throw if the destination file already exists */
|
|
15
|
+
clobber?: boolean;
|
|
16
|
+
/** @deprecated Legacy, not used */
|
|
17
|
+
limit?: number;
|
|
18
|
+
}
|
|
2
19
|
/**
|
|
3
|
-
*
|
|
20
|
+
* Callback used during directory walking in {@linkcode fs.walkDir}.
|
|
21
|
+
* Return true to stop walking.
|
|
4
22
|
*/
|
|
5
|
-
export type WalkDirCallback = (itemPath: string, isDirectory: boolean) => boolean | void
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
mkdirp?: boolean | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Set it to false if you want an exception to be thrown
|
|
15
|
-
* if the destination file already exists
|
|
16
|
-
*/
|
|
17
|
-
clobber?: boolean | undefined;
|
|
18
|
-
/**
|
|
19
|
-
* Legacy deprecated property, not used anymore
|
|
20
|
-
*/
|
|
21
|
-
limit?: number | undefined;
|
|
22
|
-
};
|
|
23
|
-
export type ReadFn<TBuffer extends NodeJS.ArrayBufferView> = (fd: number, buffer: TBuffer | import("node:fs").ReadAsyncOptions<TBuffer>, offset?: number | undefined, length?: number | undefined, position?: number | null | undefined) => B<{
|
|
23
|
+
export type WalkDirCallback = (itemPath: string, isDirectory: boolean) => boolean | void | Promise<boolean | void>;
|
|
24
|
+
/**
|
|
25
|
+
* Promisified fs.read signature.
|
|
26
|
+
* @template TBuffer - Buffer type (e.g. NodeJS.ArrayBufferView)
|
|
27
|
+
* @deprecated use `typeof read.__promisify__` instead
|
|
28
|
+
*/
|
|
29
|
+
export type ReadFn<TBuffer extends NodeJS.ArrayBufferView = NodeJS.ArrayBufferView> = (fd: number, buffer: TBuffer | ReadAsyncOptions<TBuffer>, offset?: number, length?: number, position?: number | null) => B<{
|
|
24
30
|
bytesRead: number;
|
|
25
31
|
buffer: TBuffer;
|
|
26
32
|
}>;
|
|
27
|
-
export
|
|
33
|
+
export declare const fs: {
|
|
28
34
|
/**
|
|
29
|
-
* Resolves `true` if `path` is _readable_
|
|
30
|
-
*
|
|
35
|
+
* Resolves `true` if `path` is _readable_.
|
|
31
36
|
* On Windows, ACLs are not supported, so this becomes a simple check for existence.
|
|
32
|
-
*
|
|
33
37
|
* This function will never reject.
|
|
34
|
-
* @param {PathLike} path
|
|
35
|
-
* @returns {Promise<boolean>}
|
|
36
38
|
*/
|
|
37
|
-
|
|
39
|
+
hasAccess(filePath: PathLike): Promise<boolean>;
|
|
38
40
|
/**
|
|
39
41
|
* Resolves `true` if `path` is executable; `false` otherwise.
|
|
40
|
-
*
|
|
41
|
-
* On Windows, this function delegates to {@linkcode fs.hasAccess}.
|
|
42
|
-
*
|
|
42
|
+
* On Windows, delegates to {@linkcode fs.hasAccess}.
|
|
43
43
|
* This function will never reject.
|
|
44
|
-
* @param {PathLike} path
|
|
45
|
-
* @returns {Promise<boolean>}
|
|
46
44
|
*/
|
|
47
|
-
|
|
45
|
+
isExecutable(filePath: PathLike): Promise<boolean>;
|
|
46
|
+
/** Alias for {@linkcode fs.hasAccess} */
|
|
47
|
+
exists(filePath: PathLike): Promise<boolean>;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {PathLike} path
|
|
51
|
-
*/
|
|
52
|
-
export function exists(path: PathLike): Promise<boolean>;
|
|
53
|
-
/**
|
|
54
|
-
* Remove a directory and all its contents, recursively
|
|
55
|
-
* @param {PathLike} filepath
|
|
56
|
-
* @returns Promise<void>
|
|
49
|
+
* Remove a directory and all its contents, recursively.
|
|
57
50
|
* @see https://nodejs.org/api/fs.html#fspromisesrmpath-options
|
|
58
51
|
*/
|
|
59
|
-
|
|
52
|
+
rimraf(filepath: PathLike): Promise<void>;
|
|
60
53
|
/**
|
|
61
|
-
* Remove a directory and all its contents, recursively
|
|
62
|
-
* @param {PathLike} filepath
|
|
63
|
-
* @returns undefined
|
|
54
|
+
* Remove a directory and all its contents, recursively (sync).
|
|
64
55
|
* @see https://nodejs.org/api/fs.html#fsrmsyncpath-options
|
|
65
56
|
*/
|
|
66
|
-
|
|
57
|
+
rimrafSync(filepath: PathLike): void;
|
|
67
58
|
/**
|
|
68
|
-
* Like Node.js
|
|
69
|
-
*
|
|
70
|
-
* @param {string|Buffer|URL} filepath
|
|
71
|
-
* @param {import('fs').MakeDirectoryOptions} [opts]
|
|
72
|
-
* @returns {Promise<string|undefined>}
|
|
59
|
+
* Like Node.js `fsPromises.mkdir()`, but will not reject if the directory already exists.
|
|
73
60
|
* @see https://nodejs.org/api/fs.html#fspromisesmkdirpath-options
|
|
74
61
|
*/
|
|
75
|
-
|
|
62
|
+
mkdir(filepath: string | Buffer | URL, opts?: MakeDirectoryOptions): Promise<string | undefined>;
|
|
76
63
|
/**
|
|
77
|
-
* Copies files
|
|
78
|
-
* @param {string} source - Source to copy
|
|
79
|
-
* @param {string} destination - Destination to copy to
|
|
80
|
-
* @param {ncp.Options} [opts] - Additional arguments to pass to `ncp`
|
|
64
|
+
* Copies files and entire directories.
|
|
81
65
|
* @see https://npm.im/ncp
|
|
82
|
-
* @returns {Promise<void>}
|
|
83
|
-
*/
|
|
84
|
-
export function copyFile(source: string, destination: string, opts?: ncp.Options): Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
* Create an MD5 hash of a file.
|
|
87
|
-
* @param {PathLike} filePath
|
|
88
|
-
* @returns {Promise<string>}
|
|
89
66
|
*/
|
|
90
|
-
|
|
67
|
+
copyFile(source: string, destination: string, opts?: ncp.Options): Promise<void>;
|
|
68
|
+
/** Create an MD5 hash of a file. */
|
|
69
|
+
md5(filePath: PathLike): Promise<string>;
|
|
91
70
|
/**
|
|
92
|
-
* Move a file or a folder
|
|
93
|
-
*
|
|
94
|
-
* @param {string} from Source file/folder
|
|
95
|
-
* @param {string} to Destination file/folder
|
|
96
|
-
* @param {mv} [opts] Move options
|
|
97
|
-
* @returns {Promise<void>}
|
|
71
|
+
* Move a file or a folder.
|
|
98
72
|
*/
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
export { sanitize as sanitizeName };
|
|
73
|
+
mv(from: string, to: string, opts?: MvOptions): Promise<void>;
|
|
74
|
+
/** Find path to an executable in system `PATH`. @see https://github.com/npm/node-which */
|
|
75
|
+
which: typeof which;
|
|
103
76
|
/**
|
|
104
|
-
*
|
|
105
|
-
* @
|
|
106
|
-
* @param {string} [algorithm]
|
|
107
|
-
* @returns {Promise<string>}
|
|
77
|
+
* Given a glob pattern, resolve with list of files matching that pattern.
|
|
78
|
+
* @see https://github.com/isaacs/node-glob
|
|
108
79
|
*/
|
|
109
|
-
|
|
80
|
+
glob(pattern: string, options?: GlobOptions): Promise<string[]>;
|
|
81
|
+
/** Sanitize a filename. @see https://github.com/parshap/node-sanitize-filename */
|
|
82
|
+
sanitizeName: typeof sanitize;
|
|
83
|
+
/** Create a hex digest of some file at `filePath`. */
|
|
84
|
+
hash(filePath: PathLike, algorithm?: string): Promise<string>;
|
|
110
85
|
/**
|
|
111
|
-
* Returns
|
|
112
|
-
*
|
|
113
|
-
* @param {string} dir - Dir to start walking at
|
|
114
|
-
* @param {import('klaw').Options} [opts]
|
|
115
|
-
* @returns {import('klaw').Walker}
|
|
86
|
+
* Returns a Walker instance (readable stream / async iterator).
|
|
116
87
|
* @see https://www.npmjs.com/package/klaw
|
|
117
88
|
*/
|
|
118
|
-
|
|
89
|
+
walk(dir: string, opts?: klaw.Options): Walker;
|
|
90
|
+
/** Recursively create a directory. */
|
|
91
|
+
mkdirp(dir: PathLike): Promise<string | undefined>;
|
|
119
92
|
/**
|
|
120
|
-
*
|
|
121
|
-
* @param
|
|
122
|
-
* @
|
|
93
|
+
* Walks a directory; callback is invoked with path joined with dir.
|
|
94
|
+
* @param dir - Directory path to start walking
|
|
95
|
+
* @param recursive - If true, walk subdirectories
|
|
96
|
+
* @param callback - Called for each path; return true to stop
|
|
97
|
+
* @returns The found path or null if not found
|
|
123
98
|
*/
|
|
124
|
-
|
|
99
|
+
walkDir(dir: string, recursive: boolean, callback: WalkDirCallback): Promise<string | null>;
|
|
125
100
|
/**
|
|
126
|
-
*
|
|
127
|
-
* @
|
|
128
|
-
* @param {boolean} recursive Set it to true if you want to continue walking sub directories
|
|
129
|
-
* @param {WalkDirCallback} callback The callback to be called when a new path is found
|
|
130
|
-
* @throws {Error} If the `dir` parameter contains a path to an invalid folder
|
|
131
|
-
* @returns {Promise<string?>} returns the found path or null if the item was not found
|
|
101
|
+
* Reads the closest `package.json` from absolute path `dir`.
|
|
102
|
+
* @throws If there were problems finding or reading `package.json`
|
|
132
103
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
* @param {string} dir - Directory to search from
|
|
137
|
-
* @param {import('read-pkg').Options} [opts] - Additional options for `read-pkg`
|
|
138
|
-
* @throws {Error} If there were problems finding or reading a `package.json` file
|
|
139
|
-
* @returns {import('read-pkg').NormalizedPackageJson} A parsed `package.json`
|
|
140
|
-
*/
|
|
141
|
-
export function readPackageJsonFrom(dir: string, opts?: import("read-pkg").Options): import("read-pkg").NormalizedPackageJson;
|
|
104
|
+
readPackageJsonFrom(dir: string, opts?: NormalizeOptions & {
|
|
105
|
+
cwd?: string;
|
|
106
|
+
}): NormalizedPackageJson;
|
|
142
107
|
/**
|
|
143
108
|
* Finds the project root directory from `dir`.
|
|
144
|
-
* @
|
|
145
|
-
* @throws
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
import { promises as fsPromises } from 'fs';
|
|
184
|
-
import { constants } from 'fs';
|
|
185
|
-
import { createWriteStream } from 'fs';
|
|
186
|
-
import { createReadStream } from 'fs';
|
|
109
|
+
* @throws TypeError If `dir` is not a non-empty absolute path
|
|
110
|
+
* @throws Error If project root could not be found
|
|
111
|
+
*/
|
|
112
|
+
findRoot(dir: string): string;
|
|
113
|
+
access: typeof fsPromises.access;
|
|
114
|
+
appendFile: typeof fsPromises.appendFile;
|
|
115
|
+
chmod: typeof fsPromises.chmod;
|
|
116
|
+
close: typeof close.__promisify__;
|
|
117
|
+
constants: typeof constants;
|
|
118
|
+
createWriteStream: typeof createWriteStream;
|
|
119
|
+
createReadStream: typeof createReadStream;
|
|
120
|
+
lstat: typeof fsPromises.lstat;
|
|
121
|
+
/**
|
|
122
|
+
* Promisified fs.open. Resolves with a file descriptor (not FileHandle).
|
|
123
|
+
* Use fs.openFile for a FileHandle.
|
|
124
|
+
*/
|
|
125
|
+
open: typeof open.__promisify__;
|
|
126
|
+
openFile: typeof fsPromises.open;
|
|
127
|
+
readdir: typeof fsPromises.readdir;
|
|
128
|
+
read: typeof read.__promisify__;
|
|
129
|
+
readFile: typeof fsPromises.readFile;
|
|
130
|
+
readlink: typeof fsPromises.readlink;
|
|
131
|
+
realpath: typeof fsPromises.realpath;
|
|
132
|
+
rename: typeof fsPromises.rename;
|
|
133
|
+
stat: typeof fsPromises.stat;
|
|
134
|
+
symlink: typeof fsPromises.symlink;
|
|
135
|
+
unlink: typeof fsPromises.unlink;
|
|
136
|
+
write: (arg1: number, arg2: string) => B<number>;
|
|
137
|
+
writeFile: typeof fsPromises.writeFile;
|
|
138
|
+
/** @deprecated Use `constants.F_OK` instead. */
|
|
139
|
+
F_OK: number;
|
|
140
|
+
/** @deprecated Use `constants.R_OK` instead. */
|
|
141
|
+
R_OK: number;
|
|
142
|
+
/** @deprecated Use `constants.W_OK` instead. */
|
|
143
|
+
W_OK: number;
|
|
144
|
+
/** @deprecated Use `constants.X_OK` instead. */
|
|
145
|
+
X_OK: number;
|
|
146
|
+
};
|
|
147
|
+
export default fs;
|
|
187
148
|
//# sourceMappingURL=fs.d.ts.map
|
package/build/lib/fs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../lib/fs.
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../lib/fs.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,UAAU,CAAC;AAEzB,OAAO,EACL,KAAK,EACL,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,IAAI,UAAU,EACtB,IAAI,EAGJ,IAAI,EACJ,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAEtB,MAAM,SAAS,CAAC;AAGjB,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,MAAM,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAEjC,OAAO,GAAG,MAAM,KAAK,CAAC;AAGtB,OAAO,EAAkB,KAAK,gBAAgB,EAAE,KAAK,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAC5F,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B,oCAAoC;AACpC,MAAM,WAAW,SAAS;IACxB,uEAAuE;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,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