-
Notifications
You must be signed in to change notification settings - Fork 607
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] Introduce a "rush add" command #843
Conversation
Fixes #820 #Resolved |
required: true, | ||
argumentName: 'PACKAGE_NAME', | ||
description: '(Required) The name of the package which should be added as a dependency' | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is clunky. How hard would it be to add an "anonymous" argument to TS-command-line? #WontFix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pete and I discussed this, but it will be a pretty big change in ts-command-line. We decided to just go with the normal way for now, then potentially change it later.
In reply to: 220407271 [](ancestors = 220407271)
parameterShortName: '-v', | ||
argumentName: 'VERSION_RANGE', | ||
description: '' | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be specified as package@version
? #WontFix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be, but requires extra parsing and whatnot. We will make it like that when we allow anonymous arguments.
In reply to: 220407345 [](ancestors = 220407345)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just split by the "@" character?
In reply to: 220751648 [](ancestors = 220751648,220749976,220743394,220407345)
description: 'If specified, the version specifier inserted into the' | ||
+ ' package.json will be a prepended with a "caret" specifier ("^").' | ||
}); | ||
this._devDependencyFlag = this.defineFlagParameter({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be just specified with the version. #ByDesign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can specify the version as "~1.2.3" or "^2.3.4"
In reply to: 220743430 [](ancestors = 220743430,220407415)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You highlighted devDependency flag.
And that isn't how --version works. It works how "npm install --save" works.
In reply to: 220750046 [](ancestors = 220750046,220743430,220407415)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So NPM has --carat and --tilde arguments? That seems really clunky.
In reply to: 220751772 [](ancestors = 220751772,220750046,220743430,220407415)
}); | ||
this._makeConsistentFlag = this.defineFlagParameter({ | ||
parameterLongName: '--make-consistent', | ||
parameterShortName: '-c', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-c [](start = 27, length = 2)
-m
? #Resolved
}); | ||
this._noInstallFlag = this.defineFlagParameter({ | ||
parameterLongName: '--no-install', | ||
parameterShortName: '-n', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-n [](start = 27, length = 2)
Is this the same as npm? #WontFix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean. NPM doesn't have an option for --skip-install or --no-install or anything.
In reply to: 220750062 [](ancestors = 220750062,220407520)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameterLongName: '--version', | ||
parameterShortName: '-v', | ||
argumentName: 'VERSION_RANGE', | ||
description: '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'' [](start = 19, length = 2)
Include a description. #Resolved
|
||
constructor(parser: RushCommandLineParser) { | ||
const documentation: string[] = [ | ||
'Blah.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blah [](start = 7, length = 4)
? #Resolved
@@ -743,6 +743,16 @@ export class RushConfiguration { | |||
return this._versionPolicyConfiguration; | |||
} | |||
|
|||
public getCurrentProjectFromPath(currentFolderPath: string): RushConfigurationProject | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getCurrentProjectFromPath [](start = 9, length = 25)
getProjectFromPath
? It doesn't necessarily need to be the current project or the current path. #Resolved
public getCurrentProjectFromPath(currentFolderPath: string): RushConfigurationProject | undefined { | ||
const resolvedPath: string = path.resolve(currentFolderPath); | ||
for (const project of this.projects) { | ||
if (path.relative(project.projectFolder, resolvedPath).indexOf('..') !== 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path.relative(project.projectFolder, resolvedPath).indexOf('..') !== 0 [](start = 10, length = 70)
use Path.isUnder
from node-core-library. #Resolved
common/reviews/api/rush-lib.api.ts
Outdated
@@ -156,6 +156,8 @@ class RushConfiguration { | |||
readonly eventHooks: EventHooks; | |||
findProjectByShorthandName(shorthandProjectName: string): RushConfigurationProject | undefined; | |||
findProjectByTempName(tempProjectName: string): RushConfigurationProject | undefined; | |||
// (undocumented) | |||
getCurrentProjectFromPath(currentFolderPath: string): RushConfigurationProject | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docs. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this the "current" project? Probably it should be getProjectForPath
?
In reply to: 220408115 [](ancestors = 220408115)
public getCurrentProjectFromPath(currentFolderPath: string): RushConfigurationProject | undefined { | ||
const resolvedPath: string = path.resolve(currentFolderPath); | ||
for (const project of this.projects) { | ||
if (path.relative(project.projectFolder, resolvedPath).indexOf('..') !== 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path.relative [](start = 10, length = 13)
Use Path.isUnder
#Resolved
[--dev] [-c] [-n] | ||
|
||
|
||
Blah. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Required) The name of the package which should be | ||
added as a dependency | ||
-v VERSION_RANGE, --version VERSION_RANGE | ||
--exact If specified, the version specifier inserted into the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inserted into [](start = 59, length = 14)
"SemVer specifier added to" #Resolved
-c, --make-consistent | ||
If specified, other packages with this dependency | ||
will have their package.json files updated to point | ||
at the specified depdendency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specify the same SemVer range? #Resolved
If specified, other packages with this dependency | ||
will have their package.json files updated to point | ||
at the specified depdendency | ||
-n, --no-install If specified, the \\"rush update\\" command will not be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no-install [](start = 8, length = 10)
--skip-update? #Resolved
import { PurgeManager } from './PurgeManager'; | ||
import { Utilities } from '../utilities/Utilities'; | ||
|
||
export const enum SemVerStyle { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export [](start = 0, length = 6)
Add docs in this file #Resolved
@@ -0,0 +1,219 @@ | |||
import * as semver from 'semver'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import [](start = 0, length = 7)
copyright banner #Resolved
* Returns the project for which the specified path is underneath that project's folder. | ||
* If the path is not under any project's folder, returns undefined. | ||
*/ | ||
public getProjectForPath(currentFolderPath: string): RushConfigurationProject | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tryGet? #Resolved
*/ | ||
public get packageJson(): IPackageJson { | ||
return this._packageJson; | ||
} | ||
|
||
/** | ||
* A useful wrapper around the package.json file for making modifications | ||
* @alpha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@beta -- we don't use alpha in WBT #Resolved
@@ -172,11 +176,20 @@ export class RushConfigurationProject { | |||
|
|||
/** | |||
* The parsed NPM "package.json" file from projectFolder. | |||
* Will be deprecated soon in favor of packageJsonEditor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will [](start = 5, length = 4)
@deprecated Use packageJsonEditor instead
#Resolved
|
||
|
||
Adds a dependency on a certain package to the current project (detected using | ||
the current working directory) and then runs rush update. If no version is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rush update [](start = 45, length = 11)
"rush update" #Resolved
latest version or a version that won't break the ensureConsistentVersions | ||
policy). If a version range is specified, the latest version in the range | ||
will be used. The version will be automatically prepended with a tilde, | ||
unless the --exact or --caret flags are used. The --make-consistent flag can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--exact [](start = 11, length = 7)
"--exact" #Resolved
package.json will be a prepended with a \\"caret\\" | ||
specifier (\\"^\\"). | ||
-d, --dev If specified, the package will be added as a | ||
\\"devDependency\\" to the package.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\"devDependency\" to the package.json [](start = 23, length = 40)
to the package.json "devDependencies" section
#Resolved
common/reviews/api/rush-lib.api.ts
Outdated
@@ -202,6 +203,9 @@ class RushConfigurationProject { | |||
// @beta | |||
readonly isMainProject: boolean; | |||
readonly packageJson: IPackageJson; | |||
// WARNING: The type "PackageJsonEditor" needs to be exported by the package (e.g. added to index.ts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PackageJsonEditor [](start = 24, length = 17)
Fix this warning #Resolved
if (mismatches.length) { | ||
if (!updateOtherPackages) { | ||
return Promise.reject(new Error(`Adding '${packageName}@${version}' to ${currentProject.packageName}` | ||
+ ` causes mismatched dependencies. Use the --make-consistent flag to update other packages to use this` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--make-consistent [](start = 56, length = 17)
"--make-consistent"
#Resolved
b593dc7
to
ee299b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…build-tools into nickpape/rush-add
Introduces a
rush add
command which can change dependencies.--package/-p
--version
), the newest version that satisfies the range will be selected.~
by default. If--caret
is used, then it will be prepended with^
. If--exact
is specified, nothing will be prepended.--make-consistent
flag must be used if the new version introduces a version mismatch andthe ensureConsistentVersions policy is active.
rush update
will be run after the command unless--no-install
is specified.