Skip to:
Content

BuddyPress.org

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#6756 closed enhancement (fixed)

npm check-dependencies

Reported by: djpaul's profile DJPaul Owned by: hnla's profile hnla
Milestone: 2.5 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Cc:

Description

I think we should introduce the check-dependencies NPM package into our Grunt workflow. It checks if currently installed NPM dependencies are the same versions that are specified in the package.json.

whether it's a version bump or a new package, one can forget to invoke npm install (or bower install) and continue using the application, possibly encountering errors caused by obsolete package versions. To avoid it, use the check-dependencies module at the top of the entry point of your application; it will inform about not up-to-date setup and optionally install the dependencies.

https://github.com/mzgol/check-dependencies

Attachments (1)

6756.diff (1.3 KB) - added by netweb 9 years ago.

Download all attachments as: .zip

Change History (13)

#1 @hnla
9 years ago

Seems a pretty sensible idea - easy to forget or simply not know or miss that package manager has had a package updated and therefore not be aware running node install /update is necessary.

#2 @hnla
9 years ago

Do we not use this though?:
https://www.npmjs.com/package/grunt-check-dependencies
(based on https://www.npmjs.org/package/check-dependencies)

Just been updating the gruntfile for a current work project running watch tasks so added this and configured for fun but think for that project it's going to be useful rather than having to prompt other devs to update this & that.

Have to admit struggled with 'check-dependencies' config-ing but found the grunt-check-dependencies easier to get setup.

#3 @netweb
9 years ago

+1 I've looked for one of these types of packages in the past and never found one :(

@netweb
9 years ago

#4 @netweb
9 years ago

Patch 6756.diff gets this up and running, I chose not to install the missing/outdated packages automatically, I think this should be left for users do themselves as they may be running a dev or custom version of a package for testing etc.

This task grunt checkDependencies:src runs before any other Grunt tasks including the default task

Here's the output from running grunt:

$ grunt
Running "checkDependencies:src" (checkDependencies) task
>> grunt-contrib-uglify: installed: 0.9.1, expected: 0.10.1
>> Invoke npm install to install missing packages
Warning: Task "checkDependencies:src" failed. Use --force to continue.

Aborted due to warnings.

FYI: I did a bunch of other semver tests and all worked great :)

#5 @DJPaul
9 years ago

  • Keywords has-patch added

Great! Thanks for testing the suggestion, both, and for the patch @netweb.

@hnla raised a good question: https://github.com/mzgol/check-dependencies and https://github.com/mzgol/grunt-check-dependencies both exist and I have no idea what the difference is (maybe one is canonical, but the old project/name had to be maintained for backwards compatibility. If we can figure out what the right one to use is, let's get it in.

#6 @netweb
9 years ago

The later https://github.com/mzgol/grunt-check-dependencies is for the Grunt "task runner" that utilizes the main NPM module https://github.com/mzgol/check-dependencies as a dependancy

#7 @hnla
9 years ago

I chose not to install the missing/outdated packages automatically

I think that would be the sensible approach, we need a prompt but should be capable of determining when we want or need to run updates.

#8 follow-up: @hnla
9 years ago

So grunt-check-dependencies doesn't install it's own dependency 'check-dependencies', still can't fully puzzle these modules and when/why to use loadNpmTasks or when registerTask; seems odd BP gruntfile has no load tasks and my other project gruntfile has both load & register and I configure both with same initConfig but register & load respectively to arrive at same favourable result - still that's my dilemma to figure out.

Installed check-dependencies and updated gruntfile to netwebs patch on one of my BP installs and it works great, nicely halts any grunt command and would prevent me using outdated modules without realizing, a no brainer to go and commit I would have thought!

#9 in reply to: ↑ 8 @netweb
9 years ago

Replying to hnla:

So grunt-check-dependencies doesn't install it's own dependency 'check-dependencies',

It does, if you apply the 6756.diff patch and run npm install you'll see that grunt-check-dependencies installs its NPM package to node_modules/grunt-check-dependencies and as part of this the dependancy check-dependencies for NodeJS v5.x is installed to node_modules/check-dependencies or for NodeJS < 4.x it will be in node_modules/grunt-check-dependencies/node_modules/check-dependencies

still can't fully puzzle these modules and when/why to use loadNpmTasks or when registerTask; seems odd BP gruntfile has no load tasks and my other project gruntfile has both load & register and I configure both with same initConfig but register & load respectively to arrive at same favourable result - still that's my dilemma to figure out.

Yes, it does, take a look here: https://buddypress.trac.wordpress.org/browser/trunk/Gruntfile.js#L24

Installed check-dependencies and updated gruntfile to netwebs patch on one of my BP installs and it works great, nicely halts any grunt command and would prevent me using outdated modules without realizing, a no brainer to go and commit I would have thought!

It does, you can take a more in depth peek at it by running: grunt checkDependencies --verbose also

#10 @hnla
9 years ago

:) darn it, missed the loadnpm line, missed the nested, hidden 'check-dependencies' and had installed it originally on it's own so assumed had to again when installing into BP.

Yep --verbose opens the lid somewhat :)

Thanks @netweb for the explanations, things start to become clearer :)

#11 @hnla
9 years ago

  • Owner set to hnla
  • Resolution set to fixed
  • Status changed from new to closed

In 10399:

Grunt Modules:
Add the grunt-check-dependencies module to grunt node modules.

Check-dependencies checks the package.json module versions to ensure that the required version is the same as the installed version and either halts on error & prompts for update or updates automatically; option set to prompt only for BP.

Fixes #6756 Props netweb, DJPaul

#12 @DJPaul
8 years ago

  • Component changed from Tools - Build Process to Build/Test Tools
Note: See TracTickets for help on using tickets.