mirror of
https://github.com/pnpm/action-setup.git
synced 2026-03-07 08:21:45 +08:00
Compare commits
6 Commits
e29d91fe75
...
a5211f7987
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5211f7987 | ||
|
|
8aea7c7d41 | ||
|
|
2502eaa221 | ||
|
|
f6cc97e7f4 | ||
|
|
3a0024f066 | ||
|
|
72f04517b7 |
@ -125,7 +125,7 @@ jobs:
|
|||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: 10
|
version: 10
|
||||||
run_install:
|
run_install: |
|
||||||
- recursive: true
|
- recursive: true
|
||||||
args: [--strict-peer-dependencies]
|
args: [--strict-peer-dependencies]
|
||||||
- args: [--global, gulp, prettier, typescript]
|
- args: [--global, gulp, prettier, typescript]
|
||||||
|
|||||||
4
dist/index.js
vendored
4
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -13,7 +13,6 @@
|
|||||||
"@actions/glob": "^0.5.0",
|
"@actions/glob": "^0.5.0",
|
||||||
"@types/expand-tilde": "^2.0.2",
|
"@types/expand-tilde": "^2.0.2",
|
||||||
"@types/node": "^20.11.5",
|
"@types/node": "^20.11.5",
|
||||||
"@types/node-fetch": "^2.6.11",
|
|
||||||
"expand-tilde": "^2.0.2",
|
"expand-tilde": "^2.0.2",
|
||||||
"yaml": "^2.3.4",
|
"yaml": "^2.3.4",
|
||||||
"zod": "^3.22.4"
|
"zod": "^3.22.4"
|
||||||
|
|||||||
@ -26,9 +26,6 @@ importers:
|
|||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^20.11.5
|
specifier: ^20.11.5
|
||||||
version: 20.17.17
|
version: 20.17.17
|
||||||
'@types/node-fetch':
|
|
||||||
specifier: ^2.6.11
|
|
||||||
version: 2.6.12
|
|
||||||
expand-tilde:
|
expand-tilde:
|
||||||
specifier: ^2.0.2
|
specifier: ^2.0.2
|
||||||
version: 2.0.2
|
version: 2.0.2
|
||||||
@ -140,9 +137,6 @@ packages:
|
|||||||
'@types/expand-tilde@2.0.2':
|
'@types/expand-tilde@2.0.2':
|
||||||
resolution: {integrity: sha512-wlsMYiapmIR4Eq/Z0qysN8xaDMjSkO6AIDNFx9oxgWGeKVA1jU+NzwPRZErBNP5z6/dx6QNkNpKglBGPO9OkTA==}
|
resolution: {integrity: sha512-wlsMYiapmIR4Eq/Z0qysN8xaDMjSkO6AIDNFx9oxgWGeKVA1jU+NzwPRZErBNP5z6/dx6QNkNpKglBGPO9OkTA==}
|
||||||
|
|
||||||
'@types/node-fetch@2.6.12':
|
|
||||||
resolution: {integrity: sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA==}
|
|
||||||
|
|
||||||
'@types/node@20.17.17':
|
'@types/node@20.17.17':
|
||||||
resolution: {integrity: sha512-/WndGO4kIfMicEQLTi/mDANUu/iVUhT7KboZPdEqqHQ4aTS+3qT3U5gIqWDFV+XouorjfgGqvKILJeHhuQgFYg==}
|
resolution: {integrity: sha512-/WndGO4kIfMicEQLTi/mDANUu/iVUhT7KboZPdEqqHQ4aTS+3qT3U5gIqWDFV+XouorjfgGqvKILJeHhuQgFYg==}
|
||||||
|
|
||||||
@ -235,10 +229,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-jqdObeR2rxZZbPSGL+3VckHMYtu+f9//KXBsVny6JSX/pa38Fy+bGjuG8eW/H6USNQWhLi8Num++cU2yOCNz4A==}
|
resolution: {integrity: sha512-jqdObeR2rxZZbPSGL+3VckHMYtu+f9//KXBsVny6JSX/pa38Fy+bGjuG8eW/H6USNQWhLi8Num++cU2yOCNz4A==}
|
||||||
engines: {node: '>= 0.12'}
|
engines: {node: '>= 0.12'}
|
||||||
|
|
||||||
form-data@4.0.1:
|
|
||||||
resolution: {integrity: sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==}
|
|
||||||
engines: {node: '>= 6'}
|
|
||||||
|
|
||||||
function-bind@1.1.2:
|
function-bind@1.1.2:
|
||||||
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
|
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
|
||||||
|
|
||||||
@ -549,11 +539,6 @@ snapshots:
|
|||||||
|
|
||||||
'@types/expand-tilde@2.0.2': {}
|
'@types/expand-tilde@2.0.2': {}
|
||||||
|
|
||||||
'@types/node-fetch@2.6.12':
|
|
||||||
dependencies:
|
|
||||||
'@types/node': 20.17.17
|
|
||||||
form-data: 4.0.1
|
|
||||||
|
|
||||||
'@types/node@20.17.17':
|
'@types/node@20.17.17':
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 6.19.8
|
undici-types: 6.19.8
|
||||||
@ -642,12 +627,6 @@ snapshots:
|
|||||||
mime-types: 2.1.35
|
mime-types: 2.1.35
|
||||||
safe-buffer: 5.2.1
|
safe-buffer: 5.2.1
|
||||||
|
|
||||||
form-data@4.0.1:
|
|
||||||
dependencies:
|
|
||||||
asynckit: 0.4.0
|
|
||||||
combined-stream: 1.0.8
|
|
||||||
mime-types: 2.1.35
|
|
||||||
|
|
||||||
function-bind@1.1.2: {}
|
function-bind@1.1.2: {}
|
||||||
|
|
||||||
get-intrinsic@1.3.0:
|
get-intrinsic@1.3.0:
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
import * as cache from '@actions/cache';
|
import { isFeatureAvailable } from '@actions/cache'
|
||||||
import * as core from '@actions/core';
|
import { endGroup, startGroup, warning } from '@actions/core'
|
||||||
import { runRestoreCache } from './run';
|
import { Inputs } from '../inputs'
|
||||||
import { Inputs } from '../inputs';
|
import { runRestoreCache } from './run'
|
||||||
|
|
||||||
export async function restoreCache(inputs: Inputs) {
|
export async function restoreCache(inputs: Inputs) {
|
||||||
if (!inputs.cache) return
|
if (!inputs.cache) return
|
||||||
|
|
||||||
if (!cache.isFeatureAvailable()) {
|
if (!isFeatureAvailable()) {
|
||||||
core.warning('Cache is not available, skipping cache restoration')
|
warning('Cache is not available, skipping cache restoration')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
core.startGroup('Restoring cache...')
|
startGroup('Restoring cache...')
|
||||||
await runRestoreCache(inputs);
|
await runRestoreCache(inputs)
|
||||||
core.endGroup();
|
endGroup()
|
||||||
}
|
}
|
||||||
|
|
||||||
export default restoreCache
|
export default restoreCache
|
||||||
|
|||||||
@ -1,39 +1,39 @@
|
|||||||
import * as cache from '@actions/cache';
|
import { restoreCache } from '@actions/cache'
|
||||||
import * as core from '@actions/core';
|
import { debug, info, saveState, setOutput } from '@actions/core'
|
||||||
import * as exec from '@actions/exec';
|
import { getExecOutput } from '@actions/exec'
|
||||||
import * as glob from '@actions/glob';
|
import { hashFiles } from '@actions/glob'
|
||||||
import os from 'os';
|
import os from 'os'
|
||||||
import { Inputs } from '../inputs';
|
import { Inputs } from '../inputs'
|
||||||
|
|
||||||
export async function runRestoreCache(inputs: Inputs) {
|
export async function runRestoreCache(inputs: Inputs) {
|
||||||
const cachePath = await getCacheDirectory();
|
const cachePath = await getCacheDirectory()
|
||||||
core.saveState('cache_path', cachePath);
|
saveState('cache_path', cachePath)
|
||||||
|
|
||||||
const fileHash = await glob.hashFiles(inputs.cacheDependencyPath);
|
const fileHash = await hashFiles(inputs.cacheDependencyPath)
|
||||||
if (!fileHash) {
|
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}`;
|
const primaryKey = `pnpm-cache-${process.env.RUNNER_OS}-${os.arch()}-${fileHash}`
|
||||||
core.debug(`Primary key is ${primaryKey}`);
|
debug(`Primary key is ${primaryKey}`)
|
||||||
core.saveState('cache_primary_key', 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) {
|
if (!cacheKey) {
|
||||||
core.info(`Cache is not found`);
|
info(`Cache is not found`)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
core.saveState('cache_restored_key', cacheKey)
|
saveState('cache_restored_key', cacheKey)
|
||||||
core.info(`Cache restored from key: ${cacheKey}`)
|
info(`Cache restored from key: ${cacheKey}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCacheDirectory() {
|
async function getCacheDirectory() {
|
||||||
const { stdout } = await exec.getExecOutput('pnpm store path --silent')
|
const { stdout } = await getExecOutput('pnpm store path --silent')
|
||||||
const cacheFolderPath = stdout.trim()
|
const cacheFolderPath = stdout.trim()
|
||||||
core.debug(`Cache folder is set to "${cacheFolderPath}"`)
|
debug(`Cache folder is set to "${cacheFolderPath}"`)
|
||||||
return cacheFolderPath;
|
return cacheFolderPath
|
||||||
};
|
}
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
import * as core from '@actions/core';
|
import { setFailed } from '@actions/core'
|
||||||
import { Inputs } from '../inputs';
|
import { Inputs } from '../inputs'
|
||||||
import { runSaveCache } from './run';
|
import { runSaveCache } from './run'
|
||||||
|
|
||||||
export async function saveCache(inputs: Inputs) {
|
export async function saveCache(inputs: Inputs) {
|
||||||
if (!inputs.cache) return
|
if (!inputs.cache) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await runSaveCache();
|
await runSaveCache()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed((error as Error).message);
|
setFailed((error as Error).message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,18 +1,18 @@
|
|||||||
import * as core from '@actions/core';
|
import { saveCache } from '@actions/cache'
|
||||||
import * as cache from '@actions/cache';
|
import { getState, info } from '@actions/core'
|
||||||
|
|
||||||
export async function runSaveCache() {
|
export async function runSaveCache() {
|
||||||
const state = core.getState('cache_restored_key');
|
const state = getState('cache_restored_key')
|
||||||
const primaryKey = core.getState('cache_primary_key');
|
const primaryKey = getState('cache_primary_key')
|
||||||
const cachePath = core.getState('cache_path');
|
const cachePath = getState('cache_path')
|
||||||
|
|
||||||
if (primaryKey === state) {
|
if (primaryKey === state) {
|
||||||
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
|
info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const cacheId = await cache.saveCache([cachePath], primaryKey);
|
const cacheId = await saveCache([cachePath], primaryKey)
|
||||||
if (cacheId == -1) return;
|
if (cacheId == -1) return
|
||||||
|
|
||||||
core.info(`Cache saved with the key: ${primaryKey}`);
|
info(`Cache saved with the key: ${primaryKey}`)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { setFailed, saveState, getState } from '@actions/core'
|
import { setFailed, saveState, getState } from '@actions/core'
|
||||||
|
import restoreCache from './cache-restore'
|
||||||
|
import saveCache from './cache-save'
|
||||||
import getInputs, { Inputs } from './inputs'
|
import getInputs, { Inputs } from './inputs'
|
||||||
import installPnpm from './install-pnpm'
|
import installPnpm from './install-pnpm'
|
||||||
import setOutputs from './outputs'
|
import setOutputs from './outputs'
|
||||||
import pnpmInstall from './pnpm-install'
|
import pnpmInstall from './pnpm-install'
|
||||||
import pruneStore from './pnpm-store-prune'
|
import pruneStore from './pnpm-store-prune'
|
||||||
import restoreCache from './cache-restore'
|
|
||||||
import saveCache from './cache-save'
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const inputs = getInputs()
|
const inputs = getInputs()
|
||||||
@ -24,7 +24,7 @@ async function runMain(inputs: Inputs) {
|
|||||||
console.log('Installation Completed!')
|
console.log('Installation Completed!')
|
||||||
setOutputs(inputs)
|
setOutputs(inputs)
|
||||||
|
|
||||||
await restoreCache(inputs);
|
await restoreCache(inputs)
|
||||||
|
|
||||||
pnpmInstall(inputs)
|
pnpmInstall(inputs)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user