Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Prioritizes new subspace config via common/config/rush",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Rush uses this file to configure the NPM package registry during installation. It is applicable
# to PNPM, NPM, and Yarn package managers. It is used by operations such as "rush install",
# "rush update", and the "install-run.js" scripts.
#
# NOTE: The "rush publish" command uses .npmrc-publish instead.
#
# Before invoking the package manager, Rush will generate an .npmrc in the folder where installation
# is performed. This generated file will omit any config lines that reference environment variables
# that are undefined in that session; this avoids problems that would otherwise result due to
# a missing variable being replaced by an empty string.
#
# If "subspacesEnabled" is true in subspaces.json, the generated file will merge settings from
# "common/config/rush/.npmrc" and "common/config/subspaces/<name>/.npmrc", with the latter taking
# precedence.
#
# * * * SECURITY WARNING * * *
#
# It is NOT recommended to store authentication tokens in a text file on a lab machine, because
# other unrelated processes may be able to read that file. Also, the file may persist indefinitely,
# for example if the machine loses power. A safer practice is to pass the token via an
# environment variable, which can be referenced from .npmrc using ${} expansion. For example:
#
# //registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}
#
# The default subspace settings are initially ignored, so it can use common/config/rush/.npmrc.
# More information: https://rushjs.io/pages/advanced/subspaces/#feature-design
#
# registry=https://registry.npmjs.org/
# always-auth=false
8 changes: 6 additions & 2 deletions libraries/rush-lib/src/cli/actions/InitSubspaceAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class InitSubspaceAction extends BaseRushAction {
}

const subspaceConfigPath: string = `${this.rushConfiguration.commonFolder}/config/subspaces/${newSubspaceName}`;
const assetsSubfolder: string = `${assetsFolderPath}/rush-init`;
const assetsSubfolder: string = `${assetsFolderPath}/rush-init/common/config`;
const templateFilePaths: string[] = [
'[dot]npmrc',
'.pnpmfile.cjs',
Expand All @@ -70,7 +70,11 @@ export class InitSubspaceAction extends BaseRushAction {
await Async.forEachAsync(
templateFilePaths,
async (templateFilePath) => {
const sourcePath: string = `${assetsSubfolder}/common/config/rush/${templateFilePath}`;
let sourcePath: string = `${assetsSubfolder}/subspaces/${templateFilePath}`;
if (!FileSystem.exists(sourcePath)) {
sourcePath = `${assetsSubfolder}/rush/${templateFilePath}`;
}

const destinationPath: string = `${subspaceConfigPath}/${templateFilePath.replace('[dot]', '.')}`;
await copyTemplateFileAsync(sourcePath, destinationPath, true);
},
Expand Down