hecks 0.1.4.rc → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/hecks +1 -1
- data/bin/hecks-package +65 -0
- data/bin/hecks_console +6 -4
- data/bin/hecks_serverless +6 -0
- data/lib/cli/build.rb +1 -0
- data/lib/cli/command_runner.rb +20 -17
- data/lib/cli/console.rb +2 -0
- data/lib/cli/generate.rb +6 -4
- data/lib/cli/hecks-cli.rb +27 -0
- data/lib/cli/test.rb +10 -9
- data/lib/console/commands.rb +5 -6
- data/lib/console/hecks-console.rb +1 -0
- data/lib/hecks.rb +5 -6
- data/lib/packager/README.md +0 -0
- data/lib/packager/app_runner.rb +21 -0
- data/lib/packager/args.rb +26 -0
- data/lib/packager/compatibility/fixnum.rb +6 -0
- data/lib/packager/hecks.rb +39 -0
- data/lib/packager/query_runner.rb +21 -0
- data/lib/packager/resources/Dockerfile +11 -0
- data/lib/packager/resources/app_binary +7 -0
- data/lib/packager/{templates/binary_package/build/resources/bundle/config → resources/bundle_config} +0 -0
- data/lib/packager/resources/traveling-ruby-20150715-2.2.2-linux-x86_64.tar.gz +0 -0
- data/lib/packager/resources/traveling-ruby-20150715-2.2.2-osx.tar.gz +0 -0
- data/lib/serverless/Domain +32 -0
- data/lib/serverless/cli.rb +75 -0
- data/lib/serverless/resources/command_name.js +5 -0
- data/lib/serverless/resources/environment.js +7 -0
- data/lib/serverless/resources/handler.js.tt +28 -0
- data/lib/serverless/resources/run_binary.js +22 -0
- data/lib/serverless/resources/serverless.yml +20 -0
- metadata +90 -38
- data/lib/cli.rb +0 -28
- data/lib/cli/package.rb +0 -13
- data/lib/console.rb +0 -23
- data/lib/packager.rb +0 -2
- data/lib/packager/generate_binary_package.rb +0 -105
- data/lib/packager/generate_lambda_package.rb +0 -26
- data/lib/packager/templates/binary_package/build/linux-x86_64/lib/app/hello.rb +0 -1
- data/lib/packager/templates/binary_package/build/resources/%domain_name%.rb.tt +0 -17
- data/lib/packager/templates/binary_package/build/resources/Dockerfile.tt +0 -8
- data/lib/packager/templates/binary_package/build/resources/Gemfile.tt +0 -4
- data/lib/packager/templates/binary_package/build/resources/wrapper.tt +0 -13
- data/lib/packager/templates/lambda_package/handler.js.tt +0 -12
- data/lib/packager/templates/lambda_package/serverless.yml.tt +0 -100
data/lib/cli/package.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
class Package < Thor
|
2
|
-
desc 'lambda', 'lambda'
|
3
|
-
register Hecks::Packager::CLI::GenerateLambdaPackage,
|
4
|
-
'lambda',
|
5
|
-
'lambda',
|
6
|
-
'Generate Lambda Package'
|
7
|
-
|
8
|
-
desc 'binary', 'binary'
|
9
|
-
register Hecks::Packager::CLI::GenerateBinaryPackage,
|
10
|
-
'binary',
|
11
|
-
'binary',
|
12
|
-
'Generate Binary Package'
|
13
|
-
end
|
data/lib/console.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'irb'
|
2
|
-
require "irb/completion"
|
3
|
-
require_relative 'console/commands'
|
4
|
-
|
5
|
-
module Hecks
|
6
|
-
module Console
|
7
|
-
def self.file
|
8
|
-
Dir.pwd.split('/').last
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.full_path
|
12
|
-
Dir.pwd + "/lib/" + file
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.domain
|
16
|
-
file.camelize.constantize
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.domain_name
|
20
|
-
domain.to_s
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/packager.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
module Hecks
|
2
|
-
module Packager
|
3
|
-
module CLI
|
4
|
-
class GenerateBinaryPackage < Thor::Group
|
5
|
-
include Thor::Actions
|
6
|
-
|
7
|
-
class_option :no_cache, aliases: '-n', desc: 'download resources', default: false, type: :boolean
|
8
|
-
|
9
|
-
HOST = "http://d6r77u77i8pq3.cloudfront.net/releases"
|
10
|
-
OSX_BINARY = "traveling-ruby-20150715-2.2.2-osx.tar.gz"
|
11
|
-
LINUX_BINARY = 'traveling-ruby-20150715-2.2.2-linux-x86_64.tar.gz'
|
12
|
-
BUILD_DIR = 'packages/binary/build'
|
13
|
-
RESOURCES_DIR = BUILD_DIR + '/resources'
|
14
|
-
OSX_DIR = BUILD_DIR + '/osx'
|
15
|
-
OSX_LIB_DIR = OSX_DIR + '/lib'
|
16
|
-
OSX_APP_DIR = OSX_LIB_DIR + '/app'
|
17
|
-
LINUX_DIR = BUILD_DIR + '/linux-x86_64'
|
18
|
-
LINUX_LIB_DIR = LINUX_DIR + 'lib'
|
19
|
-
LINUX_APP_DIR = LINUX_LIB_DIR + '/app'
|
20
|
-
|
21
|
-
def self.source_root
|
22
|
-
File.dirname(__FILE__) + '/templates'
|
23
|
-
end
|
24
|
-
|
25
|
-
def create_package_folder
|
26
|
-
directory('binary_package', './packages/binary')
|
27
|
-
end
|
28
|
-
|
29
|
-
def domain_name
|
30
|
-
Dir.pwd.split('/').last
|
31
|
-
end
|
32
|
-
|
33
|
-
def build
|
34
|
-
package(OSX_APP_DIR, OSX_LIB_DIR, OSX_BINARY, OSX_DIR)
|
35
|
-
package(LINUX_APP_DIR, LINUX_LIB_DIR, LINUX_BINARY, LINUX_DIR)
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def package(app_dir, lib_dir, binary, package_dir)
|
41
|
-
empty_directory(app_dir)
|
42
|
-
empty_directory(lib_dir + '/ruby')
|
43
|
-
return unless refresh_cache?(app_dir)
|
44
|
-
# download(binary, lib_dir)
|
45
|
-
copy_resources(app_dir, package_dir)
|
46
|
-
bundle_with_ruby_2_2_2(app_dir)
|
47
|
-
reduce_package_size(app_dir)
|
48
|
-
end
|
49
|
-
|
50
|
-
def refresh_cache?(app_dir)
|
51
|
-
return true if options[:no_cache]
|
52
|
-
return Dir[app_dir + '/*'].empty?
|
53
|
-
end
|
54
|
-
|
55
|
-
def copy_resources(app_dir, package_dir)
|
56
|
-
run("cp #{RESOURCES_DIR}/Gemfile #{app_dir}")
|
57
|
-
run("cp -rf #{RESOURCES_DIR}/bundle #{app_dir}/.bundle")
|
58
|
-
run("cp -rf #{RESOURCES_DIR}/#{domain_name}.rb #{app_dir}/#{domain_name}.rb")
|
59
|
-
run("cp -rf #{RESOURCES_DIR}/wrapper #{package_dir}/#{domain_name}")
|
60
|
-
run("cd #{package_dir} && chmod 744 #{domain_name}")
|
61
|
-
end
|
62
|
-
|
63
|
-
def download(binary, lib_dir)
|
64
|
-
run("cd #{RESOURCES_DIR} && curl -O #{HOST}/#{binary}")
|
65
|
-
run("tar -xzf #{RESOURCES_DIR}/#{binary} -C #{lib_dir}/ruby")
|
66
|
-
end
|
67
|
-
|
68
|
-
def bundle_with_ruby_2_2_2(app_dir)
|
69
|
-
run("cp -rf #{RESOURCES_DIR}/Dockerfile #{app_dir}")
|
70
|
-
run("cp #{domain_name}-0.0.0.gem #{app_dir}")
|
71
|
-
run("cd #{app_dir} && gem fetch hecks-application hecks-adapters-sql-database")
|
72
|
-
run("cd #{app_dir} && docker build -t #{domain_name} --no-cache .")
|
73
|
-
container = `docker create pizza_builder:latest`.gsub("\n", '')
|
74
|
-
run("docker cp #{container}:/usr/src/app/vendor #{app_dir}")
|
75
|
-
end
|
76
|
-
|
77
|
-
def reduce_package_size(app_dir)
|
78
|
-
files = %w(test tests spec features benchmark README* CHANGE* Change*
|
79
|
-
COPYING* LICENSE* MIT-LICENSE* TODO *.txt *.md *.rdoc doc docs example
|
80
|
-
examples sample doc-api)
|
81
|
-
|
82
|
-
files.each do |file|
|
83
|
-
run("rm -rf #{app_dir}/vendor/ruby/*/gems/*/#{file}")
|
84
|
-
end
|
85
|
-
|
86
|
-
run("rm -rf #{app_dir}/vendor/*/*/cache/*")
|
87
|
-
|
88
|
-
%w(.gitignore .travis.yml).each do |file|
|
89
|
-
run("rm -rf #{app_dir}/vendor/ruby/*/gems/*/#{file}")
|
90
|
-
end
|
91
|
-
|
92
|
-
%w(MAKEfile */Makefile */tmp).each do |file|
|
93
|
-
run("rm -f #{app_dir}/vendor/ruby/*/gems/*/ext/#{file}")
|
94
|
-
end
|
95
|
-
%w(*.c *.cpp *.h *.rl *extconf.rb *.java *.class *.md).each do |file|
|
96
|
-
run("find #{app_dir}/vendor/ruby -name '#{file}' | xargs rm -f")
|
97
|
-
end
|
98
|
-
%w(*.0 *.so *.bundle).each do |file|
|
99
|
-
run("find #{app_dir}/vendor/ruby/*/gems -name '#{file}' | xargs rm -f")
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Hecks
|
2
|
-
module Packager
|
3
|
-
module CLI
|
4
|
-
class GenerateLambdaPackage < Thor::Group
|
5
|
-
include Thor::Actions
|
6
|
-
|
7
|
-
def self.source_root
|
8
|
-
File.dirname(__FILE__) + '/templates'
|
9
|
-
end
|
10
|
-
|
11
|
-
def create_package_folder
|
12
|
-
directory('lambda_package', './packages/lambda')
|
13
|
-
end
|
14
|
-
|
15
|
-
def domain_name
|
16
|
-
Dir.pwd.split('/').last
|
17
|
-
end
|
18
|
-
|
19
|
-
def create_function
|
20
|
-
run("rm -rf packages/lambda/#{domain_name}")
|
21
|
-
run("cp -r packages/binary/build/osx packages/lambda/#{domain_name}")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
puts "HELLO!"
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'hecks'
|
2
|
-
require '<%= domain_name %>'
|
3
|
-
|
4
|
-
app = Hecks::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
|
@@ -1,8 +0,0 @@
|
|
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/
|
@@ -1,13 +0,0 @@
|
|
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" "$@"
|
@@ -1,12 +0,0 @@
|
|
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
|
-
};
|
@@ -1,100 +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: 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
|