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

yme

v0.0.6

Published

YUI Modules Explorer automatically discovers the required modules of YUI based projects by parsing JavaScript source files

Downloads

2

Readme

YUI Modules Explorer: Automatically discovers the required YUI3 modules from JavaScript source files

YUI Modules Explorer (YME) is a project which tries to save the developer from the monkey job of finding and populating the required YUI modules in JavaScript sources. What it does is to parse the JavaScript files using esprima JavaScript parser and to match the used YUI classes to the required modules.

Currently the developers are doing this manually - they look at YUI documentation, use YUI Configurator or copy and paste from the examples. The downsides of this approach are:

  • Leads to errors and misconfigurations - it is not easy to determine the right combination of modules and for that reason developers often add wrong modules or they add more modules than neeed which only increases the network traffic. This even happens with the modules inside YUI for example Dial
  • It is time consuming - determining the right combination of modules requires time and efforts

How does YME work?

  1. It parses the JavaScript files and looks for YUI Classes.
  2. It matches these classes to the modules in which they exists looking in data.json file, produced by YUIDoc.

Examples:

var overlay = new Y.Overlay({
	srcNode: '#myContent',
	visible: false,
	width: '20em'
});

In this case only one YUI class is used - Y.Overlay. So, he required module should be "overlay".

Resolving modules from values of class attributes:
var YP = Y.Plugin;

var YPA = YP.AutoComplete;

Y.one('#ac-input').plug(YPA, {
	resultFilters : ['phraseMatch', 'phraseMatchCase'],
    resultHighlighter: 'phraseMatchCase',
	source: ['foo', 'bar', 'baz']
});

The above is a relatively complex example, because we have:

  1. Aliases, constructed by declaring variables - "var YP = Y.Plugin;" and "var YPA = YP.AutoComplete;"
  2. Some modules should be resolved by matching the values of class attributes. In the above example, 'phraseMatch' and 'phraseMatchCase' require "autocomplete-filters" module in addition to "autocomplete-plugin".

Methods, directly attached to Y instance will be resolved too. For example:

Y.one(...)

will match "node-core".

Running the project

  1. Install the module - "npm install -g yme"
  2. Run "yme" with some parameters (see below for the list of command line options)

Examples

This command will parse the whole YUI src folder and will create a file, called "modules.json" with the extracted modules from each JavaScript file:

$ yme -d ~/projects/yui/yui3/src

The following command will parse only one file:

$ yme -f demo/demo.js

You can specify more than one file by separating them with commas. See below the command line options for more information

Command line options (view these via yme -h)

-f, --file [file1,file2] - The file(s) to parse and extract YUI modules.

-d, --dir [directory name] - The directory to traverse and extract YUI modules.

-c, --classes [export classes] - Export class names in addition to modules

-o, --out [file name] - The ouput file in which the information about found modules should be stored

-e, --ext [file extensions] - The file extensions which should be parsed. Defaults to "js".

-j, --json [file name] - Path to YUI data.json file. If not specified, "./data/data.json" will be used.

-i, --ignorenode [node string] - Ignore node string in files. If not speficified, "#!/usr/bin/env node" will be used.

-y, --yui-variable [var1,var2] - The name of the global YUI variable(s). Defaults to Y. Might be single value or an array.

-h, --help - output usage information

-V, --version - output the version number

Changelog

ver 0.0.5

  • Created NPM Package

ver 0.0.4

  • Added option to ignore node string - like "#!/usr/bin/env node"

ver 0.0.3

  • Traverse whole directory
  • Export modules in file
  • Bug fixing

ver 0.0.2

  • Resolve modules from class attributes

Current version - 0.0.5