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

@@ -71,9 +71,9 @@ TEST_CASE_METHOD(catalog_test_case, "Parse JSON repo") {
"packages": {
"foo": {
"1.2.3": {
"depends": {
"bar": "~4.2.1"
},
"depends": [
"bar~4.2.1"
],
"git": {
"url": "http://example.com",
"ref": "master"

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

@@ -89,18 +89,13 @@ parse_pkg_json_v1(std::string_view name, semver::version version, const json5::d

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 {
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());
}
};
auto make_dep = [&](auto&&) {
return dependency{dep_name, {dep_range.low(), dep_range.high()}};
};

auto check_one_remote = [&](auto&&) {
if (!semester::holds_alternative<std::monostate>(ret.remote)) {
@@ -109,18 +104,14 @@ parse_pkg_json_v1(std::string_view name, semver::version version, const json5::d
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,
mapping{if_key{"description",
require_str{"'description' should be a string"},
put_into{ret.description}},
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{
"git",
check_one_remote,

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

@@ -18,7 +18,7 @@ def test_import_json(dds: DDS):
'url': 'http://example.com',
'ref': 'master',
},
'depends': {},
'depends': [],
},
'1.2.5': {
'git': {

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

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

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

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

Loading…
Cancel
Save