-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
890a51a
commit 694aff2
Showing
7 changed files
with
43 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
import { config, fileUtils, terminalUtils } from '../utils'; | ||
import { terminalBuilder } from '../builders'; | ||
|
||
export class generateFunctionalSpecCommand implements ICommand { | ||
export class generateFunctionalSpecCommand implements ICommand { | ||
static commandName: string = "extension.generateFunctionalSpec"; | ||
|
||
private builder : terminalBuilder = new terminalBuilder(); | ||
private builder: terminalBuilder = new terminalBuilder(); | ||
|
||
RunCommand() { | ||
if(config.mainScriptSetting === undefined || config.folderSetting === undefined) | ||
if (config.mainScriptSetting === undefined) { | ||
console.error("Main script not set in settings"); | ||
return | ||
}; | ||
console.info("Script setting: " + config.mainScriptSetting); | ||
|
||
if (config.mainScriptSetting === undefined || config.folderSetting === undefined) { | ||
console.error("Folder not set in settings"); | ||
return; | ||
|
||
}; | ||
console.info("Folder setting: " + config.folderSetting); | ||
|
||
const mainScriptPath: string = fileUtils.generateWorkspacePath([config.folderSetting, config.mainScriptSetting]); | ||
|
||
const terminal = this.builder.setName("Ampersand generate functional spec") | ||
.setWorkingDir(['ampersand']) | ||
.getTerminal(); | ||
.setWorkingDir(['ampersand']) | ||
.getTerminal(); | ||
|
||
terminalUtils.RunCommandsInExistingTerminal(terminal, | ||
[`ampersand documentation --no-text --format docx ${mainScriptPath}`, | ||
`ampersand documentation ${mainScriptPath} --format docx --no-graphics --language=NL --ConceptualAnalysis --verbosity debug`], | ||
[`ampersand documentation --no-text --format docx ${mainScriptPath}`, | ||
`ampersand documentation ${mainScriptPath} --format docx --no-graphics --language=NL --ConceptualAnalysis --verbosity debug`], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,55 @@ | ||
import { fileUtils, terminalUtils } from "../utils"; | ||
import * as vscode from 'vscode'; | ||
import { terminalBuilder } from "../builders/terminalBuilder"; | ||
import { manifest } from '../models/manifest'; | ||
|
||
export class generatePrototypeCommand implements ICommand { | ||
static commandName: string = "extension.generatePrototype"; | ||
|
||
static portForwardTerminal: vscode.Terminal | undefined = undefined; | ||
private builder : terminalBuilder = new terminalBuilder(); | ||
private builder: terminalBuilder = new terminalBuilder(); | ||
|
||
private manifestFile : manifest; | ||
async RunCommand() { | ||
this.tryKillPortForwardedProcessAndTerminal(); | ||
|
||
constructor(context: vscode.ExtensionContext) | ||
{ | ||
this.manifestFile = new manifest(context.extensionPath); | ||
} | ||
|
||
async RunCommand() | ||
{ | ||
this.tryKillPortForwardedProcessAndTerminal(); | ||
|
||
const data = await vscode.workspace.fs.readFile(this.manifestFile.templateFileUri); | ||
this.replaceMarkers(data); | ||
} | ||
|
||
private async tryKillPortForwardedProcessAndTerminal() | ||
{ | ||
if(generatePrototypeCommand.portForwardTerminal === undefined) | ||
private async tryKillPortForwardedProcessAndTerminal() { | ||
if (generatePrototypeCommand.portForwardTerminal === undefined) | ||
return; | ||
|
||
const buildTerminal = this.builder.setName("Cleanup") | ||
.setVisibility(false) | ||
.getTerminal(); | ||
.setVisibility(false) | ||
.getTerminal(); | ||
|
||
//get the processID from the terminal that needs to be killed | ||
const terminalToKillPID = await generatePrototypeCommand.portForwardTerminal.processId; | ||
|
||
terminalUtils.RunCommandsInExistingTerminal(buildTerminal, | ||
[`PID=$(ps -ef | grep 'kubectl port-forward' | grep -v grep | awk '{print $2}')`, | ||
`kill $PID`, | ||
(`kill -9 ${terminalToKillPID}`)]); | ||
`kill $PID`, | ||
(`kill -9 ${terminalToKillPID}`)]); | ||
|
||
//Get own terminal PID to kill it later | ||
const killerTerminalPID = await buildTerminal.processId; | ||
|
||
//Kill self to cleanup | ||
terminalUtils.RunCommandsInExistingTerminal(buildTerminal,[(`kill -9 ${killerTerminalPID}`)]); | ||
} | ||
|
||
private async replaceMarkers(data: Uint8Array) | ||
{ | ||
const newData: Uint8Array = fileUtils.replaceMarkers(data, new Map<string, string>( | ||
[ | ||
['{{zipFileContent}}', this.manifestFile.encodedZipContent], | ||
['{{mainScript}}', this.manifestFile.encodedMainScript] | ||
] | ||
)); | ||
//Kill self to cleanup | ||
terminalUtils.RunCommandsInExistingTerminal(buildTerminal, [(`kill -9 ${killerTerminalPID}`)]); | ||
} | ||
|
||
await vscode.workspace.fs.writeFile(this.manifestFile.fileUri, newData); | ||
private async replaceMarkers(data: Uint8Array) { | ||
this.runPrototypeCommand(); | ||
} | ||
|
||
private runPrototypeCommand() | ||
{ | ||
private runPrototypeCommand() { | ||
const deployment: string = 'prototype'; | ||
const service: string = 'prototype'; | ||
generatePrototypeCommand.portForwardTerminal = this.builder.setName("Run prototype in minikube") | ||
.getTerminal(); | ||
const service: string = 'prototype'; | ||
|
||
generatePrototypeCommand.portForwardTerminal = this.builder.setName("Run prototype") | ||
.getTerminal(); | ||
generatePrototypeCommand.portForwardTerminal.show(); | ||
|
||
terminalUtils.RunCommandsInExistingTerminal(generatePrototypeCommand.portForwardTerminal, | ||
[`kubectl apply -f ${this.manifestFile.fileUri.fsPath}`, | ||
`kubectl rollout status deployment/${deployment} --timeout=300s`, | ||
`kubectl port-forward svc/${service} -n default 8000:80`,]); | ||
[`docker compose up -d --build`]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.