1 Star 0 Fork 0

人人如龙 / go-starter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Go Starter

Go-starter allows to bootstrap a new project from a template. It uses Git repositories as templates and is shipped with batch of utilities to make bootstarpping easier.

Installation

Download latest release from release page using one of the commands below.

Mac OS

curl https://github.com/adobe/go-starter/releases/latest/download/go-starter-darwin-amd64.tgz \
  -sSfL -o go-starter.tgz

Linux

curl https://github.com/adobe/go-starter/releases/latest/download/go-starter-linux-amd64.tgz \
  -sSfL -o go-starter.tgz

Unpack content of the archive to a directory listed in $PATH. The archive includes multiple binaries shipped with go-starter.

tar -xvzf go-starter.tgz -C /usr/local/bin
rm go-starter.tgz

Run go-starter to verify it's installed correctly.

Usage

Run go-starter with template repository URL and path where you would like to create a new project, for example:

go-starter https://github.com/adobe/go-service-starter awesome-project

You can specify full GitHub URL or just repository name (like so adobe/go-service-starter).

Now, go-starter will clone go-service-starter into ./awesome-project directory and run tasks defined in .starter.yml. See "Templates" for more details.

Advanced usage

You can skip cloning, for example if template is already cloned, but task failed to execute by passing -skip-clone flag.

You can also pass additional variables (or pre-define variables instead of entering them using prompt) using -var flag.

Templates

Templates are regular Git repositories like this one. If you try to use go-starter with random repository it will just clone it to your computer. To make use of go-starter you would need to let it know how to "post-process" template repository after it has been cloned. To do so, you need to define .starter.yml configuration file.

After go-starter clones repository it tries to load .starter.yml to execute additional actions and turn template into a project. This configuration file defines two sections:

  • questions - list of questions to be asked from user, for example: project name, binary name, team etc
  • tasks - list of commands to be executed (these can be globally installed binaries, or binaries packed with template itself)

Here is an example of .starter.yml:

questions:
  - message: Application name
    name: "application_name"
    type: input
    regexp: ^[a-z0-9\-]+$
    help_msg: Must be lowercase characters or digits or hyphens
  - message: GitHub owners
    name: "github_owners"
    type: input
    regexp: ^[a-z0-9\-]+$
    help_msg: Must be lowercase characters or digits or hyphens

tasks:
  - command: [ "go-starter-replace" ]
  - command: [ "rm", ".starter.yml" ]

This file defines two questions, asking user to enter application_name and github_owners variables. Then, go-starter will execute go-starter-replace binary (shipped with go-starter) to replace placeholders in the files of the template, turning generic tempalte into something more specific to the project. Finally it will use standard rm command to remove .starter.yml.

Each template may contain custom tasks placed in .starter folder. For example, you can create a bash script which would generate CODEOWNERS file and place it under .starter/make-owners. Then, add it as tasks in .starter.yml like so:

...

tasks:
...
  - command: [ "./.starter/make-owners" ]

Custom scripts may access variables (answers to the questions) through environment variables. They are uppercased and prefixed with STARTER_. Following example above, ./.starter/make-owners may get github_owners variable using STARTER_GITHUB_OWNERS environment variable.

Build-in tasks

Go-starter ships with few additional binaries which can be used as tasks in .starter.yml.

go-starter-replace

This binary recursively goes through files in current folder and replaces placeholders to variable values in files and their names. By default, placeholders are surrounded by < and >.

go-starter-github

This binary automatically created GitHub repository, initiates local Git repository, adds GitHub remote and pushes changes to GitHub.

go-starter-drone

This binary configures drone integration and runs first build.

MIT License © Copyright 2019 Adobe. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/openagi/go-starter.git
git@gitee.com:openagi/go-starter.git
openagi
go-starter
go-starter
master

搜索帮助