forked from platformio/platformio-core
Implement "package pack" command
This commit is contained in:
@ -25,16 +25,18 @@ class RegistryClient(RESTClient):
|
||||
def publish_package(
|
||||
self, archive_path, owner=None, released_at=None, private=False
|
||||
):
|
||||
client = AccountClient()
|
||||
account = AccountClient()
|
||||
if not owner:
|
||||
owner = client.get_account_info(offline=True).get("profile").get("username")
|
||||
owner = (
|
||||
account.get_account_info(offline=True).get("profile").get("username")
|
||||
)
|
||||
with open(archive_path, "rb") as fp:
|
||||
response = self.send_request(
|
||||
"post",
|
||||
"/v3/package/%s/%s" % (owner, PackageType.from_archive(archive_path)),
|
||||
params={"private": 1 if private else 0, "released_at": released_at},
|
||||
headers={
|
||||
"Authorization": "Bearer %s" % client.fetch_authentication_token()
|
||||
"Authorization": "Bearer %s" % account.fetch_authentication_token()
|
||||
},
|
||||
data=fp,
|
||||
)
|
||||
|
@ -34,6 +34,14 @@ def cli():
|
||||
pass
|
||||
|
||||
|
||||
@cli.command("pack", short_help="Create a tarball from a package")
|
||||
@click.argument("package", required=True, metavar="[source directory, tar.gz or zip]")
|
||||
def package_pack(package):
|
||||
p = PackagePacker(package)
|
||||
tarball_path = p.pack()
|
||||
click.secho('Wrote a tarball to "%s"' % tarball_path, fg="green")
|
||||
|
||||
|
||||
@cli.command(
|
||||
"publish", short_help="Publish a package to the PlatformIO Universal Registry"
|
||||
)
|
||||
|
@ -20,7 +20,6 @@ from platformio import app, exception, util
|
||||
from platformio.commands.boards import print_boards
|
||||
from platformio.compat import dump_json_to_unicode
|
||||
from platformio.managers.platform import PlatformFactory, PlatformManager
|
||||
from platformio.package.pack import PackagePacker
|
||||
|
||||
|
||||
@click.group(short_help="Platform Manager")
|
||||
@ -411,13 +410,3 @@ def platform_update( # pylint: disable=too-many-locals
|
||||
click.echo()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@cli.command(
|
||||
"pack", short_help="Create a tarball from development platform/tool package"
|
||||
)
|
||||
@click.argument("package", required=True, metavar="[source directory, tar.gz or zip]")
|
||||
def platform_pack(package):
|
||||
p = PackagePacker(package)
|
||||
tarball_path = p.pack()
|
||||
click.secho('Wrote a tarball to "%s"' % tarball_path, fg="green")
|
||||
|
Reference in New Issue
Block a user