Skip to content

Commit 7649383

Browse files
committed
changes for getting func pack working
1 parent 65f42c4 commit 7649383

21 files changed

+32
-293
lines changed

src/Cli/func/Actions/HelpAction.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,34 +267,34 @@ private void DisplaySubCommandHelp(ActionType subCommand)
267267
var description = subCommand.Type.GetCustomAttributes<ActionAttribute>()?.FirstOrDefault()?.HelpText;
268268

269269
// Display indented subcommand header
270-
ColoredConsole.WriteLine($" {runtimeName.DarkCyan()} {description}");
270+
ColoredConsole.WriteLine($" {runtimeName.DarkCyan()} {description}");
271271

272272
// Display subcommand switches with extra indentation
273-
DisplaySwitches(subCommand, true);
273+
DisplaySwitches(subCommand);
274274
}
275275

276-
private void DisplaySwitches(ActionType actionType, bool addExtraIndent = false)
276+
private void DisplaySwitches(ActionType actionType)
277277
{
278278
var action = _createAction.Invoke(actionType.Type);
279279
try
280280
{
281281
var options = action.ParseArgs(Array.Empty<string>());
282282
if (options.UnMatchedOptions.Any())
283283
{
284-
DisplayOptions(options.UnMatchedOptions, addExtraIndent);
284+
DisplayOptions(options.UnMatchedOptions);
285285
ColoredConsole.WriteLine();
286286
}
287287
}
288288
catch (CliArgumentsException e)
289289
{
290290
if (e.Arguments.Any())
291291
{
292-
DisplayPositionalArguments(e.Arguments, addExtraIndent);
292+
DisplayPositionalArguments(e.Arguments);
293293
}
294294

295295
if (e.ParseResults != null && e.ParseResults.UnMatchedOptions.Any())
296296
{
297-
DisplayOptions(e.ParseResults.UnMatchedOptions, addExtraIndent);
297+
DisplayOptions(e.ParseResults.UnMatchedOptions);
298298
}
299299

300300
ColoredConsole.WriteLine();
@@ -305,13 +305,13 @@ private void DisplaySwitches(ActionType actionType, bool addExtraIndent = false)
305305
}
306306
}
307307

308-
private void DisplayPositionalArguments(IEnumerable<CliArgument> arguments, bool addExtraIndent)
308+
private void DisplayPositionalArguments(IEnumerable<CliArgument> arguments)
309309
{
310310
var longestName = arguments.Max(o => o.Name.Length);
311311
longestName += 4; // 4 for coloring and <> characters
312312
foreach (var argument in arguments)
313313
{
314-
var helpLine = string.Format($"{(addExtraIndent ? " " : " ")}{{0, {-longestName}}} {{1}}", $"<{argument.Name}>".DarkGray(), argument.Description);
314+
var helpLine = string.Format($"{" "}{{0, {-longestName}}} {{1}}", $"<{argument.Name}>".DarkGray(), argument.Description);
315315
if (helpLine.Length < SafeConsole.BufferWidth)
316316
{
317317
ColoredConsole.WriteLine(helpLine);

src/Cli/func/Actions/LocalActions/PackAction/CustomPackSubcommandAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Azure.Functions.Cli.Actions.LocalActions.PackAction
88
{
9-
[Action(Name = "pack custom", ParentCommandName = "pack", ShowInHelp = true, HelpText = "Arguments specific to custom worker runtime apps when running func pack")]
9+
[Action(Name = "pack custom", ParentCommandName = "pack", ShowInHelp = false, HelpText = "Arguments specific to custom worker runtime apps when running func pack")]
1010
internal class CustomPackSubcommandAction : BaseAction
1111
{
1212
public override ICommandLineParserResult ParseArgs(string[] args)

src/Cli/func/Actions/LocalActions/PackAction/DotnetPackSubcommandAction.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,13 @@ public async Task RunAsync(PackOptions packOptions)
7373
var outputPath = PackHelpers.ResolveOutputPath(functionAppRoot, packOptions.OutputPath);
7474
PackHelpers.CleanupExistingPackage(outputPath);
7575

76-
await PackHelpers.CreatePackage(packingRoot, outputPath, packOptions.NoBuild, TelemetryCommandEvents, packOptions.PreserveExecutables);
76+
await PackHelpers.CreatePackage(packingRoot, outputPath, packOptions.NoBuild, TelemetryCommandEvents);
77+
78+
if (!packOptions.NoBuild)
79+
{
80+
// If not no-build, delete packing root after packing
81+
FileSystemHelpers.DeleteDirectorySafe(packingRoot);
82+
}
7783
}
7884

7985
public override Task RunAsync()

src/Cli/func/Actions/LocalActions/PackAction/NodePackSubcommandAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public async Task RunAsync(PackOptions packOptions, string[] args)
5757
var outputPath = PackHelpers.ResolveOutputPath(functionAppRoot, packOptions.OutputPath);
5858
PackHelpers.CleanupExistingPackage(outputPath);
5959

60-
await PackHelpers.CreatePackage(functionAppRoot, outputPath, packOptions.NoBuild, TelemetryCommandEvents, packOptions.PreserveExecutables);
60+
await PackHelpers.CreatePackage(functionAppRoot, outputPath, packOptions.NoBuild, TelemetryCommandEvents);
6161
}
6262

6363
public override Task RunAsync()

src/Cli/func/Actions/LocalActions/PackAction/PackAction.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ public PackAction(ISecretsManager secretsManager)
2424

2525
public bool NoBuild { get; set; }
2626

27-
public string[] PreserveExecutables { get; set; } = Array.Empty<string>();
28-
2927
private string[] Args { get; set; }
3028

3129
public override ICommandLineParserResult ParseArgs(string[] args)
@@ -41,11 +39,6 @@ public override ICommandLineParserResult ParseArgs(string[] args)
4139
"Otherwise, default is the current directory.")
4240
.Callback(n => NoBuild = n);
4341

44-
Parser
45-
.Setup<string>("preserve-executables")
46-
.WithDescription("Comma - separated list of executable files to specify which files should be set as executable in the zip archive.")
47-
.Callback(p => PreserveExecutables = p.Split(',').Select(s => s.Trim()).ToArray());
48-
4942
if (args.Any() && !args.First().StartsWith("-"))
5043
{
5144
FolderPath = args.First();
@@ -66,8 +59,7 @@ public override async Task RunAsync()
6659
{
6760
FolderPath = FolderPath,
6861
OutputPath = OutputPath,
69-
NoBuild = NoBuild,
70-
PreserveExecutables = PreserveExecutables
62+
NoBuild = NoBuild
7163
};
7264

7365
// Internally dispatch to runtime-specific subcommand

src/Cli/func/Actions/LocalActions/PackAction/PackHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static void CleanupExistingPackage(string outputPath)
6262
}
6363
}
6464

65-
public static async Task CreatePackage(string packingRoot, string outputPath, bool noBuild, IDictionary<string, string> telemetryCommandEvents, string[] executables, bool buildNativeDeps = false)
65+
public static async Task CreatePackage(string packingRoot, string outputPath, bool noBuild, IDictionary<string, string> telemetryCommandEvents, bool buildNativeDeps = false)
6666
{
6767
bool useGoZip = EnvironmentHelper.GetEnvironmentVariableAsBool(Constants.UseGoZip);
6868
TelemetryHelpers.AddCommandEventToDictionary(telemetryCommandEvents, "UseGoZip", useGoZip.ToString());
@@ -85,7 +85,7 @@ public static async Task DefaultZip(PackOptions packOptions, IDictionary<string,
8585
var outputPath = ResolveOutputPath(functionAppRoot, packOptions.OutputPath);
8686
CleanupExistingPackage(outputPath);
8787

88-
await CreatePackage(functionAppRoot, outputPath, packOptions.NoBuild, telemetryCommandEvents, packOptions.PreserveExecutables);
88+
await CreatePackage(functionAppRoot, outputPath, packOptions.NoBuild, telemetryCommandEvents);
8989
}
9090
}
9191
}

src/Cli/func/Actions/LocalActions/PackAction/PackOptions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@ public class PackOptions
1010
public string OutputPath { get; set; } = string.Empty;
1111

1212
public bool NoBuild { get; set; }
13-
14-
public string[] PreserveExecutables { get; set; } = Array.Empty<string>();
1513
}
1614
}

src/Cli/func/Actions/LocalActions/PackAction/PowershellPackSubcommandAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Azure.Functions.Cli.Actions.LocalActions.PackAction
88
{
9-
[Action(Name = "pack powershell", ParentCommandName = "pack", ShowInHelp = true, HelpText = "Arguments specific to PowerShell apps when running func pack")]
9+
[Action(Name = "pack powershell", ParentCommandName = "pack", ShowInHelp = false, HelpText = "Arguments specific to PowerShell apps when running func pack")]
1010
internal class PowershellPackSubcommandAction : BaseAction
1111
{
1212
public override ICommandLineParserResult ParseArgs(string[] args)

src/Cli/func/Actions/LocalActions/PackAction/PythonPackSubcommandAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public async Task RunAsync(PackOptions packOptions, string[] args)
6060
var outputPath = PackHelpers.ResolveOutputPath(functionAppRoot, packOptions.OutputPath);
6161
PackHelpers.CleanupExistingPackage(outputPath);
6262

63-
await PackHelpers.CreatePackage(functionAppRoot, outputPath, packOptions.NoBuild, TelemetryCommandEvents, packOptions.PreserveExecutables, BuildNativeDeps);
63+
await PackHelpers.CreatePackage(functionAppRoot, outputPath, packOptions.NoBuild, TelemetryCommandEvents, BuildNativeDeps);
6464
}
6565

6666
public override Task RunAsync()

src/Cli/func/Helpers/ZipHelper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Azure.Functions.Cli.Helpers
1212
{
1313
public static class ZipHelper
1414
{
15-
public static async Task<Stream> GetAppZipFile(string functionAppRoot, bool buildNativeDeps, BuildOption buildOption, bool noBuild, GitIgnoreParser ignoreParser = null, string additionalPackages = null, string[] preserveExecutables = null)
15+
public static async Task<Stream> GetAppZipFile(string functionAppRoot, bool buildNativeDeps, BuildOption buildOption, bool noBuild, GitIgnoreParser ignoreParser = null, string additionalPackages = null)
1616
{
1717
var gitIgnorePath = Path.Combine(functionAppRoot, Constants.FuncIgnoreFile);
1818
if (ignoreParser == null && FileSystemHelpers.FileExists(gitIgnorePath))
@@ -40,7 +40,7 @@ public static async Task<Stream> GetAppZipFile(string functionAppRoot, bool buil
4040
else if (GlobalCoreToolsSettings.CurrentWorkerRuntime == WorkerRuntime.Dotnet && buildOption == BuildOption.Remote)
4141
{
4242
// Remote build for dotnet does not require bin and obj folders. They will be generated during the oryx build
43-
return await CreateZip(FileSystemHelpers.GetLocalFiles(functionAppRoot, ignoreParser, false, new string[] { "bin", "obj" }), functionAppRoot, Enumerable.Empty<string>());
43+
return await CreateZip(FileSystemHelpers.GetLocalFiles(functionAppRoot, ignoreParser, false, new string[] { "bin", "obj" }), functionAppRoot, Array.Empty<string>());
4444
}
4545
else
4646
{
@@ -49,7 +49,6 @@ public static async Task<Stream> GetAppZipFile(string functionAppRoot, bool buil
4949
? new[] { customHandler }
5050
: Enumerable.Empty<string>();
5151

52-
executables = executables.Concat(preserveExecutables ?? Enumerable.Empty<string>());
5352
return await CreateZip(FileSystemHelpers.GetLocalFiles(functionAppRoot, ignoreParser, false), functionAppRoot, executables);
5453
}
5554
}

0 commit comments

Comments
 (0)