diff --git a/package-lock.json b/package-lock.json index dddaaec..56722ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/artisan", - "version": "4.10.0", + "version": "4.11.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@athenna/artisan", - "version": "4.10.0", + "version": "4.11.0", "license": "MIT", "dependencies": { "chalk-rainbow": "^1.0.0", @@ -21,11 +21,11 @@ "ora": "^6.3.1" }, "devDependencies": { - "@athenna/common": "^4.10.1", + "@athenna/common": "^4.14.0", "@athenna/config": "^4.4.0", - "@athenna/ioc": "^4.3.0", - "@athenna/logger": "^4.3.0", - "@athenna/test": "^4.7.0", + "@athenna/ioc": "^4.4.2", + "@athenna/logger": "^4.5.0", + "@athenna/test": "^4.8.0", "@athenna/view": "^4.3.0", "@typescript-eslint/eslint-plugin": "^5.56.0", "@typescript-eslint/parser": "^5.56.0", @@ -78,9 +78,9 @@ "dev": true }, "node_modules/@athenna/common": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/@athenna/common/-/common-4.10.1.tgz", - "integrity": "sha512-EVzdlfxP8dQVV5dSIQzUHXMYhby+TCxkGRtyz99nXovlkTOx//KOKE3NT6WXIZUPpAfARwQSQNfD1wEgUAmZMg==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@athenna/common/-/common-4.14.0.tgz", + "integrity": "sha512-OOe0X5rvaDyEUs5hSIs2Ggizs6koKNsmtQKN9y+ePNHITzXeFbJEAa+tGik8bgQwGFhEfQ3bpaCDEZFGFyeqCA==", "dev": true, "dependencies": { "@fastify/formbody": "^7.4.0", @@ -89,7 +89,7 @@ "chalk": "^5.3.0", "change-case": "^4.1.2", "collect.js": "^4.36.1", - "fastify": "^4.21.0", + "fastify": "^4.23.2", "got": "^12.6.1", "http-status-codes": "^2.2.0", "is-wsl": "^2.2.0", @@ -119,18 +119,18 @@ } }, "node_modules/@athenna/ioc": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-4.3.0.tgz", - "integrity": "sha512-rdlNdr2LdFP/ANDml4I6SXMqwZqKXYVs9tKDa77l6jLJxtp8VCkE7Z+pJ3dAjbyaa6XRMpWGYs4SFj4V5kY3Jw==", + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-4.4.2.tgz", + "integrity": "sha512-x0RnCftdG7Bz7zYnjZoLwaQfssgHhfh21xjfN7EvGQRbAJMLqVLazEOQTG2yWaytRcnVsxVgHL7lBCVNiv/f3A==", "dev": true, "dependencies": { "awilix": "^7.0.3" } }, "node_modules/@athenna/logger": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-4.4.0.tgz", - "integrity": "sha512-2EzVIzUlm7yWmBNhIDKP5oxfzsgRlWUwGjdgioMP+ehRIqIF0n0slsdn2wSozUG+N2hsjpaJf5oJThmIc01MfQ==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-4.5.0.tgz", + "integrity": "sha512-/2a99UHFWQxuUX7gO0QgQZED5SxUKGvM5MWz5N8mxUEbN5+28aK3h+xKC/9Zq8DxuC9uuwMnnhZhGeOmqnQutQ==", "dev": true, "dependencies": { "cls-rtracer": "^2.6.3", @@ -138,9 +138,9 @@ } }, "node_modules/@athenna/test": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/@athenna/test/-/test-4.7.0.tgz", - "integrity": "sha512-2g5M9SVY55IIJ/ucznwUPIJIdRJXt5a1r4eR2oLGLR/EEdvCyDEf4oRCjCIfsM5KBq3H0ubHRm5ec7dAISg4HQ==", + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/@athenna/test/-/test-4.8.0.tgz", + "integrity": "sha512-DYs6HkQpz/qlphiXwqulKRpLHbwhfgdra2c/S49rAkPJECHbhGBQKff5S5n6fCrJnWHaBtCzfN8wkNLlMfxApA==", "dev": true, "dependencies": { "@japa/assert": "^1.4.1", @@ -4740,9 +4740,9 @@ } }, "node_modules/fast-content-type-parse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-1.0.0.tgz", - "integrity": "sha512-Xbc4XcysUXcsP5aHUU7Nq3OwvHq97C+WnbkeIefpeYLX+ryzFJlU6OStFJhs6Ol0LkUGpcK+wL0JwfM+FCU5IA==", + "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": { @@ -4864,9 +4864,9 @@ "dev": true }, "node_modules/fastify": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/fastify/-/fastify-4.21.0.tgz", - "integrity": "sha512-tsu4bcwE4HetxqW8prA5fbC9bKHMYDp7jGEDWyzK1l90a3uOaLoIcQbdGcWeODNLVJviQnzh1wvIjTZE3MJFEg==", + "version": "4.23.2", + "resolved": "https://registry.npmjs.org/fastify/-/fastify-4.23.2.tgz", + "integrity": "sha512-WFSxsHES115svC7NrerNqZwwM0UOxbC/P6toT9LRHgAAFvG7o2AN5W+H4ihCtOGuYXjZf4z+2jXC89rVEoPWOA==", "dev": true, "dependencies": { "@fastify/ajv-compiler": "^3.5.0", @@ -4884,7 +4884,7 @@ "rfdc": "^1.3.0", "secure-json-parse": "^2.5.0", "semver": "^7.5.0", - "tiny-lru": "^11.0.1" + "toad-cache": "^3.2.0" } }, "node_modules/fastify-plugin": { @@ -7062,9 +7062,9 @@ } }, "node_modules/light-my-request": { - "version": "5.10.0", - "resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-5.10.0.tgz", - "integrity": "sha512-ZU2D9GmAcOUculTTdH9/zryej6n8TzT+fNGdNtm6SDp5MMMpHrJJkvAdE3c6d8d2chE9i+a//dS9CWZtisknqA==", + "version": "5.11.0", + "resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-5.11.0.tgz", + "integrity": "sha512-qkFCeloXCOMpmEdZ/MV91P8AT4fjwFXWaAFz3lUeStM8RcoM1ks4J/F8r1b3r6y/H4u3ACEJ1T+Gv5bopj7oDA==", "dev": true, "dependencies": { "cookie": "^0.5.0", @@ -8453,15 +8453,15 @@ } }, "node_modules/pino": { - "version": "8.15.0", - "resolved": "https://registry.npmjs.org/pino/-/pino-8.15.0.tgz", - "integrity": "sha512-olUADJByk4twxccmAxb1RiGKOSvddHugCV3wkqjyv+3Sooa2KLrmXrKEWOKi0XPCLasRR5jBXxioE1jxUa4KzQ==", + "version": "8.15.1", + "resolved": "https://registry.npmjs.org/pino/-/pino-8.15.1.tgz", + "integrity": "sha512-Cp4QzUQrvWCRJaQ8Lzv0mJzXVk4z2jlq8JNKMGaixC2Pz5L4l2p95TkuRvYbrEbe85NQsDKrAd4zalf7Ml6WiA==", "dev": true, "dependencies": { "atomic-sleep": "^1.0.0", "fast-redact": "^3.1.1", "on-exit-leak-free": "^2.1.0", - "pino-abstract-transport": "v1.0.0", + "pino-abstract-transport": "v1.1.0", "pino-std-serializers": "^6.0.0", "process-warning": "^2.0.0", "quick-format-unescaped": "^4.0.3", @@ -8475,9 +8475,9 @@ } }, "node_modules/pino-abstract-transport": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-1.0.0.tgz", - "integrity": "sha512-c7vo5OpW4wIS42hUVcT5REsL8ZljsUfBjqV/e2sFxmFEFZiq1XLUp5EYLtuDH6PEHq9W1egWqRbnLUP5FuZmOA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-1.1.0.tgz", + "integrity": "sha512-lsleG3/2a/JIWUtf9Q5gUNErBqwIu1tUKTT3dUzaf5DySw9ra1wcqKjJjLX1VTY64Wk1eEOYsVGSaGfCK85ekA==", "dev": true, "dependencies": { "readable-stream": "^4.0.0", @@ -9849,9 +9849,9 @@ "dev": true }, "node_modules/thread-stream": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-2.3.0.tgz", - "integrity": "sha512-kaDqm1DET9pp3NXwR8382WHbnpXnRkN9xGN9dQt3B2+dmXiW8X1SOwmFOxAErEQ47ObhZ96J6yhZNXuyCOL7KA==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-2.4.0.tgz", + "integrity": "sha512-xZYtOtmnA63zj04Q+F9bdEay5r47bvpo1CaNqsKi7TpoJHcotUez8Fkfo2RJWpW91lnnaApdpRbVwCWsy+ifcw==", "dev": true, "dependencies": { "real-require": "^0.2.0" @@ -9918,15 +9918,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/tiny-lru": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/tiny-lru/-/tiny-lru-11.0.1.tgz", - "integrity": "sha512-iNgFugVuQgBKrqeO/mpiTTgmBsTP0WL6yeuLfLs/Ctf0pI/ixGqIRm8sDCwMcXGe9WWvt2sGXI5mNqZbValmJg==", - "dev": true, - "engines": { - "node": ">=12" - } - }, "node_modules/tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -9959,6 +9950,15 @@ "node": ">=8.0" } }, + "node_modules/toad-cache": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/toad-cache/-/toad-cache-3.2.0.tgz", + "integrity": "sha512-Hj5zSqBS6OHbZoQk9IU8VqIr+0JUpwzunnwSlFJhG8aJSInYUMEuzItl3kJsGteTPd1qtflafdRHlRtUazYeqg==", + "dev": true, + "engines": { + "node": ">=12" + } + }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -10629,9 +10629,9 @@ "dev": true }, "@athenna/common": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/@athenna/common/-/common-4.10.1.tgz", - "integrity": "sha512-EVzdlfxP8dQVV5dSIQzUHXMYhby+TCxkGRtyz99nXovlkTOx//KOKE3NT6WXIZUPpAfARwQSQNfD1wEgUAmZMg==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/@athenna/common/-/common-4.14.0.tgz", + "integrity": "sha512-OOe0X5rvaDyEUs5hSIs2Ggizs6koKNsmtQKN9y+ePNHITzXeFbJEAa+tGik8bgQwGFhEfQ3bpaCDEZFGFyeqCA==", "dev": true, "requires": { "@fastify/formbody": "^7.4.0", @@ -10640,7 +10640,7 @@ "chalk": "^5.3.0", "change-case": "^4.1.2", "collect.js": "^4.36.1", - "fastify": "^4.21.0", + "fastify": "^4.23.2", "got": "^12.6.1", "http-status-codes": "^2.2.0", "is-wsl": "^2.2.0", @@ -10670,18 +10670,18 @@ } }, "@athenna/ioc": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-4.3.0.tgz", - "integrity": "sha512-rdlNdr2LdFP/ANDml4I6SXMqwZqKXYVs9tKDa77l6jLJxtp8VCkE7Z+pJ3dAjbyaa6XRMpWGYs4SFj4V5kY3Jw==", + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-4.4.2.tgz", + "integrity": "sha512-x0RnCftdG7Bz7zYnjZoLwaQfssgHhfh21xjfN7EvGQRbAJMLqVLazEOQTG2yWaytRcnVsxVgHL7lBCVNiv/f3A==", "dev": true, "requires": { "awilix": "^7.0.3" } }, "@athenna/logger": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-4.4.0.tgz", - "integrity": "sha512-2EzVIzUlm7yWmBNhIDKP5oxfzsgRlWUwGjdgioMP+ehRIqIF0n0slsdn2wSozUG+N2hsjpaJf5oJThmIc01MfQ==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-4.5.0.tgz", + "integrity": "sha512-/2a99UHFWQxuUX7gO0QgQZED5SxUKGvM5MWz5N8mxUEbN5+28aK3h+xKC/9Zq8DxuC9uuwMnnhZhGeOmqnQutQ==", "dev": true, "requires": { "cls-rtracer": "^2.6.3", @@ -10689,9 +10689,9 @@ } }, "@athenna/test": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/@athenna/test/-/test-4.7.0.tgz", - "integrity": "sha512-2g5M9SVY55IIJ/ucznwUPIJIdRJXt5a1r4eR2oLGLR/EEdvCyDEf4oRCjCIfsM5KBq3H0ubHRm5ec7dAISg4HQ==", + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/@athenna/test/-/test-4.8.0.tgz", + "integrity": "sha512-DYs6HkQpz/qlphiXwqulKRpLHbwhfgdra2c/S49rAkPJECHbhGBQKff5S5n6fCrJnWHaBtCzfN8wkNLlMfxApA==", "dev": true, "requires": { "@japa/assert": "^1.4.1", @@ -14152,9 +14152,9 @@ } }, "fast-content-type-parse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-1.0.0.tgz", - "integrity": "sha512-Xbc4XcysUXcsP5aHUU7Nq3OwvHq97C+WnbkeIefpeYLX+ryzFJlU6OStFJhs6Ol0LkUGpcK+wL0JwfM+FCU5IA==", + "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 }, "fast-decode-uri-component": { @@ -14267,9 +14267,9 @@ "dev": true }, "fastify": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/fastify/-/fastify-4.21.0.tgz", - "integrity": "sha512-tsu4bcwE4HetxqW8prA5fbC9bKHMYDp7jGEDWyzK1l90a3uOaLoIcQbdGcWeODNLVJviQnzh1wvIjTZE3MJFEg==", + "version": "4.23.2", + "resolved": "https://registry.npmjs.org/fastify/-/fastify-4.23.2.tgz", + "integrity": "sha512-WFSxsHES115svC7NrerNqZwwM0UOxbC/P6toT9LRHgAAFvG7o2AN5W+H4ihCtOGuYXjZf4z+2jXC89rVEoPWOA==", "dev": true, "requires": { "@fastify/ajv-compiler": "^3.5.0", @@ -14287,7 +14287,7 @@ "rfdc": "^1.3.0", "secure-json-parse": "^2.5.0", "semver": "^7.5.0", - "tiny-lru": "^11.0.1" + "toad-cache": "^3.2.0" }, "dependencies": { "semver": { @@ -15888,9 +15888,9 @@ } }, "light-my-request": { - "version": "5.10.0", - "resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-5.10.0.tgz", - "integrity": "sha512-ZU2D9GmAcOUculTTdH9/zryej6n8TzT+fNGdNtm6SDp5MMMpHrJJkvAdE3c6d8d2chE9i+a//dS9CWZtisknqA==", + "version": "5.11.0", + "resolved": "https://registry.npmjs.org/light-my-request/-/light-my-request-5.11.0.tgz", + "integrity": "sha512-qkFCeloXCOMpmEdZ/MV91P8AT4fjwFXWaAFz3lUeStM8RcoM1ks4J/F8r1b3r6y/H4u3ACEJ1T+Gv5bopj7oDA==", "dev": true, "requires": { "cookie": "^0.5.0", @@ -16901,15 +16901,15 @@ "dev": true }, "pino": { - "version": "8.15.0", - "resolved": "https://registry.npmjs.org/pino/-/pino-8.15.0.tgz", - "integrity": "sha512-olUADJByk4twxccmAxb1RiGKOSvddHugCV3wkqjyv+3Sooa2KLrmXrKEWOKi0XPCLasRR5jBXxioE1jxUa4KzQ==", + "version": "8.15.1", + "resolved": "https://registry.npmjs.org/pino/-/pino-8.15.1.tgz", + "integrity": "sha512-Cp4QzUQrvWCRJaQ8Lzv0mJzXVk4z2jlq8JNKMGaixC2Pz5L4l2p95TkuRvYbrEbe85NQsDKrAd4zalf7Ml6WiA==", "dev": true, "requires": { "atomic-sleep": "^1.0.0", "fast-redact": "^3.1.1", "on-exit-leak-free": "^2.1.0", - "pino-abstract-transport": "v1.0.0", + "pino-abstract-transport": "v1.1.0", "pino-std-serializers": "^6.0.0", "process-warning": "^2.0.0", "quick-format-unescaped": "^4.0.3", @@ -16920,9 +16920,9 @@ } }, "pino-abstract-transport": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-1.0.0.tgz", - "integrity": "sha512-c7vo5OpW4wIS42hUVcT5REsL8ZljsUfBjqV/e2sFxmFEFZiq1XLUp5EYLtuDH6PEHq9W1egWqRbnLUP5FuZmOA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-1.1.0.tgz", + "integrity": "sha512-lsleG3/2a/JIWUtf9Q5gUNErBqwIu1tUKTT3dUzaf5DySw9ra1wcqKjJjLX1VTY64Wk1eEOYsVGSaGfCK85ekA==", "dev": true, "requires": { "readable-stream": "^4.0.0", @@ -17944,9 +17944,9 @@ "dev": true }, "thread-stream": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-2.3.0.tgz", - "integrity": "sha512-kaDqm1DET9pp3NXwR8382WHbnpXnRkN9xGN9dQt3B2+dmXiW8X1SOwmFOxAErEQ47ObhZ96J6yhZNXuyCOL7KA==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-2.4.0.tgz", + "integrity": "sha512-xZYtOtmnA63zj04Q+F9bdEay5r47bvpo1CaNqsKi7TpoJHcotUez8Fkfo2RJWpW91lnnaApdpRbVwCWsy+ifcw==", "dev": true, "requires": { "real-require": "^0.2.0" @@ -18009,12 +18009,6 @@ "convert-hrtime": "^3.0.0" } }, - "tiny-lru": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/tiny-lru/-/tiny-lru-11.0.1.tgz", - "integrity": "sha512-iNgFugVuQgBKrqeO/mpiTTgmBsTP0WL6yeuLfLs/Ctf0pI/ixGqIRm8sDCwMcXGe9WWvt2sGXI5mNqZbValmJg==", - "dev": true - }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -18038,6 +18032,12 @@ "is-number": "^7.0.0" } }, + "toad-cache": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/toad-cache/-/toad-cache-3.2.0.tgz", + "integrity": "sha512-Hj5zSqBS6OHbZoQk9IU8VqIr+0JUpwzunnwSlFJhG8aJSInYUMEuzItl3kJsGteTPd1qtflafdRHlRtUazYeqg==", + "dev": true + }, "tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", diff --git a/package.json b/package.json index 3326a1a..84fbee5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/artisan", - "version": "4.10.0", + "version": "4.11.0", "description": "The Athenna CLI application. Built on top of commander and inspired in @adonisjs/ace.", "license": "MIT", "author": "João Lenon ", @@ -67,11 +67,11 @@ "cross-env": "^7.0.3" }, "devDependencies": { - "@athenna/common": "^4.10.1", + "@athenna/common": "^4.14.0", "@athenna/config": "^4.4.0", - "@athenna/ioc": "^4.3.0", - "@athenna/logger": "^4.3.0", - "@athenna/test": "^4.7.0", + "@athenna/ioc": "^4.4.2", + "@athenna/logger": "^4.5.0", + "@athenna/test": "^4.8.0", "@athenna/view": "^4.3.0", "@typescript-eslint/eslint-plugin": "^5.56.0", "@typescript-eslint/parser": "^5.56.0", diff --git a/src/artisan/ArtisanImpl.ts b/src/artisan/ArtisanImpl.ts index 45206b8..9f9cfab 100644 --- a/src/artisan/ArtisanImpl.ts +++ b/src/artisan/ArtisanImpl.ts @@ -108,26 +108,39 @@ export class ArtisanImpl { * Call an Artisan command inside a child process. * This method needs to execute a file to bootstrap * under the hood, by default the "Path.bootstrap(`artisan.${Path.ext()}`)" - * is used. + * is used and the executor is "sh node". * * @example * ```ts * Artisan.callInChild('serve --watch') * // or - * Artisan.callInChild('serve --watch', Path.pwd('other-artisan.ts')) + * Artisan.callInChild('serve --watch', { + * executor: 'node --inspect', + * path: Path.pwd('other-artisan.ts') + * }) * ``` */ public async callInChild( command: string, - path = Path.bootstrap(`artisan.${Path.ext()}`) + options?: { path?: string; executor?: string } ): Promise { + options = Options.create(options, { + executor: Config.get('rc.artisan.child.executor', 'sh node'), + path: Config.get( + 'rc.artisan.child.path', + Path.bootstrap(`artisan.${Path.ext()}`) + ) + }) + + options.path = Path.parseExt(options.path) + const separator = platform() === 'win32' ? '&' : '&&' - const executor = `cd ${Path.pwd()} ${separator} sh node` + const executor = `cd ${Path.pwd()} ${separator} ${options.executor}` if (Env('NODE_ENV')) { - command = `cross-env NODE_ENV=${process.env.NODE_ENV} ${separator} ${executor} ${path} ${command}` + command = `cross-env NODE_ENV=${process.env.NODE_ENV} ${separator} ${executor} ${options.path} ${command}` } else { - command = `${executor} ${path} ${command}` + command = `${executor} ${options.path} ${command}` } return Exec.command(command, { ignoreErrors: true }) diff --git a/src/testing/plugins/command/TestCommand.ts b/src/testing/plugins/command/TestCommand.ts index 70e8c59..13a0fcc 100644 --- a/src/testing/plugins/command/TestCommand.ts +++ b/src/testing/plugins/command/TestCommand.ts @@ -15,8 +15,17 @@ import { TestOutput } from '#src/testing/plugins/command/TestOutput' export class TestCommand { /** * The Artisan file path that will be used to run commands. + * + * @default 'Path.bootstrap(`artisan.${Path.ext()}`)' */ - public static artisanPath = undefined + public static artisanPath = Path.bootstrap(`artisan.${Path.ext()}`) + + /** + * The Artisan executor that will be used to run commands. + * + * @default 'sh node' + */ + public static artisanExecutor = 'sh node' /** * Set the artisan file path. @@ -44,8 +53,9 @@ export class TestCommand { * to make assertions. */ public async run(command: string): Promise { - return Artisan.callInChild(command, TestCommand.artisanPath).then(output => - this.createOutput(output) - ) + return Artisan.callInChild(command, { + path: TestCommand.artisanPath, + executor: TestCommand.artisanExecutor + }).then(output => this.createOutput(output)) } } diff --git a/src/testing/plugins/command/TestOutput.ts b/src/testing/plugins/command/TestOutput.ts index dbe9ce4..2e06855 100644 --- a/src/testing/plugins/command/TestOutput.ts +++ b/src/testing/plugins/command/TestOutput.ts @@ -88,7 +88,29 @@ export class TestOutput { } /** - * Assert command to log the expected message. + * Assert command to have not log the message. + */ + public assertNotLogged(message: string, stream?: 'stdout' | 'stderr') { + const existsInStdout = this.output.stdout.includes(message) + const existsInStderr = this.output.stdout.includes(message) + + switch (stream) { + case 'stdout': + this.assert.isFalse(existsInStdout) + + break + case 'stderr': + this.assert.isFalse(existsInStderr) + + break + default: + this.assert.isFalse(existsInStdout) + this.assert.isFalse(existsInStderr) + } + } + + /** + * Assert command to have a log that matches the regex. */ public assertLogMatches(regex: RegExp, stream?: 'stdout' | 'stderr') { const existsInStdout = regex.test(this.output.stdout) @@ -112,4 +134,26 @@ export class TestOutput { ) } } + + /** + * Assert command to not have a log that matches the regexp. + */ + public assertLogNotMatches(regex: RegExp, stream?: 'stdout' | 'stderr') { + const existsInStdout = regex.test(this.output.stdout) + const existsInStderr = regex.test(this.output.stderr) + + switch (stream) { + case 'stdout': + this.assert.isFalse(existsInStdout) + + break + case 'stderr': + this.assert.isFalse(existsInStderr) + + break + default: + this.assert.isFalse(existsInStdout) + this.assert.isFalse(existsInStderr) + } + } } diff --git a/tests/unit/artisan/ArtisanTest.ts b/tests/unit/artisan/ArtisanTest.ts index 51e0d33..0006e5e 100644 --- a/tests/unit/artisan/ArtisanTest.ts +++ b/tests/unit/artisan/ArtisanTest.ts @@ -16,14 +16,18 @@ import { BaseCommandTest } from '#tests/helpers/BaseCommandTest' export default class ArtisanTest extends BaseCommandTest { @Test() public async shouldThrowAnErrorWhenTryingToExecuteACommandThatDoesNotExist({ assert }: Context) { - const { stderr } = await Artisan.callInChild('not-found', this.artisan) + const { stderr } = await Artisan.callInChild('not-found', { + path: this.artisan + }) assert.equal(stderr, "error: unknown command 'not-found'\n") } @Test() public async shouldBeAbleToLogTheApplicationNameInEntrypointCommands({ assert }: Context) { - const { stdout } = await Artisan.callInChild('', this.artisan) + const { stdout } = await Artisan.callInChild('', { + path: this.artisan + }) const appNameFiglet = figlet.textSync('Artisan') @@ -34,7 +38,9 @@ export default class ArtisanTest extends BaseCommandTest { public async shouldBeAbleToRegisterCommandsAsRoutes({ assert }: Context) { process.env.NODE_ENV = 'test' - const { stderr, stdout } = await Artisan.callInChild('hello world', this.artisan) + const { stderr, stdout } = await Artisan.callInChild('hello world', { + path: this.artisan + }) assert.equal(stderr, '') assert.equal(stdout, "world\n{ loadApp: false, stayAlive: false, environments: [ 'hello' ] }\n") @@ -44,7 +50,9 @@ export default class ArtisanTest extends BaseCommandTest { @Test() public async shouldBeAbleToSetArgumentsAndOptionsUsingArgumentAndOptionDecorators({ assert }: Context) { - const { stderr, stdout } = await Artisan.callInChild('test test --other', this.artisan) + const { stderr, stdout } = await Artisan.callInChild('test test --other', { + path: this.artisan + }) assert.equal(stderr, '') assert.equal( @@ -65,7 +73,9 @@ export default class ArtisanTest extends BaseCommandTest { @Test() public async shouldBeAbleToSetCustomCommanderOptionsInCommands({ assert }: Context) { - const { stderr, stdout } = await Artisan.callInChild('unknown --unk', this.artisan) + const { stderr, stdout } = await Artisan.callInChild('unknown --unk', { + path: this.artisan + }) assert.isDefined(stdout) assert.isEmpty(stderr) diff --git a/tests/unit/commands/ListCommandTest.ts b/tests/unit/commands/ListCommandTest.ts index 34da4a6..28539f3 100644 --- a/tests/unit/commands/ListCommandTest.ts +++ b/tests/unit/commands/ListCommandTest.ts @@ -14,7 +14,9 @@ import { BaseCommandTest } from '#tests/helpers/BaseCommandTest' export default class ListCommandTest extends BaseCommandTest { @Test() public async shouldBeAbleToListOtherCommandsByAlias({ assert }: Context) { - const { stderr, stdout } = await Artisan.callInChild('list make', this.artisan) + const { stderr, stdout } = await Artisan.callInChild('list make', { + path: this.artisan + }) assert.equal(stderr, '') assert.isTrue(stdout.includes('[ LISTING MAKE ]'))