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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 798ee36082afdda202f54dfb446727e79c38f99a
|
4
|
+
data.tar.gz: 120419fa4fcd0b8f0dc2401fea4482c37e5924e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f100beec30a025476d12fd3061cdddbf24a1111f8123805c890a4d654b611f59c674364c3fa820be9895cc9a4be4f235b86ad18574fc76c04d14e94e8c08eed
|
7
|
+
data.tar.gz: d2ee8bb2c264169866082e0b176a616ad8bb0fc02bd8c8468a5088faa6ca8acd4bfb70bfabe915f32c817343fc22355f4e2e8128ad165a09880dc95d91ad1b04
|
data/bin/hecks
CHANGED
data/bin/hecks-package
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
resources_path = File.expand_path(File.dirname(__FILE__)) + '/../lib/packager/resources'
|
3
|
+
lib_path = File.expand_path(File.dirname(__FILE__)) + '/../lib/packager'
|
4
|
+
|
5
|
+
bash_script =
|
6
|
+
<<-BASH_SCRIPT
|
7
|
+
set -xe
|
8
|
+
|
9
|
+
rm -rf package_build
|
10
|
+
rm -rf package
|
11
|
+
mkdir -p package_build
|
12
|
+
|
13
|
+
cp Gemfile package_build
|
14
|
+
|
15
|
+
cp Hecksfile package_build
|
16
|
+
|
17
|
+
bundle package --gemfile package_build/Gemfile
|
18
|
+
cp #{resources_path}/Dockerfile package_build
|
19
|
+
|
20
|
+
mkdir -p package_build/package/linux/ruby
|
21
|
+
mkdir -p package_build/package/linux/lib
|
22
|
+
mkdir -p package_build/package/linux/.bundle
|
23
|
+
|
24
|
+
mkdir -p package_build/package/osx/ruby
|
25
|
+
mkdir -p package_build/package/osx/lib
|
26
|
+
mkdir -p package_build/package/osx/.bundle
|
27
|
+
|
28
|
+
tar -xzf #{resources_path}/traveling-ruby-20150715-2.2.2-linux-x86_64.tar.gz -C package_build/package/linux/ruby
|
29
|
+
tar -xzf #{resources_path}/traveling-ruby-20150715-2.2.2-osx.tar.gz -C package_build/package/osx/ruby
|
30
|
+
|
31
|
+
docker build package_build -t binary_builder
|
32
|
+
|
33
|
+
CONTAINER_ID=`docker create binary_builder:latest`
|
34
|
+
|
35
|
+
docker cp $CONTAINER_ID:/usr/src/app/vendor package_build
|
36
|
+
docker cp $CONTAINER_ID:/usr/src/app/Gemfile.lock package_build
|
37
|
+
docker rm $CONTAINER_ID
|
38
|
+
|
39
|
+
cp -r package_build/Gemfile package_build/package/linux
|
40
|
+
cp -r package_build/Gemfile package_build/package/osx
|
41
|
+
cp -r package_build/Gemfile.lock package_build/package/linux
|
42
|
+
cp -r package_build/Gemfile.lock package_build/package/osx
|
43
|
+
|
44
|
+
cp -r package_build/vendor package_build/package/linux
|
45
|
+
cp -r package_build/vendor package_build/package/osx
|
46
|
+
|
47
|
+
cp #{resources_path}/app_binary package_build/package/linux/app
|
48
|
+
cp #{resources_path}/app_binary package_build/package/osx/app
|
49
|
+
|
50
|
+
cp #{resources_path}/bundle_config package_build/package/linux/.bundle/config
|
51
|
+
cp #{resources_path}/bundle_config package_build/package/osx/.bundle/config
|
52
|
+
|
53
|
+
cp -r #{lib_path}/** package_build/package/osx/lib
|
54
|
+
cp -r #{lib_path}/** package_build/package/linux/lib
|
55
|
+
|
56
|
+
cp -r package_build/package .
|
57
|
+
cp package_build/Gemfile.lock package/linux/osx
|
58
|
+
cp package_build/Gemfile.lock package/linux/linux
|
59
|
+
|
60
|
+
rm -rf package_build
|
61
|
+
BASH_SCRIPT
|
62
|
+
|
63
|
+
bash_script.split("/n").each do |command|
|
64
|
+
puts `#{command}`
|
65
|
+
end
|
data/bin/hecks_console
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require_relative '../lib/
|
4
|
-
require
|
3
|
+
require_relative '../lib/hecks'
|
4
|
+
require HecksConsole.full_path
|
5
|
+
|
6
|
+
puts File.dirname(__FILE__)
|
5
7
|
|
6
8
|
puts "Hecks Loaded!"
|
7
|
-
puts "Using the " +
|
9
|
+
puts "Using the " + HecksConsole.domain_name + " domain"
|
8
10
|
|
9
|
-
IRB::ExtendCommandBundle.include(
|
11
|
+
IRB::ExtendCommandBundle.include(HecksConsole::Commands)
|
10
12
|
IRB.start
|
data/lib/cli/build.rb
CHANGED
data/lib/cli/command_runner.rb
CHANGED
@@ -1,25 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
class
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
class HecksCLI < Thor
|
3
|
+
class CommandRunner
|
4
|
+
# Runs CLI Commands
|
5
|
+
def initialize(hexagon, name, dry_run = false)
|
6
|
+
@hexagon = hexagon
|
7
|
+
@dry_run = dry_run
|
8
|
+
@name = name
|
9
|
+
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def call(command)
|
12
|
+
output = full_command(command)
|
13
|
+
unless File.directory?('tmp')
|
14
|
+
FileUtils.mkdir('tmp')
|
15
|
+
end
|
16
|
+
File.open('tmp/hecks', 'a') { |file| file.write(output + "\n") }
|
17
|
+
return if dry_run
|
13
18
|
end
|
14
|
-
File.open('tmp/hecks', 'a') { |file| file.write(output + "\n") }
|
15
|
-
return if dry_run
|
16
|
-
end
|
17
19
|
|
18
|
-
|
20
|
+
private
|
19
21
|
|
20
|
-
|
22
|
+
attr_reader :hexagon, :dry_run, :name
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
def full_command(command)
|
25
|
+
(['hecks'] + command).join(' ')
|
26
|
+
end
|
24
27
|
end
|
25
28
|
end
|
data/lib/cli/console.rb
CHANGED
data/lib/cli/generate.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Generate Subcommands
|
2
4
|
class Generate < Thor
|
3
5
|
desc 'domain_objects', 'generate domain objects'
|
4
6
|
method_option :type,
|
@@ -8,25 +10,25 @@ class Generate < Thor
|
|
8
10
|
banner: '[OBJECT_TYPE]',
|
9
11
|
enum: %w(entity value_object aggregate reference) if File.file?('Domain') || File.file?('hecks.gemspec')
|
10
12
|
|
11
|
-
register(
|
13
|
+
register(HecksDomain::CLI::GenerateDomainObject,
|
12
14
|
'domain_object',
|
13
15
|
'domain_object',
|
14
16
|
'Generate Domain Objects') if File.file?('Domain')
|
15
17
|
|
16
18
|
desc 'resource_server', 'generate resource_server adapter'
|
17
|
-
register(
|
19
|
+
register(HecksAdapters::ResourceServer::CLI::GenerateResourceServer,
|
18
20
|
'resource_server',
|
19
21
|
'resource_server',
|
20
22
|
'Generate A Resource Server for a domain') if File.file?('Domain')
|
21
23
|
|
22
24
|
desc 'sql_database', 'generate SQL database adapter'
|
23
|
-
register(
|
25
|
+
register(HecksAdapters::SQLDatabase::CLI::GenerateSQLDatabase,
|
24
26
|
'sql_database',
|
25
27
|
'sql_database',
|
26
28
|
'Generate a SQL Server Database adapter') if File.file?('Domain')
|
27
29
|
|
28
30
|
desc 'domain_migrations', 'generate migrations for the sql database adapter based on your domain'
|
29
|
-
register(
|
31
|
+
register(HecksAdapters::SQLDatabase::CLI::GenerateDomainMigrations,
|
30
32
|
'domain_migrations',
|
31
33
|
'domain_migrations',
|
32
34
|
'Generate Domain Migrations')
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'active_support/inflector'
|
3
|
+
require 'hecks-adapters-resource-server'
|
4
|
+
require 'hecks-adapters-sql-database'
|
5
|
+
|
6
|
+
require_relative 'generate'
|
7
|
+
require_relative 'test'
|
8
|
+
require_relative 'console'
|
9
|
+
require_relative 'command_runner'
|
10
|
+
require_relative 'build'
|
11
|
+
|
12
|
+
|
13
|
+
# A command line interface for generating and interacting with Hecks domains
|
14
|
+
class HecksCLI < Thor
|
15
|
+
package_name 'hecks'
|
16
|
+
|
17
|
+
desc 'generate', 'generate'
|
18
|
+
subcommand('generate', Generate)
|
19
|
+
|
20
|
+
desc 'test', 'test'
|
21
|
+
subcommand('test', Test) if File.file?('hecks.gemspec')
|
22
|
+
|
23
|
+
long_desc 'Generate a domain'
|
24
|
+
method_option :dryrun, aliases: '-d', type: :boolean, desc: 'Output commands without running'
|
25
|
+
|
26
|
+
register(HecksDomain::CLI::New, 'new', 'new', 'Create a new Domain') if File.file?('Domain')
|
27
|
+
end
|
data/lib/cli/test.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# Test subcommands
|
1
2
|
class Test < Thor
|
2
3
|
include Thor::Actions
|
3
4
|
|
@@ -31,26 +32,26 @@ class Test < Thor
|
|
31
32
|
private
|
32
33
|
|
33
34
|
def generate_sql_database(name)
|
34
|
-
run("cd ../
|
35
|
+
run("cd ../example/#{name} && hecks generate sql_database")
|
35
36
|
end
|
36
37
|
|
37
38
|
def reset_example(name)
|
38
|
-
run("cd ../
|
39
|
-
run("cd ../
|
40
|
-
run("cd ../
|
39
|
+
run("cd ../example/#{name} && rm -rf lib")
|
40
|
+
run("cd ../example/#{name} && rm -rf spec")
|
41
|
+
run("cd ../example/#{name} && hecks new")
|
41
42
|
end
|
42
43
|
|
43
44
|
def build_binary_package(name)
|
44
|
-
run("cd ../
|
45
|
+
run("cd ../example/#{name} && hecks package binary #{'-n' if options[:no_cache]}")
|
45
46
|
end
|
46
47
|
|
47
48
|
def build_lambda_package(name)
|
48
|
-
run("cd ../
|
49
|
+
run("cd ../example/#{name} && hecks package lambda")
|
49
50
|
end
|
50
51
|
|
51
52
|
def generate_resource_server(name)
|
52
|
-
run("cd ../
|
53
|
-
run("cd ../
|
54
|
-
run("cd ../
|
53
|
+
run("cd ../example/#{name} && rm -rf config.ru")
|
54
|
+
run("cd ../example/#{name} && hecks generate resource_server")
|
55
|
+
run("cd ../example/#{name}")
|
55
56
|
end
|
56
57
|
end
|
data/lib/console/commands.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
1
|
+
module HecksConsole
|
2
|
+
# mixin methods to the console
|
3
|
+
module Commands
|
4
|
+
def app
|
5
|
+
@app ||= HecksApplication.new(domain: HecksConsole.domain)
|
7
6
|
end
|
8
7
|
end
|
9
8
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'commands'
|
data/lib/hecks.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require '
|
3
|
-
require 'hecks-
|
4
|
-
|
5
|
-
require_relative 'cli'
|
6
|
-
require_relative 'console'
|
7
|
-
require 'hecks-adapters'
|
2
|
+
require 'thor'
|
3
|
+
require 'hecks-adapters-dynamodb'
|
4
|
+
require 'hecks-plugins-json-validator'
|
5
|
+
require_relative 'cli/hecks-cli'
|
6
|
+
require_relative 'console/hecks-console'
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module HecksPackager
|
2
|
+
# Runs operations on the domain
|
3
|
+
class AppRunner
|
4
|
+
def initialize(args:, application:)
|
5
|
+
@args = Args.new(args)
|
6
|
+
@application = application
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
domain_module.send(args.method, args.data).call
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_reader :args, :application
|
16
|
+
|
17
|
+
def domain_module
|
18
|
+
application[args.domain_module]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module HecksPackager
|
2
|
+
# represents the args passed in
|
3
|
+
class Args
|
4
|
+
attr_reader :method
|
5
|
+
|
6
|
+
def initialize(command_args)
|
7
|
+
@domain_module = command_args[0]
|
8
|
+
@method = command_args[1]
|
9
|
+
@data = command_args[2]
|
10
|
+
end
|
11
|
+
|
12
|
+
def domain_module
|
13
|
+
@domain_module.to_sym
|
14
|
+
end
|
15
|
+
|
16
|
+
def data
|
17
|
+
json = JSON.parse(@data, symbolize_names: true)
|
18
|
+
|
19
|
+
if(@method == 'delete')
|
20
|
+
return json[:id]
|
21
|
+
else
|
22
|
+
json
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'getoptlong'
|
3
|
+
|
4
|
+
Bundler.require
|
5
|
+
|
6
|
+
require_relative 'args'
|
7
|
+
require_relative 'compatibility/fixnum'
|
8
|
+
require_relative 'app_runner'
|
9
|
+
require_relative 'query_runner'
|
10
|
+
|
11
|
+
load('Hecksfile')
|
12
|
+
|
13
|
+
opts = GetoptLong.new(
|
14
|
+
[ '--module', '-m', GetoptLong::REQUIRED_ARGUMENT ],
|
15
|
+
[ '--command', '-c', GetoptLong::REQUIRED_ARGUMENT ],
|
16
|
+
[ '--data', '-d', GetoptLong::REQUIRED_ARGUMENT ]
|
17
|
+
)
|
18
|
+
|
19
|
+
domain_module = ''
|
20
|
+
command = ''
|
21
|
+
data = ''
|
22
|
+
opts.each do |opt, arg|
|
23
|
+
case opt
|
24
|
+
when '--module'
|
25
|
+
domain_module = arg
|
26
|
+
when '--command'
|
27
|
+
command = arg
|
28
|
+
when '--query'
|
29
|
+
query = arg
|
30
|
+
when '--data'
|
31
|
+
data = arg
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
if command == 'read'
|
36
|
+
puts HecksPackager::QueryRunner.new(args: [domain_module, command, data], application: HecksApp).call.to_json
|
37
|
+
else
|
38
|
+
puts HecksPackager::AppRunner.new(args: [domain_module, command, data], application: HecksApp).call.result.to_json
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module HecksPackager
|
2
|
+
# A Query runner
|
3
|
+
class QueryRunner
|
4
|
+
def initialize(args:, application:)
|
5
|
+
@args = Args.new(args)
|
6
|
+
@application = application
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
domain_module.send(args.method, args.data)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_reader :args, :application
|
16
|
+
|
17
|
+
def domain_module
|
18
|
+
application[args.domain_module]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
FROM ruby:2.2
|
2
|
+
|
3
|
+
COPY vendor /usr/src/app/vendor
|
4
|
+
|
5
|
+
COPY Gemfile /usr/src/app/Gemfile
|
6
|
+
COPY Gemfile.lock /usr/src/app/Gemfile.lock
|
7
|
+
run gem uninstall -i /usr/local/lib/ruby/gems/2.2.0 bundler --force -x
|
8
|
+
run gem install bundler -v 1.9.9
|
9
|
+
run gem list bundler
|
10
|
+
RUN cd /usr/src/app/ && ls
|
11
|
+
RUN cd /usr/src/app/ && bundle install --path vendor
|