Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buildManagerOptions config option (supports opting out of --ignore-lockfile) #409

Merged
merged 1 commit into from Nov 11, 2019

Conversation

huyphamily
Copy link
Contributor

Currently, ember-try is running yarn with the --no-lockfile option, which will install packages whose version may differ from the actual current yarn.lock file in the project. To get a true dependency environment during testing, this PR aims to add support for using the project's yarn.lock file when using ember-try by adding a config flag called useYarnLockFile that users can pass in to determine whether to use the project's yarn.lock file.

@codecov
Copy link

codecov bot commented Oct 17, 2019

Codecov Report

Merging #409 into master will increase coverage by 0.14%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #409      +/-   ##
==========================================
+ Coverage   96.72%   96.87%   +0.14%     
==========================================
  Files          17       17              
  Lines         550      576      +26     
==========================================
+ Hits          532      558      +26     
  Misses         18       18
Impacted Files Coverage Δ
lib/utils/dependency-manager-adapter-factory.js 95.45% <100%> (ø) ⬆️
lib/dependency-manager-adapters/npm.js 100% <100%> (ø) ⬆️
lib/dependency-manager-adapters/workspace.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 57d9ea2...f7dee65. Read the comment docs.

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

Instead of adding another flag, we really want a way to specify exactly what arguments to use with the package manager. I think that would allow more overall capabilities and be easier in the implementation.

Concretely, I think this would be a decent API:

// config/ember-try.js
module.exports = async function() {
  return {
    buildNpmOptions(scenarioName) {
      return []; // opt-out of defaulting `--ignore-engines --no-lockfile`
    },

    scenarios: [
    }
  };
};

Then we could structure dependency-manager-adapters/npm.js, such that in _install it would call the users function to get the final list of options.

lib/dependency-manager-adapters/npm.js Show resolved Hide resolved
lib/dependency-manager-adapters/npm.js Outdated Show resolved Hide resolved
lib/dependency-manager-adapters/npm.js Outdated Show resolved Hide resolved
@rwjblue
Copy link
Member

rwjblue commented Oct 17, 2019

I chatted with @kategengler, she suggested we use buildManagerOptions as the function name instead of my original proposal of buildNpmOptions().

@huyphamily
Copy link
Contributor Author

I see...so if someone has buildManagerOptions in their config, then we use that config instead of the default. If shrinkwrap or yarn.lock files are detected, then we back up those files and restore accordingly. I can make that change.

Copy link
Member

rwjblue commented Oct 17, 2019

Ya, exactly

if (mgrOptions.indexOf('--ignore-engines') === -1) {
mgrOptions = mgrOptions.concat(['--ignore-engines']);
} else {
if (this.useYarnCommand) {
Copy link

Choose a reason for hiding this comment

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

Do we intend to mandate the buildManagerOptions in the future? If so, we can add a deprecation here that encourages to use the manager options for these defaults.

Copy link
Member

Choose a reason for hiding this comment

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

Do we intend to mandate the buildManagerOptions in the future?

No, I believe that it will always be a "power user" option. I would expect that most users would use whatever our default command line options are, and you'd only specify buildManagerOptions if you had to deviate from that for some reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree; it is backward compatible and users do not need to use it if there isn't a need.

lib/dependency-manager-adapters/bower.js Outdated Show resolved Hide resolved
lib/dependency-manager-adapters/npm.js Show resolved Hide resolved
lib/dependency-manager-adapters/npm.js Outdated Show resolved Hide resolved
if (mgrOptions.indexOf('--ignore-engines') === -1) {
mgrOptions = mgrOptions.concat(['--ignore-engines']);
} else {
if (this.useYarnCommand) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we intend to mandate the buildManagerOptions in the future?

No, I believe that it will always be a "power user" option. I would expect that most users would use whatever our default command line options are, and you'd only specify buildManagerOptions if you had to deviate from that for some reason.

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

The code changes here look good to me, I think the only things left are documentation changes (update the README.md to include this option and explain what it does) and a review pass by @kategengler.

@huyphamily
Copy link
Contributor Author

@kategengler @rwjblue Addressed all comments and added buildManagerOptions to the readme.

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

Awesome, thank you!

@rwjblue rwjblue merged commit 0f887ba into ember-cli:master Nov 11, 2019
@rwjblue rwjblue changed the title Add support for using yarn.lock file Add buildManagerOptions config option (supports opting out of --ignore-lockfile) Nov 11, 2019
@rwjblue
Copy link
Member

rwjblue commented Nov 11, 2019

Released in v1.3.0.

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

Successfully merging this pull request may close these issues.

None yet

5 participants