Merge branch 'master' into camilaibs/migrate-catalog-graph-to-new-frontend-system
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -19,8 +19,12 @@ app:
|
||||
- entity-card:catalog-graph/relations:
|
||||
config:
|
||||
height: 300
|
||||
- entity-card:azure-devops/readme
|
||||
# Entity page content
|
||||
- entity-content:techdocs
|
||||
- entity-content:azure-devops/pipelines
|
||||
- entity-content:azure-devops/pull-requests
|
||||
- entity-content:azure-devops/git-tags
|
||||
|
||||
# scmAuthExtension: >-
|
||||
# createScmAuthExtension({
|
||||
|
||||
Vendored
+16
@@ -67,6 +67,22 @@ export interface Config {
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* An absolute path to a directory that can be used as a working dir, for
|
||||
* example as scratch space for large operations.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Note that this must be an absolute path.
|
||||
*
|
||||
* If not set, the operating system's designated temporary directory is
|
||||
* commonly used, but that is implementation defined per plugin.
|
||||
*
|
||||
* Plugins are encouraged to heed this config setting if present, to allow
|
||||
* deployment in severely locked-down or limited environments.
|
||||
*/
|
||||
workingDirectory?: string;
|
||||
|
||||
/** Database connection configuration, select base database type using the `client` field */
|
||||
database: {
|
||||
/** Default database client to use */
|
||||
|
||||
@@ -223,6 +223,27 @@ describe('FetchUrlReader', () => {
|
||||
).rejects.toThrow(NotModifiedError);
|
||||
});
|
||||
|
||||
it('should send Authorization header if token is provided', async () => {
|
||||
expect.assertions(1);
|
||||
|
||||
worker.use(
|
||||
rest.get(
|
||||
'https://backstage.io/requires-authentication',
|
||||
(req, res, ctx) => {
|
||||
expect(req.headers.get('authorization')).toBe('Bearer mytoken');
|
||||
return res(ctx.status(200));
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
await fetchUrlReader.readUrl(
|
||||
'https://backstage.io/requires-authentication',
|
||||
{
|
||||
token: 'mytoken',
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('should return etag from the response', async () => {
|
||||
const response = await fetchUrlReader.readUrl(
|
||||
'https://backstage.io/some-resource',
|
||||
|
||||
@@ -131,6 +131,7 @@ export class FetchUrlReader implements UrlReader {
|
||||
...(options?.lastModifiedAfter && {
|
||||
'If-Modified-Since': options.lastModifiedAfter.toUTCString(),
|
||||
}),
|
||||
...(options?.token && { Authorization: `Bearer ${options.token}` }),
|
||||
},
|
||||
// TODO(freben): The signal cast is there because pre-3.x versions of
|
||||
// node-fetch have a very slightly deviating AbortSignal type signature.
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
"backstage": {
|
||||
"role": "web-library"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/backstage/backstage",
|
||||
"directory": "packages/core-compat-api"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"start": "backstage-cli package start",
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
"backstage": {
|
||||
"role": "web-library"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/backstage/backstage",
|
||||
"directory": "packages/frontend-plugin-api"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"start": "backstage-cli package start",
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
isFulfilled,
|
||||
readFile,
|
||||
writeFile,
|
||||
safeEntityName,
|
||||
} from './utils';
|
||||
import { CodeOwnersEntry } from 'codeowners-utils';
|
||||
|
||||
@@ -164,9 +165,7 @@ async function fixCatalogInfoYaml(options: FixOptions) {
|
||||
codeowners,
|
||||
relativePath('.', yamlPath),
|
||||
);
|
||||
const safeName = packageJson.name
|
||||
.replace(/[^a-z0-9_\-\.]+/g, '-')
|
||||
.replace(/^[^a-z0-9]|[^a-z0-9]$/g, '');
|
||||
const safeName = safeEntityName(packageJson.name);
|
||||
let yamlJson: BackstagePackageEntity;
|
||||
|
||||
try {
|
||||
@@ -240,9 +239,7 @@ function createOrMergeEntity(
|
||||
owner: string,
|
||||
existingEntity: BackstagePackageEntity | Record<string, any> = {},
|
||||
): BackstagePackageEntity {
|
||||
const safeEntityName = packageJson.name
|
||||
.replace(/[^a-z0-9_\-\.]+/g, '-')
|
||||
.replace(/^[^a-z0-9]|[^a-z0-9]$/g, '');
|
||||
const entityName = safeEntityName(packageJson.name);
|
||||
|
||||
return {
|
||||
...existingEntity,
|
||||
@@ -251,7 +248,7 @@ function createOrMergeEntity(
|
||||
metadata: {
|
||||
...existingEntity.metadata,
|
||||
// Provide default name/title/description values.
|
||||
name: safeEntityName,
|
||||
name: entityName,
|
||||
title: packageJson.name,
|
||||
...(packageJson.description && !existingEntity.metadata?.description
|
||||
? { description: packageJson.description }
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2024 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { safeEntityName } from './utils';
|
||||
|
||||
describe('utils', () => {
|
||||
describe('safeEntityName', () => {
|
||||
it('should remove non-alphanumeric characters at the start and end', () => {
|
||||
const result = safeEntityName('%entityname$');
|
||||
expect(result).toBe('entityname');
|
||||
});
|
||||
|
||||
it('should replace non-alphanumeric characters, except - and _, with -', () => {
|
||||
const result = safeEntityName('entity@#name$');
|
||||
expect(result).toBe('entity-name');
|
||||
});
|
||||
|
||||
it('should replace capital letters with - followed by the same letter in lowercase', () => {
|
||||
const result = safeEntityName('EntityName');
|
||||
expect(result).toBe('entity-name');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -48,3 +48,20 @@ export const isRejected = (
|
||||
export const isFulfilled = <T>(
|
||||
input: PromiseSettledResult<T>,
|
||||
): input is PromiseFulfilledResult<T> => input.status === 'fulfilled';
|
||||
|
||||
/**
|
||||
* Generates a suitable entity name from a package name by slugifying the given package name.
|
||||
*
|
||||
* @param packageName - The package name to generate an entity name from.
|
||||
* @returns The generated entity name, a slugified version of the package name.
|
||||
*/
|
||||
export const safeEntityName = (packageName: string): string => {
|
||||
return packageName
|
||||
.replace(/^[^\w\s]|[^a-z0-9]$/g, '')
|
||||
.replace(/[^A-Za-z0-9_\-.]+/g, '-')
|
||||
.replace(
|
||||
/([a-z])([A-Z])/g,
|
||||
(_, a, b) => `${a}-${b.toLocaleLowerCase('en-US')}`,
|
||||
)
|
||||
.replace(/^(.)/, (_, a) => a.toLocaleLowerCase('en-US'));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user