From d55aca87aa7c015fedf61b33f22479bd38154b32 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 27 May 2024 13:58:31 +0700 Subject: [PATCH] chore: add update notifier --- cortex-js/package.json | 7 +++++-- cortex-js/src/command.ts | 10 ++++++++++ cortex-js/tsconfig.json | 5 +++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cortex-js/package.json b/cortex-js/package.json index fb2e53b2d..6515ebe62 100644 --- a/cortex-js/package.json +++ b/cortex-js/package.json @@ -53,7 +53,9 @@ "sqlite3": "^5.1.7", "typeorm": "^0.3.20", "ulid": "^2.3.0", - "uuid": "^9.0.1" + "yaml": "^2.4.2", + "uuid": "^9.0.1", + "update-notifier": "^5.0.0" }, "devDependencies": { "cpx": "^1.5.0", @@ -67,7 +69,8 @@ "@types/jest": "^29.5.2", "@types/js-yaml": "^4.0.9", "@types/node": "^20.12.9", - "@types/supertest": "^6.0.0", + "@types/supertest": "^6.0.2", + "@types/update-notifier": "^5.0.8", "@types/uuid": "^9.0.8", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", diff --git a/cortex-js/src/command.ts b/cortex-js/src/command.ts index c71a1f934..f4f42f186 100644 --- a/cortex-js/src/command.ts +++ b/cortex-js/src/command.ts @@ -1,9 +1,19 @@ #!/usr/bin/env node --no-warnings import { CommandFactory } from 'nest-commander'; import { CommandModule } from './command.module'; +import updateNotifier from 'update-notifier'; +import packageJson from './../package.json'; async function bootstrap() { await CommandFactory.run(CommandModule, ['warn', 'error']); + const notifier = updateNotifier({ + pkg: packageJson, + updateCheckInterval: 1000 * 60 * 60, // 1 hour + shouldNotifyInNpmScript: true, + }); + notifier.notify({ + isGlobal: true, + }); } bootstrap(); diff --git a/cortex-js/tsconfig.json b/cortex-js/tsconfig.json index f52125fca..0035c663f 100644 --- a/cortex-js/tsconfig.json +++ b/cortex-js/tsconfig.json @@ -1,13 +1,13 @@ { "compilerOptions": { "module": "commonjs", - "moduleResolution": "Node", + "moduleResolution": "node", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, - "target": "ES2021", + "target": "es2018", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", @@ -19,6 +19,7 @@ "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "esModuleInterop": true, + "resolveJsonModule": true, "paths": { "@/*": ["src/*"] }