-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbom.ps1
More file actions
74 lines (56 loc) · 1.85 KB
/
bom.ps1
File metadata and controls
74 lines (56 loc) · 1.85 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# bom.ps1
<#
.SYNOPSIS
Create a list of software dependencies for this project
and write them in a file together with their license.
.PARAMETER All
If specified, this will create a list of all dependencies,
including transitive dependencies.
.PARAMETER OutputFile
The path to the bill of material JSON file.
Defaults to the bom.json file in the same directory as this script.
.PARAMETER CreateLicenseFiles
If specified, this will create a license file for each dependency.
All license files will be created in the LICENSES directory.
.EXAMPLE
# Generate the bill of material file `bom.json`.
.\bom.ps1
#>
#
# Description:
#
[CmdletBinding()]
param(
[switch]
$All,
[ValidateNotNullOrEmpty()]
[string]
$OutputFile = "bom.json",
[switch]
$CreateLicenseFiles
)
Push-Location -Path $PSScriptRoot
$rootDir = Join-Path -Path $PSScriptRoot -ChildPath "scripts"
# We need to update here to capture the latest version of the solver
julia --project=$rootDir -e "using Pkg; Pkg.update()"
if($All) {
Write-Host "Creating a list of all dependencies"
julia --project=$rootDir .\scripts\bom.jl --filename $OutputFile --all
} else {
Write-Host "Creating a list of direct dependencies"
julia --project=$rootDir .\scripts\bom.jl --filename $OutputFile
}
if ($CreateLicenseFiles) {
Write-Verbose -Message "Creating license files"
$bom = Get-Content -Path $OutputFile -Raw | ConvertFrom-Json
$bom | ForEach-Object -Process {
$dep = $_
$name = $dep.name
$license = $dep.license
Write-Verbose -Message "Creating license file for $($_.name)"
$filename = "LICENSE-$name.txt"
$licenseFile = Join-Path -Path $PSScriptRoot -ChildPath "LICENSES" | Join-Path -ChildPath $filename
$license | Out-File -FilePath $licenseFile -Encoding ascii
}
}
Pop-Location