-
Notifications
You must be signed in to change notification settings - Fork 349
Expand file tree
/
Copy pathnotice-generation.ps1
More file actions
34 lines (28 loc) · 2.09 KB
/
Copy pathnotice-generation.ps1
File metadata and controls
34 lines (28 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
param (
[Parameter (Mandatory=$true)][string] $noticeFilePath,
[Parameter (Mandatory=$true)][string] $BuildArtifactStagingDir,
[Parameter (Mandatory=$true)][string] $BuildSourcesDir
)
# Download and save the ChilliCream License 1.0 from ChilliCream/graphql-platform GitHub repo
$chiliCreamLicenseSavePath = "$BuildArtifactStagingDir/chillicreamlicense.txt"
$chiliCreamLicenseMetadataURL = "https://raw.githubusercontent.com/ChilliCream/graphql-platform/main/website/src/basic/licensing/chillicream-license.md"
Invoke-WebRequest $chiliCreamLicenseMetadataURL -UseBasicParsing |
Select-Object -ExpandProperty Content |
Out-File $chiliCreamLicenseSavePath
# Define the path to the license file in your repository and Read the content of the license file
$sqlClientSNILicenseFilePath = "$BuildSourcesDir/external_licenses/Microsoft.Data.SqlClient.SNI.6.0.2.License.txt"
$sqlClientSNILicense = Get-Content -Path $sqlClientSNILicenseFilePath -Raw
# Replace erroneous copyright, using [System.IO.File] for better performance than Get-Content and Set-Content
$content = [System.IO.File]::ReadAllText($noticeFilePath) -replace "\(c\) Microsoft (2023|2024)`r`n", ""
# Prepare license content for writing to file.
$sqlClientSNIComponentName = "`r`nMICROSOFT.DATA.SQLCLIENT.SNI`r`n`r`n"
$bananaCakePopComponentName = "`r`n`r`nBanana Cake Pop`r`n`r`n"
$chiliCreamLicenseText = [System.IO.File]::ReadAllText($chiliCreamLicenseSavePath)
# Combine all notice file components and write to file. Each license is separated
# by two full lines of dashes, where after each line of dashes, there is an empty line.
# The autogenerated NOTICE text ends with a single line of dashes, so the second must be added here.
$licenseSeparator = "`r`n`r`n---------------------------------------------------------`r`n"
$finalOutputContent = $content + $licenseSeparator + $sqlClientSNIComponentName + $sqlClientSNILicense + $licenseSeparator + $licenseSeparator + $bananaCakePopComponentName + $chiliCreamLicenseText
[System.IO.File]::WriteAllText($noticeFilePath, $finalOutputContent)