-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish-PSResource: Pack and Push Feature (#1682)
- Loading branch information
1 parent
a2df53a
commit e9e8ecb
Showing
9 changed files
with
1,521 additions
and
1,049 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,7 @@ srcOld/code/obj | |
out | ||
test/**/obj | ||
test/**/bin | ||
.vs | ||
.vscode | ||
src/code/.vs | ||
test/testFiles/testScripts/test.ps1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.PowerShell.PSResourceGet.UtilClasses; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
|
||
namespace Microsoft.PowerShell.PSResourceGet.Cmdlets | ||
{ | ||
/// <summary> | ||
/// Compresses a module, script, or nupkg to a designated repository. | ||
/// </summary> | ||
[Cmdlet(VerbsData.Compress, | ||
"PSResource", | ||
SupportsShouldProcess = true)] | ||
[Alias("cmres")] | ||
public sealed class CompressPSResource : PSCmdlet | ||
{ | ||
#region Parameters | ||
|
||
/// <summary> | ||
/// Specifies the path to the resource that you want to compress. This parameter accepts the path to the folder that contains the resource. | ||
/// Specifies a path to one or more locations. Wildcards are permitted. The default location is the current directory (.). | ||
/// </summary> | ||
[Parameter(Mandatory = true, Position = 0, HelpMessage = "Path to the resource to be compressed.")] | ||
[ValidateNotNullOrEmpty] | ||
public string Path { get; set; } | ||
|
||
/// <summary> | ||
/// Specifies the path where the compressed resource (as a .nupkg file) should be saved. | ||
/// This parameter allows you to save the package to a specified location on the local file system. | ||
/// </summary> | ||
[Parameter(Mandatory = true, Position = 1, HelpMessage = "Path to save the compressed resource.")] | ||
[ValidateNotNullOrEmpty] | ||
public string DestinationPath { get; set; } | ||
|
||
/// <summary> | ||
/// Bypasses validating a resource module manifest before publishing. | ||
/// </summary> | ||
[Parameter] | ||
public SwitchParameter SkipModuleManifestValidate { get; set; } | ||
|
||
#endregion | ||
|
||
#region Members | ||
|
||
private PublishHelper _publishHelper; | ||
|
||
#endregion | ||
|
||
#region Method Overrides | ||
|
||
protected override void BeginProcessing() | ||
{ | ||
// Create a respository store (the PSResourceRepository.xml file) if it does not already exist | ||
// This is to create a better experience for those who have just installed v3 and want to get up and running quickly | ||
RepositorySettings.CheckRepositoryStore(); | ||
|
||
_publishHelper = new PublishHelper( | ||
this, | ||
Path, | ||
DestinationPath, | ||
SkipModuleManifestValidate); | ||
|
||
_publishHelper.CheckAllParameterPaths(); | ||
} | ||
|
||
protected override void EndProcessing() | ||
{ | ||
_publishHelper.PackResource(); | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,8 @@ public enum ResourceType | |
{ | ||
None, | ||
Module, | ||
Script | ||
Script, | ||
Nupkg | ||
} | ||
|
||
public enum VersionType | ||
|
Oops, something went wrong.