1
0
Fork 0
mirror of synced 2024-06-15 13:51:08 -04:00

Merge branch 'upstream_master'

This commit is contained in:
Andreas Schmidt 2019-11-23 15:19:23 +01:00
commit 8f789f011c
No known key found for this signature in database
GPG key ID: FEE0A611BEA6DEA0
12 changed files with 143 additions and 47 deletions

View file

@ -1,26 +1,15 @@
language: python language: python
python:
- "2.7"
- "pypy"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "nightly"
- "pypy3"
sudo: false sudo: false
.mixins:
- &xenial
dist: xenial
jobs:
include:
- python: "2.7"
- python: "pypy"
- python: "3.2"
- python: "3.3"
- python: "3.4"
- python: "3.5"
- python: "3.6"
- <<: *xenial
python: "3.7"
- <<: *xenial
python: "3.8-dev"
- python: "nightly"
- python: "pypy3"
script: script:
- ./test/test_travis - ./test/test_travis

View file

@ -1,12 +1,18 @@
Dotbot # Dotbot [![Build Status](https://travis-ci.org/anishathalye/dotbot.svg?branch=master)](https://travis-ci.org/anishathalye/dotbot)
======
Dotbot makes installing your dotfiles as easy as `git clone $url && cd dotfiles Dotbot makes installing your dotfiles as easy as `git clone $url && cd dotfiles
&& ./install`, even on a freshly installed system! && ./install`, even on a freshly installed system!
- [Rationale](#rationale)
- [Getting Started](#getting-started)
- [Configuration](#configuration)
- [Directives](#directives) ([Link](#link), [Create](#create), [Shell](#shell), [Clean](#clean), [Defaults](#defaults))
- [Plugins](#plugins)
- [Wiki][wiki]
--- ---
[![Build Status](https://travis-ci.org/anishathalye/dotbot.svg?branch=master)](https://travis-ci.org/anishathalye/dotbot) ## Rationale
Dotbot is a tool that bootstraps your dotfiles (it's a [Dot]files Dotbot is a tool that bootstraps your dotfiles (it's a [Dot]files
[bo]o[t]strapper, get it?). It does *less* than you think, because version [bo]o[t]strapper, get it?). It does *less* than you think, because version
@ -20,8 +26,7 @@ Dotbot is VCS-agnostic -- it doesn't make any attempt to manage your dotfiles.
If you want an in-depth tutorial about organizing your dotfiles, see this [blog If you want an in-depth tutorial about organizing your dotfiles, see this [blog
post][managing-dotfiles-post]. post][managing-dotfiles-post].
Get Running in 5 Minutes ## Getting Started
------------------------
### Starting Fresh? ### Starting Fresh?
@ -40,6 +45,7 @@ If you're using **Git**, you can add Dotbot as a submodule:
cd ~/.dotfiles # replace with the path to your dotfiles cd ~/.dotfiles # replace with the path to your dotfiles
git init # initialize repository if needed git init # initialize repository if needed
git submodule add https://github.com/anishathalye/dotbot git submodule add https://github.com/anishathalye/dotbot
git config -f .gitmodules submodule.dotbot.ignore dirty # ignore dirty commits in the submodule
cp dotbot/tools/git-submodule/install . cp dotbot/tools/git-submodule/install .
touch install.conf.yaml touch install.conf.yaml
``` ```
@ -104,6 +110,10 @@ The conventional name for the configuration file is `install.conf.yaml`.
~/.vim: vim ~/.vim: vim
~/.vimrc: vimrc ~/.vimrc: vimrc
- create:
- ~/downloads
- ~/.vim/undo-history
- shell: - shell:
- [git submodule update --init --recursive, Installing submodules] - [git submodule update --init --recursive, Installing submodules]
``` ```
@ -113,14 +123,13 @@ in JSON (which is a subset of YAML). [Here][json-equivalent] is the JSON
[equivalent][json2yaml] of the YAML configuration given above. JSON [equivalent][json2yaml] of the YAML configuration given above. JSON
configuration files are conventionally named `install.conf.json`. configuration files are conventionally named `install.conf.json`.
Configuration ## Configuration
-------------
Dotbot uses YAML or JSON-formatted configuration files to let you specify how Dotbot uses YAML or JSON-formatted configuration files to let you specify how
to set up your dotfiles. Currently, Dotbot knows how to [link](#link) files and to set up your dotfiles. Currently, Dotbot knows how to [link](#link) files and
folders, execute [shell](#shell) commands, and [clean](#clean) directories of folders, [create](#create) folders, execute [shell](#shell) commands, and
broken symbolic links. Dotbot also supports user [plugins](#plugins) for custom [clean](#clean) directories of broken symbolic links. Dotbot also supports user
commands. [plugins](#plugins) for custom commands.
**Ideally, bootstrap configurations should be idempotent. That is, the **Ideally, bootstrap configurations should be idempotent. That is, the
installer should be able to be run multiple times without causing any installer should be able to be run multiple times without causing any
@ -140,6 +149,8 @@ configuration file is not behaving as you expect, try inspecting the
Also, note that `~` in YAML is the same as `null` in JSON. If you want a single Also, note that `~` in YAML is the same as `null` in JSON. If you want a single
character string containing a tilde, make sure to enclose it in quotes: `'~'` character string containing a tilde, make sure to enclose it in quotes: `'~'`
## Directives
### Link ### Link
Link commands specify how files and directories should be symbolically linked. Link commands specify how files and directories should be symbolically linked.
@ -182,6 +193,9 @@ Available extended configuration parameters:
~/.zshrc: ~/.zshrc:
force: true force: true
path: zshrc path: zshrc
~/.hammerspoon:
if: '[ `uname` = Darwin ]'
path: hammerspoon
``` ```
If the source location is omitted or set to `null`, Dotbot will use the If the source location is omitted or set to `null`, Dotbot will use the
@ -218,6 +232,25 @@ the following config files equivalent:
relink: true relink: true
``` ```
### Create
Create commands specify empty directories to be created. This can be useful
for scaffolding out folders or parent folder structure required for various
apps, plugins, shell commands, etc.
#### Format
Create commands are specified as an array of directories to be created.
#### Example
```yaml
- create:
- ~/projects
- ~/downloads
- ~/.vim/undo-history
```
### Shell ### Shell
Shell commands specify shell commands to be run. Shell commands are run in the Shell commands specify shell commands to be run. Shell commands are run in the
@ -242,8 +275,8 @@ command itself.
```yaml ```yaml
- shell: - shell:
- mkdir -p ~/src - chsh -s $(which zsh)
- [mkdir -p ~/downloads, Creating downloads directory] - [chsh -s $(which zsh), Making zsh the default shell]
- -
command: read var && echo Your variable is $var command: read var && echo Your variable is $var
stdin: true stdin: true
@ -347,14 +380,12 @@ Wiki
Check out the [Dotbot wiki][wiki] for more information, tips and tricks, Check out the [Dotbot wiki][wiki] for more information, tips and tricks,
user-contributed plugins, and more. user-contributed plugins, and more.
Contributing ## Contributing
------------
Do you have a feature request, bug report, or patch? Great! See Do you have a feature request, bug report, or patch? Great! See
[CONTRIBUTING.md][contributing] for information on what you can do about that. [CONTRIBUTING.md][contributing] for information on what you can do about that.
Packaging ## Packaging
---------
1. Update version information. 1. Update version information.
@ -362,8 +393,7 @@ Packaging
3. Sign and upload the package using ``twine upload -s dist/*``. 3. Sign and upload the package using ``twine upload -s dist/*``.
License ## License
-------
Copyright (c) 2014-2019 Anish Athalye. Released under the MIT License. See Copyright (c) 2014-2019 Anish Athalye. Released under the MIT License. See
[LICENSE.md][license] for details. [LICENSE.md][license] for details.

View file

@ -7,9 +7,9 @@
# is useful because we don't know the name of the python binary. # is useful because we don't know the name of the python binary.
''':' # begin python string; this line is interpreted by the shell as `:` ''':' # begin python string; this line is interpreted by the shell as `:`
which python >/dev/null 2>&1 && exec python "$0" "$@" command -v python >/dev/null 2>&1 && exec python "$0" "$@"
which python3 >/dev/null 2>&1 && exec python3 "$0" "$@" command -v python3 >/dev/null 2>&1 && exec python3 "$0" "$@"
which python2 >/dev/null 2>&1 && exec python2 "$0" "$@" command -v python2 >/dev/null 2>&1 && exec python2 "$0" "$@"
>&2 echo "error: cannot find python" >&2 echo "error: cannot find python"
exit 1 exit 1
''' '''

View file

@ -1,4 +1,4 @@
from .cli import main from .cli import main
from .plugin import Plugin from .plugin import Plugin
__version__ = '1.15.0' __version__ = '1.16.0'

View file

@ -56,7 +56,7 @@ def main():
log.use_color(False) log.use_color(False)
plugin_directories = list(options.plugin_dirs) plugin_directories = list(options.plugin_dirs)
if not options.disable_built_in_plugins: if not options.disable_built_in_plugins:
from .plugins import Clean, Link, Shell, Plugins from .plugins import Clean, Create, Link, Shell, Plugins
plugin_paths = [] plugin_paths = []
for directory in plugin_directories: for directory in plugin_directories:
for plugin_path in glob.glob(os.path.join(directory, '*.py')): for plugin_path in glob.glob(os.path.join(directory, '*.py')):

View file

@ -1,4 +1,5 @@
from .clean import Clean from .clean import Clean
from .create import Create
from .link import Link from .link import Link
from .shell import Shell from .shell import Shell
from .plugins import Plugins from .plugins import Plugins

53
dotbot/plugins/create.py Normal file
View file

@ -0,0 +1,53 @@
import os
import glob
import shutil
import dotbot
import subprocess
class Create(dotbot.Plugin):
'''
Create empty paths.
'''
_directive = 'create'
def can_handle(self, directive):
return directive == self._directive
def handle(self, directive, data):
if directive != self._directive:
raise ValueError('Create cannot handle directive %s' % directive)
return self._process_paths(data)
def _process_paths(self, paths):
success = True
for path in paths:
path = os.path.expandvars(os.path.expanduser(path))
success &= self._create(path)
if success:
self._log.info('All paths have been set up')
else:
self._log.error('Some paths were not successfully set up')
return success
def _exists(self, path):
'''
Returns true if the path exists.
'''
path = os.path.expanduser(path)
return os.path.exists(path)
def _create(self, path):
success = True
if not self._exists(path):
self._log.debug('Trying to create path %s' % path)
try:
self._log.lowinfo('Creating path %s' % path)
os.makedirs(path)
except OSError:
self._log.warning('Failed to create path %s' % path)
success = False
else:
self._log.lowinfo('Path exists %s' % path)
return success

@ -1 +1 @@
Subproject commit 7e026bfee9cc0bddeb1bbca0c4a0bcd826c2bfdf Subproject commit 0f64cbfa54b0b22dc7b776b7b98a7cd657e84d78

View file

@ -73,7 +73,7 @@ setup(
], ],
install_requires=[ install_requires=[
'PyYAML>=3.12,<4', 'PyYAML>=5.1.2,<6',
], ],
# To provide executable scripts, use entry points in preference to the # To provide executable scripts, use entry points in preference to the

2
test/Vagrantfile vendored
View file

@ -1,5 +1,5 @@
Vagrant.configure(2) do |config| Vagrant.configure(2) do |config|
config.vm.box = 'debian/stretch64' config.vm.box = 'debian/buster64'
# sync by copying for isolation # sync by copying for isolation
config.vm.synced_folder "..", "/dotbot", type: "rsync" config.vm.synced_folder "..", "/dotbot", type: "rsync"

23
test/tests/create.bash Normal file
View file

@ -0,0 +1,23 @@
test_description='create folders'
. '../test-lib.bash'
test_expect_success 'run' '
run_dotbot <<EOF
- create:
- ~/somedir
- ~/nested/somedir
EOF
'
test_expect_success 'test' '
[ -d ~/somedir ] &&
[ -d ~/nested/somedir ]
'
test_expect_success 'run 2' '
run_dotbot <<EOF
- create:
- ~/somedir
- ~/nested/somedir
EOF
'

View file

@ -31,7 +31,7 @@ touch ~/tmp_bin/python &&
chmod +x ~/tmp_bin/python && chmod +x ~/tmp_bin/python &&
cat >> ~/tmp_bin/python <<EOF cat >> ~/tmp_bin/python <<EOF
#!$HOME/tmp_bin/bash #!$HOME/tmp_bin/bash
exec $(which python) exec $(command -v python)
EOF EOF
' '