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
Changes from all commits
3905d30
cb7c48f
5279cec
ca842ff
5320600
0487731
a314fa1
bf924f2
ab9ca6f
d09bc13
cd53091
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>() : ""; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
{ | ||
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; | ||
} | ||
|
||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
please add explanation + example #WontFix There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add logging throughout the project ex. file path #Pending
There was a problem hiding this comment.
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)