aws_sam_yarn_builder 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 249d84c22f208ea1f59dcaa89eae95001880f744c93d3d76bfd97852fdc6c1fd
4
- data.tar.gz: bb2f505dadbd43d4ae995591d328a95e3a369062665a6cc79d470f29eaef3706
3
+ metadata.gz: ad8d8b13ba9e72f1062105170af418674d43298c0abb123c8e0dff0dbf58cfe4
4
+ data.tar.gz: 702896342e48b42f42a31ad4f6167117feb3534554268e347d4df39776f49f07
5
5
  SHA512:
6
- metadata.gz: b6717c47b5556c29ac2f5f22213f3ecb1977d3cfa7adbca831dd1ac0b1b5a94a25772415d81d685d31d40179355fd3dff58f08ef193a949e376ddcb98a31cf91
7
- data.tar.gz: 4076c12e36f9e21032e6135e6acff2abbfa764c0e0f454d0730d2a82510d8e5b72f5c44a27eeaccdd42a946fcc21f9319ea47ae38b9652f6e20a2f8cbea91fbe
6
+ metadata.gz: b37b3260b822043d80f028363791bb9e70dd0177c24c0fb3211692cda81c41e82b92d05cc6699d83c3d8fc239a34fc48847ed8cfef73a8db086090c656ba6d32
7
+ data.tar.gz: d6195fda6f3eea5806c435ce7836e83aad41a1002c18820248c48f95c69de4b0f80f053eacb82347733fa53e02f24935048708b9bd3733f8902c21bbdae88c57
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aws_sam_yarn_builder (0.1.4)
4
+ aws_sam_yarn_builder (0.2.3)
5
5
  activesupport (~> 5.2.0)
6
6
  slop (~> 4.6.0)
7
7
 
@@ -38,4 +38,4 @@ DEPENDENCIES
38
38
  rake (~> 10.0)
39
39
 
40
40
  BUNDLED WITH
41
- 1.16.1
41
+ 1.17.3
@@ -7,11 +7,37 @@ module AwsSamYarnBuilder
7
7
  def build!
8
8
  if options[:function]
9
9
  build_single_function!
10
+ elsif options[:unified]
11
+ build_unified_template!
10
12
  else
11
13
  build_full_template!
12
14
  end
13
15
  end
14
16
 
17
+ def build_unified_template!
18
+ reset_build_dir!
19
+ reset_staging_dir!
20
+
21
+ local_dependencies = template.function_resources.map do |function|
22
+ get_local_file_dependencies(function)
23
+ end.flatten.uniq.compact
24
+
25
+ local_dependencies.each do |d|
26
+ d.pack destination_staging_dir
27
+ end
28
+
29
+ function_resource = template.function_resources.first
30
+
31
+ package = package_from_function(function_resource)
32
+
33
+ package.pack destination_staging_dir
34
+ package.build "UnifiedPackage", destination_dir, destination_staging_dir
35
+
36
+ template.write_to_output(destination_dir, template_base_dir, true)
37
+
38
+ FileUtils.rm_rf(destination_staging_dir)
39
+ end
40
+
15
41
  def build_full_template!
16
42
  reset_build_dir!
17
43
  reset_staging_dir!
@@ -7,6 +7,7 @@ module AwsSamYarnBuilder
7
7
  o.string "-d", "--destination", "path to use for the output of the build process", default: "./.aws-sam"
8
8
  o.string "-t", "--template-file", "path to the SAM template file", default: "./template.yml"
9
9
  o.string "-f", "--function", "The logical ID of a single function to build (optional)"
10
+ o.bool "-u", "--unified-package", "All the functions in the template point to the same CodeUri location, so only create a single package"
10
11
 
11
12
  o.on "--help" do
12
13
  puts o
@@ -42,9 +42,9 @@ module AwsSamYarnBuilder
42
42
  self.contents = contents
43
43
  end
44
44
 
45
- def write_to_output(output, source_directory)
45
+ def write_to_output(output, source_directory, unified = false)
46
46
  File.open(File.join(output, "template.yaml"), "w+") do |file|
47
- file << transformed_contents(source_directory)
47
+ file << transformed_contents(source_directory, unified)
48
48
  end
49
49
  end
50
50
 
@@ -70,8 +70,8 @@ module AwsSamYarnBuilder
70
70
  @document ||= YAML.load(contents)
71
71
  end
72
72
 
73
- def transformed_contents(source_directory)
74
- contents_with_transformed_step_function_definitions(contents_with_transformed_function_paths(contents), source_directory)
73
+ def transformed_contents(source_directory, unified)
74
+ contents_with_transformed_step_function_definitions(contents_with_transformed_function_paths(contents, unified), source_directory)
75
75
  end
76
76
 
77
77
  def contents_with_transformed_step_function_definitions(c, source_directory)
@@ -84,9 +84,15 @@ module AwsSamYarnBuilder
84
84
  File.read(File.expand_path(File.join(source_directory, definition_uri)))
85
85
  end
86
86
 
87
- def contents_with_transformed_function_paths(c)
88
- c.gsub(/CodeUri:\s*(.*)/) do |_|
89
- "CodeUri: ./#{find_function_name_for_code_uri($1)}"
87
+ def contents_with_transformed_function_paths(c, unified)
88
+ if unified
89
+ c.gsub(/CodeUri:\s*(.*)/) do |_|
90
+ "CodeUri: ./UnifiedPackage"
91
+ end
92
+ else
93
+ c.gsub(/CodeUri:\s*(.*)/) do |_|
94
+ "CodeUri: ./#{find_function_name_for_code_uri($1)}"
95
+ end
90
96
  end
91
97
  end
92
98
 
@@ -1,3 +1,3 @@
1
1
  module AwsSamYarnBuilder
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_sam_yarn_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Allam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-17 00:00:00.000000000 Z
11
+ date: 2019-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop