jarbs 0.5.4 → 0.5.6

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
  SHA1:
3
- metadata.gz: 80c0ed1b1f5fd38489ea989503475ffdd1758219
4
- data.tar.gz: bc04c29c3bc74f163189be69feaa9b5ad4e64dac
3
+ metadata.gz: 9bd564b81161e04d904a2cc879267146499aaced
4
+ data.tar.gz: aeb183426fef0c972a8662f5c52d24308daf3bf0
5
5
  SHA512:
6
- metadata.gz: b3f8059131403aac6efe3b5fc31e45d1a8b7a97886cc649480e4b131d38303d30b26566a2ef3fc8b0b2431b5e1288b5067db59b53712f9bb195ae2c91e84f522
7
- data.tar.gz: 4b5b269192663041025ac69be82d7010622404912a6a3dc53e9b154ffc4639aaf8096646bbddcfa3a9cab44fde34d9f570589edae28d523aa642f9c757497b6f
6
+ metadata.gz: 40d150e9161357387bc3c657ea1b032049ab45d36e30cb1650188c326df4f609846c04c02178b5f6442eed6979d8cb75c6c1fdf0b4593a58e4c858f9824c5518
7
+ data.tar.gz: e82c148d7d2a06c0082c231ba06b5b1f2acf92ec405e6a7bae2c86a9b851726d1047b04544c06a234be1a5f8070e8dfdad8ad870809b9d4a33254c4f202cb5da
@@ -37,6 +37,28 @@ module Jarbs
37
37
  @config.set('aws.profile', profile)
38
38
  end
39
39
 
40
+ command :init do |c|
41
+ c.syntax = 'jarbs init'
42
+ c.summary = 'Setup lambda project in an existing directory'
43
+ c.description = <<-DESC
44
+ Git ignores jarbs project definition file so on checkout of an existing lambda function.
45
+ When checking out a project from source control or transitioning a legacy lambda codebase to use
46
+ with jarbs, you'll need to run this command to setup the initial config and run additional checks
47
+ for compatability.
48
+ DESC
49
+ c.action do |args, options|
50
+ skip_setup = File.exists? '.jarbs'
51
+ abort('Lambda project already initialized.') if skip_setup
52
+
53
+ unless Dir.exists? 'lambdas'
54
+ say_warning("This doesn't look like a jarbs-enabled project directory (missing lambdas subdir).")
55
+ skip_setup = !agree('Continue (y/n)? ')
56
+ end
57
+
58
+ Config.touch unless skip_setup
59
+ end
60
+ end
61
+
40
62
  command :new do |c|
41
63
  c.syntax = 'jarbs new [options] name'
42
64
  c.summary = "Generate a new lambda function or project skeleton"
@@ -58,16 +80,22 @@ module Jarbs
58
80
  command :deploy do |c|
59
81
  c.syntax = 'jarbs deploy [options] directory'
60
82
  c.summary = 'Deploy a lambda function to AWS'
61
- c.option "--role [STRING]", String, "IAM role for Lambda execution"
83
+ c.option '--role [STRING]', String, 'IAM role for Lambda execution'
84
+ c.option '--dry', 'Dry run (do not interact with AWS)'
62
85
  c.action do |args, options|
63
86
  name = args.shift || abort('Name argument required')
64
87
  options.default global_defaults
65
88
 
66
89
  lambda = Lambda.new(name, options)
67
-
68
90
  abort("Lambda '#{name}' does not exist.") unless lambda.exists?
69
91
 
70
- lambda.deploy
92
+ lambda.prepare
93
+
94
+ if options.dry
95
+ say_warning('Dry run: Did not deploy to lambda.')
96
+ else
97
+ lambda.deploy
98
+ end
71
99
  end
72
100
  end
73
101
 
@@ -139,6 +167,5 @@ module Jarbs
139
167
  def jarbs_project?
140
168
  File.exists?('.jarbs')
141
169
  end
142
-
143
170
  end
144
171
  end
@@ -2,6 +2,10 @@ module Jarbs
2
2
  class Config
3
3
  FILE_NAME = '.jarbs'
4
4
 
5
+ def self.touch
6
+ File.open(FILE_NAME, 'w') {|f| f.write JSON.pretty_generate({}) }
7
+ end
8
+
5
9
  def initialize(file=FILE_NAME)
6
10
  @file = file
7
11
  @config = read
@@ -0,0 +1,23 @@
1
+ # Logs
2
+ /logs/
3
+ *.log
4
+ npm-debug.log*
5
+
6
+ # Coverage things
7
+ /lib-cov/
8
+ /coverage/
9
+
10
+ # NPM things
11
+ /node_modules/
12
+ /.npm/
13
+
14
+ # OS things
15
+ .DS_Store
16
+
17
+ # Misc
18
+ *.swp
19
+ /dest/
20
+
21
+ # Secrets and config
22
+ .env
23
+ .jarbs
@@ -41,7 +41,7 @@ module Jarbs
41
41
  end
42
42
 
43
43
  def install_handler
44
- FileUtils.cp File.join(File.dirname(__FILE__), 'fixtures', 'index.js'), @function.source_path
44
+ install_fixture('index.js', @function.source_path)
45
45
  end
46
46
  end
47
47
  end
@@ -27,12 +27,20 @@ module Jarbs
27
27
  FunctionGenerator.new(@function).generate
28
28
  end
29
29
 
30
+ def prepare
31
+ node = NodeBuild.new(@function)
32
+
33
+ node.npm_build
34
+ @package = Packager.new(@function).package
35
+ ensure
36
+ node.clean
37
+ end
38
+
30
39
  def deploy
31
40
  deployed? ? update : create
32
41
  end
33
42
 
34
43
  def create
35
- data = prepare_for_aws
36
44
  role = @options[:role] || ask("IAM role for function: ")
37
45
 
38
46
  say "Creating #{@function.env_name} on Lambda..."
@@ -44,19 +52,17 @@ module Jarbs
44
52
  role: role,
45
53
  memory_size: 128,
46
54
  timeout: 10,
47
- code: { zip_file: data }
55
+ code: { zip_file: @package }
48
56
  end
49
57
 
50
58
  say_ok "Complete!"
51
59
  end
52
60
 
53
61
  def update
54
- data = prepare_for_aws
55
-
56
62
  say "Updating #{@function.env_name} on Lambda..."
57
63
 
58
64
  capture_errors do
59
- @client.update_function_code function_name: @function.env_name, zip_file: data
65
+ @client.update_function_code function_name: @function.env_name, zip_file: @package
60
66
  end
61
67
 
62
68
  say_ok "Complete!"
@@ -83,16 +89,6 @@ module Jarbs
83
89
 
84
90
  private
85
91
 
86
- def prepare_for_aws
87
- node = NodeBuild.new(@function)
88
-
89
- node.npm_build
90
- package = Packager.new(@function).package
91
- ensure
92
- node.clean
93
- package
94
- end
95
-
96
92
  def default_region
97
93
  `aws configure get region`.chomp
98
94
  end
@@ -1,6 +1,10 @@
1
1
  module Jarbs
2
2
  module ManifestHelpers
3
3
 
4
+ def install_fixture(fixture_name, path)
5
+ FileUtils.cp File.join(File.dirname(__FILE__), 'fixtures', fixture_name), path
6
+ end
7
+
4
8
  def write_package(manifest, path)
5
9
  File.open(File.join(path, 'package.json'), 'w') do |f|
6
10
  f.write JSON.pretty_generate(manifest)
@@ -33,11 +33,19 @@ module Jarbs
33
33
  Dir.chdir(@name)
34
34
 
35
35
  write_package(manifest, '.')
36
+ install_gitignore
37
+
36
38
  NodeBuild.new(nil).npm_install('.')
37
39
 
38
40
  setup_crash_logging
39
41
  end
40
42
 
43
+ private
44
+
45
+ def install_gitignore
46
+ install_fixture('.gitignore', '.')
47
+ end
48
+
41
49
  def setup_crash_logging
42
50
  config = Config.new
43
51
  autolog = config.get('crashes.report') do
@@ -1,3 +1,3 @@
1
1
  module Jarbs
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jarbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke van der Hoeven
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-11 00:00:00.000000000 Z
11
+ date: 2015-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -156,6 +156,7 @@ files:
156
156
  - jarbs.gemspec
157
157
  - lib/jarbs.rb
158
158
  - lib/jarbs/config.rb
159
+ - lib/jarbs/fixtures/.gitignore
159
160
  - lib/jarbs/fixtures/index.js
160
161
  - lib/jarbs/function_definition.rb
161
162
  - lib/jarbs/function_generator.rb