-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
associated outputs concept jets concurrency show lambda function name jets git:push command pretty time helper update github issue template bug report
- Loading branch information
Showing
19 changed files
with
195 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class Jets::Cfn::Resource | ||
class AssociatedOutputs | ||
extend Memoist | ||
|
||
def initialize(outputs = {}, replacements = {}) | ||
@outputs = outputs | ||
@replacements = replacements | ||
end | ||
|
||
def replacer | ||
Replacer.new(@replacements) | ||
end | ||
memoize :replacer | ||
|
||
def outputs | ||
outputs = replacer.replace_placeholders(@outputs) | ||
outputs.transform_values! { |value| value.camelize } | ||
outputs.transform_keys! { |key| replacer.replace_value(key) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Jets::CLI | ||
class Git < Jets::Thor::Base | ||
desc "push", "Runs git push and jets ci:logs" | ||
def push(*args) | ||
Push.new(options.merge(args: args)).run | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
require "open3" | ||
|
||
class Jets::CLI::Git | ||
class Push < Jets::CLI::Base | ||
def initialize(options = {}) | ||
super | ||
@args = options[:args] || [] | ||
end | ||
|
||
def run | ||
args = ["push"] + @args | ||
puts "=> git #{args.join(" ")}" | ||
|
||
IO.popen(["git", *args]) do |io| | ||
io.each do |line| | ||
puts line | ||
end | ||
end | ||
|
||
return unless $?.success? | ||
|
||
set_env_vars! | ||
sleep 2 # wait ci to start | ||
Jets::CLI::Ci::Logs.new(options).run | ||
end | ||
|
||
def set_env_vars! | ||
env_vars = Jets.project.config.git.push.branch[push_branch] || {} | ||
# IE: branch_name = {JETS_ENV: "xxx", AWS_PROFILE: "xxx"} | ||
env_vars.each do |k, v| | ||
ENV[k.to_s] = v | ||
end | ||
end | ||
|
||
# man git-push | ||
# git push | ||
# git push origin | ||
# git push origin : | ||
# git push origin master | ||
# git push origin HEAD | ||
# git push mothership master:satellite/master dev:satellite/dev | ||
# git push origin HEAD:master | ||
# git push origin master:refs/heads/experimental | ||
# git push origin :experimental | ||
# git push origin +dev:master | ||
def push_branch | ||
args = @args.reject { |arg| arg.start_with?("-") } # remove options | ||
case args.size | ||
when 0 | ||
local.git_default_branch | ||
when 1 | ||
local.git_current_branch | ||
when 2 | ||
args.last | ||
else | ||
raise "ERROR: Too many arguments. Usage: jets git:push [REMOTE] [BRANCH]" | ||
end | ||
end | ||
|
||
def local | ||
Jets::Git::Local.new | ||
end | ||
memoize :local | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
## Example | ||
|
||
❯ jets concurrency:info | ||
Concurrency for demo-dev | ||
+---------------------------+----------+ | ||
| Function | Reserved | | ||
+---------------------------+----------+ | ||
| controller | 25 | | ||
| jets-prewarm_event-handle | 2 | | ||
| total | 27 | | ||
+---------------------------+----------+ | ||
Account Limits | ||
Concurrent Executions: 1000 | ||
Unreserved Concurrent Executions: 730 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,5 +65,9 @@ def git_default_branch | |
end | ||
default | ||
end | ||
|
||
def git_current_branch | ||
`rev-parse --abbrev-ref HEAD`.strip | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module Jets::Util | ||
module FormatTime | ||
def pretty_time(time) | ||
datetime = case time | ||
when Time | ||
time.to_datetime | ||
when String | ||
DateTime.parse(time) | ||
else | ||
time | ||
end | ||
|
||
if datetime > 1.day.ago.utc | ||
time_ago_in_words(datetime) + " ago" | ||
else | ||
tz_override = ENV["JETS_TZ"] # IE: America/Los_Angeles | ||
local = if tz_override | ||
tz = TZInfo::Timezone.get(tz_override) | ||
tz.time_to_local(datetime) | ||
else | ||
datetime.new_offset(DateTime.now.offset) # local time | ||
end | ||
|
||
if tz_override | ||
local.strftime("%b %-d, %Y %-l:%M:%S%P") | ||
else | ||
local.strftime("%b %-d, %Y %H:%M:%S") | ||
end | ||
end | ||
end | ||
|
||
# Simple implementation of time_ago_in_words so we dont have to include ActionView::Helpers::DateHelper | ||
def time_ago_in_words(from_time, to_time = Time.now) | ||
distance_in_seconds = (to_time - from_time).to_i | ||
case distance_in_seconds | ||
when 0..59 | ||
"#{distance_in_seconds} #{"second".pluralize(distance_in_seconds)}" | ||
when 60..3599 | ||
minutes = distance_in_seconds / 60 | ||
"#{minutes} #{"minute".pluralize(minutes)}" | ||
when 3600..86_399 | ||
hours = distance_in_seconds / 3600 | ||
"#{hours} #{"hour".pluralize(hours)}" | ||
when 86_400..604_799 | ||
days = distance_in_seconds / 86_400 | ||
"#{days} #{"day".pluralize(days)}" | ||
else | ||
from_time.strftime("%B %d, %Y") | ||
end | ||
end | ||
end | ||
end |