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

@ -52,7 +52,7 @@ See [action.yml](action.yml)
# Default: ${{ github.server_url == 'https://github.com' && github.token || '' }} # Default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
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 # Package manager should be pre-installed
# Default: '' # Default: ''
cache: '' cache: ''
@ -120,7 +120,7 @@ It's **always** recommended to commit the lockfile of your package manager for s
## Caching global packages data ## 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. 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], ['npm', utils.supportedPackageManagers.npm],
['pnpm', utils.supportedPackageManagers.pnpm], ['pnpm', utils.supportedPackageManagers.pnpm],
['yarn', utils.supportedPackageManagers.yarn], ['yarn', utils.supportedPackageManagers.yarn],
['bun', utils.supportedPackageManagers.bun],
['yarn1', null], ['yarn1', null],
['yarn2', null], ['yarn2', null],
['npm7', null] ['npm7', null]

View File

@ -22,9 +22,9 @@ 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. 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 || '' }} default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
cache: 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: 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. # 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 # escape valve for someone having issues or needing the absolute latest which isn't cached yet
outputs: outputs:

View File

@ -83594,6 +83594,11 @@ exports.supportedPackageManagers = {
} }
return stdOut; 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* () { 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') { else if (packageManager === 'yarn') {
return exports.supportedPackageManagers.yarn; return exports.supportedPackageManagers.yarn;
} }
else if (packageManager === 'bun') {
return exports.supportedPackageManagers.bun;
}
else { else {
return null; return null;
} }
@ -83792,6 +83800,7 @@ var LockType;
LockType["Npm"] = "npm"; LockType["Npm"] = "npm";
LockType["Pnpm"] = "pnpm"; LockType["Pnpm"] = "pnpm";
LockType["Yarn"] = "yarn"; LockType["Yarn"] = "yarn";
LockType["Bun"] = "bun";
})(LockType || (exports.LockType = LockType = {})); })(LockType || (exports.LockType = LockType = {}));
var State; var State;
(function (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; npm: PackageManagerInfo;
pnpm: PackageManagerInfo; pnpm: PackageManagerInfo;
yarn: PackageManagerInfo; yarn: PackageManagerInfo;
bun: PackageManagerInfo;
} }
export const supportedPackageManagers: SupportedPackageManagers = { export const supportedPackageManagers: SupportedPackageManagers = {
npm: { npm: {
@ -63,6 +64,15 @@ export const supportedPackageManagers: SupportedPackageManagers = {
} }
return stdOut; 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; return supportedPackageManagers.pnpm;
} else if (packageManager === 'yarn') { } else if (packageManager === 'yarn') {
return supportedPackageManagers.yarn; return supportedPackageManagers.yarn;
} else if (packageManager === 'bun') {
return supportedPackageManagers.bun;
} else { } else {
return null; return null;
} }

View File

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