diff --git a/lib/dependency-manager-adapters/npm.js b/lib/dependency-manager-adapters/npm.js index cc730553..3179f26a 100644 --- a/lib/dependency-manager-adapters/npm.js +++ b/lib/dependency-manager-adapters/npm.js @@ -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'); module.exports = CoreObject.extend({ init() { @@ -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}`; + } } }); }, diff --git a/package.json b/package.json index 05ba63bf..9d8b8c36 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/smoke-test-app/package-lock.json b/smoke-test-app/package-lock.json index 49f48ec3..8f518248 100644 --- a/smoke-test-app/package-lock.json +++ b/smoke-test-app/package-lock.json @@ -69,6 +69,7 @@ "fs-extra": "^6.0.1", "resolve": "^1.20.0", "rimraf": "^3.0.2", + "semver": "^7.5.4", "walk-sync": "^2.2.0" }, "devDependencies": { @@ -25966,6 +25967,7 @@ "resolve": "^1.20.0", "rimraf": "^3.0.2", "rsvp": "^4.7.0", + "semver": "^7.5.4", "tmp-sync": "^1.1.0", "walk-sync": "^2.2.0" } diff --git a/smoke-test-app/yarn.lock b/smoke-test-app/yarn.lock index 1592c566..0d2e65cc 100644 --- a/smoke-test-app/yarn.lock +++ b/smoke-test-app/yarn.lock @@ -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: diff --git a/yarn.lock b/yarn.lock index f1968f3a..82e73723 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" + send@0.17.1: version "0.17.1" resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8"