Skip to content

Commit

Permalink
add initial flow for installing a font
Browse files Browse the repository at this point in the history
  • Loading branch information
ryfu-msft committed Nov 27, 2024
1 parent 39d132b commit aae3caa
Show file tree
Hide file tree
Showing 18 changed files with 181 additions and 7 deletions.
6 changes: 4 additions & 2 deletions schemas/JSON/manifests/v1.10.0/manifest.installer.1.10.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -80,7 +81,8 @@
"nullsoft",
"wix",
"burn",
"portable"
"portable",
"font"
],
"description": "Enumeration of supported nested installer types contained inside an archive file"
},
Expand Down
6 changes: 4 additions & 2 deletions schemas/JSON/manifests/v1.10.0/manifest.singleton.1.10.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -182,7 +183,8 @@
"nullsoft",
"wix",
"burn",
"portable"
"portable",
"font"
],
"description": "Enumeration of supported nested installer types contained inside an archive file"
},
Expand Down
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -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>
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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" />
Expand Down
49 changes: 49 additions & 0 deletions src/AppInstallerCLICore/Commands/FontCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 18 additions & 0 deletions src/AppInstallerCLICore/Commands/FontCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
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
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Workflows/DownloadFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions src/AppInstallerCLICore/Workflows/FontFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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)
Expand Down Expand Up @@ -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));
}
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Workflows/InstallFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Check failure on line 53 in src/AppInstallerCLICore/Workflows/InstallFlow.h

View workflow job for this annotation

GitHub Actions / Check Spelling

`intsalling` is not a recognized word. (unrecognized-spelling)
// Required Args: None
// Inputs: Installer, InstallerPath, Manifest
// Outputs: None
void FontInstall(Execution::Context& context);
}

// Ensures that there is an applicable installer.
Expand Down
12 changes: 9 additions & 3 deletions src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
1 change: 1 addition & 0 deletions src/AppInstallerCommonCore/Public/winget/ManifestCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace AppInstaller::Manifest
Burn,
MSStore,
Portable,
Font,
};

enum class UpdateBehaviorEnum
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerSharedLib/Public/AppInstallerErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Management.Deployment/PackageManager.idl
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ namespace Microsoft.Management.Deployment
MSStore,
/// Portable type.
Portable,
/// Font type.
Font,
};

/// The package installer scope.
Expand Down

0 comments on commit aae3caa

Please sign in to comment.