diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c342cb8..cdaefb2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,8 @@ jobs: with: node-version: ${{ matrix.node-version }} + - name: Create .env.test file + run: cp .env.example .env.test - name: Install dependencies run: npm install - name: Run tests diff --git a/app/Console/Commands/NewCommand.js b/app/Console/Commands/NewCommand.js index 716e294..85ce6db 100644 --- a/app/Console/Commands/NewCommand.js +++ b/app/Console/Commands/NewCommand.js @@ -159,22 +159,21 @@ export class NewCommand extends Command { throw new NotEmptyFolderException(concretePath) } - const cdCommand = `cd ${projectPath}` const cloneCommand = `git clone --branch ${branch} ${this.url} ${projectPath}` - const runNpmInstallCommand = `${cdCommand} && npm install --silent` - const rmGitAndCopyEnv = `${cdCommand} && rm -rf .git && rm -rf .github && cp .env.example .env && cp .env.example .env.test` const moveProjectCommand = `mv ${projectPath} ${concretePath}` + const runNpmInstallCommand = `cd ${concretePath} && npm install --silent` + const rmGitAndCopyEnv = `cd ${concretePath} && rm -rf .git && rm -rf .github && cp .env.example .env && cp .env.example .env.test` await this.execCommand( cloneCommand, `Cloning scaffold project from ${this.url} in branch ${branch}`, ) + await this.execCommand(moveProjectCommand, 'Moving project to your path') + await this.execCommand(runNpmInstallCommand, 'Installing dependencies') await this.execCommand( rmGitAndCopyEnv, 'Removing defaults and creating .env/.env.test files from .env.example', ) - await this.execCommand(runNpmInstallCommand, 'Installing dependencies') - await this.execCommand(moveProjectCommand, 'Moving project to your path') console.log() diff --git a/app/Exceptions/NotEmptyFolderException.js b/app/Exceptions/NotEmptyFolderException.js index ebc1b44..6f3cc2d 100644 --- a/app/Exceptions/NotEmptyFolderException.js +++ b/app/Exceptions/NotEmptyFolderException.js @@ -20,7 +20,7 @@ export class NotEmptyFolderException extends Exception { * @param {string} projectName */ constructor(projectName) { - const message = `The directory ({yellow} "${projectName}") already exists. Try another project name or delete "${projectName}" folder.` + const message = `The directory ({yellow} "${projectName}") already exists. Try another project name or delete ({yellow} "${projectName}") folder.` super(message, 500, 'E_SIMPLE_CLI') } diff --git a/app/Exceptions/NotFoundProjectTypeException.js b/app/Exceptions/NotFoundProjectTypeException.js index a7da955..c7f169d 100644 --- a/app/Exceptions/NotFoundProjectTypeException.js +++ b/app/Exceptions/NotFoundProjectTypeException.js @@ -20,7 +20,7 @@ export class NotFoundProjectTypeException extends Exception { * @param {string} type */ constructor(type) { - const message = `The project type ({yellow} "${type}") doesnt exist. Try running "athenna new --help" to see the available project types.` + const message = `The project type ({yellow} "${type}") doesnt exist. Try running ({yellow} "athenna new --help") to see the available project types.` super(message, 500, 'E_SIMPLE_CLI') } diff --git a/package.json b/package.json index 67d0b83..523b5bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/cli", - "version": "1.1.9", + "version": "1.2.0", "description": "Athenna CLI to create new projects and install components.", "license": "MIT", "author": "João Lenon ", @@ -74,6 +74,9 @@ "include": [ "app/**/*.js" ], + "exclude": [ + "app/Console/Commands/Install/*.js" + ], "reporter": [ "text-summary", "html" diff --git a/tests/E2E/NewCommandTest.js b/tests/E2E/NewCommandTest.js index abc14a8..6f81ba9 100644 --- a/tests/E2E/NewCommandTest.js +++ b/tests/E2E/NewCommandTest.js @@ -49,4 +49,19 @@ export class NewCommandTest extends Test { assert.isTrue(await Folder.exists(Path.pwd('projectHttp/app'))) } + + /** + * @param {import('@athenna/test').HttpTestContext} ctx + */ + async shouldThrowNotEmptyFolderException({ assert }) { + await Artisan.call('new projectDefault --type slim') + await Artisan.call('new projectDefault --type slim') + } + + /** + * @param {import('@athenna/test').HttpTestContext} ctx + */ + async shouldThrowNotFoundProjectTypeException({ assert }) { + await Artisan.call('new projectDefault --type not-found') + } }