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

[rush] Fix the issue: "rush add" should be able to add unpublished locally-linked projects #1612

Merged
merged 22 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
64ceb69
add rush add test configuration
Claudiazhaoya Oct 25, 2019
52f1136
Merge branch 'master' of https://github.com/microsoft/rushstack into …
Claudiazhaoya Oct 25, 2019
58c5904
fix rush add issue about local packages
Claudiazhaoya Nov 1, 2019
8965326
Merge branch 'master' of https://github.com/microsoft/rushstack into …
Claudiazhaoya Nov 1, 2019
f7a1739
minor fix and add rush change file
Claudiazhaoya Nov 1, 2019
85c9c10
revert the changes made in launch.json
Claudiazhaoya Nov 1, 2019
90cfe98
fix the comment =s
Claudiazhaoya Nov 1, 2019
85c986d
revert pnpm.yaml
Claudiazhaoya Nov 2, 2019
dc32432
fix the comments
Claudiazhaoya Nov 4, 2019
186ba48
fix comments except the elaborated error message
Claudiazhaoya Nov 5, 2019
c744202
Merge branch 'master' of https://github.com/microsoft/rushstack into …
Claudiazhaoya Nov 5, 2019
62d6f1f
add elaborated error message
Claudiazhaoya Nov 5, 2019
8964b1f
fix the comments
Claudiazhaoya Nov 6, 2019
d7300a1
Merge branch 'master' of https://github.com/microsoft/rushstack into …
Claudiazhaoya Nov 6, 2019
f7cc78d
minor fixs on syntax
Claudiazhaoya Nov 7, 2019
1d4893d
minor fix on comments
Claudiazhaoya Nov 7, 2019
ea770dd
minor fix
Claudiazhaoya Nov 8, 2019
0be2e56
Merge branch 'master' into zhas/rush-add-test
iclanton Nov 11, 2019
b20d97e
Clean up some issues with the way local projects are detected and val…
iclanton Nov 11, 2019
27fae63
Fix a mistake in an error message.
iclanton Nov 11, 2019
186a28e
Simplfiy the cyclic dependency logic.
iclanton Nov 11, 2019
cd47ff6
Clean up error message.
iclanton Nov 11, 2019
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
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{
"version": "0.2.0",
"configurations": [
{
iclanton marked this conversation as resolved.
Show resolved Hide resolved
"type": "node",
"request": "launch",
"name": "rush add",
"program": "${workspaceFolder}/apps/rush-lib/lib/start.js",
"args": [
"add",
"-p",
"project-b"
],
"cwd": "C:/Users/zhas/Desktop/sp-client/apps/project-a"
},
{
"name": "Launch",
"type": "node",
Expand Down
20 changes: 15 additions & 5 deletions apps/rush-lib/src/logic/PackageJsonUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,18 +355,28 @@ export class PackageJsonUpdater {
}
console.log(`Querying NPM registry for latest version of "${packageName}"...`);
iclanton marked this conversation as resolved.
Show resolved Hide resolved

//if the project exists in the local
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
//if the project exists in the local
// determine if the package is a project in the local repository

const rushConfigProjects: RushConfigurationProject[] = this._rushConfiguration.projects;
rushConfigProjects.forEach(rushConfigProject => {
iclanton marked this conversation as resolved.
Show resolved Hide resolved
if(rushConfigProject.packageName === packageName) {
selectedVersion = rushConfigProject.packageJson.version;
Copy link
Member

Choose a reason for hiding this comment

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

You should break out of the loop here.

We also probably want to handle the case where a version is specified on the command-line and it doesn't match the version in the package.json

We also need to handle the case where the dependency that we're adding is marked as a cyclic dependency for the project in rush.json.

}
});

let commandArgs: string[];
Copy link
Member

Choose a reason for hiding this comment

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

This code should go inside the below condition.

if (this._rushConfiguration.packageManager === 'yarn') {
commandArgs = ['info', packageName, 'dist-tags.latest', '--silent'];
} else {
commandArgs = ['view', `${packageName}@latest`, 'version'];
}

selectedVersion = Utilities.executeCommandAndCaptureOutput(
this._rushConfiguration.packageManagerToolFilename,
commandArgs,
this._rushConfiguration.commonTempFolder
).trim();
if (selectedVersion === undefined) {
selectedVersion = Utilities.executeCommandAndCaptureOutput(
this._rushConfiguration.packageManagerToolFilename,
commandArgs,
this._rushConfiguration.commonTempFolder
).trim();
}

console.log();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "rush add now can add unpublished locally-linked projects",
iclanton marked this conversation as resolved.
Show resolved Hide resolved
"type": "none"
}
],
"packageName": "@microsoft/rush",
"email": "[email protected]"
}
Loading