From 8166f14258677013305ece0c57829d9bee8435e8 Mon Sep 17 00:00:00 2001 From: Florian Gareis Date: Mon, 19 Nov 2018 19:38:18 +0100 Subject: [PATCH] #4 - Add name option for ui-schema.json file --- tooling/src/index.ts | 6 +++--- vscode-extension/src/extension.ts | 14 +++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tooling/src/index.ts b/tooling/src/index.ts index 32db83d..02934c9 100644 --- a/tooling/src/index.ts +++ b/tooling/src/index.ts @@ -40,7 +40,7 @@ export function cloneAndInstall(repo: String, path: string, callback: (result: s * @param {string} path path to the json schema file * @param {function} callback forwards the current status to the caller */ -export function generateUISchema(path: string, callback: (result: string, type?: string) => void) { +export function generateUISchema(path: string, name: string, callback: (result: string, type?: string) => void) { // Read JSON Schema file readFile(path, 'utf8', (err, data) => { if (err) { @@ -59,9 +59,9 @@ export function generateUISchema(path: string, callback: (result: string, type?: // Check if windows or linux filesystem if(process.platform === 'win32') { - var newPath = path.substring(0, path.lastIndexOf("\\"))+'\\ui-schema.json'; + var newPath = path.substring(0, path.lastIndexOf("\\"))+'\\'+name; } else { - var newPath = path.substring(0, path.lastIndexOf("/"))+'/ui-schema.json'; + var newPath = path.substring(0, path.lastIndexOf("/"))+'/'+name; } // Write UI Schema file diff --git a/vscode-extension/src/extension.ts b/vscode-extension/src/extension.ts index b6a5e52..397bd34 100644 --- a/vscode-extension/src/extension.ts +++ b/vscode-extension/src/extension.ts @@ -43,9 +43,17 @@ export function activate(context: vscode.ExtensionContext) { return; } else { let path = args.fsPath; - showMessage('Generating UI Schema: '+path); - tooling.generateUISchema(path, function(result: string, type: string) { - showMessage(result, type); + + let options: vscode.InputBoxOptions = { + prompt: "Label: ", + placeHolder: "Enter a filename for your UI Schema (default: ui-schema.json)" + } + vscode.window.showInputBox(options).then(name => { + if (!name) name = 'ui-schema.json'; + showMessage('Generating UI Schema: '+path); + tooling.generateUISchema(path, name, function(result: string, type: string) { + showMessage(result, type); + }); }); } });