Skip to content

Instantly share code, notes, and snippets.

View chriskuech's full-sized avatar

Chris Kuech chriskuech

  • Datum Source, ex MSFT
View GitHub Profile
function Invoke-WithStorageAccount {
Param(
[ValidateNotNullOrEmpty()]
[scriptblock]$ScriptBlock
)
$name = ("s$(New-Guid)" -replace "-").Substring(24)
$storageAccount = New-AzStorageAccount `
-ResourceGroupName "ephemeral-storages" `
-Name $name`
Invoke-InDirectory $RepoRoot {
Invoke-InContext "Build ReactJS App" {
Invoke-InContext "Validate" {
Invoke-InContext "Lint" { yarn lint }
Invoke-InContext "Test" { yarn test }
}
Invoke-InContext "Transpile" { yarn build:ts }
Invoke-InContext "Bundle" { yarn webpack }
}
Invoke-InContext "Build Container" { docker build . }
# ContextLogger.psm1
$ContextStack = [System.Collections.Stack]::new()
function Invoke-InContext {
Param(
[ValidateNotNullOrEmpty()]
[string] $Name,
[ValidateNotNullOrEmpty()]
[scriptblock] $ScriptBlock
# invoke in repo root
Invoke-InDirectory "$PSScriptRoot/.." {
Invoke-InDirectory "./components" {
npm install
npm build
}
Invoke-InDirectory "./server" {
npm install
npm build
}
function Invoke-InDirectory {
Param(
[ValidateScript( { Test-Path $_ -PathType Container } )]
[string] $Path,
[ValidateNotNullOrEmpty()]
[scriptblock] $ScriptBlock
)
try {
Push-Location $Path
$ErrorActionPreference = "Stop"
Push-Location "./path/I/need/to/be/in"
try {
# do something here
} finally {
Pop-Location
}
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
# constant parameters
$org = "MyAzureDevOpsOrgName"
$project = "MyAzureDevOpsProjectName"
$areaPath = "/the/area/path/containing/my/work/items"
$tag = "the-tag-that-identifies-work-items-as-automanaged"
$query = @"
SELECT *
FROM WorkItems
WHERE [Tags] CONTAINS '$tag'
Param(
# Path to the repo containing TODO-annotated files
[Parameter(Mandatory)]
[ValidateScript({Test-Path $_ -PathType Container})]
[string]$RepoRoot
)
& {
enum Priority {
Low = 3
... # previous param definition
& {
... # previous class and enum definitions
... # previous transformations
} | Sort Priority, FilePath, Line