jets 6.0.0 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ea57049f7d7ee0153aac387f0feb438ee5a9e9816f8aeab7e21a9a6d4e33d69
4
- data.tar.gz: 2a6e9de21b85674322a8adcfb234204272aefe2e30ae6babc77244ab9f4d8635
3
+ metadata.gz: f47ac05e6c483fddfa95f18d2899386df9e228893b7ddc425ce9a5e6ef4df0c4
4
+ data.tar.gz: d18b78a75e123a66b954f35339e541df75d6e85a4dd16f1ac56ca090d00aeb6d
5
5
  SHA512:
6
- metadata.gz: 2584bc53863cef64744101705db2b65a312d4f332745b8d0ca8a41558b5f3e0dacae87ec1169dcdc4c2bfa1af75de7156c24015b212fd6e3eccc522a2b5f0da5
7
- data.tar.gz: 1fcfc2dc86ff24cec62eb34b0559229a47ebbc868e49fc2f1e9d39c7cd8836c70e1cff4adf8fbb3eee9af96610fdabea7dc21d342eda96ff0b0afa8405e2b7ff
6
+ metadata.gz: 1771244d6fed908320775d6cbeffd08d7b26defe3a57bc0c8a3e1db6e2ee92eaf49c0e277e138d9186215cdfa3b40b34508b0159aaa7d0b350ae40d464987100
7
+ data.tar.gz: '099a72152faeaad8bbbacfde6859e320025840a756115d55ee908a838da4d538d6ee5b06d3f498ac07864d4477ac4fcd455056261db5951d28253906d52be225'
@@ -27,7 +27,7 @@ Thanks!
27
27
  Make sure that you've done all of these. To mark a checkbox done, replace [ ] with [x]. Or after you create the issue you can click the checkbox.
28
28
  -->
29
29
 
30
- - [ ] Upgrade Jets: Are you using the latest version of Jets? This allows Jets to fix issues fast. There's a `jets upgrade` command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/
30
+ - [ ] Upgrade Jets: Are you using the latest version of Jets? This allows Jets to fix issues fast.
31
31
  - [ ] Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.boltops.com
32
32
  - [ ] Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.
33
33
 
data/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [6.0.1] - 2024-05-27
7
+ - [#727](https://github.com/rubyonjets/jets/pull/727) small fixes
8
+ - associated outputs concept
9
+ - jets concurrency show lambda function name
10
+ - jets git:push command
11
+ - pretty time helper
12
+ - update github issue template bug report
13
+
6
14
  ## [6.0.0] - 2024-05-23
7
15
 
8
16
  * Rails Support
data/Gemfile CHANGED
@@ -5,10 +5,6 @@ gemspec
5
5
 
6
6
  # required here for specs
7
7
  group :development, :test do
8
- gem "mysql2", "~> 0.5.2"
9
- gem "dynomite", "~> 2.0.0"
10
- end
11
-
12
- group :test do
13
- gem "actionpack", "~> 7.1.3" # jets shim specs
8
+ gem "dynomite", ">= 2.0.0"
9
+ gem "mysql2", ">= 0.5.2"
14
10
  end
data/Rakefile CHANGED
@@ -9,12 +9,6 @@ RSpec::Core::RakeTask.new
9
9
 
10
10
  require_relative "lib/jets"
11
11
 
12
- desc "Generates cli reference docs as markdown"
13
- task :docs do
14
- require "cli_markdown_jets"
15
- CliMarkdown::Creator.new.create_all
16
- end
17
-
18
12
  # Thanks: https://docs.ruby-lang.org/en/2.1.0/RDoc/Task.html
19
13
  require "rdoc/task"
20
14
  require "jets/rdoc"
@@ -0,0 +1,21 @@
1
+ class Jets::Cfn::Resource
2
+ class AssociatedOutputs
3
+ extend Memoist
4
+
5
+ def initialize(outputs = {}, replacements = {})
6
+ @outputs = outputs
7
+ @replacements = replacements
8
+ end
9
+
10
+ def replacer
11
+ Replacer.new(@replacements)
12
+ end
13
+ memoize :replacer
14
+
15
+ def outputs
16
+ outputs = replacer.replace_placeholders(@outputs)
17
+ outputs.transform_values! { |value| value.camelize }
18
+ outputs.transform_keys! { |key| replacer.replace_value(key) }
19
+ end
20
+ end
21
+ end
@@ -1,11 +1,14 @@
1
1
  class Jets::CLI::Ci
2
2
  class Status < Base
3
+ include Jets::Util::FormatTime
4
+
3
5
  def run
4
6
  check_build_id!
5
7
  run_with_exception_handling do
6
8
  puts "Build id: #{build_id}"
7
9
  resp = codebuild.batch_get_builds(ids: [build_id])
8
10
  build = resp.builds.first
11
+ puts "Build end time: #{pretty_time(build.end_time)}"
9
12
  puts "Build status: #{colored(build.build_status)}"
10
13
  end
11
14
  end
@@ -9,7 +9,7 @@ class Jets::CLI::Concurrency
9
9
  def run
10
10
  puts <<~EOL
11
11
  Settings for Function: #{@lambda_function.name}
12
- Reserved concurreny: #{reserved_concurrency}
12
+ Reserved concurrency: #{reserved_concurrency}
13
13
  Provisioned concurrency: #{provisioned_concurrency}
14
14
  EOL
15
15
  end
@@ -1,8 +1,8 @@
1
1
  class Jets::CLI::Concurrency
2
2
  class Set < Get
3
3
  def run
4
- sure? "Will update the concurrency settings for #{Jets.project.namespace}"
5
- puts "Updating concurrency settings for #{Jets.project.namespace}"
4
+ sure? "Will update the concurrency settings for #{@lambda_function.name}"
5
+ puts "Updating concurrency settings for #{@lambda_function.name}"
6
6
 
7
7
  if @options[:reserved]
8
8
  @lambda_function.reserved_concurrency = @options[:reserved]
@@ -1,8 +1,8 @@
1
1
  class Jets::CLI::Concurrency
2
2
  class Unset < Set
3
3
  def run
4
- sure? "Will unset the concurrency settings for #{Jets.project.namespace}"
5
- puts "Unsetting concurrency settings for #{Jets.project.namespace}"
4
+ sure? "Will unset the concurrency settings for #{@lambda_function.name}"
5
+ puts "Unsetting concurrency settings for #{@lambda_function.name}"
6
6
 
7
7
  if @options[:reserved]
8
8
  @lambda_function.reserved_concurrency = nil
@@ -0,0 +1,65 @@
1
+ require "open3"
2
+
3
+ class Jets::CLI::Git
4
+ class Push < Jets::CLI::Base
5
+ def initialize(options = {})
6
+ super
7
+ @args = options[:args] || []
8
+ end
9
+
10
+ def run
11
+ args = ["push"] + @args
12
+ puts "=> git #{args.join(" ")}"
13
+
14
+ IO.popen(["git", *args]) do |io|
15
+ io.each do |line|
16
+ puts line
17
+ end
18
+ end
19
+
20
+ return unless $?.success?
21
+
22
+ set_env_vars!
23
+ sleep 2 # wait ci to start
24
+ Jets::CLI::Ci::Logs.new(options).run
25
+ end
26
+
27
+ def set_env_vars!
28
+ env_vars = Jets.project.config.git.push.branch[push_branch] || {}
29
+ # IE: branch_name = {JETS_ENV: "xxx", AWS_PROFILE: "xxx"}
30
+ env_vars.each do |k, v|
31
+ ENV[k.to_s] = v
32
+ end
33
+ end
34
+
35
+ # man git-push
36
+ # git push
37
+ # git push origin
38
+ # git push origin :
39
+ # git push origin master
40
+ # git push origin HEAD
41
+ # git push mothership master:satellite/master dev:satellite/dev
42
+ # git push origin HEAD:master
43
+ # git push origin master:refs/heads/experimental
44
+ # git push origin :experimental
45
+ # git push origin +dev:master
46
+ def push_branch
47
+ args = @args.reject { |arg| arg.start_with?("-") } # remove options
48
+ case args.size
49
+ when 0
50
+ local.git_default_branch
51
+ when 1
52
+ local.git_current_branch
53
+ when 2
54
+ args.last
55
+ else
56
+ raise "ERROR: Too many arguments. Usage: jets git:push [REMOTE] [BRANCH]"
57
+ end
58
+ end
59
+
60
+ def local
61
+ Jets::Git::Local.new
62
+ end
63
+ memoize :local
64
+ end
65
+ end
@@ -0,0 +1,8 @@
1
+ class Jets::CLI
2
+ class Git < Jets::Thor::Base
3
+ desc "push", "Runs git push and jets ci:logs"
4
+ def push(*args)
5
+ Push.new(options.merge(args: args)).run
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ ## Example
2
+
3
+ ❯ jets concurrency:info
4
+ Concurrency for demo-dev
5
+ +---------------------------+----------+
6
+ | Function | Reserved |
7
+ +---------------------------+----------+
8
+ | controller | 25 |
9
+ | jets-prewarm_event-handle | 2 |
10
+ | total | 27 |
11
+ +---------------------------+----------+
12
+ Account Limits
13
+ Concurrent Executions: 1000
14
+ Unreserved Concurrent Executions: 730
@@ -3,6 +3,7 @@ require "tzinfo"
3
3
 
4
4
  class Jets::CLI::Release
5
5
  class History < Base
6
+ include Jets::Util::FormatTime
6
7
  rescue_api_error
7
8
 
8
9
  def run
@@ -29,11 +30,11 @@ class Jets::CLI::Release
29
30
  items.each do |item|
30
31
  version = item[:version]
31
32
  status = item[:stack_status]
32
- released_at = item[:pretty_created_at] || item[:created_at]
33
+ released_at = item[:created_at]
33
34
  message = item[:message] || "Deployed"
34
35
  message = message[0..50]
35
36
 
36
- row = [version, status, format_time(released_at), message]
37
+ row = [version, status, pretty_time(released_at), message]
37
38
  if @options[:sha]
38
39
  sha = item[:git_sha].to_s[0..7] if item[:git_sha]
39
40
  row << sha
@@ -42,27 +43,5 @@ class Jets::CLI::Release
42
43
  end
43
44
  presenter.show
44
45
  end
45
-
46
- def format_time(string)
47
- if string.include?("ago") # IE: 5 minutes ago
48
- string
49
- else
50
- utc = DateTime.parse(string)
51
-
52
- tz_override = ENV["JETS_TZ"] # IE: America/Los_Angeles
53
- local = if tz_override
54
- tz = TZInfo::Timezone.get(tz_override)
55
- tz.utc_to_local(utc)
56
- else
57
- utc.new_offset(DateTime.now.offset) # local time
58
- end
59
-
60
- if tz_override
61
- local.strftime("%b %-d, %Y %-l:%M:%S%P")
62
- else
63
- local.strftime("%b %-d, %Y %H:%M:%S")
64
- end
65
- end
66
- end
67
46
  end
68
47
  end
@@ -27,8 +27,7 @@ class Jets::CLI::Release
27
27
  data = release_fields.map do |field|
28
28
  # special cases for values
29
29
  value = if field == :created_at
30
- time_string = release[:pretty_created_at] || release[:created_at]
31
- format_time(time_string)
30
+ pretty_time(release[:created_at])
32
31
  else
33
32
  release[field]
34
33
  end
data/lib/jets/cli.rb CHANGED
@@ -15,6 +15,9 @@ module Jets
15
15
  desc "generate SUBCOMMAND", "generate subcommands"
16
16
  subcommand "generate", Generate
17
17
 
18
+ desc "git SUBCOMMAND", "git subcommands"
19
+ subcommand "git", Git
20
+
18
21
  desc "maintenance SUBCOMMAND", "maintenance subcommands"
19
22
  subcommand "maintenance", Maintenance
20
23
 
@@ -7,6 +7,7 @@ module Jets::Core::Config
7
7
  :ignore_paths,
8
8
  :base64_encode,
9
9
  :dotenv,
10
+ :git,
10
11
  :tips
11
12
  )
12
13
  def initialize(*)
@@ -40,6 +41,10 @@ module Jets::Core::Config
40
41
 
41
42
  @base64_encode = true
42
43
 
44
+ @git = ActiveSupport::OrderedOptions.new
45
+ @git.push = ActiveSupport::OrderedOptions.new
46
+ @git.push.branch = ActiveSupport::OrderedOptions.new
47
+
43
48
  @tips = ActiveSupport::OrderedOptions.new
44
49
  @tips.enable = true
45
50
  @tips.concurrency_change = true
@@ -65,5 +65,9 @@ module Jets::Git
65
65
  end
66
66
  default
67
67
  end
68
+
69
+ def git_current_branch
70
+ `rev-parse --abbrev-ref HEAD`.strip
71
+ end
68
72
  end
69
73
  end
@@ -5,7 +5,7 @@ module Jets::Lambda
5
5
  attr_accessor :class_name, :type
6
6
  attr_reader(
7
7
  :meth, :properties, :provisioned_concurrency, :iam_policy, :managed_iam_policy,
8
- :lang, :associated_resources
8
+ :lang, :associated_resources, :associated_outputs
9
9
  )
10
10
  def initialize(class_name, meth, options = {})
11
11
  @class_name = class_name.to_s
@@ -18,6 +18,7 @@ module Jets::Lambda
18
18
  @managed_iam_policy = options[:managed_iam_policy]
19
19
  @lang = options[:lang] || :ruby
20
20
  @associated_resources = options[:associated_resources] || {}
21
+ @associated_outputs = options[:associated_outputs] || {}
21
22
  @replacements = options[:replacements] || {} # added to baseline replacements
22
23
  end
23
24
 
@@ -169,6 +169,11 @@ module Jets::Lambda::Dsl
169
169
  # User-friendly short resource method. Users will use this.
170
170
  alias_method :resource, :associated_resources
171
171
 
172
+ def associated_outputs(outputs = {})
173
+ @associated_outputs ||= []
174
+ @associated_outputs << outputs
175
+ end
176
+
172
177
  # Using this odd way of setting these properties so we can keep the
173
178
  # resource(*definitions) signature simple. Using keyword arguments at the end
174
179
  # interfere with being able to pass in any keys for the properties hash at the end.
@@ -282,6 +287,7 @@ module Jets::Lambda::Dsl
282
287
  iam_policy: @iam_policy,
283
288
  managed_iam_policy: @managed_iam_policy,
284
289
  associated_resources: @associated_resources,
290
+ associated_outputs: @associated_outputs,
285
291
  lang: lang,
286
292
  replacements: replacements(meth))
287
293
 
@@ -0,0 +1,52 @@
1
+ module Jets::Util
2
+ module FormatTime
3
+ def pretty_time(time)
4
+ datetime = case time
5
+ when Time
6
+ time.to_datetime
7
+ when String
8
+ DateTime.parse(time)
9
+ else
10
+ time
11
+ end
12
+
13
+ if datetime > 1.day.ago.utc
14
+ time_ago_in_words(datetime) + " ago"
15
+ else
16
+ tz_override = ENV["JETS_TZ"] # IE: America/Los_Angeles
17
+ local = if tz_override
18
+ tz = TZInfo::Timezone.get(tz_override)
19
+ tz.time_to_local(datetime)
20
+ else
21
+ datetime.new_offset(DateTime.now.offset) # local time
22
+ end
23
+
24
+ if tz_override
25
+ local.strftime("%b %-d, %Y %-l:%M:%S%P")
26
+ else
27
+ local.strftime("%b %-d, %Y %H:%M:%S")
28
+ end
29
+ end
30
+ end
31
+
32
+ # Simple implementation of time_ago_in_words so we dont have to include ActionView::Helpers::DateHelper
33
+ def time_ago_in_words(from_time, to_time = Time.now)
34
+ distance_in_seconds = (to_time - from_time).to_i
35
+ case distance_in_seconds
36
+ when 0..59
37
+ "#{distance_in_seconds} #{"second".pluralize(distance_in_seconds)}"
38
+ when 60..3599
39
+ minutes = distance_in_seconds / 60
40
+ "#{minutes} #{"minute".pluralize(minutes)}"
41
+ when 3600..86_399
42
+ hours = distance_in_seconds / 3600
43
+ "#{hours} #{"hour".pluralize(hours)}"
44
+ when 86_400..604_799
45
+ days = distance_in_seconds / 86_400
46
+ "#{days} #{"day".pluralize(days)}"
47
+ else
48
+ from_time.strftime("%B %d, %Y")
49
+ end
50
+ end
51
+ end
52
+ end
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "6.0.0"
2
+ VERSION = "6.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-23 00:00:00.000000000 Z
11
+ date: 2024-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-logs
@@ -647,6 +647,7 @@ files:
647
647
  - lib/jets/cfn/iam/policy.rb
648
648
  - lib/jets/cfn/resource.rb
649
649
  - lib/jets/cfn/resource/associated.rb
650
+ - lib/jets/cfn/resource/associated_outputs.rb
650
651
  - lib/jets/cfn/resource/codebuild/fleet.rb
651
652
  - lib/jets/cfn/resource/codebuild/iam_role.rb
652
653
  - lib/jets/cfn/resource/codebuild/project/base.rb
@@ -732,12 +733,15 @@ files:
732
733
  - lib/jets/cli/generate/templates/event_types/scheduled.rb.tt
733
734
  - lib/jets/cli/generate/templates/event_types/sns.rb.tt
734
735
  - lib/jets/cli/generate/templates/event_types/sqs.rb.tt
736
+ - lib/jets/cli/git.rb
737
+ - lib/jets/cli/git/push.rb
735
738
  - lib/jets/cli/group/actions.rb
736
739
  - lib/jets/cli/group/base.rb
737
740
  - lib/jets/cli/group/helpers.rb
738
741
  - lib/jets/cli/help.rb
739
742
  - lib/jets/cli/help/build.md
740
743
  - lib/jets/cli/help/call.md
744
+ - lib/jets/cli/help/concurrency/info.md
741
745
  - lib/jets/cli/help/curl.md
742
746
  - lib/jets/cli/help/delete.md
743
747
  - lib/jets/cli/help/deploy.md
@@ -918,6 +922,7 @@ files:
918
922
  - lib/jets/thor/version_check.rb
919
923
  - lib/jets/util/call_line.rb
920
924
  - lib/jets/util/camelize.rb
925
+ - lib/jets/util/format_time.rb
921
926
  - lib/jets/util/git.rb
922
927
  - lib/jets/util/logging.rb
923
928
  - lib/jets/util/pretty.rb