Skip to content

Commit

Permalink
updated README template and readme for generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Vermel, Runn (GE Global Research) committed May 2, 2016
1 parent 9a5567c commit 03f6d19
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 86 deletions.
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@ Px Component Generator

## Introduction

The Px Component Generator is a starting point for building your own Px Component. There are several technologies that we use to make working with components easier and to aid in automating builds.
Familiarize yourself with these tools (which we cover in the Technologies section further down the page) so your component can look and feel like everything else in the Px ecosystem. The Px Component
The Px Component Generator is a starting point for building your own Predix UI Component. There are several technologies that we use to make working with components easier and to aid in automating builds.
Familiarize yourself with these tools (which we cover in the Technologies section further down the page) so your component can look and feel like everything else in the Predix UI ecosystem. The Predix UI Component
Generator relies on [Yeoman](http://yeoman.io).

## What is Yeoman and a Yeoman Generator
## Yeoman & Yeoman Generator

A generator is something run by [Yeoman](http://yeoman.io) to scaffold a software application, in this case a GE Design System component. Yeoman
is an application environment for writing and running generators. He lives in the [npm](https://npmjs.org) package repository.
You only have to ask for him once, then he packs up and moves into your hard drive.
A generator is something run by [Yeoman](http://yeoman.io) to scaffold a software application, in this case a Predix UI component. Yeoman
is an application environment for writing and running generators. Yeoman lives in the [npm](https://npmjs.org) package repository when installed globally (-g).

```
$ npm install -g yo
```

_Note: This generator works in yo 1.2 and above. To find the version of yo on your system, type `$ npm list -g yo`_

Now you have the Yeoman framework available to you. Yeoman travels light. He didn't pack any generators when he moved in. You can think of a generator like a plug-in. `generator-px-comp` is a generator that scaffolds a px-component
You can think of a generator like a plug-in. `generator-px-comp` is a generator that scaffolds a Predix UI component

To install the Px-Component generator locally, clone this repository into generator-px-comp and then from the top level directory of this project, run
To install the Predix UI Component generator locally, clone this repository into generator-px-comp and then from the top level directory of this project, run

```
$ git clone (this repository)
$ git clone https://github.com/PredixDev/generator-px-comp
$ cd generator-px-comp
$ npm link
```
Expand All @@ -38,9 +37,9 @@ $ cd px-something
$ yo px-comp
```

Running `yo px-comp` will ask you a few questions and then scaffold a sample component, Gruntfile.js, package.json, bower.json, tests, etc in your directory.
Running `yo px-comp` will ask you a few questions and then scaffold a sample component, which includes Gruntfile.js, package.json, bower.json, tests, etc in your directory.

Once you have a sample Px component, you can...
Once you have a sample Predix UI component, you can...

```
//build css
Expand All @@ -49,22 +48,24 @@ $ grunt sass
//start a local server
$ grunt depserve
//nav in a browser to localhost:[port]/test/ui/fixtures/px-my-component-name-fixture.html
//nav in a browser to
localhost:8080
```

`grunt sass` compiles [Sass](http://sass-lang.com/) into CSS.

`grunt depserve` starts a simple node HTTP server that enables correct finding of bower dependencies for local runs.

After you've verified the component works as generated, edit the sample Px component, tests and dependencies that were scaffolded for you into something useful.
When your component is finished, commit it to source control and tag an initial release.
After you've verified the component works, edit the sample Predix UI component, tests and dependencies that were scaffolded.

When your component is finished, commit it in Git and tag an initial release.

## Structure

It might seem like the generator creates quite a lot of files. Don't worry, most of them are packaged dependencies that aren't part of your Px component itself (i.e. the `node_modules` and `bower_components` directory).
It might seem like the generator creates quite a lot of files. Don't worry, most of them are packaged dependencies that aren't part of your Predix UI Component itself (i.e. the `node_modules` and `bower_components` directory).
The files that are part of the Px component are:

- **Readme.md** — A starter readme file in the Markdown format. Stash supports Markdown and we highly encourage you to write your documentation in it.
- **README.md** — A starter readme file in the Markdown format. Stash supports Markdown and we highly encourage you to write your documentation in it.
- **package.json** — An [npm](https://npmjs.org/) package file for specifying information and dependencies.
- **Gruntfile.js** — A build file for the [Grunt](http://gruntjs.com/) task runner.
- **bower.json** — A [Bower](http://bower.io/) package file for specifying information and dependencies.
Expand All @@ -77,13 +78,13 @@ The files that are part of the Px component are:

## Requirements

A component **must** meet the following requirements to be considered part of the Px ecosystem:
A component **must** meet the following requirements to be considered part of the Predix UI ecosystem:

- Must provide a README
- Must provide an email address for support requests
- Must provide working examples in the test/ui/fixtures folder
- Must provide Sass that compiles down to regular CSS
- Must provide JavaScript unit tests if the component uses JavaScript.
- Must provide JavaScript unit tests.


## Tool Chain Reference
Expand All @@ -96,7 +97,7 @@ A component **must** meet the following requirements to be considered part of th

We use [Grunt](http://gruntjs.com/) to build all of our components and Design Extensions. Take some time to familiarize yourself with the [Grunt documentation.](http://gruntjs.com/)

The Component Seed comes with two built in grunt tasks: `grunt install` and simply `grunt`. The `grunt install` task will pull down all of your dependencies using Bower and generate a RequireJS config file for you. The basic `grunt` task will just attempt to compile all of your LESS files to CSS. Under the hood `grunt install` will call `grunt` as its final step, so you should only need to run `grunt` if you've made style changes post-install.
The Component Seed comes with two built in grunt tasks: `grunt install` and simply `grunt`. The `grunt install` task will pull down all of your dependencies using Bower and generate a RequireJS config file for you. The basic `grunt` task will just attempt to compile all of your SASS files to CSS. Under the hood `grunt install` will call `grunt` as its final step, so you should only need to run `grunt` if you've made style changes post-install.

### Bower

Expand All @@ -112,7 +113,7 @@ By default the task will attempt to compile all Sass files in the `src/sass/` fo

### RECOMMENDED READING

[SMACSS](http://smacss.com/) - Scalable and Modular Architecture for CSS
[Inuit CSS](https://github.com/inuitcss/getting-started) - Scalable and Modular Architecture for CSS

[Javascript the Good Parts](http://shop.oreilly.com/product/9780596517748.do) - Insights into Javascript by Douglas Crockford

Expand All @@ -138,7 +139,7 @@ There are two things that can be going wrong in this situation.
### When I run `bower install`, bower fetches megabytes or gigabytes of stuff...what's up with that?

Bower can fetch any git repository, whether or not the target repository provides a bower.json configuration file.
Many git repositories are not bower-optimized with an `ignore` block in bower.json to prevent a client project (e.g. your Px-Component) from getting all of the target dependency's test, docs, etc. There are a few common strategies to deal with this, in order of preference:
Many git repositories are not bower-optimized with an `ignore` block in bower.json to prevent a client project (e.g. your Predix UI Component) from getting all of the target dependency's test, docs, etc. There are a few common strategies to deal with this, in order of preference:

1. Use an officially maintained, bower-optimized "shim" repository where possible. Could be in github's ["shim"](https://github.com/components/components) area or a specific maintained fork of a given project, e.g. [requirejs](https://github.com/jrburke/requirejs-bower).
2. Use "ignore" in bower.json for Px-Components to hide our own unneeded files from downstream projects.
Expand All @@ -147,7 +148,7 @@ Many git repositories are not bower-optimized with an `ignore` block in bower.js

#### You made code changes but you didn't create a new tag

Bower works off of tags, so if you add code to your component you have to version up the tag. This is why [semver](http://semver.org/) is so important. You want all those version numbers to mean something. If you haven't created a new tag **and pushed it to the remote** then you won't see any changes.
Bower works off of tags, so if you add code to your component you have to version up the tag. This is why [semver](http://semver.org/) is so important. You want all those version numbers to mean something. If you haven't created a new tag **and pushed it to the remote server** then you won't see any changes.

To create a local tag:
``` bash
Expand All @@ -166,7 +167,7 @@ $ git tag -d v0.1.0

To delete a tag on your remote:
``` bash
# WARNING! Make sure no one is using the tag!
# WARNING! Make sure no one is using the tag! This is NOT recommended.
$ git push origin :/refs/tags/v0.1.0
```

Expand Down
105 changes: 44 additions & 61 deletions app/templates/_README.md
Original file line number Diff line number Diff line change
@@ -1,97 +1,80 @@
<%= titleize(name) %>
-----------------------------------------------
#<%= titleize(name) %>

## Overview

<%= titleize(name) %> is a Predix Experience ('Px') component
<%= titleize(name) %> is a Predix UI component

## Getting Started
## Usage

Read https://github.com/pages/PX/technical-principles/
### Prerequisites
1. node.js
2. npm
3. bower
4. [webcomponents-lite.js polyfill](https://github.com/webcomponents/webcomponentsjs)

From the component's directory...
Node, npm and bower are necessary to install the component and dependencies. webcomponents.js adds support for web components and custom elements to your application.

```
$ npm install
$ bower install
$ grunt sass
```

### API and examples
## Getting Started

From the component's directory
First, install the component via bower on the command line.

```
$ grunt depserve
bower install <%= titleize(name) %> --save
```

Starts a local server. Navigate to the root of that server (e.g. http://localhost:8080/) in a browser to open the API documentation page, with link to the "Demo" / working examples.

### LiveReload

By default grunt depserve is configured to enable LiveReload and will be watching for modifications in your root directory as well as `/css`.
Second, import the component to your application with the following tag in your head.

Your browser will also need to have the LiveReload extension installed and enabled. For instructions on how to do this please refer to [livereload.com/extensions/](http://livereload.com/extensions/).

Add, remove, modify file system patterns specified in the `depserve.options.livereload` array in your `Gruntfile.js`
```
<link rel="import" href="/bower_components/<%= titleize(name) %>/<%= titleize(name) %>.html"/>
```

This is an example depserve configuration:
Finally, use the component in your application:

```
depserve: {
options: {
open: '&lt;%= depserveOpenUrl %&gt;,
livereload: [__dirname + "/js", __dirname + "/css", __dirname]
}
}
Insert Your demo code here.
```

Disable LiveReload by removing the `livereload` key from the configuration object.
<br />
<hr />

### DevMode
## documentation

From the component's directory run:
Read the full API and view the demo [here](https://predixdev.github.io/<%= titleize(name) %>).

```
$ grunt devmode
```

Starts a local server exactly the same as if you had run `grunt depserve` however in addition it also runs `grunt watch` concurrently which will execute commands on file change according to the specified matching patterns.
## Local Development

This is an example `grunt watch` configuration which watches for changes to SASS files, then on changes executes SASS compilation and automatic prefixing:
From the component's directory...

```
watch: {
sass: {
files: ['sass/**/*.scss'],
tasks: ['sass', 'autoprefixer'],
options: {
interrupt: true
}
}
}
$ npm install
$ bower install
$ grunt sass
```

### Options

Does this component have runtime configuration options? If so, they should be able to be passed as attributes on the element with examples shown below.

### Function calls

What is the public API of this component?
From the component's directory, to start a local server run:

### Extending styles
```
$ grunt depserve
```

Documented CSS extension points?
Navigate to the root of that server (e.g. http://localhost:8080/) in a browser to open the API documentation page, with link to the "Demo" / working examples.

### Extending behavior

See Polymer composition patterns
### DevMode
Devmode runs `grunt depserve` and `grunt watch` concurrently so that when you make a change to your source files and save them, your preview will be updated in any browsers you have opened and turned on LiveReload.
From the component's directory run:

GE Coding Style Guide
---------------------
```
$ grunt devmode
```

### GE Coding Style Guide
[GE JS Developer's Guide](https://github.com/GeneralElectric/javascript)

<br />
<hr />

## Known Issues

### Known Issues
Please use [Github Issues](https://github.com/PredixDev/<%= titleize(name) %>/issues) to submit any bugs you might find.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "generator-px-comp",
"version": "0.0.8",
"description": "A Px component generator for Yeoman",
"version": "0.0.9",
"description": "A Predix UI Component Generator Using Yeoman",
"keywords": [
"yeoman-generator"
],
Expand Down

0 comments on commit 03f6d19

Please sign in to comment.