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-ipsum

v0.0.6

Published

The default blueprint for ember-cli addons.

Downloads

1

Readme

Creating and Implementing a Simple Addon with ember-cli

This tutorial is designed for those of us who want a very simple introduction into the world of creating addons for Ember. It assumes you already have a basic undersanding of Ember and components, but aren't sure how addons are created. We'll focus less on creating an addon that serves much purpose and more on making your addon available, how to install it, and how to implement it into applications.

Getting started

Personally, in my development folder I've created a folder designated for Ember addons called ember-addons. Navigate to the folder you would like to create addons in.

  1. ember addon ember-ipsum (creates an addon and a folder of the same name: ember-ipsum)
  2. cd ember-ipsum
  3. Now open the addon/director with your editor of choice (sublime, atom, webstrom, etc.)
  4. Navigate to package.json and move ember-cli-htmlbars from devDependencies object into the dependencies object. If you forget to do this, you'll get an error message when you try to serve the dummy application that looks something like this:

Addon templates were detected, but there are no template compilers registered for <addon-folder-name>. Please make sure your template precompiler (commonly 'ember-cli-htmlbars') is listed in 'dependencies' (NOT 'devDependencies') in <addon-folder-name>'s 'package.json'.

Creating a Component in your Addon

Type ember g component ember-ipsum in your terminal. This is going to create 4 files:
addon\components\ember-ipsum.js
addon\templates\components\ember-ipsum.hbs
app\components\ember-ipsum.js tests\integrations\components\ember-ipsum-test.js (I'm not going to cover this, but you should be aware of it.)

  1. Open addon\components\ember-ipsum.js and overwrite it's contents with:
import Ember from 'ember';
import layout from '../templates/components/ember-ipsum';

export default Ember.Component.extend({
  layout,
  paragraph: "Data down actions up. Tomster. Routable component. Controllers are dead. No wait not yet. Ember install all the things. That's a " +
"load of HBS. I'm going to go data down and take a RESTAdapter. I have no point of view. Nested routes. Resource is no more. Controllers are " +
"singletons. What's a singleton? JSONAPIAdapter. this.set('yourComputer', 'onfire'). I think we've been setupController. Your navbar needs a " +
"hamburger-helper. Star Trek's Data vs ember-data. ember generate model role. this.store.peekRecord('aboo'). Serialize. Hash. Rinse. Repeat."
});
  1. Open addon\templates\components\ember-ipsum.hbs and overwrite it's content with:
<p>
  {{paragraph}}
</p>

{{yield}}
  1. Open app\components\ember-ipsum.js to see what it's doing. It should only contain one line of code that actually does the leg-work to get the addon to communicate whatever application it's installed into.
export { default } from 'ember-ipsum/components/ember-ipsum';

Test the Addon

Ember-cli is kind enough to generate a dummy folder for you to test your addon in. This folder acts as a separate application for you to pretend you've just installed the addon and want to use it.

  1. Open tests/dummy/app/templates/application.hbs. Add {{ember-ipsum}} to the code:
<h2 id="title">Welcome to Ember</h2>
{{ember-ipsum}}
{{outlet}}
  1. In the terminal, run ember s. Open your browser, navigate http://localhost:4200, and enjoy!

Setting up NPM

  1. If you don't already have a profile with npm, create one at https://www.npmjs.com/signup.
  2. Go to your terminal, type npm adduser and follow the prompts. It will ask you enter your username, password, and email associated with your npm profile.

Publishing to npm and github

Now you want to make your addon public. Just run the commands below in your terminal:

 npm version 0.0.1
 git push origin <branch-name>
 git push origin --tags
 npm publish

Follow the same steps everytime you make changes that you want available for the addon on npm. Just increment the version number appropriately [major].[minor].[patch]

Installing your addon to another project

Now you can open or create an Ember project and install your addon. In this example, you could run npm install ember-ipsum --save-dev. Then, you could add the ipsum text to any template you want simply by putting {{ember-ipsum}} wherever you want the text to appear.