feat(cli): adding the backend flag to the cli

This commit is contained in:
blam
2020-09-21 00:46:02 +02:00
parent 1fb8428c1e
commit 0d07847859
6 changed files with 13 additions and 10 deletions
@@ -175,7 +175,7 @@ export async function movePlugin(
});
}
export default async () => {
export default async ({ backend }: { backend: boolean }) => {
const codeownersPath = await getCodeownersFilePath(paths.targetRoot);
const questions: Question[] = [
@@ -223,7 +223,9 @@ export default async () => {
const answers: Answers = await inquirer.prompt(questions);
const appPackage = paths.resolveTargetRoot('packages/app');
const templateDir = paths.resolveOwn('templates/default-plugin');
const templateDir = paths.resolveOwn(
backend ? 'templates/default-backend-plugin' : 'templates/default-plugin',
);
const tempDir = resolvePath(os.tmpdir(), answers.id);
const pluginDir = paths.resolveTargetRoot('plugins', answers.id);
const ownerIds = parseOwnerIds(answers.owner);
@@ -240,6 +242,7 @@ export default async () => {
await createTemporaryPluginFolder(tempDir);
Task.section('Preparing files');
await templatingTask(templateDir, tempDir, {
...answers,
version,
@@ -252,7 +255,7 @@ export default async () => {
Task.section('Building the plugin');
await buildPlugin(pluginDir);
if (await fs.pathExists(appPackage)) {
if ((await fs.pathExists(appPackage)) && !backend) {
Task.section('Adding plugin as dependency in app');
await addPluginDependencyToApp(paths.targetRoot, answers.id, version);
+4
View File
@@ -61,6 +61,10 @@ export function registerCommands(program: CommanderStatic) {
program
.command('create-plugin')
.option(
'--backend',
'Create plugin with the backend dependencies as default',
)
.description('Creates a new plugin in the current repository')
.action(
lazy(() => import('./create-plugin/createPlugin').then(m => m.default)),
@@ -17,16 +17,16 @@
"test": "backstage-cli test",
"prepack": "backstage-cli prepack",
"postpack": "backstage-cli postpack",
"clean": "backstage-cli clean",
"mock-data": "./scripts/mock-data.sh"
"clean": "backstage-cli clean"
},
"dependencies": {
"@backstage/backend-common": "^{{version}}",
"@backstage/config": "^{{version}}",
"@types/express": "^4.17.6",
"express": "^4.17.1",
"express-promise-router": "^3.0.3",
"whatwg-fetch": "^2.0.0",
"winston": "^3.2.1",
"node-fetch": "^2.6.0",
"yn": "^4.0.0"
},
"devDependencies": {
@@ -1,2 +0,0 @@
#!/usr/bin/env bash
echo "use this script to load your service with some mock data if needed!"
@@ -14,5 +14,4 @@
* limitations under the License.
*/
require('whatwg-fetch');
export * from './service/router';
@@ -13,6 +13,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('whatwg-fetch');
export {};