diff options
| -rw-r--r-- | src/ipm/api.py | 9 | ||||
| -rw-r--r-- | src/ipm/typing.py | 3 | ||||
| -rw-r--r-- | src/ipm/utils/_freeze.py | 2 | ||||
| -rw-r--r-- | src/ipm/utils/freeze.py | 2 |
4 files changed, 13 insertions, 3 deletions
diff --git a/src/ipm/api.py b/src/ipm/api.py index 6745b04..60dc05b 100644 --- a/src/ipm/api.py +++ b/src/ipm/api.py @@ -80,6 +80,15 @@ def init(source_path: StrPath, force: bool = False, echo: bool = False) -> bool: toml_file.close() (source_path / "src").mkdir(parents=True, exist_ok=True) + (source_path / ".gitignores").write_text( + "# Initialized `.gitignores` generated by ipm.\n\n" + "# python\n" + "__pycache__/\n" + "*.pyc\n" + "# build\n" + "build/" + "dist/" + ) if entry_file == "0": (source_path / "src" / "__init__.py").write_text( "# Initialized `__init__.py` generated by ipm.\n" diff --git a/src/ipm/typing.py b/src/ipm/typing.py index 45591ed..0346381 100644 --- a/src/ipm/typing.py +++ b/src/ipm/typing.py @@ -1,5 +1,6 @@ from pathlib import Path from typing import ( + Union, Literal as Literal, List as List, Dict as Dict, @@ -7,7 +8,7 @@ from typing import ( AnyStr as AnyStr, ) -StrPath = str | Path +StrPath = Union[str, Path] Index = Dict[Literal["index", "host", "uuid"], str] Package = Dict[ Literal["name", "version", "description", "requirements", "dependencies"], str diff --git a/src/ipm/utils/_freeze.py b/src/ipm/utils/_freeze.py index 1df0f86..e1d19db 100644 --- a/src/ipm/utils/_freeze.py +++ b/src/ipm/utils/_freeze.py @@ -12,4 +12,4 @@ def create_tar_gz(source_folder: str, output_filepath: str) -> None: def extract_tar_gz(input_filename: str, output_folder: str) -> None: with tarfile.open(input_filename, "r:gz") as tar: - tar.extractall(output_folder) + tar.extractall(output_folder, filter=tarfile.fully_trusted_filter) diff --git a/src/ipm/utils/freeze.py b/src/ipm/utils/freeze.py index 277a068..de66f57 100644 --- a/src/ipm/utils/freeze.py +++ b/src/ipm/utils/freeze.py @@ -31,7 +31,7 @@ def build_ipk(ipk: InfiniProject, echo: bool = False) -> InfiniFrozenPackage: update("复制工程文件...", echo) shutil.copytree(src_path, build_dir / "src") shutil.copy2(ipk.source_path / "infini.toml", build_dir / "infini.toml") - success("工程文件复制完毕.") + success("工程文件复制完毕.", echo) update("打包 [bold green]ipk[/bold green]文件...", echo) _freeze.create_tar_gz( |
