thundercli 0.2.0

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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +5 -0
  3. data/exe/thunder +11 -0
  4. data/lib/thunder/application.rb +35 -0
  5. data/lib/thunder/cli/command.rb +19 -0
  6. data/lib/thunder/cli/commands/console.rb +24 -0
  7. data/lib/thunder/cli/commands/db/create.rb +20 -0
  8. data/lib/thunder/cli/commands/db/drop.rb +20 -0
  9. data/lib/thunder/cli/commands/db/migrate.rb +20 -0
  10. data/lib/thunder/cli/commands/db/reset.rb +22 -0
  11. data/lib/thunder/cli/commands/db/setup.rb +21 -0
  12. data/lib/thunder/cli/commands/generate/chunk.rb +23 -0
  13. data/lib/thunder/cli/commands/generate/command.rb +64 -0
  14. data/lib/thunder/cli/commands/generate/event.rb +28 -0
  15. data/lib/thunder/cli/commands/generate/model.rb +39 -0
  16. data/lib/thunder/cli/commands/generate/operation.rb +39 -0
  17. data/lib/thunder/cli/commands/generate/outbox.rb +33 -0
  18. data/lib/thunder/cli/commands/generate/subscriber.rb +33 -0
  19. data/lib/thunder/cli/commands/messaging/consumer.rb +52 -0
  20. data/lib/thunder/cli/commands/messaging/outbox.rb +36 -0
  21. data/lib/thunder/cli/commands/new.rb +44 -0
  22. data/lib/thunder/cli/commands/serve.rb +38 -0
  23. data/lib/thunder/cli/commands/spec.rb +77 -0
  24. data/lib/thunder/cli/commands/version.rb +16 -0
  25. data/lib/thunder/cli.rb +78 -0
  26. data/lib/thunder/console/backtrace.rb +36 -0
  27. data/lib/thunder/console/banner.rb +93 -0
  28. data/lib/thunder/console/completion.rb +68 -0
  29. data/lib/thunder/console/constants.rb +57 -0
  30. data/lib/thunder/console/evaluation.rb +72 -0
  31. data/lib/thunder/console/help.rb +30 -0
  32. data/lib/thunder/console/helpers.rb +16 -0
  33. data/lib/thunder/console/inspector.rb +114 -0
  34. data/lib/thunder/console/pretty.rb +70 -0
  35. data/lib/thunder/console/prompt.rb +52 -0
  36. data/lib/thunder/console/theme.rb +85 -0
  37. data/lib/thunder/console/views/collection.rb +172 -0
  38. data/lib/thunder/console/views/format.rb +114 -0
  39. data/lib/thunder/console/views/layout.rb +72 -0
  40. data/lib/thunder/console/views/model.rb +92 -0
  41. data/lib/thunder/console/views/operation.rb +112 -0
  42. data/lib/thunder/console/views/record.rb +95 -0
  43. data/lib/thunder/console/views.rb +45 -0
  44. data/lib/thunder/console.rb +167 -0
  45. data/lib/thunder/generator.rb +73 -0
  46. data/lib/thunder/templates/chunk/app/common/models/application_model.rb.erb +4 -0
  47. data/lib/thunder/templates/chunk/app/common/operations/external_operation.rb.erb +3 -0
  48. data/lib/thunder/templates/chunk/app/common/operations/internal_operation.rb.erb +3 -0
  49. data/lib/thunder/templates/chunk/app/external/operations/_keep.erb +0 -0
  50. data/lib/thunder/templates/chunk/app/internal/models/_keep.erb +0 -0
  51. data/lib/thunder/templates/chunk/app/internal/operations/_keep.erb +0 -0
  52. data/lib/thunder/templates/chunk/config/chunk.rb.erb +9 -0
  53. data/lib/thunder/templates/chunk/database/migrate/_keep.erb +0 -0
  54. data/lib/thunder/templates/event/event.rb.erb +6 -0
  55. data/lib/thunder/templates/model/migration.rb.erb +17 -0
  56. data/lib/thunder/templates/model/model.rb.erb +6 -0
  57. data/lib/thunder/templates/new/Gemfile.erb +21 -0
  58. data/lib/thunder/templates/new/README.md.erb +8 -0
  59. data/lib/thunder/templates/new/_gitignore.erb +4 -0
  60. data/lib/thunder/templates/new/_ruby-version.erb +2 -0
  61. data/lib/thunder/templates/new/bin/thunder.erb +6 -0
  62. data/lib/thunder/templates/new/chunks/_keep.erb +0 -0
  63. data/lib/thunder/templates/operation/external.rb.erb +24 -0
  64. data/lib/thunder/templates/operation/internal.rb.erb +26 -0
  65. data/lib/thunder/templates/outbox/migration.rb.erb +21 -0
  66. data/lib/thunder/templates/subscriber/subscriber.rb.erb +18 -0
  67. data/lib/thunder/version.rb +5 -0
  68. data/lib/thunder.rb +32 -0
  69. metadata +147 -0
@@ -0,0 +1,21 @@
1
+ <%# WARN: AI MADE -%>
2
+ # frozen_string_literal: true
3
+
4
+ # The outbox of the messaging publisher: each event the chunk publishes is written here in the transaction of the
5
+ # operation, and the outbox task sends the rows left with published_at NULL.
6
+ class <%= migration_class %> < ActiveRecord::Migration[<%= migration_version %>]
7
+ def change
8
+ create_table :<%= table_name %> do |t|
9
+ t.uuid :message_id, null: false
10
+ t.string :routing_key, null: false
11
+ t.jsonb :payload, null: false
12
+ t.datetime :created_at, null: false
13
+ t.datetime :published_at
14
+ t.integer :attempts, null: false, default: 0
15
+ t.text :last_error
16
+ end
17
+
18
+ add_index :<%= table_name %>, :message_id, unique: true
19
+ add_index :<%= table_name %>, :id, where: 'published_at IS NULL', name: 'index_<%= table_name %>_pending'
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ <%# WARN: AI MADE -%>
2
+ class <%= class_name %> < ThunderChunk::Operations::Subscriber
3
+ <% params.each do |name, type, optional| -%>
4
+ param :<%= name %>, <%= type %><%= ', optional: true' if optional %>
5
+ <% end -%>
6
+ <% uses.each do |line| -%>
7
+ <%= line %>
8
+ <% end -%>
9
+ <% unless params.empty? && uses.empty? -%>
10
+
11
+ <% end -%>
12
+ flow do
13
+ success
14
+ end
15
+
16
+ steps do
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Thunder
4
+ VERSION = '0.2.0'
5
+ end
data/lib/thunder.rb ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thunderchunk'
4
+ require 'dry/cli'
5
+
6
+ require_relative 'thunder/version'
7
+ require_relative 'thunder/cli/command'
8
+ require_relative 'thunder/cli'
9
+ require_relative 'thunder/application'
10
+ # WARN: AI MADE
11
+ require_relative 'thunder/generator'
12
+
13
+ # The application: entry point of every repo. Depends on thunderchunk and the gems below it.
14
+ module Thunder
15
+ class Error < StandardError; end
16
+
17
+ class << self
18
+ def application
19
+ @application ||= Thunder::Application.new(root: find_root(Dir.pwd))
20
+ end
21
+
22
+ def find_root(start = Dir.pwd)
23
+ root = Pathname(start).expand_path.ascend do |dir|
24
+ return dir if dir.join('chunks').directory? && dir.join('Gemfile').file?
25
+ end
26
+
27
+ raise(Error, "no chunks/ directory found from #{start}") unless root
28
+
29
+ root
30
+ end
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thundercli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Albert Alef
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: dry-cli
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.1'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '1.1'
26
+ - !ruby/object:Gem::Dependency
27
+ name: thunderchunk
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.2.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '='
38
+ - !ruby/object:Gem::Version
39
+ version: 0.2.0
40
+ - !ruby/object:Gem::Dependency
41
+ name: thunderwire
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '='
45
+ - !ruby/object:Gem::Version
46
+ version: 0.2.0
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.2.0
54
+ executables:
55
+ - thunder
56
+ extensions: []
57
+ extra_rdoc_files: []
58
+ files:
59
+ - README.md
60
+ - exe/thunder
61
+ - lib/thunder.rb
62
+ - lib/thunder/application.rb
63
+ - lib/thunder/cli.rb
64
+ - lib/thunder/cli/command.rb
65
+ - lib/thunder/cli/commands/console.rb
66
+ - lib/thunder/cli/commands/db/create.rb
67
+ - lib/thunder/cli/commands/db/drop.rb
68
+ - lib/thunder/cli/commands/db/migrate.rb
69
+ - lib/thunder/cli/commands/db/reset.rb
70
+ - lib/thunder/cli/commands/db/setup.rb
71
+ - lib/thunder/cli/commands/generate/chunk.rb
72
+ - lib/thunder/cli/commands/generate/command.rb
73
+ - lib/thunder/cli/commands/generate/event.rb
74
+ - lib/thunder/cli/commands/generate/model.rb
75
+ - lib/thunder/cli/commands/generate/operation.rb
76
+ - lib/thunder/cli/commands/generate/outbox.rb
77
+ - lib/thunder/cli/commands/generate/subscriber.rb
78
+ - lib/thunder/cli/commands/messaging/consumer.rb
79
+ - lib/thunder/cli/commands/messaging/outbox.rb
80
+ - lib/thunder/cli/commands/new.rb
81
+ - lib/thunder/cli/commands/serve.rb
82
+ - lib/thunder/cli/commands/spec.rb
83
+ - lib/thunder/cli/commands/version.rb
84
+ - lib/thunder/console.rb
85
+ - lib/thunder/console/backtrace.rb
86
+ - lib/thunder/console/banner.rb
87
+ - lib/thunder/console/completion.rb
88
+ - lib/thunder/console/constants.rb
89
+ - lib/thunder/console/evaluation.rb
90
+ - lib/thunder/console/help.rb
91
+ - lib/thunder/console/helpers.rb
92
+ - lib/thunder/console/inspector.rb
93
+ - lib/thunder/console/pretty.rb
94
+ - lib/thunder/console/prompt.rb
95
+ - lib/thunder/console/theme.rb
96
+ - lib/thunder/console/views.rb
97
+ - lib/thunder/console/views/collection.rb
98
+ - lib/thunder/console/views/format.rb
99
+ - lib/thunder/console/views/layout.rb
100
+ - lib/thunder/console/views/model.rb
101
+ - lib/thunder/console/views/operation.rb
102
+ - lib/thunder/console/views/record.rb
103
+ - lib/thunder/generator.rb
104
+ - lib/thunder/templates/chunk/app/common/models/application_model.rb.erb
105
+ - lib/thunder/templates/chunk/app/common/operations/external_operation.rb.erb
106
+ - lib/thunder/templates/chunk/app/common/operations/internal_operation.rb.erb
107
+ - lib/thunder/templates/chunk/app/external/operations/_keep.erb
108
+ - lib/thunder/templates/chunk/app/internal/models/_keep.erb
109
+ - lib/thunder/templates/chunk/app/internal/operations/_keep.erb
110
+ - lib/thunder/templates/chunk/config/chunk.rb.erb
111
+ - lib/thunder/templates/chunk/database/migrate/_keep.erb
112
+ - lib/thunder/templates/event/event.rb.erb
113
+ - lib/thunder/templates/model/migration.rb.erb
114
+ - lib/thunder/templates/model/model.rb.erb
115
+ - lib/thunder/templates/new/Gemfile.erb
116
+ - lib/thunder/templates/new/README.md.erb
117
+ - lib/thunder/templates/new/_gitignore.erb
118
+ - lib/thunder/templates/new/_ruby-version.erb
119
+ - lib/thunder/templates/new/bin/thunder.erb
120
+ - lib/thunder/templates/new/chunks/_keep.erb
121
+ - lib/thunder/templates/operation/external.rb.erb
122
+ - lib/thunder/templates/operation/internal.rb.erb
123
+ - lib/thunder/templates/outbox/migration.rb.erb
124
+ - lib/thunder/templates/subscriber/subscriber.rb.erb
125
+ - lib/thunder/version.rb
126
+ licenses: []
127
+ metadata:
128
+ rubygems_mfa_required: 'true'
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '3.4'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubygems_version: 3.6.9
144
+ specification_version: 4
145
+ summary: 'The application: finds the chunks, reads the aggregate config and supervises
146
+ the chunk processes'
147
+ test_files: []