Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
// Tasks are shell tasks calling the local gulp, so they don't depend on VS Code's
// gulp task auto-detection (gulp.autoDetect is "off" by default).
"version": "2.0.0",
"command": "gulp",
"type": "shell",
"args": ["--simple-tasks --no-color"],
"isBackground": true,
"tasks": [
{
"type": "gulp",
"task": "watch",
"label": "gulp: watch",
"type": "shell",
"command": "npx gulp watch --no-color",
"problemMatcher": ["$tsc-watch"],
"isBackground": true,
"group": {
Expand All @@ -18,17 +17,20 @@
}
},
{
"type": "gulp",
"task": "lint",
"label": "gulp: lint",
"type": "shell",
"command": "npx gulp lint --no-color",
"presentation": {
"reveal": "always",
"panel": "shared"
},
"problemMatcher": ["$eslint-stylish"]
},
{
"type": "gulp",
"task": "test",
"label": "gulp: test",
"type": "shell",
"command": "npx gulp test --no-color",
"problemMatcher": [],
"group": {
"kind": "test",
"isDefault": true
Expand Down
4 changes: 3 additions & 1 deletion extension/src/client/command/ChangeMavenProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class MavenProfileItem implements vscode.QuickPickItem {
}

get description(): string {
return `(${this.profile["vro.host"]})` || ""
const host = ConfigurationManager.profileHostKeys.map(key => this.profile[key]).find(value => !!value)

return host ? `(${host})` : ""
}

constructor(entry: [string, MavenProfile]) {
Expand Down
4 changes: 3 additions & 1 deletion extension/src/client/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export enum ProjectArchetypes {
Xml = "com.vmware.pscoe.o11n:xml-package",
Vra = "com.vmware.pscoe.vra:vra-package",
VraNg = "com.vmware.pscoe.vra-ng:vra-ng-package",
Polyglot = "com.vmware.pscoe.polyglot:polyglot-project"
Polyglot = "com.vmware.pscoe.polyglot:polyglot-project",
VcfaAllApps = "com.vmware.pscoe.vcf:all-apps-package",
Vrops = "com.vmware.pscoe.vrops:vrops-package"
}

export enum LanguageServerConfig {
Expand Down
24 changes: 24 additions & 0 deletions extension/src/client/provider/task/DefaultTasksJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,29 @@ export const TASKS_BY_TOOLCHAIN_PARENT: Record<ProjectArchetypes, VrealizeTaskCo
label: "Build",
command: "mvn clean package"
}
],

[ProjectArchetypes.VcfaAllApps]: [
{
label: "Push",
command:
"mvn clean package vcfa-all-apps:push -DincludeDependencies=false -DskipTests -P${config:vrdev.maven.profile}"
},
{
label: "Pull",
command: "mvn vcfa-all-apps:pull -P${config:vrdev.maven.profile}"
}
],

[ProjectArchetypes.Vrops]: [
{
label: "Push",
command:
"mvn clean package vrops:push -DincludeDependencies=false -DskipTests -P${config:vrdev.maven.profile}"
},
{
label: "Pull",
command: "mvn vrops:pull -P${config:vrdev.maven.profile}"
}
]
}
16 changes: 13 additions & 3 deletions extension/src/client/system/ConfigurationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
AutoWire,
BaseConfiguration,
Logger,
MavenProfile,
MavenProfilesMap,
MavenProfileWrapper,
VrealizeSettings
Expand All @@ -26,6 +27,15 @@ export class ConfigurationManager extends BaseConfiguration implements Registrab
private homeDir = process.env[process.platform === "win32" ? "USERPROFILE" : "HOME"] ?? "~"
private readonly logger = Logger.get("ConfigurationManager")

/** A Maven profile is listed when it defines at least one of these hosts */
static readonly profileHostKeys: (keyof MavenProfile)[] = [
"vro.host",
"vrang.host",
"vcd.host",
"vrops.host",
"vcfa.host"
]

readonly settingsXmlPath: string = path.resolve(this.homeDir, ".m2", "settings.xml")

constructor() {
Expand All @@ -45,7 +55,7 @@ export class ConfigurationManager extends BaseConfiguration implements Registrab
try {
return super.activeProfile
} catch (e) {
vscode.window.showErrorMessage(e.message)
vscode.window.showErrorMessage((e as Error).message)
throw e
}
}
Expand Down Expand Up @@ -118,15 +128,15 @@ export class ConfigurationManager extends BaseConfiguration implements Registrab
for (const profile of allProfiles) {
const propKeys = Object.keys(profile.properties || {})

if (propKeys.some(key => key === "vro.host")) {
if (propKeys.some(key => ConfigurationManager.profileHostKeys.includes(key as keyof MavenProfile))) {
vroProfiles[profile.id] = {
id: profile.id,
...profile.properties
}
}
}

this.logger.info("Found vRO profiles: ", vroProfiles)
this.logger.info("Found profiles: ", vroProfiles)
this.allProfiles = vroProfiles
this._onDidChangeProfiles.fire(vroProfiles)
}
Expand Down
18 changes: 15 additions & 3 deletions extension/src/client/ui/StatusBarController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,23 @@ export class StatusBarController implements Registrable, vscode.Disposable {

const serverConfIsValid = !!this.profileName
if (serverConfIsValid) {
if (this.env.hasRelevantProject()) {
const profile = this.config.activeProfile

// hint collection is only possible against vRO; other profiles (vROps, VCD, VCFA) have no vro.host
if (this.env.hasRelevantProject() && profile.getOptional("vro.host", "")) {
this.collectionButton.show()

this.collectionButton.text = "$(cloud-download)"
this.collectionButton.command = Commands.TriggerServerCollection
this.collectionButton.tooltip = "Trigger vRO hint collection"
this.collectionButton.color = undefined
} else {
this.collectionButton.hide()
}

const hostname = this.config.activeProfile.get("vro.host")
const hostname = ConfigurationManager.profileHostKeys
.map(key => profile.getOptional(key, ""))
.find(value => !!value)
this.collectionStatus.text = `$(server) ${this.profileName} (${hostname})`
this.collectionStatus.tooltip = "Change active profile"
this.collectionStatus.command = Commands.ChangeProfile
Expand All @@ -91,7 +98,12 @@ export class StatusBarController implements Registrable, vscode.Disposable {
private onConfigurationOrProfilesChanged() {
const currentProfileName = this.config.hasActiveProfile() ? this.config.activeProfile.get("id") : undefined

if (this.verifyConfiguration() && currentProfileName !== this.profileName && this.env.hasRelevantProject()) {
if (
this.verifyConfiguration() &&
currentProfileName !== this.profileName &&
this.env.hasRelevantProject() &&
this.config.activeProfile.getOptional("vro.host", "")
) {
vscode.commands.executeCommand(Commands.TriggerServerCollection)
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"onCommand:vrdev.blueprint.upload",
"onCommand:vrdev.blueprint.deploy"
],
"main": "./extension/dist/extension",
"main": "./extension/out/extension",
"icon": "assets/logo.png",
"contributes": {
"viewsContainers": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>

<groupId>com.vmware.pscoe.o11n</groupId>
<artifactId>test-pom</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>

<modules>
<module>actions</module>
</modules>

<parent>
<groupId>com.vmware.pscoe.o11n</groupId>
<artifactId>base-package</artifactId>
<version>1.0.0</version>
</parent>
</project>
6 changes: 6 additions & 0 deletions packages/node/vrdt-common/src/__tests__/maven.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe("Maven", () => {
const PARTIAL_POM_PATH = path.join(__dirname, "__fixtures__/partial.pom.xml")
const UNKNOWN_POM_PATH = path.join(__dirname, "__fixtures__/unknown.pom.xml")
const BASE_POM_PATH = path.join(__dirname, "__fixtures__/base.pom.xml")
const BASE_SINGLE_MODULE_POM_PATH = path.join(__dirname, "__fixtures__/base-single-module.pom.xml")
const ACTIONS_POM_PATH = path.join(__dirname, "__fixtures__/actions.pom.xml")

describe("PomFile", () => {
Expand Down Expand Up @@ -54,5 +55,10 @@ describe("Maven", () => {
expect(basePom.isBase).toBe(true)
expect(basePom.modules).toEqual(["actions", "workflows", "vra"])
})

it("Can read pom.xml with a single module", () => {
const basePom = new PomFile(BASE_SINGLE_MODULE_POM_PATH)
expect(basePom.modules).toEqual(["actions"])
})
})
})
3 changes: 2 additions & 1 deletion packages/node/vrdt-common/src/maven/MavenProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface MavenProfile extends Partial<Record<MavenProfileKeys, string>>
id: string
}

type MavenProfileKeys = VroProfileKeys | VraProfileKeys
type MavenProfileKeys = VroProfileKeys | VraProfileKeys | OtherHostKeys
type VroProfileKeys =
| "vro.host"
| "vro.port"
Expand All @@ -28,3 +28,4 @@ type VraProfileKeys =
| "vrang.password"
| "vrang.tenant"
| "vrang.refresh.token"
type OtherHostKeys = "vcd.host" | "vrops.host" | "vcfa.host"
7 changes: 5 additions & 2 deletions packages/node/vrdt-common/src/maven/PomFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export class PomFile {
"typescript-project-all": "com.vmware.pscoe.o11n",
"vra-package": "com.vmware.pscoe.vra",
"vra-ng-package": "com.vmware.pscoe.vra-ng",
"polyglot-project": "com.vmware.pscoe.polyglot"
"polyglot-project": "com.vmware.pscoe.polyglot",
"all-apps-package": "com.vmware.pscoe.vcf",
"vrops-package": "com.vmware.pscoe.vrops"
}

readonly jsonContent: any
Expand Down Expand Up @@ -51,7 +53,8 @@ export class PomFile {
return []
}

return modules.module || []
// a single <module> is parsed as a string rather than an array
return modules.module ? [].concat(modules.module) : []
}

constructor(public readonly filePath: string) {
Expand Down
Loading