Skip to content

Commit 5addf97

Browse files
committed
fix: temporarily disable vp CLI caching due to Windows issue (#10)
Disable restoreVpCache and saveVpCache at the code level until a new vite-plus release fixes the 'Cannot find module which' error on Windows. Tests are skipped with describe.skip and FIXME comments.
1 parent 5e9f372 commit 5addf97

File tree

4 files changed

+43
-94
lines changed

4 files changed

+43
-94
lines changed

dist/index.mjs

Lines changed: 28 additions & 28 deletions
Large diffs are not rendered by default.

src/cache-vp.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ describe("resolveVersion", () => {
8383
});
8484
});
8585

86-
describe("restoreVpCache", () => {
86+
// FIXME: Re-enable these tests after vp CLI caching is re-enabled.
87+
// Caching is temporarily disabled due to Windows `Cannot find module 'which'` issue (#10).
88+
describe.skip("restoreVpCache", () => {
8789
beforeEach(() => {
8890
vi.stubEnv("RUNNER_OS", "Linux");
8991
vi.stubEnv("HOME", "/home/runner");
@@ -145,7 +147,9 @@ describe("restoreVpCache", () => {
145147
});
146148
});
147149

148-
describe("saveVpCache", () => {
150+
// FIXME: Re-enable these tests after vp CLI caching is re-enabled.
151+
// Caching is temporarily disabled due to Windows `Cannot find module 'which'` issue (#10).
152+
describe.skip("saveVpCache", () => {
149153
beforeEach(() => {
150154
vi.stubEnv("HOME", "/home/runner");
151155
});

src/cache-vp.ts

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import { restoreCache, saveCache } from "@actions/cache";
2-
import { info, debug, saveState, getState, warning } from "@actions/core";
3-
import { arch, platform } from "node:os";
4-
import { State } from "./types.js";
5-
import { getVitePlusHome } from "./utils.js";
1+
import { info, warning } from "@actions/core";
62

73
const SEMVER_RE = /^\d+\.\d+\.\d+/;
84

@@ -31,60 +27,15 @@ export async function resolveVersion(versionInput: string): Promise<string | und
3127
}
3228
}
3329

34-
export async function restoreVpCache(version: string, nodeVersion: string): Promise<boolean> {
35-
const vpHome = getVitePlusHome();
36-
const runnerOS = process.env.RUNNER_OS || platform();
37-
const runnerArch = arch();
38-
const primaryKey = `setup-vp-${runnerOS}-${runnerArch}-${version}-node${nodeVersion}`;
39-
40-
debug(`Vp cache key: ${primaryKey}`);
41-
debug(`Vp cache path: ${vpHome}`);
42-
saveState(State.VpCachePrimaryKey, primaryKey);
43-
44-
try {
45-
const matchedKey = await restoreCache([vpHome], primaryKey);
46-
if (matchedKey) {
47-
info(`Vite+ restored from cache (key: ${matchedKey})`);
48-
saveState(State.VpCacheMatchedKey, matchedKey);
49-
return true;
50-
}
51-
} catch (error) {
52-
warning(`Failed to restore vp cache: ${error}`);
53-
}
54-
30+
// FIXME: Re-enable vp CLI caching after the new version of vite-plus is released
31+
// that fixes the Windows `Cannot find module 'which'` issue (#10).
32+
export async function restoreVpCache(_version: string, _nodeVersion: string): Promise<boolean> {
33+
info("Vp CLI caching is temporarily disabled");
5534
return false;
5635
}
5736

37+
// FIXME: Re-enable vp CLI caching after the new version of vite-plus is released
38+
// that fixes the Windows `Cannot find module 'which'` issue (#10).
5839
export async function saveVpCache(): Promise<void> {
59-
const forceInstall =
60-
process.env.SETUP_VP_FORCE_INSTALL === "true" || process.env.SETUP_VP_FORCE_INSTALL === "1";
61-
if (forceInstall) {
62-
info("SETUP_VP_FORCE_INSTALL is set, skipping vp cache save");
63-
return;
64-
}
65-
66-
const primaryKey = getState(State.VpCachePrimaryKey);
67-
const matchedKey = getState(State.VpCacheMatchedKey);
68-
69-
if (!primaryKey) {
70-
debug("No vp cache key found. Skipping save.");
71-
return;
72-
}
73-
74-
if (primaryKey === matchedKey) {
75-
info(`Vp cache hit on primary key "${primaryKey}". Skipping save.`);
76-
return;
77-
}
78-
79-
try {
80-
const vpHome = getVitePlusHome();
81-
const cacheId = await saveCache([vpHome], primaryKey);
82-
if (cacheId === -1) {
83-
warning("Vp cache save failed or was skipped.");
84-
return;
85-
}
86-
info(`Vp cache saved with key: ${primaryKey}`);
87-
} catch (error) {
88-
warning(`Failed to save vp cache: ${String(error)}`);
89-
}
40+
info("Vp CLI caching is temporarily disabled, skipping save");
9041
}

src/install-viteplus.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ const INSTALL_URL_PS1 = "https://staging.viteplus.dev/install.ps1";
1111

1212
export async function installVitePlus(inputs: Inputs, nodeVersion: string): Promise<void> {
1313
const { version } = inputs;
14-
const forceInstall =
15-
process.env.SETUP_VP_FORCE_INSTALL === "true" || process.env.SETUP_VP_FORCE_INSTALL === "1";
1614

1715
// Try to resolve version and restore from cache
1816
const resolvedVersion = await resolveVersion(version);
19-
if (resolvedVersion && !forceInstall) {
17+
if (resolvedVersion) {
2018
const cacheHit = await restoreVpCache(resolvedVersion, nodeVersion);
2119
if (cacheHit) {
2220
ensureVitePlusBinInPath();
@@ -25,10 +23,6 @@ export async function installVitePlus(inputs: Inputs, nodeVersion: string): Prom
2523
}
2624
}
2725

28-
if (forceInstall) {
29-
info("SETUP_VP_FORCE_INSTALL is set, skipping cache and forcing fresh install");
30-
}
31-
3226
// Cache miss or resolution failed — install fresh
3327
const installVersion = resolvedVersion || version;
3428
info(`Installing ${DISPLAY_NAME}@${installVersion}...`);

0 commit comments

Comments
 (0)