eas-cli 27.7.2 → 27.8.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 +214 -211
- package/build/build/build.js +1 -2
- package/build/build/utils/repository.js +4 -4
- package/build/commands/build/download.js +1 -2
- package/build/commands/simulator/availability.js +4 -3
- package/build/commands/simulator/control.js +12 -3
- package/build/commands/simulator/events.js +1 -1
- package/build/commands/simulator/exec.js +1 -1
- package/build/commands/simulator/get.js +3 -3
- package/build/commands/simulator/index.js +3 -7
- package/build/commands/simulator/list.js +1 -1
- package/build/commands/simulator/logs.js +1 -1
- package/build/commands/simulator/stop.js +1 -1
- package/build/commands/update/embedded/view.js +2 -2
- package/build/project/maybeUploadAssetMapAsync.js +2 -2
- package/build/project/maybeUploadSourceMapsAsync.js +3 -3
- package/build/project/uploadAccountScopedFileAsync.js +3 -3
- package/build/project/uploadAccountScopedProjectSourceAsync.js +2 -2
- package/build/simulator/appArchive.d.ts +6 -0
- package/build/simulator/appArchive.js +61 -0
- package/build/simulator/artifacts.js +2 -2
- package/build/simulator/controlActions.d.ts +8 -2
- package/build/simulator/controlActions.js +40 -10
- package/build/simulator/controlConfig.d.ts +2 -1
- package/build/simulator/controlConfig.js +8 -3
- package/build/simulator/hostActions.d.ts +2 -0
- package/build/simulator/hostActions.js +1 -0
- package/build/simulator/startSetup.js +5 -1
- package/build/simulator/utils.d.ts +3 -3
- package/build/simulator/utils.js +8 -6
- package/build/utils/download.js +3 -3
- package/build/utils/files.d.ts +0 -1
- package/build/utils/files.js +0 -29
- package/oclif.manifest.json +849 -849
- package/package.json +6 -6
|
@@ -8,6 +8,7 @@ exports.parseControlActionOutput = parseControlActionOutput;
|
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
9
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
10
10
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
const appArchive_1 = require("./appArchive");
|
|
11
12
|
const hostActions_1 = require("./hostActions");
|
|
12
13
|
function resolveControlActionPath(value, baseDir) {
|
|
13
14
|
if (!baseDir) {
|
|
@@ -36,8 +37,7 @@ async function prepareControlActionAsync(catalog, action, { localFileMode = 'aut
|
|
|
36
37
|
if (Object.hasOwn(params, param)) {
|
|
37
38
|
throw new Error(`${param} and file cannot both be supplied for ${action.action}.`);
|
|
38
39
|
}
|
|
39
|
-
localFile =
|
|
40
|
-
await assertLocalFileAsync(localFile.path);
|
|
40
|
+
localFile = await prepareLocalFileAsync(action.action, entry, resolveControlActionPath(action.file, baseDir));
|
|
41
41
|
}
|
|
42
42
|
else if (localFileMode === 'auto' && param && applies && typeof params[param] === 'string') {
|
|
43
43
|
const value = params[param];
|
|
@@ -62,8 +62,7 @@ async function prepareControlActionAsync(catalog, action, { localFileMode = 'aut
|
|
|
62
62
|
if (!stat) {
|
|
63
63
|
throw new Error(`${value} does not exist on this computer. Pass a local file, or prefix an absolute simulator-host path with host:.`);
|
|
64
64
|
}
|
|
65
|
-
await
|
|
66
|
-
localFile = { param, path: localPath };
|
|
65
|
+
localFile = await prepareLocalFileAsync(action.action, entry, localPath, stat);
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
return {
|
|
@@ -74,35 +73,65 @@ async function prepareControlActionAsync(catalog, action, { localFileMode = 'aut
|
|
|
74
73
|
...(localFile ? { localFile } : {}),
|
|
75
74
|
};
|
|
76
75
|
}
|
|
77
|
-
async function
|
|
76
|
+
async function prepareLocalFileAsync(action, entry, localPath, stats) {
|
|
77
|
+
const stat = await assertLocalFileAsync(localPath, { action, stats });
|
|
78
|
+
if (action === 'app.install' &&
|
|
79
|
+
(stat.isDirectory() || /\.(?:tar\.gz|tgz)$/i.test(localPath)) &&
|
|
80
|
+
entry.uploadArchive !== 'tar.gz') {
|
|
81
|
+
throw new Error('This simulator host does not support app archives. Start a session with an updated serve-sim package.');
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
param: entry.upload,
|
|
85
|
+
path: localPath,
|
|
86
|
+
...(stat.isDirectory() ? { appBundle: true } : {}),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async function assertLocalFileAsync(localPath, { action, stats } = {}) {
|
|
78
90
|
const stat = stats ?? (await fs.stat(localPath).catch(() => null));
|
|
79
91
|
if (!stat) {
|
|
80
92
|
throw new Error(`${localPath} does not exist on this computer.`);
|
|
81
93
|
}
|
|
82
94
|
if (stat.isDirectory()) {
|
|
83
|
-
|
|
95
|
+
if (action !== 'app.install') {
|
|
96
|
+
throw new Error(`${localPath} is a folder. Pass the path of a file.`);
|
|
97
|
+
}
|
|
98
|
+
if (path_1.default.extname(path_1.default.resolve(localPath)) !== '.app') {
|
|
99
|
+
throw new Error(`${localPath} is a folder. Pass a Simulator .app bundle or .tar.gz/.tgz archive.`);
|
|
100
|
+
}
|
|
84
101
|
}
|
|
85
|
-
if (!stat.isFile()) {
|
|
102
|
+
else if (!stat.isFile()) {
|
|
86
103
|
throw new Error(`${localPath} is not a regular file.`);
|
|
87
104
|
}
|
|
88
|
-
if (
|
|
105
|
+
else if (action === 'app.install' && /\.(?:ipa|zip)$/i.test(localPath)) {
|
|
106
|
+
throw new Error('Simulator installs require a Simulator .app bundle or .tar.gz/.tgz archive. Device .ipa builds and .zip archives are not supported.');
|
|
107
|
+
}
|
|
108
|
+
else if (stat.size === 0) {
|
|
89
109
|
throw new Error(`${localPath} is empty. Pass a file with content.`);
|
|
90
110
|
}
|
|
91
111
|
await fs.access(localPath, fs.constants.R_OK);
|
|
112
|
+
return stat;
|
|
92
113
|
}
|
|
93
|
-
async function executeControlActionAsync(connection, plan, { validateParams } = {}) {
|
|
114
|
+
async function executeControlActionAsync(connection, plan, { validateParams, onProgress, handleInterrupt, } = {}) {
|
|
94
115
|
connection.signal.throwIfAborted();
|
|
95
116
|
const params = { ...plan.params };
|
|
96
117
|
let uploadId;
|
|
118
|
+
let archive;
|
|
97
119
|
let succeeded = false;
|
|
98
120
|
try {
|
|
99
121
|
if (plan.localFile) {
|
|
100
|
-
|
|
122
|
+
if (plan.localFile.appBundle) {
|
|
123
|
+
onProgress?.('packaging');
|
|
124
|
+
archive = await (0, appArchive_1.createAppArchiveAsync)(plan.localFile.path, { handleInterrupt });
|
|
125
|
+
}
|
|
126
|
+
connection.signal.throwIfAborted();
|
|
127
|
+
onProgress?.('uploading');
|
|
128
|
+
const upload = await (0, hostActions_1.uploadFileAsync)(connection, archive?.path ?? plan.localFile.path);
|
|
101
129
|
uploadId = upload.uploadId;
|
|
102
130
|
params[plan.localFile.param] = plan.entry.uploadAs === 'id' ? upload.uploadId : upload.path;
|
|
103
131
|
}
|
|
104
132
|
connection.signal.throwIfAborted();
|
|
105
133
|
validateParams?.(params);
|
|
134
|
+
onProgress?.('running');
|
|
106
135
|
const result = await connection.requestAsync(plan.action, params);
|
|
107
136
|
if (result.exitCode !== 0) {
|
|
108
137
|
const detail = (result.stderr || result.stdout).trim() || `exit code ${result.exitCode}`;
|
|
@@ -116,6 +145,7 @@ async function executeControlActionAsync(connection, plan, { validateParams } =
|
|
|
116
145
|
if (uploadId && (!plan.entry.keepUpload || !succeeded)) {
|
|
117
146
|
await connection.requestAsync('upload.remove', { uploadId }).catch(() => { });
|
|
118
147
|
}
|
|
148
|
+
await archive?.cleanupAsync();
|
|
119
149
|
}
|
|
120
150
|
}
|
|
121
151
|
function parseControlActionOutput(output) {
|
|
@@ -32,8 +32,9 @@ export declare class ControlConfigExecutionError extends Error {
|
|
|
32
32
|
export declare function prepareControlConfigAsync(catalog: HostActionCatalog, filePath: string, udid: string, input?: SimulatorSessionConfig): Promise<PreparedControlConfig>;
|
|
33
33
|
/** Check local inputs before requesting a paid session; runtime validation still uses the live catalog. */
|
|
34
34
|
export declare function preflightControlConfigFilesAsync(config: SimulatorSessionConfig): Promise<void>;
|
|
35
|
-
export declare function executeControlConfigAsync(connection: HostActionConnection, config: PreparedControlConfig, { onProgress }?: {
|
|
35
|
+
export declare function executeControlConfigAsync(connection: HostActionConnection, config: PreparedControlConfig, { onProgress, handleInterrupt, }?: {
|
|
36
36
|
onProgress?: (progress: ControlConfigProgress) => void;
|
|
37
|
+
handleInterrupt?: boolean;
|
|
37
38
|
}): Promise<ControlConfigResult[]>;
|
|
38
39
|
export declare function serializeControlConfigResults(results: readonly ControlConfigResult[]): {
|
|
39
40
|
action: string;
|
|
@@ -78,7 +78,9 @@ async function preflightControlConfigFilesAsync(config) {
|
|
|
78
78
|
throw new Error('The simulator is selected by the session; remove params.udid.');
|
|
79
79
|
}
|
|
80
80
|
if (action.file) {
|
|
81
|
-
await (0, controlActions_1.assertLocalFileAsync)(path_1.default.resolve(path_1.default.dirname(config.path), action.file)
|
|
81
|
+
await (0, controlActions_1.assertLocalFileAsync)(path_1.default.resolve(path_1.default.dirname(config.path), action.file), {
|
|
82
|
+
action: action.action,
|
|
83
|
+
});
|
|
82
84
|
}
|
|
83
85
|
if (action.output) {
|
|
84
86
|
await assertWritableOutputAsync((0, controlActions_1.resolveControlActionPath)(action.output, path_1.default.dirname(config.path)));
|
|
@@ -127,7 +129,7 @@ function assertUnambiguousFileSource(ajv, plan, udid) {
|
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
|
-
async function executeControlConfigAsync(connection, config, { onProgress } = {}) {
|
|
132
|
+
async function executeControlConfigAsync(connection, config, { onProgress, handleInterrupt, } = {}) {
|
|
131
133
|
if (config.udid !== connection.udid) {
|
|
132
134
|
throw new Error('The simulator changed after this configuration was checked. Import it again.');
|
|
133
135
|
}
|
|
@@ -137,7 +139,10 @@ async function executeControlConfigAsync(connection, config, { onProgress } = {}
|
|
|
137
139
|
onProgress?.({ ...progress, status: 'running' });
|
|
138
140
|
let result;
|
|
139
141
|
try {
|
|
140
|
-
result = await (0, controlActions_1.executeControlActionAsync)(connection, plan, {
|
|
142
|
+
result = await (0, controlActions_1.executeControlActionAsync)(connection, plan, {
|
|
143
|
+
validateParams,
|
|
144
|
+
handleInterrupt,
|
|
145
|
+
});
|
|
141
146
|
}
|
|
142
147
|
catch (error) {
|
|
143
148
|
throw new ControlConfigExecutionError(index + 1, plan.action, completed, error);
|
|
@@ -21,6 +21,7 @@ declare const CatalogEntry: z.ZodObject<{
|
|
|
21
21
|
description: z.ZodOptional<z.ZodString>;
|
|
22
22
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
23
23
|
upload: z.ZodOptional<z.ZodString>;
|
|
24
|
+
uploadArchive: z.ZodOptional<z.ZodUnknown>;
|
|
24
25
|
uploadAs: z.ZodOptional<z.ZodEnum<{
|
|
25
26
|
path: "path";
|
|
26
27
|
id: "id";
|
|
@@ -42,6 +43,7 @@ export declare const HostActionCatalogSchema: z.ZodRecord<z.ZodString, z.ZodObje
|
|
|
42
43
|
description: z.ZodOptional<z.ZodString>;
|
|
43
44
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
44
45
|
upload: z.ZodOptional<z.ZodString>;
|
|
46
|
+
uploadArchive: z.ZodOptional<z.ZodUnknown>;
|
|
45
47
|
uploadAs: z.ZodOptional<z.ZodEnum<{
|
|
46
48
|
path: "path";
|
|
47
49
|
id: "id";
|
|
@@ -29,6 +29,7 @@ const CatalogEntry = SchemaNode.extend({
|
|
|
29
29
|
description: zod_1.z.string().optional(),
|
|
30
30
|
args: zod_1.z.array(zod_1.z.string()).optional(),
|
|
31
31
|
upload: zod_1.z.string().optional(),
|
|
32
|
+
uploadArchive: zod_1.z.unknown().optional(),
|
|
32
33
|
uploadAs: zod_1.z.enum(['path', 'id']).optional(),
|
|
33
34
|
uploadWhen: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
34
35
|
keepUpload: zod_1.z.boolean().optional(),
|
|
@@ -9,7 +9,11 @@ async function applyStartConfigAsync(access, config, { signal, onProgress, }) {
|
|
|
9
9
|
const catalog = await (0, hostActions_1.fetchHostActionCatalogAsync)(connection);
|
|
10
10
|
const prepared = await (0, controlConfig_1.prepareControlConfigAsync)(catalog, config.path, connection.udid, config);
|
|
11
11
|
signal.throwIfAborted();
|
|
12
|
-
|
|
12
|
+
// Startup must stop its newly created session before exiting on Ctrl+C.
|
|
13
|
+
return await (0, controlConfig_1.executeControlConfigAsync)(connection, prepared, {
|
|
14
|
+
onProgress,
|
|
15
|
+
handleInterrupt: false,
|
|
16
|
+
});
|
|
13
17
|
}
|
|
14
18
|
finally {
|
|
15
19
|
connection.close();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AppPlatform, DeviceRunSessionByIdQuery, DeviceRunSessionResourceClass, DeviceRunSessionType } from '../graphql/generated';
|
|
2
2
|
type DeviceRunSessionByIdResult = DeviceRunSessionByIdQuery['deviceRunSessions']['byId'];
|
|
3
3
|
export type DeviceRunSessionRemoteConfig = NonNullable<DeviceRunSessionByIdResult['remoteConfig']>;
|
|
4
|
-
/** Landing page where accounts without access can request it. */
|
|
5
|
-
export declare const EAS_SIMULATOR_WAITLIST_URL = "https://expo.dev/services/simulators";
|
|
6
4
|
/**
|
|
7
5
|
* Message shown when EAS Simulator is not enabled for the account. Shared by every
|
|
8
|
-
* command that can hit the gate so users always get the same
|
|
6
|
+
* command that can hit the gate so users always get the same upgrade pointer. The gate
|
|
7
|
+
* result does not say whether the account is on the Free plan or is past due, so the
|
|
8
|
+
* message covers both.
|
|
9
9
|
*/
|
|
10
10
|
export declare function formatSimulatorUnavailableMessage(accountName: string): string;
|
|
11
11
|
export declare const DEVICE_RUN_SESSION_TYPE_FLAG_VALUES: Record<DeviceRunSessionType, string>;
|
package/build/simulator/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ANDROID_EMULATOR_EGRESS_RELAY_PORT = exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_FLAG_VALUES = exports.DEVICE_RUN_SESSION_TYPE_FLAG_OPTIONS = exports.DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES =
|
|
3
|
+
exports.ANDROID_EMULATOR_EGRESS_RELAY_PORT = exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_FLAG_VALUES = exports.DEVICE_RUN_SESSION_TYPE_FLAG_OPTIONS = exports.DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES = void 0;
|
|
4
4
|
exports.formatSimulatorUnavailableMessage = formatSimulatorUnavailableMessage;
|
|
5
5
|
exports.deviceRunSessionTypesForFlagValue = deviceRunSessionTypesForFlagValue;
|
|
6
6
|
exports.deviceRunSessionTypeToFlagValue = deviceRunSessionTypeToFlagValue;
|
|
@@ -20,19 +20,21 @@ exports.formatLogLine = formatLogLine;
|
|
|
20
20
|
const tslib_1 = require("tslib");
|
|
21
21
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
22
22
|
const util_1 = require("util");
|
|
23
|
+
const url_1 = require("../build/utils/url");
|
|
23
24
|
const generated_1 = require("../graphql/generated");
|
|
24
25
|
const log_1 = require("../log");
|
|
25
26
|
const env_1 = require("./env");
|
|
26
|
-
/** Landing page where accounts without access can request it. */
|
|
27
|
-
exports.EAS_SIMULATOR_WAITLIST_URL = 'https://expo.dev/services/simulators';
|
|
28
27
|
/**
|
|
29
28
|
* Message shown when EAS Simulator is not enabled for the account. Shared by every
|
|
30
|
-
* command that can hit the gate so users always get the same
|
|
29
|
+
* command that can hit the gate so users always get the same upgrade pointer. The gate
|
|
30
|
+
* result does not say whether the account is on the Free plan or is past due, so the
|
|
31
|
+
* message covers both.
|
|
31
32
|
*/
|
|
32
33
|
function formatSimulatorUnavailableMessage(accountName) {
|
|
33
34
|
return [
|
|
34
|
-
`EAS Simulator isn't
|
|
35
|
-
`
|
|
35
|
+
`EAS Simulator isn't enabled for ${accountName}. It's available on the Starter, Production, and Enterprise plans.`,
|
|
36
|
+
`Upgrade, or update billing if a payment is past due: ${(0, log_1.link)((0, url_1.getAccountBillingUrl)(accountName))}`,
|
|
37
|
+
'If your account is on an annual Enterprise plan, contact your Expo account executive.',
|
|
36
38
|
].join('\n');
|
|
37
39
|
}
|
|
38
40
|
// Mapping enum -> CLI flag value. Declared as Record<DeviceRunSessionType, string>
|
package/build/utils/download.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.downloadFileWithProgressTrackerAsync = downloadFileWithProgressTrackerAs
|
|
|
4
4
|
exports.downloadAndMaybeExtractAppAsync = downloadAndMaybeExtractAppAsync;
|
|
5
5
|
exports.extractAppFromLocalArchiveAsync = extractAppFromLocalArchiveAsync;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
|
+
const eas_build_job_1 = require("@expo/eas-build-job");
|
|
7
8
|
const spawn_async_1 = tslib_1.__importDefault(require("@expo/spawn-async"));
|
|
8
9
|
const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
|
|
9
10
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
@@ -12,7 +13,6 @@ const stream_1 = require("stream");
|
|
|
12
13
|
const tar_1 = require("tar");
|
|
13
14
|
const util_1 = require("util");
|
|
14
15
|
const uuid_1 = require("uuid");
|
|
15
|
-
const files_1 = require("./files");
|
|
16
16
|
const paths_1 = require("./paths");
|
|
17
17
|
const progress_1 = require("./progress");
|
|
18
18
|
const fetch_1 = tslib_1.__importDefault(require("../fetch"));
|
|
@@ -91,14 +91,14 @@ async function downloadAndMaybeExtractAppAsync(url, platform, cachedAppPath) {
|
|
|
91
91
|
await fs_extra_1.default.promises.mkdir(outputDir, { recursive: true });
|
|
92
92
|
if (url.endsWith('apk')) {
|
|
93
93
|
const apkFilePath = path_1.default.join(outputDir, `${(0, uuid_1.v4)()}.apk`);
|
|
94
|
-
await downloadFileWithProgressTrackerAsync(url, apkFilePath, (ratio, total) => `Downloading app (${(0,
|
|
94
|
+
await downloadFileWithProgressTrackerAsync(url, apkFilePath, (ratio, total) => `Downloading app (${(0, eas_build_job_1.formatBytes)(total * ratio)} / ${(0, eas_build_job_1.formatBytes)(total)})`, 'Successfully downloaded app');
|
|
95
95
|
return await maybeCacheAppAsync(apkFilePath, cachedAppPath);
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
98
98
|
const tmpArchivePathDir = path_1.default.join((0, paths_1.getTmpDirectory)(), (0, uuid_1.v4)());
|
|
99
99
|
await fs_extra_1.default.mkdir(tmpArchivePathDir, { recursive: true });
|
|
100
100
|
const tmpArchivePath = path_1.default.join(tmpArchivePathDir, `${(0, uuid_1.v4)()}.tar.gz`);
|
|
101
|
-
await downloadFileWithProgressTrackerAsync(url, tmpArchivePath, (ratio, total) => `Downloading app archive (${(0,
|
|
101
|
+
await downloadFileWithProgressTrackerAsync(url, tmpArchivePath, (ratio, total) => `Downloading app archive (${(0, eas_build_job_1.formatBytes)(total * ratio)} / ${(0, eas_build_job_1.formatBytes)(total)})`, 'Successfully downloaded app archive');
|
|
102
102
|
await tarExtractAsync(tmpArchivePath, outputDir);
|
|
103
103
|
const appPath = await getAppPathAsync(outputDir, platform === generated_1.AppPlatform.Ios ? 'app' : 'apk');
|
|
104
104
|
return await maybeCacheAppAsync(appPath, cachedAppPath);
|
package/build/utils/files.d.ts
CHANGED
package/build/utils/files.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.maybeRenameExistingFileAsync = maybeRenameExistingFileAsync;
|
|
4
|
-
exports.formatBytes = formatBytes;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
5
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
7
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -22,31 +21,3 @@ async function maybeRenameExistingFileAsync(projectDir, filename) {
|
|
|
22
21
|
await fs_extra_1.default.rename(desiredFilePath, path_1.default.resolve(projectDir, getRenamedFilename(filename, num)));
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
function formatBytes(bytes) {
|
|
26
|
-
if (bytes === 0) {
|
|
27
|
-
return `0`;
|
|
28
|
-
}
|
|
29
|
-
let multiplier = 1;
|
|
30
|
-
if (bytes < 1024 * multiplier) {
|
|
31
|
-
return `${Math.floor(bytes)} B`;
|
|
32
|
-
}
|
|
33
|
-
multiplier *= 1024;
|
|
34
|
-
if (bytes < 102.4 * multiplier) {
|
|
35
|
-
return `${(bytes / multiplier).toFixed(1)} KB`;
|
|
36
|
-
}
|
|
37
|
-
if (bytes < 1024 * multiplier) {
|
|
38
|
-
return `${Math.floor(bytes / 1024)} KB`;
|
|
39
|
-
}
|
|
40
|
-
multiplier *= 1024;
|
|
41
|
-
if (bytes < 102.4 * multiplier) {
|
|
42
|
-
return `${(bytes / multiplier).toFixed(1)} MB`;
|
|
43
|
-
}
|
|
44
|
-
if (bytes < 1024 * multiplier) {
|
|
45
|
-
return `${Math.floor(bytes / multiplier)} MB`;
|
|
46
|
-
}
|
|
47
|
-
multiplier *= 1024;
|
|
48
|
-
if (bytes < 102.4 * multiplier) {
|
|
49
|
-
return `${(bytes / multiplier).toFixed(1)} GB`;
|
|
50
|
-
}
|
|
51
|
-
return `${Math.floor(bytes / 1024)} GB`;
|
|
52
|
-
}
|