From f09e6eb4ce308431cb2668e96412b292630aaba1 Mon Sep 17 00:00:00 2001 From: Fabian Chong Date: Mon, 26 Oct 2020 13:35:25 +0800 Subject: [PATCH] Add tsconfig to non monorepo plugin. --- packages/cli/src/commands/plugin/diff.ts | 6 +----- packages/cli/src/lib/tasks.ts | 6 ++++++ packages/cli/templates/default-plugin/tsconfig.json | 13 +++++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 packages/cli/templates/default-plugin/tsconfig.json diff --git a/packages/cli/src/commands/plugin/diff.ts b/packages/cli/src/commands/plugin/diff.ts index f5dfa670b7..012c061f74 100644 --- a/packages/cli/src/commands/plugin/diff.ts +++ b/packages/cli/src/commands/plugin/diff.ts @@ -40,17 +40,13 @@ const fileHandlers = [ patterns: ['package.json'], handler: handlers.packageJson, }, - { - patterns: ['tsconfig.json'], - handler: handlers.exactMatch, - }, { // make sure files in 1st level of src/ and dev/ exist patterns: ['.eslintrc.js', /^(src|dev)\/[^/]+$/], handler: handlers.exists, }, { - patterns: ['README.md', /^src\//], + patterns: ['README.md', 'tsconfig.json', /^src\//], handler: handlers.skip, }, ]; diff --git a/packages/cli/src/lib/tasks.ts b/packages/cli/src/lib/tasks.ts index 0753301b78..80dc1a5ed7 100644 --- a/packages/cli/src/lib/tasks.ts +++ b/packages/cli/src/lib/tasks.ts @@ -20,6 +20,7 @@ import handlebars from 'handlebars'; import ora from 'ora'; import { basename, dirname } from 'path'; import recursive from 'recursive-readdir'; +import { paths } from './paths'; const TASK_NAME_MAX_LENGTH = 14; @@ -72,6 +73,7 @@ export async function templatingTask( const files = await recursive(templateDir).catch(error => { 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); @@ -92,6 +94,10 @@ export async function templatingTask( }); }); } else { + if (isMonoRepo && file.match('tsconfig.json')) { + continue; + } + await Task.forItem('copying', basename(file), async () => { await fs.copyFile(file, destinationFile).catch(error => { const destination = destinationFile; diff --git a/packages/cli/templates/default-plugin/tsconfig.json b/packages/cli/templates/default-plugin/tsconfig.json new file mode 100644 index 0000000000..d77f0fe3b4 --- /dev/null +++ b/packages/cli/templates/default-plugin/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "@backstage/cli/config/tsconfig.json", + "include": [ + "src", + "dev", + "migrations" + ], + "exclude": ["node_modules"], + "compilerOptions": { + "outDir": "dist-types", + "rootDir": "." + } +}