Rename CliPlugin to CliModule and cli-plugin role to cli-module
Rename createCliPlugin to createCliModule, CliPlugin to CliModule, and the cli-plugin package role to cli-module to better distinguish CLI modules from other plugin types. Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Made-with: Cursor
This commit is contained in:
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { createCliPlugin } from '../../wiring/factory';
|
||||
import { createCliModule } from '../../wiring/factory';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export default createCliPlugin({
|
||||
export default createCliModule({
|
||||
packageJson,
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { createCliPlugin } from '@backstage/cli-node';
|
||||
import { createCliModule } from '@backstage/cli-node';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export const buildPlugin = createCliPlugin({
|
||||
export const buildPlugin = createCliModule({
|
||||
packageJson,
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('typeDistProject', () => {
|
||||
frontend: false,
|
||||
backend: false,
|
||||
cli: false,
|
||||
'cli-plugin': false,
|
||||
'cli-module': false,
|
||||
'common-library': false,
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createCliPlugin } from '@backstage/cli-node';
|
||||
import { createCliModule } from '@backstage/cli-node';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export const configOption = [
|
||||
@@ -23,7 +23,7 @@ export const configOption = [
|
||||
Array<string>(),
|
||||
] as const;
|
||||
|
||||
export default createCliPlugin({
|
||||
export default createCliModule({
|
||||
packageJson,
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createCliPlugin } from '@backstage/cli-node';
|
||||
import { createCliModule } from '@backstage/cli-node';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export default createCliPlugin({
|
||||
export default createCliModule({
|
||||
packageJson,
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createCliPlugin } from '@backstage/cli-node';
|
||||
import { createCliModule } from '@backstage/cli-node';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export default createCliPlugin({
|
||||
export default createCliModule({
|
||||
packageJson,
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createCliPlugin } from '@backstage/cli-node';
|
||||
import { createCliModule } from '@backstage/cli-node';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export default createCliPlugin({
|
||||
export default createCliModule({
|
||||
packageJson,
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
|
||||
@@ -298,7 +298,7 @@ export function fixPluginId(pkg: FixablePackage) {
|
||||
role === 'backend' ||
|
||||
role === 'frontend' ||
|
||||
role === 'cli' ||
|
||||
role === 'cli-plugin'
|
||||
role === 'cli-module'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -385,7 +385,7 @@ export function fixPluginPackages(
|
||||
role === 'backend' ||
|
||||
role === 'frontend' ||
|
||||
role === 'cli' ||
|
||||
role === 'cli-plugin'
|
||||
role === 'cli-module'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createCliPlugin } from '@backstage/cli-node';
|
||||
import { createCliModule } from '@backstage/cli-node';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export default createCliPlugin({
|
||||
export default createCliModule({
|
||||
packageJson,
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
|
||||
@@ -22,7 +22,7 @@ import type { CliCommandContext } from '../../../wiring/types';
|
||||
|
||||
const configArgPattern = /--config[=\s][^\s$]+/;
|
||||
|
||||
const noStartRoles: PackageRole[] = ['cli', 'cli-plugin', 'common-library'];
|
||||
const noStartRoles: PackageRole[] = ['cli', 'cli-module', 'common-library'];
|
||||
|
||||
export default async ({ args, info }: CliCommandContext) => {
|
||||
cli({ help: info, booleanFlagNegation: true }, undefined, args);
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createCliPlugin } from '@backstage/cli-node';
|
||||
import { createCliModule } from '@backstage/cli-node';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export default createCliPlugin({
|
||||
export default createCliModule({
|
||||
packageJson,
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createCliPlugin } from '@backstage/cli-node';
|
||||
import { createCliModule } from '@backstage/cli-node';
|
||||
import { NotImplementedError } from '@backstage/errors';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export default createCliPlugin({
|
||||
export default createCliModule({
|
||||
packageJson,
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createCliPlugin } from '@backstage/cli-node';
|
||||
import { createCliModule } from '@backstage/cli-node';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export default createCliPlugin({
|
||||
export default createCliModule({
|
||||
packageJson,
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createCliPlugin } from '@backstage/cli-node';
|
||||
import { createCliModule } from '@backstage/cli-node';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export default createCliPlugin({
|
||||
export default createCliModule({
|
||||
packageJson,
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import { CliInitializer } from './CliInitializer';
|
||||
import { createCliPlugin } from './factory';
|
||||
import { createCliModule } from './factory';
|
||||
|
||||
process.exit = jest.fn() as any;
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('CliInitializer', () => {
|
||||
process.argv = ['node', 'cli', 'test'];
|
||||
const initializer = new CliInitializer();
|
||||
initializer.add(
|
||||
createCliPlugin({
|
||||
createCliModule({
|
||||
packageJson: { name: '@backstage/test' },
|
||||
init: async reg =>
|
||||
reg.addCommand({
|
||||
@@ -50,7 +50,7 @@ describe('CliInitializer', () => {
|
||||
process.argv = ['node', 'cli', 'test', '[positional]', '<arg>'];
|
||||
const initializer = new CliInitializer();
|
||||
initializer.add(
|
||||
createCliPlugin({
|
||||
createCliModule({
|
||||
packageJson: { name: '@backstage/test' },
|
||||
init: async reg =>
|
||||
reg.addCommand({
|
||||
@@ -72,7 +72,7 @@ describe('CliInitializer', () => {
|
||||
process.argv = ['node', 'cli', 'test', '--verbose'];
|
||||
const initializer = new CliInitializer();
|
||||
initializer.add(
|
||||
createCliPlugin({
|
||||
createCliModule({
|
||||
packageJson: { name: '@backstage/test' },
|
||||
init: async reg =>
|
||||
reg.addCommand({
|
||||
@@ -97,7 +97,7 @@ describe('CliInitializer', () => {
|
||||
process.argv = ['node', 'cli', 'secret'];
|
||||
const initializer = new CliInitializer();
|
||||
initializer.add(
|
||||
createCliPlugin({
|
||||
createCliModule({
|
||||
packageJson: { name: '@backstage/test' },
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
@@ -124,7 +124,7 @@ describe('CliInitializer', () => {
|
||||
const writeSpy = jest.spyOn(process.stdout, 'write');
|
||||
const initializer2 = new CliInitializer();
|
||||
initializer2.add(
|
||||
createCliPlugin({
|
||||
createCliModule({
|
||||
packageJson: { name: '@backstage/test' },
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
@@ -152,7 +152,7 @@ describe('CliInitializer', () => {
|
||||
const writeSpy = jest.spyOn(process.stdout, 'write');
|
||||
const initializer = new CliInitializer();
|
||||
initializer.add(
|
||||
createCliPlugin({
|
||||
createCliModule({
|
||||
packageJson: { name: '@backstage/test' },
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
@@ -187,7 +187,7 @@ describe('CliInitializer', () => {
|
||||
const writeSpy = jest.spyOn(process.stdout, 'write');
|
||||
const initializer = new CliInitializer();
|
||||
initializer.add(
|
||||
createCliPlugin({
|
||||
createCliModule({
|
||||
packageJson: { name: '@backstage/test' },
|
||||
init: async reg => {
|
||||
reg.addCommand({
|
||||
@@ -223,7 +223,7 @@ describe('CliInitializer', () => {
|
||||
];
|
||||
const initializer = new CliInitializer();
|
||||
initializer.add(
|
||||
createCliPlugin({
|
||||
createCliModule({
|
||||
packageJson: { name: '@backstage/test' },
|
||||
init: async reg =>
|
||||
reg.addCommand({
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
import { CommandGraph } from './CommandGraph';
|
||||
import {
|
||||
OpaqueCliPlugin,
|
||||
OpaqueCliModule,
|
||||
OpaqueCommandTreeNode,
|
||||
OpaqueCommandLeafNode,
|
||||
} from '@internal/cli';
|
||||
import type { CommandNode } from '@internal/cli';
|
||||
import type { CliPlugin } from '@backstage/cli-node';
|
||||
import type { CliModule } from '@backstage/cli-node';
|
||||
import { CommandRegistry } from './CommandRegistry';
|
||||
import { Command } from 'commander';
|
||||
import { version } from './version';
|
||||
@@ -39,12 +39,12 @@ function isNodeHidden(node: CommandNode): boolean {
|
||||
return children.every(child => isNodeHidden(child));
|
||||
}
|
||||
|
||||
type UninitializedFeature = CliPlugin | Promise<{ default: CliPlugin }>;
|
||||
type UninitializedFeature = CliModule | Promise<{ default: CliModule }>;
|
||||
|
||||
export class CliInitializer {
|
||||
private graph = new CommandGraph();
|
||||
private commandRegistry = new CommandRegistry(this.graph);
|
||||
#uninitiazedFeatures: Promise<CliPlugin>[] = [];
|
||||
#uninitiazedFeatures: Promise<CliModule>[] = [];
|
||||
|
||||
add(feature: UninitializedFeature) {
|
||||
if (isPromise(feature)) {
|
||||
@@ -56,9 +56,9 @@ export class CliInitializer {
|
||||
}
|
||||
}
|
||||
|
||||
async #register(feature: CliPlugin) {
|
||||
if (OpaqueCliPlugin.isType(feature)) {
|
||||
const internal = OpaqueCliPlugin.toInternal(feature);
|
||||
async #register(feature: CliModule) {
|
||||
if (OpaqueCliModule.isType(feature)) {
|
||||
const internal = OpaqueCliModule.toInternal(feature);
|
||||
for (const command of await internal.commands) {
|
||||
this.commandRegistry.addCommand(command);
|
||||
}
|
||||
@@ -186,8 +186,8 @@ export class CliInitializer {
|
||||
|
||||
/** @internal */
|
||||
export function unwrapFeature(
|
||||
feature: CliPlugin | { default: CliPlugin },
|
||||
): CliPlugin {
|
||||
feature: CliModule | { default: CliModule },
|
||||
): CliModule {
|
||||
if ('$$type' in feature) {
|
||||
return feature;
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { createCliPlugin } from '@backstage/cli-node';
|
||||
export { createCliModule } from '@backstage/cli-node';
|
||||
|
||||
@@ -17,5 +17,5 @@
|
||||
export type {
|
||||
CliCommandContext,
|
||||
CliCommand,
|
||||
CliPlugin,
|
||||
CliModule,
|
||||
} from '@backstage/cli-node';
|
||||
|
||||
Reference in New Issue
Block a user