Skip to content

Commit

Permalink
Merge pull request #23 from AthennaIO/develop
Browse files Browse the repository at this point in the history
fix(commands): adjust tests and npm install command
  • Loading branch information
jlenon7 authored Sep 6, 2022
2 parents 9b032c1 + 7574c2a commit 088a1dd
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions app/Console/Commands/NewCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/NotEmptyFolderException.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/NotFoundProjectTypeException.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <lenon@athenna.io>",
Expand Down Expand Up @@ -74,6 +74,9 @@
"include": [
"app/**/*.js"
],
"exclude": [
"app/Console/Commands/Install/*.js"
],
"reporter": [
"text-summary",
"html"
Expand Down
15 changes: 15 additions & 0 deletions tests/E2E/NewCommandTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}

0 comments on commit 088a1dd

Please sign in to comment.