<commit_before>[CmdletBinding()]
Param(
	[Parameter(Mandatory=$True,Position=1)]
	[string]$SiteUrl,

	[Parameter(Mandatory=$True)]
	[string]$UserName,

	[Parameter(Mandatory=$True)]
	[string]$Password
)

# -----------------
# Include utility scripts
# -----------------
.".\Utility\Navigation.ps1" 

# -----------------
# Connect to the site
# -----------------

$PasswordAsSecure = ConvertTo-SecureString $Password -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential ($UserName , $PasswordAsSecure)
Connect-SPOnline -Url $SiteUrl -Credentials $Credentials

$SiteMapTermSetId = "52d6944d-bd98-48c1-ba45-57d4efe2f941"

# -----------------
# Provision a dummy taxonomy term set
# -----------------
$0 = $myInvocation.MyCommand.Definition
$CommandDirectory = [System.IO.Path]::GetDirectoryName($0)

$TaxonomyconfigurationFilePath = $CommandDirectory + ".\Taxonomy.xml"
Import-SPOTermGroupFromXml -Path $TaxonomyconfigurationFilePath

# -----------------
# Set the term set to be the navigation term set for the web
# -----------------

# Warning: Using CSOM is different form using PnP cmdlets
# Don't use the "Get-SPOContext" PnP cmdlet to retrieve the context when working with CSOM
# If you do so, you will get an error when converting "ClientContext" to "ClientRuntimeContext" and other CSOM surprises
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) 
$SPCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $PasswordAsSecure)
$Context.Credentials = $SPCredentials

MapTermSetToNavigationContext -Context $Context -TermSetId $SiteMapTermSetId -GlobalNavigation
# Event if we don't use the current navigation, we have to set it with the same term set (don't work otherwise)
MapTermSetToNavigationContext -Context $Context -TermSetId $SiteMapTermSetId -CurrentNavigation

$Context.Dispose()

# -----------------
# Upload files in the style library (folders are created automatically by the PnP cmdlet)
# -----------------
Add-SPOFile -Path ".\Html\navbar.html" -Folder "/Style Library/NavigationSample/Html" -Checkout
Add-SPOFile -Path ".\Html\contextualmenu.html" -Folder "/Style Library/NavigationSample/Html" -Checkout
Add-SPOFile -Path ".\Js\Modules\module.navigation.js" -Folder "/Style Library/NavigationSample/Js/Modules" -Checkout<commit_msg>Add the utility module to the deployment script<commit_after>[CmdletBinding()]
Param(
	[Parameter(Mandatory=$True,Position=1)]
	[string]$SiteUrl,

	[Parameter(Mandatory=$True)]
	[string]$UserName,

	[Parameter(Mandatory=$True)]
	[string]$Password
)

# -----------------
# Include utility scripts
# -----------------
.".\Utility\Navigation.ps1" 

# -----------------
# Connect to the site
# -----------------

$PasswordAsSecure = ConvertTo-SecureString $Password -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential ($UserName , $PasswordAsSecure)
Connect-SPOnline -Url $SiteUrl -Credentials $Credentials

$SiteMapTermSetId = "52d6944d-bd98-48c1-ba45-57d4efe2f941"

# -----------------
# Provision a dummy taxonomy term set
# -----------------
$0 = $myInvocation.MyCommand.Definition
$CommandDirectory = [System.IO.Path]::GetDirectoryName($0)

$TaxonomyconfigurationFilePath = $CommandDirectory + ".\Taxonomy.xml"
Import-SPOTermGroupFromXml -Path $TaxonomyconfigurationFilePath

# -----------------
# Set the term set to be the navigation term set for the web
# -----------------

# Warning: Using CSOM is different form using PnP cmdlets
# Don't use the "Get-SPOContext" PnP cmdlet to retrieve the context when working with CSOM
# If you do so, you will get an error when converting "ClientContext" to "ClientRuntimeContext" and other CSOM surprises
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) 
$SPCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $PasswordAsSecure)
$Context.Credentials = $SPCredentials

MapTermSetToNavigationContext -Context $Context -TermSetId $SiteMapTermSetId -GlobalNavigation
# Event if we don't use the current navigation, we have to set it with the same term set (don't work otherwise)
MapTermSetToNavigationContext -Context $Context -TermSetId $SiteMapTermSetId -CurrentNavigation

$Context.Dispose()

# -----------------
# Upload files in the style library (folders are created automatically by the PnP cmdlet)
# -----------------
Add-SPOFile -Path ".\Html\navbar.html" -Folder "/Style Library/NavigationSample/Html" -Checkout
Add-SPOFile -Path ".\Html\contextualmenu.html" -Folder "/Style Library/NavigationSample/Html" -Checkout
Add-SPOFile -Path ".\Js\Modules\module.utility.js" -Folder "/Style Library/NavigationSample/Js/Modules" -Checkout
Add-SPOFile -Path ".\Js\Modules\module.navigation.js" -Folder "/Style Library/NavigationSample/Js/Modules" -Checkout
{'fraction_non_alphanumeric': 0.16756087494841107, 'fraction_numerical': 0.00990507635163021, 'mean_word_length': 3.775369458128079, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '698705', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1392, 'n_words': 375}