I'm working on a module and there is a sub module for scanning barcodes that requires this, quagga.
Currently you have to manually download the library and put it into the libraries dir. If I add this as a dependency to the module you cannot install it without doing this first.
Can I have composer or something download a git repo to the libraries when installing the submodule?
Edit:
libraries.yml
form:
version: VERSION
css:
layout:
css/commerce_pos_barcode_scanning.css: {}
js:
js/commerce_pos_barcode_scanning.js: {}
dependencies:
- core/jquery
- core/drupal
- commerce_pos/quagga
quagga:
remote: https://github.com/serratus/quaggaJS.git
version: 1.0.0
license:
name: MIT
url: https://github.com/serratus/quaggaJS/blob/master/LICENSE
gpl-compatible: yes
js:
/libraries/webrtc/adapter-latest.js: {}
/libraries/quagga/quagga.min.js: {}
install.yml
function commerce_pos_barcode_scanning_requirements($phase) {
$requirements = [];
if ($phase == 'install' || $phase == 'runtime') {
$path = 'libraries/quagga/quagga.min.js';
if (!file_exists($path)) {
$requirements['commerce_pos_barcode_scanning'] = [
'title' => t('POS Barcode Scanning'),
'description' => t('To scan barcodes, you need to install the quagga JavaScript library. <a href="/modules/contrib/commerce_pos/modules/barcode_scanning/README.md">How To</a>'),
'severity' => REQUIREMENT_WARNING,
];
}
else {
$requirements['commerce_pos_barcode_scanning'] = [
'title' => t('POS Barcode Scanning'),
'severity' => REQUIREMENT_OK,
'value' => t('quagga JavaScript library has been configured.'),
];
}
}
return $requirements;
}