Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ This is a GitHub Action with main and post execution phases (defined in `action.

### Lock File Detection

Auto-detects package manager from lock files: `pnpm-lock.yaml`, `package-lock.json`, `yarn.lock`, `bun.lockb`
Auto-detects package manager from lock files: `pnpm-lock.yaml`, `package-lock.json`, `yarn.lock`

## Testing

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GitHub Action to set up [Vite+](https://github.com/voidzero-dev/vite-plus) (`@vo
- Support both npm Registry and GitHub Package Registry
- Cache project dependencies with auto-detection of lock files
- Optionally run `vite install` after setup
- Support for all major package managers (npm, pnpm, yarn, bun)
- Support for all major package managers (npm, pnpm, yarn)

## Requirements

Expand Down Expand Up @@ -113,7 +113,6 @@ When `cache: true` is set, the action automatically detects your lock file and c
| `pnpm-lock.yaml` | pnpm | pnpm store |
| `package-lock.json` | npm | npm cache |
| `yarn.lock` | yarn | yarn cache |
| `bun.lockb` | bun | bun cache |

The cache key format is: `vite-plus-{OS}-{arch}-{pm}-{lockfile-hash}`

Expand Down
122 changes: 61 additions & 61 deletions dist/index.mjs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export enum LockFileType {
Npm = "npm",
Pnpm = "pnpm",
Yarn = "yarn",
Bun = "bun",
}

export interface LockFileInfo {
Expand Down
28 changes: 1 addition & 27 deletions src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@ describe("detectLockFile", () => {
});
});

it("should return lock file info for bun.lockb", () => {
vi.mocked(existsSync).mockReturnValue(true);

const result = detectLockFile("bun.lockb");

expect(result).toEqual({
type: LockFileType.Bun,
path: join(mockWorkspace, "bun.lockb"),
filename: "bun.lockb",
});
});

it("should return undefined if explicit file does not exist", () => {
vi.mocked(existsSync).mockReturnValue(false);

Expand Down Expand Up @@ -144,7 +132,7 @@ describe("detectLockFile", () => {
});

it("should detect yarn.lock when higher priority files are absent", () => {
vi.mocked(readdirSync).mockReturnValue(["yarn.lock", "bun.lockb"] as unknown as ReturnType<
vi.mocked(readdirSync).mockReturnValue(["yarn.lock"] as unknown as ReturnType<
typeof readdirSync
>);

Expand All @@ -157,20 +145,6 @@ describe("detectLockFile", () => {
});
});

it("should detect bun.lockb when no other lock files present", () => {
vi.mocked(readdirSync).mockReturnValue(["bun.lockb"] as unknown as ReturnType<
typeof readdirSync
>);

const result = detectLockFile();

expect(result).toEqual({
type: LockFileType.Bun,
path: join(mockWorkspace, "bun.lockb"),
filename: "bun.lockb",
});
});

it("should return undefined when no lock files found", () => {
vi.mocked(readdirSync).mockReturnValue([
"package.json",
Expand Down
17 changes: 0 additions & 17 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { info, warning, debug } from "@actions/core";
import { getExecOutput } from "@actions/exec";
import { existsSync, readdirSync } from "node:fs";
import { isAbsolute, join, basename } from "node:path";
import { homedir } from "node:os";
import { LockFileType } from "./types.js";
import type { LockFileInfo } from "./types.js";

Expand All @@ -12,7 +11,6 @@ const LOCK_FILES: Array<{ filename: string; type: LockFileType }> = [
{ filename: "package-lock.json", type: LockFileType.Npm },
{ filename: "npm-shrinkwrap.json", type: LockFileType.Npm },
{ filename: "yarn.lock", type: LockFileType.Yarn },
{ filename: "bun.lockb", type: LockFileType.Bun },
];

/**
Expand Down Expand Up @@ -67,9 +65,6 @@ function inferLockFileType(fullPath: string, filename: string): LockFileInfo {
if (filename.includes("yarn")) {
return { type: LockFileType.Yarn, path: fullPath, filename };
}
if (filename.includes("bun")) {
return { type: LockFileType.Bun, path: fullPath, filename };
}
// Default to npm
return { type: LockFileType.Npm, path: fullPath, filename };
}
Expand All @@ -83,8 +78,6 @@ export async function getCacheDirectories(lockType: LockFileType): Promise<strin
case LockFileType.Pnpm:
case LockFileType.Yarn:
return getViteCacheDir();
case LockFileType.Bun:
return getBunCacheDir();
default:
return [];
}
Expand Down Expand Up @@ -112,13 +105,3 @@ async function getViteCacheDir(): Promise<string[]> {
const cacheDir = await getCommandOutput("vite", ["pm", "cache", "dir"]);
return cacheDir ? [cacheDir] : [];
}

async function getBunCacheDir(): Promise<string[]> {
const cacheDir = await getCommandOutput("bun", ["pm", "cache"]);
if (cacheDir) return [cacheDir];

// Fallback to default location
const home = homedir();
const defaultCache = join(home, ".bun", "install", "cache");
return existsSync(defaultCache) ? [defaultCache] : [];
}