From 30994a3a282ffc9a61bb0a38b837fe4d0d3c6895 Mon Sep 17 00:00:00 2001 From: "me@rodrigorodriguez.com" Date: Tue, 24 Sep 2024 14:30:01 -0300 Subject: [PATCH] new(all): Node.js v22 and ts-node. --- .vscode/launch.json | 16 ++++++++-------- boot.mjs | 16 ++-------------- package.json | 5 +++-- packages/nodemon.json | 5 +++++ src/app.ts | 2 +- src/util.ts | 2 +- tsconfig.json | 3 ++- 7 files changed, 22 insertions(+), 27 deletions(-) create mode 100644 packages/nodemon.json diff --git a/.vscode/launch.json b/.vscode/launch.json index 817a5373..f31cdc49 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,25 +5,25 @@ "type": "node", "request": "launch", "sourceMaps": true, - "name": "Debug Program", - "runtimeExecutable": "node", + "name": "Debug Program with Nodemon", + "runtimeExecutable": "npx", + "runtimeArgs": ["nodemon", "--exec", "tsx"], // Use nodemon with tsx "program": "${workspaceRoot}/boot.mjs", "cwd": "${workspaceRoot}", "env": { "NODE_ENV": "development", - "NODE_NO_WARNINGS":"1" + "NODE_NO_WARNINGS": "1" }, "args": [ - "--no-deprecation", - "--loader ts-node/esm", - "--require ${workspaceRoot}/suppress-node-warnings.cjs", + "--require", "${workspaceRoot}/suppress-node-warnings.cjs" ], "skipFiles": [ "node_modules/**/*.js", "/**" - ], + ], "outFiles": [ - "${workspaceRoot}/dist/**/*.js"], + "${workspaceRoot}/dist/**/*.js" + ], "stopOnEntry": false, "console": "integratedTerminal" } diff --git a/boot.mjs b/boot.mjs index 455b1ef4..28064780 100644 --- a/boot.mjs +++ b/boot.mjs @@ -6,8 +6,8 @@ import fs from 'fs/promises'; import os from 'node:os'; import path from 'path'; import { exec } from 'child_process'; -import pjson from './package.json' assert { type: 'json' }; -import {GBUtil} from './dist/src/util.js' +import pjson from './package.json'; +import {GBUtil} from './src/util.js' // Displays version of Node JS being used at runtime and others attributes. @@ -22,19 +22,7 @@ try { }); }; var processDist = async () => { - if (!await GBUtil.exists('dist')) { - console.log(`\n`); - console.log(`General Bots: Compiling...`); - exec(path.join(__dirname, 'node_modules/.bin/tsc'), async (err, stdout, stderr) => { - if (err) { - console.error(err); - return; - } await run(); - }); - } else { - await run(); - } }; // Installing modules if it has not been done yet. diff --git a/package.json b/package.json index dd362143..dcb02347 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "botserver", "version": "5.0.0", - "type": "module", "description": "General Bot Community Edition open-core server.", "main": "./boot.mjs", "bugs": "https://github.com/pragmatismo-io/BotServer/issues", @@ -15,7 +14,7 @@ "Alan Perdomo " ], "engines": { - "node": "=20.17.0" + "node": "=22.9.0" }, "license": "AGPL-3.0", "preferGlobal": true, @@ -171,6 +170,7 @@ "node-html-parser": "6.1.13", "node-nlp": "4.27.0", "node-tesseract-ocr": "2.2.1", + "nodemon": "^3.1.7", "npm": "10.8.3", "open": "10.1.0", "open-docxtemplater-image-module": "1.0.3", @@ -249,6 +249,7 @@ "super-strong-password-generator-es": "2.0.2", "travis-deploy-once": "5.0.11", "tslint": "6.1.3", + "tsx": "^4.19.1", "vitest": "2.0.5" }, "eslintConfig": { diff --git a/packages/nodemon.json b/packages/nodemon.json new file mode 100644 index 00000000..a3140c48 --- /dev/null +++ b/packages/nodemon.json @@ -0,0 +1,5 @@ +{ + "watch": ["src", "packages"], + "ext": "ts", + "exec": "tsx" +} \ No newline at end of file diff --git a/src/app.ts b/src/app.ts index bab0e63b..5f80e339 100644 --- a/src/app.ts +++ b/src/app.ts @@ -380,7 +380,7 @@ function shutdown() { GBLogEx.info(0, 'General Bots API server closed.'); process.exit(0); }); - + }); } diff --git a/src/util.ts b/src/util.ts index 783fbd95..64a95942 100644 --- a/src/util.ts +++ b/src/util.ts @@ -31,7 +31,7 @@ /** * @fileoverview General Bots local utility. */ - + 'use strict'; import * as YAML from 'yaml'; import SwaggerClient from 'swagger-client'; diff --git a/tsconfig.json b/tsconfig.json index aef46202..e9fd7dc6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { - "strict": false, + "rootDir": "./", + "strict": true, "allowJs": true, "downlevelIteration": true, "baseUrl": "./",