From 9942e2e45ba433346743ce32bb5a8e5baabc7ce9 Mon Sep 17 00:00:00 2001 From: Yohe-Am <56622350+Yohe-Am@users.noreply.github.com> Date: Fri, 15 Dec 2023 12:05:18 +0000 Subject: [PATCH] fix: commit built code --- index.js | 130 +++++++++++++++++++++++++++---------------------------- 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/index.js b/index.js index 2e8ac53..145b027 100644 --- a/index.js +++ b/index.js @@ -81701,7 +81701,7 @@ const os = __importStar(__nccwpck_require__(2037)); const node_fetch_1 = __importDefault(__nccwpck_require__(467)); const crypto_1 = __importDefault(__nccwpck_require__(6113)); // TODO: auto-manage these versions -const DENO_VERSION = "1.39.0"; +const DENO_VERSION = '1.39.0'; async function latestGhjkVersion() { const resp = await (0, node_fetch_1.default)(`https://api.github.com/repos/metatypedev/ghjk/releases/latest`); if (!resp.ok) { @@ -81716,75 +81716,73 @@ async function latestGhjkVersion() { */ async function main() { try { - const inputVersion = core.getInput("version"); - const inputInstallerUrl = core.getInput("installer-url"); - const inputSync = core.getInput("sync"); - const inputSkipDenoInstall = core.getInput("skip-deno-install"); - const inputCacheDisable = core.getInput("cache-disable"); - const inputCacheKeyPrefix = core.getInput("cache-key-prefix"); - const inputCacheSaveIf = core.getInput("cache-save-if"); - const inputCacheKeyEnvVars = core.getInput("cache-key-env-vars"); + const inputVersion = core.getInput('version'); + const inputInstallerUrl = core.getInput('installer-url'); + const inputSync = core.getInput('sync'); + const inputSkipDenoInstall = core.getInput('skip-deno-install'); + const inputCacheDisable = core.getInput('cache-disable'); + const inputCacheKeyPrefix = core.getInput('cache-key-prefix'); + const inputCacheSaveIf = core.getInput('cache-save-if'); + const inputCacheKeyEnvVars = core.getInput('cache-key-env-vars'); const version = inputVersion.length > 0 ? inputVersion - : process.env["GHJK_VERSION"] ?? (await latestGhjkVersion()); + : process.env['GHJK_VERSION'] ?? (await latestGhjkVersion()); const installerUrl = inputInstallerUrl.length > 0 ? inputInstallerUrl : `https://raw.github.com/metatypedev/ghjk/${version}/install.ts`; - const execDir = await installGhjk(version, installerUrl, inputSkipDenoInstall === "true"); + const execDir = await installGhjk(version, installerUrl, inputSkipDenoInstall === 'true'); core.addPath(execDir); - const configStr = (await exec.getExecOutput("ghjk", ["print", "config"])) + const configStr = (await exec.getExecOutput('ghjk', ['print', 'config'])) .stdout; - const ghjkDir = (await exec.getExecOutput("ghjk", ["print", "ghjk-dir-path"], { - silent: true, + const ghjkDir = (await exec.getExecOutput('ghjk', ['print', 'ghjk-dir-path'], { + silent: true })).stdout.trim(); - if (inputCacheDisable === "false" && cache.isFeatureAvailable()) { - const ghjkVersion = (await exec.getExecOutput("ghjk", ["--version"], { silent: true })).stdout.trim(); - const configPath = (await exec.getExecOutput("ghjk", ["print", "config-path"], { - silent: true, + if (inputCacheDisable === 'false' && cache.isFeatureAvailable()) { + const ghjkVersion = (await exec.getExecOutput('ghjk', ['--version'], { silent: true })).stdout.trim(); + const configPath = (await exec.getExecOutput('ghjk', ['print', 'config-path'], { + silent: true })).stdout.trim(); - const hasher = crypto_1.default.createHash("sha1"); + const hasher = crypto_1.default.createHash('sha1'); hasher.update(ghjkVersion); hasher.update(configPath); // TODO: consider ignoring config to avoid misses just for one dep change hasher.update(configStr); const hashedEnvs = [ - "GHJK", - "DENO", + 'GHJK', + 'DENO', ...inputCacheKeyEnvVars - .split(",") - .filter((str) => str.length > 0) - .map((str) => str.trim()), + .split(',') + .filter(str => str.length > 0) + .map(str => str.trim()) ]; for (const [key, val] of Object.entries(process.env)) { - if (hashedEnvs.some((pfix) => key.startsWith(pfix))) { + if (hashedEnvs.some(pfix => key.startsWith(pfix))) { hasher.update(`${key}=${val}`); } } - const hash = hasher.digest("hex"); - const keyPrefix = inputCacheKeyPrefix.length > 0 - ? inputCacheKeyPrefix - : "v0-ghjk"; + const hash = hasher.digest('hex'); + const keyPrefix = inputCacheKeyPrefix.length > 0 ? inputCacheKeyPrefix : 'v0-ghjk'; const key = `${keyPrefix}-${hash}`; - const envsDir = core.toPlatformPath(path.resolve(ghjkDir, "envs")); + const envsDir = core.toPlatformPath(path.resolve(ghjkDir, 'envs')); const cacheDirs = [envsDir]; core.info(JSON.stringify({ cacheDirs, envsDir, ghjkDir })); // NOTE: restoreCache modifies the array it's given for some reason await cache.restoreCache([...cacheDirs], key); - if (inputCacheSaveIf === "true") { + if (inputCacheSaveIf === 'true') { core.info(`enabling cache with key ${key}: [${cacheDirs}]`); - core.saveState("ghjk-cache-save", true); - core.saveState("ghjk-post-args", { + core.saveState('ghjk-cache-save', true); + core.saveState('ghjk-post-args', { key, - cacheDirs, + cacheDirs }); } } - if (inputSync === "true") { - await exec.exec("ghjk", ["ports", "sync"]); + if (inputSync === 'true') { + await exec.exec('ghjk', ['ports', 'sync']); } - core.setOutput("GHJK_DIR", ghjkDir); - core.exportVariable("GHJK_DIR", ghjkDir); - core.exportVariable("BASH_ENV", `${ghjkDir}/env.sh`); + core.setOutput('GHJK_DIR', ghjkDir); + core.exportVariable('GHJK_DIR', ghjkDir); + core.exportVariable('BASH_ENV', `${ghjkDir}/env.sh`); } catch (error) { // Fail the workflow run if an error occurs @@ -81794,18 +81792,18 @@ async function main() { } exports.main = main; async function installGhjk(version, installerUrl, skipDenoInstall) { - let denoExec = "deno"; - if (skipDenoInstall && !process.env["GHJK_INSTALL_DENO_EXEC"]) { - const denoOut = await exec.getExecOutput("deno", ["--version"]); + let denoExec = 'deno'; + if (skipDenoInstall && !process.env['GHJK_INSTALL_DENO_EXEC']) { + const denoOut = await exec.getExecOutput('deno', ['--version']); if (denoOut.exitCode !== 0) { - throw new Error("skip-deno-install set but no deno binary found"); + throw new Error('skip-deno-install set but no deno binary found'); } core.debug(`skipping deno install & using found "deno" bin`); } else { - denoExec = await installDeno(process.env["DENO_VERSION"] ?? DENO_VERSION); + denoExec = await installDeno(process.env['DENO_VERSION'] ?? DENO_VERSION); } - const foundExecDir = tc.find("ghjk", version); + const foundExecDir = tc.find('ghjk', version); if (foundExecDir.length !== 0) { core.debug(`found cached ghjk tool under version ${version}: ${foundExecDir}`); return foundExecDir; @@ -81814,20 +81812,20 @@ async function installGhjk(version, installerUrl, skipDenoInstall) { core.debug(`unable to find cached ghjk tool under version ${version}`); } core.debug(`installing ghjk using install.ts`); - const installDir = process.env["GHJK_INSTALL_EXE_DIR"] ?? - core.toPlatformPath(path.resolve(os.homedir(), ".local", "bin")); + const installDir = process.env['GHJK_INSTALL_EXE_DIR'] ?? + core.toPlatformPath(path.resolve(os.homedir(), '.local', 'bin')); const env = { ...process.env, GHJK_INSTALL_EXE_DIR: installDir, - SHELL: "bash", + SHELL: 'bash' }; // NOTE: we make the ghjk bin use whichver deno is avail in path // to avoid it hardcoding the current deno bin path // which won't be the same after tool cache restore - env["GHJK_INSTALL_DENO_EXEC"] = "deno"; - core.debug(JSON.stringify({ denoExec, env }, undefined, " ")); + env['GHJK_INSTALL_DENO_EXEC'] = 'deno'; + core.debug(JSON.stringify({ denoExec, env }, undefined, ' ')); await exec.exec(`"${denoExec}" run -A`, [installerUrl], { env }); - return await tc.cacheDir(installDir, "ghjk", version); + return await tc.cacheDir(installDir, 'ghjk', version); } exports.installGhjk = installGhjk; async function installDeno(version) { @@ -81838,32 +81836,32 @@ async function installDeno(version) { function zipName() { let arch; switch (process.arch) { - case "arm64": - arch = "aarch64"; + case 'arm64': + arch = 'aarch64'; break; - case "x64": - arch = "x86_64"; + case 'x64': + arch = 'x86_64'; break; default: throw new Error(`Unsupported architechture ${process.arch}.`); } let platform; switch (process.platform) { - case "linux": - platform = "unknown-linux-gnu"; + case 'linux': + platform = 'unknown-linux-gnu'; break; - case "darwin": - platform = "apple-darwin"; + case 'darwin': + platform = 'apple-darwin'; break; - case "win32": - platform = "pc-windows-msvc"; + case 'win32': + platform = 'pc-windows-msvc'; break; default: throw new Error(`Unsupported platform ${process.platform}.`); } return `deno-${arch}-${platform}.zip`; } - const cachedPath = tc.find("ghjk-deno", version); + const cachedPath = tc.find('ghjk-deno', version); if (cachedPath) { core.info(`Using cached Deno installation from ${cachedPath}.`); core.addPath(cachedPath); @@ -81874,7 +81872,7 @@ async function installDeno(version) { core.info(`Downloading Deno from ${url}.`); const zipPath = await tc.downloadTool(url); const extractedFolder = await tc.extractZip(zipPath); - const newCachedPath = await tc.cacheDir(extractedFolder, "ghjk-deno", version); + const newCachedPath = await tc.cacheDir(extractedFolder, 'ghjk-deno', version); core.info(`Cached Deno to ${newCachedPath}.`); core.addPath(newCachedPath); return `${newCachedPath}/deno`; @@ -81887,15 +81885,15 @@ exports.installDeno = installDeno; async function post() { try { if (cache.isFeatureAvailable() && - core.getState("ghjk-cache-save") === "true") { - const argsStr = core.getState("ghjk-post-args"); + core.getState('ghjk-cache-save') === 'true') { + const argsStr = core.getState('ghjk-post-args'); core.info(argsStr); const args = JSON.parse(argsStr); const { key, cacheDirs } = args; await cache.saveCache(cacheDirs, key); } else { - core.info("cache-save flag is false, skipping"); + core.info('cache-save flag is false, skipping'); } } catch (error) {