-
Notifications
You must be signed in to change notification settings - Fork 653
[rush-lib] support users to provide their own assets file for init subspace #5134
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
a8edb30
b9e9100
30413bd
ccbaf8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@microsoft/rush", | ||
| "comment": "suport users to provide their own assets when init a new subspace instead of always using the default one", | ||
| "type": "none" | ||
| } | ||
| ], | ||
| "packageName": "@microsoft/rush" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,11 @@ | |
| */ | ||
| "subspacesEnabled": false, | ||
|
|
||
| /** | ||
| * the starting assets folder relative to rush.json location you want to use when init a subspace | ||
| */ | ||
| // "subspaceInitAssetsFolder": "", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this design, it seems that a given monorepo can have at most one set of custom file templates to use with We could instead designate a standard location, e.g.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, thanks! I’ll update it accordingly.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or maybe |
||
|
|
||
| /** | ||
| * (DEPRECATED) This is a temporary workaround for migrating from an earlier prototype | ||
| * of this feature: https://github.com/microsoft/rushstack/pull/3481 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import { type ISubspacesConfigurationJson, SubspacesConfiguration } from '../../ | |
| import { Async, FileSystem, JsonFile } from '@rushstack/node-core-library'; | ||
| import { ConsoleTerminalProvider, Terminal } from '@rushstack/terminal'; | ||
| import { copyTemplateFileAsync } from '../../utilities/templateUtilities'; | ||
| import * as path from 'path'; | ||
|
|
||
| export class InitSubspaceAction extends BaseRushAction { | ||
| private readonly _subspaceNameParameter: IRequiredCommandLineStringParameter; | ||
|
|
@@ -58,7 +59,10 @@ export class InitSubspaceAction extends BaseRushAction { | |
| } | ||
|
|
||
| const subspaceConfigPath: string = `${this.rushConfiguration.commonFolder}/config/subspaces/${newSubspaceName}`; | ||
| const assetsSubfolder: string = `${assetsFolderPath}/rush-init`; | ||
| const defaultAssetsSubfolder: string = `${assetsFolderPath}/rush-init`; | ||
| const userDefinedAssetsFolder: string | undefined = subspacesConfiguration.subspaceInitAssetsFolder | ||
| ? path.join(this.rushConfiguration.rushJsonFolder, subspacesConfiguration.subspaceInitAssetsFolder) | ||
jzhang026 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| : undefined; | ||
| const templateFilePaths: string[] = [ | ||
| '[dot]npmrc', | ||
| '.pnpmfile.cjs', | ||
|
|
@@ -70,9 +74,14 @@ export class InitSubspaceAction extends BaseRushAction { | |
| await Async.forEachAsync( | ||
| templateFilePaths, | ||
| async (templateFilePath) => { | ||
| const sourcePath: string = `${assetsSubfolder}/common/config/rush/${templateFilePath}`; | ||
| const defaultAssetSourcePath: string = `${defaultAssetsSubfolder}/common/config/rush/${templateFilePath}`; | ||
| const destinationPath: string = `${subspaceConfigPath}/${templateFilePath.replace('[dot]', '.')}`; | ||
| await copyTemplateFileAsync(sourcePath, destinationPath, true); | ||
| await copyTemplateFileAsync(defaultAssetSourcePath, destinationPath, true); | ||
| if (userDefinedAssetsFolder) { | ||
| // if user provided their own assets file for subspace initiation | ||
| // we just copy and overwrite the default files | ||
| await copyTemplateFileAsync(userDefinedAssetsFolder, destinationPath, true); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This approach seems like it will (1) try to copy a file that doesn't exist and (2) print a notice like Both issues could be avoided using
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, Please fill out the How it was tested PR notes 😸 |
||
| } | ||
| }, | ||
| { concurrency: 10 } | ||
| ); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.