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
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@types/debug": "^4.1.12",
"@types/filesystem": "^0.0.36",
"@types/node": "^25.0.0",
"@types/semver": "^7.7.1",
"@types/sinon": "^21.0.0",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^8.43.0",
Expand All @@ -73,6 +74,7 @@
"rollup": "4.60.1",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-license": "^3.6.0",
"semver": "^7.7.4",
"sinon": "^21.0.0",
"tiktoken": "^1.0.22",
"typescript": "^6.0.2",
Expand Down
1 change: 1 addition & 0 deletions src/third_party/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type {Flags, Result, RunnerResult, OutputMode};
export type {Options as YargsOptions} from 'yargs';
export {default as yargs} from 'yargs';
export {hideBin} from 'yargs/helpers';
export {default as semver} from 'semver';
export {default as debug} from 'debug';
export type {Debugger} from 'debug';
export {McpServer} from '@modelcontextprotocol/sdk/server/mcp.js';
Expand Down
3 changes: 2 additions & 1 deletion src/utils/check-for-updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import os from 'node:os';
import path from 'node:path';
import process from 'node:process';

import {semver} from '../third_party/index.js';
import {VERSION} from '../version.js';

/**
Expand Down Expand Up @@ -46,7 +47,7 @@ export async function checkForUpdates(message: string) {
// Ignore errors reading cache.
}

if (cachedVersion && cachedVersion !== VERSION) {
if (cachedVersion && semver.lt(VERSION, cachedVersion)) {
console.warn(
`\nUpdate available: ${VERSION} -> ${cachedVersion}\n${message}\n`,
);
Expand Down
20 changes: 20 additions & 0 deletions tests/check-for-updates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ describe('checkForUpdates', () => {
assert.ok(spawnStub.notCalled);
});

it('does not notify if incoming version is older than current version', async () => {
sinon.stub(os, 'homedir').returns('/home/user');
sinon.stub(fs, 'stat').resolves({mtimeMs: Date.now()} as unknown as Stats);
sinon.stub(fs, 'readFile').callsFake(async filePath => {
if (filePath.toString().includes('latest.json')) {
return JSON.stringify({
version: '0.0.1',
});
}
throw new Error(`File not found: ${filePath}`);
});
const warnStub = sinon.stub(console, 'warn');
const spawnStub = sinon.stub(child_process, 'spawn');

await checkForUpdates('Run `npm update` to update.');

assert.ok(warnStub.notCalled);
assert.ok(spawnStub.notCalled);
});

it('does not spawn fetch process if cache is fresh', async () => {
sinon.stub(os, 'homedir').returns('/home/user');
sinon.stub(fs, 'stat').resolves({mtimeMs: Date.now()} as unknown as Stats);
Expand Down
48 changes: 24 additions & 24 deletions tests/third_party_notices.test.js.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,30 @@ Permission to use, copy, modify, and/or distribute this software for any purpose
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


-------------------- DEPENDENCY DIVIDER --------------------

Name: semver
URL: git+https://github.com/npm/node-semver.git
Version: <VERSION>
License: ISC

The ISC License

Copyright (c) Isaac Z. Schlueter and Contributors

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


-------------------- DEPENDENCY DIVIDER --------------------

Name: debug
Expand Down Expand Up @@ -829,30 +853,6 @@ URL: https://github.com/puppeteer/puppeteer/tree/main/packages/browsers
Version: <VERSION>
License: Apache-2.0

-------------------- DEPENDENCY DIVIDER --------------------

Name: semver
URL: git+https://github.com/npm/node-semver.git
Version: <VERSION>
License: ISC

The ISC License

Copyright (c) Isaac Z. Schlueter and Contributors

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


-------------------- DEPENDENCY DIVIDER --------------------

Name: proxy-agent
Expand Down
Loading