-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
142 additions
and
64 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
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
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
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
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,26 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.IO.Compression; | ||
|
||
namespace Microsoft.PowerPlatform.PowerApps.Persistence.Extensions; | ||
|
||
public static class IMsappArchiveExtensions | ||
{ | ||
/// <summary> | ||
/// Returns the entry in the archive with the given name or throws a <see cref="FileNotFoundException"/> if it does not exist. | ||
/// </summary> | ||
/// <param name="archive">the <see cref="IMsappArchive"/> instance.</param> | ||
/// <param name="entryName">the name of the entry to fetch.</param> | ||
/// <returns></returns> | ||
/// <exception cref="ArgumentException"></exception> | ||
/// <exception cref="FileNotFoundException"></exception> | ||
public static ZipArchiveEntry GetRequiredEntry(this IMsappArchive archive, string entryName) | ||
{ | ||
var entry = archive.GetEntry(entryName) ?? | ||
throw new FileNotFoundException($"Entry '{entryName}' not found in msapp archive."); | ||
|
||
return entry; | ||
} | ||
} | ||
|
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
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
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,17 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
namespace Microsoft.PowerPlatform.PowerApps.Persistence.Utils; | ||
|
||
public static class FileUtils | ||
{ | ||
/// <summary> | ||
/// Converts backslashes to forward slashes, removes trailing slashes, and converts to lowercase. | ||
/// </summary> | ||
/// <param name="path"></param> | ||
/// <returns></returns> | ||
public static string NormalizePath(string path) | ||
{ | ||
return path.Trim().Replace('\\', '/').Trim('/').ToLowerInvariant(); | ||
} | ||
} |
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,28 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
namespace Microsoft.PowerPlatform.PowerApps.Persistence.Yaml; | ||
|
||
public static class YamlUtils | ||
{ | ||
#region Constants | ||
|
||
public const string YamlFileExtension = ".yaml"; | ||
public const string YmlFileExtension = ".yml"; | ||
public const string YamlFxFileExtension = ".fx.yaml"; | ||
|
||
#endregion | ||
|
||
/// <summary> | ||
/// Checks if the given path is a yaml file. | ||
/// </summary> | ||
/// <param name="path"></param> | ||
/// <returns></returns> | ||
public static bool IsYamlFile(string path) | ||
{ | ||
return | ||
Path.GetExtension(path).Equals(YamlFileExtension, StringComparison.OrdinalIgnoreCase) || | ||
Path.GetExtension(path).Equals(YmlFileExtension, StringComparison.OrdinalIgnoreCase); | ||
} | ||
} | ||
|