Skip to content

Commit a0293ab

Browse files
committed
Adding parameter descriptions
1 parent c58e613 commit a0293ab

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

lib/generators/strapi/component_generator.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ module Strapi
22
class ComponentGenerator < Rails::Generators::Base
33
source_root File.expand_path("component_templates", __dir__)
44

5-
argument :component_name, type: :string, required: true
6-
argument :component_type, type: :string, required: true
7-
class_option :strapi_params, type: :array, default: []
5+
desc "Generates a Strapi component and related files"
6+
7+
argument :component_name, type: :string, required: true, desc: "Name of your component, do not include Cms:: namespace, we automatically add this"
8+
argument :component_type, type: :string, required: true, desc: "Name of the type you assigned your component to, e,g blocks"
9+
class_option :strapi_params, type: :array, default: [], desc: "A list of params you want to include from strapi, please provide these matching the case you have used in Strapi"
810

911
COMPONENT_TYPES = %w[blocks content_blocks buttons email_content]
1012
PROVIDER = "providers/strapi/"
1113
BASE_PATH = "app/services/cms/"
12-
STRAPI_PATH = "#{BASE_PATH}#{PROVIDER}"
14+
STRAPI_PATH = File.join(BASE_PATH, PROVIDER)
1315
TEST_BASE_PATH = "spec/services/cms/"
14-
TEST_PATH = "#{TEST_BASE_PATH}#{PROVIDER}"
16+
TEST_PATH = File.join(TEST_BASE_PATH, PROVIDER)
1517

1618
def setup_params
1719
raise StandardError unless COMPONENT_TYPES.include?(component_type)
@@ -25,23 +27,23 @@ def setup_params
2527
end
2628

2729
def create_query_file
28-
template("query_template.rb.tt", "#{STRAPI_PATH}queries/components/#{@component_type_filename}/#{@component_filename}.rb")
30+
template("query_template.rb.tt", File.join(STRAPI_PATH, "queries/components", @component_type_filename, "#{@component_filename}.rb"))
2931
end
3032

3133
def create_query_test
32-
template("query_test_template.rb.tt", "#{TEST_PATH}queries/components/#{@component_type_filename}/#{@component_filename}_spec.rb")
34+
template("query_test_template.rb.tt", File.join(TEST_PATH, "queries/components", @component_type_filename, "#{@component_filename}_spec.rb"))
3335
end
3436

3537
def create_mock_file
36-
template("mock_template.rb.tt", "#{STRAPI_PATH}mocks/dynamic_components/#{@component_type_filename}/#{@component_filename}.rb")
38+
template("mock_template.rb.tt", File.join(STRAPI_PATH, "mocks/dynamic_components", @component_type_filename, "#{@component_filename}.rb"))
3739
end
3840

3941
def create_data_file
40-
template("mapping_template.rb.tt", "#{BASE_PATH}dynamic_components/#{@component_type_filename}/#{@component_filename}.rb")
42+
template("mapping_template.rb.tt", File.join(BASE_PATH, "dynamic_components", @component_type_filename, "#{@component_filename}.rb"))
4143
end
4244

4345
def create_data_text
44-
template("mapping_test_template.rb.tt", "#{TEST_BASE_PATH}dynamic_components/#{@component_type_filename}/#{@component_filename}_spec.rb")
46+
template("mapping_test_template.rb.tt", File.join(TEST_BASE_PATH, "dynamic_components", @component_type_filename, "#{@component_filename}_spec.rb"))
4547
end
4648

4749
def run_view_component_generator

spec/lib/generators/strapi/component_generator_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
end
9090

9191
def file_path(file)
92-
"tmp/gen_test/#{file}"
92+
File.join(tmp_dir, file)
9393
end
9494
end
9595

0 commit comments

Comments
 (0)