From 2c52c1b2765984ec002f6becc1221a54d280bccc Mon Sep 17 00:00:00 2001 From: Eric Chen Date: Tue, 29 Sep 2020 15:02:04 +0800 Subject: [PATCH] Improve the error message on code snippet and user defined template (#83) --- package-lock.json | 14 +++++++------- package.json | 5 ++--- snippets/snippets.json | 2 +- src/view/ui.ts | 4 ++++ src/view/uiConstants.ts | 1 + 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4e64be9..f508d7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vscode-dtdl", - "version": "0.2.0", + "version": "1.0.0-rc2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2466,9 +2466,9 @@ } }, "dtdl-language-server": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/dtdl-language-server/-/dtdl-language-server-0.4.2.tgz", - "integrity": "sha512-7taXkWOLYwl6aOsL+OiMw4CZtp3o4L5BnKN/wEu0M1Huezk1EIL4jaMB2KPBQB3RKbO4ip9kubT68SdAJ3593g==", + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/dtdl-language-server/-/dtdl-language-server-0.4.3.tgz", + "integrity": "sha512-FoXxrG3VhXRGjruRxx83LzV0unIpPt2B2f4/gICKVm5E6MSpNSglJxEG13pXB7zb4CO7kndDNeqXS2X5iDIyfA==", "requires": { "commander": "^5.0.0", "jsonc-parser": "^2.2.1", @@ -4764,9 +4764,9 @@ } }, "jsonc-parser": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.3.0.tgz", - "integrity": "sha512-b0EBt8SWFNnixVdvoR2ZtEGa9ZqLhbJnOjezn+WP+8kspFm+PFYDN8Z4Bc7pRlDjvuVcADSUkroIuTWWn/YiIA==" + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.3.1.tgz", + "integrity": "sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg==" }, "jsonfile": { "version": "4.0.0", diff --git a/package.json b/package.json index 25d9c47..30d980d 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,8 @@ "name": "vscode-dtdl", "displayName": "DTDL", "description": "This extension provides syntax highlighting to read and edit JSON documents using the Digital Twins Definition Language", - "version": "0.2.0", + "version": "1.0.0-rc3", "publisher": "vsciot-vscode", - "preview": true, "aiKey": "[AIKEY PLACEHOLDER]", "icon": "logo.png", "license": "SEE LICENSE IN LICENSE.txt", @@ -95,7 +94,7 @@ "copy-webpack-plugin": "^6.0.1" }, "dependencies": { - "dtdl-language-server": "^0.4.2", + "dtdl-language-server": "^0.4.3", "fs-extra": "^7.0.1", "vscode-extension-telemetry": "^0.1.6", "vscode-languageclient": "^6.1.3" diff --git a/snippets/snippets.json b/snippets/snippets.json index c3547ce..eb158d7 100644 --- a/snippets/snippets.json +++ b/snippets/snippets.json @@ -16,7 +16,7 @@ "Add DTDL Command" : { "prefix": "dtc", "body" : [ - "{\n\t\"@type\": \"Command\",\n\t\"name\": \"$1\",\n\t\"schema\": $2\n}" + "{\n\t\"@type\": \"Command\",\n\t\"name\": \"$1\"\n}" ], "description": "Adds a DTDL Command" } diff --git a/src/view/ui.ts b/src/view/ui.ts index 1947013..544a141 100644 --- a/src/view/ui.ts +++ b/src/view/ui.ts @@ -85,6 +85,10 @@ export class UI { */ public static async selectTemplateFile(label: string, folder: string): Promise { const files: string[] = Utility.listFile(folder, Constants.TEMPLATE_FILE_GLOB); + if (!files.length) { + const message = `${UIConstants.TEMPLATES_NOT_FOUND_MSG} ${folder}`; + throw new Error(message); + } if (files.length === 1) { return files[0]; } diff --git a/src/view/uiConstants.ts b/src/view/uiConstants.ts index b479831..3fb1b60 100644 --- a/src/view/uiConstants.ts +++ b/src/view/uiConstants.ts @@ -9,4 +9,5 @@ export class UIConstants { public static readonly SELECT_TEMPLATE_FILE_LABEL = "Select template file"; public static readonly INPUT_MODEL_NAME_LABEL = "Input device model name"; public static readonly BROWSE_LABEL = "Browse..."; + public static readonly TEMPLATES_NOT_FOUND_MSG = "No template is found in folder"; }