1
0
mirror of https://github.com/beego/bee.git synced 2024-12-22 15:10:49 +00:00
beego bee tool mirror
Go to file
astaxie 9db35a8270 Merge pull request #364 from szyhf/master
给bee run增加了一个参数extra,允许watch额外的包(刚忘了要pr到develop)
2017-03-08 11:30:24 +08:00
testdata/router change this to short name 2014-11-05 22:48:09 +08:00
vendor Add gorilla/websocket to vendor folder 2017-01-23 20:12:40 +01:00
.gitignore Set the output format for bee version 2016-12-24 14:51:14 +01:00
.goxc.json add goxc 2016-01-07 10:17:34 +08:00
.travis.yml update travis 2016-12-27 20:44:17 +08:00
apiapp.go Added a few tweaks to the folder structure in the long description 2016-12-03 16:06:46 +01:00
autorouter_test.go Added func getControllerInfo 2013-07-27 09:44:44 +08:00
autorouter.go Implementing the new logging infrastructure 2016-11-13 15:14:48 +01:00
bale.go Enhances the commands short and long description 2016-12-03 11:54:41 +01:00
banner.go Set the output format for bee version 2016-12-24 14:51:14 +01:00
bee.go bee 1.8.0 2017-03-06 21:33:19 +08:00
bee.json Generate WebSocket client in static/js 2017-01-27 16:57:37 +01:00
Beefile Generate WebSocket client in static/js 2017-01-27 16:57:37 +01:00
code.go Implementing the new logging infrastructure 2016-11-13 15:14:48 +01:00
color.go Added black and white colors 2016-11-23 15:58:21 +01:00
colorwriter_windows.go Added more helper functions to output colored text 2016-11-13 14:10:11 +01:00
colorwriter.go Added ANSI color writer 2016-07-31 23:21:20 +02:00
conf.go Enable reload through JSON/YAML configuration files 2017-01-22 22:24:52 +01:00
dockerize.go Added default base image + New layout for displaying options 2016-12-23 11:53:02 +01:00
fix.go Enhances the commands short and long description 2016-12-03 11:54:41 +01:00
g_appcode.go add inet type for Postgres 2016-12-12 22:34:13 +02:00
g_controllers.go This fixes #147 2016-12-25 13:53:06 +01:00
g_docs.go Merge pull request #358 from sergeylanzman/patch-2 2017-03-05 21:44:18 +08:00
g_hproseappcode.go Implementing the new logging infrastructure 2016-11-13 15:14:48 +01:00
g_migration.go Implementing the new logging infrastructure 2016-11-13 15:14:48 +01:00
g_model.go Implementing the new logging infrastructure 2016-11-13 15:14:48 +01:00
g_scaffold.go Implementing the new logging infrastructure 2016-11-13 15:14:48 +01:00
g_views.go Implementing the new logging infrastructure 2016-11-13 15:14:48 +01:00
g.go Enhances the commands short and long description 2016-12-03 11:54:41 +01:00
hproseapp.go Handle case when appname argument is missing 2016-12-27 09:44:15 +01:00
LICENSE Update LICENSE 2013-10-30 19:54:53 -04:00
logger.go Initialize the logger templates inside the logger singleton once (and only once) 2016-11-20 11:54:12 +01:00
Makefile added Makefile 2016-07-26 21:05:32 +02:00
migrate.go Enhances the commands short and long description 2016-12-03 11:54:41 +01:00
new.go Generate WebSocket client in static/js 2017-01-27 16:57:37 +01:00
pack.go Merge pull request #331 from amrfaissal/fix-330 2016-12-05 14:54:06 +01:00
README.md Updated README.md 2016-12-26 22:44:27 +01:00
reload.go Implements the Reload WebSocket endpoint 2017-01-22 22:14:29 +01:00
run.go 简化参数extra为ex,并移除了多于的日志 2017-03-07 13:00:37 +08:00
rundocs.go Added PreRun phase to Command struct 2016-11-20 22:28:52 +01:00
test.go Added PreRun phase to Command struct 2016-11-20 22:28:52 +01:00
util.go Added a few tweaks to the folder structure in the long description 2016-12-03 16:06:46 +01:00
version.go Set the output format for bee version 2016-12-24 14:51:14 +01:00
watch.go Update watch.go 2017-02-25 22:14:45 +02:00

bee

Bee is a command-line tool facilitating development of Beego-based application.

Build Status

Requirements

  • Go version >= 1.3.

Installation

To install bee use the go get command:

go get github.com/beego/bee

Then you can add bee binary to PATH environment variable in your ~/.bashrc or ~/.bash_profile file:

export PATH=$PATH:<your_main_gopath>/bin

If you already have bee installed, updating bee is simple:

go get -u github.com/beego/bee

Basic commands

Bee provides a variety of commands which can be helpful at various stages of development. The top level commands include:

    new         Creates a Beego application
    run         Run the application by starting a local development server
    pack        Compresses a Beego application into a single file
    api         Creates a Beego API application
    hprose      Creates an RPC application based on Hprose and Beego frameworks
    bale        Transforms non-Go files to Go source files
    version     Prints the current Bee version
    generate    Source code generator
    migrate     Runs database migrations
    fix         Fixes your application by making it compatible with newer versions of Beego
    dockerize   Generates a Dockerfile for your Beego application

bee version

To display the current version of bee, beego and go installed on your machine:

$ bee version
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.6.2

├── Beego     : 1.7.2
├── GoVersion : go1.7.4
├── GOOS      : linux
├── GOARCH    : amd64
├── NumCPU    : 2
├── GOPATH    : /home/beeuser/.go
├── GOROOT    : /usr/lib/go
├── Compiler  : gc
└── Date      : Monday, 26 Dec 2016

You can also change the output format using -o flag:

$ bee version -o json
{
    "GoVersion": "go1.7.4",
    "GOOS": "linux",
    "GOARCH": "amd64",
    "NumCPU": 2,
    "GOPATH": "/home/beeuser/.go",
    "GOROOT": "/usr/lib/go",
    "Compiler": "gc",
    "BeeVersion": "1.6.2",
    "BeegoVersion": "1.7.2"
}

For more information on the usage, run bee help version.

bee new

To create a new Beego web application:

$ bee new my-web-app
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.6.2
2016/12/26 22:28:11 INFO     ▶ 0001 Creating application...
    create   /home/beeuser/.go/src/github.com/user/my-web-app/
    create   /home/beeuser/.go/src/github.com/user/my-web-app/conf/
    create   /home/beeuser/.go/src/github.com/user/my-web-app/controllers/
    create   /home/beeuser/.go/src/github.com/user/my-web-app/models/
    create   /home/beeuser/.go/src/github.com/user/my-web-app/routers/
    create   /home/beeuser/.go/src/github.com/user/my-web-app/tests/
    create   /home/beeuser/.go/src/github.com/user/my-web-app/static/
    create   /home/beeuser/.go/src/github.com/user/my-web-app/static/js/
    create   /home/beeuser/.go/src/github.com/user/my-web-app/static/css/
    create   /home/beeuser/.go/src/github.com/user/my-web-app/static/img/
    create   /home/beeuser/.go/src/github.com/user/my-web-app/views/
    create   /home/beeuser/.go/src/github.com/user/my-web-app/conf/app.conf
    create   /home/beeuser/.go/src/github.com/user/my-web-app/controllers/default.go
    create   /home/beeuser/.go/src/github.com/user/my-web-app/views/index.tpl
    create   /home/beeuser/.go/src/github.com/user/my-web-app/routers/router.go
    create   /home/beeuser/.go/src/github.com/user/my-web-app/tests/default_test.go
    create   /home/beeuser/.go/src/github.com/user/my-web-app/main.go
2016/12/26 22:28:11 SUCCESS  ▶ 0002 New application successfully created!

For more information on the usage, run bee help new.

bee run

To run the application we just created, you can navigate to the application folder and execute:

$ cd my-web-app && bee run

Or from anywhere in your machine:

$ bee run github.com/user/my-web-app

For more information on the usage, run bee help run.

bee pack

To compress a Beego application into a single deployable file:

$ bee pack
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.6.2
2016/12/26 22:29:29 INFO     ▶ 0001 Packaging application on '/home/beeuser/.go/src/github.com/user/my-web-app'...
2016/12/26 22:29:29 INFO     ▶ 0002 Building application...
2016/12/26 22:29:29 INFO     ▶ 0003 Using: GOOS=linux GOARCH=amd64
2016/12/26 22:29:31 SUCCESS  ▶ 0004 Build Successful!
2016/12/26 22:29:31 INFO     ▶ 0005 Writing to output: /home/beeuser/.go/src/github.com/user/my-web-app/my-web-app.tar.gz
2016/12/26 22:29:31 INFO     ▶ 0006 Excluding relpath prefix: .
2016/12/26 22:29:31 INFO     ▶ 0007 Excluding relpath suffix: .go:.DS_Store:.tmp
2016/12/26 22:29:32 SUCCESS  ▶ 0008 Application packed!

For more information on the usage, run bee help pack.

bee api

To create a Beego API application:

$ bee api my-api
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.6.2
2016/12/26 22:30:12 INFO     ▶ 0001 Creating API...
    create   /home/beeuser/.go/src/github.com/user/my-api
    create   /home/beeuser/.go/src/github.com/user/my-api/conf
    create   /home/beeuser/.go/src/github.com/user/my-api/controllers
    create   /home/beeuser/.go/src/github.com/user/my-api/tests
    create   /home/beeuser/.go/src/github.com/user/my-api/conf/app.conf
    create   /home/beeuser/.go/src/github.com/user/my-api/models
    create   /home/beeuser/.go/src/github.com/user/my-api/routers/
    create   /home/beeuser/.go/src/github.com/user/my-api/controllers/object.go
    create   /home/beeuser/.go/src/github.com/user/my-api/controllers/user.go
    create   /home/beeuser/.go/src/github.com/user/my-api/tests/default_test.go
    create   /home/beeuser/.go/src/github.com/user/my-api/routers/router.go
    create   /home/beeuser/.go/src/github.com/user/my-api/models/object.go
    create   /home/beeuser/.go/src/github.com/user/my-api/models/user.go
    create   /home/beeuser/.go/src/github.com/user/my-api/main.go
2016/12/26 22:30:12 SUCCESS  ▶ 0002 New API successfully created!

For more information on the usage, run bee help api.

bee hprose

To create an Hprose RPC application based on Beego:

$ bee hprose my-rpc-app
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.6.2
2016/12/26 22:30:58 INFO     ▶ 0001 Creating application...
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/conf/
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/controllers/
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/models/
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/routers/
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/tests/
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/static/
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/static/js/
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/static/css/
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/static/img/
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/views/
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/conf/app.conf
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/controllers/default.go
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/views/index.tpl
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/routers/router.go
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/tests/default_test.go
    create   /home/beeuser/.go/src/github.com/user/my-rpc-app/main.go
2016/12/26 22:30:58 SUCCESS  ▶ 0002 New application successfully created!

For more information on the usage, run bee help hprose.

bee bale

To pack all the static files into Go source files:

$ bee bale
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.6.2
2016/12/26 22:32:41 INFO     ▶ 0001 Loading configuration from 'bee.json'...
2016/12/26 22:32:41 SUCCESS  ▶ 0002 Baled resources successfully!

For more information on the usage, run bee help bale.

bee migrate

For database migrations, use bee migrate.

For more information on the usage, run bee help migrate.

bee generate

Bee also comes with a source code generator which speeds up the development.

For example, to generate a new controller named hello:

$ bee generate controller hello
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.6.2
2016/12/26 22:33:58 INFO     ▶ 0001 Using 'Hello' as controller name
2016/12/26 22:33:58 INFO     ▶ 0002 Using 'controllers' as package name
    create   /home/beeuser/.go/src/github.com/user/my-web-app/controllers/hello.go
2016/12/26 22:33:58 SUCCESS  ▶ 0003 Controller successfully generated!

For more information on the usage, run bee help generate.

bee dockerize

Bee also helps you dockerize your Beego application by generating a Dockerfile.

For example, to generate a Dockerfile with Go version 1.6.4 and exposing port 9000:

$ bee dockerize -image="library/golang:1.6.4" -expose=9000
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.6.2
2016/12/26 22:34:54 INFO     ▶ 0001 Generating Dockerfile...
2016/12/26 22:34:54 SUCCESS  ▶ 0002 Dockerfile generated.

For more information on the usage, run bee help dockerize.

Shortcuts

Because you'll likely type these generator commands over and over, it makes sense to create aliases:

# Generator Stuff
alias g:a="bee generate appcode"
alias g:m="bee generate model"
alias g:c="bee generate controller"
alias g:v="bee generate view"
alias g:mi="bee generate migration"

These can be stored , for example, in your ~/.bash_profile or ~/.bashrc files.

Help

To print more information on the usage of a particular command, use bee help <command>.

For instance, to get more information about the run command:

$ bee help run
USAGE
  bee run [appname] [watchall] [-main=*.go] [-downdoc=true]  [-gendoc=true] [-vendor=true] [-e=folderToExclude]  [-tags=goBuildTags] [-runmode=BEEGO_RUNMODE]

OPTIONS
  -downdoc
      Enable auto-download of the swagger file if it does not exist.

  -e=[]
      List of paths to exclude.

  -gendoc
      Enable auto-generate the docs.

  -main=[]
      Specify main go files.

  -runmode
      Set the Beego run mode.

  -tags
      Set the build tags. See: https://golang.org/pkg/go/build/

  -vendor=false
      Enable watch vendor folder.

DESCRIPTION
  Run command will supervise the filesystem of the application for any changes, and recompile/restart it.

Contributing

Bug reports, feature requests and pull requests are always welcome.

We work on two branches: master for stable, released code and develop, a development branch. It might be important to distinguish them when you are reading the commit history searching for a feature or a bugfix, or when you are unsure of where to base your work from when contributing.

Found a bug?

Please submit an issue on GitHub and we will follow up. Even better, we would appreciate a Pull Request with a fix for it!

  • If the bug was found in a release, it is best to base your work on master and submit your PR against it.
  • If the bug was found on develop (the development branch), base your work on develop and submit your PR against it.

Please follow the Pull Request Guidelines.

Want a feature?

Feel free to request a feature by submitting an issue on GitHub and open the discussion.

If you'd like to implement a new feature, please consider opening an issue first to talk about it. It may be that somebody is already working on it, or that there are particular issues that you should be aware of before implementing the change. If you are about to open a Pull Request, please make sure to follow the submissions guidelines.

Submission Guidelines

Submitting an issue

Before you submit an issue, search the archive, maybe you will find that a similar one already exists.

If you are submitting an issue for a bug, please include the following:

  • An overview of the issue
  • Your use case (why is this a bug for you?)
  • The version of bee you are running (include the output of bee version)
  • Steps to reproduce the issue
  • Eventually, logs from your application.
  • Ideally, a suggested fix

The more information you give us, the more able to help we will be!

Submitting a Pull Request

  • First of all, make sure to base your work on the develop branch (the development branch):
  # a bugfix branch for develop would be prefixed by fix/
  # a bugfix branch for master would be prefixed by hotfix/
  $ git checkout -b feature/my-feature develop
  • Please create commits containing related changes. For example, two different bugfixes should produce two separate commits. A feature should be made of commits splitted by logical chunks (no half-done changes). Use your best judgement as to how many commits your changes require.

  • Write insightful and descriptive commit messages. It lets us and future contributors quickly understand your changes without having to read your changes. Please provide a summary in the first line (50-72 characters) and eventually, go to greater lengths in your message's body. A good example can be found in Angular commit message format.

  • Please include the appropriate test cases for your patch.

  • Make sure all tests pass before submitting your changes.

  • Rebase your commits. It may be that new commits have been introduced on develop. Rebasing will update your branch with the most recent code and make your changes easier to review:

    $ git fetch
    $ git rebase origin/develop
    
  • Push your changes:

    $ git push origin -u feature/my-feature
    
  • Open a pull request against the develop branch.

  • If we suggest changes:

    • Please make the required updates (after discussion if any)

    • Only create new commits if it makes sense. Generally, you will want to amend your latest commit or rebase your branch after the new changes:

      $ git rebase -i develop
      # choose which commits to edit and perform the updates
      
    • Re-run the tests

    • Force push to your branch:

      $ git push origin feature/my-feature -f
      

Licence

Copyright 2016 bee authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.