Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[In Progress] Chore: TR-3008 update 3rd party deps #175

Closed
wants to merge 1 commit into from

Conversation

Nicholass
Copy link

% npm audit
found 0 vulnerabilities

Replaced deprecated lodash method calls

Tested with:

npm run test:dev
npm run build

@Nicholass Nicholass added the dependencies Pull requests that update a dependency file label Aug 31, 2023
@Nicholass Nicholass changed the title Chore: TR-3008 update 3rd party deps [In Progress] Chore: TR-3008 update 3rd party deps Aug 31, 2023
Copy link
Contributor

@oatymart oatymart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current changes look too risky, but don't give up. Run a full TAO instance to understand which libs could or couldn't be safely upgraded.

package.json Outdated
Comment on lines 57 to 62
"handlebars": "^4.7.8",
"interactjs": "1.3.4",
"jquery": "1.9.1",
"jquery": "^3.7.1",
"jquery-mockjax": "^2.6.0",
"jquery-simulate": "^1.0.2",
"lodash": "2.4.1",
"lodash": "^4.17.21",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we can get away with casually bumping all these libs.

The reason is that tao-core-sdk is not used in isolation, it is used as part of a fully-installed TAO where several other components are still using handlebars 1.3.0, jquery 1.9.1 and lodash 2.4.1. In some cases we would have a conflict in the browser (jquery for sure / lodash not sure).

That's why we intend to handle the upgrade of these libs with a dedicated task designed to upgrade each one in all places at the same time.

The overall initiative to move some lodash usages to the v4 API is good, though. If you want to concentrate on that, you can continue, but be sure to test this library installed in tao-core in a full TAO Community.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that this one is indeed to risky. I guess I'll go with npm audit fix without --force for now.

Copy link
Contributor

@jsconan jsconan Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, as Martin explained, you should have a look at how the FE packages relate to each other on TAO.

We have a bunch of libraries that are dependent on each other, hierarchically. When updating one, you need to spread the change across all others.

As a quick overview, we have in order:

  • tao-core-shared-libs
  • tao-core-libs
  • tao-core-sdk
  • tao-core-ui
  • tao-item-runner
  • tao-item-runner-qti
  • tao-test-runner
  • tao-test-runner-qti

And besides that, a galaxy of smaller packages that are consumed for the tooling, like:

  • grunt-tao-bundle
  • browserslist-config-tao
  • eslint-config-tao
  • prettier-config
  • etc.

And some other specific libraries...

In TAO, we also have extensions that will contain frontend code too, consuming and relying on the above-mentioned libs.

A change in lodash, will impact all of that. The same with jQuery, Handlebars, Select2... Because these are peer dependencies, and only one version at a time is supported. If you update one in a package, it will conflict with the version required in another package.

In other words, we cannot update a single package without taking care of all of the others that depend on it

package.json Outdated
@@ -81,7 +81,7 @@
"rollup-plugin-istanbul": "^2.0.1",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"select2": "3.5.1",
"select2": "^4.1.0-rc.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked what breaking changes are announced in select2 v4? Could it affect us?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This breaks TAO. We cannot upgrade Select2 for the time being, the code is not compatible, and a significant migration is required. Moreover, we should not use RC without a very good reason.

@@ -584,7 +584,7 @@ DataBinder.prototype._setNodeValue = function _setNodeValue($node, value) {
}

//assign value
if (_.contains(['INPUT', 'SELECT', 'TEXTAREA'], $node[0].nodeName)) {
if (_.includes(['INPUT', 'SELECT', 'TEXTAREA'], $node[0].nodeName)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better replacement might be vanilla Array.includes(). It would ease the work of upgrading lodash v2 to v4, if we end up doing that later.

@@ -25,7 +25,7 @@ jobs:
node-version: 18.x
registry-url: https://registry.npmjs.org
- name: Install packages
run: npm ci
run: npm ci --legacy-peer-deps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs explanation too.

Copy link
Contributor

@jsconan jsconan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I understand the good intent, but I'm afraid this PR needs to be closed. None of the proposed version upgrades is acceptable in the state.

FYI, we have specific tickets for taking care of these major upgrades.

@@ -25,7 +25,7 @@ jobs:
node-version: 18.x
registry-url: https://registry.npmjs.org
- name: Install packages
run: npm ci
run: npm ci --legacy-peer-deps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This is adding an exception in the install flow. Setting install options in the CI won't remove issues when installing locally. A better approach is to rely on a local .npmrc so that the experience is seamless for everyone.

package.json Outdated
Comment on lines 57 to 59
"handlebars": "^4.7.8",
"interactjs": "1.3.4",
"jquery": "1.9.1",
"jquery": "^3.7.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This is breaking everything in TAO. Please do not apply blindly a version bump without properly migrating the code, especially when breaking changes are involved.

FYI, we already have tasks for taking care of these particular dependencies, as Martin already spotted.

package.json Outdated
@@ -81,7 +81,7 @@
"rollup-plugin-istanbul": "^2.0.1",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"select2": "3.5.1",
"select2": "^4.1.0-rc.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This breaks TAO. We cannot upgrade Select2 for the time being, the code is not compatible, and a significant migration is required. Moreover, we should not use RC without a very good reason.

reverted `--force` part. tests now good
@Nicholass Nicholass force-pushed the chore/tr-3008/update-3rd-party-deps branch from eed61c5 to a56c89c Compare September 5, 2023 13:38
@github-actions
Copy link

github-actions bot commented Sep 5, 2023

Version

Target Version 2.0.3
Last version 2.0.2

There are 0 BREAKING CHANGE, 0 feature, 0 fix

@github-actions
Copy link

github-actions bot commented Sep 5, 2023

Coverage Report

Totals Coverage
Statements: 90.79% ( 2592 / 2855 )
Methods: 95.19% ( 594 / 624 )

@Nicholass
Copy link
Author

it looks like less "Aggresive" version bump gives nothing but 1 high issue in addition
with the fix: 5 vulnerabilities (2 moderate, 1 high, 2 critical)
current dev: 6 vulnerabilities (4 moderate, 2 critical)
In dev the vulnerable packages are:
select2, jquery, uglify-js so I guess I'd close this PR as redundant

@Nicholass Nicholass closed this Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants