mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
Iris cmd: download packages on every iris create command
This commit is contained in:
parent
a3f3e7ebd2
commit
dc2b40283e
|
@ -48,6 +48,8 @@ type (
|
|||
HTML(status int, name string, binding interface{}, layout ...string) error
|
||||
// Render same as .HTML but with status to iris.StatusOK (200)
|
||||
Render(name string, binding interface{}, layout ...string) error
|
||||
// MustRender same as .Render but returns 500 internal server http status (error) if rendering fail
|
||||
MustRender(name string, binding interface{}, layout ...string)
|
||||
// RenderString accepts a template filename, its context data and returns the result of the parsed template (string)
|
||||
RenderString(name string, binding interface{}, layout ...string) (result string, err error)
|
||||
// MarkdownString parses the (dynamic) markdown string and returns the converted html string
|
||||
|
|
|
@ -43,6 +43,13 @@ func (ctx *Context) Render(name string, binding interface{}, layout ...string) e
|
|||
return ctx.HTML(StatusOK, name, binding, layout...)
|
||||
}
|
||||
|
||||
// MustRender same as .Render but returns 500 internal server http status (error) if rendering fail
|
||||
func (ctx *Context) MustRender(name string, binding interface{}, layout ...string) {
|
||||
if err := ctx.Render(name, binding, layout...); err != nil {
|
||||
ctx.Panic()
|
||||
}
|
||||
}
|
||||
|
||||
// RenderString accepts a template filename, its context data and returns the result of the parsed template (string)
|
||||
func (ctx *Context) RenderString(name string, binding interface{}, layout ...string) (result string, err error) {
|
||||
return ctx.station.templates.RenderString(name, binding, layout...)
|
||||
|
|
17
iris/main.go
17
iris/main.go
|
@ -36,7 +36,7 @@ func init() {
|
|||
|
||||
createCmd := cli.Command("create", "create a project to a given directory").
|
||||
Flag("dir", "./", "-d ./ creates an iris starter kit to the current directory").
|
||||
Flag("type", "basic", "-t basic creates the project based on the t 'package'").
|
||||
Flag("type", "basic", "creates the project based on the -t package. Available type is only 'basic', currently").
|
||||
Action(create)
|
||||
|
||||
app.Command(createCmd)
|
||||
|
@ -48,9 +48,15 @@ func main() {
|
|||
|
||||
func create(flags cli.Flags) (err error) {
|
||||
|
||||
if !utils.DirectoryExists(packagesDir) {
|
||||
downloadPackages()
|
||||
}
|
||||
/* ///TODO: add a version.json and check if the repository's version is bigger than local and then do the downloadPackages.
|
||||
|
||||
if !utils.DirectoryExists(packagesDir) {
|
||||
downloadPackages()
|
||||
}
|
||||
*/
|
||||
|
||||
// currently: always download packages, because I'm adding new things to the packages every day.
|
||||
downloadPackages()
|
||||
|
||||
targetDir := flags.String("dir")
|
||||
|
||||
|
@ -97,10 +103,9 @@ func createPackage(packageName string, targetDir string) error {
|
|||
app.Printf("\n Failed to build the %s package. Trace: %s", packageName, err.Error())
|
||||
}
|
||||
buildCmd.Wait()
|
||||
println("\n")
|
||||
print("\n\n")
|
||||
|
||||
// run backend/backend(.exe)
|
||||
|
||||
executable := "backend"
|
||||
if runtime.GOOS == "windows" {
|
||||
executable += ".exe"
|
||||
|
|
5
route.go
5
route.go
|
@ -172,11 +172,8 @@ func (r *Route) setHost(s string) {
|
|||
// Parse used to check arguments with the route's named parameters and return the correct url
|
||||
// second return value is false when the action cannot be done
|
||||
func (r *Route) Parse(args ...interface{}) (string, bool) {
|
||||
// check if arguments are not equal to the named parameters ( : = 1, * = all named parameters split to / ), if this happens then send not found err
|
||||
///TODO: I'm thinking of making an option to disable these checks and just return a result, because they have cost when rendering an html/template, not too big compared to the render action but... we will see
|
||||
// can also do a check if this url can be realy served (_tree.rootBranch.GetBranch(path, ctx.Params)) and if not then return a 404 or a link to a ./templates/errors/404.html
|
||||
// but we don't have access to the context itself(so we will have some memory allocations), although it's a good idea but let's keep things simple here.
|
||||
argsLen := len(args)
|
||||
|
||||
// we have named parameters but arguments not given
|
||||
if argsLen == 0 && r.formattedParts > 0 {
|
||||
return "", false
|
||||
|
|
|
@ -96,7 +96,7 @@ func TestRouter(t *testing.T) {
|
|||
})
|
||||
|
||||
// run the tests (1)
|
||||
for idx, _ := range routes {
|
||||
for idx := range routes {
|
||||
r := routes[idx]
|
||||
e.Request(r.Method, r.RequestPath).
|
||||
Expect().
|
||||
|
|
Loading…
Reference in New Issue
Block a user