For getting tarteaucitron.js lib by composer, the module need a composer.json file like this :

{
    "name": "drupal/my_module",
    "description": "module_desc",
    "type": "drupal-module",
    "authors": [
        {
            "name": "name",
            "email": "e_mail"
        }
    ],
    "minimum-stability": "dev",
    "homepage": "drupal/projet/page",
    "support": {
        "issues": "drupal/projet/page/issues"
    }
    "require": {
      "amauric/tarteaucitron": "^1.2.0",
    },
    "repositories": {
        "tarteaucitron": {
            "type": "package",
            "package": {
                "name": "AmauriC/tarteaucitron",
                "version": "1.2",
                "type": "drupal-library",
                "dist": {
                    "url": "https://github.com/AmauriC/tarteaucitron.js/archive/V1.2.zip",
                    "type": "zip"
                },
                "require": {
                    "composer/installers": "^1.2.0"
                }
            }
        }
    }
}

Comments

DrDam created an issue. See original summary.

boulaffasae’s picture

Status: Active » Needs review

Hello DrDam, we appreciate your contribution.

TacJS will move to 3.0 version as soon as possible.
I added the composer.json file to the module, https://git.drupalcode.org/project/tacjs/tree/8.x-3.x.

  • boulaffasae committed 5726402 on 8.x-3.x
    Issue #3083861: Need a composer.json file for getting tarteaucitron lib
    
drdam’s picture

The branch 3.x are not available with composer...

  • boulaffasae committed 59996d6 on 8.x-3.x
    Issue #3083861 defining dependencies in composer.json
    
boulaffasae’s picture

Hello DrDam, branchs 3.0/3.1 are now available with composer.
but installation still failed, am i missing something ?

wodby@php.container:/var/www/html $ composer require 'drupal/tacjs:^3.1'
./composer.json has been updated
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Installation request for drupal/tacjs ^3.1 -> satisfiable by drupal/tacjs[3.1.0].
    - drupal/tacjs 3.1.0 requires amauric/tarteaucitron.js ^1.2 -> no matching package found.
Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Installation failed, reverting ./composer.json to its original content.

  • boulaffasae committed fb9380b on 8.x-3.x
    Issues #3083861 Need a composer.json file for getting tarteaucitron lib
    

  • boulaffasae committed 0a14bb3 on 8.x-3.x
     Issues #3083861 Need a composer.json file for getting tarteaucitron lib
    
boulaffasae’s picture

Status: Needs review » Fixed

tarteaucitron.js is now part of the module TacJS

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nonom’s picture

It's what we are using in mobile_detect; fit it your needs

{
  "name": "drupal/mobile_detect",
  "description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices.",
  "type": "drupal-module",
  "homepage": "http://drupal.org/project/mobile_detect",
  "authors": [
    {
      "name": "Matthew Donadio (mpdonadio)",
      "homepage": "https://www.drupal.org/u/mpdonadio",
      "role": "Maintainer"
    },
    {
      "name": "Darryl Norris (darol100)",
      "email": "admin@darrylnorris.com",
      "homepage": "https://www.drupal.org/u/darol100",
      "role": "Co-maintainer"
    }
  ],
  "support": {
    "issues": "http://drupal.org/project/mobile_detect",
    "irc": "irc://irc.freenode.org/drupal-contribute",
    "source": "http://cgit.drupalcode.org/mobile_detect"
  },
  "license": "GPL-2.0+",
  "minimum-stability": "dev",
  "require": {
    "mobiledetect/mobiledetectlib": "~2.8"
  }
}
nonom’s picture

Do you want a patch from my side? I'm afraid it means rewrite a few things into the module.

Grats for the module, pretty useful :-)

boulaffasae’s picture

Hi @nonom Thank you very much for the Docs :)

Yes, we really need your and everyone help to make this module more useful.

I think because that mobiledetect/mobiledetectlib exist at packagist.org, that's why it can be downloaded using composer.json. But i don't know how you could handle the installation path /libraries, /modules, /themes ?

At the End, we added tarteaucitorn.js JavaScript files to TacJS module, the same way Drupal Core handle third-party libraries such as Sortable.js