npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mavenmon

v0.0.2

Published

mavenmon =========

Downloads

9

Readme

mavenmon

like nodemon but for maven projects

Installation

npm install -g mavenmon

Usage

Go to your maven project root and run

mavenmon 

This will automatically start watching your project with the default settings

You can also override some functionalities by defining different logic in the command line

mavemon some_dir onchange_handler.js --filter file_filter.js
  • some_dir - defines which dir to watch

  • onchange_handler.js - define a different behavior when file changes. See spec below.

  • file_filter.js - defines which files should be watched and which should not. See spec below.

On change handler

For example

/**
   A change handler that assumes this is a multi module project and runs maven build on relevant artifact when code changes. 
   Otherwise ignores.
**/
module.exports = function (data) {
  return new Promise(function (resolve, reject) {
    try {
      if (data.path.endsWith('.java')) {
        console.log('running mvn clean install')
        execSync('mvn clean install -DskipTests=true -nsu -pl ' + data.pom.project.artifactid, {stdio: [0, 1, 2]})
      } else {
        console.log('unhandled path [' + data.path + ']', data.type)
      }
    } catch (e) {
      reject(e)
      return
    } finally {
      console.log('finished process [' + data.path + ']', data.type)
    }
    resolve()
  })
}

As you can see onchange_handler.js must expost a function that receives as a parameter the modified data. Specifically these fields

  • dir - [string] - the pom directory
  • pom - [object] - an object in the pom.xml structure. all the keys are lowercase (artifactid and not artifactId)
  • jarfile - [string] - a guess where the jar file will be.
  • classfile - [string] - a guess where the class file will be.

File filter

For example

var fs = require('fs')
var path = require('path')

/**

    A file filter that focuses on java files under src, on compiled classes from src and jar files.

**/

module.exports = function shouldWatchFolder (filepath) {
  try {
    var result = false
    if (fs.existsSync(filepath)) {
      if (fs.lstatSync(filepath).isDirectory() &&
        path.basename(filepath) !== 'node_modules' &&
        path.basename(filepath) !== 'test-classes' &&
        filepath.indexOf('src/test/java') < 0 &&
        path.basename(filepath) !== 'dev' && (filepath === '.' || path.basename(filepath)[0] !== '.')) {
        result = true
      }

      if (filepath.endsWith('.java') || filepath.endsWith('.class') || filepath.endsWith('.jar')) {
        result = true
      }
    } else {
      return true // if does not exist, watch it! otherwise will be ignored if readded. fixes issue where file is deleted.
    }
  } catch (e) {
    console.log('should i ignore error', e)
    result = false
  }
  return result
}

The file filter should expose a function that returns true if should be ignored.

NOTE - if file does not exist, you might still want to watch it in case it returns. If you return false, then mavenmon will not detect it if it comes back.