Skip to content

Commit a74c6c6

Browse files
committed
initial
0 parents  commit a74c6c6

37 files changed

+12815
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
coverage
3+
typings

.vscode/keybindings.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"key": "ctrl+d",
3+
"command": "editor.action.copyLinesDownAction",
4+
"when": "editorTextFocus"
5+
}

.vscode/launch.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Launch",
6+
"type": "node",
7+
"request": "launch",
8+
"program": "${workspaceRoot}/index.js",
9+
"stopOnEntry": false,
10+
"args": [],
11+
"cwd": "${workspaceRoot}",
12+
"preLaunchTask": null,
13+
"runtimeExecutable": null,
14+
"runtimeArgs": [
15+
"--nolazy"
16+
],
17+
"env": {
18+
"NODE_ENV": "development"
19+
},
20+
"externalConsole": false,
21+
"sourceMaps": false,
22+
"outDir": null
23+
},
24+
{
25+
"name": "Attach",
26+
"type": "node",
27+
"request": "attach",
28+
"port": 5858,
29+
"address": "localhost",
30+
"restart": false,
31+
"sourceMaps": false,
32+
"outDir": null,
33+
"localRoot": "${workspaceRoot}",
34+
"remoteRoot": null
35+
}
36+
]
37+
}

.vscode/settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"files.exclude": {
3+
"**/.git": true,
4+
"**/.DS_Store": true,
5+
"source/**/*.js": true,
6+
"test/**/*.js": true
7+
}
8+
}

dist/app.min.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/app.min.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assets/css/main.css

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
h1 {
2+
font-size: 14pt; }

gulp.env.js

Whitespace-only changes.

gulpfile.js

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
"use strict";
2+
3+
//******************************************************************************
4+
//* DEPENDENCIES
5+
//******************************************************************************
6+
var gulp = require("gulp"),
7+
browserify = require("browserify"),
8+
sass = require('gulp-sass'),
9+
source = require("vinyl-source-stream"),
10+
buffer = require("vinyl-buffer"),
11+
tslint = require("gulp-tslint"),
12+
tsc = require("gulp-typescript"),
13+
sourcemaps = require("gulp-sourcemaps"),
14+
uglify = require("gulp-uglify"),
15+
runSequence = require("run-sequence"),
16+
mocha = require("gulp-mocha"),
17+
istanbul = require("gulp-istanbul"),
18+
browserSync = require('browser-sync').create();
19+
20+
//******************************************************************************
21+
//* LINT
22+
//******************************************************************************
23+
gulp.task("lint", function() {
24+
return gulp.src([
25+
"source/**/**.ts",
26+
"test/**/**.test.ts"
27+
])
28+
.pipe(tslint({ }))
29+
.pipe(tslint.report("verbose"));
30+
});
31+
32+
//******************************************************************************
33+
//* BUILD
34+
//******************************************************************************
35+
var tsProject = tsc.createProject("tsconfig.json");
36+
37+
gulp.task("build-app", function() {
38+
return gulp.src([
39+
"source/**/**.ts",
40+
"typings/main.d.ts/",
41+
"source/interfaces/interfaces.d.ts"
42+
])
43+
.pipe(tsc(tsProject))
44+
.js.pipe(gulp.dest("source/"));
45+
});
46+
47+
var tsTestProject = tsc.createProject("tsconfig.json");
48+
49+
gulp.task("build-test", function() {
50+
return gulp.src([
51+
"test/**/*.ts",
52+
"typings/main.d.ts/",
53+
"source/interfaces/interfaces.d.ts"
54+
])
55+
.pipe(tsc(tsTestProject))
56+
.js.pipe(gulp.dest("test/"));
57+
});
58+
59+
gulp.task('build-sass', function () {
60+
return gulp.src([
61+
"source/assets/sass/**/*.scss"
62+
])
63+
.pipe(sass().on('error', sass.logError))
64+
.pipe(gulp.dest('dist/assets/css'));
65+
});
66+
67+
gulp.task("build", function(cb) {
68+
runSequence(["build-app", "build-test", "build-sass"], cb);
69+
});
70+
71+
72+
//******************************************************************************
73+
//* TEST
74+
//******************************************************************************
75+
gulp.task("istanbul:hook", function() {
76+
return gulp.src(['source/**/*.js'])
77+
// Covering files
78+
.pipe(istanbul())
79+
// Force `require` to return covered files
80+
.pipe(istanbul.hookRequire());
81+
});
82+
83+
gulp.task("test", ["istanbul:hook"], function() {
84+
return gulp.src('test/**/*.test.js')
85+
.pipe(mocha({ui: 'bdd'}))
86+
.pipe(istanbul.writeReports());
87+
});
88+
89+
//******************************************************************************
90+
//* BUNDLE
91+
//******************************************************************************
92+
gulp.task("bundle", function() {
93+
94+
var libraryName = "app";
95+
var mainTsFilePath = "source/app.js";
96+
var outputFolder = "dist/";
97+
var outputFileName = libraryName + ".min.js";
98+
99+
var bundler = browserify({
100+
debug: true,
101+
standalone : libraryName
102+
});
103+
104+
return bundler.add(mainTsFilePath)
105+
.bundle()
106+
.pipe(source(outputFileName))
107+
.pipe(buffer())
108+
.pipe(sourcemaps.init({ loadMaps: true }))
109+
.pipe(uglify())
110+
.pipe(sourcemaps.write('./'))
111+
.pipe(gulp.dest(outputFolder));
112+
});
113+
114+
//******************************************************************************
115+
//* DEV SERVER
116+
//******************************************************************************
117+
gulp.task("watch", ["default"], function () {
118+
119+
browserSync.init({
120+
server: "./"
121+
});
122+
123+
gulp.watch([ "source/**/**.ts", "test/**/*.ts"], ["default"]);
124+
gulp.watch("dist/*.js").on('change', browserSync.reload);
125+
});
126+
127+
//******************************************************************************
128+
//* DEFAULT
129+
//******************************************************************************
130+
gulp.task("default", function (cb) {
131+
runSequence("lint", "build", "test", "bundle", cb);
132+
});

index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>Document</title>
8+
<link rel="stylesheet" type="text/css" href="./dist/assets/css/main.css">
9+
</head>
10+
<body>
11+
<ui-view></ui-view>
12+
<script src="./dist/app.min.js"></script>
13+
</body>
14+
</html>

package.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "component-library",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"dependencies": {
7+
"angular": "^1.5.3",
8+
"angular-foundation": "^0.8.0"
9+
},
10+
"devDependencies": {
11+
"browser-sync": "^2.12.3",
12+
"browserify": "^13.0.0",
13+
"chai": "^3.5.0",
14+
"gulp": "^3.9.1",
15+
"gulp-istanbul": "^0.10.4",
16+
"gulp-mocha": "^2.2.0",
17+
"gulp-sass": "^2.2.0",
18+
"gulp-sourcemaps": "^1.6.0",
19+
"gulp-tslint": "^4.3.5",
20+
"gulp-typescript": "^2.13.0",
21+
"gulp-uglify": "^1.5.3",
22+
"jquery": "^2.2.3",
23+
"run-sequence": "^1.1.5",
24+
"tslint": "^3.7.4",
25+
"typescript": "^1.8.10",
26+
"typings": "^0.7.12",
27+
"vinyl-buffer": "^1.0.0",
28+
"vinyl-source-stream": "^1.1.0"
29+
},
30+
"scripts": {
31+
"test": "echo \"Error: no test specified\" && exit 1"
32+
},
33+
"keywords": [],
34+
"author": "",
35+
"license": "ISC"
36+
}

source/app.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"use strict";
2+
var ng = require("angular");
3+
var App;
4+
(function (App) {
5+
var AppComponent = (function () {
6+
function AppComponent() {
7+
this._appModule = ng.module("app", ["ui.router"]);
8+
this._appModule.config(function ($locationProvider, $stateProvider, $routeProvider) {
9+
$locationProvider.html5Mode({
10+
enabled: true,
11+
requireBase: false,
12+
});
13+
$routeProvider.otherwise("/");
14+
});
15+
ng.bootstrap(document, [this._appModule.name]);
16+
}
17+
AppComponent.$inject = ["$routeProvider"];
18+
return AppComponent;
19+
}());
20+
App.AppComponent = AppComponent;
21+
})(App || (App = {}));

source/app.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import * as ng from "angular";
2+
3+
4+
namespace App {
5+
export class AppComponent {
6+
public static $inject = ["$routeProvider"];
7+
private _appModule: ng.IModule;
8+
constructor() {
9+
this._appModule = ng.module("app", ["ui.router"]);
10+
this._appModule.config((
11+
$locationProvider: ng.ILocationProvider,
12+
$stateProvider: ng.ui.IStateProvider,
13+
$routeProvider: ng.ui.IUrlRouterProvider) => {
14+
$locationProvider.html5Mode({
15+
enabled: true,
16+
requireBase: false,
17+
});
18+
$routeProvider.otherwise("/");
19+
// config ui-router
20+
/* $stateProvider.state("home", <ng.ui.IState>{
21+
url: "/",
22+
views: {
23+
"Home": {
24+
templateUrl: "source/components/home/home.component.html",
25+
},
26+
},
27+
});*/
28+
29+
});
30+
ng.bootstrap(document, [this._appModule.name]);
31+
}
32+
}
33+
}

source/assets/sass/main.scss

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$header-h1-size: 14pt;
2+
3+
h1 {
4+
font-size: $header-h1-size;
5+
}

source/components/greeter.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use strict";
2+
var Greeter = (function () {
3+
function Greeter(message) {
4+
this.greeting = message;
5+
}
6+
Greeter.prototype.greet = function () {
7+
return "Hello " + this.greeting;
8+
};
9+
return Greeter;
10+
}());
11+
exports.Greeter = Greeter;
12+
Object.defineProperty(exports, "__esModule", { value: true });
13+
exports.default = Greeter;

source/components/greeter.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export class Greeter implements GreeterInterface {
2+
public greeting: string;
3+
constructor(message: string) {
4+
this.greeting = message;
5+
}
6+
public greet(): string {
7+
return `Hello ${this.greeting}`;
8+
}
9+
}
10+
export default Greeter;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>Home</h1>

source/interfaces/greeter.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface GreeterInterface {
2+
greeting: string;
3+
greet: () => string;
4+
}

source/interfaces/interfaces.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="./greeter.d.ts" />

test/greeter.test.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use strict";
2+
var chai_1 = require("chai");
3+
var greeter_1 = require("../source/components/greeter");
4+
describe("Greeter class", function () {
5+
it("Should set msg when an instance is created", function () {
6+
var expected = "world!";
7+
var greater = new greeter_1.default(expected);
8+
chai_1.expect(greater.greeting).eql(expected);
9+
});
10+
it("Should greet", function () {
11+
var greet = "world!";
12+
var greater = new greeter_1.default(greet);
13+
var actual = greater.greet();
14+
var expected = "Hello " + greet;
15+
chai_1.expect(actual).eql(expected);
16+
});
17+
});

test/greeter.test.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { expect } from "chai";
2+
import Greeter from "../source/components/greeter";
3+
4+
describe("Greeter class", () => {
5+
it("Should set msg when an instance is created", () => {
6+
let expected = "world!";
7+
let greater = new Greeter(expected);
8+
expect(greater.greeting).eql(expected);
9+
});
10+
11+
it("Should greet", () => {
12+
let greet = "world!";
13+
let greater = new Greeter(greet);
14+
let actual = greater.greet();
15+
let expected = `Hello ${greet}`;
16+
expect(actual).eql(expected);
17+
});
18+
});

0 commit comments

Comments
 (0)