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

Package manager #10

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ members = [
"vocab",
"core",
"syntax",
"cli",
"json-schema",
"json-ld-context"
"json-ld-context",
"tldrc",
"manager"
]
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "treeldr-manager"
version = "0.1.0"
authors = ["Spruce Systems Inc."]
description = "TreeLDR package manager"
edition = "2021"

[dependencies]
log = "0.4"
stderrlog = "0.5"
clap = { version = "3.0", features = ["derive"] }

[[bin]]
name = "treeldr"
path = "src/main.rs"
47 changes: 47 additions & 0 deletions manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# TreeLDR package manager

The package manager is in charge of resolving/importing dependencies,
calling the `tldrc` compiler with the correct parameters to generate the
desired targets, and publishing new definitions.

## TreeLDR Package

A package is primarily defined by a base IRI and an RDF dataset defining
new terms relative to this base IRI.
For every RDF quad in the dataset:
- Either the subject, predicate or object **must** be relative to the base IRI.
- The graph **must** be relative to the base IRI.

### Versioning

A package is published on a registry with a *version* strictly following
[Semantic Versioning 2.0.0](https://semver.org/).

A change in the dataset is considered backward compatible iff:
- No quad is removed; and
- The predicate of a newly added quad is **not**
`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`
- The predicate is **not** a property taking at most one value
(declared for instance with `https://schema.org/multipleValues`).

Duplicates are ignored. Implicit quads (derived from the semantics of a term)
are not ignored.
For instance, for every property `p`, the following implicit quad is always
defined:
```n-quads
p <https://schema.org/multipleValues> <https://schema.org/False>
```
unless the following quad is explicitly defined:
```n-quads
p <https://schema.org/multipleValues> <https://schema.org/True>
```
Adding the later would be a breaking change, as it implicitly means removing the
former.

## Registry

Packages are downloaded from a registry, or directly from the source for well known packages such as `https://schema.org`.

## HTTP schemes

Two terms are considered equivalent if every parts of their IRI except for the schemes are equals, and their schemes are either `http` and/or `https`.
15 changes: 15 additions & 0 deletions manager/examples/verite/treeldr.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "my-awesome-treeldr-package"
version = "1.0.0"
description = "Something"

[dependencies]
"https://schema.org" = "14.0"

# Generate a JSON-LD context.
[json-ld-context]
target = "context.jsonld"

# Generate a typescript package.
[typescript]
# Will generate `package.json`, `tsconfig.json`, `src/`
32 changes: 32 additions & 0 deletions manager/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use clap::Parser;

#[derive(Parser)]
#[clap(name="treeldr", author, version, about, long_about = None)]
struct Args {
/// Sets the level of verbosity.
#[clap(short, long = "verbose", parse(from_occurrences))]
verbosity: usize,

#[clap(subcommand)]
command: Command,
}

#[derive(clap::Subcommand)]
pub enum Command {
/// Compile the current package.
Build
}

fn main() {
// Parse options.
let args = Args::parse();

// Init logger.
stderrlog::new().verbosity(args.verbosity).init().unwrap();

match args.command {
Command::Build => {
println!("bye.")
}
}
}
2 changes: 2 additions & 0 deletions tldrc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
Cargo.lock
1 change: 1 addition & 0 deletions tldrc/.rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hard_tabs = true
11 changes: 4 additions & 7 deletions cli/Cargo.toml → tldrc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[package]
name = "treeldr-cli"
name = "tldrc"
version = "0.1.0"
authors = ["Spruce Systems Inc."]
description = "Schema definition language."
description = "TreeLDR compiler"
edition = "2021"
default-run = "tldrc"

[features]
default = ["json-schema", "json-ld-context"]
Expand All @@ -27,8 +28,4 @@ clap = { version = "3.0", features = ["derive"] }

# Extensions.
treeldr-json-schema = { path = "../json-schema", version = "0.1", optional = true }
treeldr-json-ld-context = { path = "../json-ld-context", version = "0.1", optional = true }

[[bin]]
name = "treeldr"
path = "src/main.rs"
treeldr-json-ld-context = { path = "../json-ld-context", version = "0.1", optional = true }
2 changes: 1 addition & 1 deletion cli/src/main.rs → tldrc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use treeldr_syntax as syntax;
mod source;

#[derive(Parser)]
#[clap(name="treeldr", author, version, about, long_about = None)]
#[clap(author, version, about, long_about = None)]
struct Args {
/// Input files.
#[clap(short = 'i', multiple_occurrences = true)]
Expand Down
File renamed without changes.