@testrigor/testrigor-cli 1.0.0 → 2.0.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/README.md +230 -3
- package/dist/commands/authenticate.d.ts +14 -0
- package/dist/commands/authenticate.js +87 -26
- package/dist/commands/test-suite/config.js +1 -1
- package/dist/commands/test-suite/run.js +253 -234
- package/dist/commands/test-suite/validate-syntax.js +2 -3
- package/dist/flags/chrome-extension.js +3 -2
- package/dist/types.d.ts +0 -12
- package/dist/util/appium.js +92 -34
- package/dist/util/certificate-uploader.js +5 -6
- package/dist/util/config.js +15 -15
- package/dist/util/parser.js +8 -8
- package/dist/util/request-builder.d.ts +2 -8
- package/dist/util/request-builder.js +12 -35
- package/dist/util/trtc.d.ts +2 -0
- package/dist/util/trtc.js +107 -38
- package/dist/util/tunnel.js +7 -6
- package/dist/util/type-guards.js +3 -4
- package/dist/util/utils.d.ts +3 -3
- package/dist/util/utils.js +23 -23
- package/dist/util/variable-file-uploader.js +7 -13
- package/dist/util/variables-path-parser.js +4 -4
- package/npm-shrinkwrap.json +11047 -0
- package/oclif.manifest.json +253 -180
- package/package.json +21 -20
package/dist/util/trtc.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
3
|
+
exports.extractZip = extractZip;
|
|
4
|
+
exports.extractTar = extractTar;
|
|
5
|
+
exports.download = download;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const fs_1 = tslib_1.__importDefault(require("@supercharge/fs"));
|
|
8
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
9
|
+
const os = tslib_1.__importStar(require("os"));
|
|
10
|
+
const path = tslib_1.__importStar(require("path"));
|
|
11
|
+
const stream_1 = require("stream");
|
|
12
|
+
const tar = tslib_1.__importStar(require("tar-stream"));
|
|
13
|
+
const unzip = tslib_1.__importStar(require("unzip-stream"));
|
|
14
|
+
const zlib = tslib_1.__importStar(require("zlib"));
|
|
12
15
|
const core_1 = require("@oclif/core");
|
|
13
16
|
const FILE_EXTENSION = {
|
|
14
17
|
darwin: "tar.gz",
|
|
@@ -56,39 +59,77 @@ function getUrl() {
|
|
|
56
59
|
}
|
|
57
60
|
throw new Error(`Unsupported platform ${platform} or architecture ${architecture}`);
|
|
58
61
|
}
|
|
62
|
+
const DOWNLOAD_ATTEMPTS = 3;
|
|
63
|
+
const DOWNLOAD_STALL_TIMEOUT_MS = 20000;
|
|
64
|
+
function errorMessage(error) {
|
|
65
|
+
return error instanceof Error ? error.message : String(error);
|
|
66
|
+
}
|
|
67
|
+
// Writes an archive entry to a temp file next to its destination and renames it over the
|
|
68
|
+
// destination once fully flushed, so on any OS the binary is never spawned half-written. It also
|
|
69
|
+
// replaces an existing binary with a new file instead of truncating and rewriting it in place,
|
|
70
|
+
// which an OS may refuse or penalise while that binary is running or cached from a previous run.
|
|
71
|
+
function writeEntry(entryPath, entry, mode) {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
const tmpPath = `${entryPath}.${process.pid}.tmp`;
|
|
74
|
+
const writeStream = fs.createWriteStream(tmpPath);
|
|
75
|
+
writeStream.on("error", reject);
|
|
76
|
+
writeStream.on("close", () => {
|
|
77
|
+
if (mode !== undefined) {
|
|
78
|
+
try {
|
|
79
|
+
fs.chmodSync(tmpPath, mode);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
core_1.ux.warn(`Could not set permissions for ${entryPath}: ${errorMessage(error)}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
fs.renameSync(tmpPath, entryPath);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
reject(error);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
resolve();
|
|
93
|
+
});
|
|
94
|
+
entry.pipe(writeStream);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
59
97
|
async function extractZip(dir, stream) {
|
|
98
|
+
const parser = unzip.Parse();
|
|
99
|
+
const writes = [];
|
|
60
100
|
return new Promise((resolve, reject) => {
|
|
61
|
-
stream
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.
|
|
101
|
+
stream.on("error", reject);
|
|
102
|
+
parser.on("error", reject);
|
|
103
|
+
parser.on("entry", (entry) => {
|
|
104
|
+
const entryPath = path.join(dir, entry.path);
|
|
105
|
+
if (entry.type === "Directory") {
|
|
106
|
+
fs.mkdirSync(entryPath, { recursive: true });
|
|
107
|
+
entry.autodrain();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
fs.mkdirSync(path.dirname(entryPath), { recursive: true });
|
|
111
|
+
writes.push(writeEntry(entryPath, entry));
|
|
112
|
+
});
|
|
113
|
+
parser.on("finish", () => Promise.all(writes).then(() => resolve(getBinaryPath(dir)), reject));
|
|
114
|
+
stream.pipe(parser);
|
|
65
115
|
});
|
|
66
116
|
}
|
|
67
117
|
async function extractTar(dir, stream) {
|
|
68
118
|
const extract = tar.extract();
|
|
69
119
|
return new Promise((resolve, reject) => {
|
|
120
|
+
stream.on("error", reject);
|
|
70
121
|
extract.on("error", reject);
|
|
71
122
|
extract.on("entry", (header, stream, next) => {
|
|
72
123
|
const entryPath = path.join(dir, header.name);
|
|
73
124
|
const opts = { mode: header.mode };
|
|
74
125
|
switch (header.type) {
|
|
75
126
|
case "directory":
|
|
76
|
-
|
|
127
|
+
fs_1.default.ensureDir(entryPath, opts);
|
|
77
128
|
next();
|
|
78
129
|
break;
|
|
79
|
-
case "file":
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
writeStream.on("close", () => {
|
|
83
|
-
try {
|
|
84
|
-
fs.chmodSync(entryPath, header.mode || 0o644);
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
core_1.ux.warn(`Could not set permissions for ${entryPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
130
|
+
case "file":
|
|
131
|
+
writeEntry(entryPath, stream, header.mode || 0o644).then(() => next(), reject);
|
|
132
|
+
return;
|
|
92
133
|
case "symlink":
|
|
93
134
|
// ignore symlinks since they will not work on windows
|
|
94
135
|
next();
|
|
@@ -103,18 +144,46 @@ async function extractTar(dir, stream) {
|
|
|
103
144
|
stream.pipe(zlib.createGunzip()).pipe(extract);
|
|
104
145
|
});
|
|
105
146
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
147
|
+
// Aborts the download when no data arrives for DOWNLOAD_STALL_TIMEOUT_MS, since a stalled
|
|
148
|
+
// connection would otherwise never settle.
|
|
149
|
+
async function downloadOnce(dir) {
|
|
150
|
+
const controller = new AbortController();
|
|
151
|
+
let stallTimer;
|
|
152
|
+
const armStallTimer = () => {
|
|
153
|
+
clearTimeout(stallTimer);
|
|
154
|
+
stallTimer = setTimeout(() => controller.abort(), DOWNLOAD_STALL_TIMEOUT_MS);
|
|
155
|
+
};
|
|
156
|
+
armStallTimer();
|
|
157
|
+
try {
|
|
158
|
+
const response = await fetch(getUrl(), { signal: controller.signal });
|
|
159
|
+
if (!response.ok) {
|
|
160
|
+
throw new Error(`unexpected response ${response.statusText}`);
|
|
161
|
+
}
|
|
162
|
+
if (response.body == null) {
|
|
163
|
+
throw new Error("unexpected null response body");
|
|
164
|
+
}
|
|
165
|
+
const stream = stream_1.Readable.fromWeb(response.body);
|
|
166
|
+
const extraction = os.platform() === WIN32_PLATFORM
|
|
167
|
+
? extractZip(dir, stream)
|
|
168
|
+
: extractTar(dir, stream);
|
|
169
|
+
// Attached after the extractor has piped the body, so no chunk is consumed before it.
|
|
170
|
+
stream.on("data", armStallTimer);
|
|
171
|
+
return await extraction;
|
|
110
172
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
throw new Error("unexpected null response body");
|
|
173
|
+
finally {
|
|
174
|
+
clearTimeout(stallTimer);
|
|
114
175
|
}
|
|
115
|
-
|
|
116
|
-
|
|
176
|
+
}
|
|
177
|
+
async function download(dir) {
|
|
178
|
+
let lastError;
|
|
179
|
+
for (let attempt = 1; attempt <= DOWNLOAD_ATTEMPTS; attempt++) {
|
|
180
|
+
try {
|
|
181
|
+
// eslint-disable-next-line no-await-in-loop
|
|
182
|
+
return await downloadOnce(dir);
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
lastError = error;
|
|
186
|
+
}
|
|
117
187
|
}
|
|
118
|
-
|
|
188
|
+
throw new Error(`Could not download the trtc binary after ${DOWNLOAD_ATTEMPTS} attempts: ${errorMessage(lastError)}`);
|
|
119
189
|
}
|
|
120
|
-
exports.download = download;
|
package/dist/util/tunnel.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const fs_1 = tslib_1.__importDefault(require("@supercharge/fs"));
|
|
5
|
+
const childProcess = tslib_1.__importStar(require("child_process"));
|
|
6
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
7
|
const trtc_1 = require("./trtc");
|
|
7
8
|
const utils_1 = require("./utils");
|
|
8
9
|
function randomPort(min, max) {
|
|
@@ -17,12 +18,12 @@ type = "tcp"
|
|
|
17
18
|
remotePort = ${port}
|
|
18
19
|
[proxies.plugin]
|
|
19
20
|
type = "http_proxy"`;
|
|
20
|
-
await
|
|
21
|
+
await fs_1.default.writeFile(configPath, newConfigContent);
|
|
21
22
|
return configPath;
|
|
22
23
|
}
|
|
23
24
|
async function startTrtc(trtc, configPath) {
|
|
24
25
|
return new Promise((resolve, reject) => {
|
|
25
|
-
if (!
|
|
26
|
+
if (!fs_1.default.pathExistsSync(trtc)) {
|
|
26
27
|
reject(new Error(`Binary not found at ${trtc}`));
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
@@ -97,5 +98,5 @@ class Tunnel {
|
|
|
97
98
|
return this.port;
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
|
-
exports.default = Tunnel;
|
|
101
101
|
Tunnel.BINARY_DIRECTORY = "trtc";
|
|
102
|
+
exports.default = Tunnel;
|
package/dist/util/type-guards.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isPlainObject = isPlainObject;
|
|
4
|
+
exports.isSignedUrlApi2Response = isSignedUrlApi2Response;
|
|
5
|
+
exports.isCertificateUploadApi2Response = isCertificateUploadApi2Response;
|
|
4
6
|
function isPlainObject(value) {
|
|
5
7
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
8
|
}
|
|
7
|
-
exports.isPlainObject = isPlainObject;
|
|
8
9
|
function isSignedUrlApi2Response(value) {
|
|
9
10
|
return isPlainObject(value) && "status" in value;
|
|
10
11
|
}
|
|
11
|
-
exports.isSignedUrlApi2Response = isSignedUrlApi2Response;
|
|
12
12
|
function isCertificateUploadApi2Response(value) {
|
|
13
13
|
return isPlainObject(value) && "status" in value;
|
|
14
14
|
}
|
|
15
|
-
exports.isCertificateUploadApi2Response = isCertificateUploadApi2Response;
|
package/dist/util/utils.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ export declare const UPLOAD_TIMEOUT_MS: number;
|
|
|
3
3
|
export declare function createDirectory(name: string): Promise<string>;
|
|
4
4
|
export declare function getHomeDir(): string;
|
|
5
5
|
export declare function pathExists(name: string | undefined): Promise<boolean>;
|
|
6
|
-
export declare function isRunningOnCi():
|
|
7
|
-
export declare function rendererToUse(): "
|
|
6
|
+
export declare function isRunningOnCi(): boolean;
|
|
7
|
+
export declare function rendererToUse(): "verbose" | "default";
|
|
8
8
|
export declare function isYamlFile(fileName: string): boolean;
|
|
9
9
|
export declare function isTextFile(fileName: string): boolean;
|
|
10
10
|
export declare function isJsonFile(fileName: string): boolean;
|
|
11
11
|
export declare function isValidFileExtensionToUpload(fileName: string): boolean;
|
|
12
|
-
export declare function getExtensionLength(fileName: string):
|
|
12
|
+
export declare function getExtensionLength(fileName: string): 5 | 4 | 0;
|
|
13
13
|
export declare function removeExtension(fileName: string): string;
|
|
14
14
|
export declare function extractUrlWithoutQueryParams(urlString: string): string;
|
|
15
15
|
export declare function extractRunIdFromDetailsUrl(detailsUrl: string | undefined): string;
|
package/dist/util/utils.js
CHANGED
|
@@ -1,61 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
exports.UPLOAD_TIMEOUT_MS = exports.MAX_FILE_SIZE_100_MB = void 0;
|
|
4
|
+
exports.createDirectory = createDirectory;
|
|
5
|
+
exports.getHomeDir = getHomeDir;
|
|
6
|
+
exports.pathExists = pathExists;
|
|
7
|
+
exports.isRunningOnCi = isRunningOnCi;
|
|
8
|
+
exports.rendererToUse = rendererToUse;
|
|
9
|
+
exports.isYamlFile = isYamlFile;
|
|
10
|
+
exports.isTextFile = isTextFile;
|
|
11
|
+
exports.isJsonFile = isJsonFile;
|
|
12
|
+
exports.isValidFileExtensionToUpload = isValidFileExtensionToUpload;
|
|
13
|
+
exports.getExtensionLength = getExtensionLength;
|
|
14
|
+
exports.removeExtension = removeExtension;
|
|
15
|
+
exports.extractUrlWithoutQueryParams = extractUrlWithoutQueryParams;
|
|
16
|
+
exports.extractRunIdFromDetailsUrl = extractRunIdFromDetailsUrl;
|
|
17
|
+
exports.isValidUrl = isValidUrl;
|
|
18
|
+
const tslib_1 = require("tslib");
|
|
19
|
+
const fs_1 = tslib_1.__importDefault(require("@supercharge/fs"));
|
|
20
|
+
const path = tslib_1.__importStar(require("path"));
|
|
21
|
+
const is_ci_1 = tslib_1.__importDefault(require("is-ci"));
|
|
8
22
|
const YAML_EXTENSION = ".yaml";
|
|
9
23
|
const YML_EXTENSION = ".yml";
|
|
10
24
|
const TXT_EXTENSION = ".txt";
|
|
11
25
|
const JSON_EXTENSION = ".json";
|
|
12
26
|
const FILE_UPLOAD_EXTENSIONS = [".zip", ".exe", ".msi", ".apk", ".aab", ".ipa"];
|
|
13
27
|
const DIRECTORY_NAME = ".testrigor";
|
|
14
|
-
const TESTRIGOR_CLI_HOME = process.env.TESTRIGOR_CLI_HOME || path.join(
|
|
28
|
+
const TESTRIGOR_CLI_HOME = process.env.TESTRIGOR_CLI_HOME || path.join(fs_1.default.homeDir(), DIRECTORY_NAME);
|
|
15
29
|
const NOT_AVAILABLE_TEST_SUITE_RUN = "not-available";
|
|
16
30
|
exports.MAX_FILE_SIZE_100_MB = 100 * 1024 * 1024;
|
|
17
31
|
exports.UPLOAD_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes for large file uploads
|
|
18
32
|
async function createDirectory(name) {
|
|
19
33
|
const directoryPath = path.join(TESTRIGOR_CLI_HOME, name);
|
|
20
|
-
await
|
|
34
|
+
await fs_1.default.ensureDir(directoryPath);
|
|
21
35
|
return directoryPath;
|
|
22
36
|
}
|
|
23
|
-
exports.createDirectory = createDirectory;
|
|
24
37
|
function getHomeDir() {
|
|
25
38
|
return TESTRIGOR_CLI_HOME;
|
|
26
39
|
}
|
|
27
|
-
exports.getHomeDir = getHomeDir;
|
|
28
40
|
async function pathExists(name) {
|
|
29
41
|
if (!name) {
|
|
30
42
|
return false;
|
|
31
43
|
}
|
|
32
|
-
return
|
|
44
|
+
return fs_1.default.pathExists(path.join(TESTRIGOR_CLI_HOME, name));
|
|
33
45
|
}
|
|
34
|
-
exports.pathExists = pathExists;
|
|
35
46
|
function isRunningOnCi() {
|
|
36
|
-
return
|
|
47
|
+
return is_ci_1.default;
|
|
37
48
|
}
|
|
38
|
-
exports.isRunningOnCi = isRunningOnCi;
|
|
39
49
|
function rendererToUse() {
|
|
40
50
|
return isRunningOnCi() ? "verbose" : "default";
|
|
41
51
|
}
|
|
42
|
-
exports.rendererToUse = rendererToUse;
|
|
43
52
|
function isYamlFile(fileName) {
|
|
44
53
|
return fileName.endsWith(YAML_EXTENSION) || fileName.endsWith(YML_EXTENSION);
|
|
45
54
|
}
|
|
46
|
-
exports.isYamlFile = isYamlFile;
|
|
47
55
|
function isTextFile(fileName) {
|
|
48
56
|
return fileName.endsWith(TXT_EXTENSION);
|
|
49
57
|
}
|
|
50
|
-
exports.isTextFile = isTextFile;
|
|
51
58
|
function isJsonFile(fileName) {
|
|
52
59
|
return fileName.endsWith(JSON_EXTENSION);
|
|
53
60
|
}
|
|
54
|
-
exports.isJsonFile = isJsonFile;
|
|
55
61
|
function isValidFileExtensionToUpload(fileName) {
|
|
56
62
|
return FILE_UPLOAD_EXTENSIONS.some((ext) => fileName.endsWith(ext));
|
|
57
63
|
}
|
|
58
|
-
exports.isValidFileExtensionToUpload = isValidFileExtensionToUpload;
|
|
59
64
|
function getExtensionLength(fileName) {
|
|
60
65
|
if (fileName.endsWith(YAML_EXTENSION)) {
|
|
61
66
|
return 5;
|
|
@@ -65,17 +70,14 @@ function getExtensionLength(fileName) {
|
|
|
65
70
|
}
|
|
66
71
|
return 0;
|
|
67
72
|
}
|
|
68
|
-
exports.getExtensionLength = getExtensionLength;
|
|
69
73
|
function removeExtension(fileName) {
|
|
70
74
|
return fileName.slice(0, -getExtensionLength(fileName));
|
|
71
75
|
}
|
|
72
|
-
exports.removeExtension = removeExtension;
|
|
73
76
|
function extractUrlWithoutQueryParams(urlString) {
|
|
74
77
|
const url = new URL(urlString);
|
|
75
78
|
url.search = "";
|
|
76
79
|
return url.toString();
|
|
77
80
|
}
|
|
78
|
-
exports.extractUrlWithoutQueryParams = extractUrlWithoutQueryParams;
|
|
79
81
|
function extractRunIdFromDetailsUrl(detailsUrl) {
|
|
80
82
|
if (!detailsUrl) {
|
|
81
83
|
return NOT_AVAILABLE_TEST_SUITE_RUN;
|
|
@@ -83,7 +85,6 @@ function extractRunIdFromDetailsUrl(detailsUrl) {
|
|
|
83
85
|
const parts = detailsUrl.split("/");
|
|
84
86
|
return parts[parts.length - 1];
|
|
85
87
|
}
|
|
86
|
-
exports.extractRunIdFromDetailsUrl = extractRunIdFromDetailsUrl;
|
|
87
88
|
function isValidUrl(url) {
|
|
88
89
|
try {
|
|
89
90
|
// Basic URL validation - accepts http, https, localhost, self, and supports ports
|
|
@@ -94,4 +95,3 @@ function isValidUrl(url) {
|
|
|
94
95
|
return false;
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
|
-
exports.isValidUrl = isValidUrl;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uploadVariableFile =
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
3
|
+
exports.uploadVariableFile = uploadVariableFile;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path = tslib_1.__importStar(require("path"));
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
8
|
const type_guards_1 = require("./type-guards");
|
|
9
9
|
async function uploadVariableFile(api2BaseUrl, testSuiteId, token, localFilePath) {
|
|
10
10
|
const fileName = path.basename(localFilePath);
|
|
11
|
-
const
|
|
12
|
-
const presignedResp = await (0, node_fetch_commonjs_1.default)(`${api2BaseUrl}/apps/${testSuiteId}/test_data/global_variables/file/pre_signed_url`, {
|
|
11
|
+
const presignedResp = await fetch(`${api2BaseUrl}/apps/${testSuiteId}/test_data/global_variables/file/pre_signed_url`, {
|
|
13
12
|
method: "POST",
|
|
14
13
|
body: JSON.stringify({ fileName }),
|
|
15
14
|
headers: {
|
|
@@ -27,17 +26,12 @@ async function uploadVariableFile(api2BaseUrl, testSuiteId, token, localFilePath
|
|
|
27
26
|
!presignedJson.data) {
|
|
28
27
|
throw new Error(`Failed to request presigned URL for variable file '${fileName}': ${presignedJson.message}`);
|
|
29
28
|
}
|
|
30
|
-
const
|
|
31
|
-
const putResp = await (0, node_fetch_commonjs_1.default)(presignedJson.data.url, {
|
|
29
|
+
const putResp = await fetch(presignedJson.data.url, {
|
|
32
30
|
method: "PUT",
|
|
33
|
-
body:
|
|
34
|
-
headers: {
|
|
35
|
-
"Content-length": `${fileSize}`,
|
|
36
|
-
},
|
|
31
|
+
body: await (0, fs_1.openAsBlob)(localFilePath),
|
|
37
32
|
});
|
|
38
33
|
if (!putResp.ok) {
|
|
39
34
|
throw new Error(`Failed to upload variable file '${fileName}' to S3: ${putResp.statusText}`);
|
|
40
35
|
}
|
|
41
36
|
return (0, utils_1.extractUrlWithoutQueryParams)(presignedJson.data.url);
|
|
42
37
|
}
|
|
43
|
-
exports.uploadVariableFile = uploadVariableFile;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseVariablesJson =
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
exports.parseVariablesJson = parseVariablesJson;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
7
|
const type_guards_1 = require("./type-guards");
|
|
7
8
|
const MAX_FILE_SIZE_BYTES = 100 * 1024 * 1024;
|
|
8
9
|
const MAX_COMBINED_SIZE_BYTES = 100 * 1024 * 1024;
|
|
@@ -123,4 +124,3 @@ function parseVariablesJson(parsed) {
|
|
|
123
124
|
}
|
|
124
125
|
return { textValues, fileInputs, certInputs };
|
|
125
126
|
}
|
|
126
|
-
exports.parseVariablesJson = parseVariablesJson;
|