From 0b2a13b5c9ef12b51f91b03253e9f9288546ce67 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 12 Oct 2020 22:19:50 +0200 Subject: [PATCH 1/4] chore(cli): backend plugins should have the backend suffix --- packages/cli/src/commands/create-plugin/createPlugin.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/commands/create-plugin/createPlugin.ts b/packages/cli/src/commands/create-plugin/createPlugin.ts index cbaf956bdb..491e399b1f 100644 --- a/packages/cli/src/commands/create-plugin/createPlugin.ts +++ b/packages/cli/src/commands/create-plugin/createPlugin.ts @@ -224,9 +224,12 @@ export default async (cmd: Command) => { } const answers: Answers = await inquirer.prompt(questions); - const name = cmd.scope + const pluginName = cmd.scope ? `@${cmd.scope.replace(/^@/, '')}/plugin-${answers.id}` : `plugin-${answers.id}`; + + const name = cmd.backend ? `${pluginName}-backend` : pluginName; + const npmRegistry = cmd.npmRegistry && cmd.scope ? cmd.npmRegistry : ''; const privatePackage = cmd.private === false ? false : true; const isMonoRepo = await fs.pathExists(paths.resolveTargetRoot('lerna.json')); From a8a4f4138035d4e141b9adeee9ca30ac6772a6fe Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 12 Oct 2020 22:27:21 +0200 Subject: [PATCH 2/4] chore(cli): folder name etc should have the suffix too --- .../commands/create-plugin/createPlugin.ts | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/cli/src/commands/create-plugin/createPlugin.ts b/packages/cli/src/commands/create-plugin/createPlugin.ts index 491e399b1f..057e36ceb9 100644 --- a/packages/cli/src/commands/create-plugin/createPlugin.ts +++ b/packages/cli/src/commands/create-plugin/createPlugin.ts @@ -224,12 +224,11 @@ export default async (cmd: Command) => { } const answers: Answers = await inquirer.prompt(questions); - const pluginName = cmd.scope - ? `@${cmd.scope.replace(/^@/, '')}/plugin-${answers.id}` - : `plugin-${answers.id}`; - - const name = cmd.backend ? `${pluginName}-backend` : pluginName; + const pluginId = cmd.backend ? `${answers.id}-backend` : answers.id; + const name = cmd.scope + ? `@${cmd.scope.replace(/^@/, '')}/plugin-${pluginId}` + : `plugin-${pluginId}`; const npmRegistry = cmd.npmRegistry && cmd.scope ? cmd.npmRegistry : ''; const privatePackage = cmd.private === false ? false : true; const isMonoRepo = await fs.pathExists(paths.resolveTargetRoot('lerna.json')); @@ -239,10 +238,10 @@ export default async (cmd: Command) => { ? 'templates/default-backend-plugin' : 'templates/default-plugin', ); - const tempDir = resolvePath(os.tmpdir(), answers.id); + const tempDir = resolvePath(os.tmpdir(), pluginId); const pluginDir = isMonoRepo - ? paths.resolveTargetRoot('plugins', answers.id) - : paths.resolveTargetRoot(answers.id); + ? paths.resolveTargetRoot('plugins', pluginId) + : paths.resolveTargetRoot(pluginId); const ownerIds = parseOwnerIds(answers.owner); const { version } = isMonoRepo ? await fs.readJson(paths.resolveTargetRoot('lerna.json')) @@ -270,7 +269,7 @@ export default async (cmd: Command) => { }); Task.section('Moving to final location'); - await movePlugin(tempDir, pluginDir, answers.id); + await movePlugin(tempDir, pluginDir, pluginId); Task.section('Building the plugin'); await buildPlugin(pluginDir); @@ -280,13 +279,13 @@ export default async (cmd: Command) => { await addPluginDependencyToApp(paths.targetRoot, name, version); Task.section('Import plugin in app'); - await addPluginToApp(paths.targetRoot, answers.id, name); + await addPluginToApp(paths.targetRoot, pluginId, name); } if (ownerIds && ownerIds.length) { await addCodeownersEntry( codeownersPath!, - `/plugins/${answers.id}`, + `/plugins/${pluginId}`, ownerIds, ); } From bd3864385b3085c02d47094d40fdd0c986068bd1 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 12 Oct 2020 22:51:17 +0200 Subject: [PATCH 3/4] chore(e2e): fix the e2e test --- packages/e2e-test/src/commands/run.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/e2e-test/src/commands/run.ts b/packages/e2e-test/src/commands/run.ts index 2a0f641014..7111ff1867 100644 --- a/packages/e2e-test/src/commands/run.ts +++ b/packages/e2e-test/src/commands/run.ts @@ -56,7 +56,7 @@ export async function run() { const pluginName = await createPlugin('test-plugin', appDir); print('Creating a Backstage Backend Plugin'); - await createPlugin('test-backend-plugin', appDir, ['--backend']); + await createPlugin('test-plugin', appDir, ['--backend']); print('Starting the app'); await testAppServe(pluginName, appDir); @@ -265,13 +265,16 @@ async function createPlugin( print('Waiting for plugin create script to be done'); await waitForExit(child); - const pluginDir = resolvePath(appDir, 'plugins', pluginName); + const canonicalName = options.includes('--backend') + ? `${pluginName}-backend}` + : pluginName; + const pluginDir = resolvePath(appDir, 'plugins', canonicalName); for (const cmd of [['tsc'], ['lint'], ['test', '--no-watch']]) { print(`Running 'yarn ${cmd.join(' ')}' in newly created plugin`); await runPlain(['yarn', ...cmd], { cwd: pluginDir }); } - return pluginName; + return canonicalName; } finally { child.kill(); } From b7d15b4f1ac20a7c0abab11de272a7846b20fc03 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 13 Oct 2020 03:02:58 +0200 Subject: [PATCH 4/4] chore(cli): remove superfluous bracket that was causing all the things --- packages/e2e-test/src/commands/run.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/e2e-test/src/commands/run.ts b/packages/e2e-test/src/commands/run.ts index 7111ff1867..cfe0ad9685 100644 --- a/packages/e2e-test/src/commands/run.ts +++ b/packages/e2e-test/src/commands/run.ts @@ -266,9 +266,11 @@ async function createPlugin( await waitForExit(child); const canonicalName = options.includes('--backend') - ? `${pluginName}-backend}` + ? `${pluginName}-backend` : pluginName; + const pluginDir = resolvePath(appDir, 'plugins', canonicalName); + for (const cmd of [['tsc'], ['lint'], ['test', '--no-watch']]) { print(`Running 'yarn ${cmd.join(' ')}' in newly created plugin`); await runPlain(['yarn', ...cmd], { cwd: pluginDir });