Skip to content

Commit 8cc5196

Browse files
lizozomelasticmachine
authored andcommitted
[Plugin Generator] Generate tsconfig and useDefaultBehaviors (#72040)
* improve test stability * add a tsconfig file and useDefaultBehaviors Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 2a1ce2b commit 8cc5196

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

packages/kbn-plugin-generator/sao_template/sao.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ module.exports = function ({ name, targetPath }) {
120120
return !customPath;
121121
},
122122
},
123+
generateTsconfig: {
124+
type: 'confirm',
125+
message: 'Would you like to use a custom tsconfig file?',
126+
default: true,
127+
},
123128
},
124129
filters: {
125130
'public/**/index.scss': 'generateScss',
@@ -128,6 +133,7 @@ module.exports = function ({ name, targetPath }) {
128133
'translations/**/*': 'generateTranslations',
129134
'i18nrc.json': 'generateTranslations',
130135
'eslintrc.js': 'generateEslint',
136+
'tsconfig.json': 'generateTsconfig',
131137
},
132138
move: {
133139
'eslintrc.js': '.eslintrc.js',

packages/kbn-plugin-generator/sao_template/sao.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ describe('plugin generator sao integration', () => {
8080
generateApi: true,
8181
generateScss: false,
8282
generateEslint: false,
83+
generateTsconfig: false,
8384
});
8485

8586
// check output files
8687
expect(res.fileList).toContain('public/plugin.ts');
8788
expect(res.fileList).not.toContain('public/index.scss');
8889
expect(res.fileList).not.toContain('.eslintrc.js');
90+
expect(res.fileList).not.toContain('tsconfig.json');
8991
});
9092

9193
it('plugin package has correct title', async () => {
@@ -136,6 +138,7 @@ describe('plugin generator sao integration', () => {
136138

137139
it('includes dotfiles', async () => {
138140
const res = await sao.mockPrompt(template);
141+
expect(res.files['tsconfig.json']).toBeTruthy();
139142
expect(res.files['.eslintrc.js']).toBeTruthy();
140143
expect(res.files['.i18nrc.json']).toBeTruthy();
141144
});

packages/kbn-plugin-generator/sao_template/template/public/components/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const <%= upperCamelCaseName %>App = ({ basename, notifications, http, na
7373
<Router basename={basename}>
7474
<I18nProvider>
7575
<>
76-
<navigation.ui.TopNavMenu appName={ PLUGIN_ID } showSearchBar={true} />
76+
<navigation.ui.TopNavMenu appName={ PLUGIN_ID } showSearchBar={true} useDefaultBehaviors={true}/>
7777
<EuiPage restrictWidth="1000px">
7878
<EuiPageBody>
7979
<EuiPageHeader>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./target",
5+
"skipLibCheck": true
6+
},
7+
"include": [
8+
"index.ts",
9+
"common/**/*.ts",
10+
"public/**/*.ts",
11+
"public/**/*.tsx",
12+
"server/**/*.ts",
13+
"../../typings/**/*",
14+
],
15+
"exclude": []
16+
}

0 commit comments

Comments
 (0)