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

Create vcxproj for yaml-cpp and add manifest helper lib with tests #14

Merged
merged 11 commits into from Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion azure-pipelines.yml
Expand Up @@ -33,7 +33,8 @@ steps:

- task: CmdLine@2
inputs:
script: 'RepositoryLibTests.exe -s -r junit -o TEST-RepositoryLib-$(_artifact).xml'
script: |
RepositoryLibTests.exe -s -r junit -o TEST-RepositoryLib-$(_artifact).xml
workingDirectory: 'src\Release\'

- task: PublishTestResults@2
Expand Down
25 changes: 17 additions & 8 deletions cgmanifest.json
@@ -1,14 +1,23 @@
{
"Registrations":[
{
"component": {
"type": "git",
"git": {
"repositoryUrl": "https://github.com/catchorg/Catch2.git",
"commitHash": "e1c9d5569dc4135babb9c81891d70a8ba8ed938c"
}
}
{
"component": {
"type": "git",
"git": {
"repositoryUrl": "https://github.com/catchorg/Catch2.git",
"commitHash": "e1c9d5569dc4135babb9c81891d70a8ba8ed938c"
}
}
},
{
"component": {
"type": "git",
"git": {
"repositoryUrl": "https://github.com/jbeder/yaml-cpp.git",
"commitHash": "9a3624205e8774953ef18f57067b3426c1c5ada6"
}
}
}
],
"Version": 1
}
6 changes: 6 additions & 0 deletions src/AppInstallerCLI/AppInstallerCLI.vcxproj
Expand Up @@ -167,9 +167,15 @@
<Project>{1c6e0108-2860-4b17-9f7e-fa5c6c1f3d3d}</Project>
<Private>false</Private>
</ProjectReference>
<ProjectReference Include="..\PackageManifestHelper\PackageManifestHelper.vcxproj">
<Project>{f8f75341-9455-4d5b-824a-47a7818ee864}</Project>
</ProjectReference>
<ProjectReference Include="..\RepositoryLib\RepositoryLib.vcxproj">
<Project>{5eb88068-5fb9-4e69-89b2-72dbc5e068f9}</Project>
</ProjectReference>
<ProjectReference Include="..\YamlCppLib\YamlCppLib.vcxproj">
<Project>{8bb94bb8-374f-4294-bca1-c7811514a6b7}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
40 changes: 40 additions & 0 deletions src/AppInstallerClient.sln
Expand Up @@ -25,6 +25,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{63D9DA93
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RepositoryLibTests", "RepositoryLibTests\RepositoryLibTests.vcxproj", "{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "YamlCppLib", "YamlCppLib\YamlCppLib.vcxproj", "{8BB94BB8-374F-4294-BCA1-C7811514A6B7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PackageManifestHelper", "PackageManifestHelper\PackageManifestHelper.vcxproj", "{F8F75341-9455-4D5B-824A-47A7818EE864}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Telemetry\Telemetry.vcxitems*{1c6e0108-2860-4b17-9f7e-fa5c6c1f3d3d}*SharedItemsImports = 4
Expand Down Expand Up @@ -144,6 +148,42 @@ Global
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|x64.Build.0 = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|x86.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|x86.Build.0 = Release|Win32
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Debug|Any CPU.ActiveCfg = Debug|Win32
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Debug|ARM.ActiveCfg = Debug|ARM
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Debug|ARM.Build.0 = Debug|ARM
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Debug|ARM64.ActiveCfg = Debug|ARM64
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Debug|ARM64.Build.0 = Debug|ARM64
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Debug|x64.ActiveCfg = Debug|x64
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Debug|x64.Build.0 = Debug|x64
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Debug|x86.ActiveCfg = Debug|Win32
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Debug|x86.Build.0 = Debug|Win32
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Release|Any CPU.ActiveCfg = Release|Win32
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Release|ARM.ActiveCfg = Release|ARM
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Release|ARM.Build.0 = Release|ARM
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Release|ARM64.ActiveCfg = Release|ARM64
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Release|ARM64.Build.0 = Release|ARM64
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Release|x64.ActiveCfg = Release|x64
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Release|x64.Build.0 = Release|x64
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Release|x86.ActiveCfg = Release|Win32
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Release|x86.Build.0 = Release|Win32
{F8F75341-9455-4D5B-824A-47A7818EE864}.Debug|Any CPU.ActiveCfg = Debug|Win32
{F8F75341-9455-4D5B-824A-47A7818EE864}.Debug|ARM.ActiveCfg = Debug|ARM
{F8F75341-9455-4D5B-824A-47A7818EE864}.Debug|ARM.Build.0 = Debug|ARM
{F8F75341-9455-4D5B-824A-47A7818EE864}.Debug|ARM64.ActiveCfg = Debug|ARM64
{F8F75341-9455-4D5B-824A-47A7818EE864}.Debug|ARM64.Build.0 = Debug|ARM64
{F8F75341-9455-4D5B-824A-47A7818EE864}.Debug|x64.ActiveCfg = Debug|x64
{F8F75341-9455-4D5B-824A-47A7818EE864}.Debug|x64.Build.0 = Debug|x64
{F8F75341-9455-4D5B-824A-47A7818EE864}.Debug|x86.ActiveCfg = Debug|Win32
{F8F75341-9455-4D5B-824A-47A7818EE864}.Debug|x86.Build.0 = Debug|Win32
{F8F75341-9455-4D5B-824A-47A7818EE864}.Release|Any CPU.ActiveCfg = Release|Win32
{F8F75341-9455-4D5B-824A-47A7818EE864}.Release|ARM.ActiveCfg = Release|ARM
{F8F75341-9455-4D5B-824A-47A7818EE864}.Release|ARM.Build.0 = Release|ARM
{F8F75341-9455-4D5B-824A-47A7818EE864}.Release|ARM64.ActiveCfg = Release|ARM64
{F8F75341-9455-4D5B-824A-47A7818EE864}.Release|ARM64.Build.0 = Release|ARM64
{F8F75341-9455-4D5B-824A-47A7818EE864}.Release|x64.ActiveCfg = Release|x64
{F8F75341-9455-4D5B-824A-47A7818EE864}.Release|x64.Build.0 = Release|x64
{F8F75341-9455-4D5B-824A-47A7818EE864}.Release|x86.ActiveCfg = Release|Win32
{F8F75341-9455-4D5B-824A-47A7818EE864}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
15 changes: 15 additions & 0 deletions src/PackageManifestHelper/InstallerSwitches.cpp
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include "pch.h"
#include "InstallerSwitches.h"

namespace AppInstaller::Manifest
{
void InstallerSwitches::PopulateSwitchesFields(YAML::Node switchesNode)
{
this->Default = switchesNode["Default"] ? switchesNode["Default"].as<std::string>() : "";
this->Silent = switchesNode["Silent"] ? switchesNode["Silent"].as<std::string>() : "";
this->Verbose = switchesNode["Verbose"] ? switchesNode["Verbose"].as<std::string>() : "";
}
}
19 changes: 19 additions & 0 deletions src/PackageManifestHelper/InstallerSwitches.h
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#pragma once
#include <string>
namespace AppInstaller::Manifest
{
class InstallerSwitches
{
public:
std::string Default;

std::string Silent;

std::string Verbose;

void PopulateSwitchesFields(YAML::Node switchesNode);
};
}
92 changes: 92 additions & 0 deletions src/PackageManifestHelper/Manifest.cpp
@@ -0,0 +1,92 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include "pch.h"
#include "framework.h"
#include "Manifest.h"

namespace AppInstaller::Manifest
{
void Manifest::PopulateManifestFields(const YAML::Node& rootNode)
{
// Required fields
this->Id = rootNode["Id"].as<std::string>();
this->Name = rootNode["Name"].as<std::string>();
this->Version = rootNode["Version"].as<std::string>();

// Optional fields.
this->ShortId = rootNode["ShortId"] ? rootNode["ShortId"].as<std::string>() : "";
this->CompanyName = rootNode["CompanyName"] ? rootNode["CompanyName"].as<std::string>() : "";
this->Authors = rootNode["Authors"] ? rootNode["Authors"].as<std::string>() : "";
this->Channel = rootNode["Channel"] ? rootNode["Channel"].as<std::string>() : "";
this->Author = rootNode["Author"] ? rootNode["Author"].as<std::string>() : "";
this->License = rootNode["License"] ? rootNode["License"].as<std::string>() : "";
this->MinOSVersion = rootNode["MinOSVersion"] ? rootNode["MinOSVersion"].as<std::string>() : "";
this->Tags = rootNode["Tags"] ? rootNode["Tags"].as<std::string>() : "";
this->Commands = rootNode["Commands"] ? rootNode["Commands"].as<std::string>() : "";
this->Protocols = rootNode["Protocols"] ? rootNode["Protocols"].as<std::string>() : "";
this->FileExtensions = rootNode["FileExtensions"] ? rootNode["FileExtensions"].as<std::string>() : "";
this->InstallerType = rootNode["InstallerType"] ? rootNode["InstallerType"].as<std::string>() : "";
this->Description = rootNode["Description"] ? rootNode["Description"].as<std::string>() : "";
this->Homepage = rootNode["Homepage"] ? rootNode["Homepage"].as<std::string>() : "";
this->LicenseUrl = rootNode["LicenseUrl"] ? rootNode["LicenseUrl"].as<std::string>() : "";

YAML::Node installersNode = rootNode["Installers"];
for (std::size_t i = 0; i < installersNode.size(); i++) {
YAML::Node installerNode = installersNode[i];
ManifestInstaller installer;
installer.PopulateInstallerFields(installerNode);
this->Installers.emplace_back(std::move(installer));
}

if (rootNode["Localization"])
{
YAML::Node localizationsNode = rootNode["Localization"];
for (std::size_t i = 0; i < localizationsNode.size(); i++) {
YAML::Node localizationNode = localizationsNode[i];
ManifestLocalization localization;
localization.PopulateLocalizationFields(localizationNode);
this->Localization.emplace_back(std::move(localization));
}
}

if (rootNode["Switches"])
{
YAML::Node switchesNode = rootNode["Switches"];
InstallerSwitches switches;
switches.PopulateSwitchesFields(switchesNode);
this->Switches.emplace(std::move(switches));
}
}

Manifest Manifest::CreatePackageManifestFromFile(const std::string& inputFile)
{
Copy link
Contributor

@ranm-msft ranm-msft Dec 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ [](start = 4, length = 1)

Add logging throughout the project ex. file path #Pending

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently only tracelogging is enabled. we'll add a logger wrapper and log in a following PR


In reply to: 360160037 [](ancestors = 360160037)

YAML::Node rootNode = YAML::LoadFile(inputFile);

Manifest manifest;
manifest.PopulateManifestFields(rootNode);

return manifest;
}

Manifest Manifest::CreatePackageManifest(const std::string& input)
{
Manifest manifest;

try
{
YAML::Node rootNode = YAML::Load(input);
manifest.PopulateManifestFields(rootNode);
}
catch (std::exception & e)
{
// Log theinput string when read manifest failure
throw;
}

return manifest;
}


}

73 changes: 73 additions & 0 deletions src/PackageManifestHelper/Manifest.h
@@ -0,0 +1,73 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#pragma once
#include <string>
#include <vector>
#include <optional>
#include "ManifestInstaller.h"
#include "ManifestLocalization.h"

namespace AppInstaller::Manifest
{
class Manifest
{
public:
// Required
std::string Id;

// Required
std::string Name;

// Required
std::string Version;

// Name subject to change
std::string ShortId;
Copy link
Contributor

@ranm-msft ranm-msft Dec 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShortId [](start = 20, length = 7)

please add explanation + example #WontFix

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the location for that kind of documentation.


In reply to: 360142170 [](ancestors = 360142170)


std::string CompanyName;

// Comma separated Values
std::string Authors;

std::string Channel;

std::string Author;

std::string License;

std::string MinOSVersion;

// Comma separated values
std::string Tags;

// Comma separated values
std::string Commands;

// Comma separated values
std::string Protocols;

// Comma separated values
std::string FileExtensions;

std::vector<ManifestInstaller> Installers;

std::vector<ManifestLocalization> Localization;

std::string InstallerType;

std::optional<InstallerSwitches> Switches;

std::string Description;

std::string Homepage;

std::string LicenseUrl;

void PopulateManifestFields(const YAML::Node& rootNode);

static Manifest CreatePackageManifestFromFile(const std::string& inputFile);

static Manifest CreatePackageManifest(const std::string& input);
};
}
29 changes: 29 additions & 0 deletions src/PackageManifestHelper/ManifestInstaller.cpp
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include "pch.h"
#include "ManifestInstaller.h"

namespace AppInstaller::Manifest
{
void ManifestInstaller::PopulateInstallerFields(YAML::Node installerNode)
{
// Required fields
this->Arch = installerNode["Arch"].as<std::string>();
this->Url = installerNode["Url"].as<std::string>();
this->Sha256 = installerNode["Sha256"].as<std::string>();

// Optional fields.
this->Language = installerNode["Language"] ? installerNode["Language"].as<std::string>() : "";
this->Scope = installerNode["Scope"] ? installerNode["Scope"].as<std::string>() : "";
this->InstallerType = installerNode["InstallerType"] ? installerNode["InstallerType"].as<std::string>() : "";

if (installerNode["Switches"])
{
YAML::Node switchesNode = installerNode["Switches"];
InstallerSwitches switches;
switches.PopulateSwitchesFields(switchesNode);
this->Switches.emplace(std::move(switches));
}
}
}
37 changes: 37 additions & 0 deletions src/PackageManifestHelper/ManifestInstaller.h
@@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#pragma once
#include <string>
#include <optional>
#include "InstallerSwitches.h"

namespace AppInstaller::Manifest
{
class ManifestInstaller
{
public:
// Required. Values: x86, x64, arm, arm64, all.
std::string Arch;

// Required
std::string Url;

// Required
std::string Sha256;

// Empty means default
std::string Language;

// Name TBD
std::string Scope;

// If present, has more presedence than root
std::string InstallerType;

// If present, has more presedence than root
std::optional<InstallerSwitches> Switches;

void PopulateInstallerFields(YAML::Node installerNode);
};
}