vagrant-trellis-sequel 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github_changelog_generator +2 -0
- data/.gitignore +14 -0
- data/.hound.yml +4 -0
- data/.rubocop.rails.yml +137 -0
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile +30 -0
- data/LICENSE.txt +21 -0
- data/README.md +124 -0
- data/Rakefile +3 -0
- data/lib/vagrant-trellis-sequel.rb +4 -0
- data/lib/vagrant_plugins/trellis_sequel/commands/open.rb +81 -0
- data/lib/vagrant_plugins/trellis_sequel/commands/root.rb +58 -0
- data/lib/vagrant_plugins/trellis_sequel/identity.rb +23 -0
- data/lib/vagrant_plugins/trellis_sequel/plugin.rb +18 -0
- data/lib/vagrant_plugins/trellis_sequel/template.spf +42 -0
- data/vagrant-trellis-sequel.gemspec +29 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b3a285c74f4eac02b78eb50dc7f6dd1cf6d3313d
|
4
|
+
data.tar.gz: a5f6b2886d51af5164ed47e97d073e9b30792655
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 44ac6679fd2bbc9fba3a70d5cd8f5958249adbf702d1ca7f89ef60630716c3c35d8fac4b29d997918b7adf831e66b60aab5632c9166e02f0bb6bed198e6e8a96
|
7
|
+
data.tar.gz: e828a73f5d677bf8b97d6c779e31309f5b1f42197c828f68476f45a99baefad8b04b52516175388598b67b624581ceac45bf40838b68b03cbaed5e7aae242fee
|
data/.gitignore
ADDED
data/.hound.yml
ADDED
data/.rubocop.rails.yml
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.2
|
3
|
+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
4
|
+
# to ignore them, so only the ones explicitly set in this file are enabled.
|
5
|
+
DisabledByDefault: true
|
6
|
+
Exclude:
|
7
|
+
- '**/templates/**/*'
|
8
|
+
- '**/vendor/**/*'
|
9
|
+
- 'actionpack/lib/action_dispatch/journey/parser.rb'
|
10
|
+
|
11
|
+
# Prefer &&/|| over and/or.
|
12
|
+
Style/AndOr:
|
13
|
+
Enabled: true
|
14
|
+
|
15
|
+
# Do not use braces for hash literals when they are the last argument of a
|
16
|
+
# method call.
|
17
|
+
Style/BracesAroundHashParameters:
|
18
|
+
Enabled: true
|
19
|
+
EnforcedStyle: context_dependent
|
20
|
+
|
21
|
+
# Align `when` with `case`.
|
22
|
+
Layout/CaseIndentation:
|
23
|
+
Enabled: true
|
24
|
+
|
25
|
+
# Align comments with method definitions.
|
26
|
+
Layout/CommentIndentation:
|
27
|
+
Enabled: true
|
28
|
+
|
29
|
+
Layout/EmptyLineAfterMagicComment:
|
30
|
+
Enabled: true
|
31
|
+
|
32
|
+
# In a regular class definition, no empty lines around the body.
|
33
|
+
Layout/EmptyLinesAroundClassBody:
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
# In a regular method definition, no empty lines around the body.
|
37
|
+
Layout/EmptyLinesAroundMethodBody:
|
38
|
+
Enabled: true
|
39
|
+
|
40
|
+
# In a regular module definition, no empty lines around the body.
|
41
|
+
Layout/EmptyLinesAroundModuleBody:
|
42
|
+
Enabled: true
|
43
|
+
|
44
|
+
Layout/FirstParameterIndentation:
|
45
|
+
Enabled: true
|
46
|
+
|
47
|
+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
48
|
+
Style/HashSyntax:
|
49
|
+
Enabled: true
|
50
|
+
|
51
|
+
# Method definitions after `private` or `protected` isolated calls need one
|
52
|
+
# extra level of indentation.
|
53
|
+
Layout/IndentationConsistency:
|
54
|
+
Enabled: true
|
55
|
+
EnforcedStyle: rails
|
56
|
+
|
57
|
+
# Two spaces, no tabs (for indentation).
|
58
|
+
Layout/IndentationWidth:
|
59
|
+
Enabled: true
|
60
|
+
|
61
|
+
Layout/SpaceAfterColon:
|
62
|
+
Enabled: true
|
63
|
+
|
64
|
+
Layout/SpaceAfterComma:
|
65
|
+
Enabled: true
|
66
|
+
|
67
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
68
|
+
Enabled: true
|
69
|
+
|
70
|
+
Layout/SpaceAroundKeyword:
|
71
|
+
Enabled: true
|
72
|
+
|
73
|
+
Layout/SpaceAroundOperators:
|
74
|
+
Enabled: true
|
75
|
+
|
76
|
+
Layout/SpaceBeforeFirstArg:
|
77
|
+
Enabled: true
|
78
|
+
|
79
|
+
# Defining a method with parameters needs parentheses.
|
80
|
+
Style/MethodDefParentheses:
|
81
|
+
Enabled: true
|
82
|
+
|
83
|
+
Style/FrozenStringLiteralComment:
|
84
|
+
Enabled: true
|
85
|
+
EnforcedStyle: always
|
86
|
+
Exclude:
|
87
|
+
- 'actionview/test/**/*.builder'
|
88
|
+
- 'actionview/test/**/*.ruby'
|
89
|
+
- 'actionpack/test/**/*.builder'
|
90
|
+
- 'actionpack/test/**/*.ruby'
|
91
|
+
- 'activestorage/db/migrate/**/*.rb'
|
92
|
+
|
93
|
+
# Use `foo {}` not `foo{}`.
|
94
|
+
Layout/SpaceBeforeBlockBraces:
|
95
|
+
Enabled: true
|
96
|
+
|
97
|
+
# Use `foo { bar }` not `foo {bar}`.
|
98
|
+
Layout/SpaceInsideBlockBraces:
|
99
|
+
Enabled: true
|
100
|
+
|
101
|
+
# Use `{ a: 1 }` not `{a:1}`.
|
102
|
+
Layout/SpaceInsideHashLiteralBraces:
|
103
|
+
Enabled: true
|
104
|
+
|
105
|
+
Layout/SpaceInsideParens:
|
106
|
+
Enabled: true
|
107
|
+
|
108
|
+
# Check quotes usage according to lint rule below.
|
109
|
+
Style/StringLiterals:
|
110
|
+
Enabled: true
|
111
|
+
EnforcedStyle: double_quotes
|
112
|
+
|
113
|
+
# Detect hard tabs, no hard tabs.
|
114
|
+
Layout/Tab:
|
115
|
+
Enabled: true
|
116
|
+
|
117
|
+
# Blank lines should not have any spaces.
|
118
|
+
Layout/TrailingBlankLines:
|
119
|
+
Enabled: true
|
120
|
+
|
121
|
+
# No trailing whitespace.
|
122
|
+
Layout/TrailingWhitespace:
|
123
|
+
Enabled: true
|
124
|
+
|
125
|
+
# Use quotes for string literals when they are enough.
|
126
|
+
Style/UnneededPercentQ:
|
127
|
+
Enabled: true
|
128
|
+
|
129
|
+
# Align `end` with the matching keyword or starting expression except for
|
130
|
+
# assignments, where it should be aligned with the LHS.
|
131
|
+
Lint/EndAlignment:
|
132
|
+
Enabled: true
|
133
|
+
EnforcedStyleAlignWith: variable
|
134
|
+
|
135
|
+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
136
|
+
Lint/RequireParentheses:
|
137
|
+
Enabled: true
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
## Our Standards
|
8
|
+
|
9
|
+
Examples of behavior that contributes to creating a positive environment include:
|
10
|
+
|
11
|
+
* Using welcoming and inclusive language
|
12
|
+
* Being respectful of differing viewpoints and experiences
|
13
|
+
* Gracefully accepting constructive criticism
|
14
|
+
* Focusing on what is best for the community
|
15
|
+
* Showing empathy towards other community members
|
16
|
+
|
17
|
+
Examples of unacceptable behavior by participants include:
|
18
|
+
|
19
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
20
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
21
|
+
* Public or private harassment
|
22
|
+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
23
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
24
|
+
|
25
|
+
## Our Responsibilities
|
26
|
+
|
27
|
+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
28
|
+
|
29
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
30
|
+
|
31
|
+
## Scope
|
32
|
+
|
33
|
+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
34
|
+
|
35
|
+
## Enforcement
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at vagrant-trellis-sequel@typist.tech. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
38
|
+
|
39
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
40
|
+
|
41
|
+
## Attribution
|
42
|
+
|
43
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
44
|
+
|
45
|
+
[homepage]: http://contributor-covenant.org
|
46
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
5
|
+
|
6
|
+
# To make `$ bundle exec vagrant` works
|
7
|
+
embedded_directories = %w[/Applications/Vagrant/embedded /opt/vagrant/embedded]
|
8
|
+
embedded_directories.each do |path|
|
9
|
+
ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"] = path if File.directory?(path)
|
10
|
+
end
|
11
|
+
|
12
|
+
unless ENV.key?("VAGRANT_INSTALLER_EMBEDDED_DIR")
|
13
|
+
$stderr.puts "Couldn't find a packaged install of vagrant, and we need this"
|
14
|
+
$stderr.puts "in order to make use of the RubyEncoder libraries."
|
15
|
+
$stderr.puts "I looked in:"
|
16
|
+
embedded_locations.each do |path|
|
17
|
+
$stderr.puts " #{path}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
group :development do
|
22
|
+
# We depend on Vagrant for development, but we don't add it as a
|
23
|
+
# gem dependency because we expect to be installed within the
|
24
|
+
# Vagrant environment itself using `vagrant plugin`.
|
25
|
+
gem "vagrant", github: "mitchellh/vagrant"
|
26
|
+
end
|
27
|
+
|
28
|
+
group :plugins do
|
29
|
+
gemspec
|
30
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Tang Rufus
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
# Vagrant Trellis Sequel
|
2
|
+
|
3
|
+
[![Gem](https://img.shields.io/gem/v/vagrant-trellis-sequel.svg)](https://rubygems.org/gems/vagrant-trellis-sequel)
|
4
|
+
[![Gem](https://img.shields.io/gem/dt/vagrant-trellis-sequel.svg)](https://rubygems.org/gems/vagrant-trellis-sequel)
|
5
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/TypistTech/vagrant-trellis-sequel.svg)](https://gemnasium.com/github.com/TypistTech/vagrant-trellis-sequel)
|
6
|
+
[![license](https://img.shields.io/github/license/TypistTech/vagrant-trellis-sequel.svg)](https://github.com/TypistTech/vagrant-trellis-sequel/blob/master/LICENSE)
|
7
|
+
[![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://www.typist.tech/donate/vagrant-trellis-sequel/)
|
8
|
+
[![Hire Typist Tech](https://img.shields.io/badge/Hire-Typist%20Tech-ff69b4.svg)](https://www.typist.tech/contact/)
|
9
|
+
|
10
|
+
Open Trellis databases in Sequel Pro with a single command
|
11
|
+
|
12
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
13
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
14
|
+
|
15
|
+
|
16
|
+
- [Installation](#installation)
|
17
|
+
- [Usage](#usage)
|
18
|
+
- [Connection Errors](#connection-errors)
|
19
|
+
- [`key_load_public: No such file or directory`](#key_load_public-no-such-file-or-directory)
|
20
|
+
- [Help Wanted!](#help-wanted)
|
21
|
+
- [Support!](#support)
|
22
|
+
- [Donate via PayPal *](#donate-via-paypal-)
|
23
|
+
- [Why don't you hire me?](#why-dont-you-hire-me)
|
24
|
+
- [Want to help in other way? Want to be a sponsor?](#want-to-help-in-other-way-want-to-be-a-sponsor)
|
25
|
+
- [Feedback](#feedback)
|
26
|
+
- [Change log](#change-log)
|
27
|
+
- [Credits](#credits)
|
28
|
+
- [Contributing](#contributing)
|
29
|
+
- [License](#license)
|
30
|
+
|
31
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
32
|
+
|
33
|
+
## Installation
|
34
|
+
|
35
|
+
```bash
|
36
|
+
$ vagrant plugin install vagrant-trellis-sequel
|
37
|
+
```
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
```bash
|
42
|
+
#Usage: vagrant trellis-sequel open [options] [vm-id]
|
43
|
+
#
|
44
|
+
# -u, --user DB_USER Required. Database username.
|
45
|
+
# -p, --password DB_PASSWORD Required. Value of db_password from group_vars/development/vault.yml
|
46
|
+
# -h, --help Print this help
|
47
|
+
|
48
|
+
# Example:
|
49
|
+
$ vagrant trellis-sequel open -u example_com -p example_dbpassword
|
50
|
+
```
|
51
|
+
|
52
|
+
## Connection Errors
|
53
|
+
|
54
|
+
If you get a connection error, the first thing to attempt to debug is to check the details that Sequel Pro gives you (under the Show Details button).
|
55
|
+
|
56
|
+
### `key_load_public: No such file or directory`
|
57
|
+
|
58
|
+
If you get this error on macOS Sierra, it's possible that you have too many SSH keys loaded into your `ssh-agent`. If you're using multiple boxes with [this setup in your SSH config](http://apple.stackexchange.com/a/264974/55070) (`AddKeysToAgent yes`), each new box you add will be added to your agent. With too many of these, SSH will hit the authentication retries limit before getting to the correct key.
|
59
|
+
|
60
|
+
The simple solution is to add this to your `~/.ssh/config` file:
|
61
|
+
|
62
|
+
```
|
63
|
+
# Disable checks on Vagrant machines
|
64
|
+
Host 127.0.0.1
|
65
|
+
# Skip adding to agent
|
66
|
+
AddKeysToAgent no
|
67
|
+
|
68
|
+
# Only use key specified on CLI
|
69
|
+
IdentitiesOnly yes
|
70
|
+
|
71
|
+
# Skip known hosts
|
72
|
+
UserKnownHostsFile /dev/null
|
73
|
+
StrictHostKeyChecking no
|
74
|
+
```
|
75
|
+
|
76
|
+
This disables using system-level keys (both from the agent, and your regular SSH keys), and disables host checks (which are not necessary for localhost). This does not affect `vagrant ssh`, which already uses these options.
|
77
|
+
|
78
|
+
## Help Wanted!
|
79
|
+
|
80
|
+
Pull requests are welcome.
|
81
|
+
|
82
|
+
- Parse database passwords from config file.
|
83
|
+
|
84
|
+
## Support!
|
85
|
+
|
86
|
+
### Donate via PayPal [![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://www.typist.tech/donate/vagrant-trellis-sequel/)
|
87
|
+
|
88
|
+
Love Vagrant Trellis Sequel? Help me maintain it, a [donation here](https://www.typist.tech/donate/vagrant-trellis-sequel/) can help with it.
|
89
|
+
|
90
|
+
### Why don't you hire me?
|
91
|
+
|
92
|
+
Ready to take freelance WordPress jobs. Contact me via the contact form [here](https://www.typist.tech/contact/) or, via email [info@typist.tech](mailto:info@typist.tech)
|
93
|
+
|
94
|
+
### Want to help in other way? Want to be a sponsor?
|
95
|
+
|
96
|
+
Contact: [Tang Rufus](mailto:tangrufus@gmail.com)
|
97
|
+
|
98
|
+
## Feedback
|
99
|
+
|
100
|
+
**Please provide feedback!** We want to make this library useful in as many projects as possible.
|
101
|
+
Please submit an [issue](https://github.com/TypistTech/vagrant-trellis-sequel/issues/new) and point out what you do and don't like, or fork the project and make suggestions.
|
102
|
+
**No issue is too small.**
|
103
|
+
|
104
|
+
## Change log
|
105
|
+
|
106
|
+
Please see [CHANGELOG](./CHANGELOG.md) for more information on what has changed recently.
|
107
|
+
|
108
|
+
## Credits
|
109
|
+
|
110
|
+
[Vagrant Trellis Sequel](https://github.com/TypistTech/vagrant-trellis-sequel) is a [Typist Tech](https://www.typist.tech) project and maintained by [Tang Rufus](https://twitter.com/Tangrufus), freelance developer for [hire](https://www.typist.tech/contact/).
|
111
|
+
|
112
|
+
Inspired from [Sequel Pro for Chassis](https://github.com/Chassis/SequelPro).
|
113
|
+
|
114
|
+
Special thanks to [the Roots team](https://roots.io/about/) whose [Trellis](https://github.com/roots/trellis) make this project possible.
|
115
|
+
|
116
|
+
Full list of contributors can be found [here](https://github.com/TypistTech/vagrant-trellis-sequel/graphs/contributors).
|
117
|
+
|
118
|
+
## Contributing
|
119
|
+
|
120
|
+
Please see [CODE_OF_CONDUCT](./CODE_OF_CONDUCT.md) for details.
|
121
|
+
|
122
|
+
## License
|
123
|
+
|
124
|
+
[Vagrant Trellis Sequel](https://github.com/TypistTech/vagrant-trellis-sequel) is released under the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "erb"
|
4
|
+
require "ostruct"
|
5
|
+
require "optparse"
|
6
|
+
require "vagrant"
|
7
|
+
|
8
|
+
module VagrantPlugins
|
9
|
+
module TrellisSequel
|
10
|
+
module Commands
|
11
|
+
class Open < Vagrant.plugin("2", :command)
|
12
|
+
def execute
|
13
|
+
options = {}
|
14
|
+
opts = OptionParser.new do |o|
|
15
|
+
o.banner = "Usage: vagrant trellis-sequel open [options] [vm-id]"
|
16
|
+
o.separator ""
|
17
|
+
|
18
|
+
o.on("-u", "--user DB_USER", String, "Required. Database username.") do |user|
|
19
|
+
options[:user] = user
|
20
|
+
end
|
21
|
+
|
22
|
+
o.on("-p", "--password DB_PASSWORD", String, "Required. Value of db_password from group_vars/development/vault.yml") do |password|
|
23
|
+
options[:password] = password || "example_dbpassword"
|
24
|
+
end
|
25
|
+
|
26
|
+
o.on("-h", "--help", "Print this help") do
|
27
|
+
@env.ui.info(opts)
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
end
|
31
|
+
argv = parse_options(opts)
|
32
|
+
|
33
|
+
# Check required options
|
34
|
+
missing_required_options = [:user, :password].any? { |param| options[param].nil? }
|
35
|
+
fail Vagrant::Errors::CLIInvalidOptions.new(help: "Missing required options.") if missing_required_options
|
36
|
+
|
37
|
+
@env.ui.info("Generating SPF file...")
|
38
|
+
|
39
|
+
# Load the SPF template
|
40
|
+
template_path = File.join(File.dirname(__FILE__), "/..", "template.spf")
|
41
|
+
template = ERB.new(File.read(template_path), nil, "%<>")
|
42
|
+
|
43
|
+
with_target_vms(argv) do |machine|
|
44
|
+
# Collect data
|
45
|
+
ssh_info = machine.ssh_info
|
46
|
+
raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
|
47
|
+
|
48
|
+
data = {
|
49
|
+
"database" => {
|
50
|
+
"name" => "#{options[:user]}_development",
|
51
|
+
"user" => options[:user],
|
52
|
+
"password" => options[:password],
|
53
|
+
},
|
54
|
+
"ssh" => {
|
55
|
+
"host" => ssh_info[:host],
|
56
|
+
"port" => ssh_info[:port],
|
57
|
+
"user" => ssh_info[:username],
|
58
|
+
"private_key_path" => ssh_info[:private_key_path],
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
# Output template
|
63
|
+
content = template.result OpenStruct.new(data).instance_eval { binding }
|
64
|
+
|
65
|
+
# Write it to the file
|
66
|
+
path = File.join(@env.tmp_path, "#{data["database"]["name"]}.spf")
|
67
|
+
file = File.open(path, "w")
|
68
|
+
file.write(content)
|
69
|
+
file.close()
|
70
|
+
|
71
|
+
# And, open it
|
72
|
+
system("open \"#{path}\"")
|
73
|
+
end
|
74
|
+
|
75
|
+
# Always exit with success
|
76
|
+
0
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
require "vagrant"
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module TrellisSequel
|
8
|
+
module Commands
|
9
|
+
class Root < Vagrant.plugin("2", :command)
|
10
|
+
def self.synopsis
|
11
|
+
"open Trellis databases in Sequel Pro"
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(argv, env)
|
15
|
+
super
|
16
|
+
|
17
|
+
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
|
18
|
+
|
19
|
+
@subcommands = Vagrant::Registry.new
|
20
|
+
|
21
|
+
@subcommands.register(:open) do
|
22
|
+
require_relative "open"
|
23
|
+
Open
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def execute
|
28
|
+
return help if (@main_args & %w[-h --help]).any?
|
29
|
+
|
30
|
+
command_class = @subcommands.get(@sub_command&.to_sym)
|
31
|
+
return help unless command_class
|
32
|
+
|
33
|
+
# Initialize and execute the command class
|
34
|
+
command_class.new(@sub_args, @env).execute
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def help
|
40
|
+
option_parser = OptionParser.new do |opts|
|
41
|
+
opts.banner = "Usage: vagrant trellis-sequel <command> [<args>]"
|
42
|
+
opts.separator ""
|
43
|
+
opts.separator "Available subcommands:"
|
44
|
+
|
45
|
+
@subcommands.keys.sort.each do |key|
|
46
|
+
opts.separator " #{key}"
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.separator ""
|
50
|
+
opts.separator "For help on any individual command run 'vagrant trellis-sequel COMMAND -h'"
|
51
|
+
end
|
52
|
+
|
53
|
+
@env.ui.info(option_parser.help, prefix: false)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module TrellisSequel
|
5
|
+
module Identity
|
6
|
+
def self.name
|
7
|
+
"vagrant-trellis-sequel"
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.version
|
11
|
+
"0.1.0"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.description
|
15
|
+
"Open Trellis databases in Sequel Pro with a single command"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.summary
|
19
|
+
description
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "vagrant"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module TrellisSequel
|
7
|
+
class Plugin < Vagrant.plugin("2")
|
8
|
+
name Identity.name
|
9
|
+
|
10
|
+
description Identity.description
|
11
|
+
|
12
|
+
command "trellis-sequel" do
|
13
|
+
require_relative "commands/root"
|
14
|
+
Commands::Root
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>ContentFilters</key>
|
6
|
+
<dict/>
|
7
|
+
<key>auto_connect</key>
|
8
|
+
<true/>
|
9
|
+
<key>data</key>
|
10
|
+
<dict>
|
11
|
+
<key>connection</key>
|
12
|
+
<dict>
|
13
|
+
<key>database</key>
|
14
|
+
<string><%= database["name"] %></string>
|
15
|
+
<key>host</key>
|
16
|
+
<string>127.0.0.1</string>
|
17
|
+
<key>password</key>
|
18
|
+
<string><%= database["password"] %></string>
|
19
|
+
<key>ssh_host</key>
|
20
|
+
<string><%= ssh["host"] %></string>
|
21
|
+
<key>ssh_keyLocation</key>
|
22
|
+
<string><%= ssh["private_key_path"][0] %></string>
|
23
|
+
<key>ssh_keyLocationEnabled</key>
|
24
|
+
<integer>1</integer>
|
25
|
+
<key>ssh_port</key>
|
26
|
+
<string><%= ssh["port"] %></string>
|
27
|
+
<key>ssh_user</key>
|
28
|
+
<string><%= ssh["user"] %></string>
|
29
|
+
<key>type</key>
|
30
|
+
<string>SPSSHTunnelConnection</string>
|
31
|
+
<key>user</key>
|
32
|
+
<string><%= database["user"] %></string>
|
33
|
+
</dict>
|
34
|
+
</dict>
|
35
|
+
<key>format</key>
|
36
|
+
<string>connection</string>
|
37
|
+
<key>queryFavorites</key>
|
38
|
+
<array/>
|
39
|
+
<key>queryHistory</key>
|
40
|
+
<array/>
|
41
|
+
</dict>
|
42
|
+
</plist>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "vagrant_plugins/trellis_sequel/identity.rb"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = VagrantPlugins::TrellisSequel::Identity.name
|
9
|
+
spec.version = VagrantPlugins::TrellisSequel::Identity.version
|
10
|
+
spec.authors = ["Tang Rufus", "Typist Tech"]
|
11
|
+
spec.email = ["tangrufus@gmail.com", "vagrant-trellis-sequel@typist.tech"]
|
12
|
+
|
13
|
+
spec.summary = VagrantPlugins::TrellisSequel::Identity.summary
|
14
|
+
spec.homepage = "https://www.typist.tech/projects/vagrant-trellis-sequel"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.required_ruby_version = ">= 2.3.0"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
27
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
28
|
+
spec.add_development_dependency "rubocop", "~> 0.49"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-trellis-sequel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tang Rufus
|
8
|
+
- Typist Tech
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-09-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.15'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.15'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '12.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '12.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rubocop
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0.49'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.49'
|
56
|
+
description:
|
57
|
+
email:
|
58
|
+
- tangrufus@gmail.com
|
59
|
+
- vagrant-trellis-sequel@typist.tech
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".github_changelog_generator"
|
65
|
+
- ".gitignore"
|
66
|
+
- ".hound.yml"
|
67
|
+
- ".rubocop.rails.yml"
|
68
|
+
- ".rubocop.yml"
|
69
|
+
- CHANGELOG.md
|
70
|
+
- CODE_OF_CONDUCT.md
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- lib/vagrant-trellis-sequel.rb
|
76
|
+
- lib/vagrant_plugins/trellis_sequel/commands/open.rb
|
77
|
+
- lib/vagrant_plugins/trellis_sequel/commands/root.rb
|
78
|
+
- lib/vagrant_plugins/trellis_sequel/identity.rb
|
79
|
+
- lib/vagrant_plugins/trellis_sequel/plugin.rb
|
80
|
+
- lib/vagrant_plugins/trellis_sequel/template.spf
|
81
|
+
- vagrant-trellis-sequel.gemspec
|
82
|
+
homepage: https://www.typist.tech/projects/vagrant-trellis-sequel
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 2.3.0
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.5.2.1
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Open Trellis databases in Sequel Pro with a single command
|
106
|
+
test_files: []
|