yeoman / configstore

Easily load and persist config without having to think about where and how
BSD 2-Clause "Simplified" License
868 stars 56 forks source link

Recommended upgrade path? #23

Closed jescalan closed 9 years ago

jescalan commented 9 years ago

Appreciate the note about the breaking change in 1.x -- do you have a recommended upgrade path for moving towards 1.x and above? Is it just a matter of digging up the existing yaml file and converting it to json?

Just curious if you have a recommended way to upgrade, since it seems like it shouldn't be too tough and I'm sure people want to do it :grinning:

sindresorhus commented 9 years ago

Yeah, that's why we chose to do it in a major. If you care about what's saved there's no reason for you to upgrade. The upgrade is mostly just for new users. You could always check if it's YAML and convert it, but I didn't want to deal with such complexity, and which would have to stay in the codebase forever. Think of 2.0.0 as a new module.

jescalan commented 9 years ago

Sure, I understand. I was just curious if you had a recommended chunk of code to do this that could be implemented outside the module by users so they can stay on the latest version. But if I'm reading this right, you're saying that ^0.3.x and ^1.0.0 will remain the same in functionality and patches until 2.x, so it doesn't matter and there's no need to upgrade?

sindresorhus commented 9 years ago

Some quick untested example code:

var fs = require('fs');
var pathExists = require('path-exists');
var Configstore = require('configstore');
var YAML = require('some-yaml-module');
var c = new Configstore('your-id');
var ymlPath = c.path.replace(/json$/, 'yml');

if (pathExists.sync(ymlPath)) {
  c.all = YAML.parse(fs.readFileSync(c.path));
  fs.unlinkSync(ymlPath);
}

But if I'm reading this right, you're saying that ^0.3.x and ^1.0.0 will remain the same in functionality and patches until 2.x, so it doesn't matter and there's no need to upgrade?

I'm saying 1.0.0 is very stable and will continue to work perfectly. However it's not going to get any more updates.