Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffold Components Fix #230

Merged
merged 5 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ Documenting All Changes to the Skelebot Project

---

## v1.33.2
#### Changed
- **Scaffolding** | Fixed a bug in scaffolding where templates were not having components loaded in the config section

---

## v1.33.1
#### Merged: 2022-09-19
#### Released: 2022-09-19
#### Changed
- **S3Repo** | Fixed a bug in S3Repo where the artifact version was not being parsed properly in some cases

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.33.1
1.33.2
9 changes: 5 additions & 4 deletions skelebot/systems/scaffolding/scaffolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def scaffold(self):

# Prompt user based on the template
for prompt in template.get("prompts", []):
print(prompt)
self.variables[prompt["var"]] = promptUser(prompt["message"])

# Iterate over components for additional prompts and add any components that are scaffolded
Expand Down Expand Up @@ -127,20 +126,22 @@ def scaffold(self):
print("Attaching fiber optic ligaments...")
for file_dict in template.get("files", []):
with open(file_dict["template"], "r") as tmp_file:
print(f"READING TEMPLATE: {file_dict['template']}")
with open(file_dict["name"], "w") as dst_file:
print(f"WRITING FILE: {file_dict['name']}")
dst_file.write(self.__format_variables(tmp_file.read()))

print("Soldering the micro-computer to the skele-skull...")
# Build the config object based on the user inputs
cfg = self.__format_config(template["config"])
cfg["name"] = name
for component in components:
component_dict = component.toDict()
if component_dict != {}:
cfg["components"][component.__class__.__name__.lower()] = component_dict

config = Config.load(cfg)
config.description = description
config.maintainer = maintainer
config.contact = contact
config.components = components
config.version = "0.1.0"

if (not self.existing):
Expand Down
13 changes: 7 additions & 6 deletions test/test_systems_scaffolding_scaffolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from unittest import mock

import skelebot as sb
from skelebot.components.bump import Bump

TEMPLATE = {
"dirs": ["src/assets/"],
Expand Down Expand Up @@ -120,9 +121,9 @@ def test_execute_scaffold_git_pull(self, mock_prompt, mock_yaml, mock_readme, mo

# Set up mock components with scaffolding
mock_single_comp = mock.MagicMock()
mock_single_comp.scaffold.return_value = 'foo'
mock_single_comp.scaffold.return_value = Bump()
mock_list_comp = mock.MagicMock()
mock_list_comp.scaffold.return_value = ['bar', 'baz']
mock_list_comp.scaffold.return_value = [Bump(), Bump()]

mock_cFactory.return_value.buildComponents.return_value = [
mock_single_comp, mock_list_comp
Expand Down Expand Up @@ -190,9 +191,9 @@ def test_execute_scaffold_git_clone(self, mock_prompt, mock_yaml, mock_readme, m

# Set up mock components with scaffolding
mock_single_comp = mock.MagicMock()
mock_single_comp.scaffold.return_value = 'foo'
mock_single_comp.scaffold.return_value = Bump()
mock_list_comp = mock.MagicMock()
mock_list_comp.scaffold.return_value = ['bar', 'baz']
mock_list_comp.scaffold.return_value = [Bump(), Bump()]

mock_cFactory.return_value.buildComponents.return_value = [
mock_single_comp, mock_list_comp
Expand Down Expand Up @@ -253,9 +254,9 @@ def test_execute_scaffold_dash(self, mock_prompt, mock_yaml, mock_readme, mock_p

# Set up mock components with scaffolding
mock_single_comp = mock.MagicMock()
mock_single_comp.scaffold.return_value = 'foo'
mock_single_comp.scaffold.return_value = Bump()
mock_list_comp = mock.MagicMock()
mock_list_comp.scaffold.return_value = ['bar', 'baz']
mock_list_comp.scaffold.return_value = [Bump(), Bump()]

mock_cFactory.return_value.buildComponents.return_value = [
mock_single_comp, mock_list_comp
Expand Down