From 1269ce064a480fbbff0ad781f5df0a75e540b1af Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 8 Apr 2022 13:58:40 +0300 Subject: [PATCH] Improved detection of a package type from the tarball archive // Resolve #3828 --- HISTORY.rst | 1 + docs | 2 +- platformio/package/commands/publish.py | 11 ++++++++--- tests/commands/pkg/test_install.py | 4 +--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 747d8c488d..6d86d128c9 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -32,6 +32,7 @@ PlatformIO Core 5 - Added support for `symbolic links `__ allowing pointing the local source folder to the Package Manager (`issue #3348 `_) - Automatically install dependencies of the local (private) project libraries (`issue #2910 `_) + - Improved detection of a package type from the tarball archive (`issue #3828 `_) - Ignore files according to the patterns declared in ".gitignore" when using the `pio package pack `__ command (`issue #4188 `_) - Dropped automatic updates of global libraries and development platforms (`issue #4179 `_) - Dropped support for the "pythonPackages" field in "platform.json" manifest in favor of `Extra Python Dependencies `__ diff --git a/docs b/docs index f834c85d59..f543ff06f0 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit f834c85d5956851172ae1daa4e4aa9474839472e +Subproject commit f543ff06f03f8f5d12aea232098a75bf6a070fb9 diff --git a/platformio/package/commands/publish.py b/platformio/package/commands/publish.py index 100227ed4e..9028bd31a5 100644 --- a/platformio/package/commands/publish.py +++ b/platformio/package/commands/publish.py @@ -52,6 +52,11 @@ def validate_datetime(ctx, param, value): # pylint: disable=unused-argument help="PIO Account username (can be organization username). " "Default is set to a username of the authorized PIO Account", ) +@click.option( + "--type", "type_", + type=click.Choice(list(PackageType.items().values())), + help="Custom package type", +) @click.option( "--released-at", callback=validate_datetime, @@ -69,13 +74,13 @@ def validate_datetime(ctx, param, value): # pylint: disable=unused-argument help="Do not show interactive prompt", ) def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals - package, owner, released_at, private, notify, non_interactive + package, owner, type_, released_at, private, notify, non_interactive ): click.secho("Preparing a package...", fg="cyan") owner = owner or AccountClient().get_logged_username() do_not_pack = not os.path.isdir(package) and isinstance( FileUnpacker.new_archiver(package), TARArchiver - ) + ) and PackageType.from_archive(package) archive_path = None with tempfile.TemporaryDirectory() as tmp_dir: # pylint: disable=no-member # publish .tar.gz instantly without repacking @@ -86,7 +91,7 @@ def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals p = PackagePacker(package) archive_path = p.pack() - type_ = PackageType.from_archive(archive_path) + type_ = type_ or PackageType.from_archive(archive_path) manifest = ManifestSchema().load_manifest( ManifestParserFactory.new_from_archive(archive_path).as_dict() ) diff --git a/tests/commands/pkg/test_install.py b/tests/commands/pkg/test_install.py index df746b9d50..d2aa25d689 100644 --- a/tests/commands/pkg/test_install.py +++ b/tests/commands/pkg/test_install.py @@ -275,9 +275,7 @@ def test_remove_project_unused_libdeps( # add new deps lib_deps = config.get("env:baremetal", "lib_deps") - config.set( - "env:baremetal", "lib_deps", lib_deps + ["bblanchon/ArduinoJson@^5"] - ) + config.set("env:baremetal", "lib_deps", lib_deps + ["bblanchon/ArduinoJson@^5"]) config.save() result = clirunner.invoke( package_install_cmd,