diff --git a/README.md b/README.md index f3e02a56e5216c62b1d88c7a14764c7455cbc0ae..b91319bad013042a4616ade6567abbe2df965a6e 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,76 @@ REQUIREMENTS INSTALLATION ------------ -1. Download and extract the clipboard.js plugin, rename extracted folder to - "clipboard" and copy it into "sites/all/libraries". The plugin should - now be located at "sites/all/libraries/clipboard.js/dist/clipboard.js". You can - also just use 'drush cbdl' to automatically download the library. + +**MANUAL** + +Download and extract the clipboard.js plugin, rename extracted folder to +"clipboard.js" and copy it into "web/libraries". The plugin should +now be located at "web/libraries/clipboard.js/dist/clipboard.js". + +**INSTALLATION VIA COMPOSER** + +It is assumed you are installing Drupal through Composer using the Drupal +Composer facade. See https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies#drupal-packagist + +The Clipboard.js Drupal module is shipped with a "composer.libraries.json" file +contains information about the clipboard.js library, required by the module itself. + +This file should be merged with the project's main composer.json by the aid +of the Composer Merge Plugin plugin available on GitHub. To make use of +from the project directory, open a terminal and run: + +``` +composer require wikimedia/composer-merge-plugin +``` + +Then, edit the "composer.json" file of your website and under the "extra" +section add: + +``` +"merge-plugin": { + "include": [ + "web/modules/contrib/clipboardjs/composer.libraries.json" + ] +} +``` + +(*) note: the `web` represents the folder where drupal lives like: ex. +`docroot`. + +From now on, every time the "composer.json" file is updated, it will also +read the content of "composer.libraries.json" file located at +web/modules/contrib/clipboardjs/ and update accordingly. + +Remember, you may have other entries in there already. For this to work, you +need to have the 'oomphinc/composer-installers-extender' installer. If you +don't have it, or are not sure, simply run: + +``` +composer require oomphinc/composer-installers-extender +``` + +Then, run the following composer command: + +``` +composer require drupal/clipboardjs +``` + +This command will add the clipboardjs Drupal module and the clipboard.js JavaScript library to your +project. + +**INSTALLATION VIA DRUSH** + +A Drush command is provided for easy installation of the clipboard.js library. + +``` +drush cbd +``` + +The command will download the library and unpack it in "libraries". + +If you are using Composer to manage your site's dependencies, +then the clipboard.js library will automatically be downloaded to `web/libraries/clipboard.js`. USAGE ----- diff --git a/clipboardjs.libraries.yml b/clipboardjs.libraries.yml index d336d1df7aabb08cb57cbdd3ac7f4253db5e94c2..f715d1cdcb06dbf60925787b50db28742a8be803 100644 --- a/clipboardjs.libraries.yml +++ b/clipboardjs.libraries.yml @@ -1,6 +1,6 @@ clipboardjs: remote: https://github.com/zenorocha/clipboard.js/ - version: "2.0.10" + version: "v2.0.11" license: name: MIT url: https://zenorocha.mit-license.org/ diff --git a/composer.libraries.json b/composer.libraries.json new file mode 100644 index 0000000000000000000000000000000000000000..7b977cdd056a7c5fadb0cc23cacd3f6e41b2e72d --- /dev/null +++ b/composer.libraries.json @@ -0,0 +1,23 @@ +{ + "require": { + "zenorocha/clipboard.js": "v2.0.11" + }, + "repositories": { + "zenorocha/clipboard.js": { + "type": "package", + "package": { + "name": "zenorocha/clipboard.js", + "version": "v2.0.11", + "type": "drupal-library", + "extra": { + "installer-name": "clipboard.js" + }, + "source": { + "url": "https://github.com/zenorocha/clipboard.js.git", + "type": "git", + "reference": "v2.0.11" + } + } + } + } +} diff --git a/src/Commands/ClipboardJsCommands.php b/src/Commands/ClipboardJsCommands.php index e570a30e8cd4902d048b2b49a1bd046af3a791a1..a734d0966f97c43061bb9ba4cf1e7fe15ec83f8d 100644 --- a/src/Commands/ClipboardJsCommands.php +++ b/src/Commands/ClipboardJsCommands.php @@ -11,7 +11,7 @@ use Drush\Exec\ExecTrait; */ class ClipboardJsCommands extends DrushCommands { - const LIBRARY_VERSION = '2.0.10'; + const LIBRARY_VERSION = '2.0.11'; const LIBRARY_DOWNLOAD_URL = 'https://github.com/zenorocha/clipboard.js/archive/v' . self::LIBRARY_VERSION . '.zip';