Update get-folder-size

This commit is contained in:
Henry Mercer
2025-08-29 19:03:20 +01:00
parent 2549c084dc
commit c2b56013b4
15 changed files with 3062 additions and 3808 deletions
+1 -1
View File
@@ -76,7 +76,7 @@ export default [
typescript: {},
},
"import/ignore": ["sinon", "uuid", "@octokit/plugin-retry"],
"import/ignore": ["sinon", "uuid", "@octokit/plugin-retry", "get-folder-size"],
},
rules: {
+344 -411
View File
File diff suppressed because it is too large Load Diff
+288 -356
View File
File diff suppressed because it is too large Load Diff
+246 -313
View File
File diff suppressed because it is too large Load Diff
+380 -447
View File
File diff suppressed because it is too large Load Diff
+296 -364
View File
File diff suppressed because it is too large Load Diff
+238 -305
View File
File diff suppressed because it is too large Load Diff
+335 -402
View File
File diff suppressed because it is too large Load Diff
+111 -178
View File
@@ -21915,7 +21915,7 @@ var require_retry_helper = __commonJS({
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.RetryHelper = void 0;
var core7 = __importStar(require_core());
var core8 = __importStar(require_core());
var RetryHelper = class {
constructor(maxAttempts, minSeconds, maxSeconds) {
if (maxAttempts < 1) {
@@ -21938,10 +21938,10 @@ var require_retry_helper = __commonJS({
if (isRetryable && !isRetryable(err)) {
throw err;
}
core7.info(err.message);
core8.info(err.message);
}
const seconds = this.getSleepAmount();
core7.info(`Waiting ${seconds} seconds before trying again`);
core8.info(`Waiting ${seconds} seconds before trying again`);
yield this.sleep(seconds);
attempt++;
}
@@ -22021,7 +22021,7 @@ var require_tool_cache = __commonJS({
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.evaluateVersions = exports2.isExplicitVersion = exports2.findFromManifest = exports2.getManifestFromRepo = exports2.findAllVersions = exports2.find = exports2.cacheFile = exports2.cacheDir = exports2.extractZip = exports2.extractXar = exports2.extractTar = exports2.extract7z = exports2.downloadTool = exports2.HTTPError = void 0;
var core7 = __importStar(require_core());
var core8 = __importStar(require_core());
var io3 = __importStar(require_io());
var crypto = __importStar(require("crypto"));
var fs = __importStar(require("fs"));
@@ -22050,8 +22050,8 @@ var require_tool_cache = __commonJS({
return __awaiter(this, void 0, void 0, function* () {
dest = dest || path2.join(_getTempDirectory(), crypto.randomUUID());
yield io3.mkdirP(path2.dirname(dest));
core7.debug(`Downloading ${url}`);
core7.debug(`Destination ${dest}`);
core8.debug(`Downloading ${url}`);
core8.debug(`Destination ${dest}`);
const maxAttempts = 3;
const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10);
const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20);
@@ -22078,7 +22078,7 @@ var require_tool_cache = __commonJS({
allowRetries: false
});
if (auth) {
core7.debug("set auth");
core8.debug("set auth");
if (headers === void 0) {
headers = {};
}
@@ -22087,7 +22087,7 @@ var require_tool_cache = __commonJS({
const response = yield http.get(url, headers);
if (response.message.statusCode !== 200) {
const err = new HTTPError(response.message.statusCode);
core7.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
core8.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
throw err;
}
const pipeline = util.promisify(stream.pipeline);
@@ -22096,16 +22096,16 @@ var require_tool_cache = __commonJS({
let succeeded = false;
try {
yield pipeline(readStream, fs.createWriteStream(dest));
core7.debug("download complete");
core8.debug("download complete");
succeeded = true;
return dest;
} finally {
if (!succeeded) {
core7.debug("download failed");
core8.debug("download failed");
try {
yield io3.rmRF(dest);
} catch (err) {
core7.debug(`Failed to delete '${dest}'. ${err.message}`);
core8.debug(`Failed to delete '${dest}'. ${err.message}`);
}
}
}
@@ -22120,7 +22120,7 @@ var require_tool_cache = __commonJS({
process.chdir(dest);
if (_7zPath) {
try {
const logLevel = core7.isDebug() ? "-bb1" : "-bb0";
const logLevel = core8.isDebug() ? "-bb1" : "-bb0";
const args = [
"x",
logLevel,
@@ -22170,7 +22170,7 @@ var require_tool_cache = __commonJS({
throw new Error("parameter 'file' is required");
}
dest = yield _createExtractFolder(dest);
core7.debug("Checking tar --version");
core8.debug("Checking tar --version");
let versionOutput = "";
yield (0, exec_1.exec)("tar --version", [], {
ignoreReturnCode: true,
@@ -22180,7 +22180,7 @@ var require_tool_cache = __commonJS({
stderr: (data) => versionOutput += data.toString()
}
});
core7.debug(versionOutput.trim());
core8.debug(versionOutput.trim());
const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR");
let args;
if (flags instanceof Array) {
@@ -22188,7 +22188,7 @@ var require_tool_cache = __commonJS({
} else {
args = [flags];
}
if (core7.isDebug() && !flags.includes("v")) {
if (core8.isDebug() && !flags.includes("v")) {
args.push("-v");
}
let destArg = dest;
@@ -22220,7 +22220,7 @@ var require_tool_cache = __commonJS({
args = [flags];
}
args.push("-x", "-C", dest, "-f", file);
if (core7.isDebug()) {
if (core8.isDebug()) {
args.push("-v");
}
const xarPath = yield io3.which("xar", true);
@@ -22265,7 +22265,7 @@ var require_tool_cache = __commonJS({
"-Command",
pwshCommand
];
core7.debug(`Using pwsh at path: ${pwshPath}`);
core8.debug(`Using pwsh at path: ${pwshPath}`);
yield (0, exec_1.exec)(`"${pwshPath}"`, args);
} else {
const powershellCommand = [
@@ -22285,7 +22285,7 @@ var require_tool_cache = __commonJS({
powershellCommand
];
const powershellPath = yield io3.which("powershell", true);
core7.debug(`Using powershell at path: ${powershellPath}`);
core8.debug(`Using powershell at path: ${powershellPath}`);
yield (0, exec_1.exec)(`"${powershellPath}"`, args);
}
});
@@ -22294,7 +22294,7 @@ var require_tool_cache = __commonJS({
return __awaiter(this, void 0, void 0, function* () {
const unzipPath = yield io3.which("unzip", true);
const args = [file];
if (!core7.isDebug()) {
if (!core8.isDebug()) {
args.unshift("-q");
}
args.unshift("-o");
@@ -22305,8 +22305,8 @@ var require_tool_cache = __commonJS({
return __awaiter(this, void 0, void 0, function* () {
version = semver2.clean(version) || version;
arch = arch || os.arch();
core7.debug(`Caching tool ${tool} ${version} ${arch}`);
core7.debug(`source dir: ${sourceDir}`);
core8.debug(`Caching tool ${tool} ${version} ${arch}`);
core8.debug(`source dir: ${sourceDir}`);
if (!fs.statSync(sourceDir).isDirectory()) {
throw new Error("sourceDir is not a directory");
}
@@ -22324,14 +22324,14 @@ var require_tool_cache = __commonJS({
return __awaiter(this, void 0, void 0, function* () {
version = semver2.clean(version) || version;
arch = arch || os.arch();
core7.debug(`Caching tool ${tool} ${version} ${arch}`);
core7.debug(`source file: ${sourceFile}`);
core8.debug(`Caching tool ${tool} ${version} ${arch}`);
core8.debug(`source file: ${sourceFile}`);
if (!fs.statSync(sourceFile).isFile()) {
throw new Error("sourceFile is not a file");
}
const destFolder = yield _createToolPath(tool, version, arch);
const destPath = path2.join(destFolder, targetFile);
core7.debug(`destination file ${destPath}`);
core8.debug(`destination file ${destPath}`);
yield io3.cp(sourceFile, destPath);
_completeToolPath(tool, version, arch);
return destFolder;
@@ -22355,12 +22355,12 @@ var require_tool_cache = __commonJS({
if (versionSpec) {
versionSpec = semver2.clean(versionSpec) || "";
const cachePath = path2.join(_getCacheDirectory(), toolName, versionSpec, arch);
core7.debug(`checking cache: ${cachePath}`);
core8.debug(`checking cache: ${cachePath}`);
if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) {
core7.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`);
core8.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`);
toolPath = cachePath;
} else {
core7.debug("not found");
core8.debug("not found");
}
}
return toolPath;
@@ -22391,7 +22391,7 @@ var require_tool_cache = __commonJS({
const http = new httpm.HttpClient("tool-cache");
const headers = {};
if (auth) {
core7.debug("set auth");
core8.debug("set auth");
headers.authorization = auth;
}
const response = yield http.getJson(treeUrl, headers);
@@ -22412,7 +22412,7 @@ var require_tool_cache = __commonJS({
try {
releases = JSON.parse(versionsRaw);
} catch (_a) {
core7.debug("Invalid json");
core8.debug("Invalid json");
}
}
return releases;
@@ -22438,7 +22438,7 @@ var require_tool_cache = __commonJS({
function _createToolPath(tool, version, arch) {
return __awaiter(this, void 0, void 0, function* () {
const folderPath = path2.join(_getCacheDirectory(), tool, semver2.clean(version) || version, arch || "");
core7.debug(`destination ${folderPath}`);
core8.debug(`destination ${folderPath}`);
const markerPath = `${folderPath}.complete`;
yield io3.rmRF(folderPath);
yield io3.rmRF(markerPath);
@@ -22450,19 +22450,19 @@ var require_tool_cache = __commonJS({
const folderPath = path2.join(_getCacheDirectory(), tool, semver2.clean(version) || version, arch || "");
const markerPath = `${folderPath}.complete`;
fs.writeFileSync(markerPath, "");
core7.debug("finished caching tool");
core8.debug("finished caching tool");
}
function isExplicitVersion(versionSpec) {
const c = semver2.clean(versionSpec) || "";
core7.debug(`isExplicit: ${c}`);
core8.debug(`isExplicit: ${c}`);
const valid = semver2.valid(c) != null;
core7.debug(`explicit? ${valid}`);
core8.debug(`explicit? ${valid}`);
return valid;
}
exports2.isExplicitVersion = isExplicitVersion;
function evaluateVersions(versions, versionSpec) {
let version = "";
core7.debug(`evaluating ${versions.length} versions`);
core8.debug(`evaluating ${versions.length} versions`);
versions = versions.sort((a, b) => {
if (semver2.gt(a, b)) {
return 1;
@@ -22478,9 +22478,9 @@ var require_tool_cache = __commonJS({
}
}
if (version) {
core7.debug(`matched: ${version}`);
core8.debug(`matched: ${version}`);
} else {
core7.debug("match not found");
core8.debug("match not found");
}
return version;
}
@@ -54772,127 +54772,6 @@ var require_del = __commonJS({
}
});
// node_modules/tiny-each-async/index.js
var require_tiny_each_async = __commonJS({
"node_modules/tiny-each-async/index.js"(exports2, module2) {
"use strict";
module2.exports = function eachAsync(arr, parallelLimit, iteratorFn, cb) {
var pending = 0;
var index = 0;
var lastIndex = arr.length - 1;
var called = false;
var limit;
var callback;
var iterate;
if (typeof parallelLimit === "number") {
limit = parallelLimit;
iterate = iteratorFn;
callback = cb || function noop() {
};
} else {
iterate = parallelLimit;
callback = iteratorFn || function noop() {
};
limit = arr.length;
}
if (!arr.length) {
return callback();
}
var iteratorLength = iterate.length;
var shouldCallNextIterator = function shouldCallNextIterator2() {
return !called && pending < limit && index < lastIndex;
};
var iteratorCallback = function iteratorCallback2(err) {
if (called) {
return;
}
pending--;
if (err || index === lastIndex && !pending) {
called = true;
callback(err);
} else if (shouldCallNextIterator()) {
processIterator(++index);
}
};
var processIterator = function processIterator2() {
pending++;
var args = iteratorLength === 2 ? [arr[index], iteratorCallback] : [arr[index], index, iteratorCallback];
iterate.apply(null, args);
if (shouldCallNextIterator()) {
processIterator2(++index);
}
};
processIterator();
};
}
});
// node_modules/get-folder-size/index.js
var require_get_folder_size = __commonJS({
"node_modules/get-folder-size/index.js"(exports2, module2) {
"use strict";
var fs = require("fs");
var path2 = require("path");
var eachAsync = require_tiny_each_async();
function readSizeRecursive(seen, item, ignoreRegEx, callback) {
let cb;
let ignoreRegExp;
if (!callback) {
cb = ignoreRegEx;
ignoreRegExp = null;
} else {
cb = callback;
ignoreRegExp = ignoreRegEx;
}
fs.lstat(item, function lstat(e, stats) {
let total = !e ? stats.size || 0 : 0;
if (stats) {
if (seen.has(stats.ino)) {
return cb(null, 0);
}
seen.add(stats.ino);
}
if (!e && stats.isDirectory()) {
fs.readdir(item, (err, list) => {
if (err) {
return cb(err);
}
eachAsync(
list,
5e3,
(dirItem, next) => {
readSizeRecursive(
seen,
path2.join(item, dirItem),
ignoreRegExp,
(error2, size) => {
if (!error2) {
total += size;
}
next(error2);
}
);
},
(finalErr) => {
cb(finalErr, total);
}
);
});
} else {
if (ignoreRegExp && ignoreRegExp.test(item)) {
total = 0;
}
cb(e, total);
}
});
}
module2.exports = (...args) => {
args.unshift(/* @__PURE__ */ new Set());
return readSizeRecursive(...args);
};
}
});
// package.json
var require_package = __commonJS({
"package.json"(exports2, module2) {
@@ -54940,7 +54819,7 @@ var require_package = __commonJS({
"fast-deep-equal": "^3.1.3",
"file-url": "^3.0.0",
"follow-redirects": "^1.15.11",
"get-folder-size": "^2.0.1",
"get-folder-size": "^5.0.0",
"js-yaml": "^4.1.0",
jsonschema: "1.4.1",
long: "^5.3.2",
@@ -55008,22 +54887,76 @@ var require_package = __commonJS({
// src/start-proxy-action.ts
var import_child_process = require("child_process");
var path = __toESM(require("path"));
var core6 = __toESM(require_core());
var core7 = __toESM(require_core());
var toolcache = __toESM(require_tool_cache());
var import_node_forge = __toESM(require_lib2());
// src/actions-util.ts
var core3 = __toESM(require_core());
var core4 = __toESM(require_core());
var toolrunner = __toESM(require_toolrunner());
var github = __toESM(require_github());
var io2 = __toESM(require_io());
// src/util.ts
var core2 = __toESM(require_core());
var core3 = __toESM(require_core());
var exec = __toESM(require_exec());
var io = __toESM(require_io());
var import_del = __toESM(require_del());
var import_get_folder_size = __toESM(require_get_folder_size());
// node_modules/get-folder-size/index.js
var import_node_path = require("node:path");
async function getFolderSize(itemPath, options) {
return await core(itemPath, options, { errors: true });
}
getFolderSize.loose = async (itemPath, options) => await core(itemPath, options);
getFolderSize.strict = async (itemPath, options) => await core(itemPath, options, { strict: true });
async function core(rootItemPath, options = {}, returnType = {}) {
const fs = options.fs || await import("node:fs/promises");
let folderSize = 0n;
const foundInos = /* @__PURE__ */ new Set();
const errors = [];
await processItem(rootItemPath);
async function processItem(itemPath) {
if (options.ignore?.test(itemPath)) return;
const stats = returnType.strict ? await fs.lstat(itemPath, { bigint: true }) : await fs.lstat(itemPath, { bigint: true }).catch((error2) => errors.push(error2));
if (typeof stats !== "object") return;
if (!foundInos.has(stats.ino)) {
foundInos.add(stats.ino);
folderSize += stats.size;
}
if (stats.isDirectory()) {
const directoryItems = returnType.strict ? await fs.readdir(itemPath) : await fs.readdir(itemPath).catch((error2) => errors.push(error2));
if (typeof directoryItems !== "object") return;
await Promise.all(
directoryItems.map(
(directoryItem) => processItem((0, import_node_path.join)(itemPath, directoryItem))
)
);
}
}
if (!options.bigint) {
if (folderSize > BigInt(Number.MAX_SAFE_INTEGER)) {
const error2 = new RangeError(
"The folder size is too large to return as a Number. You can instruct this package to return a BigInt instead."
);
if (returnType.strict) {
throw error2;
}
errors.push(error2);
folderSize = Number.MAX_SAFE_INTEGER;
} else {
folderSize = Number(folderSize);
}
}
if (returnType.errors) {
return {
size: folderSize,
errors: errors.length > 0 ? errors : null
};
} else {
return folderSize;
}
}
// node_modules/js-yaml/dist/js-yaml.mjs
function isNothing(subject) {
@@ -55594,7 +55527,7 @@ var json = failsafe.extend({
float
]
});
var core = json;
var core2 = json;
var YAML_DATE_REGEXP = new RegExp(
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
);
@@ -55808,7 +55741,7 @@ var set = new type("tag:yaml.org,2002:set", {
resolve: resolveYamlSet,
construct: constructYamlSet
});
var _default = core.extend({
var _default = core2.extend({
implicit: [
timestamp,
merge
@@ -57639,7 +57572,7 @@ function getErrorMessage(error2) {
// src/actions-util.ts
var pkg = require_package();
var getOptionalInput = function(name) {
const value = core3.getInput(name);
const value = core4.getInput(name);
return value.length > 0 ? value : void 0;
};
function getTemporaryDirectory() {
@@ -57651,17 +57584,17 @@ var persistInputs = function() {
const inputEnvironmentVariables = Object.entries(process.env).filter(
([name]) => name.startsWith("INPUT_")
);
core3.saveState(persistedInputsKey, JSON.stringify(inputEnvironmentVariables));
core4.saveState(persistedInputsKey, JSON.stringify(inputEnvironmentVariables));
};
// src/logging.ts
var core4 = __toESM(require_core());
var core5 = __toESM(require_core());
function getActionsLogger() {
return core4;
return core5;
}
// src/start-proxy.ts
var core5 = __toESM(require_core());
var core6 = __toESM(require_core());
// src/languages.ts
var KnownLanguage = /* @__PURE__ */ ((KnownLanguage2) => {
@@ -57742,10 +57675,10 @@ function getCredentials(logger, registrySecrets, registriesCredentials, language
throw new ConfigurationError("Invalid credentials - must be an object");
}
if (isDefined(e.password)) {
core5.setSecret(e.password);
core6.setSecret(e.password);
}
if (isDefined(e.token)) {
core5.setSecret(e.token);
core6.setSecret(e.token);
}
if (!isDefined(e.url) && !isDefined(e.host)) {
throw new ConfigurationError(
@@ -57830,7 +57763,7 @@ async function runWrapper() {
const logger = getActionsLogger();
const tempDir = getTemporaryDirectory();
const proxyLogFilePath = path.resolve(tempDir, "proxy.log");
core6.saveState("proxy-log-file", proxyLogFilePath);
core7.saveState("proxy-log-file", proxyLogFilePath);
const credentials = getCredentials(
logger,
getOptionalInput("registry_secrets"),
@@ -57871,7 +57804,7 @@ async function startProxy(binPath, config, logFilePath, logger) {
);
subprocess.unref();
if (subprocess.pid) {
core6.saveState("proxy-process-pid", `${subprocess.pid}`);
core7.saveState("proxy-process-pid", `${subprocess.pid}`);
}
subprocess.on("error", (error2) => {
subprocessError = error2;
@@ -57890,16 +57823,16 @@ async function startProxy(binPath, config, logFilePath, logger) {
throw subprocessError;
}
logger.info(`Proxy started on ${host}:${port}`);
core6.setOutput("proxy_host", host);
core6.setOutput("proxy_port", port.toString());
core6.setOutput("proxy_ca_certificate", config.ca.cert);
core7.setOutput("proxy_host", host);
core7.setOutput("proxy_port", port.toString());
core7.setOutput("proxy_ca_certificate", config.ca.cert);
const registry_urls = config.all_credentials.filter((credential) => credential.url !== void 0).map((credential) => ({
type: credential.type,
url: credential.url
}));
core6.setOutput("proxy_urls", JSON.stringify(registry_urls));
core7.setOutput("proxy_urls", JSON.stringify(registry_urls));
} catch (error2) {
core6.setFailed(`start-proxy action failed: ${getErrorMessage(error2)}`);
core7.setFailed(`start-proxy action failed: ${getErrorMessage(error2)}`);
}
}
async function getProxyBinaryPath() {
+221 -288
View File
File diff suppressed because it is too large Load Diff
+340 -407
View File
File diff suppressed because it is too large Load Diff
+251 -318
View File
File diff suppressed because it is too large Load Diff
+8 -15
View File
@@ -28,7 +28,7 @@
"fast-deep-equal": "^3.1.3",
"file-url": "^3.0.0",
"follow-redirects": "^1.15.11",
"get-folder-size": "^2.0.1",
"get-folder-size": "^5.0.0",
"js-yaml": "^4.1.0",
"jsonschema": "1.4.1",
"long": "^5.3.2",
@@ -6041,10 +6041,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/gar": {
"version": "1.0.4",
"license": "MIT"
},
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
@@ -6067,14 +6063,15 @@
}
},
"node_modules/get-folder-size": {
"version": "2.0.1",
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/get-folder-size/-/get-folder-size-5.0.0.tgz",
"integrity": "sha512-+fgtvbL83tSDypEK+T411GDBQVQtxv+qtQgbV+HVa/TYubqDhNd5ghH/D6cOHY9iC5/88GtOZB7WI8PXy2A3bg==",
"license": "MIT",
"dependencies": {
"gar": "^1.0.4",
"tiny-each-async": "2.0.3"
},
"bin": {
"get-folder-size": "bin/get-folder-size"
"get-folder-size": "bin/get-folder-size.js"
},
"engines": {
"node": ">=18.11.0"
}
},
"node_modules/get-intrinsic": {
@@ -8689,10 +8686,6 @@
"node": ">=4"
}
},
"node_modules/tiny-each-async": {
"version": "2.0.3",
"license": "MIT"
},
"node_modules/tinyglobby": {
"version": "0.2.12",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.12.tgz",
+1 -1
View File
@@ -42,7 +42,7 @@
"fast-deep-equal": "^3.1.3",
"file-url": "^3.0.0",
"follow-redirects": "^1.15.11",
"get-folder-size": "^2.0.1",
"get-folder-size": "^5.0.0",
"js-yaml": "^4.1.0",
"jsonschema": "1.4.1",
"long": "^5.3.2",
+2 -2
View File
@@ -1,7 +1,6 @@
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import { promisify } from "util";
import * as core from "@actions/core";
import * as exec from "@actions/exec/lib/exec";
@@ -831,7 +830,8 @@ export async function tryGetFolderBytes(
quiet: boolean = false,
): Promise<number | undefined> {
try {
return await promisify<string, number>(getFolderSize)(cacheDir);
// tolerate some errors since we're only estimating the size
return await getFolderSize.loose(cacheDir);
} catch (e) {
if (!quiet || logger.isDebug()) {
logger.warning(