Skip to content

Angular cli compatibility #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

npm-debug.log*

# Dependency directory
node_modules
typings
Expand All @@ -11,19 +8,18 @@ typings
# Optional REPL history
.node_repl_history

# output/generated
dist
bundles
npm-debug.log*
**/*.js
**/*.js.map
**/*.d.ts

/*.js
/*.js.map
#/*.d.ts

app/**/*.js
app/**/*.js.map
app/**/*.d.ts

demos/*/app/**/*.js
demos/*/app/**/*.map
demos/*/app/**/*.d.ts
# Workspace Settings
.idea/workspace.xml
.vscode

.idea/workspace.xml
# DO NOT ignore (must come last)
!demos/*/systemjs.config.js
!src/typings.d.ts
3 changes: 0 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,3 @@ tsconfig.json
typings.json

.travis.yml

#TODO: Modify build process so it doesn't need this file at all.
core.ts
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# [Summary of Changes](https://github.com/TheFirstDeity/angular2-logger/blob/master/docs/dev/CHANGES.md)
https://github.com/TheFirstDeity/angular2-logger/blob/master/docs/dev/CHANGES.md

---

# Angular2-Logger

[![Build Status](https://travis-ci.org/code-chunks/angular2-logger.svg?branch=master)](https://travis-ci.org/code-chunks/angular2-logger)
[![npm version](https://badge.fury.io/js/angular2-logger.svg)](https://badge.fury.io/js/angular2-logger)
[![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)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/raw/code-chunks/angular2-logger/master/LICENSE)
[![Support](https://supporter.60devs.com/api/b/cjv93jwfwck3yp8z2mn1d9gay)](https://supporter.60devs.com/give/cjv93jwfwck3yp8z2mn1d9gay)

## What is it?

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

1. Install the npm module.

npm install --save angular2-logger

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:

In `systemjs.config.js`:

// map tells the System loader where to look for things
var map = {
'app': 'app', // 'dist',
Expand All @@ -32,7 +36,7 @@ This is a work in progress and is not ready for production, use with care, the A
'rxjs': 'node_modules/rxjs',
'angular2-logger': 'node_modules/angular2-logger' // ADD THIS
};

//packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'main.ts', defaultExtension: 'ts' },
Expand All @@ -43,14 +47,14 @@ This is a work in progress and is not ready for production, use with care, the A


3. Setup the Provider.

In `app.module.ts`:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { Logger } from "angular2-logger/core"; // ADD THIS

@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent ],
Expand All @@ -73,21 +77,21 @@ This is a work in progress and is not ready for production, use with care, the A
this._logger.log('This is a priority level 5 log message...');
}
}
By default the logger level will be set to `Level.WARN`, so you'll only see Warning and Error messages.

By default the logger level will be set to `Level.WARN`, so you'll only see Warning and Error messages.

### Going deeper...

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

- Dynamically using the console:

logger.level = logger.Level.LOG; // same as: logger.level = 5;
logger.level = logger.Level.LOG; // same as: logger.level = 5;

- Or using one of the predefined configuration providers:

import {LOG_LOGGER_PROVIDERS} from "angular2-logger/core";

@NgModule({
...
providers: [ LOG_LOGGER_PROVIDERS ]
Expand Down Expand Up @@ -116,7 +120,7 @@ If the Providers included don't meet your needs you can configure the default lo

@NgModule({
...
providers: [
providers: [
{ provide: Options, useValue: { store: false } },
Logger
]
Expand Down Expand Up @@ -163,19 +167,19 @@ You can also override the default configuration options by extending the Options
...
@NgModule({
...
providers: [
providers: [
{ provide: Options, useClass: CustomLoggerOptions },
Logger
]
})

Class names like `Options` and `Level` might be too common, if you get a conflict you can rename them like this:

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

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

- Quickstart guide now follows the pattern in Angular 2's Quickstart to add the references to other libs in `systemjs.config.js`.
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`.
- Quickstart guide now follows the pattern in Angular 2's Quickstart to add the references to other libs in `systemjs.config.js`.
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`.

## Breaking changes on 0.3.0
The codebase was updated to handle the breaking changes on Angular2's Release Candidate.
Expand Down
48 changes: 0 additions & 48 deletions core.d.ts

This file was deleted.

8 changes: 0 additions & 8 deletions core.ts

This file was deleted.

35 changes: 35 additions & 0 deletions docs/dev/CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Status

#### **Requirements**
- [ ] Tested with both es5 & es6 project
- [ ] Demos, make them to play
- [ ] Satisfied with the file/directory structure
- [ ] All files have cool little headings and stuff

#### **Experiments**
- [ ] Update angular dep to `rc6`
- [ ] Update Typescript dep
- [ ] Refactor for ts2 features

# Changes

## **0.4.666**
- #### **Directories & Modules**
- renamed `app` to `src` since this is more of a library
- 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`.)
- **Feature:** Bundlers like Webpack may automatically pick the proper es5 or es6 `js` depending on their target configuration. Works with the `angular-cli`.
- **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.
- **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._
- #### **package.json**
- `"main"` points at the es5 entry point, which is the umd `index.js` right now (TODO: point at bundle)
- `"module"` points at the es6 entry point, overriding `main`. This behavior has been adopted for es6 compatible builds using Webpack (`angular-cli` uses it.)
- `"typings"` points to the `.d.ts` entry point.
- `"compile"` tasks now pass configuration to the compiler to avoid duplicate `tsconfig.json` files
- `"clean"` now uses `del-cli` for safer deletes with simpler glob patterns
- #### **typings.json**
- `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
- #### **Miscellanious**
- Organized `.gitignore` entries

## **0.4.5**
...
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
{
"name": "angular2-logger",
"version": "0.4.5",
"version": "0.4.666",
"description": "A Log4j inspired Logger for Angular 2.",
"repository": {
"type": "git",
"url": "git+https://github.com/code-chunks/angular2-logger"
},
"main": "es5/index.js",
"module": "index.js",
"typings": "index.d.ts",

"scripts": {
"tsc": "tsc",
"typings": "typings",
"uglifyjs": "uglifyjs",
"tslint": "tslint *.ts src/**/*.ts",
"lint": "npm run tslint",
"prepublish": "npm run build",
"clean": "rimraf *.js *.map app/**/*.js app/**/*.map app/**/*.d.ts demos/*/app**/*.js demos/*/app/*.map demos/*/app/*.d.ts dist bundles",
"clean": "del-cli modules/ bundles/ es5/ **/*{.js,.map,.d.ts} !src/typings.d.ts !demos/*/systemjs.config.js !{node_modules,typings}/** ",
"precompile": "typings install",
"compile": "npm run compile:es5 && npm run compile:sys && npm run compile:es6",
"compile:amd": "tsc -p tsconfig-amd.json",
"compile:sys": "tsc -p tsconfig-sys.json",
"compile:es5": "tsc -p tsconfig-es5.json",
"compile:es6": "tsc -p tsconfig-es6.json",
"compile:es2015": "tsc -p tsconfig-es2015.json",
"compile": "npm run compile:es6 && npm run compile:umd && npm run compile:sys",
"compile:es6": "tsc -p src/tsconfig.json --declaration",
"compile:umd": "tsc -p src/tsconfig.json -m umd -t es5 --outDir es5",
"compile:sys": "tsc -p src/tsconfig.json -m system -t es5 --outFile bundles/angular2-logger.sys.js",
"pretest": "npm run lint",
"test": "echo tests pending...",
"prebuild": "npm run clean && npm run compile && npm run test",
Expand Down Expand Up @@ -71,20 +73,20 @@
"homepage": "https://github.com/code-chunks/angular2-logger#readme",
"dependencies": {},
"devDependencies": {
"rimraf": "^2.5.2",
"tslint": "^3.8.1",
"typescript": "1.8.10",
"typings": "^1.0.3",
"uglify-js": "^2.6.2",
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"systemjs": "0.19.37",
"core-js": "^2.4.0",
"del-cli": "0.2.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"systemjs": "0.19.37",
"tslint": "^3.8.1",
"typescript": "1.8.10",
"typings": "^1.0.3",
"uglify-js": "^2.6.2",
"zone.js": "^0.6.12"
},
"peerDependencies": {
Expand All @@ -93,6 +95,5 @@
"@angular/core": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5"
},
"main": "core.js"
}
}
6 changes: 6 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @module
* @description
* Entry point for all public APIs of the core bundle.
*/
export * from './modules/core/';
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @module
* @description
* Main entry point that doesn't currently export anything. Use 'angular2-logger/core'.
*/
export let message: string = 'should probably export cool stuff like NgModules';
8 changes: 8 additions & 0 deletions src/modules/core/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @module
* @description
* Public API.
*/
export * from "./level";
export * from "./logger";
export * from "./providers";
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions tsconfig-es6.json → src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"removeComments": true,

"noLib": true,
"target": "es6",
"module": "es2015",
"moduleResolution": "node",
"outDir": "./dist/es6",
"rootDir": ".",
"sourceMap": true,
"target": "es6"
"outDir": "../",
"rootDir": "."
},
"files": [
"core.ts"
],
"angularCompilerOptions": {
"strictMetadataEmit": true
}
}
}
Loading