cksource / mrgit

A tool for managing projects build using multiple repositories.
49 stars 9 forks source link

Support for presets #151

Closed pomek closed 1 year ago

pomek commented 1 year ago

šŸ“ Provide a description of the new feature

Let's assume the following configuration as input. It uses tags, which we plan to introduce soon.

{
  "packages": "external/",
  "dependencies": {
    "ckeditor5-linters-config": "ckeditor/ckeditor5-linters-config@latest",
    "ckeditor5-dev": "ckeditor/ckeditor5-dev@latest"
  }
}

While bootstrapping the project (mrgit sync), mrgit clones and check-outs dependencies on the latest created tag.

A package published on npm may (but it does not have to) contain the same files as a tag on Github. Fortunately, the packages specified above do.

So, by default, sync will process repositories specified in the #dependencies key.

Presets

Let's assume I'd like to synchronize the entire project depending on events, e.g., when starting TP, preparing a release, etc.

An example configuration.

{
  "packages": "external/",
  "dependencies": {
    "ckeditor5-linters-config": "ckeditor/ckeditor5-linters-config@latest",
    "ckeditor5-dev": "ckeditor/ckeditor5-dev@latest"
  },
  "presets": {
    "dev": {
      "ckeditor5-linters-config": "ckeditor/ckeditor5-linters-config",
      "ckeditor5-dev": "ckeditor/ckeditor5-dev"
    },
    "typedoc": {
      "ckeditor5-dev": "ckeditor/ckeditor5-dev#ck/11721-build-API-from-typedoc"
    }
  }
}

And passing a preset name when using the sync command.

In other words, when the --preset modifier is available, specified dependencies for the given preset are merged with the dependencies values. And preset takes precedence over dependencies.

przemyslaw-zan commented 1 year ago

If user were to execute command mrgit save --preset development with config file as follows:

{
    "packages": "external/",
    "dependencies": {
        "ckeditor5-linters-config": "ckeditor/ckeditor5-linters-config@latest",
        "ckeditor5-dev": "ckeditor/ckeditor5-dev@latest"
    },
    "presets": {
        "development": {
            "ckeditor5-dev": "ckeditor/ckeditor5-dev"
        }
    }
}

What would be expected outcome? I imagine that ckeditor5-dev should have its commit hash saved in the preset/development object. What about the ckeditor5-linters-config though?

  1. Its commit hash is not saved.
  2. Its commit hash gets saved in the dependencies object.
  3. It gets added to the preset/development object and its commit hash gets saved there.

Option 1 would mean that save does not save the exact state of the multirepo. Option 2 would mean that default dependencies and other presets are affected. Because of this, I come to the conclusion that correct behavior there is to add the ckeditor5-linters-config key along with its commit hash to the preset/development object.