layered_stack 0.0.5 → 0.0.6
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/lib/layered_stack/backend/create.rb +2 -2
- data/lib/layered_stack/frontend/create.rb +8 -8
- data/lib/layered_stack/root/create.rb +80 -0
- data/lib/layered_stack/version.rb +1 -1
- data/lib/layered_stack.rb +11 -4
- data/templates/backend/rails_template.rb +51 -0
- data/templates/root/Gemfile +11 -0
- data/templates/root/Procfile +2 -0
- data/templates/root/devcontainer/Dockerfile +9 -0
- data/templates/root/devcontainer/devcontainer.json +19 -0
- data/templates/root/devcontainer/docker-compose.yml +12 -0
- data/templates/root/devcontainer/layered-stack-0.0.1.vsix +0 -0
- data/templates/root/layered_stack/cli/LICENSE.md +21 -0
- data/templates/root/layered_stack/cli/bin/layered_stack +3 -0
- data/templates/root/layered_stack/cli/cli/LICENSE.md +21 -0
- data/templates/root/layered_stack/cli/cli/bin/layered_stack +3 -0
- data/templates/root/layered_stack/cli/cli/layered_stack-0.0.6.gem +0 -0
- data/templates/root/layered_stack/cli/cli/layered_stack.gemspec +30 -0
- data/templates/root/layered_stack/cli/cli/lib/layered_stack/backend/create.rb +42 -0
- data/templates/root/layered_stack/cli/cli/lib/layered_stack/backend/start.rb +30 -0
- data/templates/root/layered_stack/cli/cli/lib/layered_stack/frontend/create.rb +137 -0
- data/templates/root/layered_stack/cli/cli/lib/layered_stack/frontend/start.rb +33 -0
- data/templates/root/layered_stack/cli/cli/lib/layered_stack/root/create.rb +80 -0
- data/templates/root/layered_stack/cli/cli/lib/layered_stack/version.rb +5 -0
- data/templates/root/layered_stack/cli/cli/lib/layered_stack.rb +63 -0
- data/templates/root/layered_stack/cli/cli/templates/backend/rails_template.rb +51 -0
- data/templates/root/layered_stack/cli/cli/templates/frontend/images/logo_dark.svg +29 -0
- data/templates/root/layered_stack/cli/cli/templates/frontend/images/logo_light.svg +29 -0
- data/templates/root/layered_stack/cli/cli/templates/frontend/layout.js +21 -0
- data/templates/root/layered_stack/cli/cli/templates/frontend/page.js +35 -0
- data/templates/root/layered_stack/cli/cli/templates/frontend/tailwind.config.js +19 -0
- data/templates/root/layered_stack/cli/cli/templates/root/Gemfile +11 -0
- data/templates/root/layered_stack/cli/cli/templates/root/Procfile +2 -0
- data/templates/root/layered_stack/cli/cli/templates/root/devcontainer/Dockerfile +9 -0
- data/templates/root/layered_stack/cli/cli/templates/root/devcontainer/devcontainer.json +19 -0
- data/templates/root/layered_stack/cli/cli/templates/root/devcontainer/docker-compose.yml +12 -0
- data/templates/root/layered_stack/cli/cli/templates/root/devcontainer/layered-stack-0.0.1.vsix +0 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/LICENSE.md +21 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/bin/layered_stack +3 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/layered_stack-0.0.6.gem +0 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/layered_stack.gemspec +30 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack/backend/create.rb +42 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack/backend/start.rb +30 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack/frontend/create.rb +137 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack/frontend/start.rb +33 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack/root/create.rb +80 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack/version.rb +5 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack.rb +63 -0
- data/{assets/backend/template.rb → templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/backend/rails_template.rb} +15 -20
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/frontend/images/logo_dark.svg +29 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/frontend/images/logo_light.svg +29 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/frontend/layout.js +21 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/frontend/page.js +35 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/frontend/tailwind.config.js +19 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/Gemfile +8 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/Procfile +2 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/devcontainer/Dockerfile +9 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/devcontainer/devcontainer.json +19 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/devcontainer/docker-compose.yml +11 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/devcontainer/layered-stack-0.0.1.vsix +0 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/LICENSE.md +21 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/bin/layered_stack-rails +3 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/layered_stack-rails.gemspec +29 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/scaffold_generator.rb +89 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/templates/active_record/model/model.erb +9 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/example.rb +97 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/generate.rb +34 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/generate_new.rb +34 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/version.rb +5 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails.rb +26 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/LICENSE.md +21 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/bin/layered_stack-rails +3 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/layered_stack-rails.gemspec +29 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/scaffold_generator.rb +89 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/templates/active_record/model/model.erb +9 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/example.rb +97 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/generate.rb +34 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/generate_new.rb +34 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/version.rb +5 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/layered_stack_rails.rb +26 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/LICENSE.md +21 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/bin/layered_stack-rails +3 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/layered_stack-rails.gemspec +29 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/generators/layered_stack_rails/scaffold_generator.rb +89 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/generators/layered_stack_rails/templates/active_record/model/model.erb +9 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/layered_stack_rails/example.rb +97 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/layered_stack_rails/generate.rb +34 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/layered_stack_rails/generate_new.rb +34 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/layered_stack_rails/version.rb +5 -0
- data/templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/layered_stack_rails.rb +26 -0
- data/templates/root/layered_stack/cli/layered_stack-0.0.6.gem +0 -0
- data/templates/root/layered_stack/cli/layered_stack.gemspec +30 -0
- data/templates/root/layered_stack/cli/lib/layered_stack/backend/create.rb +42 -0
- data/templates/root/layered_stack/cli/lib/layered_stack/backend/start.rb +30 -0
- data/templates/root/layered_stack/cli/lib/layered_stack/frontend/create.rb +137 -0
- data/templates/root/layered_stack/cli/lib/layered_stack/frontend/start.rb +33 -0
- data/templates/root/layered_stack/cli/lib/layered_stack/root/create.rb +80 -0
- data/templates/root/layered_stack/cli/lib/layered_stack/version.rb +5 -0
- data/templates/root/layered_stack/cli/lib/layered_stack.rb +63 -0
- data/templates/root/layered_stack/cli/templates/backend/rails_template.rb +48 -0
- data/templates/root/layered_stack/cli/templates/frontend/images/logo_dark.svg +29 -0
- data/templates/root/layered_stack/cli/templates/frontend/images/logo_light.svg +29 -0
- data/templates/root/layered_stack/cli/templates/frontend/layout.js +21 -0
- data/templates/root/layered_stack/cli/templates/frontend/page.js +35 -0
- data/templates/root/layered_stack/cli/templates/frontend/tailwind.config.js +19 -0
- data/templates/root/layered_stack/cli/templates/root/Gemfile +8 -0
- data/templates/root/layered_stack/cli/templates/root/Procfile +2 -0
- data/templates/root/layered_stack/cli/templates/root/devcontainer/Dockerfile +9 -0
- data/templates/root/layered_stack/cli/templates/root/devcontainer/devcontainer.json +19 -0
- data/templates/root/layered_stack/cli/templates/root/devcontainer/docker-compose.yml +11 -0
- data/templates/root/layered_stack/cli/templates/root/devcontainer/layered-stack-0.0.1.vsix +0 -0
- data/templates/root/layered_stack/cli/templates/root/layered_stack/rails/LICENSE.md +21 -0
- data/templates/root/layered_stack/cli/templates/root/layered_stack/rails/bin/layered_stack-rails +3 -0
- data/templates/root/layered_stack/cli/templates/root/layered_stack/rails/layered_stack-rails.gemspec +29 -0
- data/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/scaffold_generator.rb +89 -0
- data/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/templates/active_record/model/model.erb +9 -0
- data/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/example.rb +97 -0
- data/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/generate.rb +34 -0
- data/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/generate_new.rb +34 -0
- data/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/version.rb +5 -0
- data/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails.rb +26 -0
- data/templates/root/layered_stack/rails/LICENSE.md +21 -0
- data/templates/root/layered_stack/rails/bin/layered_stack-rails +3 -0
- data/templates/root/layered_stack/rails/layered_stack-rails.gemspec +29 -0
- data/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/scaffold_generator.rb +89 -0
- data/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/templates/active_record/model/model.erb +9 -0
- data/templates/root/layered_stack/rails/lib/layered_stack_rails/example.rb +97 -0
- data/templates/root/layered_stack/rails/lib/layered_stack_rails/generate.rb +34 -0
- data/templates/root/layered_stack/rails/lib/layered_stack_rails/generate_new.rb +34 -0
- data/templates/root/layered_stack/rails/lib/layered_stack_rails/version.rb +5 -0
- data/templates/root/layered_stack/rails/lib/layered_stack_rails.rb +26 -0
- data/templates/root/layered_stack/rails/rails/LICENSE.md +21 -0
- data/templates/root/layered_stack/rails/rails/bin/layered_stack-rails +3 -0
- data/templates/root/layered_stack/rails/rails/layered_stack-rails.gemspec +29 -0
- data/templates/root/layered_stack/rails/rails/lib/generators/layered_stack_rails/scaffold_generator.rb +89 -0
- data/templates/root/layered_stack/rails/rails/lib/generators/layered_stack_rails/templates/active_record/model/model.erb +9 -0
- data/templates/root/layered_stack/rails/rails/lib/layered_stack_rails/example.rb +97 -0
- data/templates/root/layered_stack/rails/rails/lib/layered_stack_rails/generate.rb +34 -0
- data/templates/root/layered_stack/rails/rails/lib/layered_stack_rails/generate_new.rb +34 -0
- data/templates/root/layered_stack/rails/rails/lib/layered_stack_rails/version.rb +5 -0
- data/templates/root/layered_stack/rails/rails/lib/layered_stack_rails.rb +26 -0
- metadata +152 -16
- /data/{assets → templates/frontend}/images/logo_dark.svg +0 -0
- /data/{assets → templates/frontend}/images/logo_light.svg +0 -0
- /data/{assets → templates/frontend}/layout.js +0 -0
- /data/{assets → templates/frontend}/page.js +0 -0
- /data/{assets → templates/frontend}/tailwind.config.js +0 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
require "rails"
|
2
|
+
require "rails/generators"
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
class LayeredStackRails::ScaffoldGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
argument :model_name, type: :string
|
8
|
+
|
9
|
+
def execute
|
10
|
+
yaml_content = YAML.load_file(File.join("layered_stack", "resources.yml"))
|
11
|
+
|
12
|
+
model_data = yaml_content["resources"][model_name]
|
13
|
+
if model_data
|
14
|
+
puts "Generating model #{model_name} with attributes: #{model_data["attributes"]}"
|
15
|
+
generate_scaffold(model_name, model_data["attributes"], model_data["associations"])
|
16
|
+
else
|
17
|
+
puts "Model #{model_name} not found in resources.yml"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_model_file
|
22
|
+
template "active_record/model/model.erb", File.join("app/models", "#{model_name}.rb")
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def generate_scaffold(model_name, attributes, associations)
|
28
|
+
@attributes = attributes.map do |name, details|
|
29
|
+
if details['password_digest']
|
30
|
+
"#{name}:digest"
|
31
|
+
elsif details['token']
|
32
|
+
"#{name}:token"
|
33
|
+
else
|
34
|
+
attribute_string = if details['type'] == 'decimal'
|
35
|
+
precision = details['precision']
|
36
|
+
scale = details['scale']
|
37
|
+
"#{name}:decimal{#{precision}.#{scale}}"
|
38
|
+
else
|
39
|
+
type = details['type']
|
40
|
+
limit = details['limit']
|
41
|
+
limit_string = limit ? "{#{limit}}" : ""
|
42
|
+
"#{name}:#{type}#{limit_string}"
|
43
|
+
end
|
44
|
+
|
45
|
+
attribute_string += ":index" if details['index'] == true
|
46
|
+
attribute_string += ":uniq" if details['index'] == 'uniq'
|
47
|
+
|
48
|
+
attribute_string
|
49
|
+
end
|
50
|
+
end.join(" ")
|
51
|
+
|
52
|
+
@class_name = model_name.classify
|
53
|
+
|
54
|
+
@validations = []
|
55
|
+
attributes.each do |name, details|
|
56
|
+
if details['required']
|
57
|
+
@validations << "validates :#{name}, presence: true"
|
58
|
+
end
|
59
|
+
if details['type'] == 'integer'
|
60
|
+
@validations << "validates :#{name}, numericality: { only_integer: true }"
|
61
|
+
end
|
62
|
+
if details['precision'] && details['scale']
|
63
|
+
@validations << "validates :#{name}, numericality: true"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
@associations = []
|
68
|
+
associations.each do |name, details|
|
69
|
+
case details['type']
|
70
|
+
when 'has_many'
|
71
|
+
if details['through']
|
72
|
+
@associations << "has_many :#{name}, through: :#{details['through']}"
|
73
|
+
else
|
74
|
+
@associations << "has_many :#{name}"
|
75
|
+
end
|
76
|
+
when 'belongs_to'
|
77
|
+
@associations << "belongs_to :#{name}"
|
78
|
+
end
|
79
|
+
end if associations
|
80
|
+
|
81
|
+
# Generate the scaffold command
|
82
|
+
invoke "rails:scaffold", [model_name.camelize, *@attributes.split(" "), "--api"], force: true
|
83
|
+
|
84
|
+
# ToDo: Write a custom generator that avoids this workaround
|
85
|
+
# Delete the model file after scaffolding to avoid duplicate model files
|
86
|
+
model_file_path = File.join("app/models", "#{model_name}.rb")
|
87
|
+
File.delete(model_file_path) if File.exist?(model_file_path)
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class <%= @class_name %> < ApplicationRecord
|
2
|
+
<%= "# <associations>" %>
|
3
|
+
<%= @associations.map { |association| association }.join("\n ") %>
|
4
|
+
<%= "# </associations>" %>
|
5
|
+
|
6
|
+
<%= "# <validations>" %>
|
7
|
+
<%= @validations.map { |validation| validation }.join("\n ") %>
|
8
|
+
<%= "# </validations>" %>
|
9
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
module LayeredStackRails
|
5
|
+
class Example < Thor
|
6
|
+
def self.execute
|
7
|
+
new.execute
|
8
|
+
end
|
9
|
+
|
10
|
+
no_commands do
|
11
|
+
def execute
|
12
|
+
logger.info("> layered_stack-rails/example")
|
13
|
+
|
14
|
+
# Ensure the directory exists
|
15
|
+
directory_path = 'layered_stack'
|
16
|
+
unless File.directory?(directory_path)
|
17
|
+
FileUtils.mkdir_p(directory_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Create the example product.yml file
|
21
|
+
example_product = File.join(directory_path, 'resources.yml')
|
22
|
+
unless File.exist?(example_product)
|
23
|
+
File.open(example_product, 'w') do |file|
|
24
|
+
file.write(<<~YAML)
|
25
|
+
resources:
|
26
|
+
product:
|
27
|
+
attributes:
|
28
|
+
name:
|
29
|
+
type: string
|
30
|
+
required: true
|
31
|
+
index: uniq
|
32
|
+
description:
|
33
|
+
type: text
|
34
|
+
price:
|
35
|
+
type: decimal
|
36
|
+
precision: 10
|
37
|
+
scale: 2
|
38
|
+
required: true
|
39
|
+
stock_quantity:
|
40
|
+
type: integer
|
41
|
+
required: true
|
42
|
+
associations:
|
43
|
+
order_items:
|
44
|
+
type: has_many
|
45
|
+
orders:
|
46
|
+
type: has_many
|
47
|
+
through: order_items
|
48
|
+
|
49
|
+
order:
|
50
|
+
attributes:
|
51
|
+
order_number:
|
52
|
+
type: string
|
53
|
+
required: true
|
54
|
+
index: uniq
|
55
|
+
order_date:
|
56
|
+
type: datetime
|
57
|
+
required: true
|
58
|
+
total_amount:
|
59
|
+
type: decimal
|
60
|
+
precision: 10
|
61
|
+
scale: 2
|
62
|
+
required: true
|
63
|
+
associations:
|
64
|
+
order_items:
|
65
|
+
type: has_many
|
66
|
+
products:
|
67
|
+
type: has_many
|
68
|
+
through: order_items
|
69
|
+
|
70
|
+
order_item:
|
71
|
+
attributes:
|
72
|
+
quantity:
|
73
|
+
type: integer
|
74
|
+
required: true
|
75
|
+
price:
|
76
|
+
type: decimal
|
77
|
+
precision: 10
|
78
|
+
scale: 2
|
79
|
+
required: true
|
80
|
+
associations:
|
81
|
+
order:
|
82
|
+
type: belongs_to
|
83
|
+
product:
|
84
|
+
type: belongs_to
|
85
|
+
YAML
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def logger
|
93
|
+
@logger ||= Logger.new(STDOUT)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'logger'
|
3
|
+
require 'yaml'
|
4
|
+
require 'rails'
|
5
|
+
|
6
|
+
module LayeredStackRails
|
7
|
+
class Generate < Thor
|
8
|
+
def self.execute
|
9
|
+
new.execute
|
10
|
+
end
|
11
|
+
|
12
|
+
no_commands do
|
13
|
+
def execute
|
14
|
+
logger.info("> layered_stack-rails/generate_new")
|
15
|
+
|
16
|
+
yaml_content = YAML.load_file(File.join("layered_stack", "resources.yml"))
|
17
|
+
resources = yaml_content["resources"]
|
18
|
+
resources.each do |model_name, model_data|
|
19
|
+
if model_data
|
20
|
+
system("rails generate layered_stack_rails:scaffold #{model_name}")
|
21
|
+
else
|
22
|
+
logger.error("Model #{model_name} not found in resources.yml")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def logger
|
30
|
+
@logger ||= Logger.new(STDOUT)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'logger'
|
3
|
+
require 'yaml'
|
4
|
+
require 'rails'
|
5
|
+
|
6
|
+
module LayeredStackRails
|
7
|
+
class GenerateNew < Thor
|
8
|
+
def self.execute
|
9
|
+
new.execute
|
10
|
+
end
|
11
|
+
|
12
|
+
no_commands do
|
13
|
+
def execute
|
14
|
+
logger.info("> layered_stack-rails/generate_new")
|
15
|
+
|
16
|
+
yaml_content = YAML.load_file(File.join("layered_stack", "resources.yml"))
|
17
|
+
resources = yaml_content["resources"]
|
18
|
+
resources.each do |model_name, model_data|
|
19
|
+
if model_data
|
20
|
+
system("rails generate layered_stack_rails:scaffold #{model_name}")
|
21
|
+
else
|
22
|
+
logger.error("Model #{model_name} not found in resources.yml")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def logger
|
30
|
+
@logger ||= Logger.new(STDOUT)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
# Require all .rb files in the layered_stack_rails folder recursively
|
5
|
+
Dir[File.join(__dir__, 'layered_stack_rails/**/*.rb')].each { |file| require_relative file }
|
6
|
+
|
7
|
+
module LayeredStackRails
|
8
|
+
class Cli < Thor
|
9
|
+
desc "product", "Creates an example product.yml resource file in the layered_stack/resources directory"
|
10
|
+
def example
|
11
|
+
LayeredStackRails::Example.execute
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "generate", "Generates resources from ./layered_stack/resources.yml"
|
15
|
+
def generate
|
16
|
+
LayeredStackRails::Generate.execute
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "dev", "Run example and generate with 'product' as the name"
|
20
|
+
def dev
|
21
|
+
example
|
22
|
+
generate
|
23
|
+
system('rails db:migrate')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: layered_stack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Layered Stack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -28,42 +28,178 @@ dependencies:
|
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 7.
|
33
|
+
version: 7.2.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 7.
|
40
|
+
version: 7.2.1
|
41
41
|
description: CLI for Layered Stack
|
42
42
|
email:
|
43
|
-
- support@layeredstack.
|
43
|
+
- support@layeredstack.org
|
44
44
|
executables:
|
45
45
|
- layered_stack
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
-
- assets/backend/template.rb
|
50
|
-
- assets/images/logo_dark.svg
|
51
|
-
- assets/images/logo_light.svg
|
52
|
-
- assets/layout.js
|
53
|
-
- assets/page.js
|
54
|
-
- assets/tailwind.config.js
|
55
49
|
- bin/layered_stack
|
56
50
|
- lib/layered_stack.rb
|
57
51
|
- lib/layered_stack/backend/create.rb
|
58
52
|
- lib/layered_stack/backend/start.rb
|
59
53
|
- lib/layered_stack/frontend/create.rb
|
60
54
|
- lib/layered_stack/frontend/start.rb
|
55
|
+
- lib/layered_stack/root/create.rb
|
61
56
|
- lib/layered_stack/version.rb
|
62
|
-
|
57
|
+
- templates/backend/rails_template.rb
|
58
|
+
- templates/frontend/images/logo_dark.svg
|
59
|
+
- templates/frontend/images/logo_light.svg
|
60
|
+
- templates/frontend/layout.js
|
61
|
+
- templates/frontend/page.js
|
62
|
+
- templates/frontend/tailwind.config.js
|
63
|
+
- templates/root/Gemfile
|
64
|
+
- templates/root/Procfile
|
65
|
+
- templates/root/devcontainer/Dockerfile
|
66
|
+
- templates/root/devcontainer/devcontainer.json
|
67
|
+
- templates/root/devcontainer/docker-compose.yml
|
68
|
+
- templates/root/devcontainer/layered-stack-0.0.1.vsix
|
69
|
+
- templates/root/layered_stack/cli/LICENSE.md
|
70
|
+
- templates/root/layered_stack/cli/bin/layered_stack
|
71
|
+
- templates/root/layered_stack/cli/cli/LICENSE.md
|
72
|
+
- templates/root/layered_stack/cli/cli/bin/layered_stack
|
73
|
+
- templates/root/layered_stack/cli/cli/layered_stack-0.0.6.gem
|
74
|
+
- templates/root/layered_stack/cli/cli/layered_stack.gemspec
|
75
|
+
- templates/root/layered_stack/cli/cli/lib/layered_stack.rb
|
76
|
+
- templates/root/layered_stack/cli/cli/lib/layered_stack/backend/create.rb
|
77
|
+
- templates/root/layered_stack/cli/cli/lib/layered_stack/backend/start.rb
|
78
|
+
- templates/root/layered_stack/cli/cli/lib/layered_stack/frontend/create.rb
|
79
|
+
- templates/root/layered_stack/cli/cli/lib/layered_stack/frontend/start.rb
|
80
|
+
- templates/root/layered_stack/cli/cli/lib/layered_stack/root/create.rb
|
81
|
+
- templates/root/layered_stack/cli/cli/lib/layered_stack/version.rb
|
82
|
+
- templates/root/layered_stack/cli/cli/templates/backend/rails_template.rb
|
83
|
+
- templates/root/layered_stack/cli/cli/templates/frontend/images/logo_dark.svg
|
84
|
+
- templates/root/layered_stack/cli/cli/templates/frontend/images/logo_light.svg
|
85
|
+
- templates/root/layered_stack/cli/cli/templates/frontend/layout.js
|
86
|
+
- templates/root/layered_stack/cli/cli/templates/frontend/page.js
|
87
|
+
- templates/root/layered_stack/cli/cli/templates/frontend/tailwind.config.js
|
88
|
+
- templates/root/layered_stack/cli/cli/templates/root/Gemfile
|
89
|
+
- templates/root/layered_stack/cli/cli/templates/root/Procfile
|
90
|
+
- templates/root/layered_stack/cli/cli/templates/root/devcontainer/Dockerfile
|
91
|
+
- templates/root/layered_stack/cli/cli/templates/root/devcontainer/devcontainer.json
|
92
|
+
- templates/root/layered_stack/cli/cli/templates/root/devcontainer/docker-compose.yml
|
93
|
+
- templates/root/layered_stack/cli/cli/templates/root/devcontainer/layered-stack-0.0.1.vsix
|
94
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/LICENSE.md
|
95
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/bin/layered_stack
|
96
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/layered_stack-0.0.6.gem
|
97
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/layered_stack.gemspec
|
98
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack.rb
|
99
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack/backend/create.rb
|
100
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack/backend/start.rb
|
101
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack/frontend/create.rb
|
102
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack/frontend/start.rb
|
103
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack/root/create.rb
|
104
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/lib/layered_stack/version.rb
|
105
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/backend/rails_template.rb
|
106
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/frontend/images/logo_dark.svg
|
107
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/frontend/images/logo_light.svg
|
108
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/frontend/layout.js
|
109
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/frontend/page.js
|
110
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/frontend/tailwind.config.js
|
111
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/Gemfile
|
112
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/Procfile
|
113
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/devcontainer/Dockerfile
|
114
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/devcontainer/devcontainer.json
|
115
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/devcontainer/docker-compose.yml
|
116
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/devcontainer/layered-stack-0.0.1.vsix
|
117
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/LICENSE.md
|
118
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/bin/layered_stack-rails
|
119
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/layered_stack-rails.gemspec
|
120
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/scaffold_generator.rb
|
121
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/templates/active_record/model/model.erb
|
122
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails.rb
|
123
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/example.rb
|
124
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/generate.rb
|
125
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/generate_new.rb
|
126
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/version.rb
|
127
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/LICENSE.md
|
128
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/bin/layered_stack-rails
|
129
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/layered_stack-rails.gemspec
|
130
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/scaffold_generator.rb
|
131
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/templates/active_record/model/model.erb
|
132
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/layered_stack_rails.rb
|
133
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/example.rb
|
134
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/generate.rb
|
135
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/generate_new.rb
|
136
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/version.rb
|
137
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/LICENSE.md
|
138
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/bin/layered_stack-rails
|
139
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/layered_stack-rails.gemspec
|
140
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/generators/layered_stack_rails/scaffold_generator.rb
|
141
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/generators/layered_stack_rails/templates/active_record/model/model.erb
|
142
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/layered_stack_rails.rb
|
143
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/layered_stack_rails/example.rb
|
144
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/layered_stack_rails/generate.rb
|
145
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/layered_stack_rails/generate_new.rb
|
146
|
+
- templates/root/layered_stack/cli/cli/templates/root/layered_stack/rails/rails/lib/layered_stack_rails/version.rb
|
147
|
+
- templates/root/layered_stack/cli/layered_stack-0.0.6.gem
|
148
|
+
- templates/root/layered_stack/cli/layered_stack.gemspec
|
149
|
+
- templates/root/layered_stack/cli/lib/layered_stack.rb
|
150
|
+
- templates/root/layered_stack/cli/lib/layered_stack/backend/create.rb
|
151
|
+
- templates/root/layered_stack/cli/lib/layered_stack/backend/start.rb
|
152
|
+
- templates/root/layered_stack/cli/lib/layered_stack/frontend/create.rb
|
153
|
+
- templates/root/layered_stack/cli/lib/layered_stack/frontend/start.rb
|
154
|
+
- templates/root/layered_stack/cli/lib/layered_stack/root/create.rb
|
155
|
+
- templates/root/layered_stack/cli/lib/layered_stack/version.rb
|
156
|
+
- templates/root/layered_stack/cli/templates/backend/rails_template.rb
|
157
|
+
- templates/root/layered_stack/cli/templates/frontend/images/logo_dark.svg
|
158
|
+
- templates/root/layered_stack/cli/templates/frontend/images/logo_light.svg
|
159
|
+
- templates/root/layered_stack/cli/templates/frontend/layout.js
|
160
|
+
- templates/root/layered_stack/cli/templates/frontend/page.js
|
161
|
+
- templates/root/layered_stack/cli/templates/frontend/tailwind.config.js
|
162
|
+
- templates/root/layered_stack/cli/templates/root/Gemfile
|
163
|
+
- templates/root/layered_stack/cli/templates/root/Procfile
|
164
|
+
- templates/root/layered_stack/cli/templates/root/devcontainer/Dockerfile
|
165
|
+
- templates/root/layered_stack/cli/templates/root/devcontainer/devcontainer.json
|
166
|
+
- templates/root/layered_stack/cli/templates/root/devcontainer/docker-compose.yml
|
167
|
+
- templates/root/layered_stack/cli/templates/root/devcontainer/layered-stack-0.0.1.vsix
|
168
|
+
- templates/root/layered_stack/cli/templates/root/layered_stack/rails/LICENSE.md
|
169
|
+
- templates/root/layered_stack/cli/templates/root/layered_stack/rails/bin/layered_stack-rails
|
170
|
+
- templates/root/layered_stack/cli/templates/root/layered_stack/rails/layered_stack-rails.gemspec
|
171
|
+
- templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/scaffold_generator.rb
|
172
|
+
- templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/generators/layered_stack_rails/templates/active_record/model/model.erb
|
173
|
+
- templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails.rb
|
174
|
+
- templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/example.rb
|
175
|
+
- templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/generate.rb
|
176
|
+
- templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/generate_new.rb
|
177
|
+
- templates/root/layered_stack/cli/templates/root/layered_stack/rails/lib/layered_stack_rails/version.rb
|
178
|
+
- templates/root/layered_stack/rails/LICENSE.md
|
179
|
+
- templates/root/layered_stack/rails/bin/layered_stack-rails
|
180
|
+
- templates/root/layered_stack/rails/layered_stack-rails.gemspec
|
181
|
+
- templates/root/layered_stack/rails/lib/generators/layered_stack_rails/scaffold_generator.rb
|
182
|
+
- templates/root/layered_stack/rails/lib/generators/layered_stack_rails/templates/active_record/model/model.erb
|
183
|
+
- templates/root/layered_stack/rails/lib/layered_stack_rails.rb
|
184
|
+
- templates/root/layered_stack/rails/lib/layered_stack_rails/example.rb
|
185
|
+
- templates/root/layered_stack/rails/lib/layered_stack_rails/generate.rb
|
186
|
+
- templates/root/layered_stack/rails/lib/layered_stack_rails/generate_new.rb
|
187
|
+
- templates/root/layered_stack/rails/lib/layered_stack_rails/version.rb
|
188
|
+
- templates/root/layered_stack/rails/rails/LICENSE.md
|
189
|
+
- templates/root/layered_stack/rails/rails/bin/layered_stack-rails
|
190
|
+
- templates/root/layered_stack/rails/rails/layered_stack-rails.gemspec
|
191
|
+
- templates/root/layered_stack/rails/rails/lib/generators/layered_stack_rails/scaffold_generator.rb
|
192
|
+
- templates/root/layered_stack/rails/rails/lib/generators/layered_stack_rails/templates/active_record/model/model.erb
|
193
|
+
- templates/root/layered_stack/rails/rails/lib/layered_stack_rails.rb
|
194
|
+
- templates/root/layered_stack/rails/rails/lib/layered_stack_rails/example.rb
|
195
|
+
- templates/root/layered_stack/rails/rails/lib/layered_stack_rails/generate.rb
|
196
|
+
- templates/root/layered_stack/rails/rails/lib/layered_stack_rails/generate_new.rb
|
197
|
+
- templates/root/layered_stack/rails/rails/lib/layered_stack_rails/version.rb
|
198
|
+
homepage: https://www.layeredstack.org/
|
63
199
|
licenses:
|
64
200
|
- MIT
|
65
201
|
metadata:
|
66
|
-
homepage_uri: https://www.layeredstack.
|
202
|
+
homepage_uri: https://www.layeredstack.org/
|
67
203
|
source_code_uri: https://github.com/LayeredStack/cli
|
68
204
|
post_install_message:
|
69
205
|
rdoc_options: []
|
@@ -73,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
209
|
requirements:
|
74
210
|
- - ">="
|
75
211
|
- !ruby/object:Gem::Version
|
76
|
-
version: 3.3.
|
212
|
+
version: 3.3.4
|
77
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
214
|
requirements:
|
79
215
|
- - ">="
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|