diff --git a/packages/backend-common/src/reading/BitbucketUrlReader.ts b/packages/backend-common/src/reading/BitbucketUrlReader.ts index 4367424423..4578436521 100644 --- a/packages/backend-common/src/reading/BitbucketUrlReader.ts +++ b/packages/backend-common/src/reading/BitbucketUrlReader.ts @@ -23,7 +23,7 @@ import { readBitbucketIntegrationConfigs, } from '@backstage/integration'; import fetch from 'cross-fetch'; -import parseGitUri from 'git-url-parse'; +import parseGitUrl from 'git-url-parse'; import { Readable } from 'stream'; import { NotFoundError } from '../errors'; import { ReadTreeResponseFactory } from './tree'; @@ -101,8 +101,9 @@ export class BitbucketUrlReader implements UrlReader { url: string, options?: ReadTreeOptions, ): Promise { - const gitUrl: parseGitUri.GitUrl = parseGitUri(url); - const { name: repoName, owner: project, resource, filepath } = gitUrl; + const { name: repoName, owner: project, resource, filepath } = parseGitUrl( + url, + ); const isHosted = resource === 'bitbucket.org'; @@ -142,7 +143,7 @@ export class BitbucketUrlReader implements UrlReader { } private async getLastCommitShortHash(url: string): Promise { - const { name: repoName, owner: project, ref } = parseGitUri(url); + const { name: repoName, owner: project, ref } = parseGitUrl(url); let branch = ref; if (!branch) { diff --git a/packages/backend-common/src/reading/GithubUrlReader.ts b/packages/backend-common/src/reading/GithubUrlReader.ts index 5ca2a99692..27167f4242 100644 --- a/packages/backend-common/src/reading/GithubUrlReader.ts +++ b/packages/backend-common/src/reading/GithubUrlReader.ts @@ -21,7 +21,7 @@ import { getGitHubRequestOptions, } from '@backstage/integration'; import fetch from 'cross-fetch'; -import parseGitUri from 'git-url-parse'; +import parseGitUrl from 'git-url-parse'; import { Readable } from 'stream'; import { InputError, NotFoundError } from '../errors'; import { ReadTreeResponseFactory } from './tree'; @@ -92,7 +92,7 @@ export class GithubUrlReader implements UrlReader { resource, full_name, filepath, - } = parseGitUri(url); + } = parseGitUrl(url); if (!ref) { // TODO(Rugvip): We should add support for defaulting to the default branch diff --git a/packages/backend-common/src/reading/GitlabUrlReader.ts b/packages/backend-common/src/reading/GitlabUrlReader.ts index d51e8dc090..299bbc783b 100644 --- a/packages/backend-common/src/reading/GitlabUrlReader.ts +++ b/packages/backend-common/src/reading/GitlabUrlReader.ts @@ -29,7 +29,7 @@ import { ReadTreeResponse, UrlReader, } from './types'; -import parseGitUri from 'git-url-parse'; +import parseGitUrl from 'git-url-parse'; import { Readable } from 'stream'; export class GitlabUrlReader implements UrlReader { @@ -85,7 +85,7 @@ export class GitlabUrlReader implements UrlReader { resource, full_name, filepath, - } = parseGitUri(url); + } = parseGitUrl(url); if (!ref) { throw new InputError( diff --git a/plugins/catalog-backend/src/ingestion/LocationAnalyzer.ts b/plugins/catalog-backend/src/ingestion/LocationAnalyzer.ts index 97df326fc5..bc81cf14f8 100644 --- a/plugins/catalog-backend/src/ingestion/LocationAnalyzer.ts +++ b/plugins/catalog-backend/src/ingestion/LocationAnalyzer.ts @@ -15,7 +15,7 @@ */ import { Logger } from 'winston'; -import parseGitUri from 'git-url-parse'; +import parseGitUrl from 'git-url-parse'; import { AnalyzeLocationRequest, AnalyzeLocationResponse, @@ -31,7 +31,7 @@ export class RepoLocationAnalyzer implements LocationAnalyzer { async analyzeLocation( request: AnalyzeLocationRequest, ): Promise { - const { owner, name, source } = parseGitUri(request.location.target); + const { owner, name, source } = parseGitUrl(request.location.target); const entity = { apiVersion: 'backstage.io/v1alpha1', kind: 'Component', diff --git a/plugins/catalog-backend/src/ingestion/processors/CodeOwnersProcessor.ts b/plugins/catalog-backend/src/ingestion/processors/CodeOwnersProcessor.ts index e2b8a8b62c..e1d7e22ccf 100644 --- a/plugins/catalog-backend/src/ingestion/processors/CodeOwnersProcessor.ts +++ b/plugins/catalog-backend/src/ingestion/processors/CodeOwnersProcessor.ts @@ -20,7 +20,7 @@ import * as codeowners from 'codeowners-utils'; import { CodeOwnersEntry } from 'codeowners-utils'; // NOTE: This can be removed when ES2021 is implemented import 'core-js/features/promise'; -import parseGitUri from 'git-url-parse'; +import parseGitUrl from 'git-url-parse'; import { filter, get, head, pipe, reverse } from 'lodash/fp'; import { Logger } from 'winston'; import { CatalogProcessor } from './types'; @@ -123,7 +123,7 @@ export function buildCodeOwnerUrl( basePath: string, codeOwnersPath: string, ): string { - return buildUrl({ ...parseGitUri(basePath), codeOwnersPath }); + return buildUrl({ ...parseGitUrl(basePath), codeOwnersPath }); } export function parseCodeOwners(ownersText: string) { diff --git a/plugins/catalog-import/src/util/urls.ts b/plugins/catalog-import/src/util/urls.ts index d142263734..c51dc0a999 100644 --- a/plugins/catalog-import/src/util/urls.ts +++ b/plugins/catalog-import/src/util/urls.ts @@ -14,12 +14,12 @@ * limitations under the License. */ -import parseGitUri from 'git-url-parse'; +import parseGitUrl from 'git-url-parse'; export type UrlType = 'file' | 'tree'; export function urlType(url: string): UrlType { - const { filepathtype, filepath } = parseGitUri(url); + const { filepathtype, filepath } = parseGitUrl(url); if (filepathtype === 'tree' || filepathtype === 'file') { return filepathtype; diff --git a/plugins/catalog-import/src/util/useGithubRepos.ts b/plugins/catalog-import/src/util/useGithubRepos.ts index 30e77e18a8..89448a1be1 100644 --- a/plugins/catalog-import/src/util/useGithubRepos.ts +++ b/plugins/catalog-import/src/util/useGithubRepos.ts @@ -18,7 +18,7 @@ import * as YAML from 'yaml'; import { useApi, configApiRef } from '@backstage/core'; import { catalogImportApiRef } from '../api/CatalogImportApi'; import { ConfigSpec } from '../components/ImportComponentPage'; -import parseGitUri from 'git-url-parse'; +import parseGitUrl from 'git-url-parse'; // TODO: (O5ten) Refactor into a core API instead of direct usage like this // https://github.com/backstage/backstage/pull/3613#issuecomment-7408929430 @@ -33,7 +33,7 @@ export function useGithubRepos() { name: repoName, owner: ownerName, resource: hostname, - } = parseGitUri(selectedRepo.location); + } = parseGitUrl(selectedRepo.location); const configs = readGitHubIntegrationConfigs( config.getOptionalConfigArray('integrations.github') ?? [], diff --git a/plugins/catalog/src/components/createEditLink.ts b/plugins/catalog/src/components/createEditLink.ts index cc04d605f1..57fc876704 100644 --- a/plugins/catalog/src/components/createEditLink.ts +++ b/plugins/catalog/src/components/createEditLink.ts @@ -15,7 +15,7 @@ */ import { LocationSpec } from '@backstage/catalog-model'; -import gitUrlParse from 'git-url-parse'; +import parseGitUrl from 'git-url-parse'; /** * Creates the edit link for components yaml file @@ -26,7 +26,7 @@ import gitUrlParse from 'git-url-parse'; export const createEditLink = (location: LocationSpec): string | undefined => { try { - const urlData = gitUrlParse(location.target); + const urlData = parseGitUrl(location.target); const url = new URL(location.target); switch (location.type) { case 'github': @@ -64,7 +64,7 @@ export const createEditLink = (location: LocationSpec): string | undefined => { * @returns string representing type of icon to be used */ export const determineUrlType = (url: string): string => { - const urlData = gitUrlParse(url); + const urlData = parseGitUrl(url); if (urlData.source === 'github.com') { return 'github'; diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/azure.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/azure.ts index a38c5f4fdc..51763c6291 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/azure.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/azure.ts @@ -20,7 +20,7 @@ import { TemplateEntityV1alpha1 } from '@backstage/catalog-model'; import { parseLocationAnnotation } from '../helpers'; import { InputError, Git } from '@backstage/backend-common'; import { PreparerBase, PreparerOptions } from './types'; -import GitUriParser from 'git-url-parse'; +import parseGitUrl from 'git-url-parse'; import { Config } from '@backstage/config'; export class AzurePreparer implements PreparerBase { @@ -46,7 +46,7 @@ export class AzurePreparer implements PreparerBase { } const templateId = template.metadata.name; - const parsedGitLocation = GitUriParser(location); + const parsedGitLocation = parseGitUrl(location); const repositoryCheckoutUrl = parsedGitLocation.toString('https'); const tempDir = await fs.promises.mkdtemp( path.join(workingDirectory, templateId), diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/bitbucket.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/bitbucket.ts index 5b244d24ce..278b481da2 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/bitbucket.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/bitbucket.ts @@ -20,7 +20,7 @@ import { TemplateEntityV1alpha1 } from '@backstage/catalog-model'; import { parseLocationAnnotation } from '../helpers'; import { InputError, Git } from '@backstage/backend-common'; import { PreparerBase, PreparerOptions } from './types'; -import GitUriParser from 'git-url-parse'; +import parseGitUrl from 'git-url-parse'; import { Config } from '@backstage/config'; export class BitbucketPreparer implements PreparerBase { @@ -49,7 +49,7 @@ export class BitbucketPreparer implements PreparerBase { } const templateId = template.metadata.name; - const repo = GitUriParser(location); + const repo = parseGitUrl(location); const repositoryCheckoutUrl = repo.toString('https'); const tempDir = await fs.promises.mkdtemp( diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.ts index e7fa0c9b72..c157263894 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.ts @@ -20,7 +20,7 @@ import { TemplateEntityV1alpha1 } from '@backstage/catalog-model'; import { parseLocationAnnotation } from '../helpers'; import { InputError, Git } from '@backstage/backend-common'; import { PreparerBase, PreparerOptions } from './types'; -import GitUriParser from 'git-url-parse'; +import parseGitUrl from 'git-url-parse'; export class GithubPreparer implements PreparerBase { token?: string; @@ -44,7 +44,7 @@ export class GithubPreparer implements PreparerBase { } const templateId = template.metadata.name; - const parsedGitLocation = GitUriParser(location); + const parsedGitLocation = parseGitUrl(location); const repositoryCheckoutUrl = parsedGitLocation.toString('https'); const tempDir = await fs.promises.mkdtemp( path.join(workingDirectory, templateId), diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/gitlab.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/gitlab.ts index 6e169baa98..9b0d468431 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/gitlab.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/gitlab.ts @@ -21,7 +21,7 @@ import { readGitLabIntegrationConfigs, } from '@backstage/integration'; import fs from 'fs-extra'; -import GitUriParser from 'git-url-parse'; +import parseGitUrl from 'git-url-parse'; import os from 'os'; import path from 'path'; import { parseLocationAnnotation } from '../helpers'; @@ -55,7 +55,7 @@ export class GitlabPreparer implements PreparerBase { } const templateId = template.metadata.name; - const parsedGitLocation = GitUriParser(location); + const parsedGitLocation = parseGitUrl(location); const repositoryCheckoutUrl = parsedGitLocation.toString('https'); const tempDir = await fs.promises.mkdtemp( path.join(workingDirectory, templateId),