hanami 1.3.5 → 2.0.0.alpha1
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 +4 -4
- data/CHANGELOG.md +51 -41
- data/FEATURES.md +2 -12
- data/LICENSE.md +1 -1
- data/README.md +5 -8
- data/bin/hanami +6 -4
- data/hanami.gemspec +24 -28
- data/lib/hanami/application.rb +44 -176
- data/lib/hanami/boot.rb +6 -0
- data/lib/hanami/cli/commands/command.rb +21 -29
- data/lib/hanami/cli/commands/server.rb +63 -14
- data/lib/hanami/cli/commands.rb +5 -42
- data/lib/hanami/configuration/cookies.rb +24 -0
- data/lib/hanami/configuration/middleware.rb +8 -28
- data/lib/hanami/configuration/security.rb +141 -0
- data/lib/hanami/configuration/sessions.rb +50 -0
- data/lib/hanami/configuration.rb +181 -191
- data/lib/hanami/container.rb +107 -0
- data/lib/hanami/frameworks.rb +24 -18
- data/lib/hanami/routes.rb +17 -205
- data/lib/hanami/server.rb +5 -69
- data/lib/hanami/version.rb +3 -1
- data/lib/hanami.rb +39 -243
- metadata +36 -233
- data/lib/hanami/action/csrf_protection.rb +0 -211
- data/lib/hanami/action/routing_helpers.rb +0 -40
- data/lib/hanami/app.rb +0 -96
- data/lib/hanami/application_configuration.rb +0 -1495
- data/lib/hanami/application_name.rb +0 -108
- data/lib/hanami/application_namespace.rb +0 -14
- data/lib/hanami/assets/asset.rb +0 -72
- data/lib/hanami/assets/static.rb +0 -102
- data/lib/hanami/cli/commands/assets/precompile.rb +0 -42
- data/lib/hanami/cli/commands/assets.rb +0 -16
- data/lib/hanami/cli/commands/console.rb +0 -95
- data/lib/hanami/cli/commands/db/apply.rb +0 -32
- data/lib/hanami/cli/commands/db/console.rb +0 -44
- data/lib/hanami/cli/commands/db/create.rb +0 -32
- data/lib/hanami/cli/commands/db/drop.rb +0 -32
- data/lib/hanami/cli/commands/db/migrate.rb +0 -39
- data/lib/hanami/cli/commands/db/prepare.rb +0 -32
- data/lib/hanami/cli/commands/db/rollback.rb +0 -59
- data/lib/hanami/cli/commands/db/version.rb +0 -32
- data/lib/hanami/cli/commands/db.rb +0 -32
- data/lib/hanami/cli/commands/destroy/action.rb +0 -137
- data/lib/hanami/cli/commands/destroy/app.rb +0 -159
- data/lib/hanami/cli/commands/destroy/mailer.rb +0 -74
- data/lib/hanami/cli/commands/destroy/migration.rb +0 -51
- data/lib/hanami/cli/commands/destroy/model.rb +0 -84
- data/lib/hanami/cli/commands/destroy.rb +0 -26
- data/lib/hanami/cli/commands/generate/action/action.erb +0 -7
- data/lib/hanami/cli/commands/generate/action/action_spec.minitest.erb +0 -11
- data/lib/hanami/cli/commands/generate/action/action_spec.rspec.erb +0 -9
- data/lib/hanami/cli/commands/generate/action/action_without_view.erb +0 -7
- data/lib/hanami/cli/commands/generate/action/view.erb +0 -7
- data/lib/hanami/cli/commands/generate/action/view_spec.minitest.erb +0 -12
- data/lib/hanami/cli/commands/generate/action/view_spec.rspec.erb +0 -10
- data/lib/hanami/cli/commands/generate/action.rb +0 -321
- data/lib/hanami/cli/commands/generate/app/application.erb +0 -313
- data/lib/hanami/cli/commands/generate/app/favicon.ico +0 -0
- data/lib/hanami/cli/commands/generate/app/gitkeep.erb +0 -0
- data/lib/hanami/cli/commands/generate/app/layout.erb +0 -7
- data/lib/hanami/cli/commands/generate/app/layout_spec.minitest.erb +0 -10
- data/lib/hanami/cli/commands/generate/app/layout_spec.rspec.erb +0 -10
- data/lib/hanami/cli/commands/generate/app/routes.erb +0 -5
- data/lib/hanami/cli/commands/generate/app/template.erb.erb +0 -10
- data/lib/hanami/cli/commands/generate/app/template.haml.erb +0 -7
- data/lib/hanami/cli/commands/generate/app/template.slim.erb +0 -8
- data/lib/hanami/cli/commands/generate/app.rb +0 -243
- data/lib/hanami/cli/commands/generate/mailer/mailer.erb +0 -9
- data/lib/hanami/cli/commands/generate/mailer/mailer_spec.minitest.erb +0 -7
- data/lib/hanami/cli/commands/generate/mailer/mailer_spec.rspec.erb +0 -5
- data/lib/hanami/cli/commands/generate/mailer.rb +0 -104
- data/lib/hanami/cli/commands/generate/migration/migration.erb +0 -4
- data/lib/hanami/cli/commands/generate/migration.rb +0 -41
- data/lib/hanami/cli/commands/generate/model/entity.erb +0 -2
- data/lib/hanami/cli/commands/generate/model/entity_spec.minitest.erb +0 -5
- data/lib/hanami/cli/commands/generate/model/entity_spec.rspec.erb +0 -3
- data/lib/hanami/cli/commands/generate/model/migration.erb +0 -10
- data/lib/hanami/cli/commands/generate/model/repository.erb +0 -5
- data/lib/hanami/cli/commands/generate/model/repository_spec.minitest.erb +0 -5
- data/lib/hanami/cli/commands/generate/model/repository_spec.rspec.erb +0 -3
- data/lib/hanami/cli/commands/generate/model.rb +0 -125
- data/lib/hanami/cli/commands/generate/secret.rb +0 -48
- data/lib/hanami/cli/commands/generate.rb +0 -28
- data/lib/hanami/cli/commands/new/.env.development.erb +0 -3
- data/lib/hanami/cli/commands/new/.env.test.erb +0 -3
- data/lib/hanami/cli/commands/new/.gitkeep.erb +0 -0
- data/lib/hanami/cli/commands/new/Gemfile.erb +0 -57
- data/lib/hanami/cli/commands/new/README.md.erb +0 -33
- data/lib/hanami/cli/commands/new/config/boot.erb +0 -2
- data/lib/hanami/cli/commands/new/config/environment.erb +0 -49
- data/lib/hanami/cli/commands/new/config.ru.erb +0 -3
- data/lib/hanami/cli/commands/new/gitignore.erb +0 -4
- data/lib/hanami/cli/commands/new/gitignore_with_sqlite.erb +0 -5
- data/lib/hanami/cli/commands/new/hanamirc.erb +0 -3
- data/lib/hanami/cli/commands/new/lib/project.erb +0 -2
- data/lib/hanami/cli/commands/new/minitest/Rakefile.erb +0 -12
- data/lib/hanami/cli/commands/new/minitest/features_helper.erb +0 -11
- data/lib/hanami/cli/commands/new/minitest/spec_helper.erb +0 -7
- data/lib/hanami/cli/commands/new/rspec/Rakefile.erb +0 -9
- data/lib/hanami/cli/commands/new/rspec/capybara.erb +0 -8
- data/lib/hanami/cli/commands/new/rspec/features_helper.erb +0 -12
- data/lib/hanami/cli/commands/new/rspec/rspec.erb +0 -2
- data/lib/hanami/cli/commands/new/rspec/spec_helper.erb +0 -103
- data/lib/hanami/cli/commands/new/schema.sql.erb +0 -0
- data/lib/hanami/cli/commands/new.rb +0 -578
- data/lib/hanami/cli/commands/project.rb +0 -421
- data/lib/hanami/cli/commands/routes.rb +0 -21
- data/lib/hanami/cli/commands/templates.rb +0 -31
- data/lib/hanami/cli/commands/version.rb +0 -19
- data/lib/hanami/common_logger.rb +0 -109
- data/lib/hanami/components/app/assets.rb +0 -59
- data/lib/hanami/components/app/controller.rb +0 -74
- data/lib/hanami/components/app/routes.rb +0 -59
- data/lib/hanami/components/app/view.rb +0 -44
- data/lib/hanami/components/component.rb +0 -182
- data/lib/hanami/components/components.rb +0 -479
- data/lib/hanami/components/routes_inspector.rb +0 -72
- data/lib/hanami/components.rb +0 -156
- data/lib/hanami/config/cookies.rb +0 -69
- data/lib/hanami/config/framework_configuration.rb +0 -43
- data/lib/hanami/config/load_paths.rb +0 -46
- data/lib/hanami/config/mapper.rb +0 -47
- data/lib/hanami/config/routes.rb +0 -20
- data/lib/hanami/config/security.rb +0 -110
- data/lib/hanami/config/sessions.rb +0 -119
- data/lib/hanami/configuration/app.rb +0 -21
- data/lib/hanami/early_hints.rb +0 -129
- data/lib/hanami/env.rb +0 -69
- data/lib/hanami/environment.rb +0 -541
- data/lib/hanami/environment_application_configurations.rb +0 -37
- data/lib/hanami/hanamirc.rb +0 -169
- data/lib/hanami/mailer/glue.rb +0 -27
- data/lib/hanami/middleware_stack.rb +0 -172
- data/lib/hanami/rake_helper.rb +0 -78
- data/lib/hanami/rake_tasks.rb +0 -3
- data/lib/hanami/rendering_policy.rb +0 -94
- data/lib/hanami/routing/default.rb +0 -32
- data/lib/hanami/setup.rb +0 -3
- data/lib/hanami/static.rb +0 -63
- data/lib/hanami/templates/default.html.erb +0 -30
- data/lib/hanami/templates/welcome.html.erb +0 -52
- data/lib/hanami/views/default.rb +0 -37
- data/lib/hanami/views/default_template_finder.rb +0 -22
- data/lib/hanami/views/null_view.rb +0 -15
- data/lib/hanami/welcome.rb +0 -41
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
require "hanami/utils/kernel"
|
|
2
|
-
|
|
3
|
-
module Hanami
|
|
4
|
-
class CLI
|
|
5
|
-
module Commands
|
|
6
|
-
module Db
|
|
7
|
-
# @since 1.1.0
|
|
8
|
-
# @api private
|
|
9
|
-
class Rollback < Command
|
|
10
|
-
requires "model.sql"
|
|
11
|
-
|
|
12
|
-
desc "Rollback migrations"
|
|
13
|
-
|
|
14
|
-
argument :steps, desc: "Number of steps to rollback the database", default: 1
|
|
15
|
-
|
|
16
|
-
example [
|
|
17
|
-
" # Rollbacks latest migration",
|
|
18
|
-
"2 # Rollbacks last two migrations"
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
# @since 1.1.0
|
|
22
|
-
# @api private
|
|
23
|
-
def call(steps:, **)
|
|
24
|
-
context = Context.new(steps: steps)
|
|
25
|
-
context = assert_valid_steps!(context)
|
|
26
|
-
|
|
27
|
-
rollback_database(context)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
private
|
|
31
|
-
|
|
32
|
-
# @since 1.1.0
|
|
33
|
-
# @api private
|
|
34
|
-
def assert_valid_steps!(context)
|
|
35
|
-
context = context.with(steps: Utils::Kernel.Integer(context.steps.to_s))
|
|
36
|
-
handle_error(context) unless context.steps.positive?
|
|
37
|
-
context
|
|
38
|
-
rescue TypeError
|
|
39
|
-
handle_error(context)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# @since 1.1.0
|
|
43
|
-
# @api private
|
|
44
|
-
def rollback_database(context)
|
|
45
|
-
require "hanami/model/migrator"
|
|
46
|
-
Hanami::Model::Migrator.rollback(steps: context.steps)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# @since 1.1.0
|
|
50
|
-
# @api private
|
|
51
|
-
def handle_error(context)
|
|
52
|
-
warn "the number of steps must be a positive integer (you entered `#{context.steps}')."
|
|
53
|
-
exit(1)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module Hanami
|
|
2
|
-
class CLI
|
|
3
|
-
module Commands
|
|
4
|
-
module Db
|
|
5
|
-
# @since 1.1.0
|
|
6
|
-
# @api private
|
|
7
|
-
class Version < Command
|
|
8
|
-
requires "model.configuration.no_logger"
|
|
9
|
-
|
|
10
|
-
desc "Print the current migrated version"
|
|
11
|
-
|
|
12
|
-
# @since 1.1.0
|
|
13
|
-
# @api private
|
|
14
|
-
def call(**options)
|
|
15
|
-
context = Context.new(options: options)
|
|
16
|
-
|
|
17
|
-
print_database_version(context)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
# @since 1.1.0
|
|
23
|
-
# @api private
|
|
24
|
-
def print_database_version(*)
|
|
25
|
-
require "hanami/model/migrator"
|
|
26
|
-
puts Hanami::Model::Migrator.version
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module Hanami
|
|
2
|
-
# Hanami CLI
|
|
3
|
-
#
|
|
4
|
-
# @since 1.1.0
|
|
5
|
-
class CLI
|
|
6
|
-
module Commands
|
|
7
|
-
# @since 1.1.0
|
|
8
|
-
# @api private
|
|
9
|
-
module Db
|
|
10
|
-
require "hanami/cli/commands/db/version"
|
|
11
|
-
require "hanami/cli/commands/db/create"
|
|
12
|
-
require "hanami/cli/commands/db/drop"
|
|
13
|
-
require "hanami/cli/commands/db/migrate"
|
|
14
|
-
require "hanami/cli/commands/db/rollback"
|
|
15
|
-
require "hanami/cli/commands/db/prepare"
|
|
16
|
-
require "hanami/cli/commands/db/apply"
|
|
17
|
-
require "hanami/cli/commands/db/console"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
register "db" do |prefix|
|
|
22
|
-
prefix.register "version", Commands::Db::Version
|
|
23
|
-
prefix.register "create", Commands::Db::Create
|
|
24
|
-
prefix.register "drop", Commands::Db::Drop
|
|
25
|
-
prefix.register "migrate", Commands::Db::Migrate
|
|
26
|
-
prefix.register "rollback", Commands::Db::Rollback
|
|
27
|
-
prefix.register "prepare", Commands::Db::Prepare
|
|
28
|
-
prefix.register "apply", Commands::Db::Apply
|
|
29
|
-
prefix.register "console", Commands::Db::Console
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
module Hanami
|
|
2
|
-
class CLI
|
|
3
|
-
module Commands
|
|
4
|
-
module Destroy
|
|
5
|
-
# @since 1.1.0
|
|
6
|
-
# @api private
|
|
7
|
-
class Action < Command
|
|
8
|
-
desc "Destroy an action from app"
|
|
9
|
-
|
|
10
|
-
example [
|
|
11
|
-
"web home#index # Basic usage",
|
|
12
|
-
"admin users#index # Destroy from `admin` app"
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
argument :app, required: true, desc: "The application name (eg. `web`)"
|
|
16
|
-
argument :action, required: true, desc: "The action name (eg. `home#index`)"
|
|
17
|
-
|
|
18
|
-
# @since 1.1.0
|
|
19
|
-
# @api private
|
|
20
|
-
def call(app:, action:, **options)
|
|
21
|
-
app = Utils::String.underscore(app)
|
|
22
|
-
*controller, action = controller_and_action(action)
|
|
23
|
-
action_name = controller_and_action_name(controller, action)
|
|
24
|
-
|
|
25
|
-
context = Context.new(app: app, controller: controller, action: action, action_name: action_name, options: options)
|
|
26
|
-
|
|
27
|
-
assert_valid_app!(context)
|
|
28
|
-
|
|
29
|
-
remove_route(context)
|
|
30
|
-
destroy_view_spec(context)
|
|
31
|
-
destroy_action_spec(context)
|
|
32
|
-
destroy_templates(context)
|
|
33
|
-
destroy_view(context)
|
|
34
|
-
destroy_action(context)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
private
|
|
38
|
-
|
|
39
|
-
# @since 1.1.0
|
|
40
|
-
# @api private
|
|
41
|
-
def assert_valid_app!(context)
|
|
42
|
-
return if project.app?(context)
|
|
43
|
-
|
|
44
|
-
existing_apps = project.apps.map { |name| "`#{name}'" }.join(' ')
|
|
45
|
-
warn "`#{context.app}' is not a valid APP. Please specify one of: #{existing_apps}"
|
|
46
|
-
exit(1)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# @since 1.1.0
|
|
50
|
-
# @api private
|
|
51
|
-
def controller_and_action(name)
|
|
52
|
-
# FIXME: extract this regexp
|
|
53
|
-
name.split(/#|\//)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# @since 1.1.0
|
|
57
|
-
# @api private
|
|
58
|
-
def controller_and_action_name(controller, action)
|
|
59
|
-
# FIXME: extract this separator
|
|
60
|
-
[namespaced_controller(controller), action].join("#")
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# @since 1.1.0
|
|
64
|
-
# #api private
|
|
65
|
-
def namespaced_controller(controller)
|
|
66
|
-
controller.join("/")
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# @since 1.1.0
|
|
70
|
-
# @api private
|
|
71
|
-
def remove_route(context)
|
|
72
|
-
content = %r{#{context.action_name}}
|
|
73
|
-
destination = project.app_routes(context)
|
|
74
|
-
|
|
75
|
-
begin
|
|
76
|
-
files.remove_line(destination, content)
|
|
77
|
-
rescue ArgumentError
|
|
78
|
-
warn "cannot find `#{context.action_name}' in `#{context.app}' application."
|
|
79
|
-
warn "please run `hanami routes' to know the existing actions."
|
|
80
|
-
exit(1)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
say(:subtract, destination)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# @since 1.1.0
|
|
87
|
-
# @api private
|
|
88
|
-
def destroy_view_spec(context)
|
|
89
|
-
destination = project.view_spec(context)
|
|
90
|
-
return unless files.exist?(destination)
|
|
91
|
-
|
|
92
|
-
files.delete(destination)
|
|
93
|
-
say(:remove, destination)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
# @since 1.1.0
|
|
97
|
-
# @api private
|
|
98
|
-
def destroy_action_spec(context)
|
|
99
|
-
destination = project.action_spec(context)
|
|
100
|
-
|
|
101
|
-
files.delete(destination)
|
|
102
|
-
say(:remove, destination)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# @since 1.1.0
|
|
106
|
-
# @api private
|
|
107
|
-
def destroy_templates(context)
|
|
108
|
-
destinations = project.templates(context)
|
|
109
|
-
destinations.each do |destination|
|
|
110
|
-
files.delete(destination)
|
|
111
|
-
say(:remove, destination)
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# @since 1.1.0
|
|
116
|
-
# @api private
|
|
117
|
-
def destroy_view(context)
|
|
118
|
-
destination = project.view(context)
|
|
119
|
-
return unless files.exist?(destination)
|
|
120
|
-
|
|
121
|
-
files.delete(destination)
|
|
122
|
-
say(:remove, destination)
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
# @since 1.1.0
|
|
126
|
-
# @api private
|
|
127
|
-
def destroy_action(context)
|
|
128
|
-
destination = project.action(context)
|
|
129
|
-
|
|
130
|
-
files.delete(destination)
|
|
131
|
-
say(:remove, destination)
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
module Hanami
|
|
2
|
-
class CLI
|
|
3
|
-
module Commands
|
|
4
|
-
module Destroy
|
|
5
|
-
# @since 1.1.0
|
|
6
|
-
# @api private
|
|
7
|
-
class App < Command
|
|
8
|
-
desc "Destroy an app"
|
|
9
|
-
|
|
10
|
-
argument :app, required: true, desc: "The application name (eg. `web`)"
|
|
11
|
-
|
|
12
|
-
example [
|
|
13
|
-
"admin # Destroy `admin` app"
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
# @since 1.1.0
|
|
17
|
-
# @api private
|
|
18
|
-
def call(app:, **options) # rubocop:disable Metrics/MethodLength
|
|
19
|
-
app = Utils::String.underscore(app)
|
|
20
|
-
context = Context.new(app: app, options: options)
|
|
21
|
-
|
|
22
|
-
assert_valid_app!(context)
|
|
23
|
-
context = context.with(base_url: base_url(context))
|
|
24
|
-
|
|
25
|
-
remove_test_http_session_secret(context)
|
|
26
|
-
remove_development_http_session_secret(context)
|
|
27
|
-
|
|
28
|
-
remove_mount_app(context)
|
|
29
|
-
remove_require_app(context)
|
|
30
|
-
|
|
31
|
-
recursively_destroy_precompiled_assets(context)
|
|
32
|
-
destroy_assets_manifest(context)
|
|
33
|
-
|
|
34
|
-
recursively_destroy_specs(context)
|
|
35
|
-
recursively_destroy_app(context)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
private
|
|
39
|
-
|
|
40
|
-
# @since 1.1.0
|
|
41
|
-
# @api private
|
|
42
|
-
def assert_valid_app!(context)
|
|
43
|
-
return if project.app?(context)
|
|
44
|
-
|
|
45
|
-
existing_apps = project.apps.map { |name| "`#{name}'" }.join(' ')
|
|
46
|
-
warn "`#{context.app}' is not a valid APP. Please specify one of: #{existing_apps}"
|
|
47
|
-
exit(1)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# @since 1.1.0
|
|
51
|
-
# @api private
|
|
52
|
-
def remove_test_http_session_secret(context)
|
|
53
|
-
content = "#{context.app.upcase}_SESSIONS_SECRET"
|
|
54
|
-
destination = project.env(context, "test")
|
|
55
|
-
|
|
56
|
-
files.remove_line(destination, content)
|
|
57
|
-
say(:subtract, destination)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# @since 1.1.0
|
|
61
|
-
# @api private
|
|
62
|
-
def remove_development_http_session_secret(context)
|
|
63
|
-
content = "#{context.app.upcase}_SESSIONS_SECRET"
|
|
64
|
-
destination = project.env(context, "development")
|
|
65
|
-
|
|
66
|
-
files.remove_line(destination, content)
|
|
67
|
-
say(:subtract, destination)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# @since 1.1.0
|
|
71
|
-
# @api private
|
|
72
|
-
def remove_mount_app(context)
|
|
73
|
-
content = "mount #{context.app.classify}::Application"
|
|
74
|
-
destination = project.environment(context)
|
|
75
|
-
|
|
76
|
-
files.remove_line(destination, content)
|
|
77
|
-
say(:subtract, destination)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
# @since 1.1.0
|
|
81
|
-
# @api private
|
|
82
|
-
def remove_require_app(context)
|
|
83
|
-
content = "require_relative '../apps/#{context.app}/application'"
|
|
84
|
-
destination = project.environment(context)
|
|
85
|
-
|
|
86
|
-
files.remove_line(destination, content)
|
|
87
|
-
say(:subtract, destination)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# @since 1.1.0
|
|
91
|
-
# @api private
|
|
92
|
-
def recursively_destroy_precompiled_assets(context)
|
|
93
|
-
destination = project.public_app_assets(context)
|
|
94
|
-
return unless files.directory?(destination)
|
|
95
|
-
|
|
96
|
-
files.delete_directory(destination)
|
|
97
|
-
say(:remove, destination)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
# @since 1.1.0
|
|
101
|
-
# @api private
|
|
102
|
-
def destroy_assets_manifest(context)
|
|
103
|
-
destination = project.assets_manifest(context)
|
|
104
|
-
return unless files.exist?(destination)
|
|
105
|
-
|
|
106
|
-
files.delete(destination)
|
|
107
|
-
say(:remove, destination)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# @since 1.1.0
|
|
111
|
-
# @api private
|
|
112
|
-
def recursively_destroy_specs(context)
|
|
113
|
-
destination = project.app_spec(context)
|
|
114
|
-
|
|
115
|
-
files.delete_directory(destination)
|
|
116
|
-
say(:remove, destination)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
# @since 1.1.0
|
|
120
|
-
# @api private
|
|
121
|
-
def recursively_destroy_app(context)
|
|
122
|
-
destination = project.app(context)
|
|
123
|
-
|
|
124
|
-
files.delete_directory(destination)
|
|
125
|
-
say(:remove, destination)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
# @since 1.1.0
|
|
129
|
-
# @api private
|
|
130
|
-
def base_url(context)
|
|
131
|
-
content = "mount #{context.app.classify}::Application"
|
|
132
|
-
destination = project.environment(context)
|
|
133
|
-
|
|
134
|
-
line = read_matching_line(destination, content)
|
|
135
|
-
*, at = line.split(/at\:[[:space:]]*/)
|
|
136
|
-
|
|
137
|
-
at.strip.gsub(/["']*/, "")
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
# @since 1.1.0
|
|
141
|
-
# @api private
|
|
142
|
-
def read_matching_line(path, target)
|
|
143
|
-
content = ::File.readlines(path)
|
|
144
|
-
line = content.find do |l|
|
|
145
|
-
case target
|
|
146
|
-
when String
|
|
147
|
-
l.include?(target)
|
|
148
|
-
when Regexp
|
|
149
|
-
l =~ target
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
line or raise ArgumentError.new("Cannot find `#{target}' inside `#{path}'.")
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
end
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
module Hanami
|
|
2
|
-
class CLI
|
|
3
|
-
module Commands
|
|
4
|
-
module Destroy
|
|
5
|
-
# @since 1.1.0
|
|
6
|
-
# @api private
|
|
7
|
-
class Mailer < Command
|
|
8
|
-
requires "environment"
|
|
9
|
-
desc "Destroy a mailer"
|
|
10
|
-
|
|
11
|
-
argument :mailer, required: true, desc: "The mailer name (eg. `welcome`)"
|
|
12
|
-
|
|
13
|
-
example [
|
|
14
|
-
"welcome # Destroy `WelcomeMailer` mailer"
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
# @since 1.1.0
|
|
18
|
-
# @api private
|
|
19
|
-
def call(mailer:, **options)
|
|
20
|
-
mailer = Utils::String.transform(mailer, :underscore, :singularize)
|
|
21
|
-
context = Context.new(mailer: mailer, options: options)
|
|
22
|
-
|
|
23
|
-
assert_valid_mailer!(context)
|
|
24
|
-
|
|
25
|
-
destroy_mailer_spec(context)
|
|
26
|
-
destroy_templates(context)
|
|
27
|
-
destroy_mailer(context)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
private
|
|
31
|
-
|
|
32
|
-
# @since 1.1.0
|
|
33
|
-
# @api private
|
|
34
|
-
def assert_valid_mailer!(context)
|
|
35
|
-
destination = project.mailer(context)
|
|
36
|
-
return if files.exist?(destination)
|
|
37
|
-
|
|
38
|
-
destination = project.mailers(context)
|
|
39
|
-
warn "cannot find `#{context.mailer}' mailer. Please have a look at `#{destination}' directory to find an existing mailer."
|
|
40
|
-
exit(1)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# @since 1.1.0
|
|
44
|
-
# @api private
|
|
45
|
-
def destroy_mailer_spec(context)
|
|
46
|
-
destination = project.mailer_spec(context)
|
|
47
|
-
|
|
48
|
-
files.delete(destination)
|
|
49
|
-
say(:remove, destination)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# @since 1.1.0
|
|
53
|
-
# @api private
|
|
54
|
-
def destroy_templates(context)
|
|
55
|
-
destinations = project.mailer_templates(context)
|
|
56
|
-
destinations.each do |destination|
|
|
57
|
-
files.delete(destination)
|
|
58
|
-
say(:remove, destination)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# @since 1.1.0
|
|
63
|
-
# @api private
|
|
64
|
-
def destroy_mailer(context)
|
|
65
|
-
destination = project.mailer(context)
|
|
66
|
-
|
|
67
|
-
files.delete(destination)
|
|
68
|
-
say(:remove, destination)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
module Hanami
|
|
2
|
-
class CLI
|
|
3
|
-
module Commands
|
|
4
|
-
module Destroy
|
|
5
|
-
# @since 1.1.0
|
|
6
|
-
# @api private
|
|
7
|
-
class Migration < Command
|
|
8
|
-
desc "Destroy a migration"
|
|
9
|
-
|
|
10
|
-
argument :migration, required: true, desc: "The migration name (eg. `create_users`)"
|
|
11
|
-
|
|
12
|
-
example [
|
|
13
|
-
"create_users # Destroy `db/migrations/#{Project.migration_timestamp}_create_users.rb`"
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
# @since 1.1.0
|
|
17
|
-
# @api private
|
|
18
|
-
def call(migration:, **options)
|
|
19
|
-
migration = Utils::String.underscore(migration)
|
|
20
|
-
context = Context.new(migration: migration, options: options)
|
|
21
|
-
context = context.with(destination: project.find_migration(context))
|
|
22
|
-
|
|
23
|
-
assert_valid_migration!(context)
|
|
24
|
-
|
|
25
|
-
destroy_migration(context)
|
|
26
|
-
true
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
private
|
|
30
|
-
|
|
31
|
-
# @since 1.1.0
|
|
32
|
-
# @api private
|
|
33
|
-
def assert_valid_migration!(context)
|
|
34
|
-
return if !context.destination.nil? && files.exist?(context.destination)
|
|
35
|
-
|
|
36
|
-
destination = project.migrations(context)
|
|
37
|
-
warn "cannot find `#{context.migration}'. Please have a look at `#{destination}' directory to find an existing migration"
|
|
38
|
-
exit(1)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# @since 1.1.0
|
|
42
|
-
# @api private
|
|
43
|
-
def destroy_migration(context)
|
|
44
|
-
files.delete(context.destination)
|
|
45
|
-
say(:remove, context.destination)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
module Hanami
|
|
2
|
-
class CLI
|
|
3
|
-
module Commands
|
|
4
|
-
module Destroy
|
|
5
|
-
# @since 1.1.0
|
|
6
|
-
# @api private
|
|
7
|
-
class Model < Command
|
|
8
|
-
requires "environment"
|
|
9
|
-
|
|
10
|
-
desc "Destroy a model"
|
|
11
|
-
|
|
12
|
-
argument :model, required: true, desc: "The model name (eg. `user`)"
|
|
13
|
-
|
|
14
|
-
example [
|
|
15
|
-
"user # Destroy `User` entity and `UserRepository` repository"
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
# @since 1.1.0
|
|
19
|
-
# @api private
|
|
20
|
-
def call(model:, **options)
|
|
21
|
-
model = Utils::String.transform(model, :underscore, :singularize)
|
|
22
|
-
context = Context.new(model: model, options: options)
|
|
23
|
-
|
|
24
|
-
assert_valid_model!(context)
|
|
25
|
-
|
|
26
|
-
destroy_repository_spec(context)
|
|
27
|
-
destroy_entity_spec(context)
|
|
28
|
-
destroy_repository(context)
|
|
29
|
-
destroy_entity(context)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
# @since 1.1.0
|
|
35
|
-
# @api private
|
|
36
|
-
def assert_valid_model!(context)
|
|
37
|
-
destination = project.entity(context)
|
|
38
|
-
return if files.exist?(destination)
|
|
39
|
-
|
|
40
|
-
destination = project.entities(context)
|
|
41
|
-
warn "cannot find `#{context.model}' model. Please have a look at `#{destination}' directory to find an existing model."
|
|
42
|
-
exit(1)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# @since 1.1.0
|
|
46
|
-
# @api private
|
|
47
|
-
def destroy_repository_spec(context)
|
|
48
|
-
destination = project.repository_spec(context)
|
|
49
|
-
|
|
50
|
-
files.delete(destination)
|
|
51
|
-
say(:remove, destination)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# @since 1.1.0
|
|
55
|
-
# @api private
|
|
56
|
-
def destroy_entity_spec(context)
|
|
57
|
-
destination = project.entity_spec(context)
|
|
58
|
-
|
|
59
|
-
files.delete(destination)
|
|
60
|
-
say(:remove, destination)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# @since 1.1.0
|
|
64
|
-
# @api private
|
|
65
|
-
def destroy_repository(context)
|
|
66
|
-
destination = project.repository(context)
|
|
67
|
-
|
|
68
|
-
files.delete(destination)
|
|
69
|
-
say(:remove, destination)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# @since 1.1.0
|
|
73
|
-
# @api private
|
|
74
|
-
def destroy_entity(context)
|
|
75
|
-
destination = project.entity(context)
|
|
76
|
-
|
|
77
|
-
files.delete(destination)
|
|
78
|
-
say(:remove, destination)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
module Hanami
|
|
2
|
-
# Hanami CLI
|
|
3
|
-
#
|
|
4
|
-
# @since 1.1.0
|
|
5
|
-
class CLI
|
|
6
|
-
module Commands
|
|
7
|
-
# @since 1.1.0
|
|
8
|
-
# @api private
|
|
9
|
-
module Destroy
|
|
10
|
-
require "hanami/cli/commands/destroy/app"
|
|
11
|
-
require "hanami/cli/commands/destroy/action"
|
|
12
|
-
require "hanami/cli/commands/destroy/model"
|
|
13
|
-
require "hanami/cli/commands/destroy/mailer"
|
|
14
|
-
require "hanami/cli/commands/destroy/migration"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
register "destroy", aliases: ["d"] do |prefix|
|
|
19
|
-
prefix.register "app", Commands::Destroy::App
|
|
20
|
-
prefix.register "action", Commands::Destroy::Action
|
|
21
|
-
prefix.register "model", Commands::Destroy::Model
|
|
22
|
-
prefix.register "mailer", Commands::Destroy::Mailer
|
|
23
|
-
prefix.register "migration", Commands::Destroy::Migration
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require_relative '../../../spec_helper'
|
|
2
|
-
|
|
3
|
-
describe <%= app.classify %>::Controllers::<%= classified_controller_name %>::<%= action.classify %> do
|
|
4
|
-
let(:action) { <%= app.classify %>::Controllers::<%= classified_controller_name %>::<%= action.classify %>.new }
|
|
5
|
-
let(:params) { Hash[] }
|
|
6
|
-
|
|
7
|
-
it 'is successful' do
|
|
8
|
-
response = action.call(params)
|
|
9
|
-
_(response[0]).must_equal 200
|
|
10
|
-
end
|
|
11
|
-
end
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
RSpec.describe <%= app.classify %>::Controllers::<%= classified_controller_name %>::<%= action.classify %>, type: :action do
|
|
2
|
-
let(:action) { described_class.new }
|
|
3
|
-
let(:params) { Hash[] }
|
|
4
|
-
|
|
5
|
-
it 'is successful' do
|
|
6
|
-
response = action.call(params)
|
|
7
|
-
expect(response[0]).to eq 200
|
|
8
|
-
end
|
|
9
|
-
end
|