Skip to content

Commit

Permalink
dynamically add overrides if the version is a pre-release in npm
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Aug 15, 2023
1 parent 16ca894 commit 3b00c62
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/dependency-manager-adapters/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const path = require('path');
const debug = require('debug')('ember-try:dependency-manager-adapter:npm');
const rimraf = util.promisify(require('rimraf'));
const chalk = require('chalk');
const semver = require('semver')

Check failure on line 11 in lib/dependency-manager-adapters/npm.js

View workflow job for this annotation

GitHub Actions / Lint

Insert `;`

module.exports = CoreObject.extend({
init() {
Expand Down Expand Up @@ -202,6 +203,15 @@ module.exports = CoreObject.extend({
delete packageJSON[kindOfDependency][packageName];
} else {
packageJSON[kindOfDependency][packageName] = version;

// in npm we need to always add an override if the version is a pre-release
if (semver.prerelease(version) || /^https*:\/\/.*\.tg*z/.test(version)) {
if (!packageJSON.overrides) {
packageJSON.overrides = {};
}

packageJSON.overrides[packageName] = `$${packageName}`;
}
}
});
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"fs-extra": "^6.0.1",
"resolve": "^1.20.0",
"rimraf": "^3.0.2",
"semver": "^7.5.4",
"walk-sync": "^2.2.0"
},
"devDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions smoke-test-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions smoke-test-app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4195,6 +4195,7 @@ ember-try@../:
fs-extra "^6.0.1"
resolve "^1.20.0"
rimraf "^3.0.2"
semver "^7.5.4"
walk-sync "^2.2.0"

emoji-regex@^8.0.0:
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7036,6 +7036,13 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.2.0, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.5.4:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
dependencies:
lru-cache "^6.0.0"

[email protected]:
version "0.17.1"
resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8"
Expand Down

0 comments on commit 3b00c62

Please sign in to comment.