Allow to update only the PIO Core packages

This commit is contained in:
Ivan Kravets
2017-03-27 14:14:29 +03:00
parent b7a61f12e8
commit e736b08a49
5 changed files with 18 additions and 11 deletions

2
docs

Submodule docs updated: b130133bb7...a5a472148c

View File

@ -332,9 +332,6 @@ def platform_uninstall(platforms):
help="Do not update, only check for a new version") help="Do not update, only check for a new version")
@click.option("--json-output", is_flag=True) @click.option("--json-output", is_flag=True)
def platform_update(platforms, only_packages, only_check, json_output): def platform_update(platforms, only_packages, only_check, json_output):
# cleanup cached board and platform lists
app.clean_cache()
pm = PlatformManager() pm = PlatformManager()
pkg_dir_to_name = {} pkg_dir_to_name = {}
if not platforms: if not platforms:
@ -366,6 +363,8 @@ def platform_update(platforms, only_packages, only_check, json_output):
result.append(data) result.append(data)
return click.echo(json.dumps(result)) return click.echo(json.dumps(result))
else: else:
# cleanup cached board and platform lists
app.clean_cache()
for platform in platforms: for platform in platforms:
click.echo("Platform %s" % click.style( click.echo("Platform %s" % click.style(
pkg_dir_to_name.get(platform, platform), fg="cyan")) pkg_dir_to_name.get(platform, platform), fg="cyan"))

View File

@ -14,6 +14,7 @@
import click import click
from platformio import app
from platformio.commands.lib import lib_update as cmd_lib_update from platformio.commands.lib import lib_update as cmd_lib_update
from platformio.commands.platform import platform_update as cmd_platform_update from platformio.commands.platform import platform_update as cmd_platform_update
from platformio.managers.core import update_core_packages from platformio.managers.core import update_core_packages
@ -22,15 +23,23 @@ from platformio.managers.lib import LibraryManager
@click.command( @click.command(
"update", short_help="Update installed platforms, packages and libraries") "update", short_help="Update installed platforms, packages and libraries")
@click.option(
"--core-packages", is_flag=True, help="Update only the core packages")
@click.option( @click.option(
"-c", "-c",
"--only-check", "--only-check",
is_flag=True, is_flag=True,
help="Do not update, only check for new version") help="Do not update, only check for new version")
@click.pass_context @click.pass_context
def cli(ctx, only_check): def cli(ctx, core_packages, only_check):
update_core_packages(only_check) update_core_packages(only_check)
if core_packages:
return
# cleanup lib search results, cached board and platform lists
app.clean_cache()
click.echo() click.echo()
click.echo("Platform Manager") click.echo("Platform Manager")
click.echo("================") click.echo("================")

View File

@ -59,8 +59,6 @@ def on_platformio_start(ctx, force, caller):
app.set_session_var("caller_id", caller) app.set_session_var("caller_id", caller)
telemetry.on_command() telemetry.on_command()
if ctx.args and ctx.args[0] == "update":
app.clean_cache()
if not in_silence(ctx): if not in_silence(ctx):
after_upgrade(ctx) after_upgrade(ctx)
@ -159,7 +157,7 @@ def after_upgrade(ctx):
app.clean_cache() app.clean_cache()
# Update PlatformIO's Core packages # Update PlatformIO's Core packages
update_core_packages() update_core_packages(silent=True)
u = Upgrader(last_version, __version__) u = Upgrader(last_version, __version__)
if u.run(ctx): if u.run(ctx):

View File

@ -21,7 +21,6 @@ from platformio import exception, util
from platformio.managers.package import PackageManager from platformio.managers.package import PackageManager
CORE_PACKAGES = { CORE_PACKAGES = {
"project-templates": "*",
"pysite-pioplus": ">=0.3.0,<2", "pysite-pioplus": ">=0.3.0,<2",
"tool-pioplus": ">=0.6.10,<2", "tool-pioplus": ">=0.6.10,<2",
"tool-unity": "~1.20302.1", "tool-unity": "~1.20302.1",
@ -53,11 +52,13 @@ def get_core_package_dir(name):
return pm.install(name, requirements) return pm.install(name, requirements)
def update_core_packages(only_check=False): def update_core_packages(only_check=False, silent=False):
pm = CorePackageManager() pm = CorePackageManager()
for name, requirements in CORE_PACKAGES.items(): for name, requirements in CORE_PACKAGES.items():
pkg_dir = pm.get_package_dir(name) pkg_dir = pm.get_package_dir(name)
if pkg_dir and pm.outdated(pkg_dir, requirements): if not pkg_dir:
continue
if not silent or pm.outdated(pkg_dir, requirements):
pm.update(name, requirements, only_check=only_check) pm.update(name, requirements, only_check=only_check)