@ohos-ports/actions-io 0.0.0-stage → 3.0.2-beta.0
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/LICENSE.md +9 -0
- package/README.md +64 -2
- package/lib/io-util.d.ts +32 -0
- package/lib/io-util.js +181 -0
- package/lib/io-util.js.map +1 -0
- package/lib/io.d.ts +64 -0
- package/lib/io.js +271 -0
- package/lib/io.js.map +1 -0
- package/package.json +43 -4
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright 2019 GitHub
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@actions/io`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Core functions for cli filesystem scenarios
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
#### mkdir -p
|
|
8
|
+
|
|
9
|
+
Recursively make a directory. Follows rules specified in [man mkdir](https://linux.die.net/man/1/mkdir) with the `-p` option specified:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
const io = require('@actions/io');
|
|
13
|
+
|
|
14
|
+
await io.mkdirP('path/to/make');
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
#### cp/mv
|
|
18
|
+
|
|
19
|
+
Copy or move files or folders. Follows rules specified in [man cp](https://linux.die.net/man/1/cp) and [man mv](https://linux.die.net/man/1/mv):
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
const io = require('@actions/io');
|
|
23
|
+
|
|
24
|
+
// Recursive must be true for directories
|
|
25
|
+
const options = { recursive: true, force: false }
|
|
26
|
+
|
|
27
|
+
await io.cp('path/to/directory', 'path/to/dest', options);
|
|
28
|
+
await io.mv('path/to/file', 'path/to/dest');
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### rm -rf
|
|
32
|
+
|
|
33
|
+
Remove a file or folder recursively. Follows rules specified in [man rm](https://linux.die.net/man/1/rm) with the `-r` and `-f` rules specified.
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
const io = require('@actions/io');
|
|
37
|
+
|
|
38
|
+
await io.rmRF('path/to/directory');
|
|
39
|
+
await io.rmRF('path/to/file');
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### which
|
|
43
|
+
|
|
44
|
+
Get the path to a tool and resolves via paths. Follows the rules specified in [man which](https://linux.die.net/man/1/which).
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
const exec = require('@actions/exec');
|
|
48
|
+
const io = require('@actions/io');
|
|
49
|
+
|
|
50
|
+
const pythonPath: string = await io.which('python', true)
|
|
51
|
+
|
|
52
|
+
await exec.exec(`"${pythonPath}"`, ['main.py']);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
# @ohos-ports/actions-io — HarmonyOS (OpenHarmony) adaptation notes
|
|
58
|
+
|
|
59
|
+
Port of `@actions/io@3.0.2` (name mapped per `@ohos-ports` scoped naming).
|
|
60
|
+
|
|
61
|
+
**Change:** `isUnixExecutable` now honors supplementary groups (POSIX semantics):
|
|
62
|
+
the group-execute branch accepts `stats.gid === process.getgid()` **or**
|
|
63
|
+
`process.getgroups().includes(stats.gid)`. On HarmonyOS, hmdfs presents user
|
|
64
|
+
files as `0770` with an owner uid/gid that may differ from the consuming
|
|
65
|
+
process, which previously made `io.which()` reject exec-able GNU binaries.
|
package/lib/io-util.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
export declare const chmod: typeof fs.promises.chmod, copyFile: typeof fs.promises.copyFile, lstat: typeof fs.promises.lstat, mkdir: typeof fs.promises.mkdir, open: typeof fs.promises.open, readdir: typeof fs.promises.readdir, rename: typeof fs.promises.rename, rm: typeof fs.promises.rm, rmdir: typeof fs.promises.rmdir, stat: typeof fs.promises.stat, symlink: typeof fs.promises.symlink, unlink: typeof fs.promises.unlink;
|
|
3
|
+
export declare const IS_WINDOWS: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Custom implementation of readlink to ensure Windows junctions
|
|
6
|
+
* maintain trailing backslash for backward compatibility with Node.js < 24
|
|
7
|
+
*
|
|
8
|
+
* In Node.js 20, Windows junctions (directory symlinks) always returned paths
|
|
9
|
+
* with trailing backslashes. Node.js 24 removed this behavior, which breaks
|
|
10
|
+
* code that relied on this format for path operations.
|
|
11
|
+
*
|
|
12
|
+
* This implementation restores the Node 20 behavior by adding a trailing
|
|
13
|
+
* backslash to all junction results on Windows.
|
|
14
|
+
*/
|
|
15
|
+
export declare function readlink(fsPath: string): Promise<string>;
|
|
16
|
+
export declare const UV_FS_O_EXLOCK = 268435456;
|
|
17
|
+
export declare const READONLY: number;
|
|
18
|
+
export declare function exists(fsPath: string): Promise<boolean>;
|
|
19
|
+
export declare function isDirectory(fsPath: string, useStat?: boolean): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
|
|
22
|
+
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
|
23
|
+
*/
|
|
24
|
+
export declare function isRooted(p: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Best effort attempt to determine whether a file exists and is executable.
|
|
27
|
+
* @param filePath file path to check
|
|
28
|
+
* @param extensions additional file extensions to try
|
|
29
|
+
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
|
30
|
+
*/
|
|
31
|
+
export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>;
|
|
32
|
+
export declare function getCmdPath(): string;
|
package/lib/io-util.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import * as fs from 'fs';
|
|
11
|
+
import * as path from 'path';
|
|
12
|
+
export const { chmod, copyFile, lstat, mkdir, open, readdir, rename, rm, rmdir, stat, symlink, unlink } = fs.promises;
|
|
13
|
+
// export const {open} = 'fs'
|
|
14
|
+
export const IS_WINDOWS = process.platform === 'win32';
|
|
15
|
+
/**
|
|
16
|
+
* Custom implementation of readlink to ensure Windows junctions
|
|
17
|
+
* maintain trailing backslash for backward compatibility with Node.js < 24
|
|
18
|
+
*
|
|
19
|
+
* In Node.js 20, Windows junctions (directory symlinks) always returned paths
|
|
20
|
+
* with trailing backslashes. Node.js 24 removed this behavior, which breaks
|
|
21
|
+
* code that relied on this format for path operations.
|
|
22
|
+
*
|
|
23
|
+
* This implementation restores the Node 20 behavior by adding a trailing
|
|
24
|
+
* backslash to all junction results on Windows.
|
|
25
|
+
*/
|
|
26
|
+
export function readlink(fsPath) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const result = yield fs.promises.readlink(fsPath);
|
|
29
|
+
// On Windows, restore Node 20 behavior: add trailing backslash to all results
|
|
30
|
+
// since junctions on Windows are always directory links
|
|
31
|
+
if (IS_WINDOWS && !result.endsWith('\\')) {
|
|
32
|
+
return `${result}\\`;
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691
|
|
38
|
+
export const UV_FS_O_EXLOCK = 0x10000000;
|
|
39
|
+
export const READONLY = fs.constants.O_RDONLY;
|
|
40
|
+
export function exists(fsPath) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
try {
|
|
43
|
+
yield stat(fsPath);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (err.code === 'ENOENT') {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export function isDirectory(fsPath_1) {
|
|
55
|
+
return __awaiter(this, arguments, void 0, function* (fsPath, useStat = false) {
|
|
56
|
+
const stats = useStat ? yield stat(fsPath) : yield lstat(fsPath);
|
|
57
|
+
return stats.isDirectory();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
|
|
62
|
+
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
|
63
|
+
*/
|
|
64
|
+
export function isRooted(p) {
|
|
65
|
+
p = normalizeSeparators(p);
|
|
66
|
+
if (!p) {
|
|
67
|
+
throw new Error('isRooted() parameter "p" cannot be empty');
|
|
68
|
+
}
|
|
69
|
+
if (IS_WINDOWS) {
|
|
70
|
+
return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
|
|
71
|
+
); // e.g. C: or C:\hello
|
|
72
|
+
}
|
|
73
|
+
return p.startsWith('/');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Best effort attempt to determine whether a file exists and is executable.
|
|
77
|
+
* @param filePath file path to check
|
|
78
|
+
* @param extensions additional file extensions to try
|
|
79
|
+
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
|
80
|
+
*/
|
|
81
|
+
export function tryGetExecutablePath(filePath, extensions) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
let stats = undefined;
|
|
84
|
+
try {
|
|
85
|
+
// test file exists
|
|
86
|
+
stats = yield stat(filePath);
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
if (err.code !== 'ENOENT') {
|
|
90
|
+
// eslint-disable-next-line no-console
|
|
91
|
+
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (stats && stats.isFile()) {
|
|
95
|
+
if (IS_WINDOWS) {
|
|
96
|
+
// on Windows, test for valid extension
|
|
97
|
+
const upperExt = path.extname(filePath).toUpperCase();
|
|
98
|
+
if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
|
|
99
|
+
return filePath;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
if (isUnixExecutable(stats)) {
|
|
104
|
+
return filePath;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// try each extension
|
|
109
|
+
const originalFilePath = filePath;
|
|
110
|
+
for (const extension of extensions) {
|
|
111
|
+
filePath = originalFilePath + extension;
|
|
112
|
+
stats = undefined;
|
|
113
|
+
try {
|
|
114
|
+
stats = yield stat(filePath);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
if (err.code !== 'ENOENT') {
|
|
118
|
+
// eslint-disable-next-line no-console
|
|
119
|
+
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (stats && stats.isFile()) {
|
|
123
|
+
if (IS_WINDOWS) {
|
|
124
|
+
// preserve the case of the actual file (since an extension was appended)
|
|
125
|
+
try {
|
|
126
|
+
const directory = path.dirname(filePath);
|
|
127
|
+
const upperName = path.basename(filePath).toUpperCase();
|
|
128
|
+
for (const actualName of yield readdir(directory)) {
|
|
129
|
+
if (upperName === actualName.toUpperCase()) {
|
|
130
|
+
filePath = path.join(directory, actualName);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
// eslint-disable-next-line no-console
|
|
137
|
+
console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
|
|
138
|
+
}
|
|
139
|
+
return filePath;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
if (isUnixExecutable(stats)) {
|
|
143
|
+
return filePath;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return '';
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function normalizeSeparators(p) {
|
|
152
|
+
p = p || '';
|
|
153
|
+
if (IS_WINDOWS) {
|
|
154
|
+
// convert slashes on Windows
|
|
155
|
+
p = p.replace(/\//g, '\\');
|
|
156
|
+
// remove redundant slashes
|
|
157
|
+
return p.replace(/\\\\+/g, '\\');
|
|
158
|
+
}
|
|
159
|
+
// remove redundant slashes
|
|
160
|
+
return p.replace(/\/\/+/g, '/');
|
|
161
|
+
}
|
|
162
|
+
// on Mac/Linux, test the execute bit
|
|
163
|
+
// R W X R W X R W X
|
|
164
|
+
// 256 128 64 32 16 8 4 2 1
|
|
165
|
+
function isUnixExecutable(stats) {
|
|
166
|
+
return ((stats.mode & 1) > 0 ||
|
|
167
|
+
((stats.mode & 8) > 0 &&
|
|
168
|
+
process.getgid !== undefined &&
|
|
169
|
+
(stats.gid === process.getgid() ||
|
|
170
|
+
(process.getgroups !== undefined &&
|
|
171
|
+
process.getgroups().includes(stats.gid)))) ||
|
|
172
|
+
((stats.mode & 64) > 0 &&
|
|
173
|
+
process.getuid !== undefined &&
|
|
174
|
+
stats.uid === process.getuid()));
|
|
175
|
+
}
|
|
176
|
+
// Get the path of cmd.exe in windows
|
|
177
|
+
export function getCmdPath() {
|
|
178
|
+
var _a;
|
|
179
|
+
return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`;
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=io-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io-util.js","sourceRoot":"","sources":["../src/io-util.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,MAAM,CAAC,MAAM,EACX,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAK,EACL,IAAI,EACJ,OAAO,EACP,MAAM,EACN,EAAE,EACF,KAAK,EACL,IAAI,EACJ,OAAO,EACP,MAAM,EACP,GAAG,EAAE,CAAC,QAAQ,CAAA;AACf,6BAA6B;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,UAAgB,QAAQ,CAAC,MAAc;;QAC3C,MAAM,MAAM,GAAG,MAA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,GAAG,CAAC,IAAI,EAAE,CAAA;IACX,IAAI,UAAU,EAAE,CAAC;QACf,6BAA6B;QAC7B,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAE1B,2BAA2B;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAClC,CAAC;IAED,2BAA2B;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC;AAED,qCAAqC;AACrC,6BAA6B;AAC7B,6BAA6B;AAC7B,SAAS,gBAAgB,CAAC,KAAe;IACvC,OAAO,CACL,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC;QACpB,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC;YACnB,OAAO,CAAC,MAAM,KAAK,SAAS;YAC5B,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QACjC,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC;YACpB,OAAO,CAAC,MAAM,KAAK,SAAS;YAC5B,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAClC,CAAA;AACH,CAAC;AAED,qCAAqC;AACrC,MAAM,UAAU,UAAU;;IACxB,OAAO,MAAA,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,mCAAI,SAAS,CAAA;AAC5C,CAAC"}
|
package/lib/io.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for cp/mv options
|
|
3
|
+
*/
|
|
4
|
+
export interface CopyOptions {
|
|
5
|
+
/** Optional. Whether to recursively copy all subdirectories. Defaults to false */
|
|
6
|
+
recursive?: boolean;
|
|
7
|
+
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */
|
|
8
|
+
force?: boolean;
|
|
9
|
+
/** Optional. Whether to copy the source directory along with all the files. Only takes effect when recursive=true and copying a directory. Default is true*/
|
|
10
|
+
copySourceDirectory?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Interface for cp/mv options
|
|
14
|
+
*/
|
|
15
|
+
export interface MoveOptions {
|
|
16
|
+
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */
|
|
17
|
+
force?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Copies a file or folder.
|
|
21
|
+
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
|
|
22
|
+
*
|
|
23
|
+
* @param source source path
|
|
24
|
+
* @param dest destination path
|
|
25
|
+
* @param options optional. See CopyOptions.
|
|
26
|
+
*/
|
|
27
|
+
export declare function cp(source: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Moves a path.
|
|
30
|
+
*
|
|
31
|
+
* @param source source path
|
|
32
|
+
* @param dest destination path
|
|
33
|
+
* @param options optional. See MoveOptions.
|
|
34
|
+
*/
|
|
35
|
+
export declare function mv(source: string, dest: string, options?: MoveOptions): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Remove a path recursively with force
|
|
38
|
+
*
|
|
39
|
+
* @param inputPath path to remove
|
|
40
|
+
*/
|
|
41
|
+
export declare function rmRF(inputPath: string): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Make a directory. Creates the full path with folders in between
|
|
44
|
+
* Will throw if it fails
|
|
45
|
+
*
|
|
46
|
+
* @param fsPath path to create
|
|
47
|
+
* @returns Promise<void>
|
|
48
|
+
*/
|
|
49
|
+
export declare function mkdirP(fsPath: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
|
52
|
+
* If you check and the tool does not exist, it will throw.
|
|
53
|
+
*
|
|
54
|
+
* @param tool name of the tool
|
|
55
|
+
* @param check whether to check if tool exists
|
|
56
|
+
* @returns Promise<string> path to tool
|
|
57
|
+
*/
|
|
58
|
+
export declare function which(tool: string, check?: boolean): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns a list of all occurrences of the given tool on the system path.
|
|
61
|
+
*
|
|
62
|
+
* @returns Promise<string[]> the paths of the tool
|
|
63
|
+
*/
|
|
64
|
+
export declare function findInPath(tool: string): Promise<string[]>;
|
package/lib/io.js
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { ok } from 'assert';
|
|
11
|
+
import * as path from 'path';
|
|
12
|
+
import * as ioUtil from './io-util.js';
|
|
13
|
+
/**
|
|
14
|
+
* Copies a file or folder.
|
|
15
|
+
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
|
|
16
|
+
*
|
|
17
|
+
* @param source source path
|
|
18
|
+
* @param dest destination path
|
|
19
|
+
* @param options optional. See CopyOptions.
|
|
20
|
+
*/
|
|
21
|
+
export function cp(source_1, dest_1) {
|
|
22
|
+
return __awaiter(this, arguments, void 0, function* (source, dest, options = {}) {
|
|
23
|
+
const { force, recursive, copySourceDirectory } = readCopyOptions(options);
|
|
24
|
+
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
|
|
25
|
+
// Dest is an existing file, but not forcing
|
|
26
|
+
if (destStat && destStat.isFile() && !force) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// If dest is an existing directory, should copy inside.
|
|
30
|
+
const newDest = destStat && destStat.isDirectory() && copySourceDirectory
|
|
31
|
+
? path.join(dest, path.basename(source))
|
|
32
|
+
: dest;
|
|
33
|
+
if (!(yield ioUtil.exists(source))) {
|
|
34
|
+
throw new Error(`no such file or directory: ${source}`);
|
|
35
|
+
}
|
|
36
|
+
const sourceStat = yield ioUtil.stat(source);
|
|
37
|
+
if (sourceStat.isDirectory()) {
|
|
38
|
+
if (!recursive) {
|
|
39
|
+
throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
yield cpDirRecursive(source, newDest, 0, force);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
if (path.relative(source, newDest) === '') {
|
|
47
|
+
// a file cannot be copied to itself
|
|
48
|
+
throw new Error(`'${newDest}' and '${source}' are the same file`);
|
|
49
|
+
}
|
|
50
|
+
yield copyFile(source, newDest, force);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Moves a path.
|
|
56
|
+
*
|
|
57
|
+
* @param source source path
|
|
58
|
+
* @param dest destination path
|
|
59
|
+
* @param options optional. See MoveOptions.
|
|
60
|
+
*/
|
|
61
|
+
export function mv(source_1, dest_1) {
|
|
62
|
+
return __awaiter(this, arguments, void 0, function* (source, dest, options = {}) {
|
|
63
|
+
if (yield ioUtil.exists(dest)) {
|
|
64
|
+
let destExists = true;
|
|
65
|
+
if (yield ioUtil.isDirectory(dest)) {
|
|
66
|
+
// If dest is directory copy src into dest
|
|
67
|
+
dest = path.join(dest, path.basename(source));
|
|
68
|
+
destExists = yield ioUtil.exists(dest);
|
|
69
|
+
}
|
|
70
|
+
if (destExists) {
|
|
71
|
+
if (options.force == null || options.force) {
|
|
72
|
+
yield rmRF(dest);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
throw new Error('Destination already exists');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
yield mkdirP(path.dirname(dest));
|
|
80
|
+
yield ioUtil.rename(source, dest);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Remove a path recursively with force
|
|
85
|
+
*
|
|
86
|
+
* @param inputPath path to remove
|
|
87
|
+
*/
|
|
88
|
+
export function rmRF(inputPath) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
if (ioUtil.IS_WINDOWS) {
|
|
91
|
+
// Check for invalid characters
|
|
92
|
+
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
|
|
93
|
+
if (/[*"<>|]/.test(inputPath)) {
|
|
94
|
+
throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
// note if path does not exist, error is silent
|
|
99
|
+
yield ioUtil.rm(inputPath, {
|
|
100
|
+
force: true,
|
|
101
|
+
maxRetries: 3,
|
|
102
|
+
recursive: true,
|
|
103
|
+
retryDelay: 300
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
throw new Error(`File was unable to be removed ${err}`);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Make a directory. Creates the full path with folders in between
|
|
113
|
+
* Will throw if it fails
|
|
114
|
+
*
|
|
115
|
+
* @param fsPath path to create
|
|
116
|
+
* @returns Promise<void>
|
|
117
|
+
*/
|
|
118
|
+
export function mkdirP(fsPath) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
ok(fsPath, 'a path argument must be provided');
|
|
121
|
+
yield ioUtil.mkdir(fsPath, { recursive: true });
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
|
126
|
+
* If you check and the tool does not exist, it will throw.
|
|
127
|
+
*
|
|
128
|
+
* @param tool name of the tool
|
|
129
|
+
* @param check whether to check if tool exists
|
|
130
|
+
* @returns Promise<string> path to tool
|
|
131
|
+
*/
|
|
132
|
+
export function which(tool, check) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
if (!tool) {
|
|
135
|
+
throw new Error("parameter 'tool' is required");
|
|
136
|
+
}
|
|
137
|
+
// recursive when check=true
|
|
138
|
+
if (check) {
|
|
139
|
+
const result = yield which(tool, false);
|
|
140
|
+
if (!result) {
|
|
141
|
+
if (ioUtil.IS_WINDOWS) {
|
|
142
|
+
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
const matches = yield findInPath(tool);
|
|
151
|
+
if (matches && matches.length > 0) {
|
|
152
|
+
return matches[0];
|
|
153
|
+
}
|
|
154
|
+
return '';
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Returns a list of all occurrences of the given tool on the system path.
|
|
159
|
+
*
|
|
160
|
+
* @returns Promise<string[]> the paths of the tool
|
|
161
|
+
*/
|
|
162
|
+
export function findInPath(tool) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
if (!tool) {
|
|
165
|
+
throw new Error("parameter 'tool' is required");
|
|
166
|
+
}
|
|
167
|
+
// build the list of extensions to try
|
|
168
|
+
const extensions = [];
|
|
169
|
+
if (ioUtil.IS_WINDOWS && process.env['PATHEXT']) {
|
|
170
|
+
for (const extension of process.env['PATHEXT'].split(path.delimiter)) {
|
|
171
|
+
if (extension) {
|
|
172
|
+
extensions.push(extension);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// if it's rooted, return it if exists. otherwise return empty.
|
|
177
|
+
if (ioUtil.isRooted(tool)) {
|
|
178
|
+
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
|
|
179
|
+
if (filePath) {
|
|
180
|
+
return [filePath];
|
|
181
|
+
}
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
// if any path separators, return empty
|
|
185
|
+
if (tool.includes(path.sep)) {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
// build the list of directories
|
|
189
|
+
//
|
|
190
|
+
// Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
|
|
191
|
+
// it feels like we should not do this. Checking the current directory seems like more of a use
|
|
192
|
+
// case of a shell, and the which() function exposed by the toolkit should strive for consistency
|
|
193
|
+
// across platforms.
|
|
194
|
+
const directories = [];
|
|
195
|
+
if (process.env.PATH) {
|
|
196
|
+
for (const p of process.env.PATH.split(path.delimiter)) {
|
|
197
|
+
if (p) {
|
|
198
|
+
directories.push(p);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// find all matches
|
|
203
|
+
const matches = [];
|
|
204
|
+
for (const directory of directories) {
|
|
205
|
+
const filePath = yield ioUtil.tryGetExecutablePath(path.join(directory, tool), extensions);
|
|
206
|
+
if (filePath) {
|
|
207
|
+
matches.push(filePath);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return matches;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function readCopyOptions(options) {
|
|
214
|
+
const force = options.force == null ? true : options.force;
|
|
215
|
+
const recursive = Boolean(options.recursive);
|
|
216
|
+
const copySourceDirectory = options.copySourceDirectory == null
|
|
217
|
+
? true
|
|
218
|
+
: Boolean(options.copySourceDirectory);
|
|
219
|
+
return { force, recursive, copySourceDirectory };
|
|
220
|
+
}
|
|
221
|
+
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
|
|
222
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
// Ensure there is not a run away recursive copy
|
|
224
|
+
if (currentDepth >= 255)
|
|
225
|
+
return;
|
|
226
|
+
currentDepth++;
|
|
227
|
+
yield mkdirP(destDir);
|
|
228
|
+
const files = yield ioUtil.readdir(sourceDir);
|
|
229
|
+
for (const fileName of files) {
|
|
230
|
+
const srcFile = `${sourceDir}/${fileName}`;
|
|
231
|
+
const destFile = `${destDir}/${fileName}`;
|
|
232
|
+
const srcFileStat = yield ioUtil.lstat(srcFile);
|
|
233
|
+
if (srcFileStat.isDirectory()) {
|
|
234
|
+
// Recurse
|
|
235
|
+
yield cpDirRecursive(srcFile, destFile, currentDepth, force);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
yield copyFile(srcFile, destFile, force);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// Change the mode for the newly created directory
|
|
242
|
+
yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
// Buffered file copy
|
|
246
|
+
function copyFile(srcFile, destFile, force) {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
248
|
+
if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) {
|
|
249
|
+
// unlink/re-link it
|
|
250
|
+
try {
|
|
251
|
+
yield ioUtil.lstat(destFile);
|
|
252
|
+
yield ioUtil.unlink(destFile);
|
|
253
|
+
}
|
|
254
|
+
catch (e) {
|
|
255
|
+
// Try to override file permission
|
|
256
|
+
if (e.code === 'EPERM') {
|
|
257
|
+
yield ioUtil.chmod(destFile, '0666');
|
|
258
|
+
yield ioUtil.unlink(destFile);
|
|
259
|
+
}
|
|
260
|
+
// other errors = it doesn't exist, no work to do
|
|
261
|
+
}
|
|
262
|
+
// Copy over symlink
|
|
263
|
+
const symlinkFull = yield ioUtil.readlink(srcFile);
|
|
264
|
+
yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null);
|
|
265
|
+
}
|
|
266
|
+
else if (!(yield ioUtil.exists(destFile)) || force) {
|
|
267
|
+
yield ioUtil.copyFile(srcFile, destFile);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=io.js.map
|
package/lib/io.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.js","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,EAAE,EAAC,MAAM,QAAQ,CAAA;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AAsBtC;;;;;;;GAOG;AACH,MAAM,UAAgB,EAAE;yDACtB,MAAc,EACd,IAAY,EACZ,UAAuB,EAAE;QAEzB,MAAM,EAAC,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;QAExE,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAC7E,4CAA4C;QAC5C,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;YAC5C,OAAM;QACR,CAAC;QAED,wDAAwD;QACxD,MAAM,OAAO,GACX,QAAQ,IAAI,QAAQ,CAAC,WAAW,EAAE,IAAI,mBAAmB;YACvD,CAAC,CAAC,IA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AM,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC1C,CAAC;IACH,CAAC;CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-ports/actions-io",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "3.0.2-beta.0",
|
|
4
|
+
"description": "Actions io lib",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"github",
|
|
7
|
+
"actions",
|
|
8
|
+
"io"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/actions/toolkit/tree/main/packages/io",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "lib/io.js",
|
|
14
|
+
"types": "lib/io.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./lib/io.d.ts",
|
|
18
|
+
"import": "./lib/io.js"
|
|
19
|
+
},
|
|
20
|
+
"./lib/io-util": {
|
|
21
|
+
"types": "./lib/io-util.d.ts",
|
|
22
|
+
"import": "./lib/io-util.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"directories": {
|
|
26
|
+
"lib": "lib",
|
|
27
|
+
"test": "__tests__"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"lib"
|
|
31
|
+
],
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/ohos-ports/ohos-ports.git",
|
|
35
|
+
"directory": "ports/actions-io/3.0.2"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json",
|
|
39
|
+
"test": "echo \"Error: run tests from root\" && exit 1",
|
|
40
|
+
"tsc": "tsc"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/ohos-ports/ohos-ports/issues"
|
|
44
|
+
}
|
|
45
|
+
}
|