From 24fef6efe783f71e1c8b7ff5fd5e39509a3238f5 Mon Sep 17 00:00:00 2001 From: jlenon7 Date: Mon, 30 Dec 2024 21:35:42 -0300 Subject: [PATCH 1/2] feat(http): start vite server --- package-lock.json | 12 ++++++------ package.json | 4 ++-- src/applications/Http.ts | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0edc71b..ae258c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/core", - "version": "5.6.0", + "version": "5.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@athenna/core", - "version": "5.6.0", + "version": "5.7.0", "license": "MIT", "dependencies": { "pretty-repl": "^3.1.2", @@ -17,7 +17,7 @@ "@athenna/common": "^5.3.0", "@athenna/config": "^5.1.0", "@athenna/cron": "^5.4.0", - "@athenna/http": "^5.6.0", + "@athenna/http": "^5.7.0", "@athenna/ioc": "^5.0.0", "@athenna/logger": "^5.1.0", "@athenna/test": "^5.2.0", @@ -130,9 +130,9 @@ } }, "node_modules/@athenna/http": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/@athenna/http/-/http-5.6.0.tgz", - "integrity": "sha512-F3P8roHFL19hBO2rPtHJz2QgzW+deqnAsz0e4OwgZMtwDUTakwvVAn/s7F2+MEd2qzGVsVIyDn01AmfcilG9yA==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@athenna/http/-/http-5.7.0.tgz", + "integrity": "sha512-QYlcgOj2tjDS64SImxFcsJ7gqlUZ6rcOm1UgwQ0bXWS7QKq26aome1tYw+EzYWLdPukGgQzgnrJvc3V89WCkRQ==", "dev": true, "engines": { "node": ">=20.0.0" diff --git a/package.json b/package.json index 50c594f..0e81fd2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/core", - "version": "5.6.0", + "version": "5.7.0", "description": "One foundation for multiple applications.", "license": "MIT", "author": "João Lenon ", @@ -85,7 +85,7 @@ "@athenna/common": "^5.3.0", "@athenna/config": "^5.1.0", "@athenna/cron": "^5.4.0", - "@athenna/http": "^5.6.0", + "@athenna/http": "^5.7.0", "@athenna/ioc": "^5.0.0", "@athenna/logger": "^5.1.0", "@athenna/test": "^5.2.0", diff --git a/src/applications/Http.ts b/src/applications/Http.ts index ccba957..0b8a94e 100644 --- a/src/applications/Http.ts +++ b/src/applications/Http.ts @@ -34,6 +34,10 @@ export class Http { ioc.safeUse('Athenna/Core/HttpRoute').register() + if (process.argv.includes('--vite')) { + await server.viteReady() + } + await server.listen({ host: options.host, port: options.port }) if (Config.notExists('rc.bootLogs') || Config.is('rc.bootLogs', false)) { @@ -79,6 +83,7 @@ export class Http { await kernel.registerHelmet() await kernel.registerStatic() await kernel.registerSwagger() + await kernel.registerVite() await kernel.registerRateLimit() await kernel.registerRTracer(options.trace) await kernel.registerLoggerTerminator() From 65a520e2f346457b143de8c903edc03667ea547a Mon Sep 17 00:00:00 2001 From: jlenon7 Date: Tue, 31 Dec 2024 11:45:11 -0300 Subject: [PATCH 2/2] chore(npm): update dependencies --- package-lock.json | 219 +++++++++--------- package.json | 4 +- src/commands/BuildCommand.ts | 35 +-- src/commands/ServeCommand.ts | 87 +------ tests/fixtures/consoles/build-vite.ts | 4 - .../fixtures/consoles/serve-vite-with-logs.ts | 25 -- tests/fixtures/consoles/serve-vite.ts | 25 -- 7 files changed, 110 insertions(+), 289 deletions(-) diff --git a/package-lock.json b/package-lock.json index ae258c9..aa3648e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,10 +14,10 @@ }, "devDependencies": { "@athenna/artisan": "^5.3.0", - "@athenna/common": "^5.3.0", + "@athenna/common": "^5.5.0", "@athenna/config": "^5.1.0", "@athenna/cron": "^5.4.0", - "@athenna/http": "^5.7.0", + "@athenna/http": "^5.10.0", "@athenna/ioc": "^5.0.0", "@athenna/logger": "^5.1.0", "@athenna/test": "^5.2.0", @@ -66,12 +66,12 @@ } }, "node_modules/@athenna/common": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/@athenna/common/-/common-5.3.0.tgz", - "integrity": "sha512-g53yElUzyBs7iEKkCxsyYNjn72hXHz8D80TzvSrHFMba5pWxotOgqaTRwKIGsB80bhOhvBBYgiZ1DXW+RDYwfw==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/@athenna/common/-/common-5.5.0.tgz", + "integrity": "sha512-SdWaCsfJGXXMDnzpBokED6QVZfvyob21ITAIa3VDw4itDeHqpiSVjBmB5J6CquAo+FXfuTvkzcMzeecnoG6Rhg==", "dev": true, "dependencies": { - "@fastify/formbody": "^7.4.0", + "@fastify/formbody": "^8.0.1", "bytes": "^3.1.2", "callsite": "^1.0.0", "chalk": "^5.4.1", @@ -79,7 +79,7 @@ "collect.js": "^4.36.1", "csv-parser": "^3.1.0", "execa": "^8.0.1", - "fastify": "^4.29.0", + "fastify": "^5.2.0", "got": "^12.6.1", "http-status-codes": "^2.3.0", "is-wsl": "^2.2.0", @@ -130,9 +130,9 @@ } }, "node_modules/@athenna/http": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@athenna/http/-/http-5.7.0.tgz", - "integrity": "sha512-QYlcgOj2tjDS64SImxFcsJ7gqlUZ6rcOm1UgwQ0bXWS7QKq26aome1tYw+EzYWLdPukGgQzgnrJvc3V89WCkRQ==", + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/@athenna/http/-/http-5.10.0.tgz", + "integrity": "sha512-DqHsyk1GZEnX9lERVS6ax+uIQvfs1C4UvH1ubua/1CzJG0nxSQ01/eG5K/uFxM3rLywDLJ2H9UQBmUK6WPCUvQ==", "dev": true, "engines": { "node": ">=20.0.0" @@ -906,45 +906,39 @@ } }, "node_modules/@fastify/ajv-compiler": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@fastify/ajv-compiler/-/ajv-compiler-3.6.0.tgz", - "integrity": "sha512-LwdXQJjmMD+GwLOkP7TVC68qa+pSSogeWWmznRJ/coyTcfe9qA05AHFSe1eZFwK6q+xVRpChnvFUkf1iYaSZsQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@fastify/ajv-compiler/-/ajv-compiler-4.0.1.tgz", + "integrity": "sha512-DxrBdgsjNLP0YM6W5Hd6/Fmj43S8zMKiFJYgi+Ri3htTGAowPVG/tG1wpnWLMjufEnehRivUCKZ1pLDIoZdTuw==", "dev": true, "dependencies": { - "ajv": "^8.11.0", - "ajv-formats": "^2.1.1", - "fast-uri": "^2.0.0" + "ajv": "^8.12.0", + "ajv-formats": "^3.0.1", + "fast-uri": "^3.0.0" } }, - "node_modules/@fastify/ajv-compiler/node_modules/fast-uri": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-2.4.0.tgz", - "integrity": "sha512-ypuAmmMKInk5q7XcepxlnUWDLWv4GFtaJqAzWKqn62IpQ3pejtr5dTVbt3vwqVaMKmkNR55sTT+CqUKIaT21BA==", - "dev": true - }, "node_modules/@fastify/error": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/@fastify/error/-/error-3.4.1.tgz", - "integrity": "sha512-wWSvph+29GR783IhmvdwWnN4bUxTD01Vm5Xad4i7i1VuAOItLvbPAb69sb0IQ2N57yprvhNIwAP5B6xfKTmjmQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@fastify/error/-/error-4.0.0.tgz", + "integrity": "sha512-OO/SA8As24JtT1usTUTKgGH7uLvhfwZPwlptRi2Dp5P4KKmJI3gvsZ8MIHnNwDs4sLf/aai5LzTyl66xr7qMxA==", "dev": true }, "node_modules/@fastify/fast-json-stringify-compiler": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@fastify/fast-json-stringify-compiler/-/fast-json-stringify-compiler-4.3.0.tgz", - "integrity": "sha512-aZAXGYo6m22Fk1zZzEUKBvut/CIIQe/BapEORnxiD5Qr0kPHqqI69NtEMCme74h+at72sPhbkb4ZrLd1W3KRLA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@fastify/fast-json-stringify-compiler/-/fast-json-stringify-compiler-5.0.1.tgz", + "integrity": "sha512-f2d3JExJgFE3UbdFcpPwqNUEoHWmt8pAKf8f+9YuLESdefA0WgqxeT6DrGL4Yrf/9ihXNSKOqpjEmurV405meA==", "dev": true, "dependencies": { - "fast-json-stringify": "^5.7.0" + "fast-json-stringify": "^6.0.0" } }, "node_modules/@fastify/formbody": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@fastify/formbody/-/formbody-7.4.0.tgz", - "integrity": "sha512-H3C6h1GN56/SMrZS8N2vCT2cZr7mIHzBHzOBa5OPpjfB/D6FzP9mMpE02ZzrFX0ANeh0BAJdoXKOF2e7IbV+Og==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@fastify/formbody/-/formbody-8.0.1.tgz", + "integrity": "sha512-LPrcadSIK8TrQk510Zdj56fnw7cyHq0/PW0YHGGM8ycGL4X7XAex+FKcwpzB4i5lF9eykc71a4EtcO9AEoByqw==", "dev": true, "dependencies": { - "fast-querystring": "^1.0.0", - "fastify-plugin": "^4.0.0" + "fast-querystring": "^1.1.2", + "fastify-plugin": "^5.0.0" } }, "node_modules/@fastify/merge-json-schemas": { @@ -2321,9 +2315,9 @@ } }, "node_modules/ajv-formats": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", - "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", "dev": true, "dependencies": { "ajv": "^8.0.0" @@ -2610,12 +2604,12 @@ } }, "node_modules/avvio": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/avvio/-/avvio-8.4.0.tgz", - "integrity": "sha512-CDSwaxINFy59iNwhYnkvALBwZiTydGkOecZyPkqBpABYR1KqGEsET0VOOYDwtleZSUIdeY36DC2bSZ24CO1igA==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/avvio/-/avvio-9.1.0.tgz", + "integrity": "sha512-fYASnYi600CsH/j9EQov7lECAniYiBFiiAtBNuZYLA2leLe9qOvZzqYHFjtIj6gD2VMoMLP14834LFWvr4IfDw==", "dev": true, "dependencies": { - "@fastify/error": "^3.3.0", + "@fastify/error": "^4.0.0", "fastq": "^1.17.1" } }, @@ -5493,12 +5487,6 @@ "node": ">=4" } }, - "node_modules/fast-content-type-parse": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-1.1.0.tgz", - "integrity": "sha512-fBHHqSTFLVnR61C+gltJuE5GkVQMV0S2nqUO8TJ+5Z3qAKG8vAx4FKai1s5jq/inV1+sREynIWSuQ6HgoSXpDQ==", - "dev": true - }, "node_modules/fast-decode-uri-component": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/fast-decode-uri-component/-/fast-decode-uri-component-1.0.1.tgz", @@ -5552,37 +5540,20 @@ "dev": true }, "node_modules/fast-json-stringify": { - "version": "5.16.1", - "resolved": "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-5.16.1.tgz", - "integrity": "sha512-KAdnLvy1yu/XrRtP+LJnxbBGrhN+xXu+gt3EUvZhYGKCr3lFHq/7UFJHHFgmJKoqlh6B40bZLEv7w46B0mqn1g==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stringify/-/fast-json-stringify-6.0.0.tgz", + "integrity": "sha512-FGMKZwniMTgZh7zQp9b6XnBVxUmKVahQLQeRQHqwYmPDqDhcEKZ3BaQsxelFFI5PY7nN71OEeiL47/zUWcYe1A==", "dev": true, "dependencies": { - "@fastify/merge-json-schemas": "^0.1.0", - "ajv": "^8.10.0", + "@fastify/merge-json-schemas": "^0.1.1", + "ajv": "^8.12.0", "ajv-formats": "^3.0.1", "fast-deep-equal": "^3.1.3", - "fast-uri": "^2.1.0", + "fast-uri": "^2.3.0", "json-schema-ref-resolver": "^1.0.1", "rfdc": "^1.2.0" } }, - "node_modules/fast-json-stringify/node_modules/ajv-formats": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", - "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", - "dev": true, - "dependencies": { - "ajv": "^8.0.0" - }, - "peerDependencies": { - "ajv": "^8.0.0" - }, - "peerDependenciesMeta": { - "ajv": { - "optional": true - } - } - }, "node_modules/fast-json-stringify/node_modules/fast-uri": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-2.4.0.tgz", @@ -5620,9 +5591,9 @@ "dev": true }, "node_modules/fastify": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/fastify/-/fastify-4.29.0.tgz", - "integrity": "sha512-MaaUHUGcCgC8fXQDsDtioaCcag1fmPJ9j64vAKunqZF4aSub040ZGi/ag8NGE2714yREPOKZuHCfpPzuUD3UQQ==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/fastify/-/fastify-5.2.0.tgz", + "integrity": "sha512-3s+Qt5S14Eq5dCpnE0FxTp3z4xKChI83ZnMv+k0FwX+VUoZrgCFoLAxpfdi/vT4y6Mk+g7aAMt9pgXDoZmkefQ==", "dev": true, "funding": [ { @@ -5635,28 +5606,33 @@ } ], "dependencies": { - "@fastify/ajv-compiler": "^3.5.0", - "@fastify/error": "^3.4.0", - "@fastify/fast-json-stringify-compiler": "^4.3.0", + "@fastify/ajv-compiler": "^4.0.0", + "@fastify/error": "^4.0.0", + "@fastify/fast-json-stringify-compiler": "^5.0.0", "abstract-logging": "^2.0.1", - "avvio": "^8.3.0", - "fast-content-type-parse": "^1.1.0", - "fast-json-stringify": "^5.8.0", - "find-my-way": "^8.0.0", - "light-my-request": "^5.11.0", + "avvio": "^9.0.0", + "fast-json-stringify": "^6.0.0", + "find-my-way": "^9.0.0", + "light-my-request": "^6.0.0", "pino": "^9.0.0", - "process-warning": "^3.0.0", + "process-warning": "^4.0.0", "proxy-addr": "^2.0.7", - "rfdc": "^1.3.0", - "secure-json-parse": "^2.7.0", - "semver": "^7.5.4", - "toad-cache": "^3.3.0" + "rfdc": "^1.3.1", + "secure-json-parse": "^3.0.1", + "semver": "^7.6.0", + "toad-cache": "^3.7.0" } }, "node_modules/fastify-plugin": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-4.5.1.tgz", - "integrity": "sha512-stRHYGeuqpEZTL1Ef0Ovr2ltazUT9g844X5z/zEBFLG8RYlpDiOCIG+ATvYEp+/zmc7sN29mcIMp8gvYplYPIQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-5.0.1.tgz", + "integrity": "sha512-HCxs+YnRaWzCl+cWRYFnHmeRFyR5GVnJTAaCJQiYzQSDwK9MgJdyAsuL3nh0EWRCYMgQ5MeziymvmAhUHYHDUQ==", + "dev": true + }, + "node_modules/fastify/node_modules/secure-json-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-3.0.1.tgz", + "integrity": "sha512-9QR7G96th4QJ2+dJwvZB+JoXyt8PN+DbEjOr6kL2/JU4KH8Eb2sFdU+gt8EDdzWDWoWH0uocDdfCoFzdVSixUA==", "dev": true }, "node_modules/fastq": { @@ -5757,14 +5733,14 @@ } }, "node_modules/find-my-way": { - "version": "8.2.2", - "resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-8.2.2.tgz", - "integrity": "sha512-Dobi7gcTEq8yszimcfp/R7+owiT4WncAJ7VTTgFH1jYJ5GaG1FbhjwDG820hptN0QDFvzVY3RfCzdInvGPGzjA==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-9.1.0.tgz", + "integrity": "sha512-Y5jIsuYR4BwWDYYQ2A/RWWE6gD8a0FMgtU+HOq1WKku+Cwdz8M1v8wcAmRXXM1/iqtoqg06v+LjAxMYbCjViMw==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-querystring": "^1.0.0", - "safe-regex2": "^3.1.0" + "safe-regex2": "^4.0.0" }, "engines": { "node": ">=14" @@ -8106,14 +8082,23 @@ } }, "node_modules/light-my-request": { - "version": "5.14.0", - "resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-5.14.0.tgz", - "integrity": "sha512-aORPWntbpH5esaYpGOOmri0OHDOe3wC5M2MQxZ9dvMLZm6DnaAn0kJlcbU9hwsQgLzmZyReKwFwwPkR+nHu5kA==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-6.4.0.tgz", + "integrity": "sha512-U0UONITz4GVQodMPoygnqJan2RYfhyLsCzFBakJHWNfiQKyHzvp38YOxxLGs8lIDPwR6ngd4gmuZJQQJtRBu/A==", "dev": true, "dependencies": { - "cookie": "^0.7.0", - "process-warning": "^3.0.0", - "set-cookie-parser": "^2.4.1" + "cookie": "^1.0.1", + "process-warning": "^4.0.0", + "set-cookie-parser": "^2.6.0" + } + }, + "node_modules/light-my-request/node_modules/cookie": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz", + "integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==", + "dev": true, + "engines": { + "node": ">=18" } }, "node_modules/lilconfig": { @@ -9775,12 +9760,6 @@ "integrity": "sha512-e906FRY0+tV27iq4juKzSYPbUj2do2X2JX4EzSca1631EB2QJQUqGbDuERal7LCtOpxl6x3+nvo9NPZcmjkiFA==", "dev": true }, - "node_modules/pino/node_modules/process-warning": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-4.0.0.tgz", - "integrity": "sha512-/MyYDxttz7DfGMMHiysAsFE4qF+pQYAA8ziO/3NcRVrQ5fSk+Mns4QZA/oRPFzvcqNoVJXQNWNAsdwBXLUkQKw==", - "dev": true - }, "node_modules/pkg-dir": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-7.0.0.tgz", @@ -10071,9 +10050,9 @@ "dev": true }, "node_modules/process-warning": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-3.0.0.tgz", - "integrity": "sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-4.0.0.tgz", + "integrity": "sha512-/MyYDxttz7DfGMMHiysAsFE4qF+pQYAA8ziO/3NcRVrQ5fSk+Mns4QZA/oRPFzvcqNoVJXQNWNAsdwBXLUkQKw==", "dev": true }, "node_modules/property-information": { @@ -10412,9 +10391,9 @@ "dev": true }, "node_modules/ret": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.4.3.tgz", - "integrity": "sha512-0f4Memo5QP7WQyUEAYUO3esD/XjOc3Zjjg5CPsAq1p8sIu0XPeMbHJemKA0BO7tV0X7+A0FoEpbmHXWxPyD3wQ==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.5.0.tgz", + "integrity": "sha512-I1XxrZSQ+oErkRR4jYbAyEEu2I0avBvvMM5JN+6EBprOGRCs63ENqZ3vjavq8fBw2+62G5LF5XelKwuJpcvcxw==", "dev": true, "engines": { "node": ">=10" @@ -10658,12 +10637,22 @@ } }, "node_modules/safe-regex2": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/safe-regex2/-/safe-regex2-3.1.0.tgz", - "integrity": "sha512-RAAZAGbap2kBfbVhvmnTFv73NWLMvDGOITFYTZBAaY8eR+Ir4ef7Up/e7amo+y1+AH+3PtLkrt9mvcTsG9LXug==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/safe-regex2/-/safe-regex2-4.0.1.tgz", + "integrity": "sha512-goqsB+bSlOmVX+CiFX2PFc1OV88j5jvBqIM+DgqrucHnUguAUNtiNOs+aTadq2NqsLQ+TQ3UEVG3gtSFcdlkCg==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], "dependencies": { - "ret": "~0.4.0" + "ret": "~0.5.0" } }, "node_modules/safe-stable-stringify": { diff --git a/package.json b/package.json index 0e81fd2..65daf30 100644 --- a/package.json +++ b/package.json @@ -82,10 +82,10 @@ }, "devDependencies": { "@athenna/artisan": "^5.3.0", - "@athenna/common": "^5.3.0", + "@athenna/common": "^5.5.0", "@athenna/config": "^5.1.0", "@athenna/cron": "^5.4.0", - "@athenna/http": "^5.7.0", + "@athenna/http": "^5.10.0", "@athenna/ioc": "^5.0.0", "@athenna/logger": "^5.1.0", "@athenna/test": "^5.2.0", diff --git a/src/commands/BuildCommand.ts b/src/commands/BuildCommand.ts index 98ca188..51ff0f4 100644 --- a/src/commands/BuildCommand.ts +++ b/src/commands/BuildCommand.ts @@ -110,46 +110,15 @@ export class BuildCommand extends BaseCommand { } public async getViteConfig(vite: any) { - const defaultConfig = { - root: Path.pwd(), - assetsUrl: '/assets', - buildDirectory: 'public/assets', - logLevel: 'silent', - css: { - preprocessorOptions: { - scss: { - api: 'modern' - } - } - }, - build: { - assetsDir: '', - manifest: true, - emptyOutDir: true, - outDir: 'public/assets', - assetsInlineLimit: 0, - rollupOptions: { - output: { - entryFileNames: '[name].js', - chunkFileNames: '[name].js', - assetFileNames: '[name].[ext]' - } - } - } - } - - const { config: fileConfig } = await vite.loadConfigFromFile( + const { config } = await vite.loadConfigFromFile( { command: 'build', - mode: 'development' + mode: 'production' }, undefined, Path.pwd() ) - const config = vite.mergeConfig(defaultConfig, fileConfig) - await vite.build(config) - return config } } diff --git a/src/commands/ServeCommand.ts b/src/commands/ServeCommand.ts index 7114db3..c3e4359 100644 --- a/src/commands/ServeCommand.ts +++ b/src/commands/ServeCommand.ts @@ -22,7 +22,8 @@ export class ServeCommand extends BaseCommand { @Option({ signature: '-v, --vite', - description: 'Use vite to build your application static files.', + description: + 'Turn on vite dev server for HMR and static files compilation.', default: false }) public vite: boolean @@ -41,24 +42,6 @@ export class ServeCommand extends BaseCommand { Path.bin(`main.${Path.ext()}`) ) - if (this.vite) { - const formerNodeEnv = Env('NODE_ENV') - - const vite = await this.getVite() - const config = await this.getViteConfig(vite) - - await vite.build(config) - - Log.channelOrVanilla('application').success( - 'Static files successfully compiled with ({yellow} vite)' - ) - - /** - * Vite changes NODE_ENV when building which we need to avoid. - */ - process.env.NODE_ENV = formerNodeEnv - } - if (this.watch) { const nodemon = this.getNodemon() @@ -98,24 +81,6 @@ export class ServeCommand extends BaseCommand { console.clear() - if (this.vite) { - const formerNodeEnv = Env('NODE_ENV') - - const vite = await this.getVite() - const config = await this.getViteConfig(vite) - - await vite.build(config) - - Log.channelOrVanilla('application').success( - 'Static files successfully recompiled with ({yellow} vite)' - ) - - /** - * Vite changes NODE_ENV when building which we need to avoid. - */ - process.env.NODE_ENV = formerNodeEnv - } - Log.channelOrVanilla('application').success( 'Application successfully restarted' ) @@ -135,52 +100,4 @@ export class ServeCommand extends BaseCommand { return require('nodemon') } - - public async getVite() { - return import('vite') - } - - public async getViteConfig(vite: any) { - const defaultConfig = { - root: Path.pwd(), - assetsUrl: '/assets', - buildDirectory: 'public/assets', - logLevel: 'silent', - css: { - preprocessorOptions: { - scss: { - api: 'modern' - } - } - }, - build: { - assetsDir: '', - manifest: true, - emptyOutDir: true, - outDir: 'public/assets', - assetsInlineLimit: 0, - rollupOptions: { - output: { - entryFileNames: '[name].js', - chunkFileNames: '[name].js', - assetFileNames: '[name].[ext]' - } - } - } - } - - const { config: fileConfig } = await vite.loadConfigFromFile( - { - command: 'build', - mode: 'development' - }, - undefined, - Path.pwd() - ) - - const config = vite.mergeConfig(defaultConfig, fileConfig) - await vite.build(config) - - return config - } } diff --git a/tests/fixtures/consoles/build-vite.ts b/tests/fixtures/consoles/build-vite.ts index 39c808b..87edb51 100644 --- a/tests/fixtures/consoles/build-vite.ts +++ b/tests/fixtures/consoles/build-vite.ts @@ -35,10 +35,6 @@ vite.loadConfigFromFile = function () { return { config: {} } } -vite.mergeConfig = function () { - return {} -} - vite.build = function () { return this } diff --git a/tests/fixtures/consoles/serve-vite-with-logs.ts b/tests/fixtures/consoles/serve-vite-with-logs.ts index 346737c..674b2c9 100644 --- a/tests/fixtures/consoles/serve-vite-with-logs.ts +++ b/tests/fixtures/consoles/serve-vite-with-logs.ts @@ -7,12 +7,10 @@ * file that was distributed with this source code. */ -import { Mock } from '@athenna/test' import { Path } from '@athenna/common' import { ViewProvider } from '@athenna/view' import { Rc, Config } from '@athenna/config' import { LoggerProvider } from '@athenna/logger' -import { ServeCommand } from '#src/commands/ServeCommand' import { Artisan, ConsoleKernel, ArtisanProvider } from '@athenna/artisan' new ViewProvider().register() @@ -27,29 +25,6 @@ Path.mergeDirs(Config.get('rc.directories', {})) await new ConsoleKernel().registerCommands() -const vite = function () { - return Mock.fake() -} - -vite.loadConfigFromFile = function () { - return { config: {} } -} - -vite.mergeConfig = function () { - return {} -} - -vite.build = function () { - return this -} - -const vitePluginRestart = function () { - return Mock.fake() -} - Config.set('rc.bootLogs', true) -Mock.when(ServeCommand.prototype, 'getVite').return(vite) -Mock.when(ServeCommand.prototype, 'getVitePluginRestart').return(vitePluginRestart) - await Artisan.parse(process.argv) diff --git a/tests/fixtures/consoles/serve-vite.ts b/tests/fixtures/consoles/serve-vite.ts index d4c3609..3964b6c 100644 --- a/tests/fixtures/consoles/serve-vite.ts +++ b/tests/fixtures/consoles/serve-vite.ts @@ -7,12 +7,10 @@ * file that was distributed with this source code. */ -import { Mock } from '@athenna/test' import { Path } from '@athenna/common' import { ViewProvider } from '@athenna/view' import { Rc, Config } from '@athenna/config' import { LoggerProvider } from '@athenna/logger' -import { ServeCommand } from '#src/commands/ServeCommand' import { Artisan, ConsoleKernel, ArtisanProvider } from '@athenna/artisan' new ViewProvider().register() @@ -27,27 +25,4 @@ Path.mergeDirs(Config.get('rc.directories', {})) await new ConsoleKernel().registerCommands() -const vite = function () { - return Mock.fake() -} - -vite.loadConfigFromFile = function () { - return { config: {} } -} - -vite.mergeConfig = function () { - return {} -} - -vite.build = function () { - return this -} - -const vitePluginRestart = function () { - return Mock.fake() -} - -Mock.when(ServeCommand.prototype, 'getVite').return(vite) -Mock.when(ServeCommand.prototype, 'getVitePluginRestart').return(vitePluginRestart) - await Artisan.parse(process.argv)