Downloads:

415

Downloads of v 1.0.3:

341

Last Update:

25 Mar 2021

Package Maintainer(s):

Software Author(s):

  • David Yair

Tags:

notepadplusplus-plugin.template

NotepadPlusPlus-Plugin Template

  • 1
  • 2
  • 3

1.0.3 | Updated: 25 Mar 2021

Downloads:

415

Downloads of v 1.0.3:

341

Maintainer(s):

Software Author(s):

  • David Yair

  • 1
  • 2
  • 3
NotepadPlusPlus-Plugin Template 1.0.3

  • 1
  • 2
  • 3

All Checks are Passing

3 Passing Tests


Validation Testing Passed


Verification Testing Passed

Details

Scan Testing Successful:

No detections found in any package files

Details
Learn More

Deployment Method: Individual Install, Upgrade, & Uninstall

To install NotepadPlusPlus-Plugin Template, run the following command from the command line or from PowerShell:

>

To upgrade NotepadPlusPlus-Plugin Template, run the following command from the command line or from PowerShell:

>

To uninstall NotepadPlusPlus-Plugin Template, run the following command from the command line or from PowerShell:

>

Deployment Method:

📝 NOTE: This applies to both open source and commercial editions of Chocolatey.

1. Enter Your Internal Repository Url

(this should look similar to https://community.chocolatey.org/api/v2/)


2. Setup Your Environment

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

2. Get the package into your environment

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2/. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Copy Your Script

choco upgrade notepadplusplus-plugin.template -y --source="'INTERNAL REPO URL'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade notepadplusplus-plugin.template -y --source="'INTERNAL REPO URL'" 
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Install notepadplusplus-plugin.template
  win_chocolatey:
    name: notepadplusplus-plugin.template
    version: '1.0.3'
    source: INTERNAL REPO URL
    state: present

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.


chocolatey_package 'notepadplusplus-plugin.template' do
  action    :install
  source   'INTERNAL REPO URL'
  version  '1.0.3'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


cChocoPackageInstaller notepadplusplus-plugin.template
{
    Name     = "notepadplusplus-plugin.template"
    Version  = "1.0.3"
    Source   = "INTERNAL REPO URL"
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'notepadplusplus-plugin.template':
  ensure   => '1.0.3',
  provider => 'chocolatey',
  source   => 'INTERNAL REPO URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


4. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

This package was approved by moderator TheCakeIsNaOH on 01 Apr 2021.

Description

Template package for creating notepadplusplus plugin packages

Template Properties

  • PLUGIN_NAME - Optional property for using this template. Use this property to specify the plugin dll file name when it is different from your plugin name.
    For example if my plugin is called: 'SaveAndExec' and my plugin dll file is named: 'exec.dll' then I can pass it with: PLUGIN_NAME="exec"
    Default: package-id.

Usage

  1. Create choco package sources using this template. See examples below:
  • Example 1: choco new bettermultiselection -t notepadplusplus-plugin
  • Example 2: choco new myplugin -t notepadplusplus-plugin PLUGIN_NAME="DllPluginFileName"
  1. Put your plugin dll file into tools\x32 or tools\x64 (or both)
  2. Pack the plugin package by with choco pack command

templates\notepadplsuplus-plugin.nuspec.template
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
  <metadata>
    <id>notepadplusplus-plugin-[[PackageNameLower]]</id>
    <version>[[PackageVersion]]</version>
    <title>Notepad++ Plugin - [[PackageName]] (Install)</title>
    <authors>David Yair</authors>
    <owners>David Yair</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>
Install Notepad++ Plugin [[PackageName]]  
  
## Package parameters

- `/nppInstallDir:{Notepad++ installation dir}` - Provide full path to notepad++ existing installation dir. If not provided will search the default locations.
- `/skipIfAlreadyInstalled` - Instructs the installing script to skip if an any plugin existing-installation is detected.
- `/removePluginDir` - Uninstall flag to remove the whole plugin dir upon uninstall. Default behavior is to remove the whole dir only when it is empty after uninstalling.

Example 1: `choco install notepadplusplus-plugin-[[PackageNameLower]] --yes --params " /nppInstallDir:""C:\My\Notepad++"" "`  
Example 2: `choco install notepadplusplus-plugin-[[PackageNameLower]] --yes --params " /nppInstallDir:""C:\My\Notepad++"" /skipIfAlreadyInstalled "`  
Example 3: `choco uninstall notepadplusplus-plugin-[[PackageNameLower]] --yes --params " /nppInstallDir:""C:\My\Notepad++"" /removePluginDir "`  
	</description>
    <summary>This package is a plugin installation for 'Notepad++' which is a free source code editor and Notepad replacement that supports several languages.</summary>
    <tags>notepad notepadplusplus-plugin notepad-plus-plus editor text development foss</tags>
    <dependencies>
      <dependency id="notepadplusplus.install" />
    </dependencies>
  </metadata>
  <files>
    <file src="tools\**" target="tools" />
  </files>
</package>
templates\tools\chocolateyInstall.ps1
$ErrorActionPreference = 'Stop'

$pluginName = "[[PLUGIN_NAME]]"
$attribNamePluginName = "[[PLUGIN_NAME" + "]]"
$pluginPkgName = $env:ChocolateyPackageName
$pluginPkgVersion = $env:ChocolateyPackageVersion
if ((! $pluginName) -or ($pluginName.trim() -eq "") -or ($pluginName.trim() -eq $attribNamePluginName)) {Write-Host "Updating plugin-name to: '[[PackageName]]'" -ForegroundColor Cyan; $pluginName = "[[PackageName]]"}
$pluginDirName = $pluginName
$notepadPlusPlusSoftwareName   = 'Notepad\+\+*'
$toolsPath = Split-Path -parent $MyInvocation.MyCommand.Definition
$pluginDll = $null
$pluginDllFileName = "$pluginName.dll"
$skipIfAlreadyInstalled = $false

# Load helpers file
$helpersFile = Join-Path $toolsPath "helpers.ps1"
$helpersFile = Get-Item $helpersFile
Write-Host "Loading helpers file: $helpersFile"
. "$helpersFile"

if ((Get-ProcessorBits 32) -or ($env:ChocolateyForceX86 -eq $true)) {
	Write-Host "Installing x32 bit version" -ForegroundColor Yellow
	$pluginDll = Get-Item "$(Join-Path $toolsPath `"x32\$pluginDllFileName`")"
} else {
	Write-Host "Installing x64 bit version" -ForegroundColor Yellow
	$pluginDll = Get-Item "$(Join-Path $toolsPath `"x64\$pluginDllFileName`")"
}


# Check plugin DLL exists and reachable
if (! $pluginDll) {Write-Host "Error - Missing or unreachable plugin dll file: '$pluginDll'" -ForegroundColor RED ; exit 1}



# Read package parameters for notepad++ installation dir:
$pp = Get-PackageParameters
if ($pp -and $pp.Keys.Count -gt 0) {Write-Host "`nReceived package params:" -ForegroundColor Cyan; $pp.Keys | foreach {Write-Host $_ = $pp[$_]}; Write-Host "`n" }
if ($pp['nppInstallDir']) { $installLocation = $pp['nppInstallDir']}
if ($pp['skipIfAlreadyInstalled']) { $skipIfAlreadyInstalled = $true}


# Attempt to get current installed notepad++ dir
if (! $installLocation) {
	Write-Host "Did not receive param: '/nppInstallDir' - Attempting to locate $notepadPlusPlusSoftwareName installation dir"
	$installLocation = getNppInstallationDir $notepadPlusPlusSoftwareName
}

# Validate
checkNppInstallationDirIsValid $installLocation

# Prepare envs
$pluginsDir = Join-Path $installLocation "plugins"
$pluginInstallLocation = Join-Path $pluginsDir "$pluginDirName"
$pluginInstallLocationDllFile = Join-Path $pluginInstallLocation $pluginDllFileName

# Make sure dest plugin dir exists
createDir $pluginInstallLocation

# Check if already exists
if ((Test-Path -Path $pluginInstallLocationDllFile) -and $skipIfAlreadyInstalled) {
	Write-Host "Found plugin dll: '$pluginInstallLocationDllFile' `nPlugin: '$pluginName' is already installed"
	Write-Host " and flag: '/skipIfAlreadyInstalled' was received - skipping installation of this plugin's version: '$pluginPkgVersion'" -ForegroundColor Yellow
	cleanup
	exit 0
}

# Kill any running Notepad++ instances
killOpenProcesses "notepad++.exe"

# Removing any existing previous installed plugin dll files
Write-Host "Checking for existing previous installation of plugin: '$pluginName' dll files under: '$pluginInstallLocation'"
$existingPluginDllFiles = Get-ChildItem $pluginInstallLocation\*.dll
if ($existingPluginDllFiles -and ($existingPluginDllFiles.Length -gt 0)) {
	Write-Host "Removing any existing previous installed plugin: '$pluginName' dll files under: '$pluginInstallLocation'" -ForegroundColor Yellow
	$existingPluginDllFiles | foreach {Write-Host " - $_"}
	$existingPluginDllFiles | ForEach-Object { Remove-Item $_ -Force; Start-Sleep -Milliseconds 200; if (Test-Path $_) {Write-Host "Error - Failed to remove existing plugin: '$pluginName' previous installed dll file: '$_' `nFile might be in use.`nTry removing it yourself and reinstall this package" -ForegroundColor RED ; exit 1} }
}


# Copy plugin new dll file to: $pluginInstallLocation
Write-Host "Copying plugin: '$pluginName' new dll file `n from: '$pluginDll' to: '$pluginInstallLocation' "
$errHelpMsg = "Failed to copy plugin: '$pluginName' new dll file`n from: '$pluginDll' to: '$pluginInstallLocation'"
Copy-Item -Path $pluginDll -Destination $pluginInstallLocation -Force
if (! $?) {Write-Host "Error - Copy command seems to have failed `n$errHelpMsg" -ForegroundColor RED ; exit 1}
if (! (Test-Path -Path $pluginInstallLocationDllFile)) {Write-Host "Error - Missing or unreachable: '$pluginInstallLocationDllFile' `n$errHelpMsg" -ForegroundColor RED ; exit 1}


# Success
Write-Host "Success - Finished installing plugin: '$pluginName' new dll file to: '$pluginInstallLocation' " -ForegroundColor Green

# Cleanup func call
cleanup

Write-Host "Done"



templates\tools\chocolateyUninstall.ps1


$pluginName = "[[PLUGIN_NAME]]"
$attribNamePluginName = "[[PLUGIN_NAME" + "]]"
if ((! $pluginName) -or ($pluginName.trim() -eq "") -or ($pluginName.trim() -eq $attribNamePluginName)) {Write-Host "Updating plugin-name to: '[[PackageName]]'" -ForegroundColor Cyan; $pluginName = "[[PackageName]]"}
$pluginDirName = $pluginName
$notepadPlusPlusSoftwareName   = 'Notepad\+\+*'
$toolsPath = Split-Path -parent $MyInvocation.MyCommand.Definition
$pluginDllFileName = "$pluginName.dll"
$removePluginDir = $false

# Load helpers file
$helpersFile = Join-Path $toolsPath "helpers.ps1"
$helpersFile = Get-Item $helpersFile
Write-Host "Loading helpers file: $helpersFile"
. "$helpersFile"


# Read package parameters for notepad++ installation dir:
$pp = Get-PackageParameters
if ($pp -and $pp.Keys.Count -gt 0) {Write-Host "`nReceived package params:" -ForegroundColor Cyan; $pp.Keys | foreach {Write-Host $_ = $pp[$_]}; Write-Host "`n" }
if ($pp['nppInstallDir']) { $installLocation = $pp['nppInstallDir']}
if ($pp['removePluginDir']) { $removePluginDir = $true}


# Attempt to get current installed notepad++ dir
if (! $installLocation) {
	Write-Host "Did not receive param: '/nppInstallDir' - Attempting to locate $notepadPlusPlusSoftwareName installation dir"
	$installLocation = getNppInstallationDir $notepadPlusPlusSoftwareName
}

# Validate
checkNppInstallationDirIsValid $installLocation

# Prepare envs
$pluginsDir = Join-Path $installLocation "plugins"
$pluginInstallLocation = Join-Path $pluginsDir "$pluginDirName"
$pluginInstallLocationDllFile = Join-Path $pluginInstallLocation $pluginDllFileName


# Check plugin dir exists:
if (! (Test-Path -Path $pluginInstallLocation)) {Write-Warning "Plugin: '$pluginName' installation dir is missing from: $pluginInstallLocation `nNothing to do here.."; exit 0}


# Kill any running Notepad++ instances
killOpenProcesses "notepad++.exe"

# Check plugin dll file exists:
if (! (Test-Path -Path $pluginInstallLocationDllFile)) {
	Write-Warning "Plugin: '$pluginName' dll file is missing from: $pluginInstallLocationDllFile"
	checkAndRemovePluginDir $pluginInstallLocation
	exit 0
}

# Remove plugin DLL file
$errHelpMsg = "Failed to remove plugin dll: '$pluginInstallLocationDllFile'"
Write-Host "Removing plugin dll: $pluginInstallLocationDllFile"
Remove-Item -Path $pluginInstallLocationDllFile -Force
if (! $?) {Write-Host "Error - Remove action seems to have failed`n$errHelpMsg" -ForegroundColor RED ; exit 1}
if (Test-Path -Path $pluginInstallLocationDllFile) {Write-Host "Error - Remove action seems to have failed`n$errHelpMsg" -ForegroundColor RED ; exit 1}


checkAndRemovePluginDir $pluginInstallLocation
exit 0


templates\tools\helpers.ps1
# Contains helper functions for chocolateyInstall.ps1 & chocolateyUninstall.ps1 scripts

function getNppInstallationDir($nppSoftwareName) {
### Returns Notepad++ installation dir or $null if it can't find it
	$_nppInstallationDir = Get-AppInstallLocation $nppSoftwareName

	if (! $_nppInstallationDir)  {
		Write-Warning "Can't find $notepadPlusPlusSoftwareName install location via Chocolatey"
		
		# Default Install Locations
		$notepadPlusPlusDefaultInstallLocations = [System.Collections.ArrayList]::new()
		$notepadPlusPlusDefaultInstallLocations.add("$(Join-Path $env:ProgramFiles 'Notepad++')") | Out-Null
		$notepadPlusPlusDefaultInstallLocations.add("$(Join-Path $env:ProgramW6432 'Notepad++')") | Out-Null
		$notepadPlusPlusDefaultInstallLocations.add("$(Join-Path ${env:ProgramFiles(x86)} 'Notepad++')") | Out-Null

		# Remove Duplicate Paths
		$notepadPlusPlusDefaultInstallLocations = $notepadPlusPlusDefaultInstallLocations | select -Unique
		
		Write-Host "Looking for $notepadPlusPlusSoftwareName installation dir in default locations:"
		$notepadPlusPlusDefaultInstallLocations | foreach {Write-Host " - $_"}
		
		# Check for first path that exists
		$notepadPlusPlusDefaultInstallLocations | foreach {if (Test-path -Path $_) {$_nppInstallationDir = $_; Write-Host "Found $notepadPlusPlusSoftwareName installation dir: $_nppInstallationDir" -ForegroundColor Yellow; return $_nppInstallationDir} }
	}
	
	return $_nppInstallationDir
}

function checkNppInstallationDirIsValid($nppInstallationDir) {
### Checks that provided path is actually a Notpad++ installation dir
###  by testing if it exists & contains a 'plugins' dir
	Write-Host "Validating $notepadPlusPlusSoftwareName installation dir: $nppInstallationDir"
	$errHelpMsg = "You can try to reinstall this package and provide the $notepadPlusPlusSoftwareName existing installation dir via param: '/nppInstallDir'. `nExample: choco install $pluginPkgName --yes --params `" /nppInstallDir:`"`"C:\Notepad++`"`" `" "
	if (! $nppInstallationDir) {Write-Host "Error - No $notepadPlusPlusSoftwareName installation dir provided ('nppInstallationDir' is null) `nFailed to find $notepadPlusPlusSoftwareName installation dir`n${errHelpMsg}" -ForegroundColor RED ; exit 1}
	if (! (Test-Path -Path $nppInstallationDir)) {Write-Host "Error - Missing or unreachable $notepadPlusPlusSoftwareName installation dir: '$nppInstallationDir'`n${errHelpMsg}" -ForegroundColor RED ; exit 1}
	$pluginsDir = Join-Path $nppInstallationDir "plugins"
	if (! (Test-Path -Path $pluginsDir)) {Write-Host "Error - Missing or unreachable $notepadPlusPlusSoftwareName plugins dir: '$pluginsDir'`n${errHelpMsg}" -ForegroundColor RED ; exit 1}
}

function checkAndRemovePluginDir($nppPluginDir) {
	# Check if plugin dll dir is empty - if so then remove it
	$directoryInfo = Get-ChildItem $nppPluginDir | Measure-Object
	# $directoryInfo.count  Returns the count of all of the objects in the directory
	if (($directoryInfo.count -gt 0) -and (! $removePluginDir)) {Write-Warning "Plugin: '$pluginName' dir: ${nppPluginDir} is not empty and flag: '/removePluginDir' was not received. You should delete it by yourself later"; exit 0}
	Write-Host "Removing plugin dir: '${nppPluginDir}' "
	
	# Delete dir content
	Get-ChildItem -Path $nppPluginDir -Recurse | Remove-Item -force -recurse
	# Remove the dir itself
	Remove-Item $nppPluginDir -Force
}


function createDir($directoryPath) {
### Creates a directory at a given path
### Fails execution upon failure
	if (! (Test-Path -Path $directoryPath)) {
		Write-Host "Creating dir: '$directoryPath'"
		New-Item -Type Directory -Path $directoryPath -Force
		if (! (Test-Path -Path $directoryPath)) {Write-Host "Error - Missing or unreachable dir: '$directoryPath'`nand also failed to create it" -ForegroundColor RED ; exit 1}
	}
}


function cleanup() {
# Removes dirs: 'x32' & 'x64' from 'tools' dir
	Write-Host "Cleaning unncessary files: $toolsPath\*.dll" -ForegroundColor Yellow
	if (! $toolsPath) {Write-Host "Resetting var: 'toolsPath'"; $toolsPath = Split-Path -parent $MyInvocation.MyCommand.Definition}
	Get-ChildItem -Recurse $toolsPath\*.dll | ForEach-Object { Remove-Item $_ -ea 0; if (Test-Path $_) { Set-Content "$_.ignore" '' } }
}


function killProcess($procName, $procId) {
	Write-Host "Killing process: '$procName'   pid: $procId" -ForegroundColor Yellow
	& "taskkill" "/f" "/t" "/PID" "$procId"
	if ($LASTEXITCODE -ne 0) {Write-Host "Error - Failed killing process: $procName" -ForegroundColor RED; return}
}


function killOpenProcesses($processName) {
	$ownPid = $pid
	Write-Host "Looking for processes with name: '$processName'"
	$targetProcessesList = Get-WmiObject Win32_Process | where { ($_.ProcessId -ne $ownPid) -and (($_.Caption -Like "*${processName}*") -or ($_.Name -Like "*${processName}*") -or ($_.Description -Like "*${processName}*") -or ($_.ProcessName -Like "*${processName}*")) }
	if (! $targetProcessesList) {return}
	
	if (! $targetProcessesList.Count) {Write-Host "Found 1 process to kill"; killProcess $targetProcessesList.Name $targetProcessesList.ProcessId; return}
	Write-Host "Found $($targetProcessesList.Count) processes to kill" -ForegroundColor Cyan
	$targetProcessesList | foreach {killProcess $_.Name $_.ProcessId}  # Multiple processes
}


templates\tools\x32\.keep
 
templates\tools\x64\.keep
 

Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Add to Builder Version Downloads Last Updated Status
NotepadPlusPlus-Plugin Template 1.0.0 74 Monday, March 1, 2021 Approved

This package has no dependencies.

Discussion for the NotepadPlusPlus-Plugin Template Package

Ground Rules:

  • This discussion is only about NotepadPlusPlus-Plugin Template and the NotepadPlusPlus-Plugin Template package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or NotepadPlusPlus-Plugin Template, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus