Skip to content

Instantly share code, notes, and snippets.

@wilsonpage
Last active March 3, 2020 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wilsonpage/3d7f636a78db66f8f1d7 to your computer and use it in GitHub Desktop.
Save wilsonpage/3d7f636a78db66f8f1d7 to your computer and use it in GitHub Desktop.
Version controlled packages in Gaia

Version controlled packages in Gaia

If you are a Gaia hacker, you have two choices when using Bower controlled packages: global or local.

Global

You can use shared/ just like any other Gaia shared piece of code. This means you always get the latest version of that package, this means that you run the risk of code changing, you're not depending on a locked version.

Updating packages in Gaia should be done/reviewed by the package owner. This is because they will have the best knowledge as to which apps are likely to be affected by the update, and whether any app changes are required to avoid breakage. The update steps, like all Bower controlled shared dependencies, are as follows:

  1. $ npm install -g bower (if you've never used Bower)
  2. $ cd shared/
  3. $ bower update <package-name>
  4. Commit all changes made by the update and submit a pull-request.

Local

Local dependency management allows you to control exactly what version of module your app depends on, giving you control over when to update. This is more stable, with the trade off of slightly more work.

If you haven't used Bower in your app before you will need to:

  1. $ npm install -g bower (if you've never used Bower)
  2. $ cd gaia/apps/my-app
  3. $ bower init

You'll notice you have a new bower.json file in your project, this file is used to define what packages your app depends on, and at exactly what versions.

Now you can install the package into your app:

$ bower install gaia-components/<package-name> --save

The package will now have been magically placed in bower_components/<package-name>. You're now free to use the contents of this package however you please.

Notice that the package has now been added to your bower.json's "dependencies" list. The # semver extension on the end of the package location identifies what version range you are prepared to accept when you choose to bower update. Removing this semver definition will mean that you will get the latest version when updating.

Make sure to check-in all new files and changes, just as if they were part of your app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment