Skip to content

Commit

Permalink
Resolving #35
Browse files Browse the repository at this point in the history
  • Loading branch information
Power-Maverick committed Dec 29, 2021
1 parent 3a3ce00 commit b3106f2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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%"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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`"
}
15 changes: 11 additions & 4 deletions src/helpers/templateHelper.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/utils/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit b3106f2

Please sign in to comment.