Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add whatif and export support NpmDsc #132

Merged
merged 14 commits into from
Nov 28, 2024
3 changes: 3 additions & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ videojs
vsconfig
websites
wekyb
Hmmss
MMdd
MMdd
3 changes: 2 additions & 1 deletion .github/actions/spelling/expect/generic_terms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ sortby
ssh
usr
versioning
VGpu
VGpu
ADDLOCAL
3 changes: 2 additions & 1 deletion .github/actions/spelling/expect/software.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dotnet
dotnettool
NUnit
reportgenerator
markdownlint
markdownlint
msiexec
54 changes: 54 additions & 0 deletions resources/Help/NpmDsc/NpmPackage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
external help file: NpmDsc.psm1-Help.xml
Module Name: NpmDsc
ms.date: 11/16/2024
online version:
schema: 2.0.0
title: NpmPackage
---

# NpmPackage

## SYNOPSIS

The `NpmPackage` DSC Resource allows you to manage the installation, update, and removal of npm packages. This resource ensures that the specified npm package is in the desired state.

## DESCRIPTION

The `NpmPackage` DSC Resource allows you to manage the installation, update, and removal of npm packages. This resource ensures that the specified npm package is in the desired state.

## PARAMETERS

| **Parameter** | **Attribute** | **DataType** | **Description** | **Allowed Values** |
| ------------------ | -------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
| `Ensure` | Optional | String | Specifies whether the npm package should be present or absent. The default value is `Present`. | `Present`, `Absent` |
| `Name` | Key, Mandatory | String | The name of the npm package to manage. This is a key property. | Any valid npm package name |
| `Version` | Optional | String | The version of the npm package to install. If not specified, the latest version will be installed. | Any valid version string (e.g., `4.17.1`) |
| `PackageDirectory` | Optional | String | The directory where the npm package should be installed. If not specified, the package will be installed in the current directory. | Any valid directory path |
| `Global` | Optional | Boolean | Indicates whether the npm package should be installed globally. The default value is `$false`. | `$true`, `$false` |

## EXAMPLES

### EXAMPLE 1 - Install React package in default directory

```powershell
PS C:\> Invoke-DscResource -ModuleName NpmDsc -Name NpmPackage -Method Set -Property @{ Name = 'react' }

# This example installs the npm package 'react' in the current directory.
```

### EXAMPLE 2 - Install Babel package in global directory

```powershell
PS C:\> Invoke-DscResource -ModuleName NpmDsc -Name NpmPackage -Method Set -Property @{ Name = 'babel'; Global = $true }

# This example installs the npm package 'babel' globally.
```

### EXAMPLE 3 - Get WhatIf result for React package

```powershell
PS C:\> ([NpmPackage]@{ Name = 'react' }).WhatIf()

# This example returns the whatif result for installing the npm package 'react'. Note: This does not actually install the package and requires the module to be imported using 'using module <moduleName>'.
```
Loading