Skip to content

Commit b9c45c8

Browse files
authored
Add whatif and export support NpmDsc (#132)
1 parent 584dfb6 commit b9c45c8

6 files changed

Lines changed: 462 additions & 107 deletions

File tree

.github/actions/spelling/allow.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,6 @@ videojs
6565
vsconfig
6666
websites
6767
wekyb
68+
Hmmss
69+
MMdd
70+
MMdd

.github/actions/spelling/expect/generic_terms.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ sortby
1818
ssh
1919
usr
2020
versioning
21-
VGpu
21+
VGpu
22+
ADDLOCAL

.github/actions/spelling/expect/software.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ dotnet
44
dotnettool
55
NUnit
66
reportgenerator
7-
markdownlint
7+
markdownlint
8+
msiexec
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
external help file: NpmDsc.psm1-Help.xml
3+
Module Name: NpmDsc
4+
ms.date: 11/16/2024
5+
online version:
6+
schema: 2.0.0
7+
title: NpmPackage
8+
---
9+
10+
# NpmPackage
11+
12+
## SYNOPSIS
13+
14+
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.
15+
16+
## DESCRIPTION
17+
18+
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.
19+
20+
## PARAMETERS
21+
22+
| **Parameter** | **Attribute** | **DataType** | **Description** | **Allowed Values** |
23+
| ------------------ | -------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
24+
| `Ensure` | Optional | String | Specifies whether the npm package should be present or absent. The default value is `Present`. | `Present`, `Absent` |
25+
| `Name` | Key, Mandatory | String | The name of the npm package to manage. This is a key property. | Any valid npm package name |
26+
| `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`) |
27+
| `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 |
28+
| `Global` | Optional | Boolean | Indicates whether the npm package should be installed globally. The default value is `$false`. | `$true`, `$false` |
29+
30+
## EXAMPLES
31+
32+
### EXAMPLE 1 - Install React package in default directory
33+
34+
```powershell
35+
PS C:\> Invoke-DscResource -ModuleName NpmDsc -Name NpmPackage -Method Set -Property @{ Name = 'react' }
36+
37+
# This example installs the npm package 'react' in the current directory.
38+
```
39+
40+
### EXAMPLE 2 - Install Babel package in global directory
41+
42+
```powershell
43+
PS C:\> Invoke-DscResource -ModuleName NpmDsc -Name NpmPackage -Method Set -Property @{ Name = 'babel'; Global = $true }
44+
45+
# This example installs the npm package 'babel' globally.
46+
```
47+
48+
### EXAMPLE 3 - Get WhatIf result for React package
49+
50+
```powershell
51+
PS C:\> ([NpmPackage]@{ Name = 'react' }).WhatIf()
52+
53+
# 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>'.
54+
```

0 commit comments

Comments
 (0)