Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
awickham10 committed Jun 20, 2018
1 parent 8316ec3 commit 77e8cc3
Show file tree
Hide file tree
Showing 26 changed files with 5,325 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
// When enabled, will trim trailing whitespace when you save a file.
"files.trimTrailingWhitespace": true,

// Enable PSScriptAnalyzer
"powershell.scriptAnalysis.enable": true,
"powershell.scriptAnalysis.settingsPath": "PSScriptAnalyzerSettings.psd1"
}
134 changes: 134 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// A task runner that invokes Pester to run all Pester tests under the
// current workspace folder.
// NOTE: This Test task runner requires an updated version of Pester (>=4.0.3)
// in order for the problemMatcher to find failed test information (message, line, file).
// If you don't have that version, you can update Pester from the PowerShell Gallery
// with this command:
//
// PS C:\> Update-Module Pester
//
// If that gives an error like:
// "Module 'Pester' was not installed by using Install-Module, so it cannot be updated."
// then execute:
//
// PS C:\> Install-Module Pester -Scope CurrentUser -Force
//
// NOTE: The Clean, Build and Publish tasks require PSake. PSake can be installed
// from the PowerShell Gallery with this command:
//
// PS C:\> Install-Module PSake -Scope CurrentUser -Force
//
// Available variables which can be used inside of strings:
// ${workspaceFolder} the path of the workspace folder that contains the tasks.json file
// ${workspaceFolderBasename} the name of the workspace folder that contains the tasks.json file without any slashes (/)
// ${file} the current opened file
// ${relativeFile} the current opened file relative to the workspace folder containing the file
// ${fileBasename} the current opened file's basename
// ${fileBasenameNoExtension} the current opened file's basename without the extension
// ${fileDirname} the current opened file's dirname
// ${fileExtname} the current opened file's extension
// ${cwd} the task runner's current working directory on startup
// ${lineNumber} the current selected line number in the active file
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"args": [
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command"
]
}
}
},
"linux": {
"options": {
"shell": {
"executable": "/usr/bin/pwsh",
"args": [
"-NoProfile",
"-Command"
]
}
}
},
"osx": {
"options": {
"shell": {
"executable": "/usr/local/bin/pwsh",
"args": [
"-NoProfile",
"-Command"
]
}
}
},
"tasks": [
{
"label": "Clean",
"type": "shell",
"command": "Invoke-PSake build.ps1 -taskList Clean"
},
{
"label": "Build",
"type": "shell",
"command": "Invoke-PSake build.ps1 -taskList Build",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Test All",
"type": "shell",
"command": "Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true}",
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": [
"$pester"
]
},
{
"label": "Test Current",
"type": "shell",
"command": "$testFile = if ('${fileBasename}' -like '*.Tests.ps1') { '${fileBasename}' } else { '${fileBasenameNoExtension}.Tests.ps1' }; Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true} -Script ('${workspaceRoot}\\Tests\\' + $testFile)",
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": [
{
"owner": "powershell",
"fileLocation": [
"absolute"
],
"severity": "error",
"pattern": [
{
"regexp": "^\\s*(?:\\[-\\]\\s+)(.*?)(?:\\s+\\d+\\.?\\d*\\s*m?s)\\s*$",
"message": 1
},
{
"regexp": "^\\s+at\\s+[^,]+,\\s*(.*?):\\s+line\\s+(\\d+)$",
"file": 1,
"line": 2
}
]
}
]
},
{
"label": "Publish",
"type": "shell",
"command": "Invoke-PSake build.ps1 -taskList Publish"
}
]
}


// "command": "$ProgressPreference = 'SilentlyContinue'; Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true} -Script '${workspaceRoot}/Tests/${fileBasenameNoExtension}.Tests.ps1';",
125 changes: 125 additions & 0 deletions DbVisualizer/DbVisualizer.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#
# Module manifest for module 'DbVisualizer'
#
# Generated by: Andrew Wickham
#
# Generated on: 5/18/2018
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'DbVisualizer.psm1'

# Version number of this module.
ModuleVersion = '0.0.1'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = '11fb0233-dd04-4b32-b3c9-23913d32c4c4'

# Author of this module
Author = 'Andrew Wickham'

# Company or vendor of this module
CompanyName = 'Westfield'

# Copyright statement for this module
Copyright = '(c) 2018 Westfield. All rights reserved.'

# Description of the functionality provided by this module
# Description = ''

# Minimum version of the Windows PowerShell engine required by this module
# PowerShellVersion = ''

# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @(
'Merge-DbvDriver',
'Merge-DbvPreference'
)

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
#CmdletsToExport = '*'

# Variables to export from this module
#VariablesToExport = '*'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
#AliasesToExport = '*'

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()

# A URL to the license for this module.
# LicenseUri = ''

# A URL to the main website for this project.
# ProjectUri = ''

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''

} # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}
17 changes: 17 additions & 0 deletions DbVisualizer/DbVisualizer.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$functionFolders = @('Public', 'Internal')
ForEach ($folder in $functionFolders)
{
$folderPath = Join-Path -Path $PSScriptRoot -ChildPath $folder
If (Test-Path -Path $folderPath)
{
Write-Verbose -Message "Importing from $folder"
$functions = Get-ChildItem -Path $folderPath -Filter '*.ps1'
ForEach ($function in $functions)
{
Write-Verbose -Message " Importing $($function.BaseName)"
. $($function.FullName)
}
}
}
$publicFunctions = (Get-ChildItem -Path "$PSScriptRoot\Public" -Filter '*.ps1').BaseName
Export-ModuleMember -Function $publicFunctions
17 changes: 17 additions & 0 deletions DbVisualizer/Internal/Get-DbvXml.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function Get-DbvXml {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $Path
)

process {
$content = Get-Content -Path $Path -Raw

if (-not $content) {
throw "Could not read file: $Path"
}

[xml]$content
}
}
11 changes: 11 additions & 0 deletions DbVisualizer/Internal/Save-DbvXml.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function Save-DbvXml {
[CmdletBinding()]
param (
[System.Xml.XmlDocument] $Xml,
[string] $Path
)

process {
$Xml.Save($Path)
}
}
66 changes: 66 additions & 0 deletions DbVisualizer/Public/Add-DbvConnection.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
param (
[Parameter(Mandatory = $true)]
$Alias,

[Parameter(Mandatory = $true)]
[ValidateSet('Development', 'Test', 'Production')]
$PermissionMode,

[Parameter(Mandatory = $true)]
[ValidateSet('Db2 LUW', 'Db2 z/OS', 'Netezza', 'SQL Server')]
$Driver,

[Parameter(Mandatory = $true)]
$Server,

[Parameter(Mandatory = $true)]
$Port,

[Parameter(Mandatory = $true)]
$Database
)

# things to update
<#
Alias
Notes
Url
Driver
Profile
Type
ServerInfoFormat
Properties
UrlFormat
UrlVariables
#>

$databaseXml = @"
<Database id="101">
<Alias>$Alias</Alias>
<Notes />
<Url />
<Driver>$Driver</Driver>
<Userid />
<Profile>auto</Profile>
<Type>sqlserver</Type>
<Password></Password>
<ServerInfoFormat>1</ServerInfoFormat>
<Properties>
<Property key="integratedSecurity">true</Property>
<Property key="dbvis.ConnectionBorder">Red.png</Property>
<Property key="dbvis.ConnectionMode">Production</Property>
</Properties>
<UrlFormat>0</UrlFormat>
<UrlVariables>
<Driver>
$Driver
<UrlVariable UrlVariableName="Server">$Server</UrlVariable>
<UrlVariable UrlVariableName="Port">$Port</UrlVariable>
<UrlVariable UrlVariableName="Database">$Database</UrlVariable>
<UrlVariable UrlVariableName="Instance" />
</Driver>
</UrlVariables>
</Database>
"@
Loading

0 comments on commit 77e8cc3

Please sign in to comment.