From 903c9d9c63694a1ba178774b77f05094953a9aee Mon Sep 17 00:00:00 2001 From: Fabian Chong Date: Wed, 16 Sep 2020 14:06:14 +0800 Subject: [PATCH] fix plugin template verification --- .../cli/src/commands/create-plugin/createPlugin.ts | 4 ++-- packages/cli/src/lib/tasks.ts | 14 -------------- .../cli/templates/default-plugin/package.json.hbs | 3 ++- .../cli/templates/default-plugin/tsconfig.json | 12 ------------ 4 files changed, 4 insertions(+), 29 deletions(-) delete mode 100644 packages/cli/templates/default-plugin/tsconfig.json diff --git a/packages/cli/src/commands/create-plugin/createPlugin.ts b/packages/cli/src/commands/create-plugin/createPlugin.ts index 8241f68b8c..9b97746c0e 100644 --- a/packages/cli/src/commands/create-plugin/createPlugin.ts +++ b/packages/cli/src/commands/create-plugin/createPlugin.ts @@ -233,11 +233,11 @@ export default async (cmd: Command) => { ? `"${scopeName}:registry": "${cmd.npmRegistry}"` : ''; const privatePackage = cmd.private === false ? false : true; - + const isMonoRepo = await fs.pathExists(paths.resolveTargetRoot('lerna.json')); const appPackage = paths.resolveTargetRoot('packages/app'); const templateDir = paths.resolveOwn('templates/default-plugin'); const tempDir = resolvePath(os.tmpdir(), answers.id); - const pluginDir = (await fs.pathExists(paths.resolveTargetRoot('lerna.json'))) + const pluginDir = isMonoRepo ? paths.resolveTargetRoot('plugins', answers.id) : paths.resolveTargetRoot(answers.id); const ownerIds = parseOwnerIds(answers.owner); diff --git a/packages/cli/src/lib/tasks.ts b/packages/cli/src/lib/tasks.ts index 34f796165b..75794a1ba6 100644 --- a/packages/cli/src/lib/tasks.ts +++ b/packages/cli/src/lib/tasks.ts @@ -19,7 +19,6 @@ import fs from 'fs-extra'; import handlebars from 'handlebars'; import ora from 'ora'; import { basename, dirname } from 'path'; -import { paths } from './paths'; import recursive from 'recursive-readdir'; const TASK_NAME_MAX_LENGTH = 14; @@ -74,8 +73,6 @@ export async function templatingTask( throw new Error(`Failed to read template directory: ${error.message}`); }); - const isMonoRepo = await fs.pathExists(paths.resolveTargetRoot('lerna.json')); - for (const file of files) { const destinationFile = file.replace(templateDir, destinationDir); await fs.ensureDir(dirname(destinationFile)); @@ -94,17 +91,6 @@ export async function templatingTask( ); }); }); - } else { - if (isMonoRepo && basename(file) === 'tsconfig.json') continue; - - await Task.forItem('copying', basename(file), async () => { - await fs.copyFile(file, destinationFile).catch(error => { - const destination = destinationFile; - throw new Error( - `Failed to copy file to ${destination} : ${error.message}`, - ); - }); - }); } } } diff --git a/packages/cli/templates/default-plugin/package.json.hbs b/packages/cli/templates/default-plugin/package.json.hbs index 1a969f9712..5e59b6fa0d 100644 --- a/packages/cli/templates/default-plugin/package.json.hbs +++ b/packages/cli/templates/default-plugin/package.json.hbs @@ -4,7 +4,8 @@ "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", - "private": {{privatePackage}}, +{{#if privatePackage}} "private": {{privatePackage}}, +{{/if}} "publishConfig": { {{#if npmRegistry}} {{{npmRegistry}}}, {{/if}} diff --git a/packages/cli/templates/default-plugin/tsconfig.json b/packages/cli/templates/default-plugin/tsconfig.json deleted file mode 100644 index 40e967d267..0000000000 --- a/packages/cli/templates/default-plugin/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "@backstage/cli/config/tsconfig.json", - "include": [ - "src", - "dev", - "migrations" - ], - "compilerOptions": { - "outDir": "dist-types", - "rootDir": "." - } -}