-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
228 additions
and
119 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
include masonite/snippets/exceptions/css/* | ||
include masonite/snippets/* | ||
include masonite/snippets/scaffold/* | ||
include masonite/snippets/auth/controllers/* | ||
include masonite/snippets/auth/templates/auth/* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
|
||
from cleo import Command | ||
|
||
from masonite.app import App | ||
from masonite.helpers.filesystem import make_directory | ||
from masonite.view import View | ||
|
||
|
||
class BaseScaffoldCommand(Command): | ||
""" | ||
Creates a model | ||
model | ||
{name : Name of the model} | ||
""" | ||
|
||
scaffold_name = 'Example' | ||
base_directory = 'app/example/' | ||
template = '/masonite/snippets/scaffold/model' | ||
|
||
def handle(self): | ||
class_name = self.argument('name') | ||
view = View(App()) | ||
class_directory = self.base_directory + '{}.py'.format(class_name) | ||
|
||
if not make_directory(class_directory): | ||
return self.error('{0} Already Exists!'.format(self.scaffold_name)) | ||
|
||
f = open(class_directory, 'w+') | ||
if view.exists(self.template): | ||
f.write( | ||
view.render(self.template, { | ||
'class': class_name.split('/')[-1]}).rendered_template | ||
) | ||
self.info('{} Created Successfully!'.format(self.scaffold_name)) | ||
return f.close() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,16 @@ | ||
import os | ||
from cleo import Command | ||
from masonite.commands import BaseScaffoldCommand | ||
|
||
|
||
class CommandCommand(Command): | ||
class CommandCommand(BaseScaffoldCommand): | ||
""" | ||
Creates a new command | ||
command | ||
{name : Name of the command you would like to create} | ||
""" | ||
|
||
def handle(self): | ||
command = self.argument('name') | ||
if not os.path.isfile('app/commands/{0}.py'.format(command)): | ||
if not os.path.exists(os.path.dirname('app/commands/{0}.py'.format(command))): | ||
# Create the path to the command if it does not exist | ||
os.makedirs(os.path.dirname('app/commands/{0}.py'.format(command))) | ||
|
||
f = open('app/commands/{0}.py'.format(command), 'w+') | ||
|
||
f.write('""" A {0} Command """\n'.format(command)) | ||
f.write('from cleo import Command\n\n\n') | ||
f.write('class {0}(Command):\n """\n Description of command\n\n '.format(command)) | ||
f.write('command:name\n {argument : description}\n """\n\n ') | ||
f.write('def handle(self):\n pass') | ||
|
||
self.info('Command Created Successfully!') | ||
else: | ||
self.error('Command Already Exists!') | ||
scaffold_name = 'Command' | ||
template = '/masonite/snippets/scaffold/command' | ||
base_directory = 'app/commands/' |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,16 @@ | ||
import os | ||
from cleo import Command | ||
from masonite.commands import BaseScaffoldCommand | ||
|
||
|
||
class ModelCommand(Command): | ||
class ModelCommand(BaseScaffoldCommand): | ||
""" | ||
Creates a model | ||
model | ||
{name : Name of the model} | ||
""" | ||
|
||
def handle(self): | ||
model = self.argument('name') | ||
if not os.path.isfile('app/{0}.py'.format(model)): | ||
if not os.path.exists(os.path.dirname('app/{0}.py'.format(model))): | ||
# Create the path to the model if it does not exist | ||
os.makedirs(os.path.dirname('app/{0}.py'.format(model))) | ||
|
||
f = open('app/{0}.py'.format(model), 'w+') | ||
|
||
f.write("''' A {0} Database Model '''\n".format( | ||
model.split('/')[-1])) | ||
f.write('from config.database import Model\n\n') | ||
f.write("class {0}(Model):\n pass\n".format(model.split('/')[-1])) | ||
|
||
self.info('Model Created Successfully!') | ||
else: | ||
self.error('Model Already Exists!') | ||
scaffold_name = "Model" | ||
template = '/masonite/snippets/scaffold/model' | ||
base_directory = 'app/' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,16 @@ | ||
import os | ||
from cleo import Command | ||
from masonite.commands import BaseScaffoldCommand | ||
|
||
|
||
class ProviderCommand(Command): | ||
class ProviderCommand(BaseScaffoldCommand): | ||
""" | ||
Creates a new Service Provider | ||
provider | ||
{name : Name of the Service Provider you want to create} | ||
""" | ||
|
||
def handle(self): | ||
provider = self.argument('name') | ||
|
||
if not os.path.isfile('app/providers/{0}.py'.format(provider)): | ||
if not os.path.exists(os.path.dirname('app/providers/{0}.py'.format(provider))): | ||
# Create the path to the service provider if it does not exist | ||
os.makedirs(os.path.dirname('app/providers/{0}.py'.format(provider))) | ||
|
||
f = open('app/providers/{0}.py'.format(provider), 'w+') | ||
|
||
f.write("''' A {0} Service Provider '''\n".format(provider)) | ||
f.write('from masonite.provider import ServiceProvider\n\n') | ||
f.write("class {0}(ServiceProvider):\n\n ".format(provider)) | ||
f.write("def register(self):\n pass\n\n ") | ||
f.write("def boot(self):\n pass\n") | ||
|
||
self.info('Service Provider Created Successfully!') | ||
else: | ||
self.comment('Service Provider Already Exists!') | ||
scaffold_name = 'Service Provider' | ||
base_directory = 'app/providers/' | ||
template = '/masonite/snippets/scaffold/provider' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,16 @@ | ||
import os | ||
from cleo import Command | ||
from masonite.commands import BaseScaffoldCommand | ||
|
||
|
||
class ValidatorCommand(Command): | ||
class ValidatorCommand(BaseScaffoldCommand): | ||
""" | ||
Creates a validator | ||
validator | ||
{name : Name of the validator} | ||
""" | ||
|
||
def handle(self): | ||
validator = self.argument('name') | ||
if not os.path.isfile('app/validators/{0}.py'.format(validator)): | ||
if not os.path.exists(os.path.dirname('app/validators/{0}.py'.format(validator))): | ||
# Create the path to the validator if it does not exists already | ||
os.makedirs(os.path.dirname('app/validators/{0}.py'.format(validator))) | ||
|
||
f = open('app/validators/{0}.py'.format(validator), 'w+') | ||
|
||
f.write("''' A {0} Validator '''\n".format(validator.split('/')[-1])) | ||
f.write('from masonite.validator import Validator\n\n') | ||
f.write("class {0}Validator(Validator):\n pass\n".format(validator.split('/')[-1])) | ||
|
||
self.info('Validator Created Successfully') | ||
else: | ||
self.error('Validator Already Exists!') | ||
scaffold_name = 'Validator' | ||
base_directory = 'app/validators/' | ||
template = '/masonite/snippets/scaffold/validator' |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
|
||
|
||
def make_directory(directory): | ||
if not os.path.isfile(directory): | ||
if not os.path.exists(os.path.dirname(directory)): | ||
# Create the path to the model if it does not exist | ||
os.makedirs(os.path.dirname(directory)) | ||
|
||
return True | ||
|
||
return False |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" A {{ class }} Command """ | ||
from cleo import Command | ||
|
||
|
||
class {{ class }}(Command): | ||
""" | ||
Description of command | ||
|
||
command:name | ||
{argument : description} | ||
""" | ||
|
||
def handle(self): | ||
pass |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
""" A {{ class }} Module """ | ||
|
||
|
||
class {{ class }}: | ||
"""{{ class }} Controller | ||
""" | ||
|
||
def show(self): | ||
pass |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" A {{ class }} Module """ | ||
|
||
|
||
class {{ class }}: | ||
"""Class Docstring Description | ||
""" | ||
|
||
def show(self): | ||
"""Show several resource listings | ||
""" | ||
|
||
pass | ||
|
||
def index(self): | ||
"""Show a single resource listing | ||
""" | ||
|
||
pass | ||
|
||
def create(self): | ||
"""Show form to create new resource listings | ||
""" | ||
|
||
pass | ||
|
||
def store(self): | ||
"""Create a new resource listing | ||
""" | ||
|
||
pass | ||
|
||
def edit(self): | ||
"""Show form to edit an existing resource listing | ||
""" | ||
|
||
pass | ||
|
||
def update(self): | ||
"""Edit an existing resource listing | ||
""" | ||
|
||
pass | ||
|
||
def destroy(self): | ||
"""Delete an existing resource listing | ||
""" | ||
|
||
pass |
Oops, something went wrong.