Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
VenelinBakalov authored Jun 19, 2024
2 parents 6ae18d8 + 2fe4ece commit 0b3978c
Show file tree
Hide file tree
Showing 37 changed files with 631 additions and 367 deletions.
25 changes: 8 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14.x, 16.x]
os: [ubuntu-latest, macOS-latest, windows-latest]
node-version: [19.6.0]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
CI: true
steps:
# - name: Set git config
# if: runner.os == 'Windows'
# shell: bash
# run: git config --global core.autocrlf true

- uses: actions/checkout@v2

- name: echo github.ref
Expand All @@ -36,12 +31,12 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Use NPM 8
run: npm install -g npm@8.3.1 # lock to 8.3.1 until actions/setup-node#411 and npm/cli#4341 are fixed
- name: Install NPM 9.4.0
run: npm install -g npm@9.4.0 # lock to 9.4.0 until actions/setup-node#411 and npm/cli#4341 are fixed

- name: Set version number of package.json and build artifact
id: version_step
if: runner.os == 'macOS'
if: runner.os == 'ubuntu-latest'
env:
RUN_NUMBER: ${{ github.run_number }}
run: |
Expand Down Expand Up @@ -76,17 +71,13 @@ jobs:
- name: Install dependencies
run: "npm ci"

- name: Lint, compile and test
run: "node node_modules/gulp/bin/gulp.js lint test"
if: runner.os != 'macOS'

- name: Lint, compile, test and package
run: "node node_modules/gulp/bin/gulp.js package"
if: runner.os == 'macOS'
if: runner.os == 'ubuntu-latest'

- name: Publish code coverage report
uses: codecov/codecov-action@v1
if: runner.os == 'macOS'
if: runner.os == 'ubuntu-latest'
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: "**/coverage/*.json"
Expand All @@ -95,7 +86,7 @@ jobs:

- name: Upload artifact
uses: actions/upload-artifact@v2
if: runner.os == 'macOS'
if: runner.os == 'ubuntu-latest'
with:
name: vrealize-developer-tools-${{steps.version_step.outputs.version_build}}.vsix
path: "*.vsix"
10 changes: 5 additions & 5 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
build_release:
name: Build and Release
runs-on: macos-latest
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
Expand All @@ -17,13 +17,13 @@ jobs:
- name: echo github.ref
run: echo ${{ github.ref }}

- name: Use Node.js 16.x
- name: Use Node.js 19.6.0
uses: actions/setup-node@v2
with:
node-version: 16.x
node-version: 19.6.0

- name: Use NPM 8
run: npm install -g npm@8.3.1 # lock to 8.3.1 until actions/setup-node#411 and npm/cli#4341 are fixed
- name: Use NPM 9.4.0
run: npm install -g npm@9.4.0 # lock to 9.4.0 until actions/setup-node#411 and npm/cli#4341 are fixed

- name: Install sha256sum and minisign
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ on:
jobs:
publish:
name: Publish to Visual Studio Marketplace and GitHub Packages
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- name: Use Node.js 16.x
- name: Use Node.js 19.6.0
uses: actions/setup-node@v2
with:
node-version: 16.x
node-version: 19.6.0

- name: Install vsce
run: npm install -g vsce
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"**/build/azure-pipelines/**/*.yml": "azure-pipelines"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"eslint.validate": ["javascript", "typescript"],

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

To use most of the vRealize Developer Tools's functionality, you will need a development [vRealize Orchestrator](https://www.vmware.com/products/vrealize-orchestrator.html) instance and to set up vRealize Build Tools.

- [vRealize Build Tools v2.12.5+](https://labs.vmware.com/flings/vrealize-build-tools)
- [vRealize Build Tools v2.29.0+](https://github.com/vmware/build-tools-for-vmware-aria)
- Access to Artifact Repository - [setup instructions](https://github.com/vmware/vrealize-developer-tools/wiki/Setup-Artifact-Repository)
- maven v3.5+ available on the PATH system variable
- jdk 1.8
Expand Down
2 changes: 1 addition & 1 deletion extension/src/client/command/DeletePackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class DeletePackage extends Command<void> {

constructor(config: ConfigurationManager, environment: EnvironmentManager) {
super()
this.restClient = new VroRestClient(config, environment)
this.restClient = new VroRestClient(config)
}

async execute(context: vscode.ExtensionContext, node: PackageNode): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/client/command/FetchWorkflowSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class FetchWorkflowSchema extends Command<void> {

constructor(config: ConfigurationManager, environment: EnvironmentManager) {
super()
this.restClient = new VroRestClient(config, environment)
this.restClient = new VroRestClient(config)
}

async execute(context: vscode.ExtensionContext, node: WorkflowNode): Promise<void> {
Expand Down
105 changes: 58 additions & 47 deletions extension/src/client/command/RunAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,53 +147,17 @@ export class RunAction extends Command<void> {
}

private async getScriptContent(document: vscode.TextDocument): Promise<string> {
if (document.languageId === "javascript") {
return document.getText()
}

if (document.languageId === "typescript") {
let inputFilePath = document.uri.fsPath
let inputFileName = path.basename(inputFilePath)
let tsNamespace: string | undefined
let rootPath: string
let srcPath: string

if (!document.isUntitled) {
const workspacePath = vscode.workspace.getWorkspaceFolder(document.uri)
if (!workspacePath) {
throw new Error(`File ${inputFileName} is not part of the workspace`)
}

rootPath = workspacePath.uri.fsPath
srcPath = path.join(rootPath, "src")
const pomFilePath = path.join(workspacePath.uri.fsPath, "pom.xml")

if (!fs.existsSync(pomFilePath)) {
throw new Error(`Missing pom.xml in workspace ${workspacePath.name}`)
}

const pomFile = new PomFile(pomFilePath)
tsNamespace = `${pomFile.groupId}.${pomFile.artifactId}`
} else {
rootPath = tmp.dirSync({ prefix: "o11n-ts-" }).name
srcPath = path.join(rootPath, "src")
inputFileName = inputFileName.endsWith(".ts") ? inputFileName : `${inputFileName}.ts`
inputFilePath = path.join(srcPath, inputFileName)
fs.mkdirpSync(path.dirname(inputFilePath))
fs.writeFileSync(inputFilePath, document.getText(), { encoding: "utf8" })
switch (document.languageId) {
case "javascript": {
return document.getText()
}
case "typescript": {
return this.getTypescriptContent(document)
}
default: {
return Promise.reject(new Error(`Unsupported language ID: '${document.languageId}'`))
}

this.outputChannel.appendLine(`# Compiling ${inputFileName}`)
const tsFileRelativePath = path.relative(srcPath, inputFilePath)
this.logger.debug(`Input TS file: ${inputFilePath}`)
const outputFilePath = await this.compileFile(tsFileRelativePath, rootPath, tsNamespace)
this.logger.debug(`Output JS file: ${outputFilePath}`)
const scriptContent = fs.readFileSync(outputFilePath, { encoding: "utf8" })

return scriptContent
}

return Promise.reject(`Unsupported language ID: ${document.languageId}`)
}

/**
Expand All @@ -213,8 +177,55 @@ export class RunAction extends Command<void> {
command += ` -n ${namespace}`
}
await proc.exec(command, { cwd: projectDirPath }, this.logger)

return path.join(outputDir, inputFile.replace(/\.ts$/, ".js"))
}

/**
* Return the typescript content of a vscode text document.
* @param document - reference to the vscode document.
*
* @returns the compiled javascript from the typescript document.
*/
private async getTypescriptContent(document: vscode.TextDocument): Promise<string> {
let inputFilePath = document.uri.fsPath
let inputFileName = path.basename(inputFilePath)
let tsNamespace: string | undefined
let rootPath: string
let srcPath: string

if (!document.isUntitled) {
const workspacePath = vscode.workspace.getWorkspaceFolder(document.uri)
if (!workspacePath) {
throw new Error(`File ${inputFileName} is not part of the workspace`)
}
rootPath = workspacePath.uri.fsPath
srcPath = path.join(rootPath, "src")
const pomFilePath = path.join(workspacePath.uri.fsPath, "pom.xml")
if (!fs.existsSync(pomFilePath)) {
throw new Error(`Missing pom.xml in workspace ${workspacePath.name}`)
}

const pomFile = new PomFile(pomFilePath)
tsNamespace = `${pomFile.groupId}.${pomFile.artifactId}`
} else {
rootPath = tmp.dirSync({ prefix: "o11n-ts-" }).name
srcPath = path.join(rootPath, "src")
inputFileName = inputFileName.endsWith(".ts") ? inputFileName : `${inputFileName}.ts`
inputFilePath = path.join(srcPath, inputFileName)
fs.mkdirpSync(path.dirname(inputFilePath))
fs.writeFileSync(inputFilePath, document.getText(), { encoding: "utf8" })
}

this.outputChannel.appendLine(`# Compiling ${inputFileName}`)
const tsFileRelativePath = path.relative(srcPath, inputFilePath)
this.logger.debug(`Input TS file: ${inputFilePath}`)
const outputFilePath = await this.compileFile(tsFileRelativePath, rootPath, tsNamespace)
this.logger.debug(`Output JS file: ${outputFilePath}`)
const scriptContent = fs.readFileSync(outputFilePath, { encoding: "utf8" })

return scriptContent
}
}

class ActionRunner {
Expand All @@ -225,7 +236,7 @@ class ActionRunner {
private executionToken: string

constructor(config: ConfigurationManager, private environment: EnvironmentManager) {
this.restClient = new VroRestClient(config, environment)
this.restClient = new VroRestClient(config)
this.mavenProxy = new MavenCliProxy(environment, config.vrdev.maven, this.logger)
}

Expand Down Expand Up @@ -296,7 +307,7 @@ class ActionRunner {
if (!fs.existsSync(storagePath)) {
fs.mkdirSync(storagePath)
}

// exec
await this.mavenProxy.copyDependency(
"com.vmware.pscoe.o11n",
"exec",
Expand Down
2 changes: 1 addition & 1 deletion extension/src/client/command/ShowActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ShowActions extends Command<void> {

constructor(environment: EnvironmentManager, private config: ConfigurationManager) {
super()
this.restClient = new VroRestClient(config, environment)
this.restClient = new VroRestClient(config)
}

async execute(context: vscode.ExtensionContext): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/client/command/ShowConfigurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ShowConfigurations extends Command<void> {

constructor(environment: EnvironmentManager, config: ConfigurationManager) {
super()
this.restClient = new VroRestClient(config, environment)
this.restClient = new VroRestClient(config)
}

async execute(context: vscode.ExtensionContext): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/client/command/ShowResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ShowResources extends Command<void> {

constructor(environment: EnvironmentManager, config: ConfigurationManager) {
super()
this.restClient = new VroRestClient(config, environment)
this.restClient = new VroRestClient(config)
}

async execute(context: vscode.ExtensionContext): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/client/command/ShowWorkflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ShowWorkflows extends Command<void> {

constructor(environment: EnvironmentManager, config: ConfigurationManager) {
super()
this.restClient = new VroRestClient(config, environment)
this.restClient = new VroRestClient(config)
}

async execute(context: vscode.ExtensionContext): Promise<void> {
Expand Down
Loading

0 comments on commit 0b3978c

Please sign in to comment.