Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@{ | ||
RootModule = 'PSGhost.psm1' | ||
ModuleVersion = '*' | ||
GUID = '3b4869fa-45a9-41a1-a412-bd07c84559dc' | ||
Author = 'Adam Bertram' | ||
CompanyName = 'Adam the Automator, LLC' | ||
Copyright = '(c) 2017 Adam Bertram. All rights reserved.' | ||
Description = "This module is used to interact with the blogging platform, Ghost's API." | ||
PowerShellVersion = '5.0' | ||
FunctionsToExport = '*' | ||
CmdletsToExport = '*' | ||
VariablesToExport = '*' | ||
AliasesToExport = '*' | ||
PrivateData = @{ | ||
PSData = @{ | ||
Tags = @('PSModule', 'Ghost') | ||
ProjectUri = 'https://github.com/adbertram/PSGhost' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Set-StrictMode -Version Latest | ||
|
||
# Get public and private function definition files. | ||
$Public = @(Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue) | ||
$Private = @(Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue) | ||
|
||
# Dot source the files. | ||
foreach ($import in @($Public + $Private)) { | ||
try { | ||
Write-Verbose "Importing $($import.FullName)" | ||
. $import.FullName | ||
} catch { | ||
Write-Error "Failed to import function $($import.FullName): $_" | ||
} | ||
} | ||
|
||
foreach ($file in $Public) { | ||
Export-ModuleMember -Function $file.BaseName | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
function Get-GhostApiKey { | ||
<# | ||
.SYNOPSIS | ||
Queries the API key configuration to return the API key set earlier via the Save-GhostApiKey command. | ||
.EXAMPLE | ||
PS> Get-GhostApiKey | ||
This example pulls the API key from the configuration file. | ||
#> | ||
[CmdletBinding()] | ||
param | ||
() | ||
|
||
$ErrorActionPreference = 'Stop' | ||
|
||
function decrypt([string]$TextToDecrypt) { | ||
$secure = ConvertTo-SecureString $TextToDecrypt | ||
$hook = New-Object system.Management.Automation.PSCredential("test", $secure) | ||
$plain = $hook.GetNetworkCredential().Password | ||
return $plain | ||
} | ||
|
||
try { | ||
$atKey = decrypt $encApiKey | ||
$script:GhostApiKey = $atKey | ||
$script:GhostApiKey | ||
} catch { | ||
$PSCmdlet.ThrowTerminatingError($_) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function Save-GhostApiKey { | ||
<# | ||
.SYNOPSIS | ||
Saves the API key to the configuration file obtained from your Ghost account integration | ||
.EXAMPLE | ||
PS> Save-GhostApiKey -ApiKey foobar | ||
Saves the value 'foobar' in the configuration APIKey value. | ||
#> | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory)] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$ApiKey | ||
) | ||
|
||
function encrypt([string]$TextToEncrypt) { | ||
$secure = ConvertTo-SecureString $TextToEncrypt -AsPlainText -Force | ||
$encrypted = $secure | ConvertFrom-SecureString | ||
return $encrypted | ||
} | ||
|
||
throw 'finish this' | ||
# $config = Get-PSAirTableConfiguration | ||
# $config.Application.ApiKey = encrypt($ApiKey) | ||
# $config | ConvertTo-Json | Set-Content -Path "$WorkingDir\Configuration.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"ApiKey": "XXXXXX" | ||
} |