Skip to content

Commit

Permalink
refactor(core): refactor public API
Browse files Browse the repository at this point in the history
refactor(core): refactor public API

build: update npm scripts, gulp tasks, test config, tsconfig
  • Loading branch information
Burak Tasci committed Sep 4, 2017
1 parent 02088aa commit e43896f
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 183 deletions.
27 changes: 20 additions & 7 deletions config/gulp-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ const clean = {
for (const item of Object.keys(packages[group]))
$.rimraf(`./packages/${group}/${item}/src/**/*.metadata.json`, done);
},
'tests/*.d.ts': done => {
'testing/*.js': done => {
for (const group of Object.keys(packages))
for (const item of Object.keys(packages[group]))
$.rimraf(`./packages/${group}/${item}/tests/**/*.d.ts`, done);
$.rimraf(`./packages/${group}/${item}/testing/**/*.js`, done);
},
'testing/*.d.ts': done => {
for (const group of Object.keys(packages))
for (const item of Object.keys(packages[group]))
$.rimraf(`./packages/${group}/${item}/testing/**/*.d.ts`, done);
}
};

Expand All @@ -63,6 +68,8 @@ clean['index.metadata.json'].displayName = 'clean:./index.metadata.json';
clean['src/*.js'].displayName = 'clean:./src/*.js';
clean['src/*.d.ts'].displayName = 'clean:./src/*.js';
clean['src/*.metadata.json'].displayName = 'clean:./src/*.js';
clean['testing/*.js'].displayName = 'clean:./testing/*.js';
clean['testing/*.d.ts'].displayName = 'clean:./testing/*.d.ts';

const ts = {
compile: done => {
Expand Down Expand Up @@ -100,6 +107,8 @@ const ts = {
'./**/index.ts',
'./**/src/**/*.ts',
'!./**/src/**/*.d.ts',
'./**/testing/**/*.ts',
'!./**/testing/**/*.d.ts',
'./**/tests/**/*.ts',
'!./**/tests/**/*.d.ts',
'!./**/node_modules/**/*'
Expand Down Expand Up @@ -179,13 +188,16 @@ const tests = {
configFile: $$.root(`./packages/${group}/${item}/config/karma.conf.js`),
webpack: webpack(group, item, settings),
coverageIstanbulReporter: {
reports: ['html', 'text-summary'],
reports: [
'html',
'json',
'lcovonly',
'text-summary'
],
dir: `./coverage/${group}/${item}`,
fixWebpackSourcePaths: true,
'report-config': {
html: {
subdir: 'html'
}
html: {subdir: 'html'}
}
}
}, () => d()).start();
Expand Down Expand Up @@ -225,7 +237,8 @@ gulp.task('clean',
clean['src/*.js'],
clean['src/*.d.ts'],
clean['src/*.metadata.json'],
clean['tests/*.d.ts']
clean['testing/*.js'],
clean['testing/*.d.ts']
));

gulp.task('make',
Expand Down
4 changes: 2 additions & 2 deletions config/webpack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ module.exports = (group, item, settings) => {
sourceMap: false,
inlineSourceMap: true,
compilerOptions: {
// Remove TypeScript helpers to be injected
// remove TypeScript helpers to be injected
// below by DefinePlugin
removeComments: true
},
configFileName: helpers.root(`packages/${group}/${item}/tsconfig.json`)
configFileName: helpers.root(`packages/${group}/${item}/tests/tsconfig.json`)
}
}
],
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
},
"homepage": "https://github.com/fulls1z3/ngx-meta/tree/v0.2.x/#readme",
"scripts": {
"clean": "gulp clean",
"lint": "gulp tslint",
"make": "gulp make",
"test": "gulp test"
"clean": "gulp clean --color",
"lint": "gulp tslint --color",
"make": "gulp make --color",
"test": "gulp test --color"
},
"devDependencies": {
"@angular/common": "~2.4.0",
Expand All @@ -42,7 +42,7 @@
"tslint-loader": "^3.5.3",
"awesome-typescript-loader": "^3.2.3",
"jasmine-core": "^2.8.0",
"karma": "^1.7.0",
"karma": "^1.7.1",
"karma-jasmine": "^1.1.0",
"karma-coverage": "^1.1.1",
"karma-mocha-reporter": "^2.2.4",
Expand Down
28 changes: 14 additions & 14 deletions packages/@ngx-meta/core/config/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ module.exports = function(config) {
basePath: '',
frameworks: ['jasmine'],
exclude: [],
client: {
captureConsole: false
},
client: {captureConsole: false},
files: [
{
pattern: './spec-bundle.js',
watched: false
}
],
preprocessors: {
'./spec-bundle.js': ['coverage', 'webpack', 'sourcemap']
'./spec-bundle.js': [
'coverage',
'webpack',
'sourcemap'
]
},
webpackMiddleware: {
noInfo: true,
stats: {
chunks: false
}
},
reporters: ['mocha', 'coverage', 'coverage-istanbul'],
coverageReporter: {
type: 'in-memory'
stats: {chunks: false}
},
reporters: [
'mocha',
'coverage',
'coverage-istanbul'
],
coverageReporter: {type: 'in-memory'},
port: 9876,
colors: true,
logLevel: config.LOG_WARN,
autoWatch: false,
browsers: [
'Chrome'
],
browsers: ['Chrome'],
customLaunchers: {
ChromeTravisCi: {
base: 'Chrome',
Expand Down
9 changes: 3 additions & 6 deletions packages/@ngx-meta/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@ export function metaFactory(): MetaLoader {
return new MetaStaticLoader();
}

/**
* Do not specify providers for modules that might be imported by a lazy loaded module.
*/
@NgModule()
export class MetaModule {
static forRoot(configuredProvider: any = {
provide: MetaLoader,
useFactory: (metaFactory)
}): ModuleWithProviders {
provide: MetaLoader,
useFactory: (metaFactory)
}): ModuleWithProviders {
return {
ngModule: MetaModule,
providers: [
Expand Down
2 changes: 1 addition & 1 deletion packages/@ngx-meta/core/src/meta.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class MetaGuard implements CanActivate, CanActivateChild {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
const url = state.url;

const metaSettings = (!!route && !!route.data && !!route.data['meta'])
const metaSettings = (route && route.data && route.data['meta'])
? route.data['meta']
: undefined;
this.meta.update(url, metaSettings);
Expand Down
2 changes: 1 addition & 1 deletion packages/@ngx-meta/core/src/meta.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class MetaHelper {
}

removeElement(element: any): void {
if (!!element)
if (element)
this.dom.remove(element);
}

Expand Down
14 changes: 7 additions & 7 deletions packages/@ngx-meta/core/src/meta.loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { PageTitlePositioning } from './models/page-title-positioning';
import { MetaSettings } from './models/meta-settings';

export abstract class MetaLoader {
abstract getSettings(): MetaSettings;
abstract get settings(): MetaSettings;
}

export class MetaStaticLoader implements MetaLoader {
constructor(private readonly settings: MetaSettings = {
pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
defaults: {}
}) {
get settings(): MetaSettings {
return this.providedSettings;
}

getSettings(): MetaSettings {
return this.settings;
constructor(private readonly providedSettings: MetaSettings = {
pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
defaults: {}
}) {
}
}
Loading

0 comments on commit e43896f

Please sign in to comment.