Skip to content

Commit ecc4810

Browse files
committed
RESTEasy can be excluded if using code.quarkus.io
Reads the data from code.quarkus.io or code.quarkus.redhat.com to see which quarkus extensions are required. This means if code.quarkus.io is used, then resteasy is not required. Reads the Open API of the code quarkus instance to determine if the option to prevent sample code being generated is present. If it is, then it adds another step to the project generation wizard to specify if sample code should be generated. Closes #322 Signed-off-by: David Thompson <[email protected]>
1 parent 2636c37 commit ecc4810

File tree

13 files changed

+225
-49
lines changed

13 files changed

+225
-49
lines changed

package-lock.json

Lines changed: 43 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@
267267
"devDependencies": {
268268
"@types/chai": "^4.2.3",
269269
"@types/chai-fs": "^2.0.2",
270+
"@types/ejs": "^3.0.5",
270271
"@types/fs-extra": "^7.0.0",
272+
"@types/js-yaml": "^4.0.0",
271273
"@types/lodash": "^4.14.149",
272274
"@types/mocha": "^5.2.6",
273275
"@types/node": "^10.14.16",
@@ -302,6 +304,7 @@
302304
"find-up": "^4.1.0",
303305
"fs-extra": "^8.0.1",
304306
"glob": "^7.1.4",
307+
"js-yaml": "^4.0.0",
305308
"lodash": "^4.17.21",
306309
"request": "^2.88.0",
307310
"request-promise": "^4.2.4",

src/commands/registerCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { WelcomeWebview } from "../webviews/WelcomeWebview";
77
import { addExtensionsWizard } from "../wizards/addExtensions/addExtensionsWizard";
88
import { buildBinary } from "../wizards/binary/buildBinary";
99
import { startDebugging } from "../wizards/debugging/startDebugging";
10-
import { generateProjectWizard } from "../wizards/generateProject/generationWizard";
1110
import { deployToOpenShift } from "../wizards/deployToOpenShift/deployToOpenShift";
11+
import { generateProjectWizard } from "../wizards/generateProject/generationWizard";
1212

1313
const NOT_A_QUARKUS_PROJECT = new Error('No Quarkus projects were detected in this folder');
1414
const STANDARD_MODE_REQUEST_FAILED = new Error('Error occurred while requesting standard mode from the Java language server');

src/definitions/QExtension.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ export class QExtension {
2828
artifactId: string;
2929
isRequired: boolean;
3030

31-
constructor(name: string, category: string, description: string, labels: string[], groupId: string, artifactId: string) {
31+
constructor(name: string, category: string, description: string, labels: string[], groupId: string, artifactId: string, isRequired: boolean) {
3232
this.name = name;
3333
this.category = category;
3434
this.description = description;
3535
this.labels = labels;
3636
this.groupId = groupId;
3737
this.artifactId = artifactId;
38-
this.isRequired = name === 'RESTEasy JAX-RS'; // 'RESTEasy JAX-RS' is included in every Quarkus project
38+
this.isRequired = isRequired;
3939
}
4040

4141
getGroupIdArtifactIdString() {
@@ -61,7 +61,7 @@ export function convertToQExtension(extension: APIExtension): QExtension {
6161
artifactId = extension.id;
6262
}
6363
return new QExtension(extension.name, extension.category, extension.description,
64-
extension.labels, groupId, artifactId);
64+
extension.labels, groupId, artifactId, extension.default);
6565
}
6666

6767
/**
@@ -76,4 +76,5 @@ export interface APIExtension {
7676
shortName: string;
7777
category: string;
7878
order: Number;
79+
default: boolean;
7980
}

src/definitions/inputState.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface ProjectGenState extends State {
3434
packageName: string;
3535
resourceName: string;
3636
targetDir: Uri;
37+
isGenerateSampleCode: boolean;
3738
}
3839

3940
export interface AddExtensionsState extends State {

src/extension.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import { TelemetryService } from '@redhat-developer/vscode-redhat-telemetry';
1716
import * as path from 'path';
1817
import { commands, ConfigurationChangeEvent, Disposable, ExtensionContext, languages, Terminal, TextDocument, window, workspace } from 'vscode';
1918
import { registerVSCodeCommands } from './commands/registerCommands';
20-
import { VSCODE_QUARKUS_EXTENSION_NAME } from './definitions/constants';
2119
import { ProjectLabelInfo } from './definitions/ProjectLabelInfo';
2220
import { PropertiesLanguageMismatch, QuarkusConfig } from './QuarkusConfig';
2321
import { QuarkusContext } from './QuarkusContext';
2422
import quarkusProjectListener from './QuarkusProjectListener';
2523
import { terminalCommandRunner } from './terminal/terminalCommandRunner';
24+
import { initTelemetryService } from './utils/telemetryUtils';
2625
import { WelcomeWebview } from './webviews/WelcomeWebview';
2726
import { createTerminateDebugListener } from './wizards/debugging/terminateProcess';
28-
import { initTelemetryService } from './utils/telemetryUtils';
2927

3028
export async function activate(context: ExtensionContext) {
3129

src/test/vscodeUiTest/ProjectGenerationWizard.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
import * as _ from 'lodash';
17-
18-
import { InputBox, QuickPickItem, Workbench, WebDriver, WebElement, By, until, Key } from 'vscode-extension-tester';
17+
import { By, InputBox, Key, QuickPickItem, WebDriver, WebElement, Workbench } from 'vscode-extension-tester';
1918
import { DialogHandler, OpenDialog } from 'vscode-extension-tester-native';
2019

2120
/**
@@ -30,7 +29,7 @@ export class ProjectGenerationWizard extends InputBox {
3029
/**
3130
* The number of steps the wizard has
3231
*/
33-
private lastStep: number = 7;
32+
private lastStep: number = 8;
3433

3534
/**
3635
* Opens the project generation wizard
@@ -78,6 +77,9 @@ export class ProjectGenerationWizard extends InputBox {
7877
await wizard.confirm();
7978
}
8079
}
80+
await wizard.focusQuickPick(0);
81+
await wizard.next();
82+
await wizard.focusQuickPick(0);
8183
await wizard.next();
8284

8385
const dialog: OpenDialog = await DialogHandler.getOpenDialog();
@@ -213,6 +215,19 @@ export class ProjectGenerationWizard extends InputBox {
213215
return (await this.getNthQuickPickItemInfo(n)).label;
214216
}
215217

218+
/**
219+
* Focuses on the quick pick with the given index
220+
*
221+
* @param n the index of the quick pick option to focus
222+
* @returns when the quick pick is focused
223+
*/
224+
public async focusQuickPick(n: number): Promise<void> {
225+
const quickPickToFocus: QuickPickItem = await this.findQuickPick(n);
226+
while (!(await quickPickToFocus.getAttribute('class')).includes('focused')) {
227+
await this.sendKeys(Key.DOWN);
228+
}
229+
}
230+
216231
/**
217232
* Returns the `n`th quick pick item's `QuickPickItemInfo`
218233
* @param n

src/test/vscodeUiTest/suite/projectGenerationTest.ts

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -100,76 +100,82 @@ describe('Project generation tests', function() {
100100
expect(resourceName).equals('GreetingResource');
101101
await wizard.next();
102102

103-
await wizard.sendKeys(Key.DOWN, Key.UP);
104-
105-
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('1 extension selected');
106-
await wizard.sendKeys(Key.DOWN, Key.DOWN);
107-
await wizard.confirm();
108-
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('2 extensions selected');
109-
await wizard.sendKeys(Key.DOWN, Key.DOWN, Key.DOWN);
103+
await wizard.focusQuickPick(0);
104+
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('0 extensions selected');
105+
await wizard.focusQuickPick(2);
110106
await wizard.confirm();
111-
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('3 extensions selected');
112-
await wizard.sendKeys(Key.DOWN);
107+
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('1 extension selected');
108+
await wizard.focusQuickPick(3);
113109
await wizard.confirm();
114110
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('2 extensions selected');
115-
await wizard.sendKeys(Key.DOWN);
111+
await wizard.focusQuickPick(1);
116112
await wizard.confirm();
117113
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('1 extension selected');
114+
await wizard.focusQuickPick(1);
115+
await wizard.confirm();
116+
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('0 extensions selected');
118117
await wizard.cancel();
119118
});
120119

121120
/**
122121
* Tests if the project generation wizard has correct
123-
* step values at the wizard's title bar: (1/7), (2/7)
122+
* step values at the wizard's title bar: (1/8), (2/8)
124123
*/
125124
it('should have correct step values', async function() {
126125
this.timeout(30000);
127126
const wizard: ProjectGenerationWizard = await ProjectGenerationWizard.openWizard(driver);
128-
expect(await wizard.getInputBoxTitle()).to.have.string('1/7');
127+
expect(await wizard.getInputBoxTitle()).to.have.string('1/8');
129128
expect(await wizard.getBackButton()).to.not.be.ok;
130129
await wizard.next();
131130

132-
expect(await wizard.getInputBoxTitle()).to.have.string('2/7');
131+
expect(await wizard.getInputBoxTitle()).to.have.string('2/8');
133132
await wizard.next();
134133

135-
expect(await wizard.getInputBoxTitle()).to.have.string('3/7');
134+
expect(await wizard.getInputBoxTitle()).to.have.string('3/8');
136135
await wizard.next();
137136

138-
expect(await wizard.getInputBoxTitle()).to.have.string('4/7');
137+
expect(await wizard.getInputBoxTitle()).to.have.string('4/8');
139138
await wizard.next();
140139

141-
expect(await wizard.getInputBoxTitle()).to.have.string('5/7');
140+
expect(await wizard.getInputBoxTitle()).to.have.string('5/8');
142141
await wizard.next();
143142

144-
expect(await wizard.getInputBoxTitle()).to.have.string('6/7');
143+
expect(await wizard.getInputBoxTitle()).to.have.string('6/8');
145144
await wizard.next();
146145

147-
expect(await wizard.getInputBoxTitle()).to.have.string('7/7');
146+
expect(await wizard.getInputBoxTitle()).to.have.string('7/8');
147+
await wizard.focusQuickPick(0);
148+
await wizard.next();
149+
150+
expect(await wizard.getInputBoxTitle()).to.have.string('8/8');
151+
await wizard.prev();
152+
153+
expect(await wizard.getInputBoxTitle()).to.have.string('7/8');
148154
await wizard.prev();
149155

150-
expect(await wizard.getInputBoxTitle()).to.have.string('6/7');
156+
expect(await wizard.getInputBoxTitle()).to.have.string('6/8');
151157
await wizard.prev();
152158

153-
expect(await wizard.getInputBoxTitle()).to.have.string('5/7');
159+
expect(await wizard.getInputBoxTitle()).to.have.string('5/8');
154160
await wizard.prev();
155161

156-
expect(await wizard.getInputBoxTitle()).to.have.string('4/7');
162+
expect(await wizard.getInputBoxTitle()).to.have.string('4/8');
157163
await wizard.prev();
158164

159-
expect(await wizard.getInputBoxTitle()).to.have.string('3/7');
165+
expect(await wizard.getInputBoxTitle()).to.have.string('3/8');
160166
await wizard.prev();
161167

162-
expect(await wizard.getInputBoxTitle()).to.have.string('2/7');
168+
expect(await wizard.getInputBoxTitle()).to.have.string('2/8');
163169
await wizard.prev();
164170

165-
expect(await wizard.getInputBoxTitle()).to.have.string('1/7');
171+
expect(await wizard.getInputBoxTitle()).to.have.string('1/8');
166172
expect(await wizard.getBackButton()).to.not.be.ok;
167173
await wizard.next();
168174

169-
expect(await wizard.getInputBoxTitle()).to.have.string('2/7');
175+
expect(await wizard.getInputBoxTitle()).to.have.string('2/8');
170176
await wizard.prev();
171177

172-
expect(await wizard.getInputBoxTitle()).to.have.string('1/7');
178+
expect(await wizard.getInputBoxTitle()).to.have.string('1/8');
173179
expect(await wizard.getBackButton()).to.not.be.ok;
174180

175181
await wizard.cancel();
@@ -333,7 +339,7 @@ describe('Project generation tests', function() {
333339
* validation messages
334340
*/
335341
it('should have correct input validation messages', async function() {
336-
this.timeout(30000);
342+
this.timeout(60000);
337343
const wizard: ProjectGenerationWizard = await ProjectGenerationWizard.openWizard(driver);
338344
await wizard.next();
339345

@@ -430,7 +436,7 @@ describe('Project generation tests', function() {
430436
* Tests if the extensions picker displays extensions without duplicates.
431437
*/
432438
it('should display extensions without duplicates', async function() {
433-
this.timeout(60000);
439+
this.timeout(120000);
434440
const wizard: ProjectGenerationWizard = await ProjectGenerationWizard.openWizard(driver);
435441
await wizard.next();
436442
await wizard.next();

0 commit comments

Comments
 (0)