Skip to content

Instantly share code, notes, and snippets.

View scbedd's full-sized avatar

Scott Beddall scbedd

  • Microsoft
  • Seattle, WA
View GitHub Profile
@scbedd
scbedd / glob_packages_into_poetry_reqs.py
Created April 1, 2021 00:26
Get Poetry Dependencies from entire repository
import glob
import os
packages = glob.glob('C:/repo/sdk-for-python/sdk/*/*/setup.py')
for pkg in packages:
name = os.path.dirname(pkg).split(os.sep)[-1]
path = os.path.dirname(pkg.split('python/')[1]).replace(os.sep, '/')
print('{} = {{path = "{}"}}'.format(name, path))
@scbedd
scbedd / Merge-Remote-PR.ps1
Created February 9, 2021 23:38
Collect PR updates from an azure-sdk Documentation PR and apply them to local
param(
[string]$RepoId,
[string]$PRNumber,
[string]$RepoRoot = "C:/repo/azure-docs-sdk-python"
)
$API_URL = "https://api.github.com/repos/$RepoId"
function FireAPIRequest($url, $method, $body = $null)
{
@scbedd
scbedd / extract_deps.py
Created January 27, 2021 02:56
Get all the requirements from all the packages within the repo
# intended to live in the folder eng/tox/ within azure-sdk-for-python
from tox_helper_tasks import get_package_details
import os
import argparse
import glob
import sys
setup_parser_path = os.path.abspath(
os.path.join(os.path.abspath(__file__), "..", "..", "versioning")
@scbedd
scbedd / Squash-Preview-Readmes.ps1
Created December 5, 2020 00:20
Given a folder, find all readmes with a given suffix in them and supplant existing non-preview readmes with them
param(
$targetFolder,
$suffix="-pre.md"
)
Get-ChildItem -Path $targetFolder "*$suffix" | ForEach-Object {
Write-Host $_
$NewName = $_.Name.replace($suffix, ".md")
$Destination = Join-Path -Path $_.Directory.FullName -ChildPath $NewName
Move-Item -Path $_.FullName -Destination $Destination -Force
@scbedd
scbedd / Extend-Redirection.ps1
Created December 5, 2020 00:01
Given a docs-ref-services folder location, find preview readmes and generate redirection config
param(
$targetFolder,
$language,
$previewMoniker
)
$results = gci -Path $targetFolder -Filter "*-pre.md"
foreach ($readme in $results) {
Write-Host "{"
@scbedd
scbedd / find_unpublished_npm.ps1
Created August 13, 2020 23:29
Of JS Packages, which ones are unpublished to docs.ms.com?
# assumes that NPM is installed and available
$indexUrl = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/js-packages.csv"
$interrogativeUrl = "https://docs.microsoft.com/en-us/javascript/api"
$content = (Invoke-RestMethod -Method GET -Uri $indexUrl)
# assumes that the location is common
$results = $content.Split("`n") | ? { $_ }
$results = $results[1..($results.Length-1)]
$indexPackages = @{}
@scbedd
scbedd / are_these_folks_part_of_this_org.ps1
Created August 13, 2020 22:33
Check GH Org Membership
$users = "<comma separated list of github users>"
# notice that we substring(1). This is because if you grab the gh users from a codeowners file, there will be a leading @
# the substring rips it off.
$filtered_users = $users.Split(",") | % {$_.Trim()} | ? { $_ } | % { $_.SubString(1) } | Select -Unique
$not_added = @()
$headers = @{
"Content-Type" = "application/json"
"Authorization" = "token $($env:GH_TOKEN)"
@scbedd
scbedd / get_updated_readmes.py
Last active June 25, 2020 22:23
Given a list of tags, generate relative link replacements from an azure repo
import os
import glob
from subprocess import check_call, CalledProcessError
import pdb
import logging
import sys
import shutil
import requests
from io import StringIO
import csv
@scbedd
scbedd / copy-readmes-to-docs
Last active April 10, 2020 19:21
Copy Readmes To Docs
# Example Usage: ./copy_readmes.ps1 -CodeRepo C:/repo/sdk-for-python -DocRepo C:/repo/azure-docs-sdk-python
# Highly recommended that you use Powershell Core.
# git reset --hard origin/smoke-test on the doc repo prior to running this
param (
[String]$CodeRepo,
[String]$DocRepo,
[String]$TargetServices = "keyvault,storage"
)
@scbedd
scbedd / transition-versioning-js.ps1
Created March 20, 2020 00:12
Updates js files in place so that the previously deployed sites can access the new versioning strategy
# transition old style versioning strategy to new. inclusive of existing versions in both strategies
param (
$AzCopy,
$SASKey,
$Language,
$BlobName,
$DocLocation,
$AccountKey
)
$AccountName = ($BlobName.Replace("https://", "") -Split "\.")[0]