From 8cc5196a166a2092a474e12b8bba6cc6ac4edfa6 Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Mon, 20 Jul 2020 17:29:28 +0300 Subject: [PATCH] [Plugin Generator] Generate tsconfig and useDefaultBehaviors (#72040) * improve test stability * add a tsconfig file and useDefaultBehaviors Co-authored-by: Elastic Machine --- .../kbn-plugin-generator/sao_template/sao.js | 6 ++++++ .../sao_template/sao.test.js | 3 +++ .../template/public/components/app.tsx | 2 +- .../sao_template/template/tsconfig.json | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 packages/kbn-plugin-generator/sao_template/template/tsconfig.json diff --git a/packages/kbn-plugin-generator/sao_template/sao.js b/packages/kbn-plugin-generator/sao_template/sao.js index dc4d8a2fc10fb..e5f81a984ee93 100755 --- a/packages/kbn-plugin-generator/sao_template/sao.js +++ b/packages/kbn-plugin-generator/sao_template/sao.js @@ -120,6 +120,11 @@ module.exports = function ({ name, targetPath }) { return !customPath; }, }, + generateTsconfig: { + type: 'confirm', + message: 'Would you like to use a custom tsconfig file?', + default: true, + }, }, filters: { 'public/**/index.scss': 'generateScss', @@ -128,6 +133,7 @@ module.exports = function ({ name, targetPath }) { 'translations/**/*': 'generateTranslations', 'i18nrc.json': 'generateTranslations', 'eslintrc.js': 'generateEslint', + 'tsconfig.json': 'generateTsconfig', }, move: { 'eslintrc.js': '.eslintrc.js', diff --git a/packages/kbn-plugin-generator/sao_template/sao.test.js b/packages/kbn-plugin-generator/sao_template/sao.test.js index 03d95e12d58da..af243326cff33 100755 --- a/packages/kbn-plugin-generator/sao_template/sao.test.js +++ b/packages/kbn-plugin-generator/sao_template/sao.test.js @@ -80,12 +80,14 @@ describe('plugin generator sao integration', () => { generateApi: true, generateScss: false, generateEslint: false, + generateTsconfig: false, }); // check output files expect(res.fileList).toContain('public/plugin.ts'); expect(res.fileList).not.toContain('public/index.scss'); expect(res.fileList).not.toContain('.eslintrc.js'); + expect(res.fileList).not.toContain('tsconfig.json'); }); it('plugin package has correct title', async () => { @@ -136,6 +138,7 @@ describe('plugin generator sao integration', () => { it('includes dotfiles', async () => { const res = await sao.mockPrompt(template); + expect(res.files['tsconfig.json']).toBeTruthy(); expect(res.files['.eslintrc.js']).toBeTruthy(); expect(res.files['.i18nrc.json']).toBeTruthy(); }); diff --git a/packages/kbn-plugin-generator/sao_template/template/public/components/app.tsx b/packages/kbn-plugin-generator/sao_template/template/public/components/app.tsx index 7b259a9c5b99d..d75bd2f01ef23 100644 --- a/packages/kbn-plugin-generator/sao_template/template/public/components/app.tsx +++ b/packages/kbn-plugin-generator/sao_template/template/public/components/app.tsx @@ -73,7 +73,7 @@ export const <%= upperCamelCaseName %>App = ({ basename, notifications, http, na <> - + diff --git a/packages/kbn-plugin-generator/sao_template/template/tsconfig.json b/packages/kbn-plugin-generator/sao_template/template/tsconfig.json new file mode 100644 index 0000000000000..8a3ced743d0fa --- /dev/null +++ b/packages/kbn-plugin-generator/sao_template/template/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./target", + "skipLibCheck": true + }, + "include": [ + "index.ts", + "common/**/*.ts", + "public/**/*.ts", + "public/**/*.tsx", + "server/**/*.ts", + "../../typings/**/*", + ], + "exclude": [] +}