heighliner 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2652edf0b183383b89645cee4e2d22210c2099773c124fdfb44073dd9755be47
4
+ data.tar.gz: ae906d0864fd3f2ceca23cb94c1675ffcf219a4ec4fd3de3082fbaf64a0cd4eb
5
+ SHA512:
6
+ metadata.gz: 4134df6ece248fc364167114265cef9bbe7b39bb4b7746a0d0cbb23f1e0dc22b816d27093295edcc441fe2f0a5fd1e08ccac77cfe03fb37e44e7035a136f8753
7
+ data.tar.gz: 14d9595f84c5e5f545f942e6ce702bb0c8d97fc2e6603547a46c750caec41a32ebc7285059711b2e960a821d795da5f8ae36d814dd39fd289da071ef60fa3de6
data/README.md ADDED
@@ -0,0 +1,182 @@
1
+ # Heighliner
2
+
3
+ Heighliner is a tool that allows you to describe your web application using a Steerfile.
4
+
5
+ This removes the guesswork of setting up a web application for development and gives teams an edge by allowing new developers on a system to hit the ground running, as well as propagate any changes in settings to other developers via source code.
6
+
7
+ The Steerfile gives you an immense amount of control on how you want your application set up.
8
+
9
+ # Dependencies
10
+
11
+ Heighliner depends on Docker
12
+
13
+ # Installation
14
+
15
+ ## Installation (Docker)
16
+
17
+ Simply add the following line to your `.bashrc` or `.bash_profile` or '.zshrc'
18
+
19
+ ```
20
+ alias heighliner='docker run --pull=always --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.heighliner:/root/.heighliner -v `pwd`:`pwd` -e _HEIGHLINER_USER_HOME=$HOME -e _HEIGHLINER_POS=docker -e CONTEXT_DIR="`pwd`" davidsiaw/heighliner'
21
+ ```
22
+
23
+ Or if you use fish
24
+
25
+ ```
26
+ function heighliner
27
+ docker run --pull=always --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.heighliner:/root/.heighliner -v (pwd):(pwd) -e _HEIGHLINER_USER_HOME=$HOME -e _HEIGHLINER_POS=docker -e CONTEXT_DIR=(pwd) davidsiaw/heighliner $argv
28
+ end
29
+ ```
30
+
31
+ Confirm it is working by running
32
+
33
+ ```
34
+ heighliner -h
35
+ ```
36
+
37
+ ## Installation (Plain)
38
+
39
+ Execute:
40
+
41
+ ```
42
+ $ bundle install
43
+ ```
44
+
45
+ Or install it yourself as:
46
+
47
+ ```
48
+ $ gem install specific_install
49
+ $ gem specific_install -l https://github.com/davidsiaw/heighliner
50
+ ```
51
+
52
+ ## Building the docker container
53
+
54
+ You can build the Heighliner image on your machine if you want
55
+
56
+ Simply clone the repo and run
57
+
58
+ ```
59
+ cd heighliner
60
+ bundle
61
+ docker build -t davidsiaw/heighliner .
62
+ ```
63
+
64
+ And then
65
+
66
+ # Usage
67
+
68
+ You'll need a Dockerfile and a Steerfile. The Steerfile should be placed in the project root directory, with contents like this:
69
+
70
+ ```ruby
71
+ # Example Steerfile for a Rails app
72
+
73
+ dockerfile "Dockerfile"
74
+
75
+ db "mysql:5.6",
76
+ port: 3306,
77
+ data_dir: "/var/lib/mysql",
78
+ params: "-e MYSQL_ROOT_PASSWORD=test123",
79
+ commands: ""
80
+
81
+ app_params "-e DATABASE_URL=mysql2://root:test123@<%= db_container_name %>"
82
+
83
+ expose "9000"
84
+ db_reset_command "bin/rails db:reset"
85
+ ```
86
+
87
+ ```dockerfile
88
+ FROM ruby:alpine
89
+
90
+ COPY . /app
91
+ RUN apk update && apk add build-base
92
+ RUN gem install bundler
93
+ RUN bundle install
94
+
95
+ EXPOSE "3000"
96
+
97
+ CMD ["sh", "-c", "rails -b 0.0.0.0 -p 3000"]
98
+ ```
99
+
100
+ Then go to your repo's root folder and go
101
+
102
+ ```sh
103
+ bundle exec heighliner init myapp
104
+ bundle exec heighliner up
105
+ ```
106
+
107
+ Once its done, simply
108
+
109
+ ```sh
110
+ open http://myapp.lvh.me
111
+ ```
112
+
113
+ And enjoy previewing your app!
114
+
115
+ ## More documentation
116
+
117
+ You can find even more documentation in https://davidsiaw.github.io/heighliner.
118
+
119
+ If you wish to read a HTML version of this documentation you can go:
120
+
121
+ ```
122
+ cd docs
123
+ bundle install
124
+ bundle exec weaver
125
+ ```
126
+
127
+
128
+ ## Development
129
+
130
+ After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.
131
+
132
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
133
+
134
+ ### Using Heighliner with docker
135
+
136
+ You can use heighliner without ruby. if you have docker installed use the following aliases in your .bashrc or .zshrc
137
+
138
+ **Normal way:**
139
+
140
+ ```
141
+ alias heighliner='docker run --rm -ti \
142
+ -v /var/run/docker.sock:/var/run/docker.sock \
143
+ -v $HOME/.heighliner:/root/.heighliner \
144
+ -v `pwd`:`pwd` \
145
+ -e _HEIGHLINER_USER_HOME=$HOME \
146
+ -e _HEIGHLINER_POS=docker \
147
+ -e CONTEXT_DIR="`pwd`" \
148
+ davidsiaw/heighliner'
149
+ ```
150
+
151
+
152
+ **With certificates stored in 1password:**
153
+
154
+ If you have your local dev SSL certificates stored in 1password, but you want to use the docker version you can use them this way.
155
+
156
+ if you put your personal service account token in 1password you can just read them out like this.
157
+
158
+ ```
159
+ alias heighliner='docker run --rm -ti \
160
+ -v /var/run/docker.sock:/var/run/docker.sock \
161
+ -v $HOME/.heighliner:/root/.heighliner \
162
+ -v `pwd`:`pwd` \
163
+ -e _HEIGHLINER_USER_HOME=$HOME \
164
+ -e _HEIGHLINER_POS=docker \
165
+ -e CONTEXT_DIR="`pwd`" \
166
+ -e OP_SERVICE_ACCOUNT_TOKEN=`op read op://Private/local-dev/credential` \
167
+ davidsiaw/heighliner'
168
+ ```
169
+
170
+ Create the token in 1Password web app: Integrations → Developer Tools → Service Accounts.
171
+
172
+ ## Contributing
173
+
174
+ Bug reports and pull requests are welcome on GitHub at https://github.com/davidsiaw/heighliner. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
175
+
176
+ ## License
177
+
178
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
179
+
180
+ ## Code of Conduct
181
+
182
+ Everyone interacting in the Heighliner project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/davidsiaw/heighliner/blob/master/CODE_OF_CONDUCT.md).
data/exe/heighliner ADDED
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'optimist'
5
+ require 'fileutils'
6
+ require 'yaml'
7
+ require 'json'
8
+ require 'erb'
9
+
10
+ require 'heighliner'
11
+
12
+ sub_command_strings = Heighliner::SUB_COMMANDS.keys.map(&:to_s)
13
+
14
+ Heighliner::SUB_COMMANDS.each { |k, v| Heighliner::Cli.register(k, v) }
15
+
16
+ # It was difficult to allow global arguments like -v and -q to be typed both before and after cmds
17
+ # and still support `heighliner -h` for full help messages and `heighliner subcmd -h` for focused messages.
18
+ # Putting the global options in an array, using an Optimist::Parser and basically everything up to
19
+ # the 'end parser hacks' comment are all hacks to marry the above two behaviours.
20
+
21
+ global_opts = [
22
+ [:verbose, "Show Heighliner's debug output", { short: '-v' }],
23
+ [:quiet, 'Suppress all output', { short: '-q' }]
24
+ ]
25
+
26
+ parser = Optimist::Parser.new do
27
+ version "Heighliner v#{Heighliner::VERSION}"
28
+
29
+ banner <<~BANNER
30
+ #{version}
31
+
32
+ Heighliner is a tool to make development a lot easier by defining how an application starts using a Steerfile in the source code's root directory.g
33
+
34
+ Prerequisites
35
+ =============
36
+
37
+ Install docker on your system and make sure the current user has all the rights required to spin up docker containers.
38
+
39
+ Usage
40
+ =====
41
+
42
+ For typical usage you'll want to do the following three commands.
43
+
44
+ \`\`\`
45
+ heighliner init ENV_NAME
46
+ heighliner up
47
+ heighliner attach
48
+ \`\`\`
49
+
50
+ This will boot up your application in docker and bind mount your local source directory so you can start doing development. Happy coding!
51
+
52
+ If any of these commands are giving you trouble, please run them with the \`-v\` flag set. They will show you what exactly is happening so you can debug.
53
+
54
+ Subcommands
55
+ ===========
56
+
57
+ - #{Heighliner::SUB_COMMANDS.keys.join("\n- ")}
58
+
59
+ Type \`SUB_COMMAND -h\` for help with specific subcommands.
60
+
61
+ Global Parameters
62
+ =================
63
+ BANNER
64
+
65
+ global_opts.each { |o| opt(*o) }
66
+ end
67
+
68
+ commands = sub_command_strings & ARGV
69
+
70
+ if commands.empty?
71
+ Optimist.with_standard_exception_handling parser do
72
+ raise Optimist::HelpNeeded
73
+ end
74
+ end
75
+
76
+ cmd = commands.first
77
+ ## end parser hacks ##
78
+
79
+ begin
80
+ Heighliner::Cli.run_command(:"#{cmd}", global_opts)
81
+ rescue Heighliner::Error => e
82
+ puts ''
83
+ puts e.message
84
+ end
85
+
86
+ puts ''
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Heighliner
4
+ # Prints properly after a dotter prints
5
+ class AfterDotter
6
+ def initialize(dotter:, channel: $stderr)
7
+ @channel = channel
8
+ @dotter = dotter
9
+ end
10
+
11
+ def puts(value)
12
+ if @dotter.dotted
13
+ @dotter.dotted = false
14
+ @channel.puts ''
15
+ end
16
+ @channel.puts(value)
17
+ end
18
+
19
+ def flush
20
+ @channel.flush
21
+ end
22
+ end
23
+ end