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

Future plans #1

Open
ozh opened this issue Jun 10, 2020 · 4 comments
Open

Future plans #1

ozh opened this issue Jun 10, 2020 · 4 comments

Comments

@ozh
Copy link
Member

ozh commented Jun 10, 2020

Use this in YOURLS core along with wikimedia/composer-merge-plugin

YOURLS' composer.json would be added this:

    "extra": {
        "merge-plugin": {
            "include": ["user/composer.json"]
        }
    },

Adding a plugin would be done either with:

  • editing user/composer.json, or composer require -d user ozh/example-plugin --no-update
  • then running composer update --lock

Then the idea would be to have a shortcut for this with a custom command
Something like:

    "scripts": {
        "add-plugin": "bash ./includes/somewhere/add-plugin"
    }

With add-plugin being a script like

# do some checks on  $@ and make sure we have a 'vendor/package' argument
# display some help, etc ...

# check if composer is in path
if ! command -v composer > /dev/null ; then
    echo "composer not in path, do this:"
    echo "composer require -d user $1 --no-update"
    echo "composer update --lock"
    exit 1
fi

# all right, go
composer require -d user $1 --no-update
composer update --lock
@ozh
Copy link
Member Author

ozh commented Jun 12, 2020

Or, probably better than a bash script, a custom PHP command -- https://getcomposer.org/doc/articles/plugins.md#command-provider

@ozh
Copy link
Member Author

ozh commented Jun 12, 2020

composer add-plugin custom command done :) That was interesting :)

@ozh
Copy link
Member Author

ozh commented Jun 13, 2020

Hmmm, not there yet, the custom command isn't a sane idea after all.

What I need to achieve is that the user simply composer require my/plugin and the installer takes care of everything, no need to specify -d or to update stuff.

@ozh
Copy link
Member Author

ozh commented Jun 14, 2020

So. The custom command is a sane idea after all.

  • composer require my/package : add to root composer.json
  • composer add-plugin my/package : add to user/composer.json
  • composer remove-plugin my/package
    These 2 commands work with a YOURLS plugin or any package, and will install in the appropriate location (/user/plugins or /includes/vendor)

Now to write unit tests

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

No branches or pull requests

1 participant