Skip to content

Commit 32c324a

Browse files
committed
Revert back use_async usage and add component_type
1 parent 2e2f70d commit 32c324a

File tree

5 files changed

+12
-68
lines changed

5 files changed

+12
-68
lines changed

cookiecutter.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@
88
"author_email": "Enter your email (For package.json)",
99
"github_org": "",
1010
"description": "Project Description",
11-
"component_type": [
12-
"Async with Class Component",
13-
"Async with Function Component",
14-
"Class Component",
15-
"Function Component"
16-
],
11+
"use_async": ["False", "True"],
12+
"component_type": ["Function Component", "Class Component"],
1713
"license": [
1814
"MIT License",
1915
"BSD License",

hooks/post_gen_project.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
install_deps = '{{cookiecutter.install_dependencies}}'
1010
project_shortname = '{{cookiecutter.project_shortname}}'
11-
component_type = '{{cookiecutter.component_type}}'
11+
use_async = '{{cookiecutter.use_async}}'
1212

1313

1414
is_windows = sys.platform == 'win32'
@@ -41,16 +41,15 @@ def _execute_command(cmd):
4141
template_dir = os.path.join(os.getcwd(), 'cookiecutter_templates')
4242
shutil.rmtree(template_dir)
4343

44-
print("\n\n\ncomponent_type")
45-
print(component_type)
44+
print("\n\n\nuse_async")
45+
print(use_async)
4646
# If it doesn't use async, we can remove the fragments and lazyloader.js
47-
if "Async" not in component_type:
48-
print('Since Async component is not in use, your component will not be lazy loaded and fragments will not be created.')
47+
if use_async != "True":
48+
print('use_async is set to False, your component will not be lazy loaded and fragments will not be created.')
4949
shutil.rmtree(os.path.join(os.getcwd(), 'src', 'lib', 'fragments'))
5050
os.remove(os.path.join(os.getcwd(), 'src', 'lib', 'LazyLoader.js'))
5151

5252

53-
5453
if install_deps != 'True':
5554
print('`install_dependencies` is false!!', file=sys.stderr)
5655
print('Please create a venv in your project root'

{{cookiecutter.project_shortname}}/cookiecutter_templates/AsyncClassComponent.react.js

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
{%- if "Async" in cookiecutter.component_type and "Class" in cookiecutter.component_type -%}
2-
{%- include 'cookiecutter_templates/AsyncClassComponent.react.js' -%}
3-
{%- elif "Async" in cookiecutter.component_type and "Function" in cookiecutter.component_type -%}
1+
{%- if cookiecutter.use_async == "True" -%}
42
{%- include 'cookiecutter_templates/AsyncFunctionComponent.react.js' -%}
5-
{%- elif "Class" in cookiecutter.component_type -%}
6-
{%- include 'cookiecutter_templates/ClassComponent.react.js' -%}
7-
{%- else -%}
3+
{%- elif cookiecutter.component_type == "Function Component" -%}
84
{%- include 'cookiecutter_templates/FunctionComponent.react.js' -%}
5+
{%- else -%}
6+
{%- include 'cookiecutter_templates/ClassComponent.react.js' -%}
97
{%- endif -%}

{{cookiecutter.project_shortname}}/{{cookiecutter.project_shortname}}/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
_this_module = _sys.modules[__name__]
3030

3131
async_resources = [
32-
{%- if "Async" in cookiecutter.component_type -%}
32+
{%- if cookiecutter.use_async == "True" -%}
3333
"{{cookiecutter.component_name}}",
3434
{%- endif -%}
3535
]

0 commit comments

Comments
 (0)