Browse Source

Catalog JSON now requried a 'depends' as an array

default_compile_flags
vector-of-bool 4 years ago
parent
commit
a3ed414db8
5 changed files with 12 additions and 21 deletions
  1. +3
    -3
      src/dds/catalog/catalog.test.cpp
  2. +6
    -15
      src/dds/catalog/import.cpp
  3. +1
    -1
      tests/catalog/import_test.py
  4. +1
    -1
      tests/deps/use-remote/catalog.json
  5. +1
    -1
      tests/deps/use-spdlog/project/catalog.json

+ 3
- 3
src/dds/catalog/catalog.test.cpp View File

"packages": { "packages": {
"foo": { "foo": {
"1.2.3": { "1.2.3": {
"depends": {
"bar": "~4.2.1"
},
"depends": [
"bar~4.2.1"
],
"git": { "git": {
"url": "http://example.com", "url": "http://example.com",
"ref": "master" "ref": "master"

+ 6
- 15
src/dds/catalog/import.cpp View File



using namespace semester::walk_ops; using namespace semester::walk_ops;


std::string dep_name;
auto dep_range = semver::range::everything();
auto parse_dep_range = [&](const std::string& s) {
auto make_dep = [&](std::string const& str) {
try { try {
return semver::range::parse_restricted(s);
} catch (const semver::invalid_range& e) {
return dependency::parse_depends_string(str);
} catch (std::runtime_error const& e) {
import_error(std::string(walk.path()) + e.what()); import_error(std::string(walk.path()) + e.what());
} }
}; };
auto make_dep = [&](auto&&) {
return dependency{dep_name, {dep_range.low(), dep_range.high()}};
};


auto check_one_remote = [&](auto&&) { auto check_one_remote = [&](auto&&) {
if (!semester::holds_alternative<std::monostate>(ret.remote)) { if (!semester::holds_alternative<std::monostate>(ret.remote)) {
return walk.pass; return walk.pass;
}; };


auto add_dep = any_key{put_into(dep_name),
require_str{"Dependency should specify a version range string"},
put_into_pass{dep_range, parse_dep_range},
put_into{std::back_inserter(ret.deps), make_dep}};

walk(data, walk(data,
mapping{if_key{"description", mapping{if_key{"description",
require_str{"'description' should be a string"}, require_str{"'description' should be a string"},
put_into{ret.description}}, put_into{ret.description}},
if_key{"depends", if_key{"depends",
require_obj{"'depends' must be a JSON object"},
mapping{add_dep}},
require_array{"'depends' must be an array of dependency strings"},
for_each{require_str{"Each dependency should be a string"},
put_into{std::back_inserter(ret.deps), make_dep}}},
if_key{ if_key{
"git", "git",
check_one_remote, check_one_remote,

+ 1
- 1
tests/catalog/import_test.py View File

'url': 'http://example.com', 'url': 'http://example.com',
'ref': 'master', 'ref': 'master',
}, },
'depends': {},
'depends': [],
}, },
'1.2.5': { '1.2.5': {
'git': { 'git': {

+ 1
- 1
tests/deps/use-remote/catalog.json View File

"url": "https://github.com/vector-of-bool/json.git", "url": "https://github.com/vector-of-bool/json.git",
"ref": "dds/3.7.1" "ref": "dds/3.7.1"
}, },
"depends": {}
"depends": []
} }
} }
} }

+ 1
- 1
tests/deps/use-spdlog/project/catalog.json View File

"ref": "v1.4.2", "ref": "v1.4.2",
"auto-lib": "spdlog/spdlog" "auto-lib": "spdlog/spdlog"
}, },
"depends": {}
"depends": []
} }
} }
} }

Loading…
Cancel
Save