Skip to content
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
7 changes: 7 additions & 0 deletions components/polylith/poetry/commands/create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ class CreateProjectCommand(Command):

options = [
option("name", None, "Name of the project.", flag=False),
option(
"description",
None,
"Description of the project.",
flag=False,
value_required=False,
),
]

def handle(self) -> int:
Expand Down
22 changes: 17 additions & 5 deletions components/polylith/project/create.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
from typing import Union

import tomlkit
from polylith import repo
Expand All @@ -9,7 +10,7 @@
[tool.poetry]
name = "{name}"
version = "0.1.0"
description = ""
description = "{description}"
authors = {authors}
license = ""

Expand All @@ -33,20 +34,31 @@ def get_workspace_toml(path: Path) -> dict:
return data


def create_project_toml(name, template, workspace_toml) -> tomlkit.TOMLDocument:
def create_project_toml(
name: str, template: str, workspace_toml: dict, description: str
) -> tomlkit.TOMLDocument:
authors = workspace_toml["tool"]["poetry"]["authors"]
python_version = workspace_toml["tool"]["poetry"]["dependencies"]["python"]

content = template.format(name=name, authors=authors, python_version=python_version)
content = template.format(
name=name,
description=description,
authors=authors,
python_version=python_version,
)

return tomlkit.loads(content)


def create_project(path: Path, namespace: str, name: str) -> None:
def create_project(
path: Path, namespace: str, name: str, description: Union[str, None]
) -> None:
d = create_dir(path, f"{projects_dir}/{name}")

workspace_toml = get_workspace_toml(path)
project_toml = create_project_toml(name, template, workspace_toml)
project_toml = create_project_toml(
name, template, workspace_toml, description or ""
)

fullpath = d / repo.default_toml

Expand Down
11 changes: 6 additions & 5 deletions projects/poetry_polylith_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,19 @@ Add a base:
poetry poly create base --name my_example_aws_lambda
```

##### Options
`--description`
Add a brick description. Will be added as a docstring, and in the brick-specific README
(if it is enabled in the `resources` section of the workspace config).

Add a project:

``` shell
# This command will create a project - i.e. a pyproject.toml in a project folder. No code in this folder.
poetry poly create project --name my_example_aws_lambada_project
```

##### Options
`--description`
Add a brick description. The description will be added as a docstring.
Also in the brick-specific README (when set to enabled in the `resources` section of the workspace config).


#### Info
Show info about the workspace:

Expand Down
2 changes: 1 addition & 1 deletion projects/poetry_polylith_plugin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "poetry-polylith-plugin"
version = "1.2.0"
version = "1.2.1"
description = "A Poetry plugin that adds tooling support for the Polylith Architecture"
authors = ["David Vujic"]
homepage = "https://github.com/davidvujic/python-polylith"
Expand Down