diff --git a/package.json b/package.json index ba282c3..c9e5f78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/artisan", - "version": "1.4.3", + "version": "1.4.4", "description": "The Athenna CLI application. Built on top of commander.", "license": "MIT", "author": "João Lenon ", diff --git a/src/Commands/Eslint/Fix.js b/src/Commands/Eslint/Fix.js index 80cd9bd..4db37b9 100644 --- a/src/Commands/Eslint/Fix.js +++ b/src/Commands/Eslint/Fix.js @@ -58,11 +58,11 @@ export class MakeFix extends Command { this.title(`LINTING ${options.resource}\n`, 'bold', 'green') } - const { name } = parse(filePath) - await this.execCommand(`${Path.bin('eslint')} ${filePath} --fix --quiet`) if (!options.quiet) { + const { name } = parse(filePath) + this.success( `${options.resource} ({yellow} "${name}") successfully linted.`, ) diff --git a/src/Commands/Make/Provider.js b/src/Commands/Make/Provider.js index 29d98de..209b227 100644 --- a/src/Commands/Make/Provider.js +++ b/src/Commands/Make/Provider.js @@ -69,7 +69,7 @@ export class MakeProvider extends Command { await FilePropertiesHelper.addContentToArrayProperty( path, - 'providers:', + 'providers: ', `import('#providers/${name}')`, ) diff --git a/src/Helpers/FilePropertiesHelper.js b/src/Helpers/FilePropertiesHelper.js index 3943a88..fdbc587 100644 --- a/src/Helpers/FilePropertiesHelper.js +++ b/src/Helpers/FilePropertiesHelper.js @@ -18,7 +18,7 @@ export class FilePropertiesHelper { `(?:${matcher.replace( ' ', '\\s*', - )}\\s*)\\[(?:[^][]+|\\[(?:[^][]+|\\[[^][]*\\])*\\])*\\]`, + )}\\s*)\\[(?:[^\\]\\[]+|\\[(?:[^\\]\\[]+|\\[[^\\]\\[]*\\])*\\])*\\]`, ), ) @@ -191,7 +191,7 @@ export class FilePropertiesHelper { const matches = fileContent.match( new RegExp( - `(?:${getMethod})\\[(?:[^][]+|\\[(?:[^][]+|\\[[^][]*\\])*\\])*\\]`, + `(?:${getMethod})\\[(?:[^\\]\\[]+|\\[(?:[^\\]\\[]+|\\[[^\\]\\[]*\\])*\\])*\\]`, ), ) diff --git a/tests/Stubs/replaceFile.js b/tests/Stubs/replaceFile.js index f623745..0a37c67 100644 --- a/tests/Stubs/replaceFile.js +++ b/tests/Stubs/replaceFile.js @@ -7,18 +7,30 @@ export class ReplaceFile { * @return {any[]} */ get commands() { - const internalCommands = [] + const internalCommands = [ + 'dasdada', + 'dsadsad', + 'dsadsaa', + 'dswesas', + 'ewqasdw', + 'aqwerfs', + 'dswpoik', + 'lklopls', + 'ieumjhg', + ] if (process.env.NODE_ENV !== 'production') { internalCommands.push( ...ArtisanLoader.loadCommands(), - 'oi', - 'zap', - 'truc', - 'dale', - 'vtnc', - 'zsadsadasdasdas', - 'dsaldksaldksaldkasld', + 'dasdada', + 'dsadsad', + 'dsadsaa', + 'dswesas', + 'ewqasdw', + 'aqwerfs', + 'dswpoik', + 'lklopls', + 'ieumjhg', ) } @@ -44,7 +56,17 @@ export class ReplaceFile { * @return {any[]} */ get object() { - const object = {} + const object = { + dasdada: 'dasdada', + dsadsad: 'dsadsad', + dsadsaa: 'dsadsaa', + dswesas: 'dswesas', + ewqasdw: 'ewqasdw', + aqwerfs: 'aqwerfs', + dswpoik: 'dswpoik', + lklopls: 'lklopls', + ieumjhg: 'ieumjhg', + } return object } diff --git a/tests/Unit/Commands/Make/ProviderTest.js b/tests/Unit/Commands/Make/ProviderTest.js index b52d3ab..125776e 100644 --- a/tests/Unit/Commands/Make/ProviderTest.js +++ b/tests/Unit/Commands/Make/ProviderTest.js @@ -48,13 +48,13 @@ test.group('MakeProviderTest', group => { }).timeout(60000) test('should be able to create a provider file and register it inside config/app', async ({ assert }) => { - const oldKernelLength = new File(Path.config('app.js')).getContentSync().toString().length + const oldAppConfigLength = new File(Path.config('app.js')).getContentSync().toString().length await Artisan.call('make:provider RegisterProvider') - const newKernelLength = new File(Path.config('app.js')).getContentSync().toString().length + const newAppConfigLength = new File(Path.config('app.js')).getContentSync().toString().length - assert.notEqual(newKernelLength, oldKernelLength) + assert.notEqual(newAppConfigLength, oldAppConfigLength) }).timeout(60000) test('should throw an error when the file already exists', async ({ assert }) => { diff --git a/tests/Unit/Helpers/FilePropertiesHelperTest.js b/tests/Unit/Helpers/FilePropertiesHelperTest.js index 8e2637c..649683b 100644 --- a/tests/Unit/Helpers/FilePropertiesHelperTest.js +++ b/tests/Unit/Helpers/FilePropertiesHelperTest.js @@ -31,7 +31,7 @@ test.group('FilePropertiesHelperTest', group => { assert.isTrue( content.includes( - "internalCommands.push(...ArtisanLoader.loadCommands,'oi','zap','truc','dale','vtnc','zsadsadasdasdas','dsaldksaldksaldkasld','hello')", + "internalCommands.push(...ArtisanLoader.loadCommands,'dasdada','dsadsad','dsadsaa','dswesas','ewqasdw','aqwerfs','dswpoik','lklopls','ieumjhg','hello')", ), ) }) @@ -45,7 +45,11 @@ test.group('FilePropertiesHelperTest', group => { const content = file.getContentSync().toString() - assert.isTrue(content.includes("const internalCommands = ['hello'")) + assert.isTrue( + content.includes( + "const internalCommands = ['dasdada','dsadsad','dsadsaa','dswesas','ewqasdw','aqwerfs','dswpoik','lklopls','ieumjhg','hello']", + ), + ) }) test('should be able to add content to object properties in files', async ({ assert }) => { @@ -57,7 +61,11 @@ test.group('FilePropertiesHelperTest', group => { const content = file.getContentSync().toString() - assert.isTrue(content.includes("const object = {nice: 'hello'}")) + assert.isTrue( + content.includes( + "const object = {dasdada:'dasdada',dsadsad:'dsadsad',dsadsaa:'dsadsaa',dswesas:'dswesas',ewqasdw:'ewqasdw',aqwerfs:'aqwerfs',dswpoik:'dswpoik',lklopls:'lklopls',ieumjhg:'ieumjhg',nice: 'hello'}", + ), + ) }) test('should be able to add content to array getter in files', async ({ assert }) => {