diff --git a/README.md b/README.md index ca9deca..b274e17 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ng2-dropdown +# ngx-dropdown Simple dropdown for your angular2 applications using bootstrap3. Does not depend of jquery. If you don't want to use it without bootstrap - simply create proper css classes. @@ -8,17 +8,17 @@ Please star a project if you liked it, or create an issue if you have problems w 1. Install npm module: - `npm install ng2-dropdown --save` + `npm install ngx-dropdown --save` 2. If you are using system.js you may want to add this into `map` and `package` config: ```json { "map": { - "ng2-dropdown": "node_modules/ng2-dropdown" + "ngx-dropdown": "node_modules/ngx-dropdown" }, "packages": { - "ng2-dropdown": { "main": "index.js", "defaultExtension": "js" } + "ngx-dropdown": { "main": "index.js", "defaultExtension": "js" } } } ``` @@ -49,7 +49,7 @@ Please star a project if you liked it, or create an issue if you have problems w ```typescript import {Component} from "@angular/core"; -import {DropdownModule} from "ng2-dropdown"; +import {DropdownModule} from "ngx-dropdown"; @Component({ selector: "app", @@ -116,5 +116,5 @@ export class AppModule { platformBrowserDynamic().bootstrapModule(AppModule); ``` -Take a look on samples in [./sample](https://github.com/pleerock/ng2-dropdown/tree/master/sample) for more examples of +Take a look on samples in [./sample](https://github.com/pleerock/ngx-dropdown/tree/master/sample) for more examples of usages. diff --git a/gulpfile.ts b/gulpfile.ts index ca24596..0904049 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -9,7 +9,11 @@ const chai = require("chai"); const tslint = require("gulp-tslint"); const stylish = require("tslint-stylish"); const ts = require("gulp-typescript"); -const sourcemaps = require("gulp-sourcemaps"); +const rename = require("gulp-rename"); +const file = require("gulp-file"); +const uglify = require("gulp-uglify"); + +const packageName = require("./package.json").name; @Gulpclass() export class Gulpfile { @@ -42,34 +46,112 @@ export class Gulpfile { // ------------------------------------------------------------------------- /** - * Publishes a package to npm from ./build/package directory. + * Compiles and compiles bundles. + */ + @MergedTask() + compileBundles() { + const amdTsProject = ts.createProject("tsconfig.json", { + module: "amd", + outFile: packageName + ".amd.js", + typescript: require("typescript") + }); + const systemTsProject = ts.createProject("tsconfig.json", { + module: "system", + outFile: packageName + ".system.js", + typescript: require("typescript") + }); + const amdPureTsProject = ts.createProject("tsconfig.json", { + module: "amd", + outFile: packageName + ".pure.amd.js", + noEmitHelpers: true, + noImplicitUseStrict: true, + typescript: require("typescript") + }); + const systemPureTsProject = ts.createProject("tsconfig.json", { + module: "system", + outFile: packageName + ".pure.system.js", + noEmitHelpers: true, + noImplicitUseStrict: true, + typescript: require("typescript") + }); + + return [ + gulp.src("build/bundle/**/*.ts") + .pipe(amdTsProject()).js + .pipe(gulp.dest("build/package")), + + gulp.src("build/bundle/**/*.ts") + .pipe(systemTsProject()).js + .pipe(gulp.dest("build/package")), + + gulp.src("build/bundle/**/*.ts") + .pipe(amdPureTsProject()).js + .pipe(gulp.dest("build/package")), + + gulp.src("build/bundle/**/*.ts") + .pipe(systemPureTsProject()).js + .pipe(gulp.dest("build/package")) + ]; + } + + /** + * Copies all source files into destination folder in a correct structure to build bundles. */ @Task() - npmPublish() { - return gulp.src("package.json", { read: false }) - .pipe(shell([ - "cd ./build/package && npm publish" - ])); + bundleCopySources() { + return gulp.src(["./src/**/*.ts"]) + .pipe(gulp.dest("./build/bundle/" + packageName)); } /** - * Copies all sources to the package directory. + * Creates special main file for bundle build. */ - @MergedTask() - packageCompile() { - const tsProject = ts.createProject("tsconfig.json"); - const tsResult = gulp.src(["./src/**/*.ts", "./typings/**/*.ts"]) - .pipe(sourcemaps.init()) - .pipe(ts(tsProject)); + @Task() + bundleCopyMainFile() { + return gulp.src("./package.json", { read: false }) + .pipe(file(packageName + ".ts", `export * from "./${packageName}/index";`)) + .pipe(gulp.dest("./build/bundle")); + } + /** + * Uglifys bundles. + */ + @MergedTask() + uglify() { return [ - tsResult.dts.pipe(gulp.dest("./build/package")), - tsResult.js - .pipe(sourcemaps.write(".", { sourceRoot: "", includeContent: true })) - .pipe(gulp.dest("./build/package")) + gulp.src(`./build/package/${packageName}.pure.amd.js`) + .pipe(uglify()) + .pipe(rename(`${packageName}.pure.amd.min.js`)) + .pipe(gulp.dest("./build/package")), + + gulp.src(`./build/package/${packageName}.pure.system.js`) + .pipe(uglify()) + .pipe(rename(`${packageName}.pure.system.min.js`)) + .pipe(gulp.dest("./build/package")), + + gulp.src(`./build/package/${packageName}.amd.js`) + .pipe(uglify()) + .pipe(rename(`${packageName}.amd.min.js`)) + .pipe(gulp.dest("./build/package")), + + gulp.src(`./build/package/${packageName}.system.js`) + .pipe(uglify()) + .pipe(rename(`${packageName}.system.min.js`)) + .pipe(gulp.dest("./build/package")), ]; } + /** + * Publishes a package to npm from ./build/package directory. + */ + @Task() + npmPublish() { + return gulp.src("package.json", { read: false }) + .pipe(shell([ + "cd ./build/package && npm publish" + ])); + } + /** * Change the "private" state of the packaged package.json file to public. */ @@ -91,15 +173,6 @@ export class Gulpfile { .pipe(gulp.dest("./build/package")); } - /** - * This task will copy typings.json file to the build package. - */ - @Task() - copyTypingsFile() { - return gulp.src("./typings.json") - .pipe(gulp.dest("./build/package")); - } - /** * Creates a package that can be published to npm. */ @@ -107,8 +180,10 @@ export class Gulpfile { package() { return [ "clean", - "compile", - ["packagePreparePackageFile", "packageReadmeFile", "copyTypingsFile"] + ["bundleCopySources", "bundleCopyMainFile"], + ["compile", "compileBundles"], + ["uglify"], + ["packagePreparePackageFile", "packageReadmeFile"] ]; } diff --git a/package.json b/package.json index 0375906..a7338a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "ng2-dropdown", - "version": "0.0.21", + "name": "ngx-dropdown", + "version": "0.0.22", "description": "Simple dropdown for your angular2 applications using bootstrap3.", "license": "MIT", "readmeFilename": "README.md", @@ -11,10 +11,10 @@ }, "repository": { "type": "git", - "url": "https://github.com/pleerock/ng2-dropdown.git" + "url": "https://github.com/pleerock/ngx-dropdown.git" }, "bugs": { - "url": "https://github.com/pleerock/ng2-dropdown/issues" + "url": "https://github.com/pleerock/ngx-dropdown/issues" }, "tags": [ "dropdown", @@ -27,37 +27,38 @@ "@angular/core": "^2.0.0" }, "devDependencies": { - "@angular/common": "^2.2.0", - "@angular/compiler": "^2.2.0", - "@angular/core": "^2.2.0", - "@angular/platform-browser": "^2.2.0", - "@angular/platform-browser-dynamic": "^2.2.0", - "@angular/compiler-cli": "^2.2.3", - "@angular/platform-server": "^2.2.3", - "@types/node": "^6.0.42", - "bootstrap": "^3.3.6", + "@angular/common": "^2.4.3", + "@angular/compiler": "^2.4.3", + "@angular/compiler-cli": "^2.4.3", + "@angular/core": "^2.4.3", + "@angular/forms": "^2.4.3", + "@angular/platform-browser": "^2.4.3", + "@angular/platform-browser-dynamic": "^2.4.3", + "@types/node": "^7.0.0", + "bootstrap": "^3.3.7", "chai": "^3.4.1", - "del": "^2.2.0", - "es6-promise": "^3.0.2", - "es6-shim": "^0.33.3", + "del": "^2.2.2", + "es6-shim": "^0.35.2", "gulp": "^3.9.0", - "gulp-mocha": "^2.2.0", + "gulp-file": "^0.3.0", + "gulp-mocha": "^3.0.1", + "gulp-rename": "^1.2.2", "gulp-replace": "^0.5.4", "gulp-shell": "^0.5.1", - "gulp-sourcemaps": "^1.6.0", - "gulp-tslint": "^6.1.2", - "gulp-typescript": "^3.0.2", + "gulp-tslint": "^7.0.1", + "gulp-typescript": "^3.1.4", + "gulp-uglify": "^2.0.0", "gulpclass": "^0.1.1", - "mocha": "^2.3.2", - "reflect-metadata": "0.1.2", - "rxjs": "5.0.0-beta.12", - "sinon": "^1.17.2", + "mocha": "^3.2.0", + "reflect-metadata": "0.1.9", + "rxjs": "^5.0.3", + "sinon": "^1.17.7", "sinon-chai": "^2.8.0", - "systemjs": "0.19.27", - "tslint": "^3.15.1", + "systemjs": "0.19.42", + "tslint": "^4.3.1", "tslint-stylish": "^2.1.0-beta", - "typescript": "^2.0.3", - "zone.js": "^0.6.25" + "typescript": "^2.1.5", + "zone.js": "^0.7.6" }, "scripts": { "tsc": "ngc -p ." diff --git a/sample/sample1-simple-usage/index.html b/sample/sample1-simple-usage/index.html index bd29117..abdda4f 100644 --- a/sample/sample1-simple-usage/index.html +++ b/sample/sample1-simple-usage/index.html @@ -3,7 +3,7 @@ - ng2-dropdown + ngx-dropdown @@ -13,7 +13,7 @@