Skip to content
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

refactor: Rename manager result type to MaybePromise #32977

Merged
Merged
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
4 changes: 2 additions & 2 deletions lib/modules/manager/custom/regex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import is from '@sindresorhus/is';
import type { Category } from '../../../../constants';
import type {
ExtractConfig,
MaybePromise,
PackageDependency,
PackageFileContent,
Result,
} from '../../types';
import { handleAny, handleCombination, handleRecursive } from './strategies';
import type { RegexManagerConfig, RegexManagerTemplates } from './types';
Expand All @@ -22,7 +22,7 @@ export function extractPackageFile(
content: string,
packageFile: string,
config: ExtractConfig,
): Result<PackageFileContent | null> {
): MaybePromise<PackageFileContent | null> {
let deps: PackageDependency[];
switch (config.matchStringsStrategy) {
default:
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import type {
ExtractConfig,
GlobalManagerConfig,
ManagerApi,
MaybePromise,
PackageFile,
PackageFileContent,
RangeConfig,
Result,
} from './types';
export { hashMap } from './fingerprint.generated';

Expand Down Expand Up @@ -65,7 +65,7 @@ export function extractPackageFile(
content: string,
fileName: string,
config: ExtractConfig,
): Result<PackageFileContent | null> {
): MaybePromise<PackageFileContent | null> {
const m = managers.get(manager)! ?? customManagers.get(manager)!;
if (!m) {
return null;
Expand Down
8 changes: 6 additions & 2 deletions lib/modules/manager/setup-cfg/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { logger } from '../../../logger';
import { newlineRegex, regEx } from '../../../util/regex';
import { PypiDatasource } from '../../datasource/pypi';
import { normalizePythonDepName } from '../../datasource/pypi/common';
import type { PackageDependency, PackageFileContent, Result } from '../types';
import type {
MaybePromise,
PackageDependency,
PackageFileContent,
} from '../types';

function getSectionName(str: string): string {
const [, sectionName] = regEx(/^\[\s*([^\s]+)\s*]\s*$/).exec(str) ?? [];
Expand Down Expand Up @@ -89,7 +93,7 @@ function parseDep(

export function extractPackageFile(
content: string,
): Result<PackageFileContent | null> {
): MaybePromise<PackageFileContent | null> {
logger.trace('setup-cfg.extractPackageFile()');

let sectionName: string | null = null;
Expand Down
16 changes: 8 additions & 8 deletions lib/modules/manager/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { FileChange } from '../../util/git/types';
import type { MergeConfidence } from '../../util/merge-confidence/types';
import type { CustomExtractConfig } from './custom/types';

export type Result<T> = T | Promise<T>;
export type MaybePromise<T> = T | Promise<T>;

export interface ManagerData<T> {
managerData?: T;
Expand Down Expand Up @@ -258,34 +258,34 @@ export interface ManagerApi extends ModuleApi {
currentValue: string,
bumpVersion: ReleaseType,
packageFile: string,
): Result<BumpPackageVersionResult>;
): MaybePromise<BumpPackageVersionResult>;

detectGlobalConfig?(): Result<GlobalManagerConfig>;
detectGlobalConfig?(): MaybePromise<GlobalManagerConfig>;

extractAllPackageFiles?(
config: ExtractConfig,
files: string[],
): Result<PackageFile[] | null>;
): MaybePromise<PackageFile[] | null>;

extractPackageFile?(
content: string,
packageFile?: string,
config?: ExtractConfig,
): Result<PackageFileContent | null>;
): MaybePromise<PackageFileContent | null>;

getRangeStrategy?(config: RangeConfig): RangeStrategy;

updateArtifacts?(
updateArtifact: UpdateArtifact,
): Result<UpdateArtifactsResult[] | null>;
): MaybePromise<UpdateArtifactsResult[] | null>;

updateDependency?(
updateDependencyConfig: UpdateDependencyConfig,
): Result<string | null>;
): MaybePromise<string | null>;

updateLockedDependency?(
config: UpdateLockedConfig,
): Result<UpdateLockedResult>;
): MaybePromise<UpdateLockedResult>;
}

// TODO: name and properties used by npm manager
Expand Down
Loading