Skip to content

Commit 2e296d8

Browse files
L-Qunoctogonz
andauthored
[rush] New commands "rush link-package" and "rush bridge-package" (#5123)
* fix: ci * chore: add lockfileid field * chore: optimize logic * fix: rush-link-state.json * feat: disable cache * fix: ci * fix: use version parameter * fix: ci * fix: use semver to verify version * Improve CLI docs and add EXPERIMENTAL notices * replace BaseConnectPackageAction with BaseSymlinkPackageAction --------- Co-authored-by: Pete Gonzalez <4673363+octogonz@users.noreply.github.com>
1 parent 7e5d753 commit 2e296d8

18 files changed

Lines changed: 819 additions & 27 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "(EXPERIMENTAL) Add new commands `rush link-package` and `rush bridge-package`",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush"
10+
}

common/config/subspaces/build-tests-subspace/pnpm-lock.yaml

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
22
{
3-
"pnpmShrinkwrapHash": "b48c35b584583839e5d4a9e651d78a779d206b2e",
3+
"pnpmShrinkwrapHash": "716e6139e542e55da15871cb4113731bf70cf760",
44
"preferredVersionsHash": "54149ea3f01558a859c96dee2052b797d4defe68",
5-
"packageJsonInjectedDependenciesHash": "a8af9805efae30377fcf83e1a927721f67381aee"
5+
"packageJsonInjectedDependenciesHash": "eddee15297dd4196faa2367de41611da04489b5b"
66
}

common/config/subspaces/default/pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
22
{
3-
"pnpmShrinkwrapHash": "0ca686868eb1f0b230c0067e17c8e408fc3eafd4",
3+
"pnpmShrinkwrapHash": "1091197f5a37dd2e4f7446671c2f57d872d06340",
44
"preferredVersionsHash": "54149ea3f01558a859c96dee2052b797d4defe68"
55
}

common/reviews/api/rush-lib.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ export class RushConstants {
13721372
// @deprecated
13731373
static readonly pinnedVersionsFilename: 'pinned-versions.json';
13741374
static readonly pnpmConfigFilename: 'pnpm-config.json';
1375+
static readonly pnpmDependenciesFolderName: '.pnpm';
13751376
static readonly pnpmfileGlobalFilename: 'global-pnpmfile.cjs';
13761377
static readonly pnpmfileV1Filename: 'pnpmfile.js';
13771378
static readonly pnpmfileV6Filename: '.pnpmfile.cjs';
@@ -1386,6 +1387,7 @@ export class RushConstants {
13861387
static readonly repoStateFilename: 'repo-state.json';
13871388
static readonly rushAlertsConfigFilename: 'rush-alerts.json';
13881389
static readonly rushJsonFilename: 'rush.json';
1390+
static readonly rushLinkStateFilename: 'rush-link-state.json';
13891391
static readonly rushLogsFolderName: 'rush-logs';
13901392
static readonly rushPackageName: '@microsoft/rush';
13911393
static readonly rushPluginManifestFilename: 'rush-plugin-manifest.json';

libraries/rush-lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"tar": "~6.2.1",
6565
"true-case-path": "~2.2.1",
6666
"uuid": "~8.3.2",
67-
"pnpm-sync-lib": "0.2.9"
67+
"pnpm-sync-lib": "0.3.0"
6868
},
6969
"devDependencies": {
7070
"@pnpm/lockfile.types": "~1.0.3",

libraries/rush-lib/src/api/RushProjectConfiguration.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import type { IPhase } from './CommandLineConfiguration';
1212
import { OverlappingPathAnalyzer } from '../utilities/OverlappingPathAnalyzer';
1313
import schemaJson from '../schemas/rush-project.schema.json';
1414
import anythingSchemaJson from '../schemas/rush-project.schema.json';
15+
import { RushConnect } from '../utilities/RushConnect';
16+
import type { RushConfiguration } from './RushConfiguration';
1517

1618
/**
1719
* Describes the file structure for the `<project root>/config/rush-project.json` config file.
@@ -345,6 +347,15 @@ export class RushProjectConfiguration {
345347
phaseName: string,
346348
isNoOp: boolean
347349
): string | undefined {
350+
const rushConfiguration: RushConfiguration | undefined = this.project.rushConfiguration;
351+
if (rushConfiguration) {
352+
const rushConnect: RushConnect = RushConnect.loadFromLinkStateFile(rushConfiguration);
353+
const subspaceNameList: string[] = Object.keys(rushConnect.rushLinkState ?? {});
354+
if (subspaceNameList.includes(this.project.subspace.subspaceName)) {
355+
return 'Caching has been disabled for this project because it is a linked package.';
356+
}
357+
}
358+
348359
// Skip no-op operations as they won't have any output/cacheable things.
349360
if (isNoOp) {
350361
return undefined;

libraries/rush-lib/src/api/test/__snapshots__/RushCommandLine.test.ts.snap

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,56 @@ Object {
11371137
},
11381138
],
11391139
},
1140+
Object {
1141+
"actionName": "bridge-package",
1142+
"parameters": Array [
1143+
Object {
1144+
"description": "The folder path of a locally built project, whose installation will be simulated using node_modules symlinks. This folder will be the target of the symlinks.",
1145+
"environmentVariable": undefined,
1146+
"kind": "String",
1147+
"longName": "--path",
1148+
"required": true,
1149+
"shortName": undefined,
1150+
},
1151+
Object {
1152+
"description": "A list of Rush project names to connect to the external package. If not specified, uses the project in the current working directory.",
1153+
"environmentVariable": undefined,
1154+
"kind": "StringList",
1155+
"longName": "--project",
1156+
"required": false,
1157+
"shortName": undefined,
1158+
},
1159+
Object {
1160+
"description": "It will directly replace the output for the specified version of the package, which requires you to have that package installed under the specified name in advance.",
1161+
"environmentVariable": undefined,
1162+
"kind": "String",
1163+
"longName": "--version",
1164+
"required": false,
1165+
"shortName": undefined,
1166+
},
1167+
],
1168+
},
1169+
Object {
1170+
"actionName": "link-package",
1171+
"parameters": Array [
1172+
Object {
1173+
"description": "The folder path of a locally built project, whose installation will be simulated using node_modules symlinks. This folder will be the target of the symlinks.",
1174+
"environmentVariable": undefined,
1175+
"kind": "String",
1176+
"longName": "--path",
1177+
"required": true,
1178+
"shortName": undefined,
1179+
},
1180+
Object {
1181+
"description": "A list of Rush project names to connect to the external package. If not specified, uses the project in the current working directory.",
1182+
"environmentVariable": undefined,
1183+
"kind": "StringList",
1184+
"longName": "--project",
1185+
"required": false,
1186+
"shortName": undefined,
1187+
},
1188+
],
1189+
},
11401190
Object {
11411191
"actionName": "import-strings",
11421192
"parameters": Array [

libraries/rush-lib/src/cli/RushCommandLineParser.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ import type { IBuiltInPluginConfiguration } from '../pluginFramework/PluginLoade
6262
import { InitSubspaceAction } from './actions/InitSubspaceAction';
6363
import { RushAlerts } from '../utilities/RushAlerts';
6464
import { InstallAutoinstallerAction } from './actions/InstallAutoinstallerAction';
65+
import { LinkPackageAction } from './actions/LinkPackageAction';
66+
import { BridgePackageAction } from './actions/BridgePackageAction';
6567

6668
/**
6769
* Options for `RushCommandLineParser`.
@@ -331,6 +333,8 @@ export class RushCommandLineParser extends CommandLineParser {
331333
this.addAction(new UpgradeInteractiveAction(this));
332334
this.addAction(new VersionAction(this));
333335
this.addAction(new AlertAction(this));
336+
this.addAction(new BridgePackageAction(this));
337+
this.addAction(new LinkPackageAction(this));
334338

335339
this._populateScriptActions();
336340
} catch (error) {

0 commit comments

Comments
 (0)