add plugin id format warning on frontend framework
Signed-off-by: Juan Pablo Garcia Ripa <sarabadu@gmail.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2025 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.
|
||||
*/
|
||||
|
||||
// NOTE: changing any of these constants need to be reflected in
|
||||
// @backstage/backend-plugin-api/src/wiring/constants.ts as well
|
||||
|
||||
/**
|
||||
* The pattern that IDs must match.
|
||||
*
|
||||
* @remarks
|
||||
* ids must only contain the letters `a` through `z` and digits, in groups separated by
|
||||
* dashes. Additionally, the very first character of the first group
|
||||
* must be a letter, not a digit
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const ID_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/i;
|
||||
@@ -30,6 +30,7 @@ import { FeatureFlagConfig } from './types';
|
||||
import { MakeSortedExtensionsMap } from './MakeSortedExtensionsMap';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { RouteRef, SubRouteRef, ExternalRouteRef } from '../routing';
|
||||
import { ID_PATTERN } from './constants';
|
||||
|
||||
/**
|
||||
* Information about the plugin.
|
||||
@@ -199,6 +200,13 @@ export function createFrontendPlugin<
|
||||
> {
|
||||
const pluginId = options.pluginId;
|
||||
|
||||
if (!ID_PATTERN.test(pluginId)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`WARNING: The pluginId '${pluginId}' will be invalid soon, please change it to match the pattern ${ID_PATTERN} (letters, digits, and dashes only, starting with a letter)`,
|
||||
);
|
||||
}
|
||||
|
||||
const extensions = new Array<Extension<any>>();
|
||||
const extensionDefinitionsById = new Map<
|
||||
string,
|
||||
|
||||
Reference in New Issue
Block a user