From f6cc97e7f4040e85c43946ff3f17c6666504a5b6 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Sat, 6 Dec 2025 11:09:20 +0700 Subject: [PATCH] style: format * no semicolons * no star imports * import order --- dist/index.js | Bin 1512286 -> 1509731 bytes src/cache-restore/index.ts | 18 +++++++-------- src/cache-restore/run.ts | 44 ++++++++++++++++++------------------- src/cache-save/index.ts | 10 ++++----- src/cache-save/run.ts | 20 ++++++++--------- src/index.ts | 6 ++--- 6 files changed, 49 insertions(+), 49 deletions(-) diff --git a/dist/index.js b/dist/index.js index 85e528bd96cb164818230a966b24563c9fa63bdf..90e05629e9d74f2995fbe94a4633b45040ec4038 100644 GIT binary patch delta 941 zcmZXSO-K}B7{}Rm{Ms>H*BxE0bnye`HFwro_Y>JZ#V(qW9U_$+cizz_xsD4{G*wj ze##6@&~NT;kDAtaF_{o!i2mv5q&>`e#19Rsf@+RoiC6}{xF)Gf()Jf$%0{N*Re@-17DUhi{Qs-#PMTIzGCRs3fg09rkFsv;Ydc; zOcJzVf>;U;{rj$mK5w|)3`MqJN^5wENCYEV@A(;VG#SrZ3y7b)W~j@OVF&MEJE)q$ zz72JA&gpfe>=fHu*hLYHBU4S2*+I4J#$?hWD;7a?jtzR8CaR|Bh(2Vy{+nZ$?WneV zV4tv6W6|Zt;jH_nf1JL0=ApA*FRdNs=mYPi0lg5-6zo&V1#M;|l39d&3VEu6iOCp* zjAcX*yl1oKzHgkq_Xj%<-=-9mUWtn3_$H{;g#}DXDebac0F{g+ee6=*u{hLra5tKYBvE;Qm9)xh zd?YR=#EPakT09;VqZQ3|G;vsr9%^fjmWrj~72BvIMH5vWCW@|jGLZtCWYVYY-7bZ` zZGYji>8(J5<^yd$S&*?JSxcn+8As`xz(C_fl}slC?R&KyUpO~(%&zYHuHFxYw?bhT zZ~|}x3{V5q0(C$=&;WP<7H9-c0!=_O;LU}?EsuZKBoh%ami2D8oXO?;eV^;xAY^wg i_`7mnL%tg>rf{GA^vgBAWrux0E8qvXoE>iak^cviekKqA delta 878 zcmY+C&r1|x7{{61_Sd+ZZYrUuT)^#ajX+_zT)m&ChBUBlT3)0r>vwfCgl*b6Bj!n+5Vq*o*uMiobbzND* zwrQA)tXnwOtSe=TZ8~n39E&Xry^^cgj(L@oX~`xR@WK*7GC>7hA!d;~?Y0`Xz94kc zp_W5gOHlH=iec&{b|%;}(D1t)U+@Z>tNl=%TPAKiS@OcU`|aSvdh)^0NPSl9MX0l~ zy(2^e3njBmC7pc=T@-ZI6Ydl(FY_3Ti4@s*_|!qnyRgJ#VzrotS+hT3IczD5gzh)3 zh`o*GwAh0VUjG+uVY(DY1w)sqrfCGN!=Ahzcf?86(C`{IpfEm3K7D!GoJ~^hZ)n<} zifjTKH4C*UwfW~pCZ(njD(u&1X@++TBWmhE)47(*4tw`e^K-eD$`0r1(khqonOrts z*G9RPN#z^-Cb%}7QL`%eVfH8@2}Slc@O}3`Bq^a13av z4kcP2{PyM3`Ap@`c58R_dspmZVBhY$B6L+h_s6aYHTz`SrOk~*3^)$70qxa|M8~(i Ee@(F)?f?J) diff --git a/src/cache-restore/index.ts b/src/cache-restore/index.ts index e5ebef4..b3db275 100644 --- a/src/cache-restore/index.ts +++ b/src/cache-restore/index.ts @@ -1,19 +1,19 @@ -import * as cache from '@actions/cache'; -import * as core from '@actions/core'; -import { runRestoreCache } from './run'; -import { Inputs } from '../inputs'; +import { isFeatureAvailable } from '@actions/cache' +import { endGroup, startGroup, warning } from '@actions/core' +import { Inputs } from '../inputs' +import { runRestoreCache } from './run' export async function restoreCache(inputs: Inputs) { if (!inputs.cache) return - if (!cache.isFeatureAvailable()) { - core.warning('Cache is not available, skipping cache restoration') + if (!isFeatureAvailable()) { + warning('Cache is not available, skipping cache restoration') return } - core.startGroup('Restoring cache...') - await runRestoreCache(inputs); - core.endGroup(); + startGroup('Restoring cache...') + await runRestoreCache(inputs) + endGroup() } export default restoreCache diff --git a/src/cache-restore/run.ts b/src/cache-restore/run.ts index f10ab78..017c2a9 100644 --- a/src/cache-restore/run.ts +++ b/src/cache-restore/run.ts @@ -1,39 +1,39 @@ -import * as cache from '@actions/cache'; -import * as core from '@actions/core'; -import * as exec from '@actions/exec'; -import * as glob from '@actions/glob'; -import os from 'os'; -import { Inputs } from '../inputs'; +import { restoreCache } from '@actions/cache' +import { debug, info, saveState, setOutput } from '@actions/core' +import * as exec from '@actions/exec' +import * as glob from '@actions/glob' +import os from 'os' +import { Inputs } from '../inputs' export async function runRestoreCache(inputs: Inputs) { - const cachePath = await getCacheDirectory(); - core.saveState('cache_path', cachePath); + const cachePath = await getCacheDirectory() + saveState('cache_path', cachePath) - const fileHash = await glob.hashFiles(inputs.cacheDependencyPath); + const fileHash = await glob.hashFiles(inputs.cacheDependencyPath) if (!fileHash) { - throw new Error('Some specified paths were not resolved, unable to cache dependencies.'); + throw new Error('Some specified paths were not resolved, unable to cache dependencies.') } - const primaryKey = `pnpm-cache-${process.env.RUNNER_OS}-${os.arch()}-${fileHash}`; - core.debug(`Primary key is ${primaryKey}`); - core.saveState('cache_primary_key', primaryKey); + const primaryKey = `pnpm-cache-${process.env.RUNNER_OS}-${os.arch()}-${fileHash}` + debug(`Primary key is ${primaryKey}`) + saveState('cache_primary_key', primaryKey) - let cacheKey = await cache.restoreCache([cachePath], primaryKey); + let cacheKey = await restoreCache([cachePath], primaryKey) - core.setOutput('cache-hit', Boolean(cacheKey)); + setOutput('cache-hit', Boolean(cacheKey)) if (!cacheKey) { - core.info(`Cache is not found`); - return; + info(`Cache is not found`) + return } - core.saveState('cache_restored_key', cacheKey) - core.info(`Cache restored from key: ${cacheKey}`) + saveState('cache_restored_key', cacheKey) + info(`Cache restored from key: ${cacheKey}`) } async function getCacheDirectory() { const { stdout } = await exec.getExecOutput('pnpm store path --silent') const cacheFolderPath = stdout.trim() - core.debug(`Cache folder is set to "${cacheFolderPath}"`) - return cacheFolderPath; -}; + debug(`Cache folder is set to "${cacheFolderPath}"`) + return cacheFolderPath +} diff --git a/src/cache-save/index.ts b/src/cache-save/index.ts index ea9bee2..2beec06 100644 --- a/src/cache-save/index.ts +++ b/src/cache-save/index.ts @@ -1,14 +1,14 @@ -import * as core from '@actions/core'; -import { Inputs } from '../inputs'; -import { runSaveCache } from './run'; +import { setFailed } from '@actions/core' +import { Inputs } from '../inputs' +import { runSaveCache } from './run' export async function saveCache(inputs: Inputs) { if (!inputs.cache) return try { - await runSaveCache(); + await runSaveCache() } catch (error) { - core.setFailed((error as Error).message); + setFailed((error as Error).message) } } diff --git a/src/cache-save/run.ts b/src/cache-save/run.ts index d343800..7481d58 100644 --- a/src/cache-save/run.ts +++ b/src/cache-save/run.ts @@ -1,18 +1,18 @@ -import * as core from '@actions/core'; -import * as cache from '@actions/cache'; +import { saveCache } from '@actions/cache' +import { getState, info } from '@actions/core' export async function runSaveCache() { - const state = core.getState('cache_restored_key'); - const primaryKey = core.getState('cache_primary_key'); - const cachePath = core.getState('cache_path'); + const state = getState('cache_restored_key') + const primaryKey = getState('cache_primary_key') + const cachePath = getState('cache_path') if (primaryKey === state) { - core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); - return; + info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`) + return } - const cacheId = await cache.saveCache([cachePath], primaryKey); - if (cacheId == -1) return; + const cacheId = await saveCache([cachePath], primaryKey) + if (cacheId == -1) return - core.info(`Cache saved with the key: ${primaryKey}`); + info(`Cache saved with the key: ${primaryKey}`) } diff --git a/src/index.ts b/src/index.ts index ac98d1a..b3c72cd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,11 @@ import { setFailed, saveState, getState } from '@actions/core' +import restoreCache from './cache-restore' +import saveCache from './cache-save' import getInputs, { Inputs } from './inputs' import installPnpm from './install-pnpm' import setOutputs from './outputs' import pnpmInstall from './pnpm-install' import pruneStore from './pnpm-store-prune' -import restoreCache from './cache-restore' -import saveCache from './cache-save' async function main() { const inputs = getInputs() @@ -24,7 +24,7 @@ async function runMain(inputs: Inputs) { console.log('Installation Completed!') setOutputs(inputs) - await restoreCache(inputs); + await restoreCache(inputs) pnpmInstall(inputs) }