Last active
October 11, 2017 13:58
-
-
Save rawaludin/495715425dd76fcd4586fb4ec2fcabbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! GenerateDomain(domain, table, relationship, config, const, payload_field, foreign) | |
" contracts | |
execute '!cp -rf ./app/Contracts/Basement app/Contracts/'.a:domain | |
execute "!find ./app/Contracts/".a:domain." -type f | xargs sed -i '' -e 's/Basement/".a:domain."/g'" | |
execute "!find ./app/Contracts/".a:domain." -type f | sed 'p;s/Basement/".a:domain."/g' | xargs -n2 mv" | |
" domain | |
execute '!cp -rf app/Domains/Basement app/Domains/'.a:domain | |
execute "!find ./app/Domains/".a:domain." -type f | sed 'p;s/Basement/".a:domain."/g' | xargs -n2 mv" | |
execute "!find ./app/Domains/".a:domain." -type f | xargs sed -i '' -e 's/Basement/".a:domain."/g'" | |
execute "!find ./app/Domains/".a:domain." -type f | xargs sed -i '' -e 's/basements/".a:table."/g'" | |
" Infrastructures | |
execute '!cp -rf app/Infrastructures/Basement app/Infrastructures/'.a:domain | |
execute "!find ./app/Infrastructures/".a:domain." -type f | sed 'p;s/Basement/".a:domain."/g' | xargs -n2 mv" | |
execute "!find ./app/Infrastructures/".a:domain." -type f | xargs sed -i '' -e 's/Basement/".a:domain."/g'" | |
execute "!find ./app/Infrastructures/".a:domain." -type f | xargs sed -i '' -e 's/basements/".a:relationship."/g'" | |
" config | |
execute '!cp -rf ./config/packages/basement.php config/packages/'.a:config.'.php' | |
execute "!sed -i '' -e 's/Basement/".a:domain."/g' config/packages/".a:config.'.php' | |
" test | |
execute '!cp -rf ./tests/Domains/Basement ./tests/Domains/'.a:domain | |
execute "!find ./tests/Domains/".a:domain." -type f | sed 'p;s/Basement/".a:domain."/g' | xargs -n2 mv" | |
execute "!find ./tests/Domains/".a:domain." -type f | xargs sed -i '' -e 's/Basement/".a:domain."/g'" | |
execute '!cp -rf ./tests/Infrastructures/Basement ./tests/Infrastructures/'.a:domain | |
execute "!find ./tests/Infrastructures/".a:domain." -type f | sed 'p;s/Basement/".a:domain."/g' | xargs -n2 mv" | |
execute "!find ./tests/Infrastructures/".a:domain." -type f | xargs sed -i '' -e 's/Basement/".a:domain."/g'" | |
" factory | |
execute "!echo '$factory->define(\\App\\Domains\\".a:domain."\\".a:domain."Eloquent::class, function (Faker\\Generator $faker) {' >> database/factories/StructureFactory.php" | |
execute "!echo ' return [' >> database/factories/StructureFactory.php" | |
if a:const != '0' | |
execute "!echo \" 'name' => \\$faker->randomElement(\\App\\Contracts\\Structure\\StructureInterface::".a:const.")\" >> database/factories/StructureFactory.php" | |
else | |
execute "!echo \" 'name' => \\$faker->text\" >> database/factories/StructureFactory.php" | |
endif | |
execute "!echo ' ];' >> database/factories/StructureFactory.php" | |
execute "!echo '});' >> database/factories/StructureFactory.php" | |
" Controller Assertion | |
execute '!cp -rf ./tests/Controllers/Concerns/StructureAssertion/Basement.php ./tests/Controllers/Concerns/StructureAssertion/'.a:domain.'.php' | |
execute "!sed -i '' -e 's/Basement/".a:domain."/g' ./tests/Controllers/Concerns/StructureAssertion/".a:domain.".php" | |
execute "!sed -i '' -e 's/prop_basements/prop_".a:table."/g' ./tests/Controllers/Concerns/StructureAssertion/".a:domain.".php" | |
execute "!sed -i '' -e 's/basement_id/".a:foreign."/g' ./tests/Controllers/Concerns/StructureAssertion/".a:domain.".php" | |
execute "!sed -i '' -e 's/basement/".a:payload_field."/g' ./tests/Controllers/Concerns/StructureAssertion/".a:domain.".php" | |
" run test | |
execute "!ts ./tests/Domains/".a:domain.' && ts ./tests/Infrastructures/'.a:domain | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment