2020-05-09 21:02:32 +07:00
|
|
|
import { setFailed, saveState, getState } from '@actions/core'
|
2025-12-07 22:16:49 +01:00
|
|
|
import restoreCache from './cache-restore'
|
|
|
|
|
import saveCache from './cache-save'
|
|
|
|
|
import getInputs, { Inputs } from './inputs'
|
2020-05-09 20:03:45 +07:00
|
|
|
import installPnpm from './install-pnpm'
|
2022-02-23 10:07:15 +07:00
|
|
|
import setOutputs from './outputs'
|
2020-05-09 20:24:52 +07:00
|
|
|
import pnpmInstall from './pnpm-install'
|
2020-05-09 21:15:50 +07:00
|
|
|
import pruneStore from './pnpm-store-prune'
|
2020-05-08 13:06:16 +07:00
|
|
|
|
2020-05-08 14:12:16 +07:00
|
|
|
async function main() {
|
2020-05-09 21:15:50 +07:00
|
|
|
const inputs = getInputs()
|
2025-12-07 22:16:49 +01:00
|
|
|
|
|
|
|
|
if (getState('is_post') === 'true') {
|
|
|
|
|
await runPost(inputs)
|
|
|
|
|
} else {
|
|
|
|
|
await runMain(inputs)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function runMain(inputs: Inputs) {
|
2020-05-09 21:02:32 +07:00
|
|
|
saveState('is_post', 'true')
|
2025-12-07 22:16:49 +01:00
|
|
|
|
2020-05-09 20:03:45 +07:00
|
|
|
await installPnpm(inputs)
|
2020-05-08 21:55:03 +07:00
|
|
|
console.log('Installation Completed!')
|
|
|
|
|
setOutputs(inputs)
|
2025-12-07 22:16:49 +01:00
|
|
|
|
|
|
|
|
await restoreCache(inputs)
|
|
|
|
|
|
2020-05-09 20:24:52 +07:00
|
|
|
pnpmInstall(inputs)
|
2020-05-08 14:12:16 +07:00
|
|
|
}
|
2020-05-08 13:06:16 +07:00
|
|
|
|
2025-12-07 22:16:49 +01:00
|
|
|
async function runPost(inputs: Inputs) {
|
|
|
|
|
pruneStore(inputs)
|
|
|
|
|
await saveCache(inputs)
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-08 14:12:16 +07:00
|
|
|
main().catch(error => {
|
2020-05-08 13:06:16 +07:00
|
|
|
console.error(error)
|
|
|
|
|
setFailed(error)
|
|
|
|
|
})
|