hecks-cli 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4825de58b08b998ef1d7eef46264a27b29cb9bc8
4
+ data.tar.gz: 71d172063fe5972e1dfc64a5b98caa0c468d9169
5
+ SHA512:
6
+ metadata.gz: 147a2aec84081e75d4ada35786d5d4bb3dacba19cdb1c348554913129b8c289c6de4a6f782de2c138edb0bdf21623f9ba82f377077710ee89922a59918a6e882
7
+ data.tar.gz: ed61faa4d2f07aaa134e8071dfab3618544910b3f69e9beb24ca6e0e84a15f472195e9ad4e81df94a8ce86047c5bbea8af2ba8ea1f192b7197aadfe8239f8c49
data/lib/build.rb ADDED
@@ -0,0 +1,13 @@
1
+ module Hecks
2
+ class CLI < Thor
3
+ include Thor::Actions
4
+
5
+ desc 'build', 'build and install the hecks gem'
6
+
7
+ def build
8
+ run('hecks generate readme')
9
+ run('gem build hecks')
10
+ run('gem install hecks')
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ class CommandRunner
3
+ def initialize(hexagon, name, dry_run = false)
4
+ @hexagon = hexagon
5
+ @dry_run = dry_run
6
+ @name = name
7
+ end
8
+
9
+ def call(command)
10
+ output = full_command(command)
11
+ unless File.directory?('tmp')
12
+ FileUtils.mkdir('tmp')
13
+ end
14
+ File.open('tmp/hecks', 'a') { |file| file.write(output + "\n") }
15
+ return if dry_run
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :hexagon, :dry_run, :name
21
+
22
+ def full_command(command)
23
+ (['hecks'] + command).join(' ')
24
+ end
25
+ end
data/lib/console.rb ADDED
@@ -0,0 +1,8 @@
1
+ module Hecks
2
+ class CLI < Thor
3
+ desc 'console','REPL with domain helpers'
4
+ def console
5
+ exec 'hecks_console'
6
+ end
7
+ end
8
+ end
data/lib/generate.rb ADDED
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+ class Generate < Thor
3
+ desc 'domain_objects', 'generate domain objects'
4
+ method_option :type,
5
+ aliases: '-t',
6
+ required: true,
7
+ desc: 'The type of the domain object you want to generate',
8
+ banner: '[OBJECT_TYPE]',
9
+ enum: %w(entity value_object aggregate reference) if File.file?('Domain') || File.file?('hecks.gemspec')
10
+
11
+ register(Hecks::Domain::CLI::GenerateDomainObject,
12
+ 'domain_object',
13
+ 'domain_object',
14
+ 'Generate Domain Objects') if File.file?('Domain')
15
+
16
+ desc 'resource_server', 'generate resource_server adapter'
17
+ register(Hecks::Domain::Adapters::ResourceServer::CLI::GenerateResourceServer,
18
+ 'resource_server',
19
+ 'resource_server',
20
+ 'Generate A Resource Server for a domain') if File.file?('Domain')
21
+
22
+ desc 'sql_database', 'generate SQL database adapter'
23
+ register(Hecks::Domain::Adapters::SQLDatabase::CLI::GenerateSQLDatabase,
24
+ 'sql_database',
25
+ 'sql_database',
26
+ 'Generate a SQL Server Database adapter') if File.file?('Domain')
27
+
28
+ desc 'domain_migrations', 'generate migrations for the sql database adapter based on your domain'
29
+ register(Hecks::Domain::Adapters::SQLDatabase::CLI::GenerateDomainMigrations,
30
+ 'domain_migrations',
31
+ 'domain_migrations',
32
+ 'Generate Domain Migrations')
33
+
34
+ desc 'readme', 'Generate the hecks Readme with the latest examples'
35
+ end
data/lib/hecks-cli.rb ADDED
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+ require 'active_support/inflector'
3
+ require 'hecks-packager'
4
+ require_relative 'generate'
5
+ require_relative 'package'
6
+ require_relative 'test'
7
+ require_relative 'console'
8
+ require_relative 'command_runner'
9
+ require_relative 'build'
10
+
11
+ module Hecks
12
+ class CLI < Thor
13
+ package_name 'hecks'
14
+
15
+ desc 'generate', 'generate'
16
+ subcommand('generate', Generate)
17
+
18
+ desc 'package', 'package'
19
+ subcommand('package', Package) if File.file?('Domain')
20
+
21
+ desc 'test', 'test'
22
+ subcommand('test', Test) if File.file?('hecks.gemspec')
23
+
24
+ long_desc 'Generate a domain'
25
+ method_option :dryrun, aliases: '-d', type: :boolean, desc: 'Output commands without running'
26
+
27
+ register(Hecks::Domain::CLI::New, 'new', 'new', 'Create a new Domain') if File.file?('Domain')
28
+ end
29
+ end
data/lib/package.rb ADDED
@@ -0,0 +1,13 @@
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/test.rb ADDED
@@ -0,0 +1,56 @@
1
+ class Test < Thor
2
+ include Thor::Actions
3
+
4
+ class_option :no_cache, aliases: '-n', desc: 'download resources', default: false, type: :boolean
5
+
6
+ desc 'ci', 'Run and test the generators'
7
+ def ci
8
+ examples
9
+ packages
10
+ domain_adapters
11
+ end
12
+
13
+ desc 'domain_adapters', "run the domain adapter specs"
14
+ def domain_adapters
15
+ generate_resource_server('pizza_builder')
16
+ generate_sql_database('pizza_builder')
17
+ end
18
+
19
+ desc 'examples', 'Generate and run the example specs'
20
+ def examples
21
+ reset_example('pizza_builder')
22
+ run('rspec -f d')
23
+ end
24
+
25
+ desc 'packages', 'Generate and run the package specs'
26
+ def packages
27
+ build_binary_package('pizza_builder')
28
+ build_lambda_package('pizza_builder')
29
+ end
30
+
31
+ private
32
+
33
+ def generate_sql_database(name)
34
+ run("cd spec/examples/#{name} && hecks generate sql_database")
35
+ end
36
+
37
+ def reset_example(name)
38
+ run("cd spec/examples/#{name} && rm -rf lib")
39
+ run("cd spec/examples/#{name} && rm -rf spec")
40
+ run("cd spec/examples/#{name} && hecks new")
41
+ end
42
+
43
+ def build_binary_package(name)
44
+ run("cd spec/examples/#{name} && hecks package binary #{'-n' if options[:no_cache]}")
45
+ end
46
+
47
+ def build_lambda_package(name)
48
+ run("cd spec/examples/#{name} && hecks package lambda")
49
+ end
50
+
51
+ def generate_resource_server(name)
52
+ run("cd spec/examples/#{name} && rm -rf config.ru")
53
+ run("cd spec/examples/#{name} && hecks generate resource_server")
54
+ run("cd spec/examples/#{name}")
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hecks-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Young
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Make the Domain the center of your programming world
14
+ email: chris@example.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/build.rb
20
+ - lib/command_runner.rb
21
+ - lib/console.rb
22
+ - lib/generate.rb
23
+ - lib/hecks-cli.rb
24
+ - lib/package.rb
25
+ - lib/test.rb
26
+ homepage: https://github.com/chrisyoung/hecks-domain
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.6.10
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: DDD and Hexagonal Code Generators
50
+ test_files: []