feat: support cache type bun

Signed-off-by: Jan van den Berg <koozz@linux.com>
This commit is contained in:
Jan van den Berg 2024-05-07 09:55:22 +02:00
parent c2ac33f2c6
commit 79cae9176d
No known key found for this signature in database
7 changed files with 842 additions and 810 deletions

View file

@ -26,22 +26,22 @@ See [action.yml](action.yml)
node-version: ''
# File containing the version Spec of the version to use. Examples: package.json, .nvmrc, .node-version, .tool-versions.
# If node-version and node-version-file are both provided the action will use version from node-version.
# If node-version and node-version-file are both provided the action will use version from node-version.
node-version-file: ''
# Set this option if you want the action to check for the latest available version
# Set this option if you want the action to check for the latest available version
# that satisfies the version spec.
# It will only get affect for lts Nodejs versions (12.x, >=10.15.0, lts/Hydrogen).
# It will only get affect for lts Nodejs versions (12.x, >=10.15.0, lts/Hydrogen).
# Default: false
check-latest: false
# Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.
# Default: ''. The action use system architecture by default
# Default: ''. The action use system architecture by default
architecture: ''
# Used to pull node distributions from https://github.com/actions/node-versions.
# Since there's a default, this is typically not supplied by the user.
# When running this action on github.com, the default value is sufficient.
# Used to pull node distributions from https://github.com/actions/node-versions.
# Since there's a default, this is typically not supplied by the user.
# When running this action on github.com, the default value is sufficient.
# When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
#
# We recommend using a service account with the least permissions necessary. Also
@ -52,23 +52,23 @@ See [action.yml](action.yml)
# Default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
token: ''
# Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.
# Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm, bun.
# Package manager should be pre-installed
# Default: ''
cache: ''
# Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc.
# It will generate hash from the target file for primary key. It works only If cache is specified.
# Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc.
# It will generate hash from the target file for primary key. It works only If cache is specified.
# Supports wildcards or a list of file names for caching multiple dependencies.
# Default: ''
cache-dependency-path: ''
# Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file,
# Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file,
# and set up auth to read in from env.NODE_AUTH_TOKEN.
# Default: ''
registry-url: ''
# Optional scope for authenticating against scoped registries.
# Optional scope for authenticating against scoped registries.
# Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).
# Default: ''
scope: ''
@ -120,7 +120,7 @@ It's **always** recommended to commit the lockfile of your package manager for s
## Caching global packages data
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching global packages data but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+). The `cache` input is optional, and caching is turned off by default.
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching global packages data but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+), `bun`. The `cache` input is optional, and caching is turned off by default.
The action defaults to search for the dependency file (`package-lock.json`, `npm-shrinkwrap.json` or `yarn.lock`) in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases when multiple dependency files are used, or they are located in different subdirectories.

View file

@ -60,6 +60,7 @@ describe('cache-utils', () => {
['npm', utils.supportedPackageManagers.npm],
['pnpm', utils.supportedPackageManagers.pnpm],
['yarn', utils.supportedPackageManagers.yarn],
['bun', utils.supportedPackageManagers.bun],
['yarn1', null],
['yarn2', null],
['npm7', null]

View file

@ -22,13 +22,13 @@ inputs:
description: Used to pull node distributions from node-versions. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
cache:
description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.'
description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm, bun.'
cache-dependency-path:
description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.'
description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, bun.lockb, etc. Supports wildcards or a list of file names for caching multiple dependencies.'
# TODO: add input to control forcing to pull from cloud or dist.
# escape valve for someone having issues or needing the absolute latest which isn't cached yet
outputs:
cache-hit:
cache-hit:
description: 'A boolean value to indicate if a cache was hit.'
node-version:
description: 'The installed node version.'

View file

@ -83594,6 +83594,11 @@ exports.supportedPackageManagers = {
}
return stdOut;
})
},
bun: {
name: 'bun',
lockFilePatterns: ['bun.lockb'],
getCacheFolderPath: () => (0, exports.getCommandOutputNotEmpty)('bun pm cache', 'Could not get bun cache folder path')
}
};
const getCommandOutput = (toolCommand, cwd) => __awaiter(void 0, void 0, void 0, function* () {
@ -83625,6 +83630,9 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
else if (packageManager === 'yarn') {
return exports.supportedPackageManagers.yarn;
}
else if (packageManager === 'bun') {
return exports.supportedPackageManagers.bun;
}
else {
return null;
}
@ -83792,6 +83800,7 @@ var LockType;
LockType["Npm"] = "npm";
LockType["Pnpm"] = "pnpm";
LockType["Yarn"] = "yarn";
LockType["Bun"] = "bun";
})(LockType || (exports.LockType = LockType = {}));
var State;
(function (State) {

1595
dist/setup/index.js vendored

File diff suppressed because it is too large Load diff

View file

@ -16,6 +16,7 @@ interface SupportedPackageManagers {
npm: PackageManagerInfo;
pnpm: PackageManagerInfo;
yarn: PackageManagerInfo;
bun: PackageManagerInfo;
}
export const supportedPackageManagers: SupportedPackageManagers = {
npm: {
@ -63,6 +64,15 @@ export const supportedPackageManagers: SupportedPackageManagers = {
}
return stdOut;
}
},
bun: {
name: 'bun',
lockFilePatterns: ['bun.lockb'],
getCacheFolderPath: () =>
getCommandOutputNotEmpty(
'bun pm cache',
'Could not get bun cache folder path'
)
}
};
@ -105,6 +115,8 @@ export const getPackageManagerInfo = async (packageManager: string) => {
return supportedPackageManagers.pnpm;
} else if (packageManager === 'yarn') {
return supportedPackageManagers.yarn;
} else if (packageManager === 'bun') {
return supportedPackageManagers.bun;
} else {
return null;
}

View file

@ -1,7 +1,8 @@
export enum LockType {
Npm = 'npm',
Pnpm = 'pnpm',
Yarn = 'yarn'
Yarn = 'yarn',
Bun = 'bun'
}
export enum State {