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

Font Install #5042

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Next Next commit
add initial flow for installing a font
  • Loading branch information
ryfu-msft committed Nov 27, 2024
commit aae3caa1a96b82c4dea52d67a4f9e94c0dcf1bf9
Original file line number Diff line number Diff line change
@@ -65,7 +65,8 @@
"wix",
"burn",
"pwa",
"portable"
"portable",
"font"
],
"description": "Enumeration of supported installer types. InstallerType is required in either root level or individual Installer level"
},
@@ -80,7 +81,8 @@
"nullsoft",
"wix",
"burn",
"portable"
"portable",
"font"
],
"description": "Enumeration of supported nested installer types contained inside an archive file"
},
Original file line number Diff line number Diff line change
@@ -167,7 +167,8 @@
"wix",
"burn",
"pwa",
"portable"
"portable",
"font"
],
"description": "Enumeration of supported installer types. InstallerType is required in either root level or individual Installer level"
},
@@ -182,7 +183,8 @@
"nullsoft",
"wix",
"burn",
"portable"
"portable",
"font"
],
"description": "Enumeration of supported nested installer types contained inside an archive file"
},
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line number Diff line number Diff line change
@@ -398,6 +398,7 @@
<ClInclude Include="ExecutionContext.h" />
<ClInclude Include="ExecutionProgress.h" />
<ClInclude Include="ExecutionReporter.h" />
<ClInclude Include="FontInstaller.h" />
<ClInclude Include="Invocation.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="PortableInstaller.h" />
@@ -483,6 +484,7 @@
<ClCompile Include="ExecutionContext.cpp" />
<ClCompile Include="ExecutionProgress.cpp" />
<ClCompile Include="ExecutionReporter.cpp" />
<ClCompile Include="FontInstaller.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -266,6 +266,9 @@
<ClInclude Include="Workflows\FontFlow.h">
<Filter>Workflows</Filter>
</ClInclude>
<ClInclude Include="FontInstaller.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
@@ -502,6 +505,9 @@
<ClCompile Include="Workflows\FontFlow.cpp">
<Filter>Workflows</Filter>
</ClCompile>
<ClCompile Include="FontInstaller.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
49 changes: 49 additions & 0 deletions src/AppInstallerCLICore/Commands/FontCommand.cpp
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
#include "Workflows/CompletionFlow.h"
#include "Workflows/WorkflowBase.h"
#include "Workflows/FontFlow.h"
#include "Workflows/InstallFlow.h"
#include "Resources.h"

namespace AppInstaller::CLI
@@ -43,6 +44,54 @@ namespace AppInstaller::CLI
OutputHelp(context.Reporter);
}

std::vector<Argument> FontInstallCommand::GetArguments() const
{
return {
Argument::ForType(Args::Type::Manifest),
Argument{ Args::Type::InstallScope, Resource::String::InstallScopeDescription, ArgumentType::Standard, Argument::Visibility::Help },
Argument::ForType(Args::Type::Force),
};
}

Resource::LocString FontInstallCommand::ShortDescription() const
{
return { Resource::String::FontInstallCommandShortDescription };
}

Resource::LocString FontInstallCommand::LongDescription() const
{
return { Resource::String::FontInstallCommandLongDescription };
}

void FontInstallCommand::Complete(Execution::Context& context, Args::Type valueType) const
{
UNREFERENCED_PARAMETER(valueType);
context.Reporter.Error() << Resource::String::PendingWorkError << std::endl;
THROW_HR(E_NOTIMPL);
}

Utility::LocIndView FontInstallCommand::HelpLink() const
{
return s_FontCommand_HelpLink;
}

void FontInstallCommand::ValidateArgumentsInternal(Execution::Args& execArgs) const
{
Argument::ValidateCommonArguments(execArgs);
}

void FontInstallCommand::ExecuteInternal(Execution::Context& context) const
{
if (context.Args.Contains(Execution::Args::Type::Manifest))
{
context <<
Workflow::ReportExecutionStage(ExecutionStage::Discovery) <<
Workflow::GetManifestFromArg <<
Workflow::SelectInstaller <<
Workflow::InstallSinglePackage;
}
}

std::vector<Argument> FontListCommand::GetArguments() const
{
return {
18 changes: 18 additions & 0 deletions src/AppInstallerCLICore/Commands/FontCommand.h
Original file line number Diff line number Diff line change
@@ -21,6 +21,24 @@ namespace AppInstaller::CLI
void ExecuteInternal(Execution::Context& context) const override;
};

struct FontInstallCommand final : public Command
{
FontInstallCommand(std::string_view parent) : Command("install", parent) {}

std::vector<Argument> GetArguments() const override;

Resource::LocString ShortDescription() const override;
Resource::LocString LongDescription() const override;

void Complete(Execution::Context& context, Execution::Args::Type valueType) const override;

Utility::LocIndView HelpLink() const override;

protected:
void ValidateArgumentsInternal(Execution::Args& execArgs) const override;
void ExecuteInternal(Execution::Context& context) const override;
};

struct FontListCommand final : public Command
{
FontListCommand(std::string_view parent) : Command("list", parent) {}
25 changes: 25 additions & 0 deletions src/AppInstallerCLICore/FontInstaller.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "ExecutionContext.h"
#include "FontInstaller.h"
#include <winget/Manifest.h>
#include <winget/ManifestCommon.h>
#include <winget/Filesystem.h>
#include <AppInstallerErrors.h>
#include <AppInstallerRuntime.h>

namespace AppInstaller::CLI::Font
{
FontInstaller::FontInstaller(const std::string& familyName, Manifest::ScopeEnum scope)
{
m_scope = scope;
m_familyName = familyName;

// Get the expected state from the family name and scope.
}

void FontInstaller::Install()
{
}
}
21 changes: 21 additions & 0 deletions src/AppInstallerCLICore/FontInstaller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include <filesystem>

namespace AppInstaller::CLI::Font
{
// Object representation of the metadata and functionality required for installing a font package.
struct FontInstaller
{
std::filesystem::path FontFileLocation;

FontInstaller(const std::string& familyName, Manifest::ScopeEnum scope);

void Install();

private:
Manifest::ScopeEnum m_scope;
std::string m_familyName;
};
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Resources.h
Original file line number Diff line number Diff line change
@@ -256,6 +256,8 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(FontFamily);
WINGET_DEFINE_RESOURCE_STRINGID(FontFamilyNameArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(FontFilePaths);
WINGET_DEFINE_RESOURCE_STRINGID(FontInstallCommandLongDescription);
WINGET_DEFINE_RESOURCE_STRINGID(FontInstallCommandShortDescription);
WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandLongDescription);
WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandShortDescription);
WINGET_DEFINE_RESOURCE_STRINGID(FontVersion);
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Workflows/DownloadFlow.cpp
Original file line number Diff line number Diff line change
@@ -223,6 +223,7 @@ namespace AppInstaller::CLI::Workflow
case InstallerTypeEnum::Portable:
case InstallerTypeEnum::Wix:
case InstallerTypeEnum::Zip:
case InstallerTypeEnum::Font:
context << DownloadInstallerFile;
break;
case InstallerTypeEnum::Msix:
4 changes: 4 additions & 0 deletions src/AppInstallerCLICore/Workflows/FontFlow.cpp
Original file line number Diff line number Diff line change
@@ -121,4 +121,8 @@ namespace AppInstaller::CLI::Workflow
OutputInstalledFontFamiliesTable(context, lines);
}
}

void FontInstallImpl(Execution::Context& context)
{
}
}
12 changes: 12 additions & 0 deletions src/AppInstallerCLICore/Workflows/FontFlow.h
Original file line number Diff line number Diff line change
@@ -10,4 +10,16 @@ namespace AppInstaller::CLI::Workflow
// Inputs: None
// Outputs: None
void ReportInstalledFonts(Execution::Context& context);

// Installs the font package.
// Required Args: None
// Inputs: Manifest, Scope, Rename, Location
// Outputs: None
void FontInstallImpl(Execution::Context& context);

// Initializes the font installer.
// Required Args: None
// Inputs: Scope, Manifest, Installer
// Outputs: None
void InitializeFontInstaller(Execution::Context& context);
}
14 changes: 14 additions & 0 deletions src/AppInstallerCLICore/Workflows/InstallFlow.cpp
Original file line number Diff line number Diff line change
@@ -276,6 +276,18 @@ namespace AppInstaller::CLI::Workflow
VerifyAndSetNestedInstaller <<
ExecuteInstallerForType(context.Get<Execution::Data::Installer>().value().NestedInstallerType);
}

// Runs the flow for installing a font package.
// Required Args: None
// Inputs: Installer, InstallerPath
// Outputs: None
void FontInstall(Execution::Context& context)
{
context <<
InitializeFontInstaller <<
FontInstallImpl <<
ReportInstallerResult("Font"sv, APPINSTALLER_CLI_ERROR_FONT_INSTALL_FAILED, true);
}
}

bool ExemptFromSingleInstallLocking(InstallerTypeEnum type)
@@ -443,6 +455,8 @@ namespace AppInstaller::CLI::Workflow
case InstallerTypeEnum::Zip:
context << details::ArchiveInstall;
break;
case InstallerTypeEnum::Font:
context << details::FontInstall;
default:
THROW_HR(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED));
}
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Workflows/InstallFlow.h
Original file line number Diff line number Diff line change
@@ -49,6 +49,12 @@ namespace AppInstaller::CLI::Workflow
// Inputs: Installer, InstallerPath, Manifest
// Outputs: None
void ArchiveInstall(Execution::Context& context);

// Runs the flow for intsalling a font package.
// Required Args: None
// Inputs: Installer, InstallerPath, Manifest
// Outputs: None
void FontInstall(Execution::Context& context);
}

// Ensures that there is an applicable installer.
12 changes: 9 additions & 3 deletions src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw
Original file line number Diff line number Diff line change
@@ -1812,7 +1812,7 @@ Please specify one of them using the --source option to proceed.</value>
<data name="ConfigurationSuccessfullyApplied" xml:space="preserve">
<value>Configuration successfully applied.</value>
</data>
<data name="ConfigurationUnitSuccessfullyApplied" xml:space="preserve">
<data name="ConfigurationUnitSuccessfullyApplied" xml:space="preserve">
<value>Unit successfully applied.</value>
</data>
<data name="ConfigurationWaitingOnAnother" xml:space="preserve">
@@ -3147,7 +3147,7 @@ Please specify one of them using the --source option to proceed.</value>
</data>
<data name="InstallerZeroByteFile" xml:space="preserve">
<value>Downloaded zero byte installer; ensure that your network connection is working properly.</value>
</data>
</data>
<data name="FontCommandShortDescription" xml:space="preserve">
<value>Manage fonts</value>
</data>
@@ -3183,4 +3183,10 @@ Please specify one of them using the --source option to proceed.</value>
<data name="FontVersion" xml:space="preserve">
<value>Version</value>
</data>
</root>
<data name="FontInstallCommandShortDescription" xml:space="preserve">
<value>Install a font</value>
</data>
<data name="FontInstallCommandLongDescription" xml:space="preserve">
<value>Installs the selected font package, either found by searching a configured source or directly from a manifest.</value>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -100,6 +100,7 @@ namespace AppInstaller::Manifest
Burn,
MSStore,
Portable,
Font,
};

enum class UpdateBehaviorEnum
1 change: 1 addition & 0 deletions src/AppInstallerSharedLib/Public/AppInstallerErrors.h
Original file line number Diff line number Diff line change
@@ -152,6 +152,7 @@
#define APPINSTALLER_CLI_ERROR_SFSCLIENT_PACKAGE_NOT_SUPPORTED ((HRESULT)0x8A150084)
#define APPINSTALLER_CLI_ERROR_LICENSING_API_FAILED_FORBIDDEN ((HRESULT)0x8A150085)
#define APPINSTALLER_CLI_ERROR_INSTALLER_ZERO_BYTE_FILE ((HRESULT)0x8A150086)
#define APPINSTALLER_CLI_ERROR_FONT_INSTALL_FAILED ((HRESULT)0x8A150087)

// Install errors.
#define APPINSTALLER_CLI_ERROR_INSTALL_PACKAGE_IN_USE ((HRESULT)0x8A150101)
2 changes: 2 additions & 0 deletions src/Microsoft.Management.Deployment/PackageManager.idl
Original file line number Diff line number Diff line change
@@ -467,6 +467,8 @@ namespace Microsoft.Management.Deployment
MSStore,
/// Portable type.
Portable,
/// Font type.
Font,
};

/// The package installer scope.