Skip to content

Commit

Permalink
WIP - change command
Browse files Browse the repository at this point in the history
  • Loading branch information
pior committed Jun 1, 2018
1 parent 6aebb91 commit 23689ce
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 91 deletions.
2 changes: 1 addition & 1 deletion DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ Initialize the shell:

```bash
# DAD_DEBUG=1
eval "$(dad --init)"
eval "$(bud --init)"
```
58 changes: 29 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# Dad
# DevBuddy

[![Go Report Card](https://goreportcard.com/badge/github.com/pior/dad)](https://goreportcard.com/report/github.com/pior/dad)
[![CircleCI](https://circleci.com/gh/pior/dad.svg?style=svg)](https://circleci.com/gh/pior/dad)
[![GitHub Release](https://img.shields.io/github/release/pior/dad.svg)](https://github.com/pior/dad/releases/latest)
[![GitHub Release Date](https://img.shields.io/github/release-date/pior/dad.svg)](https://github.com/pior/dad/releases/latest)
[![Go Report Card](https://goreportcard.com/badge/github.com/devbuddy/devbuddy)](https://goreportcard.com/report/github.com/devbuddy/devbuddy)
[![CircleCI](https://circleci.com/gh/devbuddy/devbuddy.svg?style=svg)](https://circleci.com/gh/devbuddy/devbuddy)
[![GitHub Release](https://img.shields.io/github/release/devbuddy/devbuddy.svg)](https://github.com/devbuddy/devbuddy/releases/latest)
[![GitHub Release Date](https://img.shields.io/github/release-date/devbuddy/devbuddy.svg)](https://github.com/devbuddy/devbuddy/releases/latest)

## What is this?

**Dad** is an open-source implementation of an amazing internal tool developed at
**DevBuddy** is an open-source implementation of an amazing internal tool developed at
[Shopify](https://engineering.shopify.com) called "**Dev**".

The first goal of this tools is to automate the **setup** tasks required to work on a project.

With **Dad**, pushing a change on a project you never touched look like this:
With **DevBuddy**, pushing a change on a project you never touched look like this:

- `dad clone pior/dad`
- `dad up`
- `bud clone devbuddy/devbuddy`
- `bud up`
- `git commit`
- `dad test`
- `bud test`
- `git push`

## Status and progress

**Dad** is mostly useful for Python and Go projects. More languages will be natively
supported. Additional automatic tasks will also be implemented, making **Dad** also
**DevBuddy** is mostly useful for Python and Go projects. More languages will be natively
supported. Additional automatic tasks will also be implemented, making **DevBuddy** also
useful for languages without native support.

See the project config [documentation](docs/Config.md).
Expand Down Expand Up @@ -54,7 +54,7 @@ Others
- Notification when important files (eg: `requirements.txt`) are updated locally
(eg: by `git pull`)
- A `help` command to guide a new developer based on `dev.yml`
- A `upgrade` command to auto-upgrade **Dad**
- A `upgrade` command to auto-upgrade **DevBuddy**

### Hosting platform:

Expand All @@ -72,24 +72,24 @@ Others
## Install

```bash
$ bash -c "$(curl -sL https://raw.githubusercontent.com/pior/dad/master/install.sh)"
$ bash -c "$(curl -sL https://raw.githubusercontent.com/devbuddy/devbuddy/master/install.sh)"
```

Uninstall it:
```bash
$ sudo rm /usr/local/bin/dad
$ sudo rm /usr/local/bin/bud
```

## Setup

★ Install the shell integration (in `~/.bash_profile`):
```bash
eval "$(dad --shell-init --with-completion)"
eval "$(bud --shell-init --with-completion)"
```

A safer version:
```bash
type dad > /dev/null 2> /dev/null && eval "$(dad --shell-init --with-completion)"
type bud > /dev/null 2> /dev/null && eval "$(bud --shell-init --with-completion)"
```

## Usage
Expand All @@ -112,13 +112,13 @@ commands:
desc: Lint the project
run: script/lint
```
See Dad own [dev.yml](dev.yml)
See DevBuddy own [dev.yml](dev.yml)

```bash
$ dad
$ bud
Usage:
dad [flags]
dad [command]
bud [flags]
bud [command]

Available Commands:
cd Jump to a local project
Expand All @@ -131,12 +131,12 @@ Available Commands:
up Ensure the project is up and running

Flags:
-h, --help help for dad
-h, --help help for bud
--shell-init Shell initialization
--version version for dad
--version version for bud
--with-completion Enable completion during initialization

Use "dad [command] --help" for more information about a command.
Use "bud [command] --help" for more information about a command.
```

## Development
Expand All @@ -145,7 +145,7 @@ Use "dad [command] --help" for more information about a command.
```bash
~ $ mkdir -p ~/src/github.com/pior
~ $ cd ~/src/github.com/pior
~/src/github.com/pior $ git clone git@github.com:pior/dad.git
~/src/github.com/pior $ git clone git@github.com:devbuddy/devbuddy.git
```

★ Fetch the dependencies (in `vendor`)
Expand All @@ -162,11 +162,11 @@ Use "dad [command] --help" for more information about a command.

To show the debug messages, add this before in your environment:
```bash
export DAD_DEBUG=1
export BUD_DEBUG=1
```
Or:
```bash
$ dad-enable-debug # dad-disable-debug
$ bud-enable-debug # bud-disable-debug
```

### Release
Expand All @@ -184,8 +184,8 @@ Expected:
1. The CI process will test the release
2. The CI process will publish macOS/Linux binaries to the Github Releases page

Updating the [install.sh](https://github.com/pior/dad/blob/master/install.sh) script is probably a good idea.
Updating the [install.sh](https://github.com/devbuddy/devbuddy/blob/master/install.sh) script is probably a good idea.

## License

[MIT](https://github.com/pior/dad/blob/master/LICENSE)
[MIT](https://github.com/devbuddy/devbuddy/blob/master/LICENSE)
File renamed without changes.
2 changes: 1 addition & 1 deletion dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ up:
commands:
testup:
desc: Build, install and run the development version
run: go install && dad up
run: go install && bud up

test:
desc: Run the unittests
Expand Down
10 changes: 5 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -eu

VERSION="v0.3.0"
DEST="/usr/local/bin"
SHELL_LINE='eval "$(dad --shell-init --with-completion)"'
SHELL_LINE='eval "$(bud --shell-init --with-completion)"'

YELLOW="\033[1;33m"
BLUE="\033[1;34m"
Expand Down Expand Up @@ -41,22 +41,22 @@ header() {

banner() {
echo ""
echo -e "${YELLOW}Welcome to Dad installer!${RESET}"
echo -e "${YELLOW}Welcome to DevBuddy installer!${RESET}"
}

instructions() {
echo ""
echo -e "${YELLOW}Good!${RESET}\n"
echo -e "${WHITE}Now, all you need is to add this to your bash .profile:${RESET}\n"
echo -e " ${CODE}" ${SHELL_LINE} "${RESET}\n"
echo -e "Report any issue to ${LINK}https://github.com/pior/dad/issues${RESET}\n"
echo -e "Report any issue to ${LINK}https://github.com/devbuddy/devbuddy/issues${RESET}\n"
}

main() {
banner

header "Downloading binary from Github"
URL="https://github.com/pior/dad/releases/download/${VERSION}/dad-$(make_variant)"
URL="https://github.com/devbuddy/devbuddy/releases/download/${VERSION}/bud-$(make_variant)"
TMPFILE=`mktemp`
curl -L -# --fail "${URL}" -o "${TMPFILE}"

Expand All @@ -68,7 +68,7 @@ main() {
read -p "Correct? [enter]"

header "Installing to ${DEST}"
sudo install "${TMPFILE}" "${DEST}/dad"
sudo install "${TMPFILE}" "${DEST}/bud"

[[ -e "${TMPFILE}" ]] && unlink "${TMPFILE}"

Expand Down
2 changes: 1 addition & 1 deletion script/buildall
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LDFLAGS="-s -w -X \"main.Version=${VERSION}\""

for GOOS in linux darwin; do
export GOOS
NAME=dad-${GOOS}-amd64
NAME=bud-${GOOS}-amd64

echo "Building $NAME"
GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "$LDFLAGS" -o dist/${NAME}
Expand Down
18 changes: 9 additions & 9 deletions tests/cd_command_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -u
oneTimeSetUp() {
# This runs in a subshell (subprocess).
# Even if Dad was enabled in the parent shell, we need to enable it here.
eval "$(dad --shell-init)"
eval "$(bud --shell-init)"
}

setUp() {
Expand All @@ -16,42 +16,42 @@ setUp() {
}

testCdExactMatch() {
dad cd dadorgtest/repotest
bud cd dadorgtest/repotest
assertEquals "cd to project directory" ~/src/github.com/dadorgtest/repotest "$PWD"

dad cd dadorgtest/repotest2
bud cd dadorgtest/repotest2
assertEquals "cd to second project directory" ~/src/github.com/dadorgtest/repotest2 "$PWD"
}

# The search will stop at the first match

testCdByExactRepo() {
dad cd repotest2
bud cd repotest2
assertEquals "cd to project directory" ~/src/github.com/dadorgtest/repotest2 "$PWD"
}

testCdByExactOrg() {
dad cd dadorgtest
bud cd dadorgtest
assertEquals "cd to project directory" ~/src/github.com/dadorgtest/repotest "$PWD"
}

testCdByPrefixRepo() {
dad cd repotes
bud cd repotes
assertEquals "cd to project directory" ~/src/github.com/dadorgtest/repotest "$PWD"
}

testCdByPrefixOrg() {
dad cd dadorgtes
bud cd dadorgtes
assertEquals "cd to project directory" ~/src/github.com/dadorgtest/repotest "$PWD"
}

testCdBySubstringRepo() {
dad cd epotest2
bud cd epotest2
assertEquals "cd to project directory" ~/src/github.com/dadorgtest/repotest2 "$PWD"
}

testCdBySubstringOrg() {
dad cd adorgtest
bud cd adorgtest
assertEquals "cd to project directory" ~/src/github.com/dadorgtest/repotest "$PWD"
}

Expand Down
6 changes: 3 additions & 3 deletions tests/create_command_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -u
oneTimeSetUp() {
# This runs in a subshell (subprocess).
# Even if Dad was enabled in the parent shell, we need to enable it here.
eval "$(dad --shell-init)"
eval "$(bud --shell-init)"
}

setUp() {
Expand All @@ -18,14 +18,14 @@ tearDown() {
}

testCreate() {
dad create dadorg/repo
bud create dadorg/repo

assertTrue "directory was created" "[ -d ~/src/github.com/dadorg/repo ]"
assertEquals "cd to project directory" ~/src/github.com/dadorg/repo "$PWD"
}

testCreateExisting() {
dad create dadorg/repo2
bud create dadorg/repo2

assertEquals "cd to project directory" ~/src/github.com/dadorg/repo2 "$PWD"
}
Expand Down
22 changes: 11 additions & 11 deletions tests/custom_commands_test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set -u

oneTimeSetUp() {
eval "$(dad --shell-init)"
eval "$(bud --shell-init)"
}

setUp() {
Expand All @@ -23,37 +23,37 @@ YAML
}

testSimple() {
dad mycmd
bud mycmd

assertEquals "somefile was created" "TESTTEST" "$(cat somefile)"
}

testArguments() {
output=$(dad echo ARG1 ARG2)
output=$(bud echo ARG1 ARG2)

assertEquals "command called with arguments" "PREFIX ARG1 ARG2" "$output"
}

testSuccess() {
dad success
bud success

assertEquals "dad return with the right exit code" 0 $?
assertEquals "bud return with the right exit code" 0 $?
}

testFailure() {
dad failure
bud failure

assertEquals "dad return with the right exit code" 1 $?
assertEquals "bud return with the right exit code" 1 $?
}

testRunInProjectRoot() {
dad isprojectroot
assertEquals "dad isprojectroot command succeed in project root" 0 $?
bud isprojectroot
assertEquals "bud isprojectroot command succeed in project root" 0 $?

mkdir -p subdir
cd subdir
dad isprojectroot
assertEquals "dad custom commands run in project root" 0 $?
bud isprojectroot
assertEquals "bud custom commands run in project root" 0 $?
}

SHUNIT_PARENT=$0
Expand Down
6 changes: 3 additions & 3 deletions tests/inspect_command_test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set -u

oneTimeSetUp() {
eval "$(dad --shell-init)"
eval "$(bud --shell-init)"
}

setUp() {
Expand All @@ -16,13 +16,13 @@ up:
- pip: [requirements.txt]
YAML

output=$(dad inspect)
output=$(bud inspect)
rc=$?
assertEquals "command failed" 0 $rc
}

testWithouthManifest() {
output=$(dad inspect)
output=$(bud inspect)
rc=$?
assertEquals "command didn't fail" 1 $rc
}
Expand Down

0 comments on commit 23689ce

Please sign in to comment.