hecks 0.0.8
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 +7 -0
- data/bin/hecks +6 -0
- data/bin/hecks_console +10 -0
- data/lib/adapters/adapters.rb +6 -0
- data/lib/adapters/events/events.rb +27 -0
- data/lib/adapters/logger/logger.rb +18 -0
- data/lib/adapters/memory_database/memory_database.rb +18 -0
- data/lib/adapters/resource_server/methods.rb +22 -0
- data/lib/adapters/resource_server/methods/create.rb +49 -0
- data/lib/adapters/resource_server/methods/delete.rb +45 -0
- data/lib/adapters/resource_server/methods/read.rb +44 -0
- data/lib/adapters/resource_server/methods/update.rb +50 -0
- data/lib/adapters/resource_server/resource_server.rb +52 -0
- data/lib/adapters/validator/validator.rb +33 -0
- data/lib/application/application.rb +45 -0
- data/lib/application/commands/commands.rb +5 -0
- data/lib/application/commands/create.rb +52 -0
- data/lib/application/commands/crud_handler.rb +40 -0
- data/lib/application/commands/delete.rb +40 -0
- data/lib/application/commands/runner.rb +48 -0
- data/lib/application/commands/update.rb +41 -0
- data/lib/application/queries/find_by_id.rb +19 -0
- data/lib/application/queries/queries.rb +2 -0
- data/lib/application/queries/query_runner.rb +28 -0
- data/lib/cli/cli.rb +24 -0
- data/lib/cli/command_runner.rb +25 -0
- data/lib/cli/commands.rb +5 -0
- data/lib/cli/commands/build.rb +10 -0
- data/lib/cli/commands/console.rb +8 -0
- data/lib/cli/commands/generate.rb +26 -0
- data/lib/cli/commands/generate/builder.rb +60 -0
- data/lib/cli/commands/generate/builder/aggregate_command_line_builder.rb +18 -0
- data/lib/cli/commands/generate/builder/reference_command_line_builder.rb +19 -0
- data/lib/cli/commands/generate/builder/value_object_command_line_builder.rb +19 -0
- data/lib/cli/commands/generate/generate_aws_package.rb +17 -0
- data/lib/cli/commands/generate/generate_binary_package.rb +92 -0
- data/lib/cli/commands/generate/generate_domain_object.rb +71 -0
- data/lib/cli/commands/generate/generate_domain_object/assignment_template.rb +36 -0
- data/lib/cli/commands/generate/generate_domain_object/option_formatter.rb +30 -0
- data/lib/cli/commands/generate/generate_lambda_package.rb +20 -0
- data/lib/cli/commands/generate/generate_resource_server.rb +17 -0
- data/lib/cli/commands/generate/new.rb +47 -0
- data/lib/cli/commands/generate/templates/aggregate/lib/domain/%name%/%head_name%.rb.tt +16 -0
- data/lib/cli/commands/generate/templates/aggregate/lib/domain/%name%/%name%.rb.tt +9 -0
- data/lib/cli/commands/generate/templates/aggregate/lib/domain/%name%/repository.rb.tt +40 -0
- data/lib/cli/commands/generate/templates/binary_package/build/linux-x86_64/lib/app/hello.rb +1 -0
- data/lib/cli/commands/generate/templates/binary_package/build/resources/%domain_name%.rb.tt +17 -0
- data/lib/cli/commands/generate/templates/binary_package/build/resources/Dockerfile.tt +8 -0
- data/lib/cli/commands/generate/templates/binary_package/build/resources/Gemfile.tt +4 -0
- data/lib/cli/commands/generate/templates/binary_package/build/resources/bundle/config +3 -0
- data/lib/cli/commands/generate/templates/binary_package/build/resources/wrapper.tt +13 -0
- data/lib/cli/commands/generate/templates/domain/%name%.gemspec.tt +12 -0
- data/lib/cli/commands/generate/templates/domain/Version +1 -0
- data/lib/cli/commands/generate/templates/domain/lib/%name%.rb.tt +21 -0
- data/lib/cli/commands/generate/templates/domain/spec/spec_helper.rb.tt +4 -0
- data/lib/cli/commands/generate/templates/lambda_package/handler.js.tt +12 -0
- data/lib/cli/commands/generate/templates/lambda_package/serverless.yml.tt +100 -0
- data/lib/cli/commands/generate/templates/reference/lib/domain/%module_name%/%file_name%.rb.tt +25 -0
- data/lib/cli/commands/generate/templates/resource_server/config.ru.tt +8 -0
- data/lib/cli/commands/generate/templates/value_object/lib/domain/%module_name%/%name%.rb.tt +24 -0
- data/lib/cli/commands/package.rb +16 -0
- data/lib/cli/commands/test.rb +41 -0
- data/lib/console/commands.rb +9 -0
- data/lib/console/console.rb +24 -0
- data/lib/domain_builder/attribute.rb +33 -0
- data/lib/domain_builder/domain.rb +17 -0
- data/lib/domain_builder/domain_builder.rb +35 -0
- data/lib/domain_builder/domain_module.rb +26 -0
- data/lib/domain_builder/domain_object.rb +37 -0
- data/lib/domain_builder/head.rb +6 -0
- data/lib/domain_builder/reference.rb +17 -0
- data/lib/domain_builder/value.rb +6 -0
- data/lib/hecks.rb +7 -0
- metadata +229 -0
@@ -0,0 +1 @@
|
|
1
|
+
puts "HELLO!"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'hecks'
|
2
|
+
require '<%= domain_name %>'
|
3
|
+
|
4
|
+
app = Hecks::Adapters::Application.new(domain: <%= domain_name.camelcase %>)
|
5
|
+
|
6
|
+
# Ruby 2.2.2 doesn't support Fixnum#positive?, so monkey patch it.
|
7
|
+
class Fixnum
|
8
|
+
def positive?
|
9
|
+
self > 0
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
domain_module = ARGV[0].to_sym
|
14
|
+
method = ARGV[1]
|
15
|
+
data = JSON.parse(ARGV[2], symbolize_names: true)
|
16
|
+
|
17
|
+
puts app[domain_module].send(method, data).call.result.inspect
|
@@ -0,0 +1,8 @@
|
|
1
|
+
FROM ruby:2.2
|
2
|
+
|
3
|
+
COPY <%= domain_name %>-0.0.0.gem /usr/src/app/<%= domain_name %>-0.0.0.gem
|
4
|
+
RUN gem install /usr/src/app/<%= domain_name %>-0.0.0.gem
|
5
|
+
COPY Gemfile /usr/src/app/Gemfile
|
6
|
+
RUN cd /usr/src/app/ && bundle package
|
7
|
+
RUN cd /usr/src/app/ && bundle install --path vendor
|
8
|
+
RUN ls /usr/src/app/
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
# Figure out where this script is located.
|
5
|
+
SELFDIR="`dirname \"$0\"`"
|
6
|
+
SELFDIR="`cd \"$SELFDIR\" && pwd`"
|
7
|
+
|
8
|
+
# Tell Bundler where the Gemfile and gems are.
|
9
|
+
export BUNDLE_GEMFILE="$SELFDIR/lib/app/Gemfile"
|
10
|
+
unset BUNDLE_IGNORE_CONFIG
|
11
|
+
|
12
|
+
# Run the actual app using the bundled Ruby interpreter, with Bundler activated.
|
13
|
+
exec "$SELFDIR/lib/ruby/bin/ruby" -rbundler/setup "$SELFDIR/lib/app/<%= domain_name %>.rb" "$@"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = '<%= name %>'
|
3
|
+
s.homepage = ""
|
4
|
+
s.version = File.read('Version').gsub("\n", '')
|
5
|
+
s.date = '2016-09-12'
|
6
|
+
s.summary = "Summary"
|
7
|
+
s.description = "Description"
|
8
|
+
s.authors = ["Author"]
|
9
|
+
s.email = 'email@example.com'
|
10
|
+
s.files = Dir["lib/**/*"]
|
11
|
+
s.license = 'MIT'
|
12
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module <%= module_name %>
|
2
|
+
Dir[File.dirname(__FILE__) + "/domain/**/*.rb"].each {|file| require file}
|
3
|
+
|
4
|
+
def self.domain_modules
|
5
|
+
Domain.constants.map { |name| Domain.const_get(name)}
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.repositories
|
9
|
+
domain_modules.map do |domain_module|
|
10
|
+
[module_name(domain_module), domain_module.const_get(:Repository)]
|
11
|
+
end.to_h
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.module_name(domain_module)
|
15
|
+
domain_module.to_s.downcase.split("::").last.to_sym
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.spec_path
|
19
|
+
File.dirname(__FILE__) + '/../HECKS'
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const spawn = require('child_process').spawn;
|
4
|
+
|
5
|
+
module.exports.<%= domain_name %> = (event, context, callback) => {
|
6
|
+
var app = '<%= domain_name %>/<%= domain_name %>'
|
7
|
+
var data = JSON.stringify(event['data'])
|
8
|
+
var command = app + ' ' + event['module'] + ' ' + event['method'] + ' ' + JSON.stringify(data)
|
9
|
+
const child = exec(command, (result) => {
|
10
|
+
context.done(result);
|
11
|
+
});
|
12
|
+
};
|
@@ -0,0 +1,100 @@
|
|
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: lambda
|
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
|
+
# - exclude-me-dir/**
|
55
|
+
|
56
|
+
functions:
|
57
|
+
<%= domain_name %>:
|
58
|
+
handler: handler.<%= domain_name %>
|
59
|
+
|
60
|
+
# The following are a few example events you can configure
|
61
|
+
# NOTE: Please make sure to change your handler code to work with those events
|
62
|
+
# Check the event documentation for details
|
63
|
+
# events:
|
64
|
+
# - http:
|
65
|
+
# path: users/create
|
66
|
+
# method: get
|
67
|
+
# - s3: ${env:BUCKET}
|
68
|
+
# - schedule: rate(10 minutes)
|
69
|
+
# - sns: greeter-topic
|
70
|
+
# - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000
|
71
|
+
# - alexaSkill
|
72
|
+
# - iot:
|
73
|
+
# sql: "SELECT * FROM 'some_topic'"
|
74
|
+
# - cloudwatchEvent:
|
75
|
+
# event:
|
76
|
+
# source:
|
77
|
+
# - "aws.ec2"
|
78
|
+
# detail-type:
|
79
|
+
# - "EC2 Instance State-change Notification"
|
80
|
+
# detail:
|
81
|
+
# state:
|
82
|
+
# - pending
|
83
|
+
|
84
|
+
# Define function environment variables here
|
85
|
+
# environment:
|
86
|
+
# variable2: value2
|
87
|
+
|
88
|
+
# you can add CloudFormation resource templates here
|
89
|
+
#resources:
|
90
|
+
# Resources:
|
91
|
+
# NewResource:
|
92
|
+
# Type: AWS::S3::Bucket
|
93
|
+
# Properties:
|
94
|
+
# BucketName: my-new-bucket
|
95
|
+
# Outputs:
|
96
|
+
# NewOutput:
|
97
|
+
# Description: "Description for the output"
|
98
|
+
# Value: "Some output value"
|
99
|
+
Plugins:
|
100
|
+
- serverless-offline
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module <%= domain_name.camelize %>
|
2
|
+
module Domain
|
3
|
+
module <%= module_name.camelize %>
|
4
|
+
class <%= name.camelize %>
|
5
|
+
attr_accessor :id, :referenced_entity
|
6
|
+
|
7
|
+
def self.factory(group_attributes)
|
8
|
+
return <%= name.camelize %>.new(group_attributes) unless group_attributes.is_a?(Array)
|
9
|
+
group_attributes.map do |attributes|
|
10
|
+
<%= name.camelize %>.new(attributes)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(id:)
|
15
|
+
@id = id
|
16
|
+
@referenced_entity = <%= options[:referenced_entity] %>
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_json(config)
|
20
|
+
JSON.generate({id: @id, referenced_entity: @referenced_entity})
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module <%= domain_name.camelize %>
|
2
|
+
module Domain
|
3
|
+
module <%= module_name.camelize %>
|
4
|
+
class <%= name.camelize %>
|
5
|
+
attr_accessor <%= attributes_without_id_as_string %>
|
6
|
+
|
7
|
+
def self.factory(group_attributes)
|
8
|
+
return <%= name.camelize %>.new(group_attributes) unless group_attributes.is_a?(Array)
|
9
|
+
group_attributes.map do |attributes|
|
10
|
+
<%= name.camelize %>.new(attributes)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(<%= option_format('param_names') %>)
|
15
|
+
<%= assignment_template(attributes_without_id) %>
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_json(config)
|
19
|
+
JSON.generate(<%= option_format('keys_and_values') %>)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'generate/generate_lambda_package'
|
2
|
+
require_relative 'generate/generate_binary_package'
|
3
|
+
|
4
|
+
class Package < Thor
|
5
|
+
desc 'lambda', 'lambda'
|
6
|
+
register GenerateLambdaPackage,
|
7
|
+
'lambda',
|
8
|
+
'lambda',
|
9
|
+
'Generate Lambda Package'
|
10
|
+
|
11
|
+
desc 'binary', 'binary'
|
12
|
+
register GenerateBinaryPackage,
|
13
|
+
'binary',
|
14
|
+
'binary',
|
15
|
+
'Generate Binary Package'
|
16
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Hecks
|
2
|
+
class CLI < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
|
5
|
+
desc 'test','Regenerate the examples and run the specs'
|
6
|
+
def test
|
7
|
+
reset_example('pizza_builder')
|
8
|
+
build_binary_package('pizza_builder')
|
9
|
+
build_lambda_package('pizza_builder')
|
10
|
+
generate_resource_server('pizza_builder')
|
11
|
+
run('rspec -f d')
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'test_pizza_builder','Regenerate the examples and run the specs'
|
15
|
+
def test_pizza_builder
|
16
|
+
reset_example('pizza_builder')
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def reset_example(name)
|
22
|
+
run("cd spec/examples/#{name} && rm -rf lib")
|
23
|
+
run("cd spec/examples/#{name} && rm -rf spec")
|
24
|
+
run("cd spec/examples/#{name} && hecks new")
|
25
|
+
end
|
26
|
+
|
27
|
+
def build_binary_package(name)
|
28
|
+
run("cd spec/examples/#{name} && hecks package binary")
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_lambda_package(name)
|
32
|
+
run("cd spec/examples/#{name} && hecks package lambda")
|
33
|
+
end
|
34
|
+
|
35
|
+
def generate_resource_server(name)
|
36
|
+
run("cd spec/examples/#{name} && rm -rf config.ru")
|
37
|
+
run("cd spec/examples/#{name} && hecks generate resource_server")
|
38
|
+
run("cd spec/examples/#{name} && cd ../../..")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'irb'
|
2
|
+
require "irb/completion"
|
3
|
+
require "hecks"
|
4
|
+
require_relative 'commands'
|
5
|
+
|
6
|
+
module Hecks
|
7
|
+
module Console
|
8
|
+
def self.file
|
9
|
+
Dir.pwd.split('/').last
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.full_path
|
13
|
+
Dir.pwd + "/lib/" + file
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.domain
|
17
|
+
file.camelize.constantize
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.domain_name
|
21
|
+
domain.to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Hecks
|
2
|
+
class DomainBuilder
|
3
|
+
class Attribute
|
4
|
+
def initialize(string)
|
5
|
+
@string = string
|
6
|
+
end
|
7
|
+
|
8
|
+
def list?
|
9
|
+
@string.include?("[")
|
10
|
+
end
|
11
|
+
|
12
|
+
def name
|
13
|
+
@string.split(":").first
|
14
|
+
end
|
15
|
+
|
16
|
+
def type
|
17
|
+
@string.split(":").last.delete("[").delete("]").camelize
|
18
|
+
end
|
19
|
+
|
20
|
+
def domain_module
|
21
|
+
return unless @string.include?("::")
|
22
|
+
@string.split("::").first.split(":").last.camelize
|
23
|
+
end
|
24
|
+
|
25
|
+
def ==(other)
|
26
|
+
return false if other.name != name
|
27
|
+
return false if other.type != type
|
28
|
+
return false if other.domain_module != domain_module
|
29
|
+
return true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Hecks
|
2
|
+
class DomainBuilder
|
3
|
+
class Domain
|
4
|
+
attr_reader :domain_modules, :name
|
5
|
+
def initialize(name:)
|
6
|
+
@name = name
|
7
|
+
@domain_modules = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def module(name, &block)
|
11
|
+
result = DomainModule.new(name: name)
|
12
|
+
@domain_modules[name.to_sym] = result
|
13
|
+
yield(result)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'domain'
|
2
|
+
require_relative 'domain_module'
|
3
|
+
require_relative 'domain_object'
|
4
|
+
require_relative 'value'
|
5
|
+
require_relative 'head'
|
6
|
+
require_relative 'attribute'
|
7
|
+
require_relative 'reference'
|
8
|
+
|
9
|
+
module Hecks
|
10
|
+
def self.specification=(value)
|
11
|
+
@specification = value
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.specification
|
15
|
+
@specification
|
16
|
+
end
|
17
|
+
|
18
|
+
class DomainBuilder
|
19
|
+
attr_accessor :domain, :specification
|
20
|
+
|
21
|
+
def initialize(domain_name:, &block)
|
22
|
+
@domain = Domain.new(name: domain_name)
|
23
|
+
block.yield(@domain)
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def domain_modules
|
28
|
+
@domain.domain_modules
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.build(domain_name, &block)
|
32
|
+
Hecks.specification = new(domain_name: domain_name, &block)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|