Skip to content

Conversation

@virkt25
Copy link
Contributor

@virkt25 virkt25 commented Dec 7, 2017

This creates a file called .loopback that allows us to store project config for future reference. Can store stuff like CLI Version, type of project, orm's being used, etc.

Storage API is used for reading / writing to config. Any class extending BaseGenerator will have access to .loopback config.

connect to #759

@virkt25 virkt25 changed the title [WIP] storing config in custom file [WIP] feat(cli): store config in custom file Dec 7, 2017
@raymondfeng
Copy link
Contributor

Please note Yeoman already has .yo-rc.json for this purpose. See http://yeoman.io/authoring/storage.html. I don't think we have to override it.

@bajtos
Copy link
Member

bajtos commented Dec 8, 2017

I don't see any obvious problems, I am ok to use a custom file name since we want to eventually move away from Yeoman anyways.

I'd personally use a file name with an extension, e.g. .loopback.json

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please discuss with Raymond what file name to use.

@raymondfeng
Copy link
Contributor

@virkt25 There are a few places in the base Yeoman generator to use .yo-rc.json as the locator to find the root of a project and exclude it from conflict checking. I don't think we have to use our custom file. Can we just stick with .yo-rc.json to avoid further overriding?

return this.config.defaults({
cliVersion: pkg.version,
lbVersion: 4,
lbVersion: 400, // 400 = 4.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep the semver and use semver to check the range compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's impossible to tell if 4110 is 4.11.0 or 4.1.10.

@virkt25 virkt25 requested a review from shimks as a code owner December 19, 2017 19:48
checkLoopBackProject() {
if (this.shouldExit()) return false;
if (this.config.get('lbVersion') >= 400) {
if (semver.gte(this.config.get('lbVersion'), '4.0.0')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused. Here is what I read: if (storedLbVersion >= '4.0.0') report error and exit. Is it intentional?

BTW, maybe we should use satisfies to check against a range.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! For some reason it worked when I ran it in a new scaffolded project.

'. ' +
'The command must be run in a LoopBack project.'
);
if (semver.satisfies(this.config.get('lbVersion'), '< 4.0.0')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs negation

Copy link
Contributor

@shimks shimks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the tests that I've written for app presence when doing artifact generation are replaced, it should LGTM. There are 6 tests failing at the moment.

@virkt25 virkt25 force-pushed the spike-prefs branch 2 times, most recently from 555d956 to 34a096b Compare January 3, 2018 20:25
@virkt25 virkt25 changed the title [WIP] feat(cli): store config in custom file feat(cli): store config in custom file Jan 3, 2018
@virkt25
Copy link
Contributor Author

virkt25 commented Jan 3, 2018

@slnode test please

@virkt25
Copy link
Contributor Author

virkt25 commented Jan 11, 2018

@raymondfeng PTAL.

semver.satisfies(version, '< 4.0.0')
) {
retErr = new Error(
'Invalid version. The command must be run in a LoopBack 4 project.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should report the offending version in the message.

'The command must be run in a LoopBack project.'
let retErr;

const version = this.config.get('lbVersion');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key is from .yo.rc.json, can we use a more obvious name such as loopback.version?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we exit if no lbVersion is found in the config file?

@bajtos
Copy link
Member

bajtos commented Jan 25, 2018

@virkt25 what's the status of this pull request? Is it still relevant? Should we close it as abandoned?

@virkt25
Copy link
Contributor Author

virkt25 commented Jan 25, 2018

Task is relevant but I've not been working on it since it's not in line with the MVP. Closing for now and will re-open when we get around to working on it.

@virkt25 virkt25 closed this Jan 25, 2018
@bajtos bajtos deleted the spike-prefs branch January 26, 2018 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants