-
Notifications
You must be signed in to change notification settings - Fork 679
[rush-lib] Abstract rush publish from npm only and introduce pluggable publish provider
#5619
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 27 commits
5dbcf9d
0683ab2
e99ba6d
89f3ba6
01c3ee6
3cb77df
13dfb42
fba09e0
f02571f
148068c
381360f
895c676
9cad3b7
b5d735d
619e8c0
732921c
18bc9aa
186aa1b
e335dca
486acea
1cbf8f7
1d80df2
aac9cc7
6c61a5f
f3b9c82
98b9c97
0d2064c
47c2319
aad8dbe
9b994ed
37c223b
55528d3
e23f38f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
TheLarkInn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "mcpServers": { | ||
| "deepwiki": { | ||
| "type": "http", | ||
| "url": "https://mcp.deepwiki.com/mcp" | ||
| } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
| // See LICENSE in the project root for license information. | ||
|
|
||
| import { ProjectConfigurationFile, InheritanceType } from '@rushstack/heft-config-file'; | ||
|
|
||
| import publishSchemaJson from '../schemas/publish.schema.json'; | ||
|
|
||
| /** | ||
| * Represents the parsed contents of a project's `config/publish.json` file. | ||
| * @public | ||
| */ | ||
| export interface IPublishJson { | ||
| /** | ||
| * An object whose keys are publish target names (e.g. 'npm', 'vsix') and whose | ||
| * values are provider-specific configuration objects. | ||
| */ | ||
| providers?: Record<string, Record<string, unknown>>; | ||
|
||
| } | ||
|
|
||
| /** | ||
| * The `ProjectConfigurationFile` instance for loading `config/publish.json` with | ||
| * rig resolution and property inheritance. | ||
| * | ||
| * @remarks | ||
| * The `providers` property uses custom inheritance: child provider sections are | ||
| * shallow-merged over parent provider sections. This means a project can override | ||
| * specific provider configs from a rig while inheriting others. | ||
| * | ||
| * @internal | ||
| */ | ||
| export const PUBLISH_CONFIGURATION_FILE: ProjectConfigurationFile<IPublishJson> = | ||
| new ProjectConfigurationFile<IPublishJson>({ | ||
| projectRelativeFilePath: 'config/publish.json', | ||
| jsonSchemaObject: publishSchemaJson, | ||
| propertyInheritance: { | ||
| providers: { | ||
| inheritanceType: InheritanceType.custom, | ||
| inheritanceFunction: ( | ||
| child: Record<string, Record<string, unknown>> | undefined, | ||
| parent: Record<string, Record<string, unknown>> | undefined | ||
| ): Record<string, Record<string, unknown>> | undefined => { | ||
| if (!child) { | ||
| return parent; | ||
| } | ||
| if (!parent) { | ||
| return child; | ||
| } | ||
| // Shallow merge: child provider sections override parent provider sections | ||
| return { ...parent, ...child }; | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ export interface IRushConfigurationProjectJson { | |
| cyclicDependencyProjects?: string[]; | ||
| versionPolicyName?: string; | ||
| shouldPublish?: boolean; | ||
| publishTarget?: string | string[]; | ||
|
||
| skipRushCheck?: boolean; | ||
| publishFolder?: string; | ||
| tags?: string[]; | ||
|
|
@@ -67,6 +68,7 @@ export interface IRushConfigurationProjectOptions { | |
| */ | ||
| export class RushConfigurationProject { | ||
| private readonly _shouldPublish: boolean; | ||
| private readonly _publishTargets: ReadonlyArray<string>; | ||
|
|
||
| private _versionPolicy: VersionPolicy | undefined = undefined; | ||
| private _dependencyProjects: Set<RushConfigurationProject> | undefined = undefined; | ||
|
|
@@ -328,10 +330,47 @@ export class RushConfigurationProject { | |
| this.skipRushCheck = !!projectJson.skipRushCheck; | ||
| this.versionPolicyName = projectJson.versionPolicyName; | ||
|
|
||
| if (this._shouldPublish && this.packageJson.private) { | ||
| // Normalize publishTarget: string -> [string], undefined -> ['npm'] | ||
| const rawTarget: string | string[] | undefined = projectJson.publishTarget; | ||
| if (rawTarget === undefined) { | ||
| this._publishTargets = ['npm']; | ||
| } else if (typeof rawTarget === 'string') { | ||
| this._publishTargets = [rawTarget]; | ||
| } else { | ||
| this._publishTargets = rawTarget; | ||
| } | ||
|
|
||
| // Validate: 'none' cannot be combined with other targets | ||
| if (this._publishTargets.includes('none') && this._publishTargets.length > 1) { | ||
|
||
| throw new Error( | ||
| `The project "${packageName}" specifies "shouldPublish": true, ` + | ||
| `but the package.json file specifies "private": true.` | ||
| `The project "${packageName}" specifies publishTarget "none" combined with other targets. ` + | ||
| `The "none" target cannot be combined with other publish targets.` | ||
| ); | ||
| } | ||
|
|
||
| // Validate: 'none' is incompatible with lockstep version policies | ||
| if ( | ||
| this._publishTargets.includes('none') && | ||
| this.versionPolicyName && | ||
| rushConfiguration.versionPolicyConfiguration | ||
| ) { | ||
| const policy: VersionPolicy | undefined = rushConfiguration.versionPolicyConfiguration.getVersionPolicy( | ||
| this.versionPolicyName | ||
| ); | ||
| if (policy && policy.isLockstepped) { | ||
| throw new Error( | ||
| `The project "${packageName}" specifies publishTarget "none" but uses the lockstep ` + | ||
| `version policy "${this.versionPolicyName}". The "none" target is incompatible with ` + | ||
| `lockstep version policies.` | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // Validate: private:true is only invalid when publishTargets includes 'npm' | ||
| if (this._shouldPublish && this.packageJson.private && this._publishTargets.includes('npm')) { | ||
| throw new Error( | ||
| `The project "${packageName}" specifies "shouldPublish": true with ` + | ||
| `publishTarget including "npm", but the package.json file specifies "private": true.` | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -482,6 +521,21 @@ export class RushConfigurationProject { | |
| return this._shouldPublish || !!this.versionPolicyName; | ||
| } | ||
|
|
||
| /** | ||
| * Specifies the publish targets for this project. Determines which publish | ||
| * provider plugins handle publishing during `rush publish`. | ||
| * | ||
| * @remarks | ||
| * Common values: `'npm'`, `'vsix'`, `'none'`. | ||
| * When the array contains `'none'`, the project participates in versioning | ||
| * but is not published by any provider. | ||
| * When omitted in rush.json, defaults to `['npm']` for backward compatibility. | ||
| * A string value is normalized to a single-element array. | ||
| */ | ||
| public get publishTargets(): ReadonlyArray<string> { | ||
|
||
| return this._publishTargets; | ||
| } | ||
|
|
||
| /** | ||
| * Version policy of the project | ||
| * @beta | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.