mirror of
				https://github.com/We-Dont-Byte/Mind_Reader.git
				synced 2025-02-04 10:38:42 +00:00 
			
		
		
		
	Install scripts:
- Windows:
  - install:
    Move repo URI into variable
    Remove -NoWinget check (was unused)
  - upgrade:
    Change -NoWinget to disable updating with winget (can take a while)
    Create function to check install of node packages which are put on Path.
- Linux:
  - Install:
    Port install-windows to some linux distros
    Support for Apt (Ubuntu, possibly Debian/Mint)
    Support for Pacman (Arch/Manjaro/Garuda)
  - Upgrade:
    Port upgrade-windows to some linux distros
			
			
This commit is contained in:
		@@ -56,6 +56,7 @@ param (
 | 
			
		||||
   [switch]$DryRun                 # Run script without installing
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
$RepoURI   = "https://github.com/We-Dont-Byte/Mind_Reader.git"
 | 
			
		||||
$RepoPath  = "$GitDir\Mind_Reader"
 | 
			
		||||
$SetupPath = "$RepoPath\setup-development\windows"
 | 
			
		||||
 | 
			
		||||
@@ -98,8 +99,8 @@ function Reload-Path {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Check if Winget is available
 | 
			
		||||
if ( $NoWinget -or -not (Command-Available winget) ) {
 | 
			
		||||
   Write-Warning "[ Warning ]: It looks like winget isn't available.`n"
 | 
			
		||||
if ( -not (Command-Available winget) ) {
 | 
			
		||||
   Write-Warning "It looks like winget isn't available.`n"
 | 
			
		||||
   Write-Host "Update 'App Installer' through the Microsoft Store, or grab the '.msixbundle' from the winget-cli repository:"
 | 
			
		||||
   Write-Host "( https://github.com/microsoft/winget-cli/releases/latest )`n" -ForegroundColor White
 | 
			
		||||
   exit
 | 
			
		||||
@@ -148,12 +149,13 @@ if ( -not (Test-Path "$GitDir") ) {
 | 
			
		||||
# Clone the repository in GitDir
 | 
			
		||||
$dir = $pwd
 | 
			
		||||
cd $GitDir
 | 
			
		||||
Dry-Run "git clone 'https://github.com/We-Dont-Byte/Mind_Reader.git'"
 | 
			
		||||
# TODO: Change this during merge onto main branch
 | 
			
		||||
Dry-Run "git clone '$RepoURI'"
 | 
			
		||||
 | 
			
		||||
# TODO: Remove this when merging
 | 
			
		||||
cd Mind_reader
 | 
			
		||||
Dry-Run "git checkout johnBreaux"
 | 
			
		||||
cd ..
 | 
			
		||||
# END TODO
 | 
			
		||||
# TODO: Remove this when merging
 | 
			
		||||
 | 
			
		||||
# Run the install script
 | 
			
		||||
if ( -not (Test-Path "$SetupPath")) {
 | 
			
		||||
 
 | 
			
		||||
@@ -52,7 +52,7 @@ param (
 | 
			
		||||
   [switch]$NoPrompt,           # Disable the 3-second wait and press-any-key prompt
 | 
			
		||||
   [switch]$Install,            # Perform all installations, even when commands are present
 | 
			
		||||
   [switch]$DryRun,             # Run script without installing
 | 
			
		||||
   [switch]$NoWinget            # Pretend Winget doesn't exist
 | 
			
		||||
   [switch]$NoWinget            # Don't update dependdencies with winget
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# .description
 | 
			
		||||
@@ -89,8 +89,8 @@ function Reload-Path {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Check if Winget is available
 | 
			
		||||
if ( $NoWinget -or -not (Command-Available winget) ) {
 | 
			
		||||
   Write-Warning "[ Warning ]: It looks like winget isn't available.`n"
 | 
			
		||||
if ( -not (Command-Available winget) ) {
 | 
			
		||||
   Write-Warning "It looks like winget isn't available.`n"
 | 
			
		||||
   Write-Host "Update 'App Installer' through the Microsoft Store, or grab the '.msixbundle' from the winget-cli repository:"
 | 
			
		||||
   Write-Host "( https://github.com/microsoft/winget-cli/releases/latest )`n" -ForegroundColor White
 | 
			
		||||
   exit
 | 
			
		||||
@@ -121,11 +121,13 @@ if ( ([Security.Principal.WindowsIdentity]::GetCurrent().Groups -contains 'S-1-5
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Import the packages from dependencies.json (autogenerated file, do not edit!)
 | 
			
		||||
Write-Host "`nInstalling packages with winget..."
 | 
			
		||||
Dry-Run 'winget install Microsoft.VisualStudio.2022.BuildTools --override "--wait --quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"'
 | 
			
		||||
Dry-Run 'winget import winget/dependencies.json'
 | 
			
		||||
# Reload the PATH, so we can use some of those sweet new commands we just installed
 | 
			
		||||
Reload-Path
 | 
			
		||||
if ( -not $NoWinget) {
 | 
			
		||||
   Write-Host "`nInstalling packages with winget..."
 | 
			
		||||
   Dry-Run 'winget install Microsoft.VisualStudio.2022.BuildTools --override "--wait --quiet --add Microsoft.VisualStudio.Workload.VCTools   --includeRecommended"'
 | 
			
		||||
   Dry-Run "winget import winget/dependencies.json"
 | 
			
		||||
   # Reload the PATH, so we can use some of those sweet new commands we just installed
 | 
			
		||||
   Reload-Path
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Check whether everything is available now:
 | 
			
		||||
$error = 0
 | 
			
		||||
@@ -140,25 +142,43 @@ if ( -not (Command-Available npm ) ) {
 | 
			
		||||
}
 | 
			
		||||
if ( $error ) { exit }
 | 
			
		||||
 | 
			
		||||
# Check if electron-rebuild is installed, if not, install it
 | 
			
		||||
if ( ($Install) -or -not (Command-Available electron-rebuild) ) {
 | 
			
		||||
   Write-Host "`nInstalling Electron-Rebuild..."
 | 
			
		||||
   Dry-Run 'npm install -g electron-rebuild'
 | 
			
		||||
   Reload-Path
 | 
			
		||||
   if ( -not (Command-Available electron-rebuild)) {
 | 
			
		||||
      Throw "electron-rebuild failed to install. Aborting."
 | 
			
		||||
# .description
 | 
			
		||||
# EnsureNodePackageInstalled:
 | 
			
		||||
# Checks for the presence of a cmdlet with a given name
 | 
			
		||||
# If it's not found, attempt to install it using npm
 | 
			
		||||
# If it's still not found, abort (this may not be good behavior?)
 | 
			
		||||
function EnsureNodePackageInstalled {
 | 
			
		||||
   param (
 | 
			
		||||
      [string[]]$command
 | 
			
		||||
   )
 | 
			
		||||
   if ( ($Install) -or -not (Command-Available $command[0]) ) {
 | 
			
		||||
      Write-Host "`nInstalling $($command[0])..."
 | 
			
		||||
      Dry-Run "npm install -g $([string]$command)"
 | 
			
		||||
      Reload-Path
 | 
			
		||||
      if ( -not (Command-Available $command[0])) {
 | 
			
		||||
         Throw "$command failed to install. Aborting."
 | 
			
		||||
      }
 | 
			
		||||
   } else {
 | 
			
		||||
      Write-Host "`n$($command[0]) already installed." -ForegroundColor green
 | 
			
		||||
   }
 | 
			
		||||
} else {
 | 
			
		||||
   Write-Host "`nElectron-Rebuild already installed." -ForegroundColor green
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Check if electron-rebuild is installed, if not, install it
 | 
			
		||||
EnsureNodePackageInstalled electron-rebuild
 | 
			
		||||
 | 
			
		||||
# These are useful (but not necessary) packages to have installed when working on new VSCode extensions
 | 
			
		||||
EnsureNodePackageInstalled yo, generator-code
 | 
			
		||||
 | 
			
		||||
# We're about to do some path traversal, so save the current directory
 | 
			
		||||
$prev_directory = $pwd
 | 
			
		||||
 | 
			
		||||
# install NodeJS dependencies for this extension
 | 
			
		||||
Write-Host "`nInstalling NodeJS Dependencies..."
 | 
			
		||||
cd ..\..
 | 
			
		||||
Dry-Run 'npm install'
 | 
			
		||||
Dry-Run "npm install"
 | 
			
		||||
 | 
			
		||||
# Run npm audit fix to upgrade vulnerable dependencies, except breaking changes.
 | 
			
		||||
Dry-Run "npm audit fix"
 | 
			
		||||
 | 
			
		||||
# if we're on a known VSCode version, go ahead and run electron-rebuild
 | 
			
		||||
switch -Regex (code --version) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user