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

ember-component-analyzer

v1.3.1

Published

Analyze ember app to know about the components that are used in each template.

Downloads

4

Readme

ember-component-analyzer

Build Status GitHub version NPM version Dependency Status codecov Greenkeeper badge

Information

NPM

This project is an experimental dark thing O_O**

This library extracts the "possibles" components that may exists in the different routes of an Ember application. It uses Glimmer compiler to make & read the AST trees.

The lib reads all the handlebars files to find all the components (usually names that contains - for components and . for contextual components). Once the "possible" components are found, it replaces all the contextual components by its real name. This part is only possible for the application components (right now its unable to read the components inside the ember-addons).

Information

NPM

How to use

  1. Import the lib
const lib = require('ember-component-analyzer');
  1. Process the application
#!/usr/bin/env node

const { Analyzer, parse } = lib;

const analyzer = new Analyzer(process.argv.slice(2), {
  // options...
});
const result = analyzer.process(); // Hell JSON
const output = parse(result); // Friendly JSON with the application data
  1. Save the results, process or do whatever you want

Options

The Analyzer class accepts an object as config. The possible attributes are:

  • families: An object containing the different typologies of the templates (components, helpers, routes, ...) and the RegExp used to recognize the type. These families represents the attributes of the result object after parsing the files.

Defaults to:

{
  components: /components/, // the file path contains the word "components"
  default: /^((?!components).)*$/ // the file path not contains the word "components"
}
  • getNodeName: This function receives an AST node as first argument and it should return the component name (if valid) or null if you don't want the element to appear in the report (for example a blacklisted element).

Example

Given:

  • Component my-wrapper.hbs:
<div>
  {{yield (hash header=(component 'my-header'))}}
  {{my-footer}}
</div>
  • Component my-header.hbs:
{{link-to}}
  • Route index.hbs:
{{#my-wrapper as |wrapper|}}
  {{wrapper.header}}
{{/my-wrapper}}

Then it will generate an output (using the exported parser) similar to:

{
  "default": [{
    "moduleId": "index.hbs",
    "components": ["my-wrapper", "header-main", "link-to", "my-footer"]
  },
  "components": [{
    "moduleId": "my-wrapper",
    "components": ["my-footer"]
  }, {
    "moduleId": "my-header",
    "components": ["link-to"]
  }]
}

Readable report?

Working on it :)

report

Contributing

We're thankful to the community for contributing any improvements.

Do not forget to follow our eslint rules and make test for the new functionalities/fixes.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details