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

Publish-PSResource: Pack and Push Feature #1682

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8246ea3
initial changes
Jul 31, 2024
e5d6b2a
Added PSResourceHelper class to share methods between Publish and Com…
Aug 1, 2024
3328544
some test cases pass, still need to fix how it handles scripts
Aug 2, 2024
9dd27b3
some more test cases passed, still a WIP
Aug 2, 2024
848bfed
All test cases passed
Aug 2, 2024
d19eef1
added tests for Compress
Aug 2, 2024
ee4eb5c
Addressed issues brought up by @alerickson
Aug 6, 2024
815af98
Update test/PublishPSResourceTests/CompressPSResource.Tests.ps1
jshigetomi Aug 6, 2024
3b88612
Update PublishPSResource.Tests.ps1
jshigetomi Aug 6, 2024
eab5a31
Update src/code/CompressPSResource.cs
jshigetomi Aug 6, 2024
505b4ec
alias to cmres
jshigetomi Aug 6, 2024
f983374
_psResourceHelper -> _publishHelper
jshigetomi Aug 6, 2024
3bc1f1b
Added nupkg as a ResourceType
Aug 19, 2024
f57f4cc
initial changes
Jul 31, 2024
c8b2d5a
Added PSResourceHelper class to share methods between Publish and Com…
Aug 1, 2024
1af00dd
some test cases pass, still need to fix how it handles scripts
Aug 2, 2024
549f8dc
some more test cases passed, still a WIP
Aug 2, 2024
7849888
All test cases passed
Aug 2, 2024
f8b8e51
Addressed issues brought up by @alerickson
Aug 6, 2024
2c2060c
Update PublishPSResource.Tests.ps1
jshigetomi Aug 6, 2024
259da8c
Fixed an ambigous test that failed on git but passed on local machine
Aug 20, 2024
6927585
Addressed issues brought up by @alerickson.
Aug 21, 2024
c4dd691
changed _cmdlet -> _cmdletPassedIn
Aug 21, 2024
8c7e37d
cleaned up a test
Aug 21, 2024
ea3a5f2
deleted extra files by mistake
Aug 21, 2024
e869ddf
adding .suo back
Aug 21, 2024
a537e23
deleted test file
Aug 22, 2024
935c2c7
Merge remote-tracking branch 'upstream/master' into issue-1635-PSReso…
Aug 23, 2024
28b3cbd
rebased with find-repo fix
Aug 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ srcOld/code/obj
out
test/**/obj
test/**/bin
.vs
.vscode
src/code/.vs
test/testFiles/testScripts/test.ps1
1 change: 1 addition & 0 deletions src/Microsoft.PowerShell.PSResourceGet.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
CLRVersion = '4.0.0'
FormatsToProcess = 'PSGet.Format.ps1xml'
CmdletsToExport = @(
'Compress-PSResource',
'Find-PSResource',
'Get-InstalledPSResource',
'Get-PSResourceRepository',
Expand Down
Binary file modified src/code/.vs/Microsoft.PowerShell.PSResourceGet/v17/.suo
Binary file not shown.
77 changes: 77 additions & 0 deletions src/code/CompressPSResource.cs
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

}
}
3 changes: 2 additions & 1 deletion src/code/PSResourceInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public enum ResourceType
{
None,
Module,
Script
Script,
Nupkg
}

public enum VersionType
Expand Down
Loading
Loading