-
Notifications
You must be signed in to change notification settings - Fork 631
[rush-lib] Supports the rush install-autoinstaller command #4823
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
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
bf0842c
feat: support install-autoinstaller
L-Qun 0471873
rush change
L-Qun 07854ba
fix: ci
L-Qun fe24372
chore: export type
L-Qun f3e6ac3
chore: update md
L-Qun 120c0b8
Update libraries/rush-lib/src/cli/actions/InstallAutoinstallerAction.ts
L-Qun 52bebb9
Update common/changes/@microsoft/rush/feat-install-autoinstaller_2024…
L-Qun 375b692
chore: use terminal instead of console
L-Qun 4e48335
update snapshot
L-Qun d7b70ad
chore: a
L-Qun d4cff21
feat: abstract the BaseAutoinstallerAction class
L-Qun 07e75db
chore: modify the desc
L-Qun d8287fc
chore: remove useless params
L-Qun db3105b
chore: update snapshot
L-Qun 1644e74
chore: resolve comments
L-Qun c7828c6
fix: lint
L-Qun 4eb62e3
fix: ci
L-Qun a41f265
Update libraries/rush-lib/src/cli/actions/BaseAutoinstallerAction.ts
L-Qun 7eedfa6
chore: remove useless exports
L-Qun 01a34d5
Update libraries/rush-lib/src/logic/Autoinstaller.ts
iclanton 0a6b8be
Update libraries/rush-lib/src/logic/Autoinstaller.ts
iclanton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
common/changes/@microsoft/rush/feat-install-autoinstaller_2024-07-04-13-25.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@microsoft/rush", | ||
"comment": "Add a new `rush install-autoinstaller` command that ensures that the specified autoinstaller is installed.", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "@microsoft/rush" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
libraries/rush-lib/src/cli/actions/BaseAutoinstallerAction.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See LICENSE in the project root for license information. | ||
|
||
import type { IRequiredCommandLineStringParameter } from '@rushstack/ts-command-line'; | ||
import type { ITerminal } from '@rushstack/terminal'; | ||
|
||
import { BaseRushAction, type IBaseRushActionOptions } from './BaseRushAction'; | ||
import { Autoinstaller } from '../../logic/Autoinstaller'; | ||
|
||
export abstract class BaseAutoinstallerAction extends BaseRushAction { | ||
protected readonly _name: IRequiredCommandLineStringParameter; | ||
protected readonly _terminal: ITerminal; | ||
|
||
public constructor(options: IBaseRushActionOptions) { | ||
super(options); | ||
|
||
this._name = this.defineStringParameter({ | ||
parameterLongName: '--name', | ||
argumentName: 'AUTOINSTALLER_NAME', | ||
required: true, | ||
description: | ||
'The name of the autoinstaller, which must be one of the folders under common/autoinstallers.' | ||
}); | ||
|
||
this._terminal = this.parser.terminal; | ||
} | ||
|
||
protected abstract prepareAsync(autoinstaller: Autoinstaller): Promise<void>; | ||
|
||
protected async runAsync(): Promise<void> { | ||
const autoinstallerName: string = this._name.value; | ||
const autoinstaller: Autoinstaller = new Autoinstaller({ | ||
autoinstallerName, | ||
rushConfiguration: this.rushConfiguration, | ||
rushGlobalFolder: this.rushGlobalFolder | ||
}); | ||
|
||
await this.prepareAsync(autoinstaller); | ||
|
||
this._terminal.writeLine(); | ||
this._terminal.writeLine('Success.'); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
libraries/rush-lib/src/cli/actions/InstallAutoinstallerAction.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See LICENSE in the project root for license information. | ||
|
||
import type { Autoinstaller } from '../../logic/Autoinstaller'; | ||
import type { RushCommandLineParser } from '../RushCommandLineParser'; | ||
import { BaseAutoinstallerAction } from './BaseAutoinstallerAction'; | ||
|
||
export class InstallAutoinstallerAction extends BaseAutoinstallerAction { | ||
public constructor(parser: RushCommandLineParser) { | ||
super({ | ||
actionName: 'install-autoinstaller', | ||
summary: 'Install autoinstaller package dependencies', | ||
documentation: 'Use this command to install dependencies for an autoinstaller folder.', | ||
parser | ||
}); | ||
} | ||
|
||
protected async prepareAsync(autoinstaller: Autoinstaller): Promise<void> { | ||
await autoinstaller.prepareAsync(); | ||
} | ||
} |
31 changes: 4 additions & 27 deletions
31
libraries/rush-lib/src/cli/actions/UpdateAutoinstallerAction.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See LICENSE in the project root for license information. | ||
|
||
import type { IRequiredCommandLineStringParameter } from '@rushstack/ts-command-line'; | ||
|
||
import { BaseRushAction } from './BaseRushAction'; | ||
import type { RushCommandLineParser } from '../RushCommandLineParser'; | ||
import { Autoinstaller } from '../../logic/Autoinstaller'; | ||
|
||
export class UpdateAutoinstallerAction extends BaseRushAction { | ||
private readonly _name: IRequiredCommandLineStringParameter; | ||
import type { Autoinstaller } from '../../logic/Autoinstaller'; | ||
import { BaseAutoinstallerAction } from './BaseAutoinstallerAction'; | ||
|
||
export class UpdateAutoinstallerAction extends BaseAutoinstallerAction { | ||
public constructor(parser: RushCommandLineParser) { | ||
super({ | ||
actionName: 'update-autoinstaller', | ||
summary: 'Updates autoinstaller package dependencies', | ||
documentation: 'Use this command to regenerate the shrinkwrap file for an autoinstaller folder.', | ||
parser | ||
}); | ||
|
||
this._name = this.defineStringParameter({ | ||
parameterLongName: '--name', | ||
argumentName: 'AUTOINSTALLER_NAME', | ||
required: true, | ||
description: | ||
'Specifies the name of the autoinstaller, which must be one of the folders under common/autoinstallers.' | ||
}); | ||
} | ||
|
||
protected async runAsync(): Promise<void> { | ||
const autoinstallerName: string = this._name.value; | ||
const autoinstaller: Autoinstaller = new Autoinstaller({ | ||
autoinstallerName, | ||
rushConfiguration: this.rushConfiguration, | ||
rushGlobalFolder: this.rushGlobalFolder | ||
}); | ||
|
||
protected async prepareAsync(autoinstaller: Autoinstaller): Promise<void> { | ||
// Do not run `autoinstaller.prepareAsync` here. It tries to install the autoinstaller with | ||
// --frozen-lockfile or equivalent, which will fail if the autoinstaller's dependencies | ||
// have been changed. | ||
|
||
await autoinstaller.updateAsync(); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log('\nSuccess.'); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.