Skip to content

Commit

Permalink
feat: allow duplicate devdep and dep when pkg is library and dep is r…
Browse files Browse the repository at this point in the history
…ange

BREAKING CHANGE: isLibrary is now an option on createCheckPackage instead of checkRecommended
  • Loading branch information
christophehurpeau committed Dec 30, 2022
1 parent 089732f commit 3697f8d
Show file tree
Hide file tree
Showing 21 changed files with 192 additions and 78 deletions.
8 changes: 6 additions & 2 deletions dist/definitions/check-package-with-workspaces.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { Except } from 'type-fest';
import type { CreateCheckPackageOptions, CheckPackageApi, OnlyWarnsForInDependenciesCheckPackageRecommendedOption, OnlyWarnsForInDependencyCheckPackageRecommendedOption, OnlyWarnsForInPackageCheckPackageRecommendedOption } from './check-package';
import type { CheckResolutionMessage } from './checks/checkResolutionsHasExplanation';
import type { PackageJson } from './utils/packageTypes';
import type { OnlyWarnsForOptionalDependencyMapping } from './utils/warnForUtils';
interface OnlyWarnsForInMonorepoPackageCheckPackageRecommendedOption extends OnlyWarnsForInPackageCheckPackageRecommendedOption {
duplicateDirectDependency: OnlyWarnsForInDependencyCheckPackageRecommendedOption['duplicateDirectDependency'];
}
type OnlyWarnsForInMonorepoPackagesCheckPackageRecommendedOption = Record<'*' | string, OnlyWarnsForInMonorepoPackageCheckPackageRecommendedOption>;
type OnlyWarnsForInMonorepoPackagesDependenciesCheckPackageRecommendedOption = Record<string, OnlyWarnsForInDependenciesCheckPackageRecommendedOption>;
export interface CheckPackageWithWorkspacesRecommendedOptions {
isLibrary?: (pkgName: string) => boolean;
allowRangeVersionsInLibraries?: boolean;
monorepoDirectDuplicateDependenciesOnlyWarnsFor?: OnlyWarnsForOptionalDependencyMapping;
onlyWarnsForInRootPackage?: OnlyWarnsForInPackageCheckPackageRecommendedOption;
Expand All @@ -23,6 +24,9 @@ export interface CheckPackageWithWorkspacesApi {
forEach: (callback: (checkPackage: CheckPackageApi) => void) => CheckPackageWithWorkspacesApi;
for: (id: string, callback: (checkPackage: CheckPackageApi) => void) => CheckPackageWithWorkspacesApi;
}
export declare function createCheckPackageWithWorkspaces(pkgDirectoryPath?: string, createCheckPackageOptions?: CreateCheckPackageOptions): CheckPackageWithWorkspacesApi;
interface CreateCheckPackageWithWorkspacesOptions extends Except<CreateCheckPackageOptions, 'isLibrary'> {
isLibrary?: (pkg: PackageJson) => boolean;
}
export declare function createCheckPackageWithWorkspaces(createCheckPackageOptions?: CreateCheckPackageWithWorkspacesOptions): CheckPackageWithWorkspacesApi;
export {};
//# sourceMappingURL=check-package-with-workspaces.d.ts.map
2 changes: 1 addition & 1 deletion dist/definitions/check-package-with-workspaces.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions dist/definitions/check-package.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import type { GetDependencyPackageJson } from './utils/createGetDependencyPackag
import type { DependenciesRanges, DependencyName, DependencyTypes, PackageJson } from './utils/packageTypes';
import type { OnlyWarnsForOptionalDependencyMapping, OnlyWarnsFor } from './utils/warnForUtils';
export interface CreateCheckPackageOptions {
packageDirectoryPath?: string;
isLibrary?: boolean | ((pkg: PackageJson) => boolean);
/** @internal */
internalWorkspacePkgDirectoryPath?: string;
}
export interface CheckDirectPeerDependenciesOptions {
isLibrary?: boolean;
missingOnlyWarnsFor?: OnlyWarnsForOptionalDependencyMapping;
invalidOnlyWarnsFor?: OnlyWarnsForOptionalDependencyMapping;
internalMissingConfigName?: string;
Expand All @@ -27,7 +28,6 @@ export interface OnlyWarnsForInDependencyCheckPackageRecommendedOption {
}
export type OnlyWarnsForInDependenciesCheckPackageRecommendedOption = Record<'*' | string, OnlyWarnsForInDependencyCheckPackageRecommendedOption>;
export interface CheckRecommendedOptions {
isLibrary?: boolean;
/** default is true for libraries, false otherwise */
allowRangeVersionsInDependencies?: boolean;
onlyWarnsForInPackage?: OnlyWarnsForInPackageCheckPackageRecommendedOption;
Expand All @@ -52,6 +52,8 @@ export interface CheckPackageApi {
/** @internal */
pkgPathName: string;
/** @internal */
isPkgLibrary: boolean;
/** @internal */
getDependencyPackageJson: GetDependencyPackageJson;
checkExactVersions: (options?: CheckExactVersionsOptions) => CheckPackageApi;
checkResolutionsVersionsMatch: () => CheckPackageApi;
Expand Down Expand Up @@ -173,5 +175,5 @@ export interface CheckPackageApi {
*/
checkSatisfiesVersionsInDependency: (depName: string, dependenciesRanges: DependenciesRanges) => CheckPackageApi;
}
export declare function createCheckPackage(pkgDirectoryPath?: string, { internalWorkspacePkgDirectoryPath }?: CreateCheckPackageOptions): CheckPackageApi;
export declare function createCheckPackage({ packageDirectoryPath, internalWorkspacePkgDirectoryPath, isLibrary, }?: CreateCheckPackageOptions): CheckPackageApi;
//# sourceMappingURL=check-package.d.ts.map
2 changes: 1 addition & 1 deletion dist/definitions/check-package.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/definitions/checks/checkDirectDuplicateDependencies.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { GetDependencyPackageJson } from 'utils/createGetDependencyPackageJson';
import type { GetDependencyPackageJson } from '../utils/createGetDependencyPackageJson';
import { createReportError } from '../utils/createReportError';
import type { PackageJson, DependencyTypes } from '../utils/packageTypes';
import type { OnlyWarnsForMappingCheck } from '../utils/warnForUtils';
export declare function checkDirectDuplicateDependencies(pkg: PackageJson, pkgPathName: string, depType: DependencyTypes, getDependencyPackageJson: GetDependencyPackageJson, onlyWarnsForCheck: OnlyWarnsForMappingCheck, reportErrorNamePrefix?: string, customCreateReportError?: typeof createReportError): Promise<void>;
export declare function checkDirectDuplicateDependencies(pkg: PackageJson, pkgPathName: string, isPackageALibrary: boolean, depType: DependencyTypes, getDependencyPackageJson: GetDependencyPackageJson, onlyWarnsForCheck: OnlyWarnsForMappingCheck, reportErrorNamePrefix?: string, customCreateReportError?: typeof createReportError): Promise<void>;
//# sourceMappingURL=checkDirectDuplicateDependencies.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/definitions/checks/checkDirectPeerDependencies.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GetDependencyPackageJson } from 'utils/createGetDependencyPackageJson';
import type { GetDependencyPackageJson } from '../utils/createGetDependencyPackageJson';
import { createReportError } from '../utils/createReportError';
import type { PackageJson } from '../utils/packageTypes';
import type { OnlyWarnsForMappingCheck } from '../utils/warnForUtils';
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/definitions/checks/checkDuplicateDependencies.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ReportError } from '../utils/createReportError';
import type { PackageJson, DependencyTypes } from '../utils/packageTypes';
import type { OnlyWarnsForCheck } from '../utils/warnForUtils';
export declare function checkDuplicateDependencies(reportError: ReportError, pkg: PackageJson, depType: DependencyTypes, searchIn: DependencyTypes[], depPkg: PackageJson, onlyWarnsForCheck: OnlyWarnsForCheck): void;
export declare function checkDuplicateDependencies(reportError: ReportError, pkg: PackageJson, isPkgLibrary: boolean, depType: DependencyTypes, searchIn: DependencyTypes[], depPkg: PackageJson, onlyWarnsForCheck: OnlyWarnsForCheck): void;
//# sourceMappingURL=checkDuplicateDependencies.d.ts.map

0 comments on commit 3697f8d

Please sign in to comment.