Skip to content

Commit

Permalink
Bower is deprecated since 2017, we should use npm instead.
Browse files Browse the repository at this point in the history
https://bower.io/blog/2017/how-to-migrate-away-from-bower/

While at it, let's use minified JS in production. Credits @robregonm
  • Loading branch information
razvanphp committed Mar 21, 2024
1 parent 9578380 commit 5f0a06d
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: composer update $DEFAULT_COMPOSER_FLAGS

- name: Install JQuery `3.6.*@stable` for tests.
run: composer require "bower-asset/jquery:3.6.*@stable"
run: composer require "npm-asset/jquery:3.6.*@stable"

- name: Install node.js.
uses: actions/setup-node@v1
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@
"yiisoft/yii2-composer": "~2.0.4",
"ezyang/htmlpurifier": "^4.6",
"cebe/markdown": "~1.0.0 | ~1.1.0 | ~1.2.0",
"bower-asset/jquery": "3.7.*@stable | 3.6.*@stable | 3.5.*@stable | 3.4.*@stable | 3.3.*@stable | 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable",
"bower-asset/inputmask": "^5.0.8 ",
"bower-asset/punycode": "^2.2",
"bower-asset/yii2-pjax": "~2.0.1"
"npm-asset/jquery": "3.7.*@stable | 3.6.*@stable | 3.5.*@stable | 3.4.*@stable | 3.3.*@stable | 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable",
"npm-asset/inputmask": "^5.0.8 ",
"npm-asset/punycode": "^2.2",
"npm-asset/yii2-pjax": "~2.0.1"
},
"require-dev": {
"dms/phpunit-arraysubset-asserts": "^0.5",
Expand Down
124 changes: 47 additions & 77 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions framework/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,17 @@
"yiisoft/yii2-composer": "~2.0.4",
"ezyang/htmlpurifier": "^4.6",
"cebe/markdown": "~1.0.0 | ~1.1.0 | ~1.2.0",
"bower-asset/jquery": "3.7.*@stable | 3.6.*@stable | 3.5.*@stable | 3.4.*@stable | 3.3.*@stable | 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable",
"bower-asset/inputmask": "^5.0.8 ",
"bower-asset/punycode": "^2.2",
"bower-asset/yii2-pjax": "~2.0.1"
"npm-asset/jquery": "3.7.*@stable | 3.6.*@stable | 3.5.*@stable | 3.4.*@stable | 3.3.*@stable | 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable",
"npm-asset/inputmask": "^5.0.8 ",
"npm-asset/punycode": "^2.2",
"npm-asset/yii2-pjax": "~2.0.1"
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"autoload": {
"psr-4": {"yii\\": ""}
},
Expand All @@ -85,5 +91,10 @@
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true
}
}
}
2 changes: 1 addition & 1 deletion framework/validators/PunycodeAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class PunycodeAsset extends AssetBundle
{
public $sourcePath = '@bower/punycode';
public $sourcePath = '@npm/punycode';
public $js = [
'punycode.js',
];
Expand Down
4 changes: 2 additions & 2 deletions framework/web/JqueryAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
class JqueryAsset extends AssetBundle
{
public $sourcePath = '@bower/jquery/dist';
public $sourcePath = '@npm/jquery/dist';
public $js = [
'jquery.js',
YII_ENV_DEV ? 'jquery.js' : 'jquery.min.js'
];
}
4 changes: 2 additions & 2 deletions framework/widgets/MaskedInputAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
*/
class MaskedInputAsset extends AssetBundle
{
public $sourcePath = '@bower/inputmask/dist';
public $sourcePath = '@npm/inputmask/dist';
public $js = [
'jquery.inputmask.js',
YII_ENV_DEV ? 'jquery.inputmask.js' : 'jquery.inputmask.min.js',
];
public $depends = [
'yii\web\YiiAsset',
Expand Down
2 changes: 1 addition & 1 deletion framework/widgets/PjaxAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class PjaxAsset extends AssetBundle
{
public $sourcePath = '@bower/yii2-pjax';
public $sourcePath = '@npm/yii2-pjax';
public $js = [
'jquery.pjax.js',
];
Expand Down
2 changes: 1 addition & 1 deletion tests/js/tests/yii.activeForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var vm = require('vm');
describe('yii.activeForm', function () {
var yiiActiveFormPath = 'framework/assets/yii.activeForm.js';
var yiiPath = 'framework/assets/yii.js';
var jQueryPath = 'vendor/bower-asset/jquery/dist/jquery.js';
var jQueryPath = 'vendor/npm-asset/jquery/dist/jquery.js';
var $;
var $activeForm;

Expand Down
2 changes: 1 addition & 1 deletion tests/js/tests/yii.captcha.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var vm = require('vm');

describe('yii.captcha', function () {
var yiiCaptchaPath = 'framework/assets/yii.captcha.js';
var jQueryPath = 'vendor/bower-asset/jquery/dist/jquery.js';
var jQueryPath = 'vendor/npm-asset/jquery/dist/jquery.js';
var $;
var $captcha;
var settings = {
Expand Down
2 changes: 1 addition & 1 deletion tests/js/tests/yii.gridView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var vm = require('vm');
describe('yii.gridView', function () {
var yiiGridViewPath = 'framework/assets/yii.gridView.js';
var yiiPath = 'framework/assets/yii.js';
var jQueryPath = 'vendor/bower-asset/jquery/dist/jquery.js';
var jQueryPath = 'vendor/npm-asset/jquery/dist/jquery.js';
var $;
var $gridView;
var settings = {
Expand Down
4 changes: 2 additions & 2 deletions tests/js/tests/yii.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ var StringUtils = {

describe('yii', function () {
var yiiPath = 'framework/assets/yii.js';
var jQueryPath = 'vendor/bower-asset/jquery/dist/jquery.js';
var pjaxPath = 'vendor/bower-asset/yii2-pjax/jquery.pjax.js';
var jQueryPath = 'vendor/npm-asset/jquery/dist/jquery.js';
var pjaxPath = 'vendor/npm-asset/yii2-pjax/jquery.pjax.js';
var sandbox;
var $;
var yii;
Expand Down
4 changes: 2 additions & 2 deletions tests/js/tests/yii.validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var StringUtils = {
};

var jsdom = require('mocha-jsdom');
var punycode = require('../../../vendor/bower-asset/punycode/punycode');
var punycode = require('../../../vendor/npm-asset/punycode/punycode');

var fs = require('fs');
var vm = require('vm');
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('yii.validation', function () {
}

jsdom({
src: fs.readFileSync('vendor/bower-asset/jquery/dist/jquery.js', 'utf-8')
src: fs.readFileSync('vendor/npm-asset/jquery/dist/jquery.js', 'utf-8')
});

before(function () {
Expand Down

0 comments on commit 5f0a06d

Please sign in to comment.