Skip to content

Commit

Permalink
Merge pull request #5 from iancleary/bug/debugging-pipx-install
Browse files Browse the repository at this point in the history
  • Loading branch information
iancleary committed May 19, 2023
2 parents f9eef95 + e241475 commit 6241184
Show file tree
Hide file tree
Showing 24 changed files with 42 additions and 83 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Expand Up @@ -13,7 +13,7 @@ jobs:
matrix:
python-version: ['3.11']
os: [ubuntu-22.04]

permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Install dependencies
run: |
pdm sync -d -G dev
- name: Run Tests
- name: Run Tests
run: |
pdm run -v pytest tests
- name: Publish package distributions to PyPI
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Expand Up @@ -28,7 +28,6 @@ jobs:
- name: Install dependencies
run: |
pdm sync -d -G dev
- name: Run Tests
- name: Run Tests
run: |
pdm run -v pytest tests
3 changes: 0 additions & 3 deletions .gitignore
Expand Up @@ -204,6 +204,3 @@ components

# PDM
.pdm-python

# src folder for default components
src/
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
@@ -1,12 +1,4 @@
repos:
# export the lockfile to requirements.txt
- repo: https://github.com/pdm-project/pdm
rev: 2.6.1 # a PDM release exposing the hook
hooks:
- id: pdm-export
# command arguments, e.g.:
args: ['-o', 'docker-images/requirements.txt', '--without-hashes']
files: ^pdm.lock$
- repo: https://github.com/pdm-project/pdm
rev: 2.6.1 # a PDM release exposing the hook
hooks:
Expand Down
18 changes: 0 additions & 18 deletions new_component/__init__.py

This file was deleted.

28 changes: 1 addition & 27 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions pyproject.toml
@@ -1,11 +1,11 @@
[project]
name = "new-component"
version = "0.4.2"
name = "new_component"
version = "0.4.3"
description = "Quickly create opinionated Styled Components for React Projects"
authors = [
{name = "Ian Cleary", email = "github@iancleary.me"},
]
requires-python = ">=3.8"
requires-python = ">=3.11"
license = {text = "MIT"}

readme = "README.md"
Expand All @@ -18,10 +18,24 @@ dependencies = [
"Jinja2==3.1.2"
]

[project.urls]
Homepage = "https://new-component.iancleary.me"
Repository = "https://github.com/iancleary/new-component"
Documentation = "https://new-component.iancleary.me"

[project.scripts]
new-component = "new_component.__main__:main"
new-component = "new_component.main:main"

[tool.pdm.version]
source = "scm"
write_to = "new_component/VERSION"
write_template = "__version__ = '{}'" # optional, default to "{}"

[tool.pdm.build]
package-dir = "src"
includes = ["src/new_component"]
source-includes = ["tests", "LICENSE", "README.md"]

[tool.pdm]
[tool.pdm.dev-dependencies]
dev = [
"pytest==7.2.0",
Expand Down
1 change: 1 addition & 0 deletions src/new_component/__init__.py
@@ -0,0 +1 @@
__app_name__ = "datnewnew"
16 changes: 16 additions & 0 deletions src/new_component/__version__.py
@@ -0,0 +1,16 @@
import importlib.metadata as importlib_metadata
import importlib.resources

# https://github.com/pdm-project/pdm/blob/cea09584c7e18f038b01a9ce0aabe18991c0d02b/src/pdm/compat.py

resources_read_text = importlib.resources.read_text


def read_version() -> str:
try:
return importlib_metadata.version(__package__ or "new_component")
except importlib_metadata.PackageNotFoundError:
return resources_read_text("new_component", "VERSION").strip()


__version__ = read_version()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added tests/__init__.py
Empty file.
10 changes: 0 additions & 10 deletions tests/test_new_component.py
Expand Up @@ -30,14 +30,12 @@


def test_version() -> None:

result = runner.invoke(cli.app, ["--version"])
assert result.exit_code == 0
assert f"{__app_name__} v{__version__}\n" in result.stdout


def test_prompt_to_create_components_directory() -> None:

result = runner.invoke(
cli.app, ["Button"], input="y\n"
) # y to create components directory
Expand All @@ -49,15 +47,13 @@ def test_prompt_to_create_components_directory() -> None:


def test_creating_component() -> None:

result = runner.invoke(cli.app, ["AwesomeComponent"])
assert result.exit_code == 0
assert "AwesomeComponent" in result.stdout
assert "✨ Creating a new AwesomeComponent Component ✨!" in result.stdout


def test_creating_component_with_directory_first_time() -> None:

# ensure ./component directory is empty
SPECIFIED_COMPONENTS_DIR_PATH = Path("./components")
if SPECIFIED_COMPONENTS_DIR_PATH.exists():
Expand All @@ -75,7 +71,6 @@ def test_creating_component_with_directory_first_time() -> None:


def test_creating_component_with_directory_that_exists() -> None:

result = runner.invoke(
cli.app, ["DirectoryComponent2", "--directory", "components"]
)
Expand All @@ -85,7 +80,6 @@ def test_creating_component_with_directory_that_exists() -> None:


def test_creating_component_files() -> None:

result = runner.invoke(cli.app, ["File"])
assert result.exit_code == 0
assert "File" in result.stdout
Expand All @@ -97,7 +91,6 @@ def test_creating_component_files() -> None:


def test_creating_component_with_extension() -> None:

result = runner.invoke(cli.app, ["Extension", "--extension", "jsx"])
assert result.exit_code == 0
assert "Extension" in result.stdout
Expand All @@ -107,7 +100,6 @@ def test_creating_component_with_extension() -> None:


def test_local_config_file() -> None:

if LOCAL_CONFIG_FILE.exists():
os.remove(LOCAL_CONFIG_FILE)

Expand All @@ -130,7 +122,6 @@ def test_local_config_file() -> None:


def test_global_config_file() -> None:

if LOCAL_CONFIG_FILE.exists():
os.remove(LOCAL_CONFIG_FILE)

Expand Down Expand Up @@ -158,7 +149,6 @@ def test_global_config_file() -> None:


def test_local_and_global_config_file() -> None:

if LOCAL_CONFIG_FILE.exists():
os.remove(LOCAL_CONFIG_FILE)

Expand Down
10 changes: 2 additions & 8 deletions tests/test_version.py
@@ -1,15 +1,9 @@
from new_component import __version__, package_version
from new_component.__version__ import __version__


def test_package_version() -> None:
"""Test package version calculation."""
[major, minor, patch] = package_version().split(".")
[major, minor, patch] = __version__.split(".")
assert isinstance(major, str)
assert isinstance(minor, str)
assert isinstance(patch, str)


def test_package_version_not_found() -> None:
"""Test package version calculation when package is not installed."""
assert package_version(package="incorrect") == "Package not found."

1 comment on commit 6241184

@vercel
Copy link

@vercel vercel bot commented on 6241184 May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.