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

RFC - Package Management #6

Closed
wants to merge 1 commit into from
Closed

Conversation

Nitemaeric
Copy link
Owner

@Nitemaeric Nitemaeric commented Oct 19, 2024

This PR is the first stepping stone for CLI-driven package management for DragonRuby.

The tool will allow developers to pull in code from GitHub (and likely other git repository hosts later once the need arises) to their local code.

As of now, I don't see any need for drenv to enforce any kind of conventions on the libraries themselves, no need for a local drenv.json or specific file structure.

The CLI will pull in the repository's code to lib/<repo>.

I plan to introduce drenv.json and generated drenv.lock files for managing dependencies.

New commands

The CLI should support the following commands:

  • drenv add ...<user/repo>[@<branch|tag|SHA>]

    Adds a dependency to your DR project - Will download the code from the remote into your source code.

    e.g.

    • Add multiple libraries:

      $ drenv add danhealy/dragonruby-zif:lib pvande/dragonborn:dragonborn.rb
    • Add a specific version of a library:

      $ drenv add danhealy/[email protected]:lib
  • drenv remove ...<user/repo>

    Removes a dependency from your DR project - Will also remove the code.

    e.g.

    $ drenv remove danhealy/dragonruby-zif # project path is not required for removal.
  • drenv outdated

    Output the list of dependencies that have been updated since installation.

    e.g.

    $ drenv outdated
    
    | package                 | commits behind | latest commit at  |
    | ----------------------- | -------------: | ----------------- |
    | danhealy/dragonruby-zif |              9 | 20 Jan 2024 12:34 |

The drenv.json file should look like this:

{
  "dependencies": {
    "danhealy/dragonruby-zif": "danhealy/[email protected]:lib",
    "pvande/dragonborn": "pvande/dragonborn",
  }
}

A lock file should be used to ensure changing the dependencies doesn't overwrite anything unintentionally.

{
  "dependencies": {
    "danhealy/dragonruby-zif": {
      "url": "https://github.com/danhealy/dragonruby-zif.git",
      "sha": "9a0c4425fab4d0c93e9a7beece5510217edb8d17"
    },
    "pvande/dragonborn": {
      "url": "https://github.com/pvande/dragonborn.git",
      "sha": "8f04446a1dd4b190c0fbb9e2a1414c4196775385"
    }
  }
}

Technical implementation notes

  • Get information about a commit.

    https://api.github.com/repos/<user>/<repo>/commits/<SHA>

  • Find out how many commits behind a commit is

    https://api.github.com/repos/<user>/<repo>/compare/<SHA>...<SHA>

The SHA is saved to the lock file upon calling drenv install.

Considerations

  • Is the tool doing too much? Does it make more sense to split package management out from version management?
  • Should dependencies have a dedicated directory within mygame? dragonruby_modules, mirroring node_modules? Should it just be vendor?

@Nitemaeric
Copy link
Owner Author

Closed in favour of #9.

@Nitemaeric Nitemaeric closed this Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant