mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
chore(manager): add more type annotations (#4344)
This commit is contained in:
parent
6be9ee0418
commit
081a23e6fc
70 changed files with 228 additions and 158 deletions
|
@ -2,7 +2,9 @@ import { logger } from '../../logger';
|
||||||
import { getDep } from '../dockerfile/extract';
|
import { getDep } from '../dockerfile/extract';
|
||||||
import { PackageFile, PackageDependency } from '../common';
|
import { PackageFile, PackageDependency } from '../common';
|
||||||
|
|
||||||
export default function extractPackageFile(content: string): PackageFile {
|
export default function extractPackageFile(
|
||||||
|
content: string
|
||||||
|
): PackageFile | null {
|
||||||
logger.trace('ansible.extractPackageFile()');
|
logger.trace('ansible.extractPackageFile()');
|
||||||
let deps: PackageDependency[] = [];
|
let deps: PackageDependency[] = [];
|
||||||
let lineNumber = 0;
|
let lineNumber = 0;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Upgrade } from '../common';
|
||||||
export default function updateDependency(
|
export default function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
) {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
const newFrom = getNewFrom(upgrade);
|
const newFrom = getNewFrom(upgrade);
|
||||||
logger.debug(`ansible.updateDependency(): ${newFrom}`);
|
logger.debug(`ansible.updateDependency(): ${newFrom}`);
|
||||||
|
|
|
@ -4,7 +4,12 @@ import { parse as _parse } from 'url';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { PackageDependency, PackageFile } from '../common';
|
import { PackageDependency, PackageFile } from '../common';
|
||||||
|
|
||||||
function parseUrl(urlString: string) {
|
interface UrlParsedResult {
|
||||||
|
repo: string;
|
||||||
|
currentValue: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseUrl(urlString: string): UrlParsedResult | null {
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (!urlString) {
|
if (!urlString) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -29,7 +34,7 @@ function parseUrl(urlString: string) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findBalancedParenIndex(longString: string) {
|
function findBalancedParenIndex(longString: string): number {
|
||||||
/**
|
/**
|
||||||
* Minimalistic string parser with single task -> find last char in def.
|
* Minimalistic string parser with single task -> find last char in def.
|
||||||
* It treats [)] as the last char.
|
* It treats [)] as the last char.
|
||||||
|
@ -63,7 +68,7 @@ function findBalancedParenIndex(longString: string) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseContent(content: string) {
|
function parseContent(content: string): string[] {
|
||||||
return [
|
return [
|
||||||
'container_pull',
|
'container_pull',
|
||||||
'http_archive',
|
'http_archive',
|
||||||
|
@ -86,7 +91,7 @@ function parseContent(content: string) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
const definitions = parseContent(content);
|
const definitions = parseContent(content);
|
||||||
if (!definitions.length) {
|
if (!definitions.length) {
|
||||||
logger.debug('No matching WORKSPACE definitions found');
|
logger.debug('No matching WORKSPACE definitions found');
|
||||||
|
|
|
@ -7,7 +7,7 @@ function updateWithNewVersion(
|
||||||
content: string,
|
content: string,
|
||||||
currentValue: string,
|
currentValue: string,
|
||||||
newValue: string
|
newValue: string
|
||||||
) {
|
): string {
|
||||||
const currentVersion = currentValue.replace(/^v/, '');
|
const currentVersion = currentValue.replace(/^v/, '');
|
||||||
const newVersion = newValue.replace(/^v/, '');
|
const newVersion = newValue.replace(/^v/, '');
|
||||||
let newContent = content;
|
let newContent = content;
|
||||||
|
@ -17,7 +17,7 @@ function updateWithNewVersion(
|
||||||
return newContent;
|
return newContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractUrl(flattened: string) {
|
function extractUrl(flattened: string): string[] | null {
|
||||||
const urlMatch = flattened.match(/url="(.*?)"/);
|
const urlMatch = flattened.match(/url="(.*?)"/);
|
||||||
if (!urlMatch) {
|
if (!urlMatch) {
|
||||||
logger.debug('Cannot locate urls in new definition');
|
logger.debug('Cannot locate urls in new definition');
|
||||||
|
@ -26,7 +26,7 @@ function extractUrl(flattened: string) {
|
||||||
return [urlMatch[1]];
|
return [urlMatch[1]];
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractUrls(content: string) {
|
function extractUrls(content: string): string[] | null {
|
||||||
const flattened = content.replace(/\n/g, '').replace(/\s/g, '');
|
const flattened = content.replace(/\n/g, '').replace(/\s/g, '');
|
||||||
const urlsMatch = flattened.match(/urls?=\[.*?\]/);
|
const urlsMatch = flattened.match(/urls?=\[.*?\]/);
|
||||||
if (!urlsMatch) {
|
if (!urlsMatch) {
|
||||||
|
@ -40,9 +40,12 @@ function extractUrls(content: string) {
|
||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getHashFromUrl(url: string) {
|
async function getHashFromUrl(url: string): Promise<string | null> {
|
||||||
const cacheNamespace = 'url-sha256';
|
const cacheNamespace = 'url-sha256';
|
||||||
const cachedResult = await renovateCache.get(cacheNamespace, url);
|
const cachedResult = await renovateCache.get<string | null>(
|
||||||
|
cacheNamespace,
|
||||||
|
url
|
||||||
|
);
|
||||||
/* istanbul ignore next line */
|
/* istanbul ignore next line */
|
||||||
if (cachedResult) return cachedResult;
|
if (cachedResult) return cachedResult;
|
||||||
try {
|
try {
|
||||||
|
@ -57,7 +60,7 @@ async function getHashFromUrl(url: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getHashFromUrls(urls: string[]) {
|
async function getHashFromUrls(urls: string[]): Promise<string | null> {
|
||||||
const hashes = (await Promise.all(
|
const hashes = (await Promise.all(
|
||||||
urls.map(url => getHashFromUrl(url))
|
urls.map(url => getHashFromUrl(url))
|
||||||
)).filter(Boolean);
|
)).filter(Boolean);
|
||||||
|
@ -73,14 +76,14 @@ async function getHashFromUrls(urls: string[]) {
|
||||||
return distinctHashes[0];
|
return distinctHashes[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setNewHash(content: string, hash: string) {
|
function setNewHash(content: string, hash: string): string {
|
||||||
return content.replace(/(sha256\s*=\s*)"[^"]+"/, `$1"${hash}"`);
|
return content.replace(/(sha256\s*=\s*)"[^"]+"/, `$1"${hash}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateDependency(
|
export async function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): Promise<string> {
|
): Promise<string | null> {
|
||||||
try {
|
try {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`bazel.updateDependency(): ${upgrade.newValue || upgrade.newDigest}`
|
`bazel.updateDependency(): ${upgrade.newValue || upgrade.newDigest}`
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { PackageFile, PackageDependency } from '../common';
|
||||||
|
|
||||||
export { extractPackageFile };
|
export { extractPackageFile };
|
||||||
|
|
||||||
function extractPackageFile(content: string): PackageFile {
|
function extractPackageFile(content: string): PackageFile | null {
|
||||||
const deps: PackageDependency[] = [];
|
const deps: PackageDependency[] = [];
|
||||||
try {
|
try {
|
||||||
const lines = content.split('\n');
|
const lines = content.split('\n');
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { Upgrade } from '../common';
|
import { Upgrade } from '../common';
|
||||||
|
|
||||||
export function updateDependency(currentFileContent: string, upgrade: Upgrade) {
|
export function updateDependency(
|
||||||
|
currentFileContent: string,
|
||||||
|
upgrade: Upgrade
|
||||||
|
): string | null {
|
||||||
try {
|
try {
|
||||||
const lineIdx = upgrade.managerData.lineNumber - 1;
|
const lineIdx = upgrade.managerData.lineNumber - 1;
|
||||||
logger.debug(`buildkite.updateDependency: ${upgrade.newValue}`);
|
logger.debug(`buildkite.updateDependency: ${upgrade.newValue}`);
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
matches,
|
matches,
|
||||||
sortVersions,
|
sortVersions,
|
||||||
} from '../../versioning/ruby';
|
} from '../../versioning/ruby';
|
||||||
import { UpdateArtifactsConfig } from '../common';
|
import { UpdateArtifactsConfig, UpdateArtifactsResult } from '../common';
|
||||||
|
|
||||||
// istanbul ignore next
|
// istanbul ignore next
|
||||||
export async function updateArtifacts(
|
export async function updateArtifacts(
|
||||||
|
@ -18,7 +18,7 @@ export async function updateArtifacts(
|
||||||
updatedDeps: string[],
|
updatedDeps: string[],
|
||||||
newPackageFileContent: string,
|
newPackageFileContent: string,
|
||||||
config: UpdateArtifactsConfig
|
config: UpdateArtifactsConfig
|
||||||
) {
|
): Promise<UpdateArtifactsResult[] | null> {
|
||||||
logger.debug(`bundler.updateArtifacts(${packageFileName})`);
|
logger.debug(`bundler.updateArtifacts(${packageFileName})`);
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (global.repoCache.bundlerArtifactsError) {
|
if (global.repoCache.bundlerArtifactsError) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ export { extractPackageFile };
|
||||||
async function extractPackageFile(
|
async function extractPackageFile(
|
||||||
content: string,
|
content: string,
|
||||||
fileName?: string
|
fileName?: string
|
||||||
): Promise<PackageFile> {
|
): Promise<PackageFile | null> {
|
||||||
const res: PackageFile = {
|
const res: PackageFile = {
|
||||||
registryUrls: [],
|
registryUrls: [],
|
||||||
deps: [],
|
deps: [],
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { RangeStrategy } from '../../versioning';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The getRangeStrategy() function is optional and can be removed if not applicable.
|
* The getRangeStrategy() function is optional and can be removed if not applicable.
|
||||||
* It is used when the user configures rangeStrategy=auto.
|
* It is used when the user configures rangeStrategy=auto.
|
||||||
|
@ -11,6 +13,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function getRangeStrategy() {
|
export function getRangeStrategy(): RangeStrategy {
|
||||||
return 'replace';
|
return 'replace';
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { Upgrade } from '../common';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
currentFileContent: string,
|
currentFileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
const delimiter =
|
const delimiter =
|
||||||
currentFileContent.split('"').length >
|
currentFileContent.split('"').length >
|
||||||
|
|
|
@ -11,7 +11,7 @@ export async function updateArtifacts(
|
||||||
updatedDeps: string[],
|
updatedDeps: string[],
|
||||||
newPackageFileContent: string,
|
newPackageFileContent: string,
|
||||||
config: UpdateArtifactsConfig
|
config: UpdateArtifactsConfig
|
||||||
): Promise<UpdateArtifactsResult[]> {
|
): Promise<UpdateArtifactsResult[] | null> {
|
||||||
await logger.debug(`cargo.updateArtifacts(${packageFileName})`);
|
await logger.debug(`cargo.updateArtifacts(${packageFileName})`);
|
||||||
if (updatedDeps === undefined || updatedDeps.length < 1) {
|
if (updatedDeps === undefined || updatedDeps.length < 1) {
|
||||||
logger.debug('No updated cargo deps - returning null');
|
logger.debug('No updated cargo deps - returning null');
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { CargoConfig, CargoSection } from './types';
|
||||||
export function extractPackageFile(
|
export function extractPackageFile(
|
||||||
content: string,
|
content: string,
|
||||||
fileName: string
|
fileName: string
|
||||||
): PackageFile {
|
): PackageFile | null {
|
||||||
logger.trace(`cargo.extractPackageFile(${fileName})`);
|
logger.trace(`cargo.extractPackageFile(${fileName})`);
|
||||||
let parsedContent: CargoConfig;
|
let parsedContent: CargoConfig;
|
||||||
try {
|
try {
|
||||||
|
@ -55,7 +55,7 @@ function extractFromSection(
|
||||||
parsedContent: CargoSection,
|
parsedContent: CargoSection,
|
||||||
section: keyof CargoSection,
|
section: keyof CargoSection,
|
||||||
target?: string
|
target?: string
|
||||||
) {
|
): PackageDependency[] {
|
||||||
const deps: PackageDependency[] = [];
|
const deps: PackageDependency[] = [];
|
||||||
const sectionContent = parsedContent[section];
|
const sectionContent = parsedContent[section];
|
||||||
if (!sectionContent) {
|
if (!sectionContent) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Upgrade } from '../common';
|
||||||
import { CargoConfig, CargoSection } from './types';
|
import { CargoConfig, CargoSection } from './types';
|
||||||
|
|
||||||
// Return true if the match string is found at index in content
|
// Return true if the match string is found at index in content
|
||||||
function matchAt(content: string, index: number, match: string) {
|
function matchAt(content: string, index: number, match: string): boolean {
|
||||||
return content.substring(index, index + match.length) === match;
|
return content.substring(index, index + match.length) === match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ function replaceAt(
|
||||||
index: number,
|
index: number,
|
||||||
oldString: string,
|
oldString: string,
|
||||||
newString: string
|
newString: string
|
||||||
) {
|
): string {
|
||||||
logger.debug(`Replacing ${oldString} with ${newString} at index ${index}`);
|
logger.debug(`Replacing ${oldString} with ${newString} at index ${index}`);
|
||||||
return (
|
return (
|
||||||
content.substr(0, index) +
|
content.substr(0, index) +
|
||||||
|
@ -27,7 +27,7 @@ function replaceAt(
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade<{ nestedVersion?: boolean }>
|
upgrade: Upgrade<{ nestedVersion?: boolean }>
|
||||||
) {
|
): string {
|
||||||
logger.trace({ config: upgrade }, 'poetry.updateDependency()');
|
logger.trace({ config: upgrade }, 'poetry.updateDependency()');
|
||||||
if (!upgrade) {
|
if (!upgrade) {
|
||||||
return fileContent;
|
return fileContent;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { logger } from '../../logger';
|
||||||
import { getDep } from '../dockerfile/extract';
|
import { getDep } from '../dockerfile/extract';
|
||||||
import { PackageFile, PackageDependency } from '../common';
|
import { PackageFile, PackageDependency } from '../common';
|
||||||
|
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
const deps: PackageDependency[] = [];
|
const deps: PackageDependency[] = [];
|
||||||
try {
|
try {
|
||||||
const lines = content.split('\n');
|
const lines = content.split('\n');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Upgrade } from '../common';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
const lines = fileContent.split('\n');
|
const lines = fileContent.split('\n');
|
||||||
const lineToChange = lines[upgrade.managerData.lineNumber];
|
const lineToChange = lines[upgrade.managerData.lineNumber];
|
||||||
|
|
|
@ -173,15 +173,17 @@ export interface ManagerApi {
|
||||||
extractAllPackageFiles?(
|
extractAllPackageFiles?(
|
||||||
config: ExtractConfig,
|
config: ExtractConfig,
|
||||||
files: string[]
|
files: string[]
|
||||||
): Result<PackageFile[]>;
|
): Result<PackageFile[] | null>;
|
||||||
|
|
||||||
extractPackageFile?(
|
extractPackageFile?(
|
||||||
content: string,
|
content: string,
|
||||||
packageFile?: string,
|
packageFile?: string,
|
||||||
config?: ExtractConfig
|
config?: ExtractConfig
|
||||||
): Result<PackageFile>;
|
): Result<PackageFile | null>;
|
||||||
|
|
||||||
getPackageUpdates(config: PackageUpdateConfig): Result<PackageUpdateResult[]>;
|
getPackageUpdates?(
|
||||||
|
config: PackageUpdateConfig
|
||||||
|
): Result<PackageUpdateResult[]>;
|
||||||
|
|
||||||
getRangeStrategy(config: RangeConfig): RangeStrategy;
|
getRangeStrategy(config: RangeConfig): RangeStrategy;
|
||||||
|
|
||||||
|
@ -190,9 +192,12 @@ export interface ManagerApi {
|
||||||
updatedDeps: string[],
|
updatedDeps: string[],
|
||||||
newPackageFileContent: string,
|
newPackageFileContent: string,
|
||||||
config: UpdateArtifactsConfig
|
config: UpdateArtifactsConfig
|
||||||
): Result<UpdateArtifactsResult[]>;
|
): Result<UpdateArtifactsResult[] | null>;
|
||||||
|
|
||||||
updateDependency(fileContent: string, upgrade: Upgrade): Result<string>;
|
updateDependency(
|
||||||
|
fileContent: string,
|
||||||
|
upgrade: Upgrade
|
||||||
|
): Result<string | null>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: name and properties used by npm manager
|
// TODO: name and properties used by npm manager
|
||||||
|
|
|
@ -3,7 +3,7 @@ import URL from 'url';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import upath from 'upath';
|
import upath from 'upath';
|
||||||
import { exec } from '../../util/exec';
|
import { exec } from '../../util/exec';
|
||||||
import { UpdateArtifactsConfig } from '../common';
|
import { UpdateArtifactsConfig, UpdateArtifactsResult } from '../common';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import * as hostRules from '../../util/host-rules';
|
import * as hostRules from '../../util/host-rules';
|
||||||
import { getChildProcessEnv } from '../../util/env';
|
import { getChildProcessEnv } from '../../util/env';
|
||||||
|
@ -13,7 +13,7 @@ export async function updateArtifacts(
|
||||||
updatedDeps: string[],
|
updatedDeps: string[],
|
||||||
newPackageFileContent: string,
|
newPackageFileContent: string,
|
||||||
config: UpdateArtifactsConfig
|
config: UpdateArtifactsConfig
|
||||||
) {
|
): Promise<UpdateArtifactsResult[] | null> {
|
||||||
logger.debug(`composer.updateArtifacts(${packageFileName})`);
|
logger.debug(`composer.updateArtifacts(${packageFileName})`);
|
||||||
process.env.COMPOSER_CACHE_DIR =
|
process.env.COMPOSER_CACHE_DIR =
|
||||||
process.env.COMPOSER_CACHE_DIR ||
|
process.env.COMPOSER_CACHE_DIR ||
|
||||||
|
|
|
@ -81,7 +81,10 @@ function parseRepositories(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function extractPackageFile(content: string, fileName: string) {
|
export async function extractPackageFile(
|
||||||
|
content: string,
|
||||||
|
fileName: string
|
||||||
|
): Promise<PackageFile | null> {
|
||||||
logger.trace(`composer.extractPackageFile(${fileName})`);
|
logger.trace(`composer.extractPackageFile(${fileName})`);
|
||||||
let composerJson: ComposerConfig;
|
let composerJson: ComposerConfig;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -28,7 +28,7 @@ export function splitImageParts(currentFrom: string): PackageDependency {
|
||||||
return dep;
|
return dep;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDep(currentFrom: string) {
|
export function getDep(currentFrom: string): PackageDependency {
|
||||||
const dep = splitImageParts(currentFrom);
|
const dep = splitImageParts(currentFrom);
|
||||||
dep.datasource = 'docker';
|
dep.datasource = 'docker';
|
||||||
if (
|
if (
|
||||||
|
@ -41,7 +41,7 @@ export function getDep(currentFrom: string) {
|
||||||
return dep;
|
return dep;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
const deps: PackageDependency[] = [];
|
const deps: PackageDependency[] = [];
|
||||||
const stageNames: string[] = [];
|
const stageNames: string[] = [];
|
||||||
let lineNumber = 0;
|
let lineNumber = 0;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { Upgrade } from '../common';
|
import { Upgrade } from '../common';
|
||||||
|
|
||||||
export function getNewFrom(upgrade: Upgrade) {
|
export function getNewFrom(upgrade: Upgrade): string {
|
||||||
const { depName, newValue, newDigest } = upgrade;
|
const { depName, newValue, newDigest } = upgrade;
|
||||||
let newFrom = depName;
|
let newFrom = depName;
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
|
@ -13,7 +13,10 @@ export function getNewFrom(upgrade: Upgrade) {
|
||||||
return newFrom;
|
return newFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateDependency(fileContent: string, upgrade: Upgrade) {
|
export function updateDependency(
|
||||||
|
fileContent: string,
|
||||||
|
upgrade: Upgrade
|
||||||
|
): string | null {
|
||||||
try {
|
try {
|
||||||
const { lineNumber, fromSuffix } = upgrade.managerData;
|
const { lineNumber, fromSuffix } = upgrade.managerData;
|
||||||
let { fromPrefix } = upgrade.managerData;
|
let { fromPrefix } = upgrade.managerData;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { logger } from '../../logger';
|
||||||
import { getDep } from '../dockerfile/extract';
|
import { getDep } from '../dockerfile/extract';
|
||||||
import { PackageFile, PackageDependency } from '../common';
|
import { PackageFile, PackageDependency } from '../common';
|
||||||
|
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
const deps: PackageDependency[] = [];
|
const deps: PackageDependency[] = [];
|
||||||
try {
|
try {
|
||||||
const lines = content.split('\n');
|
const lines = content.split('\n');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Upgrade } from '../common';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
const lines = fileContent.split('\n');
|
const lines = fileContent.split('\n');
|
||||||
const lineToChange = lines[upgrade.managerData.lineNumber];
|
const lineToChange = lines[upgrade.managerData.lineNumber];
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { logger } from '../../logger';
|
||||||
import { getDep } from '../dockerfile/extract';
|
import { getDep } from '../dockerfile/extract';
|
||||||
import { PackageFile, PackageDependency } from '../common';
|
import { PackageFile, PackageDependency } from '../common';
|
||||||
|
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
logger.debug('github-actions.extractPackageFile()');
|
logger.debug('github-actions.extractPackageFile()');
|
||||||
const deps: PackageDependency[] = [];
|
const deps: PackageDependency[] = [];
|
||||||
let lineNumber = 0;
|
let lineNumber = 0;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Upgrade } from '../common';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
const newFrom = getNewFrom(upgrade);
|
const newFrom = getNewFrom(upgrade);
|
||||||
logger.debug(`github-actions.updateDependency(): ${newFrom}`);
|
logger.debug(`github-actions.updateDependency(): ${newFrom}`);
|
||||||
|
|
|
@ -7,7 +7,7 @@ function extractDepFromInclude(includeObj: {
|
||||||
file: any;
|
file: any;
|
||||||
project: string;
|
project: string;
|
||||||
ref: string;
|
ref: string;
|
||||||
}) {
|
}): PackageDependency | null {
|
||||||
if (!includeObj.file || !includeObj.project) {
|
if (!includeObj.file || !includeObj.project) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ export function extractPackageFile(
|
||||||
content: string,
|
content: string,
|
||||||
_packageFile: string,
|
_packageFile: string,
|
||||||
config: ExtractConfig
|
config: ExtractConfig
|
||||||
): PackageFile {
|
): PackageFile | null {
|
||||||
const deps: PackageDependency[] = [];
|
const deps: PackageDependency[] = [];
|
||||||
try {
|
try {
|
||||||
const doc = yaml.safeLoad(content);
|
const doc = yaml.safeLoad(content);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Upgrade } from '../common';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
currentFileContent: string,
|
currentFileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
const { depName, newValue } = upgrade;
|
const { depName, newValue } = upgrade;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { logger } from '../../logger';
|
||||||
import { getDep } from '../dockerfile/extract';
|
import { getDep } from '../dockerfile/extract';
|
||||||
import { PackageFile, PackageDependency } from '../common';
|
import { PackageFile, PackageDependency } from '../common';
|
||||||
|
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
const deps: PackageDependency[] = [];
|
const deps: PackageDependency[] = [];
|
||||||
try {
|
try {
|
||||||
const lines = content.split('\n');
|
const lines = content.split('\n');
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Upgrade } from '../common';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
currentFileContent: string,
|
currentFileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
const newFrom = getNewFrom(upgrade);
|
const newFrom = getNewFrom(upgrade);
|
||||||
const lines = currentFileContent.split('\n');
|
const lines = currentFileContent.split('\n');
|
||||||
|
|
|
@ -11,7 +11,7 @@ export async function updateArtifacts(
|
||||||
_updatedDeps: string[],
|
_updatedDeps: string[],
|
||||||
newGoModContent: string,
|
newGoModContent: string,
|
||||||
config: UpdateArtifactsConfig
|
config: UpdateArtifactsConfig
|
||||||
): Promise<UpdateArtifactsResult[]> {
|
): Promise<UpdateArtifactsResult[] | null> {
|
||||||
logger.debug(`gomod.updateArtifacts(${goModFileName})`);
|
logger.debug(`gomod.updateArtifacts(${goModFileName})`);
|
||||||
process.env.GOPATH =
|
process.env.GOPATH =
|
||||||
process.env.GOPATH || join(config.cacheDir, './others/go');
|
process.env.GOPATH || join(config.cacheDir, './others/go');
|
||||||
|
|
|
@ -2,7 +2,11 @@ import { logger } from '../../logger';
|
||||||
import { isVersion } from '../../versioning/semver';
|
import { isVersion } from '../../versioning/semver';
|
||||||
import { PackageDependency, PackageFile } from '../common';
|
import { PackageDependency, PackageFile } from '../common';
|
||||||
|
|
||||||
function getDep(lineNumber: number, match: RegExpMatchArray, type: string) {
|
function getDep(
|
||||||
|
lineNumber: number,
|
||||||
|
match: RegExpMatchArray,
|
||||||
|
type: string
|
||||||
|
): PackageDependency {
|
||||||
const [, , currentValue] = match;
|
const [, , currentValue] = match;
|
||||||
let [, depName] = match;
|
let [, depName] = match;
|
||||||
depName = depName.replace(/"/g, '');
|
depName = depName.replace(/"/g, '');
|
||||||
|
@ -35,7 +39,7 @@ function getDep(lineNumber: number, match: RegExpMatchArray, type: string) {
|
||||||
return dep;
|
return dep;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
logger.trace({ content }, 'gomod.extractPackageFile()');
|
logger.trace({ content }, 'gomod.extractPackageFile()');
|
||||||
const deps: PackageDependency[] = [];
|
const deps: PackageDependency[] = [];
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Upgrade } from '../common';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
currentFileContent: string,
|
currentFileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
logger.debug(`gomod.updateDependency: ${upgrade.newValue}`);
|
logger.debug(`gomod.updateDependency: ${upgrade.newValue}`);
|
||||||
const { depName, depType } = upgrade;
|
const { depName, depType } = upgrade;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { coerce } from 'semver';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { PackageFile, PackageDependency } from '../common';
|
import { PackageFile, PackageDependency } from '../common';
|
||||||
|
|
||||||
export function extractPackageFile(fileContent: string): PackageFile {
|
export function extractPackageFile(fileContent: string): PackageFile | null {
|
||||||
logger.debug('gradle-wrapper.extractPackageFile()');
|
logger.debug('gradle-wrapper.extractPackageFile()');
|
||||||
const lines = fileContent.split('\n');
|
const lines = fileContent.split('\n');
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Upgrade } from '../common';
|
||||||
export async function updateDependency(
|
export async function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): Promise<string> {
|
): Promise<string | null> {
|
||||||
try {
|
try {
|
||||||
logger.debug(upgrade, 'gradle-wrapper.updateDependency()');
|
logger.debug(upgrade, 'gradle-wrapper.updateDependency()');
|
||||||
const lines = fileContent.split('\n');
|
const lines = fileContent.split('\n');
|
||||||
|
@ -35,14 +35,14 @@ export async function updateDependency(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceType(url: string) {
|
function replaceType(url: string): string {
|
||||||
return url.replace('bin', 'all');
|
return url.replace('bin', 'all');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getChecksum(url: string) {
|
async function getChecksum(url: string): Promise<string> {
|
||||||
try {
|
try {
|
||||||
const response = await got(url);
|
const response = await got(url);
|
||||||
return response.body;
|
return response.body as string;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.statusCode === 404 || err.code === 'ENOTFOUND') {
|
if (err.statusCode === 404 || err.code === 'ENOTFOUND') {
|
||||||
logger.info('Gradle checksum lookup failure: not found');
|
logger.info('Gradle checksum lookup failure: not found');
|
||||||
|
|
|
@ -26,7 +26,7 @@ export function updateGradleVersion(
|
||||||
buildGradleContent: string,
|
buildGradleContent: string,
|
||||||
dependency: GradleDependency,
|
dependency: GradleDependency,
|
||||||
newVersion: string
|
newVersion: string
|
||||||
) {
|
): string {
|
||||||
if (dependency) {
|
if (dependency) {
|
||||||
const updateFunctions: UpdateFunction[] = [
|
const updateFunctions: UpdateFunction[] = [
|
||||||
updateVersionLiterals,
|
updateVersionLiterals,
|
||||||
|
@ -84,7 +84,7 @@ function updateVersionLiterals(
|
||||||
dependency: GradleDependency,
|
dependency: GradleDependency,
|
||||||
buildGradleContent: string,
|
buildGradleContent: string,
|
||||||
newVersion: string
|
newVersion: string
|
||||||
) {
|
): string | null {
|
||||||
const regexes: RegExp[] = [
|
const regexes: RegExp[] = [
|
||||||
moduleStringVersionFormatMatch(dependency),
|
moduleStringVersionFormatMatch(dependency),
|
||||||
groovyPluginStringVersionFormatMatch(dependency),
|
groovyPluginStringVersionFormatMatch(dependency),
|
||||||
|
@ -104,7 +104,7 @@ function updateLocalVariables(
|
||||||
dependency: GradleDependency,
|
dependency: GradleDependency,
|
||||||
buildGradleContent: string,
|
buildGradleContent: string,
|
||||||
newVersion: string
|
newVersion: string
|
||||||
) {
|
): string | null {
|
||||||
const regexes: RegExp[] = [
|
const regexes: RegExp[] = [
|
||||||
moduleMapVariableVersionFormatMatch(dependency),
|
moduleMapVariableVersionFormatMatch(dependency),
|
||||||
moduleStringVariableInterpolationVersionFormatMatch(dependency),
|
moduleStringVariableInterpolationVersionFormatMatch(dependency),
|
||||||
|
@ -127,7 +127,7 @@ function updateGlobalVariables(
|
||||||
dependency: GradleDependency,
|
dependency: GradleDependency,
|
||||||
buildGradleContent: string,
|
buildGradleContent: string,
|
||||||
newVersion: string
|
newVersion: string
|
||||||
) {
|
): string | null {
|
||||||
const variable = variables[`${dependency.group}:${dependency.name}`];
|
const variable = variables[`${dependency.group}:${dependency.name}`];
|
||||||
if (variable) {
|
if (variable) {
|
||||||
const regex = variableDefinitionFormatMatch(variable);
|
const regex = variableDefinitionFormatMatch(variable);
|
||||||
|
@ -146,7 +146,7 @@ function updatePropertyFileGlobalVariables(
|
||||||
dependency: GradleDependency,
|
dependency: GradleDependency,
|
||||||
buildGradleContent: string,
|
buildGradleContent: string,
|
||||||
newVersion: string
|
newVersion: string
|
||||||
) {
|
): string | null {
|
||||||
const variable = variables[`${dependency.group}:${dependency.name}`];
|
const variable = variables[`${dependency.group}:${dependency.name}`];
|
||||||
if (variable) {
|
if (variable) {
|
||||||
const regex = new RegExp(`(${variable}\\s*=\\s*)(.*)`);
|
const regex = new RegExp(`(${variable}\\s*=\\s*)(.*)`);
|
||||||
|
@ -159,25 +159,29 @@ function updatePropertyFileGlobalVariables(
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/patrikerdes/gradle-use-latest-versions-plugin/blob/8cf9c3917b8b04ba41038923cab270d2adda3aa6/src/main/groovy/se/patrikerdes/DependencyUpdate.groovy#L27-L29
|
// https://github.com/patrikerdes/gradle-use-latest-versions-plugin/blob/8cf9c3917b8b04ba41038923cab270d2adda3aa6/src/main/groovy/se/patrikerdes/DependencyUpdate.groovy#L27-L29
|
||||||
function moduleStringVersionFormatMatch(dependency: GradleDependency) {
|
function moduleStringVersionFormatMatch(dependency: GradleDependency): RegExp {
|
||||||
return new RegExp(
|
return new RegExp(
|
||||||
`(["']${dependency.group}:${dependency.name}:)[^$].*?(([:@].*?)?["'])`
|
`(["']${dependency.group}:${dependency.name}:)[^$].*?(([:@].*?)?["'])`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function groovyPluginStringVersionFormatMatch(dependency: GradleDependency) {
|
function groovyPluginStringVersionFormatMatch(
|
||||||
|
dependency: GradleDependency
|
||||||
|
): RegExp {
|
||||||
return new RegExp(
|
return new RegExp(
|
||||||
`(id\\s+["']${dependency.group}["']\\s+version\\s+["'])[^$].*?(["'])`
|
`(id\\s+["']${dependency.group}["']\\s+version\\s+["'])[^$].*?(["'])`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function kotlinPluginStringVersionFormatMatch(dependency: GradleDependency) {
|
function kotlinPluginStringVersionFormatMatch(
|
||||||
|
dependency: GradleDependency
|
||||||
|
): RegExp {
|
||||||
return new RegExp(
|
return new RegExp(
|
||||||
`(id\\("${dependency.group}"\\)\\s+version\\s+")[^$].*?(")`
|
`(id\\("${dependency.group}"\\)\\s+version\\s+")[^$].*?(")`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function moduleMapVersionFormatMatch(dependency: GradleDependency) {
|
function moduleMapVersionFormatMatch(dependency: GradleDependency): RegExp {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
return new RegExp(
|
return new RegExp(
|
||||||
`(group\\s*:\\s*["']${dependency.group}["']\\s*,\\s*` +
|
`(group\\s*:\\s*["']${dependency.group}["']\\s*,\\s*` +
|
||||||
|
@ -188,7 +192,7 @@ function moduleMapVersionFormatMatch(dependency: GradleDependency) {
|
||||||
|
|
||||||
function moduleKotlinNamedArgumentVersionFormatMatch(
|
function moduleKotlinNamedArgumentVersionFormatMatch(
|
||||||
dependency: GradleDependency
|
dependency: GradleDependency
|
||||||
) {
|
): RegExp {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
return new RegExp(
|
return new RegExp(
|
||||||
`(group\\s*=\\s*"${dependency.group}"\\s*,\\s*` +
|
`(group\\s*=\\s*"${dependency.group}"\\s*,\\s*` +
|
||||||
|
@ -197,7 +201,9 @@ function moduleKotlinNamedArgumentVersionFormatMatch(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function moduleMapVariableVersionFormatMatch(dependency: GradleDependency) {
|
function moduleMapVariableVersionFormatMatch(
|
||||||
|
dependency: GradleDependency
|
||||||
|
): RegExp {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
return new RegExp(
|
return new RegExp(
|
||||||
`group\\s*:\\s*["']${dependency.group}["']\\s*,\\s*` +
|
`group\\s*:\\s*["']${dependency.group}["']\\s*,\\s*` +
|
||||||
|
@ -208,7 +214,7 @@ function moduleMapVariableVersionFormatMatch(dependency: GradleDependency) {
|
||||||
|
|
||||||
function moduleKotlinNamedArgumentVariableVersionFormatMatch(
|
function moduleKotlinNamedArgumentVariableVersionFormatMatch(
|
||||||
dependency: GradleDependency
|
dependency: GradleDependency
|
||||||
) {
|
): RegExp {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
return new RegExp(
|
return new RegExp(
|
||||||
`group\\s*=\\s*"${dependency.group}"\\s*,\\s*` +
|
`group\\s*=\\s*"${dependency.group}"\\s*,\\s*` +
|
||||||
|
@ -219,7 +225,7 @@ function moduleKotlinNamedArgumentVariableVersionFormatMatch(
|
||||||
|
|
||||||
function moduleStringVariableInterpolationVersionFormatMatch(
|
function moduleStringVariableInterpolationVersionFormatMatch(
|
||||||
dependency: GradleDependency
|
dependency: GradleDependency
|
||||||
) {
|
): RegExp {
|
||||||
return new RegExp(
|
return new RegExp(
|
||||||
`["']${dependency.group}:${dependency.name}:\\$([^{].*?)["']`
|
`["']${dependency.group}:${dependency.name}:\\$([^{].*?)["']`
|
||||||
);
|
);
|
||||||
|
@ -227,12 +233,12 @@ function moduleStringVariableInterpolationVersionFormatMatch(
|
||||||
|
|
||||||
function moduleStringVariableExpressionVersionFormatMatch(
|
function moduleStringVariableExpressionVersionFormatMatch(
|
||||||
dependency: GradleDependency
|
dependency: GradleDependency
|
||||||
) {
|
): RegExp {
|
||||||
return new RegExp(
|
return new RegExp(
|
||||||
`["']${dependency.group}:${dependency.name}:\\$\{([^{].*?)}["']`
|
`["']${dependency.group}:${dependency.name}:\\$\{([^{].*?)}["']`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function variableDefinitionFormatMatch(variable: string) {
|
function variableDefinitionFormatMatch(variable: string): RegExp {
|
||||||
return new RegExp(`(${variable}\\s*=\\s*?["'])(.*)(["'])`);
|
return new RegExp(`(${variable}\\s*=\\s*?["'])(.*)(["'])`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,9 @@ gradle.buildFinished {
|
||||||
await writeFile(gradleInitFile, content);
|
await writeFile(gradleInitFile, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function extractDependenciesFromUpdatesReport(localDir: string) {
|
async function extractDependenciesFromUpdatesReport(
|
||||||
|
localDir: string
|
||||||
|
): Promise<BuildDependency[]> {
|
||||||
const gradleProjectConfigurations = await readGradleReport(localDir);
|
const gradleProjectConfigurations = await readGradleReport(localDir);
|
||||||
|
|
||||||
const dependencies = gradleProjectConfigurations
|
const dependencies = gradleProjectConfigurations
|
||||||
|
@ -111,7 +113,7 @@ function mergeDependenciesWithRepositories(
|
||||||
function flatternDependencies(
|
function flatternDependencies(
|
||||||
accumulator: GradleDependencyWithRepos[],
|
accumulator: GradleDependencyWithRepos[],
|
||||||
currentValue: GradleDependencyWithRepos[]
|
currentValue: GradleDependencyWithRepos[]
|
||||||
) {
|
): GradleDependencyWithRepos[] {
|
||||||
accumulator.push(...currentValue);
|
accumulator.push(...currentValue);
|
||||||
return accumulator;
|
return accumulator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ const TIMEOUT_CODE = 143;
|
||||||
export async function extractAllPackageFiles(
|
export async function extractAllPackageFiles(
|
||||||
config: ExtractConfig,
|
config: ExtractConfig,
|
||||||
packageFiles: string[]
|
packageFiles: string[]
|
||||||
): Promise<PackageFile[]> {
|
): Promise<PackageFile[] | null> {
|
||||||
if (
|
if (
|
||||||
!packageFiles.some(packageFile =>
|
!packageFiles.some(packageFile =>
|
||||||
['build.gradle', 'build.gradle.kts'].includes(packageFile)
|
['build.gradle', 'build.gradle.kts'].includes(packageFile)
|
||||||
|
@ -117,7 +117,7 @@ async function executeGradle(config: ExtractConfig) {
|
||||||
logger.info('Gradle report complete');
|
logger.info('Gradle report complete');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getGradleCommandLine(config: ExtractConfig) {
|
async function getGradleCommandLine(config: ExtractConfig): Promise<string> {
|
||||||
let cmd: string;
|
let cmd: string;
|
||||||
const gradlewExists = await exists(config.localDir + '/gradlew');
|
const gradlewExists = await exists(config.localDir + '/gradlew');
|
||||||
if (config.binarySource === 'docker') {
|
if (config.binarySource === 'docker') {
|
||||||
|
@ -129,4 +129,5 @@ async function getGradleCommandLine(config: ExtractConfig) {
|
||||||
}
|
}
|
||||||
return cmd + ' ' + GRADLE_DEPENDENCY_REPORT_OPTIONS;
|
return cmd + ' ' + GRADLE_DEPENDENCY_REPORT_OPTIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const language = 'java';
|
export const language = 'java';
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { logger } from '../../logger';
|
||||||
import { PackageFile, PackageDependency } from '../common';
|
import { PackageFile, PackageDependency } from '../common';
|
||||||
|
|
||||||
// TODO: Maybe check if quotes/double-quotes are balanced
|
// TODO: Maybe check if quotes/double-quotes are balanced
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
logger.trace('extractPackageFile()');
|
logger.trace('extractPackageFile()');
|
||||||
/*
|
/*
|
||||||
1. match "class className < Formula"
|
1. match "class className < Formula"
|
||||||
|
@ -57,7 +57,7 @@ export function extractPackageFile(content: string): PackageFile {
|
||||||
return { deps };
|
return { deps };
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractSha256(content: string) {
|
function extractSha256(content: string): string | null {
|
||||||
const sha256RegExp = /(^|\s)sha256(\s)/;
|
const sha256RegExp = /(^|\s)sha256(\s)/;
|
||||||
let i = content.search(sha256RegExp);
|
let i = content.search(sha256RegExp);
|
||||||
if (isSpace(content[i])) {
|
if (isSpace(content[i])) {
|
||||||
|
@ -66,7 +66,7 @@ function extractSha256(content: string) {
|
||||||
return parseSha256(i, content);
|
return parseSha256(i, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseSha256(idx: number, content: string) {
|
function parseSha256(idx: number, content: string): string | null {
|
||||||
let i = idx;
|
let i = idx;
|
||||||
i += 'sha256'.length;
|
i += 'sha256'.length;
|
||||||
i = skip(i, content, c => {
|
i = skip(i, content, c => {
|
||||||
|
@ -84,7 +84,7 @@ function parseSha256(idx: number, content: string) {
|
||||||
return sha256;
|
return sha256;
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractUrl(content: string) {
|
function extractUrl(content: string): string | null {
|
||||||
const urlRegExp = /(^|\s)url(\s)/;
|
const urlRegExp = /(^|\s)url(\s)/;
|
||||||
let i = content.search(urlRegExp);
|
let i = content.search(urlRegExp);
|
||||||
// content.search() returns -1 if not found
|
// content.search() returns -1 if not found
|
||||||
|
@ -98,7 +98,13 @@ function extractUrl(content: string) {
|
||||||
return parseUrl(i, content);
|
return parseUrl(i, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseUrlPath(urlStr: string) {
|
export interface UrlPathParsedResult {
|
||||||
|
currentValue: string;
|
||||||
|
ownerName: string;
|
||||||
|
repoName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseUrlPath(urlStr: string): UrlPathParsedResult | null {
|
||||||
if (!urlStr) {
|
if (!urlStr) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +142,7 @@ export function parseUrlPath(urlStr: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseUrl(idx: number, content: string) {
|
function parseUrl(idx: number, content: string): string | null {
|
||||||
let i = idx;
|
let i = idx;
|
||||||
i += 'url'.length;
|
i += 'url'.length;
|
||||||
i = skip(i, content, c => {
|
i = skip(i, content, c => {
|
||||||
|
@ -155,7 +161,7 @@ function parseUrl(idx: number, content: string) {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractClassName(content: string) {
|
function extractClassName(content: string): string | null {
|
||||||
const classRegExp = /(^|\s)class\s/;
|
const classRegExp = /(^|\s)class\s/;
|
||||||
let i = content.search(classRegExp);
|
let i = content.search(classRegExp);
|
||||||
if (isSpace(content[i])) {
|
if (isSpace(content[i])) {
|
||||||
|
@ -166,7 +172,7 @@ function extractClassName(content: string) {
|
||||||
|
|
||||||
/* This function parses the "class className < Formula" header
|
/* This function parses the "class className < Formula" header
|
||||||
and returns the className and index of the character just after the header */
|
and returns the className and index of the character just after the header */
|
||||||
function parseClassHeader(idx: number, content: string) {
|
function parseClassHeader(idx: number, content: string): string | null {
|
||||||
let i = idx;
|
let i = idx;
|
||||||
i += 'class'.length;
|
i += 'class'.length;
|
||||||
i = skip(i, content, c => {
|
i = skip(i, content, c => {
|
||||||
|
|
|
@ -77,7 +77,11 @@ export async function updateDependency(
|
||||||
return newContent;
|
return newContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateUrl(content: string, oldUrl: string, newUrl: string) {
|
function updateUrl(
|
||||||
|
content: string,
|
||||||
|
oldUrl: string,
|
||||||
|
newUrl: string
|
||||||
|
): string | null {
|
||||||
const urlRegExp = /(^|\s)url(\s)/;
|
const urlRegExp = /(^|\s)url(\s)/;
|
||||||
let i = content.search(urlRegExp);
|
let i = content.search(urlRegExp);
|
||||||
if (i === -1) {
|
if (i === -1) {
|
||||||
|
@ -102,7 +106,11 @@ function updateUrl(content: string, oldUrl: string, newUrl: string) {
|
||||||
return newContent;
|
return newContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUrlTestContent(content: string, oldUrl: string, newUrl: string) {
|
function getUrlTestContent(
|
||||||
|
content: string,
|
||||||
|
oldUrl: string,
|
||||||
|
newUrl: string
|
||||||
|
): string {
|
||||||
const urlRegExp = /(^|\s)url(\s)/;
|
const urlRegExp = /(^|\s)url(\s)/;
|
||||||
const cleanContent = removeComments(content);
|
const cleanContent = removeComments(content);
|
||||||
let j = cleanContent.search(urlRegExp);
|
let j = cleanContent.search(urlRegExp);
|
||||||
|
@ -118,7 +126,7 @@ function replaceUrl(
|
||||||
content: string,
|
content: string,
|
||||||
oldUrl: string,
|
oldUrl: string,
|
||||||
newUrl: string
|
newUrl: string
|
||||||
) {
|
): string | null {
|
||||||
let i = idx;
|
let i = idx;
|
||||||
i += 'url'.length;
|
i += 'url'.length;
|
||||||
i = skip(i, content, c => isSpace(c));
|
i = skip(i, content, c => isSpace(c));
|
||||||
|
@ -132,7 +140,11 @@ function replaceUrl(
|
||||||
return newContent;
|
return newContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSha256(content: string, oldSha256: string, newSha256: string) {
|
function updateSha256(
|
||||||
|
content: string,
|
||||||
|
oldSha256: string,
|
||||||
|
newSha256: string
|
||||||
|
): string | null {
|
||||||
const sha256RegExp = /(^|\s)sha256(\s)/;
|
const sha256RegExp = /(^|\s)sha256(\s)/;
|
||||||
let i = content.search(sha256RegExp);
|
let i = content.search(sha256RegExp);
|
||||||
if (i === -1) {
|
if (i === -1) {
|
||||||
|
@ -161,7 +173,7 @@ function getSha256TestContent(
|
||||||
content: string,
|
content: string,
|
||||||
oldSha256: string,
|
oldSha256: string,
|
||||||
newSha256: string
|
newSha256: string
|
||||||
) {
|
): string | null {
|
||||||
const sha256RegExp = /(^|\s)sha256(\s)/;
|
const sha256RegExp = /(^|\s)sha256(\s)/;
|
||||||
const cleanContent = removeComments(content);
|
const cleanContent = removeComments(content);
|
||||||
let j = cleanContent.search(sha256RegExp);
|
let j = cleanContent.search(sha256RegExp);
|
||||||
|
@ -177,7 +189,7 @@ function replaceSha256(
|
||||||
content: string,
|
content: string,
|
||||||
oldSha256: string,
|
oldSha256: string,
|
||||||
newSha256: string
|
newSha256: string
|
||||||
) {
|
): string | null {
|
||||||
let i = idx;
|
let i = idx;
|
||||||
i += 'sha256'.length;
|
i += 'sha256'.length;
|
||||||
i = skip(i, content, c => isSpace(c));
|
i = skip(i, content, c => isSpace(c));
|
||||||
|
|
|
@ -2,7 +2,7 @@ export function skip(
|
||||||
idx: number,
|
idx: number,
|
||||||
content: string,
|
content: string,
|
||||||
cond: (s: string) => boolean
|
cond: (s: string) => boolean
|
||||||
) {
|
): number {
|
||||||
let i = idx;
|
let i = idx;
|
||||||
while (i < content.length) {
|
while (i < content.length) {
|
||||||
if (!cond(content[i])) {
|
if (!cond(content[i])) {
|
||||||
|
@ -13,18 +13,18 @@ export function skip(
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isSpace(c: string) {
|
export function isSpace(c: string): boolean {
|
||||||
return /\s/.test(c);
|
return /\s/.test(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeComments(content: string) {
|
export function removeComments(content: string): string {
|
||||||
let newContent = removeLineComments(content);
|
let newContent = removeLineComments(content);
|
||||||
newContent = removeMultiLineComments(newContent);
|
newContent = removeMultiLineComments(newContent);
|
||||||
return newContent;
|
return newContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove line comments starting with #
|
// Remove line comments starting with #
|
||||||
function removeLineComments(content: string) {
|
function removeLineComments(content: string): string {
|
||||||
let newContent = '';
|
let newContent = '';
|
||||||
let comment = false;
|
let comment = false;
|
||||||
for (let i = 0; i < content.length; i += 1) {
|
for (let i = 0; i < content.length; i += 1) {
|
||||||
|
@ -45,7 +45,7 @@ function removeLineComments(content: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove multi-line comments enclosed between =begin and =end
|
// Remove multi-line comments enclosed between =begin and =end
|
||||||
function removeMultiLineComments(content: string) {
|
function removeMultiLineComments(content: string): string {
|
||||||
const beginRegExp = /(^|\n)=begin\s/;
|
const beginRegExp = /(^|\n)=begin\s/;
|
||||||
const endRegExp = /(^|\n)=end\s/;
|
const endRegExp = /(^|\n)=end\s/;
|
||||||
let newContent = content;
|
let newContent = content;
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
import {
|
import {
|
||||||
ManagerApi,
|
|
||||||
ExtractConfig,
|
ExtractConfig,
|
||||||
RangeConfig,
|
ManagerApi,
|
||||||
|
PackageFile,
|
||||||
PackageUpdateConfig,
|
PackageUpdateConfig,
|
||||||
|
RangeConfig,
|
||||||
|
Result,
|
||||||
|
PackageUpdateResult,
|
||||||
} from './common';
|
} from './common';
|
||||||
|
import { RangeStrategy } from '../versioning';
|
||||||
|
|
||||||
const managerList = [
|
const managerList = [
|
||||||
'ansible',
|
'ansible',
|
||||||
|
@ -63,25 +67,25 @@ const languageList = [
|
||||||
|
|
||||||
export const get = <T extends keyof ManagerApi>(manager: string, name: T) =>
|
export const get = <T extends keyof ManagerApi>(manager: string, name: T) =>
|
||||||
managers[manager][name];
|
managers[manager][name];
|
||||||
export const getLanguageList = () => languageList;
|
export const getLanguageList = (): string[] => languageList;
|
||||||
export const getManagerList = () => managerList;
|
export const getManagerList = (): string[] => managerList;
|
||||||
|
|
||||||
export function extractAllPackageFiles(
|
export function extractAllPackageFiles(
|
||||||
manager: string,
|
manager: string,
|
||||||
config: ExtractConfig,
|
config: ExtractConfig,
|
||||||
files: string[]
|
files: string[]
|
||||||
) {
|
): Result<PackageFile[] | null> {
|
||||||
return managers[manager] && get(manager, 'extractAllPackageFiles')
|
return managers[manager] && managers[manager].extractAllPackageFiles
|
||||||
? get(manager, 'extractAllPackageFiles')(config, files)
|
? managers[manager].extractAllPackageFiles(config, files)
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPackageUpdates(
|
export function getPackageUpdates(
|
||||||
manager: string,
|
manager: string,
|
||||||
config: PackageUpdateConfig
|
config: PackageUpdateConfig
|
||||||
) {
|
): Result<PackageUpdateResult[]> | null {
|
||||||
return managers[manager] && get(manager, 'getPackageUpdates')
|
return managers[manager] && managers[manager].getPackageUpdates
|
||||||
? get(manager, 'getPackageUpdates')(config)
|
? managers[manager].getPackageUpdates(config)
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,13 +94,13 @@ export function extractPackageFile(
|
||||||
content: string,
|
content: string,
|
||||||
fileName?: string,
|
fileName?: string,
|
||||||
config?: ExtractConfig
|
config?: ExtractConfig
|
||||||
) {
|
): Result<PackageFile | null> {
|
||||||
return managers[manager] && get(manager, 'extractPackageFile')
|
return managers[manager] && managers[manager].extractPackageFile
|
||||||
? get(manager, 'extractPackageFile')(content, fileName, config)
|
? managers[manager].extractPackageFile(content, fileName, config)
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getRangeStrategy(config: RangeConfig) {
|
export function getRangeStrategy(config: RangeConfig): RangeStrategy {
|
||||||
const { manager, rangeStrategy } = config;
|
const { manager, rangeStrategy } = config;
|
||||||
if (managers[manager].getRangeStrategy) {
|
if (managers[manager].getRangeStrategy) {
|
||||||
// Use manager's own function if it exists
|
// Use manager's own function if it exists
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { logger } from '../../logger';
|
||||||
import { getDep } from '../dockerfile/extract';
|
import { getDep } from '../dockerfile/extract';
|
||||||
import { PackageFile, PackageDependency } from '../common';
|
import { PackageFile, PackageDependency } from '../common';
|
||||||
|
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
logger.trace('kubernetes.extractPackageFile()');
|
logger.trace('kubernetes.extractPackageFile()');
|
||||||
let deps: PackageDependency[] = [];
|
let deps: PackageDependency[] = [];
|
||||||
let lineNumber = 0;
|
let lineNumber = 0;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Upgrade } from '../common';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
const newFrom = getNewFrom(upgrade);
|
const newFrom = getNewFrom(upgrade);
|
||||||
logger.debug(`kubernetes.updateDependency(): ${newFrom}`);
|
logger.debug(`kubernetes.updateDependency(): ${newFrom}`);
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { PackageDependency, PackageFile } from '../common';
|
||||||
|
|
||||||
export const DEFAULT_CLOJARS_REPO = 'https://clojars.org/repo/';
|
export const DEFAULT_CLOJARS_REPO = 'https://clojars.org/repo/';
|
||||||
|
|
||||||
export function trimAtKey(str: string, kwName: string) {
|
export function trimAtKey(str: string, kwName: string): string | null {
|
||||||
const regex = new RegExp(`:${kwName}(?=\\s)`);
|
const regex = new RegExp(`:${kwName}(?=\\s)`);
|
||||||
const keyOffset = str.search(regex);
|
const keyOffset = str.search(regex);
|
||||||
if (keyOffset < 0) return null;
|
if (keyOffset < 0) return null;
|
||||||
|
@ -13,7 +13,7 @@ export function trimAtKey(str: string, kwName: string) {
|
||||||
return withSpaces.slice(valueOffset);
|
return withSpaces.slice(valueOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function expandDepName(name: string) {
|
export function expandDepName(name: string): string {
|
||||||
return name.indexOf('/') === -1 ? `${name}:${name}` : name.replace('/', ':');
|
return name.indexOf('/') === -1 ? `${name}:${name}` : name.replace('/', ':');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ export function extractFromVectors(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractLeinRepos(content: string) {
|
function extractLeinRepos(content: string): string[] {
|
||||||
const result = [DEFAULT_CLOJARS_REPO, DEFAULT_MAVEN_REPO];
|
const result = [DEFAULT_CLOJARS_REPO, DEFAULT_MAVEN_REPO];
|
||||||
|
|
||||||
const repoContent = trimAtKey(
|
const repoContent = trimAtKey(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { PackageFile, PackageDependency } from '../common';
|
import { PackageFile, PackageDependency } from '../common';
|
||||||
|
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
let deps: PackageDependency[] = [];
|
let deps: PackageDependency[] = [];
|
||||||
const npmDepends = content.match(/\nNpm\.depends\({([\s\S]*?)}\);/);
|
const npmDepends = content.match(/\nNpm\.depends\({([\s\S]*?)}\);/);
|
||||||
if (!npmDepends) {
|
if (!npmDepends) {
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { Upgrade } from '../common';
|
import { Upgrade } from '../common';
|
||||||
|
|
||||||
export function updateDependency(fileContent: string, upgrade: Upgrade) {
|
export function updateDependency(
|
||||||
|
fileContent: string,
|
||||||
|
upgrade: Upgrade
|
||||||
|
): string {
|
||||||
const { depName, currentValue, newValue } = upgrade;
|
const { depName, currentValue, newValue } = upgrade;
|
||||||
logger.debug(`meteor.updateDependency(): ${depName} = ${newValue}`);
|
logger.debug(`meteor.updateDependency(): ${depName} = ${newValue}`);
|
||||||
const regexReplace = new RegExp(
|
const regexReplace = new RegExp(
|
||||||
|
|
|
@ -44,7 +44,7 @@ export async function extractPackageFile(
|
||||||
content: string,
|
content: string,
|
||||||
fileName: string,
|
fileName: string,
|
||||||
config: ExtractConfig
|
config: ExtractConfig
|
||||||
): Promise<PackageFile> {
|
): Promise<PackageFile | null> {
|
||||||
logger.trace(`npm.extractPackageFile(${fileName})`);
|
logger.trace(`npm.extractPackageFile(${fileName})`);
|
||||||
logger.trace({ content });
|
logger.trace({ content });
|
||||||
const deps: PackageDependency[] = [];
|
const deps: PackageDependency[] = [];
|
||||||
|
|
|
@ -6,7 +6,7 @@ import upath from 'upath';
|
||||||
import { logger } from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
import { PackageFile } from '../../common';
|
import { PackageFile } from '../../common';
|
||||||
|
|
||||||
function matchesAnyPattern(val: string, patterns: string[]) {
|
function matchesAnyPattern(val: string, patterns: string[]): boolean {
|
||||||
const res = patterns.some(
|
const res = patterns.some(
|
||||||
pattern => pattern === val + '/' || minimatch(val, pattern, { dot: true })
|
pattern => pattern === val + '/' || minimatch(val, pattern, { dot: true })
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { NpmPackage } from './common';
|
import { NpmPackage } from './common';
|
||||||
|
|
||||||
export function mightBeABrowserLibrary(packageJson: NpmPackage) {
|
export function mightBeABrowserLibrary(packageJson: NpmPackage): boolean {
|
||||||
// return true unless we're sure it's not a browser library
|
// return true unless we're sure it's not a browser library
|
||||||
if (packageJson.private === true) {
|
if (packageJson.private === true) {
|
||||||
// it's not published
|
// it's not published
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { Upgrade } from '../common';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
const { depType, depName } = upgrade;
|
const { depType, depName } = upgrade;
|
||||||
let { newValue } = upgrade;
|
let { newValue } = upgrade;
|
||||||
if (upgrade.currentRawValue) {
|
if (upgrade.currentRawValue) {
|
||||||
|
@ -137,7 +137,7 @@ export function updateDependency(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if the match string is found at index in content
|
// Return true if the match string is found at index in content
|
||||||
function matchAt(content: string, index: number, match: string) {
|
function matchAt(content: string, index: number, match: string): boolean {
|
||||||
return content.substring(index, index + match.length) === match;
|
return content.substring(index, index + match.length) === match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ function replaceAt(
|
||||||
index: number,
|
index: number,
|
||||||
oldString: string,
|
oldString: string,
|
||||||
newString: string
|
newString: string
|
||||||
) {
|
): string {
|
||||||
logger.debug(`Replacing ${oldString} with ${newString} at index ${index}`);
|
logger.debug(`Replacing ${oldString} with ${newString} at index ${index}`);
|
||||||
return (
|
return (
|
||||||
content.substr(0, index) +
|
content.substr(0, index) +
|
||||||
|
@ -160,7 +160,7 @@ export function bumpPackageVersion(
|
||||||
content: string,
|
content: string,
|
||||||
currentValue: string,
|
currentValue: string,
|
||||||
bumpVersion: ReleaseType | string
|
bumpVersion: ReleaseType | string
|
||||||
) {
|
): string {
|
||||||
logger.debug('bumpVersion()');
|
logger.debug('bumpVersion()');
|
||||||
if (!bumpVersion) {
|
if (!bumpVersion) {
|
||||||
return content;
|
return content;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Upgrade } from '../common';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
logger.debug(`nuget.updateDependency(): ${upgrade.newFrom}`);
|
logger.debug(`nuget.updateDependency(): ${upgrade.newFrom}`);
|
||||||
const lines = fileContent.split('\n');
|
const lines = fileContent.split('\n');
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { Upgrade } from '../common';
|
import { Upgrade } from '../common';
|
||||||
|
|
||||||
export function updateDependency(_fileContent: string, upgrade: Upgrade) {
|
export function updateDependency(
|
||||||
|
_fileContent: string,
|
||||||
|
upgrade: Upgrade
|
||||||
|
): string {
|
||||||
logger.debug(`nvm.updateDependency(): ${upgrade.newVersion}`);
|
logger.debug(`nvm.updateDependency(): ${upgrade.newVersion}`);
|
||||||
return `${upgrade.newValue}\n`;
|
return `${upgrade.newValue}\n`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ export function extractPackageFile(
|
||||||
content: string,
|
content: string,
|
||||||
_: string,
|
_: string,
|
||||||
config: ExtractConfig
|
config: ExtractConfig
|
||||||
) {
|
): PackageFile | null {
|
||||||
logger.trace('pip_requirements.extractPackageFile()');
|
logger.trace('pip_requirements.extractPackageFile()');
|
||||||
|
|
||||||
let indexUrl: string;
|
let indexUrl: string;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Upgrade } from '../common';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
logger.debug(`pip_requirements.updateDependency(): ${upgrade.newValue}`);
|
logger.debug(`pip_requirements.updateDependency(): ${upgrade.newValue}`);
|
||||||
const lines = fileContent.split('\n');
|
const lines = fileContent.split('\n');
|
||||||
|
|
|
@ -6,14 +6,14 @@ import { dependencyPattern } from '../pip_requirements/extract';
|
||||||
import { ExtractConfig, PackageFile, PackageDependency } from '../common';
|
import { ExtractConfig, PackageFile, PackageDependency } from '../common';
|
||||||
|
|
||||||
export const pythonVersions = ['python', 'python3', 'python3.7'];
|
export const pythonVersions = ['python', 'python3', 'python3.7'];
|
||||||
let pythonAlias: string = null;
|
let pythonAlias: string | null = null;
|
||||||
|
|
||||||
export function parsePythonVersion(str: string) {
|
export function parsePythonVersion(str: string): number[] {
|
||||||
const arr = str.split(' ')[1].split('.');
|
const arr = str.split(' ')[1].split('.');
|
||||||
return [parseInt(arr[0], 10), parseInt(arr[1], 10)];
|
return [parseInt(arr[0], 10), parseInt(arr[1], 10)];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPythonAlias() {
|
export async function getPythonAlias(): Promise<string> {
|
||||||
if (pythonAlias) {
|
if (pythonAlias) {
|
||||||
return pythonAlias;
|
return pythonAlias;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ export async function extractPackageFile(
|
||||||
content: string,
|
content: string,
|
||||||
packageFile: string,
|
packageFile: string,
|
||||||
config: ExtractConfig
|
config: ExtractConfig
|
||||||
): Promise<PackageFile> {
|
): Promise<PackageFile | null> {
|
||||||
logger.debug('pip_setup.extractPackageFile()');
|
logger.debug('pip_setup.extractPackageFile()');
|
||||||
let setup: PythonSetup;
|
let setup: PythonSetup;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -10,7 +10,7 @@ export async function updateArtifacts(
|
||||||
_updatedDeps: string[],
|
_updatedDeps: string[],
|
||||||
newPipfileContent: string,
|
newPipfileContent: string,
|
||||||
config: UpdateArtifactsConfig
|
config: UpdateArtifactsConfig
|
||||||
): Promise<UpdateArtifactsResult[]> {
|
): Promise<UpdateArtifactsResult[] | null> {
|
||||||
logger.debug(`pipenv.updateArtifacts(${pipfileName})`);
|
logger.debug(`pipenv.updateArtifacts(${pipfileName})`);
|
||||||
process.env.PIPENV_CACHE_DIR =
|
process.env.PIPENV_CACHE_DIR =
|
||||||
process.env.PIPENV_CACHE_DIR || join(config.cacheDir, './others/pipenv');
|
process.env.PIPENV_CACHE_DIR || join(config.cacheDir, './others/pipenv');
|
||||||
|
|
|
@ -33,7 +33,7 @@ interface PipRequirement {
|
||||||
git?: string;
|
git?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
logger.debug('pipenv.extractPackageFile()');
|
logger.debug('pipenv.extractPackageFile()');
|
||||||
|
|
||||||
let pipfile: PipFile;
|
let pipfile: PipFile;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { logger } from '../../logger';
|
||||||
import { Upgrade } from '../common';
|
import { Upgrade } from '../common';
|
||||||
|
|
||||||
// Return true if the match string is found at index in content
|
// Return true if the match string is found at index in content
|
||||||
function matchAt(content: string, index: number, match: string) {
|
function matchAt(content: string, index: number, match: string): boolean {
|
||||||
return content.substring(index, index + match.length) === match;
|
return content.substring(index, index + match.length) === match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ function replaceAt(
|
||||||
index: number,
|
index: number,
|
||||||
oldString: string,
|
oldString: string,
|
||||||
newString: string
|
newString: string
|
||||||
) {
|
): string {
|
||||||
logger.debug(`Replacing ${oldString} with ${newString} at index ${index}`);
|
logger.debug(`Replacing ${oldString} with ${newString} at index ${index}`);
|
||||||
return (
|
return (
|
||||||
content.substr(0, index) +
|
content.substr(0, index) +
|
||||||
|
@ -26,7 +26,7 @@ function replaceAt(
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
const { depType, depName, newValue, managerData = {} } = upgrade;
|
const { depType, depName, newValue, managerData = {} } = upgrade;
|
||||||
const { nestedVersion } = managerData;
|
const { nestedVersion } = managerData;
|
||||||
|
|
|
@ -11,7 +11,7 @@ export async function updateArtifacts(
|
||||||
updatedDeps: string[],
|
updatedDeps: string[],
|
||||||
newPackageFileContent: string,
|
newPackageFileContent: string,
|
||||||
config: UpdateArtifactsConfig
|
config: UpdateArtifactsConfig
|
||||||
): Promise<UpdateArtifactsResult[]> {
|
): Promise<UpdateArtifactsResult[] | null> {
|
||||||
await logger.debug(`poetry.updateArtifacts(${packageFileName})`);
|
await logger.debug(`poetry.updateArtifacts(${packageFileName})`);
|
||||||
if (updatedDeps === undefined || updatedDeps.length < 1) {
|
if (updatedDeps === undefined || updatedDeps.length < 1) {
|
||||||
logger.debug('No updated poetry deps - returning null');
|
logger.debug('No updated poetry deps - returning null');
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { PoetryFile, PoetrySection } from './types';
|
||||||
export function extractPackageFile(
|
export function extractPackageFile(
|
||||||
content: string,
|
content: string,
|
||||||
fileName: string
|
fileName: string
|
||||||
): PackageFile {
|
): PackageFile | null {
|
||||||
logger.trace(`poetry.extractPackageFile(${fileName})`);
|
logger.trace(`poetry.extractPackageFile(${fileName})`);
|
||||||
let pyprojectfile: PoetryFile;
|
let pyprojectfile: PoetryFile;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { PoetryFile } from './types';
|
||||||
|
|
||||||
// TODO: Maybe factor out common code from pipenv.updateDependency and poetry.updateDependency
|
// TODO: Maybe factor out common code from pipenv.updateDependency and poetry.updateDependency
|
||||||
// Return true if the match string is found at index in content
|
// Return true if the match string is found at index in content
|
||||||
function matchAt(content: string, index: number, match: string) {
|
function matchAt(content: string, index: number, match: string): boolean {
|
||||||
return content.substring(index, index + match.length) === match;
|
return content.substring(index, index + match.length) === match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ function replaceAt(
|
||||||
index: number,
|
index: number,
|
||||||
oldString: string,
|
oldString: string,
|
||||||
newString: string
|
newString: string
|
||||||
) {
|
): string {
|
||||||
logger.debug(`Replacing ${oldString} with ${newString} at index ${index}`);
|
logger.debug(`Replacing ${oldString} with ${newString} at index ${index}`);
|
||||||
return (
|
return (
|
||||||
content.substr(0, index) +
|
content.substr(0, index) +
|
||||||
|
@ -28,7 +28,7 @@ function replaceAt(
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade<{ nestedVersion?: boolean }>
|
upgrade: Upgrade<{ nestedVersion?: boolean }>
|
||||||
): string {
|
): string | null {
|
||||||
logger.trace({ config: upgrade }, 'poetry.updateDependency()');
|
logger.trace({ config: upgrade }, 'poetry.updateDependency()');
|
||||||
if (!upgrade) {
|
if (!upgrade) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -34,7 +34,7 @@ function getDeps(
|
||||||
export function extractPackageFile(
|
export function extractPackageFile(
|
||||||
content: string,
|
content: string,
|
||||||
packageFile: string
|
packageFile: string
|
||||||
): PackageFile {
|
): PackageFile | null {
|
||||||
try {
|
try {
|
||||||
const doc = safeLoad(content);
|
const doc = safeLoad(content);
|
||||||
const deps = [
|
const deps = [
|
||||||
|
|
|
@ -52,7 +52,10 @@ interface ParseContext {
|
||||||
depType?: string;
|
depType?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseDepExpr(expr: string, ctx: ParseContext) {
|
function parseDepExpr(
|
||||||
|
expr: string,
|
||||||
|
ctx: ParseContext
|
||||||
|
): PackageDependency | null {
|
||||||
const { scalaVersion, fileOffset, variables } = ctx;
|
const { scalaVersion, fileOffset, variables } = ctx;
|
||||||
let { depType } = ctx;
|
let { depType } = ctx;
|
||||||
|
|
||||||
|
@ -139,7 +142,7 @@ function parseSbtLine(
|
||||||
line: string,
|
line: string,
|
||||||
lineIndex: number,
|
lineIndex: number,
|
||||||
lines: string[]
|
lines: string[]
|
||||||
): PackageFile & ParseOptions {
|
): (PackageFile & ParseOptions) | null {
|
||||||
const { deps, registryUrls, fileOffset, variables } = acc;
|
const { deps, registryUrls, fileOffset, variables } = acc;
|
||||||
|
|
||||||
let { isMultiDeps, scalaVersion } = acc;
|
let { isMultiDeps, scalaVersion } = acc;
|
||||||
|
|
|
@ -47,7 +47,7 @@ const searchLabels = {
|
||||||
exactVersion: EXACT_VERSION,
|
exactVersion: EXACT_VERSION,
|
||||||
};
|
};
|
||||||
|
|
||||||
function searchKeysForState(state) {
|
function searchKeysForState(state): string[] {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 'dependencies':
|
case 'dependencies':
|
||||||
return [SPACE, COLON, WILDCARD];
|
return [SPACE, COLON, WILDCARD];
|
||||||
|
@ -94,7 +94,7 @@ interface MatchResult {
|
||||||
substr: string;
|
substr: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMatch(str: string, state: string): MatchResult {
|
function getMatch(str: string, state: string): MatchResult | null {
|
||||||
const keys = searchKeysForState(state);
|
const keys = searchKeysForState(state);
|
||||||
let result = null;
|
let result = null;
|
||||||
for (let i = 0; i < keys.length; i += 1) {
|
for (let i = 0; i < keys.length; i += 1) {
|
||||||
|
@ -117,7 +117,7 @@ function getMatch(str: string, state: string): MatchResult {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDepName(url: string) {
|
function getDepName(url: string): string | null {
|
||||||
try {
|
try {
|
||||||
const { host, pathname } = new URL(url);
|
const { host, pathname } = new URL(url);
|
||||||
if (host === 'github.com' || host === 'gitlab.com') {
|
if (host === 'github.com' || host === 'gitlab.com') {
|
||||||
|
@ -135,7 +135,7 @@ function getDepName(url: string) {
|
||||||
export function extractPackageFile(
|
export function extractPackageFile(
|
||||||
content: string,
|
content: string,
|
||||||
packageFile: string = null
|
packageFile: string = null
|
||||||
): PackageFile {
|
): PackageFile | null {
|
||||||
if (!content) return null;
|
if (!content) return null;
|
||||||
|
|
||||||
const result: PackageFile = {
|
const result: PackageFile = {
|
||||||
|
|
|
@ -6,7 +6,7 @@ const fromParam = /^\s*from\s*:\s*"([^"]+)"\s*$/;
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
const { currentValue, newValue, fileReplacePosition } = upgrade;
|
const { currentValue, newValue, fileReplacePosition } = upgrade;
|
||||||
const leftPart = fileContent.slice(0, fileReplacePosition);
|
const leftPart = fileContent.slice(0, fileReplacePosition);
|
||||||
const rightPart = fileContent.slice(fileReplacePosition);
|
const rightPart = fileContent.slice(fileReplacePosition);
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { logger } from '../../logger';
|
||||||
import { isValid, isVersion } from '../../versioning/hashicorp';
|
import { isValid, isVersion } from '../../versioning/hashicorp';
|
||||||
import { PackageDependency, PackageFile } from '../common';
|
import { PackageDependency, PackageFile } from '../common';
|
||||||
|
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
logger.trace({ content }, 'terraform.extractPackageFile()');
|
logger.trace({ content }, 'terraform.extractPackageFile()');
|
||||||
if (!content.includes('module "')) {
|
if (!content.includes('module "')) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Upgrade } from '../common';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
currentFileContent: string,
|
currentFileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
logger.debug(`terraform.updateDependency: ${upgrade.newValue}`);
|
logger.debug(`terraform.updateDependency: ${upgrade.newValue}`);
|
||||||
const lines = currentFileContent.split('\n');
|
const lines = currentFileContent.split('\n');
|
||||||
|
|
|
@ -3,7 +3,7 @@ import yaml from 'js-yaml';
|
||||||
import { PackageFile, PackageDependency } from '../common';
|
import { PackageFile, PackageDependency } from '../common';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
|
|
||||||
export function extractPackageFile(content: string): PackageFile {
|
export function extractPackageFile(content: string): PackageFile | null {
|
||||||
let doc;
|
let doc;
|
||||||
try {
|
try {
|
||||||
doc = yaml.safeLoad(content);
|
doc = yaml.safeLoad(content);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { logger } from '../../logger';
|
||||||
export function updateDependency(
|
export function updateDependency(
|
||||||
fileContent: string,
|
fileContent: string,
|
||||||
upgrade: Upgrade
|
upgrade: Upgrade
|
||||||
): string {
|
): string | null {
|
||||||
try {
|
try {
|
||||||
logger.debug(`travis.updateDependency(): ${upgrade.newValue}`);
|
logger.debug(`travis.updateDependency(): ${upgrade.newValue}`);
|
||||||
const indent = detectIndent(fileContent).indent || ' ';
|
const indent = detectIndent(fileContent).indent || ' ';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`lib/manager/node/package getPackageUpdates detects pinning 1`] = `
|
exports[`lib/manager/travis/package getPackageUpdates detects pinning 1`] = `
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"isRange": true,
|
"isRange": true,
|
||||||
|
@ -14,7 +14,7 @@ Array [
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lib/manager/node/package getPackageUpdates returns result if needing updates 1`] = `
|
exports[`lib/manager/travis/package getPackageUpdates returns result if needing updates 1`] = `
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"isRange": true,
|
"isRange": true,
|
||||||
|
|
|
@ -7,7 +7,7 @@ const getPkgReleases: any = _getPkgReleases;
|
||||||
|
|
||||||
jest.mock('../../../lib/datasource/github');
|
jest.mock('../../../lib/datasource/github');
|
||||||
|
|
||||||
describe('lib/manager/node/package', () => {
|
describe('lib/manager/travis/package', () => {
|
||||||
describe('getPackageUpdates', () => {
|
describe('getPackageUpdates', () => {
|
||||||
// TODO: should be `PackageUpdateConfig`
|
// TODO: should be `PackageUpdateConfig`
|
||||||
let config: any;
|
let config: any;
|
||||||
|
|
Loading…
Reference in a new issue