Skip to content

Commit 146608b

Browse files
Angular cli compatibility (#1)
* ignore VS Code workspace settings * refactored compile (tsconfig, src/) * fix(build) refactored build scripts & typings * finished build refactoring, verified on other proj * cleared TODO item * removed donation link for now
1 parent c955318 commit 146608b

21 files changed

+119
-247
lines changed

.gitignore

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
npm-debug.log*
3-
41
# Dependency directory
52
node_modules
63
typings
@@ -11,19 +8,18 @@ typings
118
# Optional REPL history
129
.node_repl_history
1310

11+
# output/generated
1412
dist
1513
bundles
14+
npm-debug.log*
15+
**/*.js
16+
**/*.js.map
17+
**/*.d.ts
1618

17-
/*.js
18-
/*.js.map
19-
#/*.d.ts
20-
21-
app/**/*.js
22-
app/**/*.js.map
23-
app/**/*.d.ts
24-
25-
demos/*/app/**/*.js
26-
demos/*/app/**/*.map
27-
demos/*/app/**/*.d.ts
19+
# Workspace Settings
20+
.idea/workspace.xml
21+
.vscode
2822

29-
.idea/workspace.xml
23+
# DO NOT ignore (must come last)
24+
!demos/*/systemjs.config.js
25+
!src/typings.d.ts

.npmignore

-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,3 @@ tsconfig.json
2222
typings.json
2323

2424
.travis.yml
25-
26-
#TODO: Modify build process so it doesn't need this file at all.
27-
core.ts

README.md

+21-17
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
# [Summary of Changes](https://github.com/TheFirstDeity/angular2-logger/blob/master/docs/dev/CHANGES.md)
2+
https://github.com/TheFirstDeity/angular2-logger/blob/master/docs/dev/CHANGES.md
3+
4+
---
5+
16
# Angular2-Logger
27

38
[![Build Status](https://travis-ci.org/code-chunks/angular2-logger.svg?branch=master)](https://travis-ci.org/code-chunks/angular2-logger)
49
[![npm version](https://badge.fury.io/js/angular2-logger.svg)](https://badge.fury.io/js/angular2-logger)
510
[![Join the chat at https://gitter.im/code-chunks/angular2-logger](https://badges.gitter.im/code-chunks/angular2-logger.svg)](https://gitter.im/code-chunks/angular2-logger?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
611
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/code-chunks/angular2-logger/master/LICENSE)
7-
[![Support](https://supporter.60devs.com/api/b/cjv93jwfwck3yp8z2mn1d9gay)](https://supporter.60devs.com/give/cjv93jwfwck3yp8z2mn1d9gay)
812

913
## What is it?
1014

@@ -17,13 +21,13 @@ This is a work in progress and is not ready for production, use with care, the A
1721
### Quickstart
1822

1923
1. Install the npm module.
20-
24+
2125
npm install --save angular2-logger
2226

2327
2. Add the `angular2-logger` library to your app. If you are following the [Angular 2's Quickstart Guide](https://angular.io/docs/ts/latest/quickstart.html) it should be something like this:
2428

2529
In `systemjs.config.js`:
26-
30+
2731
// map tells the System loader where to look for things
2832
var map = {
2933
'app': 'app', // 'dist',
@@ -32,7 +36,7 @@ This is a work in progress and is not ready for production, use with care, the A
3236
'rxjs': 'node_modules/rxjs',
3337
'angular2-logger': 'node_modules/angular2-logger' // ADD THIS
3438
};
35-
39+
3640
//packages tells the System loader how to load when no filename and/or no extension
3741
var packages = {
3842
'app': { main: 'main.ts', defaultExtension: 'ts' },
@@ -43,14 +47,14 @@ This is a work in progress and is not ready for production, use with care, the A
4347

4448

4549
3. Setup the Provider.
46-
50+
4751
In `app.module.ts`:
4852

4953
import { NgModule } from '@angular/core';
5054
import { BrowserModule } from '@angular/platform-browser';
5155
import { AppComponent } from './app.component';
5256
import { Logger } from "angular2-logger/core"; // ADD THIS
53-
57+
5458
@NgModule({
5559
imports: [ BrowserModule ],
5660
declarations: [ AppComponent ],
@@ -73,21 +77,21 @@ This is a work in progress and is not ready for production, use with care, the A
7377
this._logger.log('This is a priority level 5 log message...');
7478
}
7579
}
76-
77-
By default the logger level will be set to `Level.WARN`, so you'll only see Warning and Error messages.
80+
81+
By default the logger level will be set to `Level.WARN`, so you'll only see Warning and Error messages.
7882

7983
### Going deeper...
8084

8185
In order to see all of the messages you just need to change the logger message hierarchy level, you can do so:
8286

8387
- Dynamically using the console:
8488

85-
logger.level = logger.Level.LOG; // same as: logger.level = 5;
86-
89+
logger.level = logger.Level.LOG; // same as: logger.level = 5;
90+
8791
- Or using one of the predefined configuration providers:
8892

8993
import {LOG_LOGGER_PROVIDERS} from "angular2-logger/core";
90-
94+
9195
@NgModule({
9296
...
9397
providers: [ LOG_LOGGER_PROVIDERS ]
@@ -116,7 +120,7 @@ If the Providers included don't meet your needs you can configure the default lo
116120

117121
@NgModule({
118122
...
119-
providers: [
123+
providers: [
120124
{ provide: Options, useValue: { store: false } },
121125
Logger
122126
]
@@ -163,19 +167,19 @@ You can also override the default configuration options by extending the Options
163167
...
164168
@NgModule({
165169
...
166-
providers: [
170+
providers: [
167171
{ provide: Options, useClass: CustomLoggerOptions },
168172
Logger
169173
]
170174
})
171-
175+
172176
Class names like `Options` and `Level` might be too common, if you get a conflict you can rename them like this:
173177

174178
import { Logger, Options as LoggerOptions, Level as LoggerLevel } from "angular2-logger/core";
175179

176180
@NgModule({
177181
...
178-
providers: [
182+
providers: [
179183
{ provide: LoggerOptions, useValue: { level: LoggerLevel.WARN } }
180184
]
181185
})
@@ -212,8 +216,8 @@ Done.
212216
The codebase was updated to handle the breaking changes on Angular2's Release Candidate 5.
213217
**Make sure you don't upgrade to this version if you haven't upgraded Angular2 to at least `2.0.0-rc.5`**
214218

215-
- Quickstart guide now follows the pattern in Angular 2's Quickstart to add the references to other libs in `systemjs.config.js`.
216-
However if you still want to do it the old way by adding the system bundle, you can still do so, except now its called `bundles/angular2-logger.sys.min.js`.
219+
- Quickstart guide now follows the pattern in Angular 2's Quickstart to add the references to other libs in `systemjs.config.js`.
220+
However if you still want to do it the old way by adding the system bundle, you can still do so, except now its called `bundles/angular2-logger.sys.min.js`.
217221

218222
## Breaking changes on 0.3.0
219223
The codebase was updated to handle the breaking changes on Angular2's Release Candidate.

core.d.ts

-48
This file was deleted.

core.ts

-8
This file was deleted.

docs/dev/CHANGES.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Status
2+
3+
#### **Requirements**
4+
- [ ] Tested with both es5 & es6 project
5+
- [ ] Demos, make them to play
6+
- [ ] Satisfied with the file/directory structure
7+
- [ ] All files have cool little headings and stuff
8+
9+
#### **Experiments**
10+
- [ ] Update angular dep to `rc6`
11+
- [ ] Update Typescript dep
12+
- [ ] Refactor for ts2 features
13+
14+
# Changes
15+
16+
## **0.4.666**
17+
- #### **Directories & Modules**
18+
- renamed `app` to `src` since this is more of a library
19+
- added `src/modules` to contain sub-packages in a way that works well with node module resolution. For example, `angular2-logger/subset` will elegantly point to whatever's exported by `src/modules/subset/index.ts`. (Just copy how I set up `core`'s files and make a `src/subset.ts`.)
20+
- **Feature:** Bundlers like Webpack may automatically pick the proper es5 or es6 `js` depending on their target configuration. Works with the `angular-cli`.
21+
- **Feature:** `src/index.ts` can be used to customize what can be imported from `angular2-logger`. It could be used as an alias for `angular2-logger/core`, or it could be like the greatest-hits from a bunch of little sub-packages.
22+
- **Query:** _Is it even worth it to have sub-packages like 'core' and whatever else? I feel like it might just be a bunch of extra typing & memorization for consumers of the api. Since `rc5`, we have NgModules to package sets of resources together._
23+
- #### **package.json**
24+
- `"main"` points at the es5 entry point, which is the umd `index.js` right now (TODO: point at bundle)
25+
- `"module"` points at the es6 entry point, overriding `main`. This behavior has been adopted for es6 compatible builds using Webpack (`angular-cli` uses it.)
26+
- `"typings"` points to the `.d.ts` entry point.
27+
- `"compile"` tasks now pass configuration to the compiler to avoid duplicate `tsconfig.json` files
28+
- `"clean"` now uses `del-cli` for safer deletes with simpler glob patterns
29+
- #### **typings.json**
30+
- `src/typings.d.ts` added to reference global types and `core-js` was removed from `typings.json`. Instead, the `es6` default lib is forced for all modules. This is done by setting `noLib` in `tsconfig.json` to stop the default lib from loading, and then explicitely referencing the es6 default (`lib.es6.d.ts`) in `typings.d.ts`. Typescript 2.0.0+ lets you do this out of the box, but this hack is needed for older versions
31+
- #### **Miscellanious**
32+
- Organized `.gitignore` entries
33+
34+
## **0.4.5**
35+
...

package.json

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
{
22
"name": "angular2-logger",
3-
"version": "0.4.5",
3+
"version": "0.4.666",
44
"description": "A Log4j inspired Logger for Angular 2.",
55
"repository": {
66
"type": "git",
77
"url": "git+https://github.com/code-chunks/angular2-logger"
88
},
9+
"main": "es5/index.js",
10+
"module": "index.js",
11+
"typings": "index.d.ts",
12+
913
"scripts": {
1014
"tsc": "tsc",
1115
"typings": "typings",
1216
"uglifyjs": "uglifyjs",
1317
"tslint": "tslint *.ts src/**/*.ts",
1418
"lint": "npm run tslint",
1519
"prepublish": "npm run build",
16-
"clean": "rimraf *.js *.map app/**/*.js app/**/*.map app/**/*.d.ts demos/*/app**/*.js demos/*/app/*.map demos/*/app/*.d.ts dist bundles",
20+
"clean": "del-cli modules/ bundles/ es5/ **/*{.js,.map,.d.ts} !src/typings.d.ts !demos/*/systemjs.config.js !{node_modules,typings}/** ",
1721
"precompile": "typings install",
18-
"compile": "npm run compile:es5 && npm run compile:sys && npm run compile:es6",
19-
"compile:amd": "tsc -p tsconfig-amd.json",
20-
"compile:sys": "tsc -p tsconfig-sys.json",
21-
"compile:es5": "tsc -p tsconfig-es5.json",
22-
"compile:es6": "tsc -p tsconfig-es6.json",
23-
"compile:es2015": "tsc -p tsconfig-es2015.json",
22+
"compile": "npm run compile:es6 && npm run compile:umd && npm run compile:sys",
23+
"compile:es6": "tsc -p src/tsconfig.json --declaration",
24+
"compile:umd": "tsc -p src/tsconfig.json -m umd -t es5 --outDir es5",
25+
"compile:sys": "tsc -p src/tsconfig.json -m system -t es5 --outFile bundles/angular2-logger.sys.js",
2426
"pretest": "npm run lint",
2527
"test": "echo tests pending...",
2628
"prebuild": "npm run clean && npm run compile && npm run test",
@@ -71,20 +73,20 @@
7173
"homepage": "https://github.com/code-chunks/angular2-logger#readme",
7274
"dependencies": {},
7375
"devDependencies": {
74-
"rimraf": "^2.5.2",
75-
"tslint": "^3.8.1",
76-
"typescript": "1.8.10",
77-
"typings": "^1.0.3",
78-
"uglify-js": "^2.6.2",
7976
"@angular/common": "2.0.0-rc.5",
8077
"@angular/compiler": "2.0.0-rc.5",
8178
"@angular/core": "2.0.0-rc.5",
8279
"@angular/platform-browser": "2.0.0-rc.5",
8380
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
84-
"systemjs": "0.19.37",
8581
"core-js": "^2.4.0",
82+
"del-cli": "0.2.0",
8683
"reflect-metadata": "^0.1.3",
8784
"rxjs": "5.0.0-beta.6",
85+
"systemjs": "0.19.37",
86+
"tslint": "^3.8.1",
87+
"typescript": "1.8.10",
88+
"typings": "^1.0.3",
89+
"uglify-js": "^2.6.2",
8890
"zone.js": "^0.6.12"
8991
},
9092
"peerDependencies": {
@@ -93,6 +95,5 @@
9395
"@angular/core": "2.0.0-rc.5",
9496
"@angular/platform-browser": "2.0.0-rc.5",
9597
"@angular/platform-browser-dynamic": "2.0.0-rc.5"
96-
},
97-
"main": "core.js"
98+
}
9899
}

src/core.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @module
3+
* @description
4+
* Entry point for all public APIs of the core bundle.
5+
*/
6+
export * from './modules/core/';

src/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @module
3+
* @description
4+
* Main entry point that doesn't currently export anything. Use 'angular2-logger/core'.
5+
*/
6+
export let message: string = 'should probably export cool stuff like NgModules';

src/modules/core/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @module
3+
* @description
4+
* Public API.
5+
*/
6+
export * from "./level";
7+
export * from "./logger";
8+
export * from "./providers";
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"compilerOptions": {
3-
"emitDecoratorMetadata": true,
3+
"sourceMap": true,
44
"experimentalDecorators": true,
5+
"emitDecoratorMetadata": true,
56
"removeComments": true,
7+
8+
"noLib": true,
9+
"target": "es6",
10+
"module": "es2015",
611
"moduleResolution": "node",
7-
"outDir": "./dist/es6",
8-
"rootDir": ".",
9-
"sourceMap": true,
10-
"target": "es6"
12+
"outDir": "../",
13+
"rootDir": "."
1114
},
12-
"files": [
13-
"core.ts"
14-
],
1515
"angularCompilerOptions": {
1616
"strictMetadataEmit": true
1717
}
18-
}
18+
}

0 commit comments

Comments
 (0)