Browse Source

fix PackageModel.get_py_typed_file(), refactor update commands

shut-new-model
Niklas Rosenstein 9 months ago
parent
commit
c4ea5ad90c
No known key found for this signature in database GPG Key ID: 6D269B33D25F6C6
3 changed files with 15 additions and 7 deletions
  1. + 8
    - 4
      src/shut/commands/mono/update.py
  2. + 6
    - 2
      src/shut/commands/pkg/update.py
  3. + 1
    - 1
      src/shut/model/package.py

+ 8
- 4
src/shut/commands/mono/update.py

@ -23,11 +23,17 @@ import click
from shut.commands import project
from shut.commands.commons.new import write_files
from shut.commands.pkg.update import update_package
from shut.model import MonorepoModel
from shut.update import get_files
from . import mono
def update_monorepo(monorepo: MonorepoModel, dry: bool = False) -> None:
files = get_files(monorepo)
write_files(files, monorepo.get_directory(), force=True, dry=dry)
@mono.command()
@click.option('--dry', is_flag=True)
@click.option('-a', '--all', 'all_', is_flag=True, help='Also update any packages in the monorepo.')
@ -37,10 +43,8 @@ def update(all_, dry):
"""
monorepo = project.load_or_exit(expect=MonorepoModel)
files = get_files(monorepo)
write_files(files, monorepo.get_directory(), force=True, dry=dry)
update_monorepo(monorepo, dry)
if all_:
for package in project.packages:
files = get_files(package)
write_files(files, package.get_directory(), force=True, dry=dry)
update_package(package, dry)

+ 6
- 2
src/shut/commands/pkg/update.py

@ -28,6 +28,11 @@ from shut.update import get_files
from . import pkg
def update_package(package: PackageModel, dry: bool = False) -> None:
files = get_files(package)
write_files(files, package.get_directory(), force=True, dry=dry)
@pkg.command()
@click.option('--dry', is_flag=True)
def update(dry):
@ -36,5 +41,4 @@ def update(dry):
"""
package = project.load_or_exit(expect=PackageModel)
files = get_files(package)
write_files(files, package.get_directory(), force=True, dry=dry)
update_package(package)

+ 1
- 1
src/shut/model/package.py

@ -175,7 +175,7 @@ class PackageModel(AbstractProjectModel):
if not self.data.typed:
return None
directory = package.get_python_package_metadata().package_directory
directory = self.get_python_package_metadata().package_directory
return os.path.join(directory, 'py.typed')
# AbstractProjectModel

Loading…
Cancel
Save