Skip to content

Commit 8260629

Browse files
committed
Revert "Update various projects to use IPackageJsonWithVersion where appropriate"
This reverts commit da284eb.
1 parent 6035e05 commit 8260629

File tree

14 files changed

+63
-77
lines changed

14 files changed

+63
-77
lines changed

apps/api-extractor-model/src/model/ApiPackage.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33

44
import { ApiItem, ApiItemKind, IApiItemJson } from '../items/ApiItem';
55
import { ApiItemContainerMixin, IApiItemContainerMixinOptions } from '../mixins/ApiItemContainerMixin';
6-
import {
7-
JsonFile,
8-
IJsonFileSaveOptions,
9-
PackageJsonLookup,
10-
IPackageJsonWithVersion
11-
} from '@microsoft/node-core-library';
6+
import { JsonFile, IJsonFileSaveOptions, PackageJsonLookup, IPackageJson } from '@microsoft/node-core-library';
127
import { ApiDocumentedItem, IApiDocumentedItemOptions } from '../items/ApiDocumentedItem';
138
import { ApiEntryPoint } from './ApiEntryPoint';
149
import { IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin';
@@ -128,7 +123,7 @@ export class ApiPackage extends ApiItemContainerMixin(ApiNameMixin(ApiDocumented
128123
options = {};
129124
}
130125

131-
const packageJson: IPackageJsonWithVersion = PackageJsonLookup.loadOwnPackageJson(__dirname);
126+
const packageJson: IPackageJson = PackageJsonLookup.loadOwnPackageJson(__dirname);
132127

133128
const jsonObject: IApiPackageJson = {
134129
metadata: {

apps/rush-lib/src/api/PackageJsonEditor.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import * as semver from 'semver';
55

66
import {
7-
IPackageJsonWithVersion,
7+
IPackageJson,
88
JsonFile,
99
Sort
1010
} from '@microsoft/node-core-library';
@@ -64,7 +64,7 @@ export class PackageJsonDependency {
6464
*/
6565
export class PackageJsonEditor {
6666
private readonly _filePath: string;
67-
private readonly _data: IPackageJsonWithVersion;
67+
private readonly _data: IPackageJson;
6868
private readonly _dependencies: Map<string, PackageJsonDependency>;
6969

7070
// NOTE: The "devDependencies" section is tracked separately because sometimes people
@@ -78,7 +78,7 @@ export class PackageJsonEditor {
7878
return new PackageJsonEditor(filePath, JsonFile.load(filePath));
7979
}
8080

81-
public static fromObject(object: IPackageJsonWithVersion, filename: string): PackageJsonEditor {
81+
public static fromObject(object: IPackageJson, filename: string): PackageJsonEditor {
8282
return new PackageJsonEditor(filename, object);
8383
}
8484

@@ -137,7 +137,7 @@ export class PackageJsonEditor {
137137
return false;
138138
}
139139

140-
private constructor(filepath: string, data: IPackageJsonWithVersion) {
140+
private constructor(filepath: string, data: IPackageJson) {
141141
this._filePath = filepath;
142142
this._data = data;
143143
this._modified = false;
@@ -200,7 +200,7 @@ export class PackageJsonEditor {
200200
this._modified = true;
201201
}
202202

203-
private _normalize(): IPackageJsonWithVersion {
203+
private _normalize(): IPackageJson {
204204
delete this._data.dependencies;
205205
delete this._data.optionalDependencies;
206206
delete this._data.peerDependencies;

apps/rush-lib/src/api/RushConfigurationProject.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import * as path from 'path';
55
import {
66
JsonFile,
7+
IPackageJson,
78
PackageName,
89
FileSystem,
9-
FileConstants,
10-
IPackageJsonWithVersion
10+
FileConstants
1111
} from '@microsoft/node-core-library';
1212

1313
import { RushConfiguration } from '../api/RushConfiguration';
@@ -37,7 +37,7 @@ export class RushConfigurationProject {
3737
private _projectFolder: string;
3838
private _projectRelativeFolder: string;
3939
private _reviewCategory: string;
40-
private _packageJson: IPackageJsonWithVersion;
40+
private _packageJson: IPackageJson;
4141
private _packageJsonEditor: PackageJsonEditor;
4242
private _tempProjectName: string;
4343
private _unscopedTempProjectName: string;
@@ -178,7 +178,7 @@ export class RushConfigurationProject {
178178
* The parsed NPM "package.json" file from projectFolder.
179179
* @deprecated Use packageJsonEditor instead
180180
*/
181-
public get packageJson(): IPackageJsonWithVersion {
181+
public get packageJson(): IPackageJson {
182182
return this._packageJson;
183183
}
184184

apps/rush-lib/src/api/VersionPolicy.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { cloneDeep } from 'lodash';
55
import * as semver from 'semver';
6-
import { IPackageJsonWithVersion } from '@microsoft/node-core-library';
6+
import { IPackageJson } from '@microsoft/node-core-library';
77

88
import {
99
IVersionPolicyJson,
@@ -113,7 +113,7 @@ export abstract class VersionPolicy {
113113
* @param project - package json
114114
* @param force - force update even when the project version is higher than the policy version.
115115
*/
116-
public abstract ensure(project: IPackageJsonWithVersion, force?: boolean): IPackageJsonWithVersion | undefined;
116+
public abstract ensure(project: IPackageJson, force?: boolean): IPackageJson | undefined;
117117

118118
/**
119119
* Bumps version based on the policy
@@ -256,7 +256,7 @@ export class LockStepVersionPolicy extends VersionPolicy {
256256
* @param project - input package json
257257
* @param force - force update even when the project version is higher than the policy version.
258258
*/
259-
public ensure(project: IPackageJsonWithVersion, force?: boolean): IPackageJsonWithVersion | undefined {
259+
public ensure(project: IPackageJson, force?: boolean): IPackageJson | undefined {
260260
const packageVersion: semver.SemVer = new semver.SemVer(project.version);
261261
const compareResult: number = packageVersion.compare(this._version);
262262
if (compareResult === 0) {
@@ -305,8 +305,8 @@ export class LockStepVersionPolicy extends VersionPolicy {
305305
}
306306
}
307307

308-
private _updatePackageVersion(project: IPackageJsonWithVersion, newVersion: semver.SemVer): IPackageJsonWithVersion {
309-
const updatedProject: IPackageJsonWithVersion = cloneDeep(project);
308+
private _updatePackageVersion(project: IPackageJson, newVersion: semver.SemVer): IPackageJson {
309+
const updatedProject: IPackageJson = cloneDeep(project);
310310
updatedProject.version = newVersion.format();
311311
return updatedProject;
312312
}
@@ -361,11 +361,11 @@ export class IndividualVersionPolicy extends VersionPolicy {
361361
* @param project - input package json
362362
* @param force - force update even when the project version is higher than the policy version.
363363
*/
364-
public ensure(project: IPackageJsonWithVersion, force?: boolean): IPackageJsonWithVersion | undefined {
364+
public ensure(project: IPackageJson, force?: boolean): IPackageJson | undefined {
365365
if (this.lockedMajor) {
366366
const version: semver.SemVer = new semver.SemVer(project.version);
367367
if (version.major < this.lockedMajor) {
368-
const updatedProject: IPackageJsonWithVersion = cloneDeep(project);
368+
const updatedProject: IPackageJson = cloneDeep(project);
369369
updatedProject.version = `${this._lockedMajor}.0.0`;
370370
return updatedProject;
371371
} else if (version.major > this.lockedMajor) {

apps/rush-lib/src/api/test/VersionPolicy.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// See LICENSE in the project root for license information.
33

44
import * as path from 'path';
5-
import { IPackageJsonWithVersion } from '@microsoft/node-core-library';
5+
import { IPackageJson } from '@microsoft/node-core-library';
66

77
import { VersionPolicyConfiguration } from '../VersionPolicyConfiguration';
88
import {
@@ -39,11 +39,11 @@ describe('VersionPolicy', () => {
3939

4040
it('updates packageJson if version is lower than the locked step version', () => {
4141
const lockStepVersionPolicy: LockStepVersionPolicy = versionPolicy as LockStepVersionPolicy;
42-
const expectedPackageJson: IPackageJsonWithVersion = {
42+
const expectedPackageJson: IPackageJson = {
4343
name: 'a',
4444
version: '1.1.0'
4545
};
46-
const originalPackageJson: IPackageJsonWithVersion = {
46+
const originalPackageJson: IPackageJson = {
4747
name: 'a',
4848
version: '1.0.1'
4949
};
@@ -52,7 +52,7 @@ describe('VersionPolicy', () => {
5252

5353
it('throws exception if version is higher than the locked step version', () => {
5454
const lockStepVersionPolicy: LockStepVersionPolicy = versionPolicy as LockStepVersionPolicy;
55-
const originalPackageJson: IPackageJsonWithVersion = {
55+
const originalPackageJson: IPackageJson = {
5656
name: 'a',
5757
version: '2.1.0'
5858
};
@@ -63,11 +63,11 @@ describe('VersionPolicy', () => {
6363

6464
it('update version with force if version is higher than the locked step version', () => {
6565
const lockStepVersionPolicy: LockStepVersionPolicy = versionPolicy as LockStepVersionPolicy;
66-
const originalPackageJson: IPackageJsonWithVersion = {
66+
const originalPackageJson: IPackageJson = {
6767
name: 'a',
6868
version: '2.1.0'
6969
};
70-
const expectedPackageJson: IPackageJsonWithVersion = {
70+
const expectedPackageJson: IPackageJson = {
7171
name: 'a',
7272
version: '1.1.0'
7373
};
@@ -117,11 +117,11 @@ describe('VersionPolicy', () => {
117117

118118
it('updates packageJson if version is lower than the locked major', () => {
119119
const individualVersionPolicy: IndividualVersionPolicy = versionPolicy as IndividualVersionPolicy;
120-
const expectedPackageJson: IPackageJsonWithVersion = {
120+
const expectedPackageJson: IPackageJson = {
121121
name: 'a',
122122
version: '2.0.0'
123123
};
124-
const originalPackageJson: IPackageJsonWithVersion = {
124+
const originalPackageJson: IPackageJson = {
125125
name: 'a',
126126
version: '1.0.1'
127127
};
@@ -130,7 +130,7 @@ describe('VersionPolicy', () => {
130130

131131
it('throws exception if version is higher than the locked step version', () => {
132132
const individualVersionPolicy: IndividualVersionPolicy = versionPolicy as IndividualVersionPolicy;
133-
const originalPackageJson: IPackageJsonWithVersion = {
133+
const originalPackageJson: IPackageJson = {
134134
name: 'a',
135135
version: '3.1.0'
136136
};

apps/rush-lib/src/logic/ChangeManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import { IPackageJsonWithVersion } from '@microsoft/node-core-library';
4+
import { IPackageJson } from '@microsoft/node-core-library';
55

66
import { IChangeInfo } from '../api/ChangeManagement';
77
import { IChangelog } from '../api/Changelog';
@@ -92,13 +92,13 @@ export class ChangeManager {
9292
* @param shouldCommit - If the value is true, package.json will be updated.
9393
* If the value is false, package.json and change logs will not be updated. It will only do a dry-run.
9494
*/
95-
public apply(shouldCommit: boolean): Map<string, IPackageJsonWithVersion> | undefined {
95+
public apply(shouldCommit: boolean): Map<string, IPackageJson> | undefined {
9696
if (!this.hasChanges()) {
9797
return;
9898
}
9999

100100
// Apply all changes to package.json files.
101-
const updatedPackages: Map<string, IPackageJsonWithVersion> = PublishUtilities.updatePackages(
101+
const updatedPackages: Map<string, IPackageJson> = PublishUtilities.updatePackages(
102102
this._allChanges,
103103
this._allPackages,
104104
this._rushConfiguration,

apps/rush-lib/src/logic/PublishUtilities.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import * as path from 'path';
1111
import * as semver from 'semver';
1212

1313
import {
14+
IPackageJson,
1415
JsonFile,
15-
FileConstants,
16-
IPackageJsonWithVersion
16+
FileConstants
1717
} from '@microsoft/node-core-library';
1818

1919
import {
@@ -90,7 +90,7 @@ export class PublishUtilities {
9090
if (allChanges.hasOwnProperty(packageName)) {
9191
const change: IChangeInfo = allChanges[packageName];
9292
const project: RushConfigurationProject = allPackages.get(packageName)!;
93-
const pkg: IPackageJsonWithVersion = project.packageJson;
93+
const pkg: IPackageJson = project.packageJson;
9494
const deps: string[] = project.downstreamDependencyProjects;
9595

9696
// Write the new version expected for the change.
@@ -142,11 +142,11 @@ export class PublishUtilities {
142142
shouldCommit: boolean,
143143
prereleaseToken?: PrereleaseToken,
144144
projectsToExclude?: Set<string>
145-
): Map<string, IPackageJsonWithVersion> {
146-
const updatedPackages: Map<string, IPackageJsonWithVersion> = new Map<string, IPackageJsonWithVersion>();
145+
): Map<string, IPackageJson> {
146+
const updatedPackages: Map<string, IPackageJson> = new Map<string, IPackageJson>();
147147

148148
Object.keys(allChanges).forEach(packageName => {
149-
const updatedPackage: IPackageJsonWithVersion = PublishUtilities._writePackageChanges(
149+
const updatedPackage: IPackageJson = PublishUtilities._writePackageChanges(
150150
allChanges[packageName],
151151
allChanges,
152152
allPackages,
@@ -288,10 +288,10 @@ export class PublishUtilities {
288288
shouldCommit: boolean,
289289
prereleaseToken?: PrereleaseToken,
290290
projectsToExclude?: Set<string>
291-
): IPackageJsonWithVersion {
291+
): IPackageJson {
292292

293293
const project: RushConfigurationProject = allPackages.get(change.packageName)!;
294-
const pkg: IPackageJsonWithVersion = project.packageJson;
294+
const pkg: IPackageJson = project.packageJson;
295295

296296
const shouldSkipVersionBump: boolean = !project.shouldPublish ||
297297
!!projectsToExclude && projectsToExclude.has(change.packageName);
@@ -453,7 +453,7 @@ export class PublishUtilities {
453453
return false;
454454
}
455455

456-
const pkg: IPackageJsonWithVersion = project.packageJson;
456+
const pkg: IPackageJson = project.packageJson;
457457
let currentChange: IChangeInfo;
458458

459459
// If the given change does not have a changeType, derive it from the "type" string.
@@ -542,7 +542,7 @@ export class PublishUtilities {
542542
if ((change.changeType! >= ChangeType.hotfix) ||
543543
(prereleaseToken && prereleaseToken.hasValue)) {
544544
for (const depName of downstreamNames) {
545-
const pkg: IPackageJsonWithVersion = allPackages.get(depName)!.packageJson;
545+
const pkg: IPackageJson = allPackages.get(depName)!.packageJson;
546546

547547
PublishUtilities._updateDownstreamDependency(
548548
pkg.name,

0 commit comments

Comments
 (0)