From 6be87460e3e25594e4b55f88aa81f33b223b388d Mon Sep 17 00:00:00 2001 From: Dan Adajian Date: Wed, 25 Oct 2023 08:13:22 -0500 Subject: [PATCH] feat: support packageManager in package.json (#27) --- .github/workflows/action.yml | 18 +++ bun.lockb | Bin 30223 -> 30583 bytes dist/action.js | 270 +++++++++++++++++++---------------- package.json | 1 + src/action.ts | 20 ++- 5 files changed, 181 insertions(+), 128 deletions(-) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 2bae4f3..fc78a6a 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -34,3 +34,21 @@ jobs: name: Verify Bun run: | bun --version + setup-bun-from-package-json-version: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup package.json + run: | + echo "$(jq '. += {"packageManager": "bun@1.0.0"}' package.json)" > package.json + - name: Setup Bun + uses: ./ + - name: Verify Bun + run: | + bun --version diff --git a/bun.lockb b/bun.lockb index 94757949726fca39e735986f7e5653157d8e5d0c..64e1703a4f60c6d057e2639b0e0110ff0c425ebc 100755 GIT binary patch delta 3503 zcmeHJdu)?c6u-B$qhB}L34`vVjIEQQ$ksivjK@BPOed~|ZFH=gY%6X?#&c{%e6bNX z|4=5=qlPMqkN5{B#*hIT6M{yg0TZ236K0k%3`zom?+^$9f9JMeG6_ci@jp-V`%cff z=bm%!z2`o5|0pkBkORIsk(KXNH@ts#&eGE-UD;ySZ~I1PZwXAwa* z&^vm%IybCa%YjH*+?qKjY2>whYEw=IzqhQnXwT#~^v^!DxKvU{hCu^1yX>Ht&5&Qy zFupgDo@B@h3gi1Q#qj-*hLa5K52>cVN78Fae(9s|L_q@_q&p1#TdYJ4dLYF#b8vF3v32{k6L1iVocF=u%i!0m9aWF4GoJm&~E0~~iQ zz%-t7f8K2D&j&Dpw=2i_5Kw!f7+`~W0C(VOMt`mgW-(s=^-hux~^igjK8$4 zbyxNt_@bhG#QSmJ*O5h|H+y<>4n5&KcJ7nkgsbEu_oaKIncZ{8QoUnYeI>awzs-C6 z^1&7Apo*%KDwulTqk6kr-ENklv_TM5n9L=I~j@bQi#< z1m}eNND-e=tm9K8le~c`OJ^y)5WF!>%Y_LY`(_>QyhRC}d3Fs1PFV)<|j0}VhU&`gVi?(RAG$46Ejz{gw*5CPT# zcLK|R3V>7Olnj7RcD^0b0nUok=7HV~cmTYK#JvDN({Ry=r2rqf)c_C2Jcoa-7W7## zM+OGZ2Y-@|EIy7w?={g6D`)GtLDl=ke0SJoQ&E9$zORT})$=@jTX6yG%jwCT+t;=h zttGxv9|k&;nyYo0OFL_I58fAQ&clQfcXQ&2$wyZ9yqVF&~zhmhYOXFI?Dy_{F{g zUkO$S72!hu;iDI9dq>aTn#jyA#Df$-=H?UhSpTC=x8r zL+7_$d2Y{+0KC8`p5zy`@g#MR`Tp$l?@zyc;Mt>zSQtu#GFItwEBRLi>WgI+ec3S0idR=7y;EO2!+d(DZQtRU_3GGO?i6>b3A$RJ zZizGLq{8rZo%O^Zc@Wd+SU5wD(HR&y$KwgVjw#$@FgX4C-lj a4A!*gB-2xym5`F3r!4Y#n^8yfl|KQw6JAUJ delta 4768 zcmeHLdrXu^5Z^sG1}K+T|apwUt2z?p~!T}V<|XIYIwbK#&IMq-2zFMwVM z57LvMZ0089F`ycFE9e)X%&)AkOJCe1#B8dTR)17v(3u+%u+vshw${9S%viV;VbF7M zc~G*x-dFEUsjU%H!LXM&te9h~Zfb3qzr@%4d!Jx*XCdcgTm&Brs@pjQo}-w9XdpMY zH8<7yYSF3ZVH$+VWb0~ zw<2j|-^r#)*cuMkNUrEi(*|&;*0wMnZu$XSnljaG$&`J_5v|EG@}b>MfoRS29d_^) z=q0%#GfhLWS<{0YEG+;xE;tvCKj;YbgTqE+xC1u190V4`+pnNED(UV(s~>6R5>>#I z`2j%AReXpa2+GitA~G=)$QwQq$k3DW{82!*mjYy9%5r|%P+KBhh{b9E(y0^~pr}+a z4agI-fegJ-*3SSkodsm*Nl_)7X=T^LO1f*aQq-V7vc3k$ zAj6Hx4D0{zlb^s`&i~^_{RA9`{Hpzb^mIKr$6P1y>wmWChyQ1q ze)i94cxG7`{h;dSPdWorJwQ4*akSstRMXHTSpYI3?W};P6&>=yQ z`lj-Gm&XhX$zBCz8GkFrhh!d5p8F1W07r7DAt#x(@^9?GO&8*xdepT-wy3 zmQRd)W}6Ev1(pFTf$Sy;I2@P^907b8$Vb{@U=6Se_&Tr}m<^l;oDSr0_;55C$VXQ` z&*4@kI4aHw7M`kZkhx$uFSvw>a$p4zM|{37h&KBDELUq>~O|6vxKT-ia$K z?rht!#)DC5&M{70AZAi`flU^YrO;+i42_EJ-tG9MvULkaxt!@v+!URpLEjENvel%) zvPTs~HoLkY!&^!I_nwLy$9_`Lq;brvXe(BxuTLwC4~Mx4^dlzq8lp=NF&LOeDaAH> z=!)95@93zo$;U2@Q;QkP<`+_Ru}5n3aj`8!zgA!P{OF;#SLG*%g2X8OBEBp6&hXnC z4-QfDkq#j)&|TQqFYuk?2Q1rkBs*Y`H&M(nSdf)ma~2}}opVB7r9%Qhuit{hE~Ra49}`Mm*nqlF5pQad(Qov>J@G`BW-n^GH=)_N&% P$ validExt.toUpperCase() === upperExt)) { return filePath; } @@ -2360,11 +2360,11 @@ var require_io_util = __commonJS({ if (stats && stats.isFile()) { if (exports.IS_WINDOWS) { try { - const directory = path.dirname(filePath); - const upperName = path.basename(filePath).toUpperCase(); + const directory = path2.dirname(filePath); + const upperName = path2.basename(filePath).toUpperCase(); for (const actualName of yield exports.readdir(directory)) { if (upperName === actualName.toUpperCase()) { - filePath = path.join(directory, actualName); + filePath = path2.join(directory, actualName); break; } } @@ -2464,7 +2464,7 @@ var require_io = __commonJS({ Object.defineProperty(exports, "__esModule", { value: true }); exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0; var assert_1 = require("assert"); - var path = __importStar2(require("path")); + var path2 = __importStar2(require("path")); var ioUtil = __importStar2(require_io_util()); function cp2(source, dest, options = {}) { return __awaiter2(this, void 0, void 0, function* () { @@ -2473,7 +2473,7 @@ var require_io = __commonJS({ if (destStat && destStat.isFile() && !force) { return; } - const newDest = destStat && destStat.isDirectory() && copySourceDirectory ? path.join(dest, path.basename(source)) : dest; + const newDest = destStat && destStat.isDirectory() && copySourceDirectory ? path2.join(dest, path2.basename(source)) : dest; if (!(yield ioUtil.exists(source))) { throw new Error(`no such file or directory: ${source}`); } @@ -2485,7 +2485,7 @@ var require_io = __commonJS({ yield cpDirRecursive(source, newDest, 0, force); } } else { - if (path.relative(source, newDest) === "") { + if (path2.relative(source, newDest) === "") { throw new Error(`'${newDest}' and '${source}' are the same file`); } yield copyFile(source, newDest, force); @@ -2498,7 +2498,7 @@ var require_io = __commonJS({ if (yield ioUtil.exists(dest)) { let destExists = true; if (yield ioUtil.isDirectory(dest)) { - dest = path.join(dest, path.basename(source)); + dest = path2.join(dest, path2.basename(source)); destExists = yield ioUtil.exists(dest); } if (destExists) { @@ -2509,7 +2509,7 @@ var require_io = __commonJS({ } } } - yield mkdirP2(path.dirname(dest)); + yield mkdirP2(path2.dirname(dest)); yield ioUtil.rename(source, dest); }); } @@ -2572,7 +2572,7 @@ var require_io = __commonJS({ } const extensions = []; if (ioUtil.IS_WINDOWS && process.env["PATHEXT"]) { - for (const extension of process.env["PATHEXT"].split(path.delimiter)) { + for (const extension of process.env["PATHEXT"].split(path2.delimiter)) { if (extension) { extensions.push(extension); } @@ -2585,12 +2585,12 @@ var require_io = __commonJS({ } return []; } - if (tool.includes(path.sep)) { + if (tool.includes(path2.sep)) { return []; } const directories = []; if (process.env.PATH) { - for (const p of process.env.PATH.split(path.delimiter)) { + for (const p of process.env.PATH.split(path2.delimiter)) { if (p) { directories.push(p); } @@ -2598,7 +2598,7 @@ var require_io = __commonJS({ } const matches = []; for (const directory of directories) { - const filePath = yield ioUtil.tryGetExecutablePath(path.join(directory, tool), extensions); + const filePath = yield ioUtil.tryGetExecutablePath(path2.join(directory, tool), extensions); if (filePath) { matches.push(filePath); } @@ -4083,7 +4083,7 @@ var require_toolrunner = __commonJS({ var os = __importStar2(require("os")); var events = __importStar2(require("events")); var child = __importStar2(require("child_process")); - var path = __importStar2(require("path")); + var path2 = __importStar2(require("path")); var io = __importStar2(require_io()); var ioUtil = __importStar2(require_io_util()); var timers_1 = require("timers"); @@ -4298,7 +4298,7 @@ var require_toolrunner = __commonJS({ exec() { return __awaiter2(this, void 0, void 0, function* () { if (!ioUtil.isRooted(this.toolPath) && (this.toolPath.includes("/") || IS_WINDOWS && this.toolPath.includes("\\"))) { - this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath); + this.toolPath = path2.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath); } this.toolPath = yield io.which(this.toolPath, true); return new Promise((resolve, reject) => __awaiter2(this, void 0, void 0, function* () { @@ -4796,7 +4796,7 @@ var require_tool_cache = __commonJS({ var fs = __importStar2(require("fs")); var mm = __importStar2(require_manifest()); var os = __importStar2(require("os")); - var path = __importStar2(require("path")); + var path2 = __importStar2(require("path")); var httpm = __importStar2(require_lib()); var semver = __importStar2(require_semver()); var stream = __importStar2(require("stream")); @@ -4818,8 +4818,8 @@ var require_tool_cache = __commonJS({ var userAgent = "actions/tool-cache"; function downloadTool2(url, dest, auth, headers) { return __awaiter2(this, void 0, void 0, function* () { - dest = dest || path.join(_getTempDirectory(), v4_1.default()); - yield io.mkdirP(path.dirname(dest)); + dest = dest || path2.join(_getTempDirectory(), v4_1.default()); + yield io.mkdirP(path2.dirname(dest)); core.debug(`Downloading ${url}`); core.debug(`Destination ${dest}`); const maxAttempts = 3; @@ -4906,7 +4906,7 @@ var require_tool_cache = __commonJS({ process.chdir(originalCwd); } } else { - const escapedScript = path.join(__dirname, "..", "scripts", "Invoke-7zdec.ps1").replace(/'/g, "''").replace(/"|\n|\r/g, ""); + const escapedScript = path2.join(__dirname, "..", "scripts", "Invoke-7zdec.ps1").replace(/'/g, "''").replace(/"|\n|\r/g, ""); const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ""); const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ""); const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; @@ -5082,7 +5082,7 @@ var require_tool_cache = __commonJS({ } const destPath = yield _createToolPath(tool, version3, arch); for (const itemName of fs.readdirSync(sourceDir)) { - const s = path.join(sourceDir, itemName); + const s = path2.join(sourceDir, itemName); yield io.cp(s, destPath, { recursive: true }); } _completeToolPath(tool, version3, arch); @@ -5100,7 +5100,7 @@ var require_tool_cache = __commonJS({ throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version3, arch); - const destPath = path.join(destFolder, targetFile); + const destPath = path2.join(destFolder, targetFile); core.debug(`destination file ${destPath}`); yield io.cp(sourceFile, destPath); _completeToolPath(tool, version3, arch); @@ -5124,7 +5124,7 @@ var require_tool_cache = __commonJS({ let toolPath = ""; if (versionSpec) { versionSpec = semver.clean(versionSpec) || ""; - const cachePath = path.join(_getCacheDirectory(), toolName, versionSpec, arch); + const cachePath = path2.join(_getCacheDirectory(), toolName, versionSpec, arch); core.debug(`checking cache: ${cachePath}`); if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); @@ -5139,12 +5139,12 @@ var require_tool_cache = __commonJS({ function findAllVersions(toolName, arch) { const versions = []; arch = arch || os.arch(); - const toolPath = path.join(_getCacheDirectory(), toolName); + const toolPath = path2.join(_getCacheDirectory(), toolName); if (fs.existsSync(toolPath)) { const children2 = fs.readdirSync(toolPath); for (const child of children2) { if (isExplicitVersion(child)) { - const fullPath = path.join(toolPath, child, arch || ""); + const fullPath = path2.join(toolPath, child, arch || ""); if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) { versions.push(child); } @@ -5199,7 +5199,7 @@ var require_tool_cache = __commonJS({ function _createExtractFolder(dest) { return __awaiter2(this, void 0, void 0, function* () { if (!dest) { - dest = path.join(_getTempDirectory(), v4_1.default()); + dest = path2.join(_getTempDirectory(), v4_1.default()); } yield io.mkdirP(dest); return dest; @@ -5207,7 +5207,7 @@ var require_tool_cache = __commonJS({ } function _createToolPath(tool, version3, arch) { return __awaiter2(this, void 0, void 0, function* () { - const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version3) || version3, arch || ""); + const folderPath = path2.join(_getCacheDirectory(), tool, semver.clean(version3) || version3, arch || ""); core.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io.rmRF(folderPath); @@ -5217,7 +5217,7 @@ var require_tool_cache = __commonJS({ }); } function _completeToolPath(tool, version3, arch) { - const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version3) || version3, arch || ""); + const folderPath = path2.join(_getCacheDirectory(), tool, semver.clean(version3) || version3, arch || ""); const markerPath = `${folderPath}.complete`; fs.writeFileSync(markerPath, ""); core.debug("finished caching tool"); @@ -5373,7 +5373,7 @@ var require_internal_path_helper = __commonJS({ }; Object.defineProperty(exports, "__esModule", { value: true }); exports.safeTrimTrailingSeparator = exports.normalizeSeparators = exports.hasRoot = exports.hasAbsoluteRoot = exports.ensureAbsoluteRoot = exports.dirname = void 0; - var path = __importStar2(require("path")); + var path2 = __importStar2(require("path")); var assert_1 = __importDefault2(require("assert")); var IS_WINDOWS = process.platform === "win32"; function dirname(p) { @@ -5381,7 +5381,7 @@ var require_internal_path_helper = __commonJS({ if (IS_WINDOWS && /^\\\\[^\\]+(\\[^\\]+)?$/.test(p)) { return p; } - let result = path.dirname(p); + let result = path2.dirname(p); if (IS_WINDOWS && /^\\\\[^\\]+\\[^\\]+\\$/.test(result)) { result = safeTrimTrailingSeparator(result); } @@ -5419,7 +5419,7 @@ var require_internal_path_helper = __commonJS({ assert_1.default(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`); if (root.endsWith("/") || IS_WINDOWS && root.endsWith("\\")) { } else { - root += path.sep; + root += path2.sep; } return root + itemPath; } @@ -5457,10 +5457,10 @@ var require_internal_path_helper = __commonJS({ return ""; } p = normalizeSeparators(p); - if (!p.endsWith(path.sep)) { + if (!p.endsWith(path2.sep)) { return p; } - if (p === path.sep) { + if (p === path2.sep) { return p; } if (IS_WINDOWS && /^[A-Z]:\\$/i.test(p)) { @@ -5806,7 +5806,7 @@ var require_minimatch = __commonJS({ "node_modules/minimatch/minimatch.js"(exports, module2) { module2.exports = minimatch; minimatch.Minimatch = Minimatch; - var path = function() { + var path2 = function() { try { return require("path"); } catch (e) { @@ -5814,7 +5814,7 @@ var require_minimatch = __commonJS({ }() || { sep: "/" }; - minimatch.sep = path.sep; + minimatch.sep = path2.sep; var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}; var expand = require_brace_expansion(); var plTypes = { @@ -5905,8 +5905,8 @@ var require_minimatch = __commonJS({ if (!options) options = {}; pattern = pattern.trim(); - if (path.sep !== "/") { - pattern = pattern.split(path.sep).join("/"); + if (path2.sep !== "/") { + pattern = pattern.split(path2.sep).join("/"); } this.options = options; this.set = []; @@ -6283,8 +6283,8 @@ var require_minimatch = __commonJS({ if (f === "/" && partial) return true; var options = this.options; - if (path.sep !== "/") { - f = f.split(path.sep).join("/"); + if (path2.sep !== "/") { + f = f.split(path2.sep).join("/"); } f = f.split(slashSplit); this.debug(this.pattern, "split", f); @@ -6428,7 +6428,7 @@ var require_internal_path = __commonJS({ }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Path = void 0; - var path = __importStar2(require("path")); + var path2 = __importStar2(require("path")); var pathHelper = __importStar2(require_internal_path_helper()); var assert_1 = __importDefault2(require("assert")); var IS_WINDOWS = process.platform === "win32"; @@ -6443,12 +6443,12 @@ var require_internal_path = __commonJS({ assert_1.default(itemPath, `Parameter 'itemPath' must not be empty`); itemPath = pathHelper.safeTrimTrailingSeparator(itemPath); if (!pathHelper.hasRoot(itemPath)) { - this.segments = itemPath.split(path.sep); + this.segments = itemPath.split(path2.sep); } else { let remaining = itemPath; let dir = pathHelper.dirname(remaining); while (dir !== remaining) { - const basename = path.basename(remaining); + const basename = path2.basename(remaining); this.segments.unshift(basename); remaining = dir; dir = pathHelper.dirname(remaining); @@ -6466,7 +6466,7 @@ var require_internal_path = __commonJS({ assert_1.default(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`); this.segments.push(segment); } else { - assert_1.default(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`); + assert_1.default(!segment.includes(path2.sep), `Parameter 'itemPath' contains unexpected path separators`); this.segments.push(segment); } } @@ -6477,12 +6477,12 @@ var require_internal_path = __commonJS({ */ toString() { let result = this.segments[0]; - let skipSlash = result.endsWith(path.sep) || IS_WINDOWS && /^[A-Z]:$/i.test(result); + let skipSlash = result.endsWith(path2.sep) || IS_WINDOWS && /^[A-Z]:$/i.test(result); for (let i = 1; i < this.segments.length; i++) { if (skipSlash) { skipSlash = false; } else { - result += path.sep; + result += path2.sep; } result += this.segments[i]; } @@ -6531,7 +6531,7 @@ var require_internal_pattern = __commonJS({ Object.defineProperty(exports, "__esModule", { value: true }); exports.Pattern = void 0; var os = __importStar2(require("os")); - var path = __importStar2(require("path")); + var path2 = __importStar2(require("path")); var pathHelper = __importStar2(require_internal_path_helper()); var assert_1 = __importDefault2(require("assert")); var minimatch_1 = require_minimatch(); @@ -6560,7 +6560,7 @@ var require_internal_pattern = __commonJS({ } pattern = _Pattern.fixupPattern(pattern, homedir2); this.segments = new internal_path_1.Path(pattern).segments; - this.trailingSeparator = pathHelper.normalizeSeparators(pattern).endsWith(path.sep); + this.trailingSeparator = pathHelper.normalizeSeparators(pattern).endsWith(path2.sep); pattern = pathHelper.safeTrimTrailingSeparator(pattern); let foundGlob = false; const searchSegments = this.segments.map((x) => _Pattern.getLiteral(x)).filter((x) => !foundGlob && !(foundGlob = x === "")); @@ -6584,8 +6584,8 @@ var require_internal_pattern = __commonJS({ match(itemPath) { if (this.segments[this.segments.length - 1] === "**") { itemPath = pathHelper.normalizeSeparators(itemPath); - if (!itemPath.endsWith(path.sep) && this.isImplicitPattern === false) { - itemPath = `${itemPath}${path.sep}`; + if (!itemPath.endsWith(path2.sep) && this.isImplicitPattern === false) { + itemPath = `${itemPath}${path2.sep}`; } } else { itemPath = pathHelper.safeTrimTrailingSeparator(itemPath); @@ -6620,9 +6620,9 @@ var require_internal_pattern = __commonJS({ assert_1.default(literalSegments.every((x, i) => (x !== "." || i === 0) && x !== ".."), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`); assert_1.default(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`); pattern = pathHelper.normalizeSeparators(pattern); - if (pattern === "." || pattern.startsWith(`.${path.sep}`)) { + if (pattern === "." || pattern.startsWith(`.${path2.sep}`)) { pattern = _Pattern.globEscape(process.cwd()) + pattern.substr(1); - } else if (pattern === "~" || pattern.startsWith(`~${path.sep}`)) { + } else if (pattern === "~" || pattern.startsWith(`~${path2.sep}`)) { homedir2 = homedir2 || os.homedir(); assert_1.default(homedir2, "Unable to determine HOME directory"); assert_1.default(pathHelper.hasAbsoluteRoot(homedir2), `Expected HOME directory to be a rooted path. Actual '${homedir2}'`); @@ -6706,8 +6706,8 @@ var require_internal_search_state = __commonJS({ Object.defineProperty(exports, "__esModule", { value: true }); exports.SearchState = void 0; var SearchState = class { - constructor(path, level) { - this.path = path; + constructor(path2, level) { + this.path = path2; this.level = level; } }; @@ -6838,7 +6838,7 @@ var require_internal_globber = __commonJS({ var core = __importStar2(require_core()); var fs = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); - var path = __importStar2(require("path")); + var path2 = __importStar2(require("path")); var patternHelper = __importStar2(require_internal_pattern_helper()); var internal_match_kind_1 = require_internal_match_kind(); var internal_pattern_1 = require_internal_pattern(); @@ -6921,7 +6921,7 @@ var require_internal_globber = __commonJS({ continue; } const childLevel = item.level + 1; - const childItems = (yield __await2(fs.promises.readdir(item.path))).map((x) => new internal_search_state_1.SearchState(path.join(item.path, x), childLevel)); + const childItems = (yield __await2(fs.promises.readdir(item.path))).map((x) => new internal_search_state_1.SearchState(path2.join(item.path, x), childLevel)); stack.push(...childItems.reverse()); } else if (match & internal_match_kind_1.MatchKind.File) { yield yield __await2(item.path); @@ -7234,7 +7234,7 @@ var require_cacheUtils = __commonJS({ var glob = __importStar2(require_glob()); var io = __importStar2(require_io()); var fs = __importStar2(require("fs")); - var path = __importStar2(require("path")); + var path2 = __importStar2(require("path")); var semver = __importStar2(require_semver()); var util = __importStar2(require("util")); var uuid_1 = require_uuid(); @@ -7254,9 +7254,9 @@ var require_cacheUtils = __commonJS({ baseLocation = "/home"; } } - tempDirectory = path.join(baseLocation, "actions", "temp"); + tempDirectory = path2.join(baseLocation, "actions", "temp"); } - const dest = path.join(tempDirectory, (0, uuid_1.v4)()); + const dest = path2.join(tempDirectory, (0, uuid_1.v4)()); yield io.mkdirP(dest); return dest; }); @@ -7281,7 +7281,7 @@ var require_cacheUtils = __commonJS({ _e = false; try { const file = _c; - const relativeFile = path.relative(workspace, file).replace(new RegExp(`\\${path.sep}`, "g"), "/"); + const relativeFile = path2.relative(workspace, file).replace(new RegExp(`\\${path2.sep}`, "g"), "/"); core.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); @@ -23684,11 +23684,11 @@ var require_mime_types = __commonJS({ } return exts[0]; } - function lookup(path) { - if (!path || typeof path !== "string") { + function lookup(path2) { + if (!path2 || typeof path2 !== "string") { return false; } - var extension2 = extname("x." + path).toLowerCase().substr(1); + var extension2 = extname("x." + path2).toLowerCase().substr(1); if (!extension2) { return false; } @@ -23945,7 +23945,7 @@ var require_form_data = __commonJS({ "node_modules/@azure/core-http/node_modules/form-data/lib/form_data.js"(exports, module2) { var CombinedStream = require_combined_stream(); var util = require("util"); - var path = require("path"); + var path2 = require("path"); var http = require("http"); var https = require("https"); var parseUrl = require("url").parse; @@ -24072,11 +24072,11 @@ var require_form_data = __commonJS({ FormData.prototype._getContentDisposition = function(value, options) { var filename, contentDisposition; if (typeof options.filepath === "string") { - filename = path.normalize(options.filepath).replace(/\\/g, "/"); + filename = path2.normalize(options.filepath).replace(/\\/g, "/"); } else if (options.filename || value.name || value.path) { - filename = path.basename(options.filename || value.name || value.path); + filename = path2.basename(options.filename || value.name || value.path); } else if (value.readable && value.hasOwnProperty("httpVersion")) { - filename = path.basename(value.client._httpMessage.path || ""); + filename = path2.basename(value.client._httpMessage.path || ""); } if (filename) { contentDisposition = 'filename="' + filename + '"'; @@ -24992,14 +24992,14 @@ var require_url_state_machine = __commonJS({ return url.replace(/\u0009|\u000A|\u000D/g, ""); } function shortenPath(url) { - const path = url.path; - if (path.length === 0) { + const path2 = url.path; + if (path2.length === 0) { return; } - if (url.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0])) { + if (url.scheme === "file" && path2.length === 1 && isNormalizedWindowsDriveLetter(path2[0])) { return; } - path.pop(); + path2.pop(); } function includesCredentials(url) { return url.username !== "" || url.password !== ""; @@ -30509,16 +30509,16 @@ var require_dist6 = __commonJS({ * Set the path for this URL. If the provided path contains a query, then it will be added to * this URL as well. */ - setPath(path) { - if (!path) { + setPath(path2) { + if (!path2) { this._path = void 0; } else { - const schemeIndex = path.indexOf("://"); + const schemeIndex = path2.indexOf("://"); if (schemeIndex !== -1) { - const schemeStart = path.lastIndexOf("/", schemeIndex); - this.set(schemeStart === -1 ? path : path.substr(schemeStart + 1), "SCHEME"); + const schemeStart = path2.lastIndexOf("/", schemeIndex); + this.set(schemeStart === -1 ? path2 : path2.substr(schemeStart + 1), "SCHEME"); } else { - this.set(path, "PATH"); + this.set(path2, "PATH"); } } } @@ -30526,19 +30526,19 @@ var require_dist6 = __commonJS({ * Append the provided path to this URL's existing path. If the provided path contains a query, * then it will be added to this URL as well. */ - appendPath(path) { - if (path) { + appendPath(path2) { + if (path2) { let currentPath = this.getPath(); if (currentPath) { if (!currentPath.endsWith("/")) { currentPath += "/"; } - if (path.startsWith("/")) { - path = path.substring(1); + if (path2.startsWith("/")) { + path2 = path2.substring(1); } - path = currentPath + path; + path2 = currentPath + path2; } - this.set(path, "PATH"); + this.set(path2, "PATH"); } } /** @@ -30847,8 +30847,8 @@ var require_dist6 = __commonJS({ } } function nextPath(tokenizer) { - const path = readUntilCharacter(tokenizer, "?"); - tokenizer._currentToken = URLToken.path(path); + const path2 = readUntilCharacter(tokenizer, "?"); + tokenizer._currentToken = URLToken.path(path2); if (!hasCurrentCharacter(tokenizer)) { tokenizer._currentState = "DONE"; } else { @@ -47908,10 +47908,10 @@ var require_dist9 = __commonJS({ ]; function escapeURLPath(url2) { const urlParsed = coreHttp.URLBuilder.parse(url2); - let path = urlParsed.getPath(); - path = path || "/"; - path = escape(path); - urlParsed.setPath(path); + let path2 = urlParsed.getPath(); + path2 = path2 || "/"; + path2 = escape(path2); + urlParsed.setPath(path2); return urlParsed.toString(); } function getProxyUriFromDevConnString(connectionString) { @@ -47990,9 +47990,9 @@ var require_dist9 = __commonJS({ } function appendToURLPath(url2, name) { const urlParsed = coreHttp.URLBuilder.parse(url2); - let path = urlParsed.getPath(); - path = path ? path.endsWith("/") ? `${path}${name}` : `${path}/${name}` : name; - urlParsed.setPath(path); + let path2 = urlParsed.getPath(); + path2 = path2 ? path2.endsWith("/") ? `${path2}${name}` : `${path2}/${name}` : name; + urlParsed.setPath(path2); const normalizedUrl = new URL(urlParsed.toString()); return normalizedUrl.toString(); } @@ -48992,9 +48992,9 @@ var require_dist9 = __commonJS({ * @param request - */ getCanonicalizedResourceString(request) { - const path = getURLPath(request.url) || "/"; + const path2 = getURLPath(request.url) || "/"; let canonicalizedResourceString = ""; - canonicalizedResourceString += `/${this.factory.accountName}${path}`; + canonicalizedResourceString += `/${this.factory.accountName}${path2}`; const queries = getURLQueries(request.url); const lowercaseQueries = {}; if (queries) { @@ -55097,8 +55097,8 @@ ${key}:${decodeURIComponent(lowercaseQueries[key])}`; if (this.operationCount >= BATCH_MAX_REQUEST) { throw new RangeError(`Cannot exceed ${BATCH_MAX_REQUEST} sub requests in a single batch`); } - const path = getURLPath(subRequest.url); - if (!path || path === "") { + const path2 = getURLPath(subRequest.url); + if (!path2 || path2 === "") { throw new RangeError(`Invalid url for sub request: '${subRequest.url}'`); } } @@ -55175,8 +55175,8 @@ ${key}:${decodeURIComponent(lowercaseQueries[key])}`; pipeline = newPipeline(credentialOrPipeline, options); } const storageClientContext = new StorageClientContext(url2, pipeline.toServiceClientOptions()); - const path = getURLPath(url2); - if (path && path !== "/") { + const path2 = getURLPath(url2); + if (path2 && path2 !== "/") { this.serviceOrContainerContext = new Container(storageClientContext); } else { this.serviceOrContainerContext = new Service(storageClientContext); @@ -58581,7 +58581,7 @@ var require_tar = __commonJS({ var exec_1 = require_exec(); var io = __importStar2(require_io()); var fs_1 = require("fs"); - var path = __importStar2(require("path")); + var path2 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var constants_1 = require_constants(); var IS_WINDOWS = process.platform === "win32"; @@ -58627,13 +58627,13 @@ var require_tar = __commonJS({ const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && compressionMethod !== constants_1.CompressionMethod.Gzip && IS_WINDOWS; switch (type) { case "create": - args.push("--posix", "-cf", BSD_TAR_ZSTD ? tarFile : cacheFileName.replace(new RegExp(`\\${path.sep}`, "g"), "/"), "--exclude", BSD_TAR_ZSTD ? tarFile : cacheFileName.replace(new RegExp(`\\${path.sep}`, "g"), "/"), "-P", "-C", workingDirectory.replace(new RegExp(`\\${path.sep}`, "g"), "/"), "--files-from", constants_1.ManifestFilename); + args.push("--posix", "-cf", BSD_TAR_ZSTD ? tarFile : cacheFileName.replace(new RegExp(`\\${path2.sep}`, "g"), "/"), "--exclude", BSD_TAR_ZSTD ? tarFile : cacheFileName.replace(new RegExp(`\\${path2.sep}`, "g"), "/"), "-P", "-C", workingDirectory.replace(new RegExp(`\\${path2.sep}`, "g"), "/"), "--files-from", constants_1.ManifestFilename); break; case "extract": - args.push("-xf", BSD_TAR_ZSTD ? tarFile : archivePath.replace(new RegExp(`\\${path.sep}`, "g"), "/"), "-P", "-C", workingDirectory.replace(new RegExp(`\\${path.sep}`, "g"), "/")); + args.push("-xf", BSD_TAR_ZSTD ? tarFile : archivePath.replace(new RegExp(`\\${path2.sep}`, "g"), "/"), "-P", "-C", workingDirectory.replace(new RegExp(`\\${path2.sep}`, "g"), "/")); break; case "list": - args.push("-tf", BSD_TAR_ZSTD ? tarFile : archivePath.replace(new RegExp(`\\${path.sep}`, "g"), "/"), "-P"); + args.push("-tf", BSD_TAR_ZSTD ? tarFile : archivePath.replace(new RegExp(`\\${path2.sep}`, "g"), "/"), "-P"); break; } if (tarPath.type === constants_1.ArchiveToolType.GNU) { @@ -58679,7 +58679,7 @@ var require_tar = __commonJS({ return BSD_TAR_ZSTD ? [ "zstd -d --long=30 --force -o", constants_1.TarFilename, - archivePath.replace(new RegExp(`\\${path.sep}`, "g"), "/") + archivePath.replace(new RegExp(`\\${path2.sep}`, "g"), "/") ] : [ "--use-compress-program", IS_WINDOWS ? '"zstd -d --long=30"' : "unzstd --long=30" @@ -58688,7 +58688,7 @@ var require_tar = __commonJS({ return BSD_TAR_ZSTD ? [ "zstd -d --force -o", constants_1.TarFilename, - archivePath.replace(new RegExp(`\\${path.sep}`, "g"), "/") + archivePath.replace(new RegExp(`\\${path2.sep}`, "g"), "/") ] : ["--use-compress-program", IS_WINDOWS ? '"zstd -d"' : "unzstd"]; default: return ["-z"]; @@ -58703,7 +58703,7 @@ var require_tar = __commonJS({ case constants_1.CompressionMethod.Zstd: return BSD_TAR_ZSTD ? [ "zstd -T0 --long=30 --force -o", - cacheFileName.replace(new RegExp(`\\${path.sep}`, "g"), "/"), + cacheFileName.replace(new RegExp(`\\${path2.sep}`, "g"), "/"), constants_1.TarFilename ] : [ "--use-compress-program", @@ -58712,7 +58712,7 @@ var require_tar = __commonJS({ case constants_1.CompressionMethod.ZstdWithoutLong: return BSD_TAR_ZSTD ? [ "zstd -T0 --force -o", - cacheFileName.replace(new RegExp(`\\${path.sep}`, "g"), "/"), + cacheFileName.replace(new RegExp(`\\${path2.sep}`, "g"), "/"), constants_1.TarFilename ] : ["--use-compress-program", IS_WINDOWS ? '"zstd -T0"' : "zstdmt"]; default: @@ -58752,7 +58752,7 @@ var require_tar = __commonJS({ exports.extractTar = extractTar; function createTar(archiveFolder, sourceDirectories, compressionMethod) { return __awaiter2(this, void 0, void 0, function* () { - (0, fs_1.writeFileSync)(path.join(archiveFolder, constants_1.ManifestFilename), sourceDirectories.join("\n")); + (0, fs_1.writeFileSync)(path2.join(archiveFolder, constants_1.ManifestFilename), sourceDirectories.join("\n")); const commands = yield getCommands(compressionMethod, "create"); yield execCommands(commands, archiveFolder); }); @@ -58827,7 +58827,7 @@ var require_cache = __commonJS({ Object.defineProperty(exports, "__esModule", { value: true }); exports.saveCache = exports.restoreCache = exports.isFeatureAvailable = exports.ReserveCacheError = exports.ValidationError = void 0; var core = __importStar2(require_core()); - var path = __importStar2(require("path")); + var path2 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); var tar_1 = require_tar(); @@ -58892,7 +58892,7 @@ var require_cache = __commonJS({ core.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } - archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); + archivePath = path2.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); core.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); if (core.isDebug()) { @@ -58935,7 +58935,7 @@ var require_cache = __commonJS({ throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); - const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod)); + const archivePath = path2.join(archiveFolder, utils.getCacheFileName(compressionMethod)); core.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); @@ -59005,13 +59005,13 @@ var setup_default = async (options) => { const cacheEnabled = cacheKey && cache.isFeatureAvailable(); const dir = (0, import_node_path.join)((0, import_node_os.homedir)(), ".bun", "bin"); action.addPath(dir); - const path = (0, import_node_path.join)(dir, "bun"); + const path2 = (0, import_node_path.join)(dir, "bun"); let revision; let cacheHit = false; if (cacheEnabled) { - const cacheRestored = await (0, import_cache.restoreCache)([path], cacheKey); + const cacheRestored = await (0, import_cache.restoreCache)([path2], cacheKey); if (cacheRestored) { - revision = await verifyBun(path); + revision = await verifyBun(path2); if (revision) { cacheHit = true; action.info("Using a cached version of Bun."); @@ -59028,12 +59028,12 @@ var setup_default = async (options) => { const extractedPath = await (0, import_tool_cache.extractZip)(zipPath); const exePath = await extractBun(extractedPath); await (0, import_io.mkdirP)(dir); - await (0, import_io.cp)(exePath, path); + await (0, import_io.cp)(exePath, path2); await (0, import_io.rmRF)(exePath); - revision = await verifyBun(path); + revision = await verifyBun(path2); } try { - await (0, import_promises.symlink)(path, (0, import_node_path.join)(dir, "bunx")); + await (0, import_promises.symlink)(path2, (0, import_node_path.join)(dir, "bunx")); } catch (error) { if (error.code !== "EEXIST") { throw error; @@ -59046,7 +59046,7 @@ var setup_default = async (options) => { } if (cacheEnabled) { try { - await (0, import_cache.saveCache)([path], cacheKey); + await (0, import_cache.saveCache)([path2], cacheKey); } catch (error) { action.warning("Failed to save Bun to cache."); } @@ -59079,10 +59079,10 @@ function getDownloadUrl(options) { cacheKey: /^latest|canary|action/i.test(release) ? null : `bun-${release}-${os}-${arch}-${avx2}-${profile}` }; } -async function extractBun(path) { - for (const entry of await (0, import_promises.readdir)(path, { withFileTypes: true })) { +async function extractBun(path2) { + for (const entry of await (0, import_promises.readdir)(path2, { withFileTypes: true })) { const { name } = entry; - const entryPath = (0, import_node_path.join)(path, name); + const entryPath = (0, import_node_path.join)(path2, name); if (entry.isFile()) { if (name === "bun") { return entryPath; @@ -59098,14 +59098,14 @@ async function extractBun(path) { } throw new Error("Could not find executable: bun"); } -async function verifyBun(path) { - const revision = await (0, import_exec.getExecOutput)(path, ["--revision"], { +async function verifyBun(path2) { + const revision = await (0, import_exec.getExecOutput)(path2, ["--revision"], { ignoreReturnCode: true }); if (revision.exitCode === 0 && /^\d+\.\d+\.\d+/.test(revision.stdout)) { return revision.stdout.trim(); } - const version3 = await (0, import_exec.getExecOutput)(path, ["--version"], { + const version3 = await (0, import_exec.getExecOutput)(path2, ["--version"], { ignoreReturnCode: true }); if (version3.exitCode === 0 && /^\d+\.\d+\.\d+/.test(version3.stdout)) { @@ -59115,11 +59115,27 @@ async function verifyBun(path) { } // src/action.ts +var import_fs = require("fs"); +var path = __toESM(require("path")); if (!process.env.RUNNER_TEMP) { process.env.RUNNER_TEMP = (0, import_node_os2.tmpdir)(); } +function readVersionFromPackageJson() { + const { GITHUB_WORKSPACE } = process.env; + if (!GITHUB_WORKSPACE) { + return; + } + const pathToPackageJson = path.join(GITHUB_WORKSPACE, "package.json"); + if (!(0, import_fs.existsSync)(pathToPackageJson)) { + return; + } + const { packageManager } = JSON.parse( + (0, import_fs.readFileSync)(pathToPackageJson, "utf8") + ); + return packageManager == null ? void 0 : packageManager.split("bun@")[1]; +} setup_default({ - version: action2.getInput("bun-version") || void 0, + version: readVersionFromPackageJson() || action2.getInput("bun-version") || void 0, customUrl: action2.getInput("bun-download-url") || void 0 }).then(({ version: version3, revision, cacheHit }) => { action2.setOutput("bun-version", version3); diff --git a/package.json b/package.json index d10f51a..c052e2d 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@actions/tool-cache": "^2.0.1" }, "devDependencies": { + "@types/node": "^20.8.2", "esbuild": "^0.19.2", "prettier": "^2.8.4", "typescript": "^4.9.5" diff --git a/src/action.ts b/src/action.ts index d0358b2..f5d3a0d 100644 --- a/src/action.ts +++ b/src/action.ts @@ -1,13 +1,31 @@ import { tmpdir } from "node:os"; import * as action from "@actions/core"; import setup from "./setup.js"; +import { existsSync, readFileSync } from "fs"; +import * as path from "path"; if (!process.env.RUNNER_TEMP) { process.env.RUNNER_TEMP = tmpdir(); } +function readVersionFromPackageJson(): string | undefined { + const { GITHUB_WORKSPACE } = process.env; + if (!GITHUB_WORKSPACE) { + return; + } + const pathToPackageJson = path.join(GITHUB_WORKSPACE, "package.json"); + if (!existsSync(pathToPackageJson)) { + return; + } + const { packageManager } = JSON.parse( + readFileSync(pathToPackageJson, "utf8") + ) as { packageManager?: string }; + return packageManager?.split("bun@")[1]; +} + setup({ - version: action.getInput("bun-version") || undefined, + version: + readVersionFromPackageJson() || action.getInput("bun-version") || undefined, customUrl: action.getInput("bun-download-url") || undefined, }) .then(({ version, revision, cacheHit }) => {