cli: rename app role to frontend

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-02-16 13:05:28 +01:00
parent 9892d74326
commit ba5ea41f9e
10 changed files with 19 additions and 19 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ Several changes were made to the new experimental package roles system. Unless y
Renamed the `backstage-cli migrate package-role` command to `backstage-cli migrate package-roles`.
Updated the package role definitions by renaming `plugin-frontend` to `frontend-plugin`, as well as the same reshuffle to `frontend-plugin-module`, `backend-plugin`, and `backend-plugin-module`.
Updated the package role definitions by renaming `app` to `frontend`, `plugin-frontend` to `frontend-plugin`, `plugin-frontend-module` to `frontend-plugin-module`, `plugin-backend` to `backend-plugin`, and `plugin-backend-module` to `backend-plugin-module`
The `backstage-cli migrate package-scripts` received several tweaks to make it more accurate. It now tries to maintain existing script arguments, like `--config` parameters for `build` and `start` scripts.
+1 -1
View File
@@ -3,7 +3,7 @@
"version": "0.2.64",
"private": true,
"backstage": {
"role": "app"
"role": "frontend"
},
"bundled": true,
"dependencies": {
@@ -26,7 +26,7 @@ interface BuildAppOptions {
configPaths: string[];
}
export async function buildApp(options: BuildAppOptions) {
export async function buildFrontend(options: BuildAppOptions) {
const { targetDir, writeStats, configPaths } = options;
const { name } = await fs.readJson(resolvePath(targetDir, 'package.json'));
await buildBundle({
+3 -3
View File
@@ -18,14 +18,14 @@ import { Command } from 'commander';
import { buildPackage, Output } from '../../lib/builder';
import { findRoleFromCommand, getRoleInfo } from '../../lib/role';
import { paths } from '../../lib/paths';
import { buildApp } from './buildApp';
import { buildFrontend } from './buildFrontend';
import { buildBackend } from './buildBackend';
export async function command(cmd: Command): Promise<void> {
const role = await findRoleFromCommand(cmd);
if (role === 'app') {
return buildApp({
if (role === 'frontend') {
return buildFrontend({
targetDir: paths.targetDir,
configPaths: cmd.config as string[],
writeStats: Boolean(cmd.stats),
+3 -3
View File
@@ -23,7 +23,7 @@ import { ExtendedPackage } from '../../lib/monorepo/PackageGraph';
import { runParallelWorkers } from '../../lib/parallel';
import { paths } from '../../lib/paths';
import { detectRoleFromPackage } from '../../lib/role';
import { buildApp } from '../build/buildApp';
import { buildFrontend } from '../build/buildFrontend';
import { buildBackend } from '../build/buildBackend';
function createScriptOptionsParser(anyCmd: Command, commandPath: string[]) {
@@ -92,7 +92,7 @@ export async function command(cmd: Command): Promise<void> {
return [];
}
if (role === 'app') {
if (role === 'frontend') {
apps.push(pkg);
return [];
} else if (role === 'backend') {
@@ -139,7 +139,7 @@ export async function command(cmd: Command): Promise<void> {
);
return;
}
await buildApp({
await buildFrontend({
targetDir: pkg.dir,
configPaths: (buildOptions.config as string[]) ?? [],
writeStats: Boolean(buildOptions.stats),
+1 -1
View File
@@ -35,7 +35,7 @@ export async function command(cmd: Command): Promise<void> {
case 'backend-plugin-module':
case 'node-library':
return startBackend(options);
case 'app':
case 'frontend':
return startFrontend({
...options,
entry: 'src/index',
@@ -31,8 +31,8 @@ describe('getRoleInfo', () => {
output: ['types', 'esm'],
});
expect(getRoleInfo('app')).toEqual({
role: 'app',
expect(getRoleInfo('frontend')).toEqual({
role: 'frontend',
platform: 'web',
output: ['bundle'],
});
@@ -56,10 +56,10 @@ describe('getRoleFromPackage', () => {
expect(
getRoleFromPackage({
backstage: {
role: 'app',
role: 'frontend',
},
}),
).toEqual('app');
).toEqual('frontend');
expect(() =>
getRoleFromPackage({
@@ -135,7 +135,7 @@ describe('detectRoleFromPackage', () => {
'cy:run': 'cypress run',
},
}),
).toEqual('app');
).toEqual('frontend');
});
it('detects the role of example-backend', () => {
+2 -2
View File
@@ -22,7 +22,7 @@ import { PackageRole, PackageRoleInfo } from './types';
const packageRoleInfos: PackageRoleInfo[] = [
{
role: 'app',
role: 'frontend',
platform: 'web',
output: ['bundle'],
},
@@ -147,7 +147,7 @@ export function detectRoleFromPackage(
const pkg = detectionSchema.parse(pkgJson);
if (pkg.scripts?.start?.includes('app:serve')) {
return 'app';
return 'frontend';
}
if (pkg.scripts?.build?.includes('backend:bundle')) {
return 'backend';
+1 -1
View File
@@ -15,7 +15,7 @@
*/
export type PackageRole =
| 'app'
| 'frontend'
| 'backend'
| 'cli'
| 'web-library'
@@ -3,7 +3,7 @@
"version": "0.2.63",
"private": true,
"backstage": {
"role": "app"
"role": "frontend"
},
"bundled": true,
"dependencies": {