mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 09:35:37 -05:00
Fix for user using command palette (#18948)
* fix for user using command palette command * rework if a user uses the create azure function via the command * for now only show in vs code * move logic to azureFunctionService + address comments * fix command location * address comments * fix validateFunction
This commit is contained in:
@@ -32,6 +32,8 @@ export const timeoutProjectError = localize('timeoutProjectError', 'Timed out wa
|
||||
export const errorNewAzureFunction = localize('errorNewAzureFunction', 'Error creating new Azure Function: {0}');
|
||||
export const azureFunctionsExtensionNotInstalled = localize('azureFunctionsExtensionNotInstalled', 'Azure Functions extension must be installed in order to use this feature.');
|
||||
export const azureFunctionsProjectMustBeOpened = localize('azureFunctionsProjectMustBeOpened', 'A C# Azure Functions project must be present in order to create a new Azure Function for this table.');
|
||||
export const needConnection = localize('needConnection', 'A connection is required to use Azure Function with SQL Binding');
|
||||
export const selectDatabase = localize('selectDatabase', 'Select Database');
|
||||
|
||||
// Insert SQL binding
|
||||
export const hostFileName = 'host.json';
|
||||
@@ -42,6 +44,7 @@ export const azureFunctionLocalSettingsFileName = 'local.settings.json';
|
||||
export const vscodeOpenCommand = 'vscode.open';
|
||||
|
||||
export const nameMustNotBeEmpty = localize('nameMustNotBeEmpty', "Name must not be empty");
|
||||
export const hasSpecialCharacters = localize('hasSpecialCharacters', "Name must not include special characters");
|
||||
export const yesString = localize('yesString', "Yes");
|
||||
export const noString = localize('noString', "No");
|
||||
export const input = localize('input', "Input");
|
||||
|
||||
@@ -10,6 +10,7 @@ import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as glob from 'fast-glob';
|
||||
import * as cp from 'child_process';
|
||||
import * as constants from '../common/constants';
|
||||
|
||||
export interface ValidationResult {
|
||||
errorMessage: string;
|
||||
@@ -162,6 +163,30 @@ export function escapeClosingBrackets(str: string): string {
|
||||
return str.replace(']', ']]');
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all special characters from object name
|
||||
* @param objectName can include brackets/periods and user entered special characters
|
||||
* @returns the object name without any special characters
|
||||
*/
|
||||
export function santizeObjectName(objectName: string): string {
|
||||
return objectName.replace(/[^a-zA-Z0-9 ]/g, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the input from user entered is valid
|
||||
* @param input from user input
|
||||
* @returns returns error if the input is empty or has special characters, undefined if the input is valid
|
||||
*/
|
||||
export function validateFunctionName(input: string): string | undefined {
|
||||
const specialChars = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
|
||||
if (!input) {
|
||||
return constants.nameMustNotBeEmpty;
|
||||
} else if (specialChars.test(input)) {
|
||||
return constants.hasSpecialCharacters;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the package info for the extension based on where the extension is installed
|
||||
* @returns the package info object
|
||||
|
||||
Reference in New Issue
Block a user