hecks-serverless 0.1.7 → 0.1.8

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: a65c39b9d453d4bf7f6b7283c8e897220e13852c
4
- data.tar.gz: e4232bd78cabc0381e48fff8d348f89892fd0f67
3
+ metadata.gz: 6ac8cbc90f1f1adb0009c5c1a4e45cfda63b2bc1
4
+ data.tar.gz: fecb81abb24c150b0543c49824ec71f38e103736
5
5
  SHA512:
6
- metadata.gz: 47d8bc778fa21ecca7e056281f416796b9e927397d7377d78be839c3eba4a5ee57ee79abb0d6cb2095687e2c9c3beffe4fdb8a2b23949139bece552cebbd4644
7
- data.tar.gz: 9f8c1afa9e443c8310bf6cdbd558719c964133952e23cdfbbc1bd49454419258d433ac467aaf4483d94ae20a2e0348dbd14867843b10094212b89d879f503b4e
6
+ metadata.gz: c5327bdd87f7830921335efa7da67681986a4dc1933f546f8dc4fa4e8e2c1faf9dbf7b5c119e298f849ee11455b3db7031c2a35325953a45358ff6fc0f2ef6c2
7
+ data.tar.gz: d247149a1cb24f3a8b2a3a1e3323684d18f15aaa0feed9b3159331d9247576c8e10b36a065e08fc92fc0738165153673ff70c7bba2da2571ba878d6e3a419fd6
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+ require 'hecks'
3
+ load(File.dirname(__FILE__) + '/../lib/Domain')
4
+
5
+ module Hecks
6
+ class Serverless
7
+ class CLI < Thor
8
+ include Thor::Actions
9
+ package_name 'hecks_serverless'
10
+
11
+ def self.source_root
12
+ File.dirname(__FILE__) + '/../lib/resources'
13
+ end
14
+
15
+ desc "generate", "generate config for running a function on lambda"
16
+ def generate
17
+ copy_file "serverless.yml"
18
+ domain_modules = DOMAIN.domain_modules.values
19
+
20
+ text = domain_modules.flat_map do |dmodule|
21
+ @domain_module = dmodule
22
+ template "handler.js", "serverless/#{dmodule.name.downcase}.js"
23
+ ['create', 'read', 'update', 'delete'].flat_map do |function|
24
+ line(dmodule, function)
25
+ end
26
+ end
27
+
28
+ insert_into_file "serverless.yml",
29
+ "\n" + text.join("\n"),
30
+ :after => "functions:"
31
+ end
32
+
33
+ private
34
+
35
+ def domain_module
36
+ @domain_module.name.downcase
37
+ end
38
+
39
+ def line(domain_module, function)
40
+ <<-LINE
41
+ #{domain_module.name.downcase}.#{function}:
42
+ handler: serverless/#{domain_module.name.downcase}.#{function}
43
+ LINE
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ Hecks::Serverless::CLI.start(ARGV)
data/lib/Domain ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # New builder format (drop the types!):
4
+ # Pizzas::Pizza(:name, :description)
5
+ # *Toppings
6
+ # named_by :Chef
7
+ # Pizzas::Chef(:name)
8
+ #
9
+ # Orders::Order
10
+ # \*LineItem(:pizza_name, :quantity, :price)
11
+ # \Pizzas::Pizza
12
+ # NOTE: Domain should generate english sentences
13
+ # A pizza has many toppings, a name, and a description
14
+ # A pizza is named by a chef
15
+ # A chef has a name
16
+ # An Order has many line items
17
+ # A Line Item has a a pizza, pizza_name, a quantity and a price
18
+
19
+
20
+ DOMAIN ||= Hecks::Domain::DomainBuilder.build "pizza_builder" do |pizza_builder|
21
+ pizza_builder.module 'Pizzas' do |pizzas|
22
+ pizzas.head("Pizza").attributes('name:string', 'description:string', 'toppings:[topping]', 'chef:chef')
23
+ pizzas.value("Topping").attributes('name:string')
24
+ pizzas.value("Chef").attributes('name:string')
25
+ end
26
+
27
+ pizza_builder.module 'Orders' do |orders|
28
+ orders.head("Order").attributes('line_items:[line_item]')
29
+ orders.value("LineItem").attributes('pizza_name:string', 'quantity:integer', 'price:currency', "pizza:pizzas::pizza")
30
+ orders.reference("pizzas::pizza")
31
+ end
32
+ end
@@ -2,7 +2,7 @@
2
2
  const exec = require('child_process').exec
3
3
 
4
4
  module.exports.create = (event, context, callback) => {
5
- var command = 'package/osx/app -m pizzas -c create -d \'' + JSON.stringify(event) + "'"
5
+ var command = "package/osx/app -m <%= domain_module %> -c create -d '" + JSON.stringify(event) + "'"
6
6
 
7
7
  exec(command, (err, stdout, stderr) => {
8
8
  if (err) { console.error(err); return }
@@ -10,7 +10,7 @@ module.exports.create = (event, context, callback) => {
10
10
  console.error(stderr)
11
11
  const response = {
12
12
  statusCode: Object.keys(result.errors).length > 0 ? 500 : 200,
13
- body: { message: 'create command called on the pizzas module', input: event, result: result, errors: result['errors']}
13
+ body: { message: 'create command called on the <%= domain_module %> module', input: event, result: result, errors: result['errors']}
14
14
  };
15
15
  callback(null, response);
16
16
  });
@@ -0,0 +1,9 @@
1
+ service: pizza-builder
2
+ provider:
3
+ name: aws
4
+ runtime: nodejs4.3
5
+ exclude:
6
+ - spec/**
7
+ - tmp/**
8
+ - package/osx/**
9
+ functions:
@@ -0,0 +1,33 @@
1
+ service: pizza-builder
2
+ provider:
3
+ name: aws
4
+ runtime: nodejs4.3
5
+ exclude:
6
+ - spec/**
7
+ - tmp/**
8
+ - package/osx/**
9
+ functions:
10
+ pizzas.create:
11
+ handler: serverless/pizzas.create
12
+
13
+ pizzas.read:
14
+ handler: serverless/pizzas.read
15
+
16
+ pizzas.update:
17
+ handler: serverless/pizzas.update
18
+
19
+ pizzas.delete:
20
+ handler: serverless/pizzas.delete
21
+
22
+ orders.create:
23
+ handler: serverless/orders.create
24
+
25
+ orders.read:
26
+ handler: serverless/orders.read
27
+
28
+ orders.update:
29
+ handler: serverless/orders.update
30
+
31
+ orders.delete:
32
+ handler: serverless/orders.delete
33
+
metadata CHANGED
@@ -1,25 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hecks-serverless
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Young
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-12 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2017-04-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
13
27
  description: Hecks Serverless
14
28
  email: chris@example.com
15
29
  executables:
16
- - hecks-serverless
30
+ - hecks_serverless
17
31
  extensions: []
18
32
  extra_rdoc_files: []
19
33
  files:
20
- - bin/hecks-serverless
21
- - resources/pizzas.js
22
- - resources/serverless.yml
34
+ - bin/hecks_serverless
35
+ - lib/Domain
36
+ - lib/resources/handler.js.tt
37
+ - lib/resources/serverless.yml
38
+ - lib/serverless.yml
23
39
  homepage: https://github.com/chrisyoung/hecks-serverless
24
40
  licenses:
25
41
  - MIT
data/bin/hecks-serverless DELETED
@@ -1,10 +0,0 @@
1
- resources_path = File.expand_path(File.dirname(__FILE__)) + '/../resources'
2
-
3
- bash_script =
4
- <<-BASH_SCRIPT
5
- cp #{resources_path}/serverless.yml .
6
- mkdir -p serverless
7
- cp #{resources_path}/pizzas.js serverless
8
- BASH_SCRIPT
9
-
10
- puts `#{bash_script}`
@@ -1,115 +0,0 @@
1
- # Welcome to Serverless!
2
- #
3
- # This file is the main config file for your service.
4
- # It's very minimal at this point and uses default values.
5
- # You can always add more config options for more control.
6
- # We've included some commented out config examples here.
7
- # Just uncomment any of them to get that config option.
8
- #
9
- # For full config options, check the docs:
10
- # docs.serverless.com
11
- #
12
- # Happy Coding!
13
-
14
- service: aws-nodejs # NOTE: update this with your service name
15
-
16
- # You can pin your service to only deploy with a specific Serverless version
17
- # Check out our docs for more details
18
- # frameworkVersion: "=X.X.X"
19
-
20
- provider:
21
- name: aws
22
- runtime: nodejs4.3
23
-
24
- # you can overwrite defaults here
25
- # stage: dev
26
- # region: us-east-1
27
-
28
- # you can add statements to the Lambda function's IAM Role here
29
- # iamRoleStatements:
30
- # - Effect: "Allow"
31
- # Action:
32
- # - "s3:ListBucket"
33
- # Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
34
- # - Effect: "Allow"
35
- # Action:
36
- # - "s3:PutObject"
37
- # Resource:
38
- # Fn::Join:
39
- # - ""
40
- # - - "arn:aws:s3:::"
41
- # - "Ref" : "ServerlessDeploymentBucket"
42
-
43
- # you can define service wide environment variables here
44
- # environment:
45
- # variable1: value1
46
-
47
- # you can add packaging information here
48
- #package:
49
- # include:
50
- # - include-me.js
51
- # - include-me-dir/**
52
- exclude:
53
- # - exclude-me.js
54
- - spec/**
55
- - tmp/**
56
- - package/osx/**
57
- functions:
58
- # PIZZAS
59
- pizzas.create:
60
- handler: serverless/pizzas.create
61
- pizzas.read:
62
- handler: serverless/pizzas.read
63
- pizzas.update:
64
- handler: serverless/pizzas.update
65
- pizzas.delete:
66
- handler: serverless/pizzas.delete
67
- # ORDERS
68
- orders.create:
69
- handler: serverless/orders.create
70
- orders.read:
71
- handler: serverless/orders.read
72
- orders.update:
73
- handler: serverless/orders.update
74
- orders.delete:
75
- handler: serverless/orders.delete
76
-
77
- # The following are a few example events you can configure
78
- # NOTE: Please make sure to change your handler code to work with those events
79
- # Check the event documentation for details
80
- # events:
81
- # - http:
82
- # path: users/create
83
- # method: get
84
- # - s3: ${env:BUCKET}
85
- # - schedule: rate(10 minutes)
86
- # - sns: greeter-topic
87
- # - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000
88
- # - alexaSkill
89
- # - iot:
90
- # sql: "SELECT * FROM 'some_topic'"
91
- # - cloudwatchEvent:
92
- # event:
93
- # source:
94
- # - "aws.ec2"
95
- # detail-type:
96
- # - "EC2 Instance State-change Notification"
97
- # detail:
98
- # state:
99
- # - pending
100
-
101
- # Define function environment variables here
102
- # environment:
103
- # variable2: value2
104
-
105
- # you can add CloudFormation resource templates here
106
- #resources:
107
- # Resources:
108
- # NewResource:
109
- # Type: AWS::S3::Bucket
110
- # Properties:
111
- # BucketName: my-new-bucket
112
- # Outputs:
113
- # NewOutput:
114
- # Description: "Description for the output"
115
- # Value: "Some output value"