Coder Social home page Coder Social logo

mob-sakai / upmgitextension Goto Github PK

View Code? Open in Web Editor NEW
762.0 762.0 78.0 711 KB

This package extends the UI of Unity Package Manager (UPM) for the packages installed from git repository.

License: MIT License

C# 91.26% JavaScript 8.74%
bitbucket editor extension git github package package-manager unity unity3d upm

upmgitextension's Introduction

UPM Git Extension

This package enhances the user interface (UI) of the Unity Package Manager (UPM) specifically for packages installed from a git repository.


PRs Welcome

<< ๐Ÿ“ Description | โš™ Installation | ๐Ÿš€ Usage | ๐Ÿ›  Development Note | ๐Ÿค Contributing >>

๐Ÿ“ Description

In Unity 2018.3, the Unity Package Manager (UPM) introduced Git support, providing a convenient way to install packages from code hosting services such as GitHub. However, certain limitations and shortcomings were identified, including:

  • Incorrect links to documents (readme, changelog, license)
  • Lack of a direct link to the repository URL
  • Limited functionality for adding, updating, and removing packages through the UI

This project addresses these issues by extending the UI of the Unity Package Manager for packages installed using Git.

Features

  • Direct link to the Git repository URL
  • Links to offline documents, including:
    • Documentations
    • Changelog
    • License
  • Support for various Git hosting platforms such as GitHub, GitLab, Bitbucket, Azure DevOps, etc.
  • Installation of packages from Git repository URLs using the UI
  • Updating packages with a specific tag/branch
  • Removing packages
  • Compatibility with Unity 2018.3 or later
  • Support for .Net 3.5, .Net 4.x, and .Net Standard 2.0
  • Version filtering
  • Support for path query parameters (for Unity 2019.3.4f or later)
  • (Version 2.0.0) Git repositories are cached, and installed/searched packages are automatically indexed:
    • Cached repositories are shared between different projects
    • Cached repository URLs are displayed as history in the installation window
    • Indexed packages are shown in My Registries
  • (Version 2.0.0) Additional menu options to open manifest.json with a code editor, open the cache directory, clear the cache, and fetch packages:



โš™ Installation

This package requires as following:

  • v1.x: Unity 2018.3 to 2019.4
  • v2.x: Unity 2020.1 or later

Install via OpenUPM

This package is available on OpenUPM package registry. This is the preferred method of installation, as you can easily receive updates as they're released.

If you have openupm-cli installed, then run the following command in your project's directory:

# for Unity 2020 or later
openupm add com.coffee.upm-git-extension
# for Unity 2018 or 2019
openupm add com.coffee.upm-git-extension@v1 

Install via UPM (using Git URL)

Navigate to your project's Packages folder and open the manifest.json file. Then add this package somewhere in the dependencies block:

{
  "dependencies": {
    // for Unity 2020 or later
    "com.coffee.upm-git-extension": "https://github.com/mob-sakai/UpmGitExtension.git",
    // for Unity 2018 or 2019
    "com.coffee.upm-git-extension": "https://github.com/mob-sakai/UpmGitExtension.git#v1",
    ...
  },
}

To update the package, change suffix #{version} to the target version.

  • e.g. "com.coffee.upm-git-extension": "https://github.com/mob-sakai/UpmGitExtension.git#2.1.0",



๐Ÿš€ Usage

Install a Package from a Git Repository

Click giticon button in the package manager UI to open the Install Package Window.

  1. Input a git repository URL and click the Find Versions button. In Unity 2019.3.4 or later, you can specify a subdirectory.

  2. Select a tag or branch and click the Find Package button.

  3. Wait a few seconds for validation.

  4. Click the Install Package button to install the package.

Update Package with a Specific Tag or Branch as Version

You can update or remove the package in your project, just as you would for official packages.



๐Ÿ›  Development Note

Develop a package for UPM

See https://www.patreon.com/posts/25070968, https://www.jianshu.com/u/275cca6e5f17 (Chinese)



๐Ÿค Contributing

Issues

Issues are incredibly valuable to this project:

  • Ideas provide a valuable source of contributions that others can make.
  • Problems help identify areas where this project needs improvement.
  • Questions indicate where contributors can enhance the user experience.

Pull Requests

Pull requests offer a fantastic way to contribute your ideas to this repository.
Please refer to CONTRIBUTING.md and develop branch for guidelines.

Support

This is an open-source project developed during my spare time.
If you appreciate it, consider supporting me.
Your support allows me to dedicate more time to development. ๐Ÿ˜Š




License

  • MIT

Author

See Also

upmgitextension's People

Contributors

andrewcarvalho avatar chikacc avatar github-actions[bot] avatar jzapdot avatar laicasaane avatar mob-sakai avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

upmgitextension's Issues

Support GitLab.com

Love the work you are doing, keep it up ๐Ÿ‘
It is possible to add support for GitLab, both private and public repos, that would be cool?

Support .Net 3.5 scripting runtime version

Hi,

Trying out this extension using Unity version 2018.3.10f1. Initially grabbed 0.7.0 (as per docs). Selecting the UPM Git Extension (or one of our own custom packages) in the Package Manager window and we get an error in console at Settings.cs line 34.

If I downgrade to version 0.6.1 or lower this error goes away and everything seems fine.

Thanks!
Ricky

A workflow without subtree split

What if we used a config JSON at the root of the repository that contained the path to the package.json file, so that we no longer need it to be at the root of the repository?

Then after cloning, we can simply use the folder containing the package.json as the UPM package.

This way we wouldn't need to maintain a separate branch just for UPM releases.

What do you think? Is this feasible, or even possible?

Unable to add more than one package from url on Windows

When I try to add a package from url when Temp/UpmGit directory already exists the following error appears in the logs:

UnauthorizedAccessException: Access to the path "Temp/UpmGit\.git\objects\0c\169d26343a6ab4309c918fa4dd5821ac5f2579" is denied.

This can be fixed by replacing:

if (Directory.Exists (kPath))
  Directory.Delete (kPath, true);

To:

DirectoryUtils.DeleteDirectory(kPath);

Line 62 Utils.cs (GitUtils.GetPackageJson)

Source code of DirectoryUtils:

internal static class DirectoryUtils
{
	public static void DeleteDirectory(string directoryPath)
	{
		if (!Directory.Exists(directoryPath))
			return;

		NormalizeAttributes(directoryPath);
		Directory.Delete(directoryPath, true);
	}

	private static void NormalizeAttributes(string directoryPath)
	{
		string[] filePaths = Directory.GetFiles(directoryPath);
		string[] subdirectoryPaths = Directory.GetDirectories(directoryPath);

		foreach (string filePath in filePaths)
		{
			File.SetAttributes(filePath, FileAttributes.Normal);
		}
		foreach (string subdirectoryPath in subdirectoryPaths)
		{
			NormalizeAttributes(subdirectoryPath);
		}
		File.SetAttributes(directoryPath, FileAttributes.Normal);
	}
}

Add support for installing packages in repository subdirectories

e.g.

{
  "dependencies": {
    "com.example.package": "https://github.com/example/package.git#1.0.0/Example Package/Packages/com.example.package"
  }
}

This is useful for developing a package in a project repository and not having to move the package to the root for release, especially for those bitten by the organization bug, like me.

Repository Index

For me what's missing is some kind of repository index. Either it could be part of the manifest.json or an additional JSON-file with content like:
{ "repositories": [ "https://github.com/a/b.git", "https://github.com/a/c.git", "https://github.com/a/d.git", "https://github.com/a/e.git", "https://github.com/a/f.git", "https://github.com/a/g.git" ], "updateURL": "https://mycompany.com/unity/package-repositories.json" }

After adding the repositories to the index, the packages in those git repositories should not be installed, but displayed in the package manager as installable.
Additionally it would be nice if this json file could be loaded from an URL (ex. https://mycompany.com/unity/package-repositories.json). As this URL is also in the json file itself as "updateURL", your extension can update this JSON file automatically. This would be awesome for big companies so that all employees can see all available packages without doing anything manually.
When saved in the EditorPrefs, this information could be used accross multiple Unity projects.

FindVersion button does not update version

Clicking FindVersion button does not not update version.
Maybe cache.

Steps

  1. push package to repo
  2. in another project open add git package window
  3. enter repository url and click "find version"
  4. understand that forget to add or push tag
  5. push tag
  6. click "find version" to update version dropdown
  7. version dropdown is not updating

Windows 7 SP1
Unity 20191.10f1
v0.9.1
I'm using gitlab ce

Unit Tests don't pass

Please update unit tests :)

I would like to contribute but I wanna make sure I don't break anything.
image

Broken on 2019.1's new PM

2019.1 is still in beta but they've changed the PM structure making this extension to not work properly there.

Just giving a heads up about it.

Error on 'git ls-remote' for private repos accessed via SSH

Hi,
My private repo is only meant to be accessed via an ssh url. Adding the package by URL in the editor works fine, but I get this error whenever I click the package in the editor:

Screen Shot 2019-05-10 at 11 11 01 AM

Typing the same command in my terminal yields the same results. However, the command seems to work when I replace "https" with "ssh".

Screen Shot 2019-05-10 at 11 17 14 AM

Is it possible for this command to use ssh when the repo url uses ssh instead of https?

Thanks!

Does not support custom port for ssh

I use port 22100 and it works fine when fetching branches, but when I click install

ssh://[email protected]:22100/npm/simple-packages.git

Error when executing git command. ssh: connect to host my.gitlab.com port 22: Connection refused
fatal: Could not read from remote repository.

Support 2019.3

Currently, in 2019.3, nothing in the package works and the following error occurs upon selecting any package:

Package manager extension failed with error: Object reference not set to an instance of an object
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

If only they had a stack trace...

Although it does seem that this project has been abandoned.

Strange with version and update

image
It show this library has update - but not.

Have no idea how it possible. Maybe after adding my package via your plugin.

Windows 7 SP1
Unity 20191.10f1
v0.9.1

Could we have option for local clone?

In the scenario that we want to develop package while also make it work directly in other project. I think UPMgit should have an option to actually cloning the git repo into some local folder and add the local path to UPM instead of PackageCache folder

Is it possible?

Can you detail how you create the upm subtree branch

I'm not very familiar with subtrees, and with what I've been reading about them, it's not very clear to me how to properly setup the branch. I was curious if you could add some details to that section for how to best set it up?

Thanks!

Unable to add package from url on Windows

When I try to add any package from url, for example, https://github.com/mob-sakai/GitPackageTest.git after selecting a branch the following error appears in the logs:

Error: git clone --depth=1 --branch 0.5.0
 --single-branch https://github.com/mob-sakai/GitPackageTest.git Temp/UpmGit

Cloning into 'Temp/UpmGit'...
warning: Could not find remote branch 0.5.0? to clone.
fatal: Remote branch 0.5.0? not found in upstream origin

This can be fixed by replacing:

result.Add (m.Groups [2].Value);

To:

result.Add (m.Groups [2].Value.Trim());

Line 52 Utils.cs (GitUtils.GetRefs)

Support git dependency in the package

ref #29
Import from: https://github.com/mob-sakai/GitDependencyResolverForUnity

This plugin resolves git url dependencies in the package for Unity Package Manager.
You can use a git url as a package dependency as following:

[ package-a/package.json ]
{
  "name": "com.coffee.package-a",
  "version": "0.1.0",
  "dependencies": {
    "com.coffee.core-a" : "https://github.com/mob-sakai/GitPackageTest#core-a-0.1.0"
  }
}

Please note the risk you are taking when using this package:
https://forum.unity.com/threads/git-support-on-package-manager.573673/page-3#post-4552084

Tag filtering

See: modesttree/Zenject#24 (comment)

How about implementing a tag filtering system, so that, for example, the tags intended to be used by UPM have a specific prefix such as "upm-9.0.0"?

The UpmGitExtension will only show the tags that have this specific prefix. This way, we can have the option of continuing to use git tags freely without them interfering with the UPM release tags.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.