Commit 8e675aff authored by nikunjkotecha's avatar nikunjkotecha Committed by nikunj
Browse files

Issue #3066451 by Eduardo Morales, nikunjkotecha, Luke.Leber, msuthars,...

Issue #3066451 by Eduardo Morales, nikunjkotecha, Luke.Leber, msuthars, JayKandari: Composer Deprecation Warning
parent 689c405b
Clientside Validation 8.x-2.0-dev, 2019-09-26
-----------------------------
- Issue #3066451 by Eduardo Morales, Luke.Leber, msuthars, JayKandari: Composer
Deprecation Warning
- Added CHANGELOG.txt
...@@ -26,39 +26,53 @@ or using Composer. ...@@ -26,39 +26,53 @@ or using Composer.
jQuery Validation 1.17.0 or higher is recommended. jQuery Validation 1.17.0 or higher is recommended.
2. If it does not already exist, create a folder named `libraries` at the web 2. If it does not already exist, create a folder named `libraries` at the web
root of your Drupal site. Then, create a folder named `jqueryvalidate` root of your Drupal site. Then, create a folder named `jquery-validation`
inside of the `libraries` folder (i.e.: `/libraries/jqueryvalidate`). inside of the `libraries` folder (i.e.: `/libraries/jquery-validation`).
3. Extract the ZIP you downloaded in step 1 inside of the 3. Extract the ZIP you downloaded in step 1 inside of the
`/libraries/jqueryvalidate` folder (i.e.: so that the `jquery.validate.js` `/libraries/jquery-validation` folder (i.e.: so that the `jquery.validate.js`
file is at `/libraries/jqueryvalidate/dist/jquery.validate.js`). file is at `/libraries/jquery-validation/dist/jquery.validate.js`).
### To install the library using Composer: ### To install the library using Composer:
Check composer.example.json in module directory for a complete working example
with npm-asset.
1. Add the proper repository to your `composer.json` file to be able to require 1. Add the proper repository to your `composer.json` file to be able to require
the JS library: the JS library. We need npm-assets, merge following
in project root's composer.json file.
```json ```json
{ "repositories": {
"type": "package", "npm-assets": {
"package": { "type": "composer",
"name": "jqueryvalidate", "url": "https://asset-packagist.org"
"version": "1.17.0",
"type": "drupal-library",
"dist": {
"url": "https://github.com/jquery-validation/jquery-validation/releases/download/1.17.0/jquery-validation-1.17.0.zip",
"type": "zip"
}
} }
} }
``` ```
2. We also need to ensure npm-asset is added as Drupal Library. Merge following
in project root's composer.json file.
```json
"extra": {
"installer-types": [
"npm-asset"
],
"installer-paths": {
"web/libraries/{$name}": [
"type:npm-asset"
],
}
}
```
It is always good to download and use the latest version here but new It is always good to download and use the latest version here but new
versions may not work as expected since those are not tested properly. versions may not work as expected since those are not tested properly.
2. Run `composer require jqueryvalidate:~1.0` 3. Run `composer require oomphinc/composer-installers-extender npm-asset/jquery-validation:^1.17`
3. Install module as usual. 4. Install module as usual.
# Extend # Extend
......
...@@ -178,7 +178,7 @@ class ClientsideValidationDemoForm extends FormBase { ...@@ -178,7 +178,7 @@ class ClientsideValidationDemoForm extends FormBase {
/** /**
* Ajax submit callback. * Ajax submit callback.
*/ */
public function setMessage(array $form, FormStateInterface $form_state) { public function submitAjax(array $form, FormStateInterface $form_state) {
$response = new AjaxResponse(); $response = new AjaxResponse();
return $response; return $response;
} }
......
...@@ -50,7 +50,7 @@ function clientside_validation_jquery_drush_command() { ...@@ -50,7 +50,7 @@ function clientside_validation_jquery_drush_command() {
* Implements drush_hook_COMMAND(). * Implements drush_hook_COMMAND().
*/ */
function drush_clientside_validation_jquery_libraries_status() { function drush_clientside_validation_jquery_libraries_status() {
$installed = file_exists(DRUPAL_ROOT . '/libraries/jqueryvalidate/dist/jquery.validate.js'); $installed = file_exists(DRUPAL_ROOT . '/libraries/jquery-validation/dist/jquery.validate.js');
$message = $installed ? 'installed' : 'not installed'; $message = $installed ? 'installed' : 'not installed';
drush_print(dt('Library required for clientside validation jQuery is @message', [ drush_print(dt('Library required for clientside validation jQuery is @message', [
'@message' => $message, '@message' => $message,
...@@ -90,10 +90,10 @@ function drush_clientside_validation_jquery_libraries_remove($status = TRUE) { ...@@ -90,10 +90,10 @@ function drush_clientside_validation_jquery_libraries_remove($status = TRUE) {
} }
$removed = FALSE; $removed = FALSE;
$library_exists = (file_exists(DRUPAL_ROOT . '/libraries/jqueryvalidate')) ? TRUE : FALSE; $library_exists = (file_exists(DRUPAL_ROOT . '/libraries/jquery-validation')) ? TRUE : FALSE;
if ($library_exists) { if ($library_exists) {
drush_print('jQuery validtion library removed'); drush_print('jQuery Validation library removed');
drush_delete_dir(DRUPAL_ROOT . '/libraries/jqueryvalidate', TRUE); drush_delete_dir(DRUPAL_ROOT . '/libraries/jquery-validation', TRUE);
drupal_flush_all_caches(); drupal_flush_all_caches();
$removed = TRUE; $removed = TRUE;
} }
...@@ -115,8 +115,8 @@ function _drush_clientside_validation_jquery_libraries_make() { ...@@ -115,8 +115,8 @@ function _drush_clientside_validation_jquery_libraries_make() {
]; ];
$url = 'https://github.com/jquery-validation/jquery-validation/archive/1.17.0.zip'; $url = 'https://github.com/jquery-validation/jquery-validation/archive/1.17.0.zip';
$data['libraries']['jqueryvalidate'] = [ $data['libraries']['jquery-validation'] = [
'directory_name' => 'jqueryvalidate', 'directory_name' => 'jquery-validation',
'destination' => 'libraries', 'destination' => 'libraries',
'download' => [ 'download' => [
'type' => 'get', 'type' => 'get',
......
...@@ -72,7 +72,7 @@ function clientside_validation_jquery_requirements($phase) { ...@@ -72,7 +72,7 @@ function clientside_validation_jquery_requirements($phase) {
return $requirements; return $requirements;
} }
$library_exists = file_exists('libraries/jqueryvalidate/dist/jquery.validate.js'); $library_exists = file_exists('libraries/jquery-validation/dist/jquery.validate.js');
$requirements['clientside_validation_jquery_library'] = [ $requirements['clientside_validation_jquery_library'] = [
'title' => t('Clientside Validation jQuery library'), 'title' => t('Clientside Validation jQuery library'),
......
...@@ -5,7 +5,7 @@ jquery.validate: ...@@ -5,7 +5,7 @@ jquery.validate:
url: https://github.com/jquery-validation/jquery-validation/blob/master/LICENSE.md url: https://github.com/jquery-validation/jquery-validation/blob/master/LICENSE.md
gpl-compatible: true gpl-compatible: true
js: js:
/libraries/jqueryvalidate/dist/jquery.validate.js: {} /libraries/jquery-validation/dist/jquery.validate.js: {}
dependencies: dependencies:
- core/drupal - core/drupal
- core/drupalSettings - core/drupalSettings
...@@ -17,7 +17,7 @@ jquery.validate.additional: ...@@ -17,7 +17,7 @@ jquery.validate.additional:
url: https://github.com/jquery-validation/jquery-validation/blob/master/LICENSE.md url: https://github.com/jquery-validation/jquery-validation/blob/master/LICENSE.md
gpl-compatible: true gpl-compatible: true
js: js:
/libraries/jqueryvalidate/dist/additional-methods.js: {} /libraries/jquery-validation/dist/additional-methods.js: {}
dependencies: dependencies:
- clientside_validation_jquery/jquery.validate - clientside_validation_jquery/jquery.validate
cv.jquery.validate: cv.jquery.validate:
......
...@@ -54,7 +54,7 @@ function clientside_validation_jquery_clientside_validation_validator_info_alter ...@@ -54,7 +54,7 @@ function clientside_validation_jquery_clientside_validation_validator_info_alter
function clientside_validation_jquery_library_info_alter(&$libraries, $extension) { function clientside_validation_jquery_library_info_alter(&$libraries, $extension) {
if ($extension == 'clientside_validation_jquery' && isset($libraries['jquery.validate'])) { if ($extension == 'clientside_validation_jquery' && isset($libraries['jquery.validate'])) {
$module_path = drupal_get_path('module', 'clientside_validation_jquery'); $module_path = drupal_get_path('module', 'clientside_validation_jquery');
$path_in_yml = '/libraries/jqueryvalidate/dist/'; $path_in_yml = '/libraries/jquery-validation/dist/';
// Load settings from config. // Load settings from config.
$config = \Drupal::config('clientside_validation_jquery.settings'); $config = \Drupal::config('clientside_validation_jquery.settings');
...@@ -62,7 +62,7 @@ function clientside_validation_jquery_library_info_alter(&$libraries, $extension ...@@ -62,7 +62,7 @@ function clientside_validation_jquery_library_info_alter(&$libraries, $extension
// Check for library or js in module only if use_cdn flag is set to false. // Check for library or js in module only if use_cdn flag is set to false.
if (empty($config->get('use_cdn'))) { if (empty($config->get('use_cdn'))) {
// Based on updated readme instructions, check in libraries. // Based on updated readme instructions, check in libraries.
if (file_exists('libraries/jqueryvalidate/dist/jquery.validate.js')) { if (file_exists('libraries/jquery-validation/dist/jquery.validate.js')) {
// We do nothing here if it is available in libraries. // We do nothing here if it is available in libraries.
return; return;
} }
......
...@@ -100,7 +100,7 @@ class ClientsideValidationjQuerySettingsForm extends ConfigFormBase { ...@@ -100,7 +100,7 @@ class ClientsideValidationjQuerySettingsForm extends ConfigFormBase {
// Validate if library exists if use CDN is set to false. // Validate if library exists if use CDN is set to false.
if (empty($values['use_cdn'])) { if (empty($values['use_cdn'])) {
$library_exists = file_exists('libraries/jqueryvalidate/dist/jquery.validate.js'); $library_exists = file_exists('libraries/jquery-validation/dist/jquery.validate.js');
if (empty($library_exists)) { if (empty($library_exists)) {
$form_state->setErrorByName('use_cdn', $this->t('Please make sure JS is available in Drupal Libraries. Check README in module folder for more details.')); $form_state->setErrorByName('use_cdn', $this->t('Please make sure JS is available in Drupal Libraries. Check README in module folder for more details.'));
......
{
"name": "drupal-composer/drupal-project",
"description": "Project template for Drupal 8 projects with composer",
"type": "project",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "",
"role": ""
}
],
"repositories": {
"drupal": {
"type": "composer",
"url": "https://packages.drupal.org/8"
},
"npm-assets": {
"type": "composer",
"url": "https://asset-packagist.org"
}
},
"require": {
"php": ">=5.6",
"composer/installers": "^1.2",
"cweagans/composer-patches": "^1.6.5",
"drupal-composer/drupal-scaffold": "^2.5",
"drupal/clientside_validation": "^1.2",
"drupal/console": "^1.0.2",
"drupal/core": "^8.7.0",
"drush/drush": "^9.0.0",
"npm-asset/jquery-validation": "^1.17",
"oomphinc/composer-installers-extender": "^1.1",
"vlucas/phpdotenv": "^2.4",
"webflo/drupal-finder": "^1.0.0",
"webmozart/path-util": "^2.3",
"zaporylie/composer-drupal-optimizations": "^1.0"
},
"require-dev": {
"webflo/drupal-core-require-dev": "^8.7.0"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true
},
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php"
],
"files": [
"load.environment.php"
]
},
"scripts": {
"pre-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"pre-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"post-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
],
"post-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
]
},
"extra": {
"composer-exit-on-patch-failure": true,
"patchLevel": {
"drupal/core": "-p2"
},
"installer-types": [
"npm-asset"
],
"installer-paths": {
"web/core": [
"type:drupal-core"
],
"web/libraries/jquery-validation": [
"npm-asset/jquery-validation"
],
"web/libraries/{$name}": [
"type:drupal-library",
"type:npm-asset"
],
"web/modules/contrib/{$name}": [
"type:drupal-module"
],
"web/profiles/contrib/{$name}": [
"type:drupal-profile"
],
"web/themes/contrib/{$name}": [
"type:drupal-theme"
],
"drush/Commands/{$name}": [
"type:drupal-drush"
]
},
"drupal-scaffold": {
"initial": {
".editorconfig": "../.editorconfig",
".gitattributes": "../.gitattributes"
}
}
}
}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"type": "drupal-module", "type": "drupal-module",
"support": { "support": {
"issues": "https://drupal.org/project/issues/clientside_validation", "issues": "https://drupal.org/project/issues/clientside_validation",
"source": "https://cgit.drupalcode.org/clientside_validation" "source": "https://git.drupalcode.org/project/clientside_validation"
}, },
"license": "GPL-2.0+", "license": "GPL-2.0+",
"minimum-stability": "dev", "minimum-stability": "dev",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment