Downloading js libraries through Composer repositories

Composer is a proven dependency management tool in PHP. Just mention application's all specifications and dependencies in composer.json and run "composer install". Composer locates, validates, downloads and loads the specified packages and ensures that exactly the right versions for each package is used.

I am developing a small Drupal 8 distribution particularly for blogging with a possibility to highlight the code within the body field. Drupal has a contributed module Codesnippet for this purpose which further has a dependency on Codesnippet add-on from CKEditor. I didn't wanted to get this JS library manually and store it under "libraries" folder. 

01. Specify JS package under "repository" section

Packa should include name, its type, version and the location from where it needs to be downloaded.

"repositories": [
    {
        "type"    : "package",
        "package" : {
            "name"    : "npralhad/codesnippet",
            "version" : "dev-master",
            "type"    : "drupal-library",
            "dist"    : {
                "url"  : "https://github.com/npralhad/codesnippet.git",
                "type" : "drupal-library"
            },
            "source"  : {
                "url"       : "https://github.com/npralhad/codesnippet.git",
                "type"      : "git",
                "reference" : "codesnippet"
            }
        }
    }
]

02. Specify package name under "require" section

Package name should be specified along with the version.

"require": {
    "npralhad/codesnippet": "dev-master"
}

03. Specify path details under "extra" section

"extra": {
    "installer-paths": {
        "libraries/{$name}" : [
            "type:drupal-library"
        ]
    }
}

04. Complete composer.json file

{
    "name": "j5Studio",
    "description": "Drupal 8 - best of best.",
    "type": "drupal-profile",
    "license": "GPL-2.0+",
    "minimum-stability": "dev",
    "prefer-stable": true,
    "require-dev": {
        "drush/drush": "^9.0"    
    },
    "config": {
        "bin-dir": "bin/"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packagist.drupal-composer.org"
        },
        {
            "type"    : "package",
            "package" : {
                "name"    : "npralhad/codesnippet",
                "version" : "dev-master",
                "type"    : "drupal-library",
                "dist"    : {
                    "url"  : "https://github.com/npralhad/codesnippet.git",
                    "type" : "drupal-library"
                },
                "source"  : {
                    "url"       : "https://github.com/npralhad/codesnippet.git",
                    "type"      : "git",
                    "reference" : "codesnippet"
                }
            }
        }
    ],
    "require": {
        "cweagans/composer-patches": "^1.5.0",
        "composer/installers": "^1.0",
        "drupal/core": "~8.2.3",
        "drupal/codesnippet": "^8.1.6",
        "npralhad/codesnippet": "dev-master"
    },
    "extra": {
        "installer-paths": {
            "core": [
                "drupal/core"
            ],
            "libraries/{$name}" : [
                "type:drupal-library"
            ],	
            "modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "html/themes/contrib/{$name}": [
                "type:drupal-theme"
            ],
            "html/profiles/contrib/{$name}": [
                "type:drupal-profile"
            ],
            "drush/contrib/{$name}": [
                "type:drupal-drush"
            ]
        },
        "enable-patching": true
    }
}