From 6b91de7a742c6158fb915c0c68323f9e125dea44 Mon Sep 17 00:00:00 2001 From: maxjeffos <44034094+maxjeffos@users.noreply.github.com> Date: Tue, 10 Aug 2021 14:56:16 -0400 Subject: [PATCH] chore: remove update notifier --- package.json | 2 -- src/cli/index.ts | 2 -- src/lib/updater.ts | 30 -------------------------- test/updater.test.ts | 49 ------------------------------------------ tsconfig.settings.json | 2 +- 5 files changed, 1 insertion(+), 84 deletions(-) delete mode 100644 src/lib/updater.ts delete mode 100644 test/updater.test.ts diff --git a/package.json b/package.json index cab5c066aa..de79a4bc33 100644 --- a/package.json +++ b/package.json @@ -140,7 +140,6 @@ "strip-ansi": "^5.2.0", "tar": "^6.1.2", "tempy": "^1.0.1", - "update-notifier": "^5.1.0", "uuid": "^8.3.2", "wrap-ansi": "^5.1.0", "yaml": "^1.10.2" @@ -155,7 +154,6 @@ "@types/restify": "^8.4.2", "@types/sarif": "^2.1.2", "@types/sinon": "^7.5.0", - "@types/update-notifier": "^4.1.0", "@typescript-eslint/eslint-plugin": "2.18.0", "@typescript-eslint/parser": "^2.0.0", "ajv": "^6.12.6", diff --git a/src/cli/index.ts b/src/cli/index.ts index 51409c0cc5..e1dfe9bf06 100755 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -22,7 +22,6 @@ import spinner = require('../lib/spinner'); import errors = require('../lib/errors/legacy-errors'); import ansiEscapes = require('ansi-escapes'); import { isPathToPackageFile } from '../lib/detect'; -import { updateCheck } from '../lib/updater'; import { MissingTargetFileError, FileFlagBadInputError, @@ -236,7 +235,6 @@ function checkPaths(args) { type AllSupportedCliOptions = Options & MonitorOptions & TestOptions; async function main() { - updateCheck(); checkRuntime(); let res; diff --git a/src/lib/updater.ts b/src/lib/updater.ts deleted file mode 100644 index a94df65dc5..0000000000 --- a/src/lib/updater.ts +++ /dev/null @@ -1,30 +0,0 @@ -import * as updateNotifier from 'update-notifier'; -import * as fs from 'fs'; -import * as p from 'path'; -import { isStandaloneBuild } from './version'; - -export function updateCheck() { - const pkgPath = p.join(__dirname, '../..', 'package.json'); - const isPkgFilePresent = fs.existsSync(pkgPath); - - if (!isPkgFilePresent) { - return false; - } - - if (isStandaloneBuild()) { - return false; - } - - const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); - - // if there's no version (f.e. during tests) - do not proceed - if (!pkg.version) { - return false; - } - - // Checks for available update and returns an instance - // Default updateCheckInterval is once a day - const notifier = updateNotifier({ pkg }); - notifier.notify(); - return true; -} diff --git a/test/updater.test.ts b/test/updater.test.ts deleted file mode 100644 index 6d778fec10..0000000000 --- a/test/updater.test.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { test } from 'tap'; -import * as fs from 'fs'; -import { updateCheck } from '../src/lib/updater'; -import * as path from 'path'; -import * as sinon from 'sinon'; -import * as updateNotifier from 'update-notifier'; - -// Fake location of the package.json file and verify the code behaves well -test('missing package.json', (t) => { - const fsStub = sinon.stub(fs, 'existsSync'); - fsStub.withArgs(path.join(__dirname, '../', 'package.json')).returns(false); - - t.tearDown(() => { - fsStub.restore(); - }); - - t.equal( - updateCheck(), - false, - 'Notifier was not started on missing package.json', - ); - t.end(); -}); - -test('STANDALONE declaration present', (t) => { - const fsStub = sinon.stub(fs, 'existsSync'); - fsStub.withArgs(path.join(__dirname, '../', 'package.json')).returns(true); - fsStub.withArgs(path.join(__dirname, '../src', 'STANDALONE')).returns(true); - - t.tearDown(() => { - fsStub.restore(); - }); - - t.equal(updateCheck(), false, 'Notifier was not started for binary build'); - t.end(); -}); - -// Run updateNotifier API for the basic package. The target is to verify API still stands -test('verify updater', async (t) => { - const pkg = { - name: 'snyk', - version: '1.0.0', - }; - const notifier = updateNotifier({ pkg }); - const info = await notifier.fetchInfo(); - - t.equal(info.name, 'snyk', 'Successful call to notifier'); - t.end(); -}); diff --git a/tsconfig.settings.json b/tsconfig.settings.json index 2a6f6c2a3e..4db6aa2681 100644 --- a/tsconfig.settings.json +++ b/tsconfig.settings.json @@ -5,7 +5,7 @@ "pretty": true, "moduleResolution": "node", "target": "es2018", - "lib": ["ES2018", "dom"], + "lib": ["ES2018", "ES2019", "dom"], "module": "commonjs", "allowJs": true, "sourceMap": true,