未验证 提交 349cf76c 编写于 作者: F Frost Ming

Ask if the project is a library

上级 aa1e7234
When initializing the project, prompt user for whether the project is a library, and give empty `name` and `version` if not.
......@@ -31,8 +31,18 @@ class Command(BaseCommand):
"Please enter the Python interpreter to use", default="", show_default=False
)
actions.do_use(project, python)
name = click.prompt("Project name", default=project.root.name)
version = click.prompt("Project version", default="0.0.0")
is_library = (
click.prompt(
"Is the project a library that will be upload to PyPI?(y/n)",
default="n",
).lower()
== "y"
)
if is_library:
name = click.prompt("Project name", default=project.root.name)
version = click.prompt("Project version", default="0.1.0")
else:
name, version = "", ""
license = click.prompt("License(SPDX name)", default="MIT")
git_user, git_email = get_user_email_from_git()
......
......@@ -40,7 +40,7 @@ description = "Python Development Master"
readme = "README.md"
keywords = ["packaging", "dependency", "workflow"]
classifiers = [
"Development Status :: 3 - Alpha",
"Development Status :: 4 - Beta",
"Topic :: Software Development :: Build Tools",
]
......
......@@ -137,13 +137,35 @@ def test_install_with_lockfile(project, invoke, working_set, repository):
def test_init_command(project_no_init, invoke, mocker):
mocker.patch(
"pdm.cli.commands.init.get_user_email_from_git",
return_value=("Testing", "me@example.org"),
)
do_init = mocker.patch.object(actions, "do_init")
result = invoke(["init"], input="python\n\n\n\n\n\n", obj=project_no_init)
assert result.exit_code == 0
python_version, _ = get_python_version(
project_no_init.environment.python_executable, True, 2
)
do_init.assert_called_with(
project_no_init,
"",
"",
"MIT",
"Testing",
"me@example.org",
f">={python_version}",
)
def test_init_command_library(project_no_init, invoke, mocker):
mocker.patch(
"pdm.cli.commands.init.get_user_email_from_git",
return_value=("Testing", "me@example.org"),
)
do_init = mocker.patch.object(actions, "do_init")
result = invoke(
["init"], input="python\ntest-project\n\n\n\n\n\n", obj=project_no_init
["init"], input="python\ny\ntest-project\n\n\n\n\n\n", obj=project_no_init
)
assert result.exit_code == 0
python_version, _ = get_python_version(
......@@ -152,7 +174,7 @@ def test_init_command(project_no_init, invoke, mocker):
do_init.assert_called_with(
project_no_init,
"test-project",
"0.0.0",
"0.1.0",
"MIT",
"Testing",
"me@example.org",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册