Coder Social home page Coder Social logo

elvisfernandes / generator-angular2-library Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jvandemo/generator-angular2-library

0.0 2.0 0.0 47 KB

Yeoman generator to create an Angular 2 library

License: MIT License

JavaScript 77.90% TypeScript 22.10%

generator-angular2-library's Introduction

generator-angular-2-library NPM version Build Status

Yeoman generator to create a standalone Angular 2 library in seconds.

If you want to create an Angular 2 library with directives, services and/or pipes, then this generator is just what you need.

The generator:

  • creates and configures package.json for your library
  • creates and configures tsconfig.json for your library
  • creates and configures tslint.json for your library
  • creates and configures typings.json for your library
  • creates and configures .gitignore, .npmignore and .travis.yml
  • creates the main library file
  • creates a sample directive, component, service and pipe
  • creates boilerplate code to conveniently export PROVIDERS, DIRECTIVES and PIPES properties
  • creates a default export for future compatibility with angular cli, see this discussion for more
  • configures tslint for you with codelyzer support

Quick start

generator-angular2-library-demo

First, install Yeoman and generator-angular2-library using npm (assuming you already have node.js pre-installed).

$ npm install -g yo
$ npm install -g generator-angular2-library

make a new directory and cd into it:

$ mkdir angular2-library-name
$ cd angular2-library-name

and generate your new library:

$ yo angular2-library

The generator will prompt you for:

? Your full name: Jurgen Van de Moere
? Your email address: [email protected]
? Your library name (kebab case): angular2-library-name
? Git repository url: https://github.com/jvandemo/angular2-library-name

and create the following files for you:

.
├── .gitignore
├── .npmignore
├── .travis.yml
├── package.json
├── README.md
├── src
│   ├── directives
│   │   ├── sample.component.ts
│   │   └── sample.directive.ts
│   ├── directives.ts
│   ├── index.ts
│   ├── pipes
│   │   └── sample.pipe.ts
│   ├── pipes.ts
│   ├── services
│   │   └── sample.service.ts
│   └── services.ts
├── tsconfig.json
├── tslint.json
└── typings.json

You can then add or edit *.ts files in the src/ directory and run:

$ npm run tsc

to automatically create all *.js, *.js.map and *.d.ts files in the dist/ directory.

Tslint

Everything comes pre-configured with tslint and codelyzer support. To lint your code:

$ npm run lint

PROVIDERS, DIRECTIVES and PIPES

The generator automatically prepares boilerplate code to export convenient bundle properties.

As a library author you are free to choose whether you want to do this or not (see this discussion).

The benefit is that consumers of your library can easily import bundles of services, directives and pipes:

import { Component } from 'angular2/core';
import { PROVIDERS, DIRECTIVES, PIPES } from 'angular2-library-name/angular2-library-name';

@Component({
  selector: 'app'
  providers: [PROVIDERS]
  directives: [DIRECTIVES],
  pipes: [PIPES]
})
export class AppComponent{
  // ...
}

The Angular team uses a similar approach with CORE_DIRECTIVES, FORM_DIRECTIVES and ROUTER_PROVIDERS.

To do

  • Create build process for building library that automatically registers with SystemJS so it can be hosted statically and imported using <script> element
  • Create process for running unit tests

Issues

Please report bugs and issues here.

Development

To run the generator unit tests:

$ npm run test

License

MIT © Jurgen Van de Moere

Change log

v2.2.0

  • Updated dependencies in package.json to Angular 2 final

v2.1.0

  • Updated templates to Angular 2.0.0 RC3 syntax

v2.0.0

  • Updated with file structure using src and dist directory

v1.1.1

  • Updated templates to Angular 2.0.0 RC1 syntax

v1.1.0

  • Added codelyzer support
  • Added tslint support
  • Added typings support

v1.0.0

v0.6.0

  • Updated dependency versions

v0.5.0

  • Added browser.d.ts to files in tsconfig.json instead of using tripleslash (see #9)

v0.4.0

  • Added reference to Angular typings

v0.3.1

  • Removed explicit RxJS dependency

v0.3.0

  • Updated to Angular 2 beta

v0.2.0

  • Added documentation
  • Added support for PROVIDERS, DIRECTIVES and PIPES

v0.1.0

  • Added documentation
  • Added boilerplate scaffolding
  • Initial version

generator-angular2-library's People

Contributors

andrewmcwatters avatar jvandemo avatar nathanwalker avatar patrickjs avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.