pebble/devsite/source/_posts/2016-06-07-pebble-packages.md
2025-02-24 18:58:29 -08:00

3.5 KiB

title author tags
Introducing Pebble Packages katharine
Freshly Baked

I am thrilled to announce that, as part of SDK 3.13 and Pebble Tool 4.3, we have launched our own packaging system: Pebble Packages!

There are already a healthy selection of Pebble libraries to be had, such as Yuriy's excellent EffectLayer, Reboot's Ramblings' palette manipulator, or even our own weather library. However, using them today is inelegant: you generally have to copy/paste all of the library code into your own project and follow some other setup instructions: assigning appmessage keys, editing resources into your appinfo.json, or similar.

Starting today, using a Pebble Package can be as simple as running pebble package install pebble-owm-weather. A Pebble Package can contain both C code for the watch and JavaScript code for the phone. Furthermore, it can also contain any resources, and define its own appmessage keys. All numeric identifiers will be resolved at app build time to ensure there are never any conflicts. This helps to enable zero-setup packages of all kinds.

To make the usage of appmessages in Pebble Packages possible, we have also substantially improved the functionality of the old appKeys section of appinfo.json. We will now automatically insert the keys into your C code with the prefix MESSAGE_KEY_. You can also access their numeric values from JavaScript by requiring the message_keys module: var keys = require('message_keys').

Packages would be nothing without a package manager, so we have built our packaging system on top of the excellent npm package manager. This gives us support for dependency management, versioning, package hosting, and more. Furthermore, some traditional JavaScript modules on npm will work out of the box, as long as they don't depend on running in node or on a browser. As part of this move we have deprecated appinfo.json: we now use package.json instead. The latest version of the Pebble Tool can convert your project when you run pebble convert-project. Old-style projects continue to be supported, but cannot use the package manager.

For your convenience, we have provided some wrappers around npm functionality:

  • pebble package install to safely install a package.
  • pebble package uninstall to uninstall a package.
  • pebble package login to log in to or create your npm account.
  • pebble package publish to publish your package to npm.

We also have UI in CloudPebble to enter your dependencies.

You can browse the available packages on npm under the pebble-package keyword, and read our guides on using and creating Pebble Packages.

I'm looking forward to seeing what you make!