Skip to content

Support for canary versions from lerna #213

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

Merged
merged 3 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions integration-tests/lerna-canary/lerna-canary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# make sure errors stop the script
set -e

echo "add patch-package"
yarn add $1

echo "Add @parcel/codeframe"
yarn add @parcel/[email protected]

echo "replace codeframe with yarn in @parcel/codefram/src/codeframe.js"
npx replace codeframe yarn node_modules/@parcel/codeframe/src/codeframe.js

echo "SNAPSHOT: making patch"
npx patch-package @parcel/codeframe
echo "END SNAPSHOT"

echo "SNAPSHOT: the patch looks like this"
cat patches/@parcel/codeframe+2.0.0-nightly.137.patch
echo "END SNAPSHOT"

echo "reinstall node_modules"
npx rimraf node_modules
yarn

echo "patch-package didn't run"
if grep yarn node_modules/@parcel/codeframe/src/codeframe.js ; then
exit 1
fi

echo "add patch-package to postinstall hook"
node ./add-postinstall.js

echo "reinstall node_modules"
npx rimraf node_modules
yarn

echo "patch-package did run"
grep yarn node_modules/@parcel/codeframe/src/codeframe.js
2 changes: 2 additions & 0 deletions integration-tests/lerna-canary/lerna-canary.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { runIntegrationTest } from "../runIntegrationTest"
runIntegrationTest({projectName: "lerna-canary", shouldProduceSnapshots: false})
9 changes: 9 additions & 0 deletions integration-tests/lerna-canary/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "lerna-canary",
"version": "1.0.0",
"description": "integration test for patch-package",
"main": "index.js",
"author": "",
"license": "ISC",
"dependencies": {}
}
4 changes: 4 additions & 0 deletions integration-tests/lerna-canary/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


4 changes: 3 additions & 1 deletion src/getPackageResolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ export function getPackageResolution({
throw new Error("Can't parse lock file")
}

const installedVersion = require(join(
const installedVersionLong = require(join(
resolve(appPath, packageDetails.path),
"package.json",
)).version as string
const indexOfPlus = installedVersionLong.indexOf('+');
const installedVersion = indexOfPlus === -1 ? installedVersionLong : installedVersionLong.substring(0, indexOfPlus)

const entries = Object.entries(appLockFile.object).filter(
([k, v]) =>
Expand Down