diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index d25902d..7eb2722 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -21,14 +21,8 @@ jobs: - name: Install dependencies run: npm install - - name: Transpile code - run: npm run build - - - name: Install jq - run: sudo apt-get -y install jq - - - name: Change import aliases to build - run: jq '.imports."#src"="./build/index.js" | .imports."#src/*"="./build/*.js"' package.json > tmp.json && mv tmp.json package.json + - name: Compile code + run: sh scripts/build - name: Automatic GitHub Release uses: justincy/github-action-npm-release@2.0.1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e8a3fe..c3c4814 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,8 +42,8 @@ jobs: - name: Run tests run: npm run test:coverage - - name: Test code transpilation - run: npm run build + - name: Test code compilation + run: sh scripts/build windows: runs-on: windows-latest @@ -65,5 +65,5 @@ jobs: - name: Run tests run: npm run test:coverage - - name: Test code transpilation - run: npm run build + - name: Test code compilation + run: sh scripts/build diff --git a/.gitignore b/.gitignore index 3a22348..4b6c558 100644 --- a/.gitignore +++ b/.gitignore @@ -114,9 +114,15 @@ out .yarn/install-state.gz .pnp.* -# Transpiled code path -dist -build +# Compiled code +./dist +./build +*.js +*.d.ts +*.js.map +!tests/Stubs/**/*.js +!tests/Stubs/**/*.d.ts +!tests/Stubs/**/*.js.map # IDE .idea @@ -127,7 +133,6 @@ build .env .env.testing .env.production -!tests/Stubs/.env # MacOS folder mapper file .DS_Store diff --git a/bin/build.ts b/bin/build.ts deleted file mode 100644 index 3292a2c..0000000 --- a/bin/build.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @athenna/core - * - * (c) João Lenon - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/* eslint-disable no-ex-assign */ - -import { Path, File, Exec, Folder, Is } from '@athenna/common' - -/* -|-------------------------------------------------------------------------- -| The tsconfig.build.json path and the compile command. -|-------------------------------------------------------------------------- -| -| The path where tsconfig.build.json will be created and the compilation -| command that will be used to compile the files. -*/ - -const path = Path.nodeModules('@athenna/tsconfig.build.json') -const compileCommand = `node_modules/.bin/tsc --project ${path}` - -/* -|-------------------------------------------------------------------------- -| Before all hook. -|-------------------------------------------------------------------------- -| -| This function will be executed before the compilation starts. Briefly, -| this function will create a tsconfig.build.json file with the correct -| configurations to compile the files such as rootDir, outDir, etc and -| also delete the old build folder if it exists. -*/ - -async function beforeAll() { - const tsconfig = await new File('../tsconfig.json').getContentAsBuilder() - - tsconfig.delete('ts-node') - tsconfig.set('include', ['../../src']) - tsconfig.set('compilerOptions.rootDir', '../../src') - tsconfig.set('compilerOptions.outDir', '../../build') - tsconfig.set('exclude', ['../../bin', '../../node_modules', '../../tests']) - - const oldBuild = new Folder(Path.pwd('/build')) - await new File(path, JSON.stringify(tsconfig.get())).load() - - if (oldBuild.folderExists) await oldBuild.remove() -} - -/* -|-------------------------------------------------------------------------- -| After all hook. -|-------------------------------------------------------------------------- -| -| This function will be executed after some error occurs or after the compi -| lation finishes. This function just delete the tsconfig.build.json file if -| it exists. -*/ - -async function afterAll() { - const tsConfigBuild = await new File(path).load() - - if (tsConfigBuild.fileExists) await tsConfigBuild.remove() -} - -try { - await beforeAll() - - const { stdout } = await Exec.command(compileCommand) - - if (stdout) console.log(stdout) -} catch (error) { - if (!Is.Exception(error)) error = error.toAthennaException() - - console.error(await error.prettify()) -} finally { - await afterAll() -} diff --git a/node b/node index 948240a..137c3e9 100755 --- a/node +++ b/node @@ -1,5 +1,21 @@ #!/bin/bash +# This file is useful for development purposes because +# it allows you to run TypeScript files without having +# to add the --loader option every time. + +# Usage: + +# ./node --version +# ./node bin/test.ts +# ./node --inspect bin/test.ts + +# Usage with "sh" or "bash": + +# sh node --version +# sh node bin/test.ts +# sh node --inspect bin/test.ts + # Node.js executable with all arguments required to run the application. node="node --loader ts-node/esm --experimental-import-meta-resolve --no-warnings" diff --git a/package-lock.json b/package-lock.json index 4ad671d..1dcc7fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,26 +1,26 @@ { "name": "@athenna/core", - "version": "3.1.5", + "version": "3.1.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@athenna/core", - "version": "3.1.5", + "version": "3.1.6", "license": "MIT", "dependencies": { "pretty-repl": "^3.1.1", "semver": "^7.3.8" }, "devDependencies": { - "@athenna/artisan": "^3.3.4", - "@athenna/common": "^3.4.3", - "@athenna/config": "^3.2.1", - "@athenna/http": "^3.4.2", - "@athenna/ioc": "^3.1.6", - "@athenna/logger": "^3.1.6", - "@athenna/test": "^3.2.2", - "@athenna/view": "^3.0.5", + "@athenna/artisan": "^3.3.6", + "@athenna/common": "^3.4.4", + "@athenna/config": "^3.2.3", + "@athenna/http": "^3.4.3", + "@athenna/ioc": "^3.1.8", + "@athenna/logger": "^3.1.7", + "@athenna/test": "^3.2.3", + "@athenna/view": "^3.0.6", "@japa/assert": "^1.3.6", "@japa/run-failed-tests": "^1.1.0", "@japa/runner": "^2.2.2", @@ -93,9 +93,9 @@ "dev": true }, "node_modules/@athenna/artisan": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/@athenna/artisan/-/artisan-3.3.4.tgz", - "integrity": "sha512-OE9r7AA4gtwuWizPQZ/L1pV+3vwBoEiBQQ3RyQmko9MoNDI8+zjB+Kfi2Dxfgy7tCWm9kvF844KCiYRAazt7zw==", + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/@athenna/artisan/-/artisan-3.3.6.tgz", + "integrity": "sha512-zT9m91vxmb+eEgYtK6eBBgF8VZdDNVsesL8guGstqK+UCZKK7Vfn4RhiajgAO9QLT6vv8LdDqNmigwtqtQjmRQ==", "dev": true, "dependencies": { "chalk-rainbow": "^1.0.0", @@ -449,9 +449,9 @@ } }, "node_modules/@athenna/common": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/@athenna/common/-/common-3.4.3.tgz", - "integrity": "sha512-opEJgrNOZNisClQCvrIm8yeHADDbcPjqT82QitKOKOChTNNSk92Mh8MmpHAa7d1ZhOZ28QCofBRtDUPYxUDTEQ==", + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/@athenna/common/-/common-3.4.4.tgz", + "integrity": "sha512-VjHkScA6cX+cqrmTtOVyE+sw0RZN95zNVSkoUmm9zy0Kz9XKAlPQ3VczSPm34/zFzV0aJP6jnAScNqhmWrrugg==", "dev": true, "dependencies": { "@fastify/formbody": "^7.4.0", @@ -480,9 +480,9 @@ } }, "node_modules/@athenna/config": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/@athenna/config/-/config-3.2.1.tgz", - "integrity": "sha512-/+IhaWI8C5XkGE35W14bU7l+g85qOxUFk0XxVIhGgOfQogn5fBLSHdOdLknFqKLGo4IGRJXxgcSG+6ugvALTaQ==", + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/@athenna/config/-/config-3.2.3.tgz", + "integrity": "sha512-LdPqBg+i4wHZ2A/quYmyjbE9excEeHu42TToW0jQzul7GNsu2Nivb3R78rLf9F3F1FpdKa2QpctVUlgb0Vyd3A==", "dev": true, "dependencies": { "dotenv": "^16.0.3", @@ -490,42 +490,42 @@ } }, "node_modules/@athenna/http": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/@athenna/http/-/http-3.4.2.tgz", - "integrity": "sha512-URYh+eGUEJ+Zu/r4zn2ypVWQp3RZo2u5/D2L9WH234uetoVIJ2sSw1GcN1DdUzn9XRpJJ2aNhedIvSq+QFm+EQ==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/@athenna/http/-/http-3.4.3.tgz", + "integrity": "sha512-e/kGnk84Qe5O27tf/d5bO3yp/t7bb3wwS9tiP5IK6IF9Mm0R9AtYYH8IEMlJw5o2KbI9k8r4vN4QY7g7zyRJIw==", "dev": true, "dependencies": { "fastify": "^4.13.0" } }, "node_modules/@athenna/ioc": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-3.1.6.tgz", - "integrity": "sha512-PE/NiOwpvv/N8J46o+SpyuPCtf1IAfOUhYDsKdPhMxMYvDziPIoWlD2uADdNDqCJqrbXdgM9qiCoNZ/9S4ux7A==", + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-3.1.8.tgz", + "integrity": "sha512-kOsg5UllGYmF1bKc5pdMqMO3kox2aV09Kxt3T18LZZZ97Mt1nyHQW5xYAcnlRcUKzba/jy/fP6aMuMkORI9hQw==", "dev": true, "dependencies": { "awilix": "^7.0.3" } }, "node_modules/@athenna/logger": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-3.1.6.tgz", - "integrity": "sha512-J0AmGQPbtgkic7zx0hyMQF5uLFFrvpiBbgRz6q+mFGW9DJayWoulr2UfJKj9Lx2jG8ckzw+xJmfaKuDet+eu/w==", + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-3.1.7.tgz", + "integrity": "sha512-YtctWZAYBqwYx8I6n9BXDUfPCvz1zbkzjaEGqVsOnlqRquEBk6R7RMopJRlc8rNxMq5p6CHdtJ3EkocQn0fkkQ==", "dev": true, "dependencies": { "telegraf": "^4.11.2" } }, "node_modules/@athenna/test": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/@athenna/test/-/test-3.2.2.tgz", - "integrity": "sha512-nCCtvcE1jOSW0WJOxa06EjARdm8XW9uuGltPiCitc3IPZl2v2GS4ZU+ApecnNLX4nm8XvNtrAofJaqMqEqaj1A==", + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/@athenna/test/-/test-3.2.3.tgz", + "integrity": "sha512-1GMFg4A2CsvQQ0ZHbPRI8i0zlY9zzV7DOay495FWSA93gljxMA4MpGn/oohlBCN3k3i4uW+AO+zQLyAukxnSgw==", "dev": true }, "node_modules/@athenna/view": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@athenna/view/-/view-3.0.5.tgz", - "integrity": "sha512-cRZbDnHQdJcbsyq/1u1iY+uvmTp2TxYZilcf9c+KpOTIMsT13A6/B8FnEBLMH2OPMZkFL1SAyy9KtWLx84Jfbw==", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@athenna/view/-/view-3.0.6.tgz", + "integrity": "sha512-8IVemDS+iBATCdAzkzu6dioCXmY1cUY8k5NMA7ohVUYOl5p2IopAAHjGhnazGUvtIHRG/LTwzdK8enbKo7u5Kg==", "dev": true, "dependencies": { "edge.js": "^5.5.0" @@ -10123,9 +10123,9 @@ "dev": true }, "@athenna/artisan": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/@athenna/artisan/-/artisan-3.3.4.tgz", - "integrity": "sha512-OE9r7AA4gtwuWizPQZ/L1pV+3vwBoEiBQQ3RyQmko9MoNDI8+zjB+Kfi2Dxfgy7tCWm9kvF844KCiYRAazt7zw==", + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/@athenna/artisan/-/artisan-3.3.6.tgz", + "integrity": "sha512-zT9m91vxmb+eEgYtK6eBBgF8VZdDNVsesL8guGstqK+UCZKK7Vfn4RhiajgAO9QLT6vv8LdDqNmigwtqtQjmRQ==", "dev": true, "requires": { "chalk-rainbow": "^1.0.0", @@ -10355,9 +10355,9 @@ } }, "@athenna/common": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/@athenna/common/-/common-3.4.3.tgz", - "integrity": "sha512-opEJgrNOZNisClQCvrIm8yeHADDbcPjqT82QitKOKOChTNNSk92Mh8MmpHAa7d1ZhOZ28QCofBRtDUPYxUDTEQ==", + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/@athenna/common/-/common-3.4.4.tgz", + "integrity": "sha512-VjHkScA6cX+cqrmTtOVyE+sw0RZN95zNVSkoUmm9zy0Kz9XKAlPQ3VczSPm34/zFzV0aJP6jnAScNqhmWrrugg==", "dev": true, "requires": { "@fastify/formbody": "^7.4.0", @@ -10386,9 +10386,9 @@ } }, "@athenna/config": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/@athenna/config/-/config-3.2.1.tgz", - "integrity": "sha512-/+IhaWI8C5XkGE35W14bU7l+g85qOxUFk0XxVIhGgOfQogn5fBLSHdOdLknFqKLGo4IGRJXxgcSG+6ugvALTaQ==", + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/@athenna/config/-/config-3.2.3.tgz", + "integrity": "sha512-LdPqBg+i4wHZ2A/quYmyjbE9excEeHu42TToW0jQzul7GNsu2Nivb3R78rLf9F3F1FpdKa2QpctVUlgb0Vyd3A==", "dev": true, "requires": { "dotenv": "^16.0.3", @@ -10396,42 +10396,42 @@ } }, "@athenna/http": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/@athenna/http/-/http-3.4.2.tgz", - "integrity": "sha512-URYh+eGUEJ+Zu/r4zn2ypVWQp3RZo2u5/D2L9WH234uetoVIJ2sSw1GcN1DdUzn9XRpJJ2aNhedIvSq+QFm+EQ==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/@athenna/http/-/http-3.4.3.tgz", + "integrity": "sha512-e/kGnk84Qe5O27tf/d5bO3yp/t7bb3wwS9tiP5IK6IF9Mm0R9AtYYH8IEMlJw5o2KbI9k8r4vN4QY7g7zyRJIw==", "dev": true, "requires": { "fastify": "^4.13.0" } }, "@athenna/ioc": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-3.1.6.tgz", - "integrity": "sha512-PE/NiOwpvv/N8J46o+SpyuPCtf1IAfOUhYDsKdPhMxMYvDziPIoWlD2uADdNDqCJqrbXdgM9qiCoNZ/9S4ux7A==", + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-3.1.8.tgz", + "integrity": "sha512-kOsg5UllGYmF1bKc5pdMqMO3kox2aV09Kxt3T18LZZZ97Mt1nyHQW5xYAcnlRcUKzba/jy/fP6aMuMkORI9hQw==", "dev": true, "requires": { "awilix": "^7.0.3" } }, "@athenna/logger": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-3.1.6.tgz", - "integrity": "sha512-J0AmGQPbtgkic7zx0hyMQF5uLFFrvpiBbgRz6q+mFGW9DJayWoulr2UfJKj9Lx2jG8ckzw+xJmfaKuDet+eu/w==", + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-3.1.7.tgz", + "integrity": "sha512-YtctWZAYBqwYx8I6n9BXDUfPCvz1zbkzjaEGqVsOnlqRquEBk6R7RMopJRlc8rNxMq5p6CHdtJ3EkocQn0fkkQ==", "dev": true, "requires": { "telegraf": "^4.11.2" } }, "@athenna/test": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/@athenna/test/-/test-3.2.2.tgz", - "integrity": "sha512-nCCtvcE1jOSW0WJOxa06EjARdm8XW9uuGltPiCitc3IPZl2v2GS4ZU+ApecnNLX4nm8XvNtrAofJaqMqEqaj1A==", + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/@athenna/test/-/test-3.2.3.tgz", + "integrity": "sha512-1GMFg4A2CsvQQ0ZHbPRI8i0zlY9zzV7DOay495FWSA93gljxMA4MpGn/oohlBCN3k3i4uW+AO+zQLyAukxnSgw==", "dev": true }, "@athenna/view": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@athenna/view/-/view-3.0.5.tgz", - "integrity": "sha512-cRZbDnHQdJcbsyq/1u1iY+uvmTp2TxYZilcf9c+KpOTIMsT13A6/B8FnEBLMH2OPMZkFL1SAyy9KtWLx84Jfbw==", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@athenna/view/-/view-3.0.6.tgz", + "integrity": "sha512-8IVemDS+iBATCdAzkzu6dioCXmY1cUY8k5NMA7ohVUYOl5p2IopAAHjGhnazGUvtIHRG/LTwzdK8enbKo7u5Kg==", "dev": true, "requires": { "edge.js": "^5.5.0" diff --git a/package.json b/package.json index f43e01a..573b075 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/core", - "version": "3.1.5", + "version": "3.1.6", "description": "The plug and play Node.js framework.", "license": "MIT", "author": "João Lenon ", @@ -17,43 +17,41 @@ ], "scripts": { "start": "sh node bin/http.ts", - "build": "sh node bin/build.ts", "http": "sh node bin/http.ts", "repl": "sh node bin/repl.ts", "artisan": "sh node bin/artisan.ts", - "lint:fix": "eslint \"{src,tests}/**/*.ts\" --fix", + "lint:fix": "eslint \"{bin,src,tests}/**/*.ts\" --fix", "test": "npm run --silent lint:fix && sh node bin/test.ts", "test:debug": "cross-env DEBUG=api:* sh node --inspect bin/test.ts", "test:coverage": "c8 npm run --silent test" }, "files": [ - "build/*.js", - "build/*.d.ts", - "build/**/*.js", - "build/**/*.d.ts", - "templates/*", - "templates/**/*" + "src/*.js", + "src/*.d.ts", + "src/**/*.js", + "src/**/*.d.ts", + "templates" ], "type": "module", - "main": "./build/index.js", - "types": "./build/index.d.ts", + "main": "./src/index.js", + "types": "./src/index.d.ts", "exports": { - ".": "./build/index.js", - "./providers/CoreProvider": "./build/Providers/CoreProvider.js", - "./commands/MakeExceptionCommand": "./build/Commands/MakeExceptionCommand.js", - "./commands/MakeFacadeCommand": "./build/Commands/MakeFacadeCommand.js", - "./commands/MakeProviderCommand": "./build/Commands/MakeProviderCommand.js", - "./commands/MakeServiceCommand": "./build/Commands/MakeServiceCommand.js", - "./commands/MakeTestCommand": "./build/Commands/MakeTestCommand.js", - "./commands/ReplCommand": "./build/Commands/ReplCommand.js", - "./commands/ServeCommand": "./build/Commands/ServeCommand.js", - "./commands/TestCommand": "./build/Commands/TestCommand.js" + ".": "./src/index.js", + "./providers/CoreProvider": "./src/Providers/CoreProvider.js", + "./commands/MakeExceptionCommand": "./src/Commands/MakeExceptionCommand.js", + "./commands/MakeFacadeCommand": "./src/Commands/MakeFacadeCommand.js", + "./commands/MakeProviderCommand": "./src/Commands/MakeProviderCommand.js", + "./commands/MakeServiceCommand": "./src/Commands/MakeServiceCommand.js", + "./commands/MakeTestCommand": "./src/Commands/MakeTestCommand.js", + "./commands/ReplCommand": "./src/Commands/ReplCommand.js", + "./commands/ServeCommand": "./src/Commands/ServeCommand.js", + "./commands/TestCommand": "./src/Commands/TestCommand.js" }, "imports": { - "#src/*": "./src/*.js", - "#src": "./src/index.js", "#bin/*": "./bin/*.js", "#bin": "./bin/index.js", + "#src/*": "./src/*.js", + "#src": "./src/index.js", "#tests/*": "./tests/*.js", "#tests": "./tests/index.js" }, @@ -62,14 +60,14 @@ "semver": "^7.3.8" }, "devDependencies": { - "@athenna/artisan": "^3.3.4", - "@athenna/common": "^3.4.3", - "@athenna/config": "^3.2.1", - "@athenna/http": "^3.4.2", - "@athenna/ioc": "^3.1.6", - "@athenna/logger": "^3.1.6", - "@athenna/test": "^3.2.2", - "@athenna/view": "^3.0.5", + "@athenna/artisan": "^3.3.6", + "@athenna/common": "^3.4.4", + "@athenna/config": "^3.2.3", + "@athenna/http": "^3.4.3", + "@athenna/ioc": "^3.1.8", + "@athenna/logger": "^3.1.7", + "@athenna/test": "^3.2.3", + "@athenna/view": "^3.0.6", "@japa/assert": "^1.3.6", "@japa/run-failed-tests": "^1.1.0", "@japa/runner": "^2.2.2", diff --git a/scripts/build b/scripts/build new file mode 100644 index 0000000..9b777fa --- /dev/null +++ b/scripts/build @@ -0,0 +1,5 @@ +#!/bin/bash + +sh scripts/clean + +./node_modules/.bin/tsc --project scripts/tsconfig.build.json diff --git a/scripts/clean b/scripts/clean new file mode 100644 index 0000000..ef17386 --- /dev/null +++ b/scripts/clean @@ -0,0 +1,4 @@ +#!/bin/bash + +find src -name "*.js" -type f -delete +find src -name "*.d.ts" -type f -delete diff --git a/scripts/tsconfig.build.json b/scripts/tsconfig.build.json new file mode 100644 index 0000000..929b74d --- /dev/null +++ b/scripts/tsconfig.build.json @@ -0,0 +1,5 @@ +{ + "extends": "../tsconfig.json", + "include": ["../**/*"], + "exclude": ["../bin", "../build", "../tests", "../scripts", "../node_modules"] +}