mirror of
https://github.com/actions/setup-node.git
synced 2026-06-11 13:44:17 +08:00
Compare commits
1 Commits
f9c794dbd5
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92a3a341bd |
2
.github/workflows/e2e-cache.yml
vendored
2
.github/workflows/e2e-cache.yml
vendored
@@ -46,7 +46,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v6
|
||||||
with:
|
with:
|
||||||
version: 6.10.0
|
version: 6.10.0
|
||||||
- name: Generate pnpm file
|
- name: Generate pnpm file
|
||||||
|
|||||||
37
dist/cache-save/index.js
vendored
37
dist/cache-save/index.js
vendored
@@ -71644,24 +71644,7 @@ exports.supportedPackageManagers = {
|
|||||||
name: 'yarn',
|
name: 'yarn',
|
||||||
lockFilePatterns: ['yarn.lock'],
|
lockFilePatterns: ['yarn.lock'],
|
||||||
getCacheFolderPath: async (projectDir) => {
|
getCacheFolderPath: async (projectDir) => {
|
||||||
// Try to enable corepack first if available
|
const yarnVersion = await (0, exports.getCommandOutputNotEmpty)(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
|
||||||
// This helps with yarn v2+ which requires corepack
|
|
||||||
await enableCorepackIfSupported();
|
|
||||||
let yarnVersion;
|
|
||||||
try {
|
|
||||||
yarnVersion = await (0, exports.getCommandOutputNotEmpty)(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// Check if this is a corepack error message
|
|
||||||
const errorMsg = err.message;
|
|
||||||
if (errorMsg.includes('packageManager') &&
|
|
||||||
errorMsg.includes('Corepack')) {
|
|
||||||
throw new Error(`Yarn v4+ requires corepack to be enabled. Please run 'corepack enable' before using ` +
|
|
||||||
`actions/setup-node with yarn, or disable caching with 'package-manager-cache: false'. ` +
|
|
||||||
`See: https://github.com/actions/setup-node/issues/1027 for more information.`);
|
|
||||||
}
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`);
|
core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`);
|
||||||
const stdOut = yarnVersion.startsWith('1.')
|
const stdOut = yarnVersion.startsWith('1.')
|
||||||
? await (0, exports.getCommandOutput)('yarn cache dir', projectDir)
|
? await (0, exports.getCommandOutput)('yarn cache dir', projectDir)
|
||||||
@@ -71673,24 +71656,6 @@ exports.supportedPackageManagers = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* Tries to enable corepack for Node.js versions that support it (16.9+)
|
|
||||||
* This helps with yarn v2+ which requires corepack
|
|
||||||
* See: https://github.com/actions/setup-node/issues/1027
|
|
||||||
*/
|
|
||||||
const enableCorepackIfSupported = async () => {
|
|
||||||
try {
|
|
||||||
await exec.exec('corepack', ['enable'], {
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true
|
|
||||||
});
|
|
||||||
core.debug('Corepack enabled successfully');
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
// Corepack not available or failed silently
|
|
||||||
core.debug('Corepack not available on this system');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const getCommandOutput = async (toolCommand, cwd) => {
|
const getCommandOutput = async (toolCommand, cwd) => {
|
||||||
let { stdout, stderr, exitCode } = await exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true, ...(cwd && { cwd }) });
|
let { stdout, stderr, exitCode } = await exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true, ...(cwd && { cwd }) });
|
||||||
if (exitCode) {
|
if (exitCode) {
|
||||||
|
|||||||
37
dist/setup/index.js
vendored
37
dist/setup/index.js
vendored
@@ -81282,24 +81282,7 @@ exports.supportedPackageManagers = {
|
|||||||
name: 'yarn',
|
name: 'yarn',
|
||||||
lockFilePatterns: ['yarn.lock'],
|
lockFilePatterns: ['yarn.lock'],
|
||||||
getCacheFolderPath: async (projectDir) => {
|
getCacheFolderPath: async (projectDir) => {
|
||||||
// Try to enable corepack first if available
|
const yarnVersion = await (0, exports.getCommandOutputNotEmpty)(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
|
||||||
// This helps with yarn v2+ which requires corepack
|
|
||||||
await enableCorepackIfSupported();
|
|
||||||
let yarnVersion;
|
|
||||||
try {
|
|
||||||
yarnVersion = await (0, exports.getCommandOutputNotEmpty)(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// Check if this is a corepack error message
|
|
||||||
const errorMsg = err.message;
|
|
||||||
if (errorMsg.includes('packageManager') &&
|
|
||||||
errorMsg.includes('Corepack')) {
|
|
||||||
throw new Error(`Yarn v4+ requires corepack to be enabled. Please run 'corepack enable' before using ` +
|
|
||||||
`actions/setup-node with yarn, or disable caching with 'package-manager-cache: false'. ` +
|
|
||||||
`See: https://github.com/actions/setup-node/issues/1027 for more information.`);
|
|
||||||
}
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`);
|
core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`);
|
||||||
const stdOut = yarnVersion.startsWith('1.')
|
const stdOut = yarnVersion.startsWith('1.')
|
||||||
? await (0, exports.getCommandOutput)('yarn cache dir', projectDir)
|
? await (0, exports.getCommandOutput)('yarn cache dir', projectDir)
|
||||||
@@ -81311,24 +81294,6 @@ exports.supportedPackageManagers = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* Tries to enable corepack for Node.js versions that support it (16.9+)
|
|
||||||
* This helps with yarn v2+ which requires corepack
|
|
||||||
* See: https://github.com/actions/setup-node/issues/1027
|
|
||||||
*/
|
|
||||||
const enableCorepackIfSupported = async () => {
|
|
||||||
try {
|
|
||||||
await exec.exec('corepack', ['enable'], {
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true
|
|
||||||
});
|
|
||||||
core.debug('Corepack enabled successfully');
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
// Corepack not available or failed silently
|
|
||||||
core.debug('Corepack not available on this system');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const getCommandOutput = async (toolCommand, cwd) => {
|
const getCommandOutput = async (toolCommand, cwd) => {
|
||||||
let { stdout, stderr, exitCode } = await exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true, ...(cwd && { cwd }) });
|
let { stdout, stderr, exitCode } = await exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true, ...(cwd && { cwd }) });
|
||||||
if (exitCode) {
|
if (exitCode) {
|
||||||
|
|||||||
@@ -40,32 +40,11 @@ export const supportedPackageManagers: SupportedPackageManagers = {
|
|||||||
name: 'yarn',
|
name: 'yarn',
|
||||||
lockFilePatterns: ['yarn.lock'],
|
lockFilePatterns: ['yarn.lock'],
|
||||||
getCacheFolderPath: async projectDir => {
|
getCacheFolderPath: async projectDir => {
|
||||||
// Try to enable corepack first if available
|
const yarnVersion = await getCommandOutputNotEmpty(
|
||||||
// This helps with yarn v2+ which requires corepack
|
`yarn --version`,
|
||||||
await enableCorepackIfSupported();
|
'Could not retrieve version of yarn',
|
||||||
|
projectDir
|
||||||
let yarnVersion: string;
|
);
|
||||||
try {
|
|
||||||
yarnVersion = await getCommandOutputNotEmpty(
|
|
||||||
`yarn --version`,
|
|
||||||
'Could not retrieve version of yarn',
|
|
||||||
projectDir
|
|
||||||
);
|
|
||||||
} catch (err) {
|
|
||||||
// Check if this is a corepack error message
|
|
||||||
const errorMsg = (err as Error).message;
|
|
||||||
if (
|
|
||||||
errorMsg.includes('packageManager') &&
|
|
||||||
errorMsg.includes('Corepack')
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Yarn v4+ requires corepack to be enabled. Please run 'corepack enable' before using ` +
|
|
||||||
`actions/setup-node with yarn, or disable caching with 'package-manager-cache: false'. ` +
|
|
||||||
`See: https://github.com/actions/setup-node/issues/1027 for more information.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(
|
core.debug(
|
||||||
`Consumed yarn version is ${yarnVersion} (working dir: "${
|
`Consumed yarn version is ${yarnVersion} (working dir: "${
|
||||||
@@ -87,24 +66,6 @@ export const supportedPackageManagers: SupportedPackageManagers = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Tries to enable corepack for Node.js versions that support it (16.9+)
|
|
||||||
* This helps with yarn v2+ which requires corepack
|
|
||||||
* See: https://github.com/actions/setup-node/issues/1027
|
|
||||||
*/
|
|
||||||
const enableCorepackIfSupported = async (): Promise<void> => {
|
|
||||||
try {
|
|
||||||
await exec.exec('corepack', ['enable'], {
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true
|
|
||||||
});
|
|
||||||
core.debug('Corepack enabled successfully');
|
|
||||||
} catch {
|
|
||||||
// Corepack not available or failed silently
|
|
||||||
core.debug('Corepack not available on this system');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getCommandOutput = async (
|
export const getCommandOutput = async (
|
||||||
toolCommand: string,
|
toolCommand: string,
|
||||||
cwd?: string
|
cwd?: string
|
||||||
|
|||||||
Reference in New Issue
Block a user