From b3106f2ab16667e34a7328dcf1533ec551a760a6 Mon Sep 17 00:00:00 2001 From: Power-Maverick Date: Wed, 29 Dec 2021 08:46:24 -0500 Subject: [PATCH] Resolving #35 --- package.json | 12 ++++++++++-- package.nls.json | 3 ++- src/helpers/templateHelper.ts | 15 +++++++++++---- src/utils/Config.ts | 1 + src/utils/Constants.ts | 2 +- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index e68a015..517fae8 100644 --- a/package.json +++ b/package.json @@ -354,8 +354,16 @@ "dataverse-devtools.enableEarlyAccessPreview": { "type": "boolean", "default": false, - "markdownDescription": "%dvdt.config.enablePreview%", - "scope": "window" + "markdownDescription": "%dvdt.config.enablePreview%" + }, + "dataverse-devtools.defaultTypeScriptTemplate": { + "default": "none", + "enum": [ + "None", + "Plain TypeScript", + "Webpack" + ], + "markdownDescription": "%dvdt.config.defaultTSTemplate%" } } } diff --git a/package.nls.json b/package.nls.json index 2eaea54..0d0ac3b 100644 --- a/package.nls.json +++ b/package.nls.json @@ -3,5 +3,6 @@ "dvdt.explorer.category": "Explorer", "dvdt.menus.group": "dvdevtools", "dvdt.config.title": "Dataverse DevTools", - "dvdt.config.enablePreview": "Enable a preview features for Dataverse DevTools. See [documentation for all available preview features](https://github.com/Power-Maverick/DataverseDevTools-VSCode#-early-access-preview).\n\n> _Note: these features are not fully tested; so if you encounter any bugs please report them on GitHub (your name will appear on the contributors list)._" + "dvdt.config.enablePreview": "Enable a preview features for Dataverse DevTools. See [documentation for all available preview features](https://github.com/Power-Maverick/DataverseDevTools-VSCode#-early-access-preview).\n\n> _Note: these features are not fully tested; so if you encounter any bugs please report them on GitHub (your name will appear on the contributors list)._", + "dvdt.config.defaultTSTemplate": "Specifies how Dataverse DevTools should behave when you initiate a TypeScript project. This will skip the extra question during TS project initialization when you either select `Plain TypeScript` or `Webpack`" } diff --git a/src/helpers/templateHelper.ts b/src/helpers/templateHelper.ts index e4ba0c0..c246dcc 100644 --- a/src/helpers/templateHelper.ts +++ b/src/helpers/templateHelper.ts @@ -1,12 +1,13 @@ import * as vscode from "vscode"; import * as path from "path"; +import * as config from "../utils/Config"; +import fetch from "node-fetch"; import { copyFolderOrFile, createFolder, pathExists, readFileSync, writeFileSync } from "../utils/FileSystem"; import { Commands } from "../terminals/commands"; import { Console } from "../terminals/console"; import { extensionName, tsTemplateType } from "../utils/Constants"; import { Placeholders } from "../utils/Placeholders"; import { ErrorMessages } from "../utils/ErrorMessages"; -import fetch from "node-fetch"; import { pascalize } from "../utils/ExtensionMethods"; export class TemplateHelper { @@ -16,9 +17,15 @@ export class TemplateHelper { constructor(private vscontext: vscode.ExtensionContext) {} public async initiateTypeScriptProject(wsPath: string) { - let tsTemplateTypeOptions: string[] = tsTemplateType; - let tsTemplateTypeOptionsQuickPick: vscode.QuickPickOptions = Placeholders.getQuickPickOptions(Placeholders.tsTemplateType); - let tsTemplateTypeResponse: string | undefined = await vscode.window.showQuickPick(tsTemplateTypeOptions, tsTemplateTypeOptionsQuickPick); + let tsTemplateTypeResponse: string | undefined; + + if (config.get("defaultTypeScriptTemplate") === "None") { + let tsTemplateTypeOptions: string[] = tsTemplateType; + let tsTemplateTypeOptionsQuickPick: vscode.QuickPickOptions = Placeholders.getQuickPickOptions(Placeholders.tsTemplateType); + tsTemplateTypeResponse = await vscode.window.showQuickPick(tsTemplateTypeOptions, tsTemplateTypeOptionsQuickPick); + } else { + tsTemplateTypeResponse = config.get("defaultTypeScriptTemplate"); + } const extPath = this.vscontext.extensionUri.fsPath; const tsFolderUri = path.join(extPath, "resources", "templates", "TypeScript"); diff --git a/src/utils/Config.ts b/src/utils/Config.ts index 71d995f..1f375ad 100644 --- a/src/utils/Config.ts +++ b/src/utils/Config.ts @@ -2,6 +2,7 @@ import { workspace } from "vscode"; import { configSectionName } from "./Constants"; export function get(key: "enableEarlyAccessPreview"): boolean; +export function get(key: "defaultTypeScriptTemplate"): "None" | "Plain TypeScript" | "Webpack"; export function get(key: any) { const extensionConfig = workspace.getConfiguration(configSectionName); diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index ccbe8ec..7a2ce3b 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -18,7 +18,7 @@ export const solDefinitionsStoreKey: string = `CurrentSolutions`; export const smartMatchStoreKey: string = `CurrentSmartMatch`; export const environmentTypes: string[] = ["Dev", "QA", "UAT", "Prod"]; export const loginTypes: string[] = ["Username/Password", "Microsoft Login Prompt", "Client Id and Secret"]; -export const tsTemplateType: string[] = ["TypeScript Only", "Webpack"]; +export const tsTemplateType: string[] = ["Plain TypeScript", "Webpack"]; export const connectionStatusBarUniqueId: string = `${extensionPrefix}.StatusBarConnectStatus`; export const maxRetries: number = 5; export const terminalName: string = "Dataverse DevTools";