Merge pull request #4100 from backstage/freben/parseGitUrl
chore: consistent naming of parseGitUrl
This commit is contained in:
@@ -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<AnalyzeLocationResponse> {
|
||||
const { owner, name, source } = parseGitUri(request.location.target);
|
||||
const { owner, name, source } = parseGitUrl(request.location.target);
|
||||
const entity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'Component',
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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') ?? [],
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user