mirror of
https://github.com/ChromeDevTools/chrome-devtools-mcp.git
synced 2026-09-14 19:45:30 +08:00
fix: avoid showing update notification for local builds (#1889)
Previously, we would show the notification if the local version string was *different* from the latest version string published to npm. With this patch, we actually check if the npm-published version is newer and avoid showing the notification otherwise. Closes #1886
This commit is contained in:
Generated
+9
@@ -23,6 +23,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",
|
||||
@@ -40,6 +41,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",
|
||||
@@ -2194,6 +2196,13 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/semver": {
|
||||
"version": "7.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.1.tgz",
|
||||
"integrity": "sha512-FmgJfu+MOcQ370SD0ev7EI8TlCAfKYU+B4m5T3yXc1CiRN94g/SZPtsCkk506aUDtlMnFZvasDwHHUcZUEaYuA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/shimmer": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/shimmer/-/shimmer-1.2.0.tgz",
|
||||
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
|
||||
Vendored
+1
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
/**
|
||||
@@ -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`,
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user