How to properly update the library parts
Asked Answered
A

1

5

I started a fresh CLI project a few weeks ago which installed the CLI in v0.24.0 & the framework in v1.0.8.

Since they released some updates this week (CLI v0.26.0, Framework v1.1.0, ...) I'm wondering how to properly update the core components.

I have the following aurelia dependencies within my package.json:

{
  // ...
  "dependencies": {
    "aurelia-animator-css": "^1.0.0",
    "aurelia-api": "^3.1.1",
    "aurelia-authentication": "^3.2.0",
    "aurelia-bootstrapper": "^1.0.0",
    "aurelia-fetch-client": "^1.1.0",
    // ...
  },
  "devDependencies": {
    "aurelia-cli": "^0.24.0",
    "aurelia-testing": "^1.0.0-beta.2.0.0",
    "aurelia-tools": "^0.2.2",
    // ...
  },
  // ...
}

The following of those packages are outdated compared to latest releases on NPM:

  • aurelia-cli 0.24.0, latest 0.26.0
  • aurelia-animator-css 1.0.0, latest 1.0.1
  • aurelia-bootstrapper 1.0.0, latest 2.1.0
  • aurelia-fetch-client 1.1.0, latest 1.1.1
  • aurelia-testing ^1.0.0-beta.2.0.0, latest ^1.0.0-beta.3.0.0
  • aurelia-tools 0.2.2, latest 1.0.0

Since all of those packages use the caret version range, most of them won't update to the latest version automatically when running npm update.

Here are my questions

  1. Do I have to manually update the version of each mentioned package within my package.json when I'd like to bring the framework to the latest state? (Seems obvious)
    • I know that I could use something like tilde or x ranges within package.json but this is not exactly what I'm looking for since I'd like to explicitly allow new versions to be installed to ensure that other devs or the build server won't work with completely different versions...
  2. Is there some streamlined process of finding out the latest version numbers of each framework package I use or do I have to manually "crawl" the versions from npm.org as I did when writing this question?
  3. The aurelia-framework package is not mentioned anywhere within my package.json file and it's not automatically updating by running npm update. How do I actually update it?
Athodyd answered 5/3, 2017 at 11:6 Comment(0)
B
7

The documentation for the CLI says to add a NPM script that you can run to update then all to the latest version:

https://github.com/aurelia/framework/blob/master/doc/article/en-US/the-aurelia-cli.md#updating-multiple-libraries.

Which would mean adding something like this to your package.json scripts section:

    "au-update": "npm i aurelia-binding@latest aurelia-bootstrapper@latest aurelia-dependency-injection@latest aurelia-event-aggregator@latest aurelia-framework@latest aurelia-history@latest aurelia-history-browser@latest aurelia-loader@latest aurelia-loader-default@latest aurelia-logging@latest aurelia-logging-console@latest aurelia-metadata@latest aurelia-pal@latest aurelia-pal-browser@latest aurelia-path@latest aurelia-polyfills@latest aurelia-route-recognizer@latest aurelia-router@latest aurelia-task-queue@latest aurelia-templating@latest aurelia-templating-binding@latest aurelia-templating-resources@latest aurelia-templating-router@latest aurelia-testing@latest aurelia-dialog@latest -S",

The first time you upgrade it will add references in your package.json to them, so the dependencies section get's a lot bigger/ adds all those missing nested dependencies.

Another way is to use a NPM package that performs these checks for all your packages npm check updates also the non-Aurelia ones.

Which allows you to do:

ncu

to check which packages are outdated, and

ncu -u

to upgrade them all to the latest version ignoring the semver restrictions.

Barnard answered 5/3, 2017 at 15:43 Comment(5)
Great answer! :-)Gorgon
Haven't seen that part about updates since it's only on the GitHub pages but not in the docs hubs...Athodyd
One more question: Why aren't all dependencies which are listed in aurelia.json also in the package.json when creating a new project using the CLI when they need to be added sometime down the road anyhow?Athodyd
Not sure why. If you are in a completely empty project you could just install aurelia-bootstrapper and get going, instead of installing all the separate packages, because it has dependencies on most of them. The same dependency on bootstrapper is used in a project generated by the CLI. As far as I understand npm update will only update the dependencies listed in your dependencies section and update them according to the specified semver range. It can be overridden with an option (to also update child dependencies), but that looks risky.Barnard
My guess would be that you could also reinstall aurelia-bootstrapper@latest and then you get the latest according to the semver of the dependencies in that package.json, which might not be the actual latest, because it could be that yesterday a new version of aurelia-x was released, but the new version of aurelia-bootstrapper that depends on that specific version of aurelia-x isn't released yet. But the above could be incorrect information, this is just my guessBarnard

© 2022 - 2024 — McMap. All rights reserved.