refactor: composer managerData (#9226)

This commit is contained in:
Rhys Arkins 2021-03-20 08:10:53 +01:00 committed by GitHub
parent eb1f645e69
commit 11454b547e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 6 deletions

View file

@ -6,7 +6,12 @@ import { SkipReason } from '../../types';
import { readLocalFile } from '../../util/fs';
import { api as semverComposer } from '../../versioning/composer';
import type { PackageDependency, PackageFile } from '../types';
import type { ComposerConfig, ComposerLock, Repo } from './types';
import type {
ComposerConfig,
ComposerLock,
ComposerManagerData,
Repo,
} from './types';
import { extractContraints } from './utils';
/**
@ -176,8 +181,11 @@ export async function extractPackageFile(
return null;
}
res.deps = deps;
if (composerJson.type) {
res.managerData = { composerJsonType: composerJson.type };
if (is.string(composerJson.type)) {
const managerData: ComposerManagerData = {
composerJsonType: composerJson.type,
};
res.managerData = managerData;
}
return res;
}

View file

@ -1,6 +1,7 @@
import { logger } from '../../logger';
import type { RangeStrategy } from '../../types';
import type { RangeConfig } from '../types';
import { ComposerManagerData } from './types';
export function getRangeStrategy(config: RangeConfig): RangeStrategy {
const {
@ -10,7 +11,7 @@ export function getRangeStrategy(config: RangeConfig): RangeStrategy {
currentValue,
rangeStrategy,
} = config;
const { composerJsonType } = managerData;
const { composerJsonType } = managerData as ComposerManagerData;
const isComplexRange = currentValue?.includes(' || ');
if (rangeStrategy === 'bump' && isComplexRange) {
logger.debug(

View file

@ -30,3 +30,7 @@ export interface ComposerLock {
packages?: ComposerLockPackage[];
'packages-dev'?: ComposerLockPackage[];
}
export interface ComposerManagerData {
composerJsonType?: string;
}

View file

@ -59,7 +59,6 @@ export interface PackageUpdateConfig {
}
export interface RangeConfig<T = Record<string, any>> extends ManagerData<T> {
composerJsonType?: 'composer-plugin' | 'library' | 'metapackage' | 'project';
currentValue?: string;
depName?: string;
depType?: string;

View file

@ -9,7 +9,7 @@ import type { PackageFile } from '../../../manager/types';
import type { RepoInitConfig } from '../../../workers/repository/init/common';
// Increment this whenever there could be incompatibilities between old and new cache structure
export const CACHE_REVISION = 5;
export const CACHE_REVISION = 6;
export interface BaseBranchCache {
sha: string; // branch commit sha