@@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
- Exposed `PI_SESSION_ID`, `PI_SESSION_FILE`, `PI_PROVIDER`, `PI_MODEL`, and `PI_REASONING_LEVEL` to commands run by built-in and factory-created bash tools.
|
- Exposed `PI_SESSION_ID`, `PI_SESSION_FILE`, `PI_PROVIDER`, `PI_MODEL`, and `PI_REASONING_LEVEL` to commands run by built-in and factory-created bash tools.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed explicit self-updates when `PI_SKIP_VERSION_CHECK` is set ([#6977](https://github.com/earendil-works/pi/issues/6977)).
|
||||||
|
|
||||||
## [0.81.1] - 2026-07-21
|
## [0.81.1] - 2026-07-21
|
||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export async function getLatestPiRelease(
|
|||||||
currentVersion: string,
|
currentVersion: string,
|
||||||
options: { timeoutMs?: number } = {},
|
options: { timeoutMs?: number } = {},
|
||||||
): Promise<LatestPiRelease | undefined> {
|
): Promise<LatestPiRelease | undefined> {
|
||||||
if (process.env.PI_SKIP_VERSION_CHECK || process.env.PI_OFFLINE) return undefined;
|
if (process.env.PI_OFFLINE) return undefined;
|
||||||
|
|
||||||
const response = await fetch(LATEST_VERSION_URL, {
|
const response = await fetch(LATEST_VERSION_URL, {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -68,6 +68,8 @@ export async function getLatestPiVersion(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function checkForNewPiVersion(currentVersion: string): Promise<LatestPiRelease | undefined> {
|
export async function checkForNewPiVersion(currentVersion: string): Promise<LatestPiRelease | undefined> {
|
||||||
|
if (process.env.PI_SKIP_VERSION_CHECK) return undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const latestRelease = await getLatestPiRelease(currentVersion);
|
const latestRelease = await getLatestPiRelease(currentVersion);
|
||||||
if (latestRelease && isNewerPackageVersion(latestRelease.version, currentVersion)) {
|
if (latestRelease && isNewerPackageVersion(latestRelease.version, currentVersion)) {
|
||||||
|
|||||||
@@ -470,6 +470,32 @@ describe("package commands", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("allows explicit self-update checks when automatic version checks are disabled", async () => {
|
||||||
|
const previousSkipVersionCheck = process.env.PI_SKIP_VERSION_CHECK;
|
||||||
|
process.env.PI_SKIP_VERSION_CHECK = "1";
|
||||||
|
const fetchMock = vi.fn(async () => Response.json({ version: VERSION }));
|
||||||
|
vi.stubGlobal("fetch", fetchMock);
|
||||||
|
const logSpy = vi.spyOn(console, "log").mockImplementation(() => {});
|
||||||
|
const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await expect(runPackageCommandDirectly(["update", "--self"])).resolves.toBeUndefined();
|
||||||
|
|
||||||
|
expect(fetchMock).toHaveBeenCalledOnce();
|
||||||
|
expect(logSpy.mock.calls.map(([message]) => String(message)).join("\n")).toContain(
|
||||||
|
`pi is already up to date (v${VERSION})`,
|
||||||
|
);
|
||||||
|
expect(errorSpy).not.toHaveBeenCalled();
|
||||||
|
expect(process.exitCode).toBeUndefined();
|
||||||
|
} finally {
|
||||||
|
if (previousSkipVersionCheck === undefined) {
|
||||||
|
delete process.env.PI_SKIP_VERSION_CHECK;
|
||||||
|
} else {
|
||||||
|
process.env.PI_SKIP_VERSION_CHECK = previousSkipVersionCheck;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it("uses the update check version for forced self updates even when current", async () => {
|
it("uses the update check version for forced self updates even when current", async () => {
|
||||||
const globalPrefix = join(tempDir, "global-prefix");
|
const globalPrefix = join(tempDir, "global-prefix");
|
||||||
const projectPrefix = join(tempDir, "project-prefix");
|
const projectPrefix = join(tempDir, "project-prefix");
|
||||||
|
|||||||
@@ -80,12 +80,21 @@ describe("version checks", () => {
|
|||||||
await expect(getLatestPiRelease("1.2.3")).resolves.toEqual({ note: "**Read this**", version: "1.2.4" });
|
await expect(getLatestPiRelease("1.2.3")).resolves.toEqual({ note: "**Read this**", version: "1.2.4" });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("skips api calls when version checks are disabled", async () => {
|
it("skips automatic api calls when version checks are disabled", async () => {
|
||||||
process.env.PI_SKIP_VERSION_CHECK = "1";
|
process.env.PI_SKIP_VERSION_CHECK = "1";
|
||||||
const fetchMock = vi.fn();
|
const fetchMock = vi.fn();
|
||||||
vi.stubGlobal("fetch", fetchMock);
|
vi.stubGlobal("fetch", fetchMock);
|
||||||
|
|
||||||
await expect(getLatestPiVersion("1.2.3")).resolves.toBeUndefined();
|
await expect(checkForNewPiVersion("1.2.3")).resolves.toBeUndefined();
|
||||||
expect(fetchMock).not.toHaveBeenCalled();
|
expect(fetchMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("allows direct api calls when automatic version checks are disabled", async () => {
|
||||||
|
process.env.PI_SKIP_VERSION_CHECK = "1";
|
||||||
|
const fetchMock = vi.fn(async () => Response.json({ version: "1.2.4" }));
|
||||||
|
vi.stubGlobal("fetch", fetchMock);
|
||||||
|
|
||||||
|
await expect(getLatestPiVersion("1.2.3")).resolves.toBe("1.2.4");
|
||||||
|
expect(fetchMock).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user