Skip to content

Commit

Permalink
Updates to devenv and docs
Browse files Browse the repository at this point in the history
- Add devcontainer and codespaces support
- Fix platyps bug, see PowerShell/platyPS#595
- Update function .md files
- Update issue templates
- Update first .LINK in all CBH to repo url

update devcontainer.json

update devcontainer.json

update comments in bootstrap.ps1

Fix platyps bug, see PowerShell/platyPS#595

test codespaces

Update first .LINK in all CBH to repo url

Update .md files

update readme.md

Update readme and add new issue template
  • Loading branch information
connorcarnes committed Feb 13, 2024
1 parent 19737a2 commit e82c9ce
Show file tree
Hide file tree
Showing 38 changed files with 427 additions and 77 deletions.
12 changes: 12 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu
# https://learn.microsoft.com/en-us/powershell/scripting/install/install-ubuntu?view=powershell-7.4
COPY bootstrap.ps1 bootstrap.ps1
RUN apt-get update \
&& apt-get install -y wget apt-transport-https software-properties-common \
&& wget -q https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& rm packages-microsoft-prod.deb \
&& apt-get update \
&& apt-get install -y powershell \
&& pwsh -File bootstrap.ps1
COPY profile.ps1 /opt/microsoft/powershell/7/profile.ps1
37 changes: 37 additions & 0 deletions .devcontainer/bootstrap.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.psresourceget/install-psresource?view=powershellget-3.x
# https://devblogs.microsoft.com/powershell/psresourceget-is-generally-available/
# https://github.com/PowerShell/PSResourceGet
# https://hub.docker.com/_/microsoft-powershell
# https://devblogs.microsoft.com/powershell/powershellget-in-powershell-7-4-updates/
# http://dahlbyk.github.io/posh-git/
# https://code.visualstudio.com/remote/advancedcontainers/change-default-source-mount
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.psresourceget/?view=powershellget-3.x
# https://code.visualstudio.com/docs/devcontainers/containers#_container-specific-settings
$ErrorActionPreference = 'Stop'
Install-PSResource -TrustRepository -Scope AllUsers -RequiredResource @{
'Microsoft.PowerShell.PSResourceGet' = @{
version = '1.0.2'
repository = 'PSGallery'
}
'Pester' = @{
version = '5.4.0'
repository = 'PSGallery'
}
'InvokeBuild' = @{
version = '5.10.2'
repository = 'PSGallery'
}
'PSScriptAnalyzer' = @{
version = '1.21.0'
repository = 'PSGallery'
}
'platyPS' = @{
version = '0.12.0'
repository = 'PSGallery'
}
'posh-git' = @{
version = '1.1.0'
repository = 'PSGallery'
}
}

27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/powershell
{
"name": "PowerShell",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.defaultProfile.linux": "pwsh"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.PowerShell",
"ms-vscode-remote.remote-containers",
"ryanluker.vscode-coverage-gutters",
"DavidAnson.vscode-markdownlint",
"eriklynd.json-tools",
"redhat.vscode-xml",
"ms-azuretools.vscode-docker"
]
}
}
}
40 changes: 40 additions & 0 deletions .devcontainer/profile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Write-Host 'Loading profile...' -ForegroundColor Cyan
Import-Module posh-git
# PSReadline
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -Colors @{ InlinePrediction = '#2F7004' } #green
Set-PSReadLineOption -PredictionViewStyle ListView #you may prefer InlineView
# Custom prompt function
function prompt {
<#
.SYNOPSIS
Custom prompt function.
.EXAMPLE
[2022-JUL-30 21:18][..project-starters\aws\aws-backup-automation][main ≡]
>>
#>
$global:promptDateTime = [datetime]::Now
$Global:promptDate = $global:promptDateTime.ToString('yyyy-MMM-dd').ToUpper()
$Global:promptTime = $global:promptDateTime.ToString('HH:mm')
# truncate the current location if too long
$currentDirectory = $executionContext.SessionState.Path.CurrentLocation.Path
$consoleWidth = [Console]::WindowWidth
$maxPath = [int]($consoleWidth / 4.5)
if ($currentDirectory.Length -gt $maxPath) {
$currentDirectory = '..' + $currentDirectory.SubString($currentDirectory.Length - $maxPath)
}
$global:promptPath = $currentDirectory

$InGitRepo = Write-VcsStatus
if ($InGitRepo) {
Write-Host "[$global:promptDate $global:promptTime]" -ForegroundColor Green -NoNewline
Write-Host "[$global:promptPath]" -ForegroundColor Magenta -NoNewline
Write-Host $InGitRepo.Trim() -NoNewline
"`r`n>>"
}
else {
Write-Host "[$global:promptDate $global:promptTime]" -ForegroundColor Green -NoNewline
Write-Host "[$global:promptPath]" -ForegroundColor Magenta -NoNewline
"`r`n>>"
}
}
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://code.visualstudio.com/docs/devcontainers/tips-and-tricks#_resolving-git-line-ending-issues-in-containers-resulting-in-many-modified-files
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/add-api-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Add API support
about: Request implementation of specific endpoints from https://developers.cloudflare.com/api/
title: Add support for [ENDPOINTS]
labels: enhancement, good first issue
assignees: ''

---

### Description
<!--- Describe the desired implementation and list links to relevant docs. Example:
I want to be able to list my accounts, view details of accounts and update accounts.
- https://developers.cloudflare.com/api/operations/accounts-list-accounts
- https://developers.cloudflare.com/api/operations/accounts-account-details
- https://developers.cloudflare.com/api/operations/accounts-update-account
-->

### Requirements
<!---
List the functions, tests and types that need to be added and create issues for future work if needed.
Example:
- Get-CFAccount.ps1
- Get-CFAccount.Tests.ps1
- Cloudflare.Account.Types.ps1xml
- Create new issue for implementation of Update-CFAccount.ps1 and Update-CFAccount.Tests.ps1
-->
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Bug report
about: Submit a new bug
title: Bug report
labels: 'bug'
labels: bug, enhancement
assignees: ''

---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
name: Feature request
name: Generic Feature Request
about: Suggest an idea for this project
title: 'Feature request'
labels: 'enhancement'
title: Feature request
labels: enhancement
assignees: ''

---
Expand Down
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/setup-dev-env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Setup dev env
about: Steps to set up developer environment
title: [YOUR_NAME] dev env setup
labels: good first issue
assignees: ''

---

```[tasklist]
### To Do
- [ ] TBD
- [ ] TBD
```

20 changes: 12 additions & 8 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"ms-vscode.PowerShell",
"ryanluker.vscode-coverage-gutters",
"DavidAnson.vscode-markdownlint"
]
}
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"ms-vscode.PowerShell",
"ms-vscode-remote.remote-containers",
"ryanluker.vscode-coverage-gutters",
"DavidAnson.vscode-markdownlint",
"eriklynd.json-tools",
"redhat.vscode-xml",
"ms-azuretools.vscode-docker"
]
}
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
| main | ![Build Status Windows PowerShell Main](https://github.com/connorcarnes/pwshCloudflare/actions/workflows/wf_WindowsPowerShell.yml/badge.svg?branch=main) | ![Build Status Windows pwsh Main](https://github.com/connorcarnes/pwshCloudflare/actions/workflows/wf_Windows.yml/badge.svg?branch=main) | ![Build Status Linux Main](https://github.com/connorcarnes/pwshCloudflare/actions/workflows/wf_Linux.yml/badge.svg?branch=main) | ![Build Status MacOS dev](https://github.com/connorcarnes/pwshCloudflare/actions/workflows/wf_MacOS.yml/badge.svg?branch=main) |
| dev | ![Build Status Windows PowerShell dev](https://github.com/connorcarnes/pwshCloudflare/actions/workflows/wf_WindowsPowerShell.yml/badge.svg?branch=dev) | ![Build Status Windows pwsh dev](https://github.com/connorcarnes/pwshCloudflare/actions/workflows/wf_Windows.yml/badge.svg?branch=dev) | ![Build Status Linux dev](https://github.com/connorcarnes/pwshCloudflare/actions/workflows/wf_Linux.yml/badge.svg?branch=dev) | ![Build Status MacOS dev](https://github.com/connorcarnes/pwshCloudflare/actions/workflows/wf_MacOS.yml/badge.svg?branch=dev) |

## Synopsis

PowerShell module for interacting with the Cloudflare API.

## Description

PowerShell module for interacting with the Cloudflare API.
PowerShell module for the [Cloudflare Client API v4](https://developers.cloudflare.com/api/). See similar projects [python-cloudflare](https://github.com/cloudflare/python-cloudflare) and [cloudflare-go](https://github.com/cloudflare/cloudflare-go) as well as [Cloudflare products](https://developers.cloudflare.com/products/)

## Functions

Expand All @@ -32,10 +28,6 @@ PowerShell module for interacting with the Cloudflare API.
| [Remove-CFZoneRecord](docs/Remove-CFZoneRecord.md) | [Delete DNS Record](https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-delete-dns-record) |
| [Set-CFZoneRecord](docs/Set-CFZoneRecord.md) | [Patch DNS Record](https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-patch-dns-record) |

## Why

The existing Cloudflare modules in the PSGallery are limited in scope. This project aims to support a broad range of [Cloudflare products](https://developers.cloudflare.com/products/) including R2, D1, Pages, Workers, Workers KV, Workers AI, Images, Stream, Access, Tunnel, Durable Objects, Queues, etc.

## Getting Started

### Installation
Expand Down Expand Up @@ -101,3 +93,7 @@ $ZoneName = 'example.com'
$Zone = Get-CfZone | Where-Object {$_.Name -eq $ZoneName}
Get-CFZoneRecord -ZoneId $Zone.id
```

## Contributors

- [Connor Carnes](https://github.com/connorcarnes)
7 changes: 4 additions & 3 deletions docs/Get-CFAccount.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
external help file: pwshCloudflare-help.xml
Module Name: pwshCloudflare
online version: https://developers.cloudflare.com/api/operations/accounts-list-accounts
online version: https://github.com/connorcarnes/pwshCloudflare
schema: 2.0.0
---

Expand Down Expand Up @@ -74,7 +74,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction.
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand All @@ -86,7 +86,8 @@ For more information, see about_CommonParameters (http://go.microsoft.com/fwlink
## RELATED LINKS
[https://github.com/connorcarnes/pwshCloudflare](https://github.com/connorcarnes/pwshCloudflare)
[https://developers.cloudflare.com/api/operations/accounts-list-accounts](https://developers.cloudflare.com/api/operations/accounts-list-accounts)
[https://developers.cloudflare.com/api/operations/accounts-account-details](https://developers.cloudflare.com/api/operations/accounts-account-details)
13 changes: 8 additions & 5 deletions docs/Get-CFD1Database.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
external help file: pwshCloudflare-help.xml
Module Name: pwshCloudflare
online version: https://developers.cloudflare.com/api/operations/cloudflare-d1-list-databases
online version: https://github.com/connorcarnes/pwshCloudflare
schema: 2.0.0
---

Expand All @@ -14,12 +14,14 @@ Gets Cloudflare D1 database(s).

### AccountId
```
Get-CFD1Database [-Name <String>] [-Id <String>] -AccountId <String> [<CommonParameters>]
Get-CFD1Database [-Name <String>] [-Id <String>] -AccountId <String>
[<CommonParameters>]
```

### AccountName
```
Get-CFD1Database [-Name <String>] [-Id <String>] -AccountName <String> [<CommonParameters>]
Get-CFD1Database [-Name <String>] [-Id <String>] -AccountName <String>
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -114,7 +116,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction.
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand All @@ -132,7 +134,8 @@ This is done so that the same output is returned regardless of parameters used.
## RELATED LINKS
[https://github.com/connorcarnes/pwshCloudflare](https://github.com/connorcarnes/pwshCloudflare)
[https://developers.cloudflare.com/api/operations/cloudflare-d1-list-databases](https://developers.cloudflare.com/api/operations/cloudflare-d1-list-databases)
[https://developers.cloudflare.com/api/operations/cloudflare-d1-get-database](https://developers.cloudflare.com/api/operations/cloudflare-d1-get-database)
10 changes: 6 additions & 4 deletions docs/Get-CFZone.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
external help file: pwshCloudflare-help.xml
Module Name: pwshCloudflare
online version: https://developers.cloudflare.com/api/operations/zones-get
online version: https://github.com/connorcarnes/pwshCloudflare
schema: 2.0.0
---

Expand All @@ -13,7 +13,8 @@ Retrieves information about a Cloudflare zone.
## SYNTAX

```
Get-CFZone [[-ZoneName] <String>] [[-ZoneID] <String>] [<CommonParameters>]
Get-CFZone [[-ZoneName] <String>] [[-ZoneID] <String>]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -69,7 +70,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction.
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand All @@ -81,5 +82,6 @@ For more information, see about_CommonParameters (http://go.microsoft.com/fwlink
## RELATED LINKS
[https://developers.cloudflare.com/api/operations/zones-get](https://developers.cloudflare.com/api/operations/zones-get)
[https://github.com/connorcarnes/pwshCloudflare](https://github.com/connorcarnes/pwshCloudflare)
[https://developers.cloudflare.com/api/operations/zones-get](https://developers.cloudflare.com/api/operations/zones-get)
7 changes: 4 additions & 3 deletions docs/Get-CFZoneRecord.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
external help file: pwshCloudflare-help.xml
Module Name: pwshCloudflare
online version: https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-list-dns-records
online version: https://github.com/connorcarnes/pwshCloudflare
schema: 2.0.0
---

Expand Down Expand Up @@ -75,7 +75,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction.
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand All @@ -88,5 +88,6 @@ For more information, see about_CommonParameters (http://go.microsoft.com/fwlink
## RELATED LINKS
[https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-list-dns-records](https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-list-dns-records)
[https://github.com/connorcarnes/pwshCloudflare](https://github.com/connorcarnes/pwshCloudflare)
[https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-list-dns-records](https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-list-dns-records)
Loading

0 comments on commit e82c9ce

Please sign in to comment.