├── .angular-cli.json ├── .editorconfig ├── .gitignore ├── .prettierignore ├── .prettierrc ├── .storybook ├── addons.js ├── config.js ├── css-warnings.js ├── tsconfig.storybook.json └── webpack.config.js ├── .vscode ├── extensions.json └── settings.json ├── .yarnrc ├── README.md ├── api └── db.json ├── e2e ├── app.e2e-spec.ts ├── app.po.ts ├── environment.ts ├── tsconfig.e2e.json └── utils │ ├── browser.ts │ └── index.ts ├── jest.config.js ├── package.json ├── proxy.conf.json ├── scripts └── index.js ├── src ├── app │ ├── __snapshots__ │ │ └── app.component.spec.ts.snap │ ├── app.component.spec.ts │ ├── app.component.stories.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── core │ │ ├── components │ │ │ ├── index.ts │ │ │ └── title │ │ │ │ ├── __snapshots__ │ │ │ │ └── title.component.spec.ts.snap │ │ │ │ ├── title.component.css │ │ │ │ ├── title.component.spec.ts │ │ │ │ ├── title.component.ts │ │ │ │ └── title.stories.ts │ │ ├── core.module.ts │ │ ├── index.ts │ │ └── services │ │ │ ├── index.ts │ │ │ ├── user.service.spec.ts │ │ │ └── user.service.ts │ ├── demo │ │ ├── button │ │ │ ├── button.component.spec.ts │ │ │ ├── button.component.stories.ts │ │ │ └── button.component.ts │ │ ├── demo.module.ts │ │ └── index.ts │ └── shared │ │ ├── components │ │ └── index.ts │ │ ├── directives │ │ └── index.ts │ │ ├── index.ts │ │ ├── pipes │ │ └── index.ts │ │ └── shared.module.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.hmr.ts │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── hmr.ts ├── index.html ├── jest-global-mocks.ts ├── main.ts ├── polyfills.ts ├── setup-jest.ts ├── stories │ ├── helpers.ts │ └── index.stories.ts ├── styles.css ├── tsconfig.app.json ├── tsconfig.spec.json └── typings.d.ts ├── tsconfig.json ├── tslint.json ├── types └── @storybook │ ├── addon-actions │ └── index.d.ts │ ├── addon-knobs │ └── angular │ │ └── index.d.ts │ ├── addon-links │ └── index.d.ts │ ├── addon-notes │ └── index.d.ts │ └── addon-options │ └── index.d.ts └── yarn.lock /.angular-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "project": { 4 | "name": "@martin_hotell/better-cli-defaults" 5 | }, 6 | "apps": [ 7 | { 8 | "root": "src", 9 | "outDir": "dist", 10 | "assets": [ 11 | "assets", 12 | "favicon.ico" 13 | ], 14 | "index": "index.html", 15 | "main": "main.ts", 16 | "polyfills": "polyfills.ts", 17 | "test": "", 18 | "tsconfig": "tsconfig.app.json", 19 | "testTsconfig": "tsconfig.spec.json", 20 | "prefix": "app", 21 | "styles": [ 22 | "styles.css" 23 | ], 24 | "scripts": [], 25 | "environmentSource": "environments/environment.ts", 26 | "environments": { 27 | "dev": "environments/environment.ts", 28 | "hmr": "environments/environment.hmr.ts", 29 | "prod": "environments/environment.prod.ts" 30 | } 31 | } 32 | ], 33 | "e2e": { 34 | }, 35 | "lint": [ 36 | { 37 | "project": "src/tsconfig.app.json", 38 | "exclude": "**/node_modules/**" 39 | }, 40 | { 41 | "project": "src/tsconfig.spec.json", 42 | "exclude": "**/node_modules/**" 43 | }, 44 | { 45 | "project": "e2e/tsconfig.e2e.json", 46 | "exclude": "**/node_modules/**" 47 | }, 48 | { 49 | "project": ".storybook/tsconfig.storybook.json", 50 | "exclude": "**/node_modules/**" 51 | } 52 | ], 53 | "test": { 54 | }, 55 | "defaults": { 56 | "styleExt": "css", 57 | "lintFix": true, 58 | "component": { 59 | "inlineTemplate": true, 60 | "changeDetection": "OnPush" 61 | } 62 | }, 63 | "warnings": { 64 | "typescriptMismatch": false 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /dist-server 6 | /tmp 7 | /out-tsc 8 | 9 | # dependencies 10 | /node_modules 11 | 12 | # IDEs and editors 13 | /.idea 14 | .project 15 | .classpath 16 | .c9/ 17 | *.launch 18 | .settings/ 19 | *.sublime-workspace 20 | 21 | # IDE - VSCode 22 | .vscode/* 23 | !.vscode/settings.json 24 | !.vscode/tasks.json 25 | !.vscode/launch.json 26 | !.vscode/extensions.json 27 | 28 | # misc 29 | /.sass-cache 30 | /connect.lock 31 | /coverage 32 | /libpeerconnection.log 33 | npm-debug.log 34 | testem.log 35 | /typings 36 | yarn-error.log 37 | 38 | # e2e 39 | /e2e/*.js 40 | /e2e/*.map 41 | 42 | # System Files 43 | .DS_Store 44 | Thumbs.db 45 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | package.json 2 | tsconfig.json 3 | tsconfig.*.json 4 | package-lock.json 5 | yarn-lock.json -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "always", 6 | "useTabs": false, 7 | "tabWidth": 2, 8 | "semi": true, 9 | "bracketSpacing": true 10 | } 11 | -------------------------------------------------------------------------------- /.storybook/addons.js: -------------------------------------------------------------------------------- 1 | import '@storybook/addon-storysource/register'; 2 | import '@storybook/addon-actions/register'; 3 | import '@storybook/addon-links/register'; 4 | import '@storybook/addon-notes/register'; 5 | import '@storybook/addon-knobs/register'; 6 | import '@storybook/addon-options/register'; 7 | -------------------------------------------------------------------------------- /.storybook/config.js: -------------------------------------------------------------------------------- 1 | import { configure } from '@storybook/angular'; 2 | import { setOptions } from '@storybook/addon-options'; 3 | 4 | // automatically import all files ending in *.stories.ts 5 | const req = require.context('../src/stories', true, /.stories.ts$/); 6 | const reqLocal = require.context('../src/app', true, /.stories.ts$/); 7 | 8 | function loadStories() { 9 | req.keys().forEach(loadStory(req)); 10 | reqLocal.keys().forEach(loadStory(reqLocal)); 11 | } 12 | 13 | /** 14 | * 15 | * @param {(filename:string)=>any} callback 16 | */ 17 | function loadStory(callback) { 18 | return (filename) => callback(filename); 19 | } 20 | 21 | configure(loadStories, module); 22 | -------------------------------------------------------------------------------- /.storybook/css-warnings.js: -------------------------------------------------------------------------------- 1 | import { document } from 'global'; 2 | 3 | export default function addCssWarning() { 4 | const warning = document.createElement('h1'); 5 | warning.textContent = 'CSS rules are not configured as needed'; 6 | warning.className = 'css-rules-warning'; 7 | warning.style.color = 'red'; 8 | 9 | document.body.insertBefore(warning, document.body.firstChild); 10 | } 11 | -------------------------------------------------------------------------------- /.storybook/tsconfig.storybook.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/stories", 5 | "baseUrl": "./", 6 | "module": "es2015" 7 | }, 8 | "include": [ 9 | "../types", 10 | "../stories", 11 | "../**/*.stories.ts" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /.storybook/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = (baseConfig) => { 4 | const storysourceLoader = { 5 | test: [/\.stories\.tsx?$/, /index\.ts$/], 6 | loaders: [require.resolve('@storybook/addon-storysource/loader')], 7 | include: [path.resolve(__dirname, '../src')], 8 | enforce: 'pre', 9 | }; 10 | baseConfig.module.rules.push(storysourceLoader); 11 | 12 | return baseConfig; 13 | }; 14 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp 6 | "eg2.tslint", 7 | "esbenp.prettier-vscode", 8 | "pflannery.vscode-versionlens", 9 | "EditorConfig.EditorConfig", 10 | "Angular.ng-template", 11 | "natewallace.angular2-inline", 12 | "johnpapa.Angular2", 13 | "christian-kohler.path-intellisense", 14 | "capaj.vscode-exports-autocomplete", 15 | "codezombiech.gitignore", 16 | "esbenp.prettier-vscode", 17 | "jasonnutter.search-node-modules", 18 | "robertohuertasm.vscode-icons", 19 | "dkundel.vscode-npm-source", 20 | "eamodio.gitlens", 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true, 3 | "tslint.enable": true, 4 | "tslint.autoFixOnSave": true, 5 | "prettier.singleQuote": true, 6 | "prettier.semi": true, 7 | "prettier.trailingComma": "es5", 8 | "prettier.printWidth": 100, 9 | "prettier.bracketSpacing": true, 10 | "prettier.arrowParens": "always", 11 | "javascript.format.enable": false, 12 | "typescript.format.enable": false 13 | } 14 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | exact true 2 | save-prefix false -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Angular CLI with better defaults from React ecosystem 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.7.1. 4 | 5 | It also adds better tooling defaults from React ecosystem, for much better and faster DX with Angular. Core remains unchanged so you get all Angular CLI benefits indefinitely 😎👌 6 | 7 | ## Project Guidelines 8 | 9 | ### Git 10 | 11 | https://github.com/wearehive/project-guidelines#git 12 | 13 | ## Running your app 14 | 15 | Run `yarn start` for booting up your app with dev server or `yarn start --open` and it will boot and open your browser. 16 | 17 | If you wanna use HMR you can run `yarn start:hmr` 18 | 19 | ## Code scaffolding 20 | 21 | Run `yarn ng g c component-name` to generate a new component. 22 | 23 | You can also use `yarn ng g directive|pipe|service|class|guard|interface|enum|module`. 24 | 25 | ## Build 26 | 27 | Run `yarn build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. 28 | 29 | ## Running unit tests 30 | 31 | Run `yarn test` to execute the unit tests via [Jest](https://facebook.github.io/jest/). 32 | 33 | For getting code coverage execute `yarn test:coverage` 34 | 35 | ## Running end-to-end tests 36 | 37 | Run `yarn e2e` to execute the end-to-end tests in chrome in watch mode via [TestCafe](https://devexpress.github.io/testcafe/). 38 | 39 | Run `yarn e2e:ci` to execute whole test suite in all browsers 40 | 41 | ## Running Storybook 42 | 43 | Run `yarn storybook` and go to `localhost:6006` 44 | 45 | ## Reformat whole code 46 | 47 | > **Note:** you don't need to do this, lint-staged and husky will do that for you 48 | 49 | You can run `yarn format` for executing prettier 50 | and `yarn lint` for linting and fixing lint mistakes in your codebase. 51 | 52 | ## Upgrade dependencies 53 | 54 | Run `yarn upgrade-interactive --latest` and choose what you wanna bump up! 55 | 56 | ## Example app 57 | 58 | [Check out this branch to explore real life usage of provided tools](https://github.com/Hotell/react-tools-for-better-angular-apps/tree/example-app) 59 | 60 | ## Further help 61 | 62 | To get more help on the Angular CLI use `yarn ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 63 | -------------------------------------------------------------------------------- /api/db.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /e2e/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | const page = new AppPage(); 4 | 5 | fixture('App').beforeEach(async (t) => {}); 6 | 7 | test('should display welcome message', async (t) => { 8 | await page.navigateTo(); 9 | 10 | const paragraphText = await page.getParagraphText(); 11 | 12 | await t.expect(paragraphText).contains('Welcome to app!'); 13 | }); 14 | -------------------------------------------------------------------------------- /e2e/app.po.ts: -------------------------------------------------------------------------------- 1 | import { Selector } from 'testcafe'; 2 | 3 | import { browser } from './utils'; 4 | 5 | export class AppPage { 6 | navigateTo() { 7 | return browser.goTo('/'); 8 | } 9 | 10 | getParagraphText() { 11 | return Selector('app-root h1').textContent; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /e2e/environment.ts: -------------------------------------------------------------------------------- 1 | export const BASE_URL = process.env.BASE_URL || 'http://localhost:4200'; 2 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "target": "esnext" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/utils/browser.ts: -------------------------------------------------------------------------------- 1 | import { t } from 'testcafe'; 2 | 3 | export class Browser { 4 | constructor(private baseURL: string) {} 5 | 6 | goTo(urlPath: string) { 7 | return t.navigateTo(`${this.baseURL}${urlPath}`); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/utils/index.ts: -------------------------------------------------------------------------------- 1 | import { BASE_URL } from '../environment'; 2 | import { Browser } from './browser'; 3 | 4 | export const browser = new Browser(BASE_URL); 5 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | // @TODO: try to add ts-check 2 | const jestConfig = { 3 | preset: 'jest-preset-angular', 4 | setupTestFrameworkScriptFile: '/src/setup-jest.ts', 5 | testMatch: [ 6 | '/src/**/__tests__/**/*.+(ts|js)?(x)', 7 | '/src/**/+(*.)+(spec|test).+(ts|js)?(x)', 8 | ], 9 | // // moduleNameMapper: { 10 | // // 'app/(.*)': '/src/app/$1', 11 | // // 'assets/(.*)': '/src/assets/$1', 12 | // // 'environments/(.*)': '/src/environments/$1', 13 | // // }, 14 | // // transformIgnorePatterns: ['node_modules/(?!@ngrx)'], 15 | coveragePathIgnorePatterns: [ 16 | '/node_modules/', 17 | '/out-tsc/', 18 | '/src/.*(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$', 19 | 'src/(setup-jest|jest-global-mocks).ts', 20 | ], 21 | }; 22 | 23 | module.exports = jestConfig; 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@martin_hotell/better-cli-defaults", 3 | "version": "0.2.0", 4 | "license": "MIT", 5 | "engines": { 6 | "node": ">=8.0.0" 7 | }, 8 | "scripts": { 9 | "start": "concurrently --kill-others \"yarn serve:api -q\" \"yarn serve:ui\"", 10 | "start:hmr": "concurrently --kill-others \"yarn serve:api -q\" \"yarn serve:ui:hmr\"", 11 | "serve:ui": "ng serve --proxy-config proxy.conf.json --aot", 12 | "serve:api": "json-server --watch \"api/db.json\"", 13 | "build": "ng build --prod", 14 | "test": "jest --watch", 15 | "test:ci": "jest --runInBand", 16 | "test:coverage": "jest --coverage", 17 | "e2e": "testcafe-live chrome e2e/**/*.e2e-spec.ts", 18 | "e2e:ci": "testcafe all e2e/**/*.e2e-spec.ts --app 'yarn start' --app-init-delay 4000", 19 | "lint": "ng lint --format codeFrame --fix", 20 | "format": "prettier {src,e2e}/**/*.{ts,tsx,json,md,scss,css,less} --write", 21 | "style": "yarn format && yarn lint", 22 | "verify": "yarn format -l && yarn lint && jest --bail", 23 | "tslint-check": "tslint-config-prettier-check ./tslint.json", 24 | "storybook": "start-storybook -p 6006", 25 | "storybook:build": "build-storybook", 26 | "commitmsg": "commitlint -e $GIT_PARAMS", 27 | "precommit": "lint-staged", 28 | "prepush": "yarn verify" 29 | }, 30 | "commitlint": { 31 | "extends": [ 32 | "@commitlint/config-conventional" 33 | ], 34 | "rules": { 35 | "header-max-length": [ 36 | 2, 37 | "always", 38 | 100 39 | ] 40 | } 41 | }, 42 | "lint-staged": { 43 | "{src,e2e}/**/*.{js,jsx,ts,tsx}": [ 44 | "yarn lint", 45 | "git add" 46 | ], 47 | "{src,e2e}/**/*.{js,jsx,ts,tsx,css,scss,less,md}": [ 48 | "prettier --write", 49 | "git add" 50 | ] 51 | }, 52 | "private": true, 53 | "dependencies": { 54 | "@angular/animations": "5.2.9", 55 | "@angular/common": "5.2.9", 56 | "@angular/compiler": "5.2.9", 57 | "@angular/core": "5.2.9", 58 | "@angular/forms": "5.2.9", 59 | "@angular/http": "5.2.9", 60 | "@angular/platform-browser": "5.2.9", 61 | "@angular/platform-browser-dynamic": "5.2.9", 62 | "@angular/router": "5.2.9", 63 | "core-js": "2.5.5", 64 | "rxjs": "5.5.9", 65 | "zone.js": "0.8.26" 66 | }, 67 | "devDependencies": { 68 | "@angular/cli": "1.7.4", 69 | "@angular/compiler-cli": "5.2.9", 70 | "@angular/language-service": "5.2.9", 71 | "@angularclass/hmr": "2.1.3", 72 | "@commitlint/cli": "6.1.3", 73 | "@commitlint/config-conventional": "6.1.3", 74 | "@storybook/addon-actions": "3.4.1", 75 | "@storybook/addon-knobs": "3.4.1", 76 | "@storybook/addon-links": "3.4.1", 77 | "@storybook/addon-notes": "3.4.1", 78 | "@storybook/addon-options": "3.4.1", 79 | "@storybook/addon-storysource": "3.4.1", 80 | "@storybook/addons": "3.4.1", 81 | "@storybook/angular": "3.4.1", 82 | "@types/node": "8.9.5", 83 | "@types/webpack-env": "1.13.5", 84 | "babel-core": "6.26.0", 85 | "codelyzer": "4.2.1", 86 | "concurrently": "3.5.1", 87 | "husky": "0.14.3", 88 | "jest": "22.4.3", 89 | "jest-preset-angular": "5.2.1", 90 | "json-server": "0.12.1", 91 | "lint-staged": "7.0.4", 92 | "prettier": "1.12.0", 93 | "testcafe": "0.19.1", 94 | "testcafe-angular-selectors": "0.3.0", 95 | "testcafe-live": "0.1.3", 96 | "tslint": "5.9.1", 97 | "tslint-config-prettier": "1.10.0", 98 | "tslint-config-standard": "7.0.0", 99 | "typescript": "2.7.2" 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /proxy.conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "/api": { 3 | "target": "http://localhost:3000", 4 | "secure": false, 5 | "pathRewrite": { 6 | "^/api": "" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /scripts/index.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | // @TODO .env processing 4 | -------------------------------------------------------------------------------- /src/app/__snapshots__/app.component.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`AppComponent should create the app 1`] = ` 4 | 7 | 8 |
12 | 13 | 14 | 17 | 18 | 19 |

20 | 21 | Welcome to 22 |

23 | 24 | 25 |
26 | 27 | 28 | Angular Logo 34 | 35 | 36 |
37 |

40 | Here are some links to help you start: 41 |

42 | 126 | 127 |
128 | `; 129 | 130 | exports[`AppComponent should render title in a h1 tag 1`] = ` 131 | 134 | 135 |
139 | 140 | 141 | 145 | 146 | 147 |

148 | 149 | Welcome to app! 150 | 151 |

152 | 153 | 154 |
155 | 156 | 157 | Angular Logo 163 | 164 | 165 |
166 |

169 | Here are some links to help you start: 170 |

171 | 255 | 256 |
257 | `; 258 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { async, TestBed } from '@angular/core/testing'; 3 | 4 | import { AppComponent } from './app.component'; 5 | 6 | import { PROVIDERS } from './core'; 7 | import { TitleComponent } from './core/components'; 8 | 9 | const moduleMocks: NgModule = { 10 | declarations: [TitleComponent], 11 | providers: [PROVIDERS], 12 | }; 13 | describe('AppComponent', () => { 14 | beforeEach(async(() => { 15 | TestBed.configureTestingModule({ 16 | declarations: [AppComponent, moduleMocks.declarations], 17 | providers: moduleMocks.providers, 18 | }).compileComponents(); 19 | })); 20 | it('should create the app', async(() => { 21 | const fixture = TestBed.createComponent(AppComponent); 22 | const app = fixture.debugElement.componentInstance; 23 | 24 | expect(app).toBeTruthy(); 25 | expect(fixture).toMatchSnapshot(); 26 | })); 27 | it(`should have as title 'app'`, async(() => { 28 | const fixture = TestBed.createComponent(AppComponent); 29 | const app = fixture.debugElement.componentInstance; 30 | 31 | expect(app.title).toEqual('app'); 32 | })); 33 | it('should render title in a h1 tag', async(() => { 34 | const fixture = TestBed.createComponent(AppComponent); 35 | fixture.detectChanges(); 36 | const compiled = fixture.debugElement.nativeElement; 37 | 38 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); 39 | expect(fixture).toMatchSnapshot(); 40 | })); 41 | }); 42 | -------------------------------------------------------------------------------- /src/app/app.component.stories.ts: -------------------------------------------------------------------------------- 1 | import { storiesOf } from '@storybook/angular'; 2 | 3 | import { AppComponent } from './app.component'; 4 | import { CoreModule } from './core'; 5 | 6 | storiesOf('App Component', module).add('root app component', () => ({ 7 | moduleMetadata: { 8 | imports: [CoreModule.forRoot()], 9 | }, 10 | component: AppComponent, 11 | props: {}, 12 | })); 13 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | template: ` 6 |
7 | 8 | Angular Logo 9 |
10 |

Here are some links to help you start:

11 | 28 | `, 29 | styles: [``], 30 | }) 31 | export class AppComponent { 32 | title = 'app'; 33 | } 34 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { CoreModule } from './core'; 5 | import { DemoModule } from './demo'; 6 | import { SharedModule } from './shared'; 7 | 8 | import { AppComponent } from './app.component'; 9 | 10 | @NgModule({ 11 | declarations: [AppComponent], 12 | imports: [BrowserModule, DemoModule, SharedModule, CoreModule.forRoot()], 13 | providers: [], 14 | bootstrap: [AppComponent], 15 | }) 16 | export class AppModule {} 17 | -------------------------------------------------------------------------------- /src/app/core/components/index.ts: -------------------------------------------------------------------------------- 1 | import { TitleComponent } from './title/title.component'; 2 | 3 | export { TitleComponent }; 4 | export const COMPONENTS = [TitleComponent]; 5 | -------------------------------------------------------------------------------- /src/app/core/components/title/__snapshots__/title.component.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`TitleComponent should create 1`] = ` 4 | 9 | 10 |

11 | 12 | Welcome to Unknown app! 13 | 14 |

15 | 16 |
17 | `; 18 | -------------------------------------------------------------------------------- /src/app/core/components/title/title.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hotell/react-tools-for-better-angular-apps/7d2e77631d9540a0f1eb588f55e0955ea2a01099/src/app/core/components/title/title.component.css -------------------------------------------------------------------------------- /src/app/core/components/title/title.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { UserService } from '../../services'; 4 | import { TitleComponent } from './title.component'; 5 | 6 | describe('TitleComponent', () => { 7 | let component: TitleComponent; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach( 11 | async(() => { 12 | TestBed.configureTestingModule({ 13 | declarations: [TitleComponent], 14 | providers: [UserService], 15 | }).compileComponents(); 16 | }) 17 | ); 18 | 19 | beforeEach(() => { 20 | fixture = TestBed.createComponent(TitleComponent); 21 | component = fixture.componentInstance; 22 | fixture.detectChanges(); 23 | }); 24 | 25 | it('should create', () => { 26 | expect(component).toBeTruthy(); 27 | expect(fixture).toMatchSnapshot(); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /src/app/core/components/title/title.component.ts: -------------------------------------------------------------------------------- 1 | import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; 2 | 3 | import { UserService } from '../../services'; 4 | 5 | @Component({ 6 | selector: 'app-title', 7 | template: ` 8 |

9 | Welcome to {{ title }}! 10 |

11 | `, 12 | styleUrls: ['./title.component.css'], 13 | changeDetection: ChangeDetectionStrategy.OnPush, 14 | }) 15 | export class TitleComponent { 16 | @Input() title = 'Unknown app'; 17 | 18 | user = this.userService.userName; 19 | 20 | constructor(private userService: UserService) {} 21 | } 22 | -------------------------------------------------------------------------------- /src/app/core/components/title/title.stories.ts: -------------------------------------------------------------------------------- 1 | import { text, withKnobs } from '@storybook/addon-knobs/angular'; 2 | import { moduleMetadata, storiesOf } from '@storybook/angular'; 3 | 4 | import { UserService } from '../../services'; 5 | import { TitleComponent } from './title.component'; 6 | 7 | storiesOf(`${TitleComponent.name}`, module) 8 | .addDecorator(withKnobs) 9 | .addDecorator( 10 | moduleMetadata({ 11 | providers: [UserService], 12 | declarations: [TitleComponent], 13 | }) 14 | ) 15 | .add('default', () => { 16 | return { 17 | template: ``, 18 | }; 19 | }) 20 | .add('with title input', () => { 21 | return { 22 | template: ``, 23 | props: { 24 | title: text('title', 'App'), 25 | }, 26 | }; 27 | }); 28 | -------------------------------------------------------------------------------- /src/app/core/core.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core'; 3 | 4 | import { COMPONENTS } from './components'; 5 | import { PROVIDERS } from './services'; 6 | 7 | @NgModule({ 8 | imports: [CommonModule], 9 | exports: [COMPONENTS], 10 | declarations: [COMPONENTS], 11 | }) 12 | export class CoreModule { 13 | constructor( 14 | @Optional() 15 | @SkipSelf() 16 | parentModule: CoreModule 17 | ) { 18 | if (parentModule) { 19 | throw new Error('CoreModule is already loaded. Import it in the AppModule only'); 20 | } 21 | } 22 | 23 | static forRoot(): ModuleWithProviders { 24 | return { 25 | ngModule: CoreModule, 26 | providers: [PROVIDERS], 27 | }; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/app/core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './core.module'; 2 | export * from './services'; 3 | -------------------------------------------------------------------------------- /src/app/core/services/index.ts: -------------------------------------------------------------------------------- 1 | import { UserService } from './user.service'; 2 | 3 | export { UserService }; 4 | export const PROVIDERS = [UserService]; 5 | -------------------------------------------------------------------------------- /src/app/core/services/user.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { inject, TestBed } from '@angular/core/testing'; 2 | 3 | import { UserService } from './user.service'; 4 | 5 | describe('UserService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [UserService], 9 | }); 10 | }); 11 | 12 | it( 13 | 'should be created', 14 | inject([UserService], (service: UserService) => { 15 | expect(service).toBeTruthy(); 16 | }) 17 | ); 18 | }); 19 | -------------------------------------------------------------------------------- /src/app/core/services/user.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | let nextId = 1; 4 | 5 | @Injectable() 6 | export class UserService { 7 | id = nextId++; 8 | private _userName = 'Sherlock Holmes'; 9 | 10 | get userName() { 11 | // Demo: add a suffix if this service has been created more than once 12 | const suffix = this.id > 1 ? ` times ${this.id}` : ''; 13 | return this._userName + suffix; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/app/demo/button/button.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ButtonComponent } from './button.component'; 4 | 5 | describe('ButtonComponent', () => { 6 | let component: ButtonComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ButtonComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ButtonComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/demo/button/button.component.stories.ts: -------------------------------------------------------------------------------- 1 | import { action } from '@storybook/addon-actions'; 2 | import { text, withKnobs } from '@storybook/addon-knobs/angular'; 3 | import { withNotes } from '@storybook/addon-notes'; 4 | import { storiesOf } from '@storybook/angular'; 5 | 6 | import { ButtonComponent } from './button.component'; 7 | 8 | storiesOf('My Button', module) 9 | .addDecorator(withKnobs) 10 | .add('with some text and knobs enabled', () => { 11 | const textProp = text('text', 'Hello World'); 12 | return { 13 | component: ButtonComponent, 14 | props: { 15 | text: textProp, 16 | }, 17 | }; 18 | }) 19 | .add('with some text', () => ({ 20 | component: ButtonComponent, 21 | props: { 22 | text: 'Hello World', 23 | }, 24 | })) 25 | .add('with some text and action', () => ({ 26 | component: ButtonComponent, 27 | props: { 28 | text: 'Hello World', 29 | click: action('clicked'), 30 | }, 31 | })) 32 | .add('with content projection', () => ({ 33 | moduleMetadata: { 34 | declarations: [ButtonComponent], 35 | }, 36 | template: `Hello World`, 37 | props: { 38 | click: action('clicked'), 39 | }, 40 | })) 41 | .add( 42 | 'Note with HTML', 43 | withNotes({ 44 | text: ` 45 |

My notes on emojis

46 | It's not all that important to be honest, but.. 47 | Emojis are great, I love emojis, in fact I like using them in my Component notes too! 😇 48 | `, 49 | })(() => ({ 50 | component: ButtonComponent, 51 | props: { 52 | text: 'Notes with HTML', 53 | onClick: () => {}, 54 | }, 55 | })) 56 | ); 57 | -------------------------------------------------------------------------------- /src/app/demo/button/button.component.ts: -------------------------------------------------------------------------------- 1 | import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-button', 5 | template: ` 6 | 9 | {{ text }} 10 | `, 11 | styles: [ 12 | ` 13 | button { 14 | border: 1px solid #eee; 15 | border-radius: 3px; 16 | background-color: #FFFFFF; 17 | cursor: pointer; 18 | font-size: 15px; 19 | padding: 3px 10px; 20 | margin: 10px; 21 | } 22 | `, 23 | ], 24 | changeDetection: ChangeDetectionStrategy.OnPush, 25 | }) 26 | export class ButtonComponent { 27 | @Input() text = ''; 28 | @Output() click = new EventEmitter(); 29 | handleClick(event: MouseEvent) { 30 | // event.stopPropagation(); 31 | this.click.emit(event); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/app/demo/demo.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { NgModule } from '@angular/core'; 3 | import { ButtonComponent } from './button/button.component'; 4 | 5 | @NgModule({ 6 | imports: [CommonModule], 7 | declarations: [ButtonComponent], 8 | exports: [ButtonComponent], 9 | }) 10 | export class DemoModule {} 11 | -------------------------------------------------------------------------------- /src/app/demo/index.ts: -------------------------------------------------------------------------------- 1 | export * from './demo.module'; 2 | -------------------------------------------------------------------------------- /src/app/shared/components/index.ts: -------------------------------------------------------------------------------- 1 | export const COMPONENTS = []; 2 | -------------------------------------------------------------------------------- /src/app/shared/directives/index.ts: -------------------------------------------------------------------------------- 1 | export const DIRECTIVES = []; 2 | -------------------------------------------------------------------------------- /src/app/shared/index.ts: -------------------------------------------------------------------------------- 1 | export * from './shared.module'; 2 | -------------------------------------------------------------------------------- /src/app/shared/pipes/index.ts: -------------------------------------------------------------------------------- 1 | export const PIPES = []; 2 | -------------------------------------------------------------------------------- /src/app/shared/shared.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { COMPONENTS } from './components'; 5 | import { DIRECTIVES } from './directives'; 6 | import { PIPES } from './pipes'; 7 | 8 | @NgModule({ 9 | imports: [CommonModule], 10 | declarations: [COMPONENTS, DIRECTIVES, PIPES], 11 | exports: [CommonModule, COMPONENTS, DIRECTIVES, PIPES], 12 | }) 13 | export class SharedModule {} 14 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hotell/react-tools-for-better-angular-apps/7d2e77631d9540a0f1eb588f55e0955ea2a01099/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/environments/environment.hmr.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: false, 3 | hmr: true, 4 | }; 5 | -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true, 3 | hmr: false, 4 | }; 5 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false, 8 | hmr: false, 9 | }; 10 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hotell/react-tools-for-better-angular-apps/7d2e77631d9540a0f1eb588f55e0955ea2a01099/src/favicon.ico -------------------------------------------------------------------------------- /src/hmr.ts: -------------------------------------------------------------------------------- 1 | import { ApplicationRef, NgModuleRef } from '@angular/core'; 2 | import { createNewHosts } from '@angularclass/hmr'; 3 | 4 | export const hmrBootstrap = (module: NodeModule, bootstrap: () => Promise>) => { 5 | if (!module.hot) { 6 | throw new Error('have you run ng with --hmr flag ?'); 7 | } 8 | 9 | let ngModule: NgModuleRef; 10 | 11 | module.hot.accept(); 12 | bootstrap().then((mod) => (ngModule = mod)); 13 | module.hot.dispose(() => { 14 | const appRef: ApplicationRef = ngModule.injector.get(ApplicationRef); 15 | const elements = appRef.components.map((c) => c.location.nativeElement); 16 | const makeVisible = createNewHosts(elements); 17 | ngModule.destroy(); 18 | makeVisible(); 19 | }); 20 | }; 21 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | My App 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/jest-global-mocks.ts: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | global.CSS = null; 3 | 4 | const webStorageMock = () => { 5 | let storage: Record = {}; 6 | return { 7 | getItem: (key: string) => (key in storage ? storage[key] : null), 8 | setItem: (key: string, value: any) => (storage[key] = value || ''), 9 | removeItem: (key: string) => delete storage[key], 10 | clear: () => (storage = {}), 11 | }; 12 | }; 13 | 14 | Object.defineProperty(window, 'localStorage', { value: webStorageMock() }); 15 | Object.defineProperty(window, 'sessionStorage', { value: webStorageMock() }); 16 | Object.defineProperty(document, 'doctype', { 17 | value: '', 18 | }); 19 | Object.defineProperty(window, 'getComputedStyle', { 20 | value: () => { 21 | return { 22 | display: 'none', 23 | appearance: ['-webkit-appearance'], 24 | }; 25 | }, 26 | }); 27 | /** 28 | * ISSUE: https://github.com/angular/material2/issues/7101 29 | * Workaround for JSDOM missing transform property 30 | */ 31 | Object.defineProperty(document.body.style, 'transform', { 32 | value: () => { 33 | return { 34 | enumerable: true, 35 | configurable: true, 36 | }; 37 | }, 38 | }); 39 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 2 | 3 | import { AppModule } from './app/app.module'; 4 | import { environment } from './environments/environment'; 5 | 6 | import { hmrBootstrap } from './hmr'; 7 | 8 | const bootstrap = () => platformBrowserDynamic().bootstrapModule(AppModule); 9 | 10 | if (environment.hmr) { 11 | if (module.hot) { 12 | hmrBootstrap(module, bootstrap); 13 | } else { 14 | // tslint:disable:no-console 15 | console.error('HMR is not enabled for webpack-dev-server!'); 16 | console.log('Are you using the --hmr flag for ng serve?'); 17 | } 18 | } else { 19 | bootstrap().catch((err) => console.log(err)); 20 | } 21 | 22 | // import { enableProdMode } from '@angular/core'; 23 | // import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 24 | 25 | // import { AppModule } from './app/app.module'; 26 | // import { environment } from './environments/environment'; 27 | 28 | // if (environment.production) { 29 | // enableProdMode(); 30 | // } 31 | 32 | // platformBrowserDynamic() 33 | // .bootstrapModule(AppModule) 34 | // .catch((err) => console.log(err)); 35 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. */ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** IE10 and IE11 requires the following for the Reflect API. */ 41 | // import 'core-js/es6/reflect'; 42 | 43 | /** Evergreen browsers require these. */ 44 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 45 | import 'core-js/es7/reflect'; 46 | 47 | /** 48 | * Required to support Web Animations `@angular/platform-browser/animations`. 49 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation 50 | */ 51 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 52 | 53 | /*************************************************************************************************** 54 | * Zone JS is required by default for Angular itself. 55 | */ 56 | import 'zone.js/dist/zone'; // Included with Angular CLI. 57 | 58 | /*************************************************************************************************** 59 | * APPLICATION IMPORTS 60 | */ 61 | -------------------------------------------------------------------------------- /src/setup-jest.ts: -------------------------------------------------------------------------------- 1 | import 'jest-preset-angular'; 2 | 3 | import './jest-global-mocks'; // browser mocks globally available for every test 4 | -------------------------------------------------------------------------------- /src/stories/helpers.ts: -------------------------------------------------------------------------------- 1 | // insert here any reusable helper functions to be used within storybook 2 | -------------------------------------------------------------------------------- /src/stories/index.stories.ts: -------------------------------------------------------------------------------- 1 | import { action } from '@storybook/addon-actions'; 2 | import { linkTo } from '@storybook/addon-links'; 3 | import { withNotes } from '@storybook/addon-notes'; 4 | import { storiesOf } from '@storybook/angular'; 5 | 6 | import { Button, Welcome } from '@storybook/angular/demo'; 7 | 8 | storiesOf('Welcome', module).add('to Storybook', () => ({ 9 | component: Welcome, 10 | props: {}, 11 | })); 12 | 13 | storiesOf('Button', module) 14 | .add('with text', () => ({ 15 | component: Button, 16 | props: { 17 | text: 'Hello Button', 18 | }, 19 | })) 20 | .add( 21 | 'with some emoji', 22 | withNotes({ text: 'My notes on a button with emojis' })(() => ({ 23 | component: Button, 24 | props: { 25 | text: '😀 😎 👍 💯', 26 | }, 27 | })) 28 | ) 29 | .add( 30 | 'with some emoji and action', 31 | withNotes({ text: 'My notes on a button with emojis' })(() => ({ 32 | component: Button, 33 | props: { 34 | text: '😀 😎 👍 💯', 35 | onClick: action('This was clicked OMG'), 36 | }, 37 | })) 38 | ); 39 | 40 | storiesOf('Another Button', module).add('button with link to another story', () => ({ 41 | component: Button, 42 | props: { 43 | text: 'Go to Welcome Story', 44 | onClick: linkTo('Welcome'), 45 | }, 46 | })); 47 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "es2015" 6 | }, 7 | "exclude": [ 8 | "setup-jest.ts", 9 | "jest-global-mocks.ts", 10 | "**/*.spec.ts", 11 | "stories", 12 | "**/*.stories.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "module": "commonjs", 6 | "types": [ 7 | "node", 8 | "jest" 9 | ] 10 | }, 11 | "include": [ 12 | "**/*.spec.ts", 13 | "**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /* SystemJS module definition */ 2 | declare var module: NodeModule; 3 | interface NodeModule { 4 | id: string; 5 | } 6 | 7 | interface Window { 8 | __REDUX_DEVTOOLS_EXTENSION_COMPOSE__(a: R): R; 9 | } 10 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "strict": true, 6 | "sourceMap": true, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "target": "es5", 11 | "skipLibCheck": true, 12 | "baseUrl": ".", 13 | "paths": {}, 14 | "lib": [ 15 | "es2017", 16 | "dom" 17 | ], 18 | "pretty": true 19 | }, 20 | "exclude": [], 21 | "angularCompilerOptions": { 22 | "fullTemplateTypeCheck": true, 23 | "skipMetadataEmit": true, 24 | "strictInjectionParameters": true, 25 | "preserveWhitespaces": false 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "codelyzer", 4 | "tslint:recommended", 5 | "tslint-config-standard", 6 | "tslint-config-prettier" 7 | ], 8 | "rules": { 9 | // @override: tslint:recommended / tslint-config-standard 10 | "object-literal-sort-keys": false, 11 | "no-floating-promises": false, 12 | "no-empty": false, 13 | 14 | // @core: code rules 15 | "deprecation": { 16 | "severity": "warn" 17 | }, 18 | "import-blacklist": [ 19 | true, 20 | "rxjs", 21 | "rxjs/Rx" 22 | ], 23 | 24 | // @core: type rules 25 | "interface-over-type-literal": false, 26 | "member-access": false, 27 | "no-inferrable-types": [ 28 | true, 29 | "ignore-params" 30 | ], 31 | "interface-name": [true, "never-prefix"], 32 | "no-non-null-assertion": true, 33 | 34 | // @ codelyzer rules 35 | "directive-selector": [ 36 | true, 37 | "attribute", 38 | "app", 39 | "camelCase" 40 | ], 41 | "component-selector": [ 42 | true, 43 | "element", 44 | "app", 45 | "kebab-case" 46 | ], 47 | "no-output-on-prefix": true, 48 | "use-input-property-decorator": true, 49 | "use-output-property-decorator": true, 50 | "use-host-property-decorator": true, 51 | "no-input-rename": true, 52 | "no-output-rename": true, 53 | "use-life-cycle-interface": true, 54 | "use-pipe-transform-interface": true, 55 | "component-class-suffix": true, 56 | "directive-class-suffix": true, 57 | "angular-whitespace": [true, "check-interpolation", "check-semicolon"] 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /types/@storybook/addon-actions/index.d.ts: -------------------------------------------------------------------------------- 1 | type ActionReturnFn = (...args: any[]) => void; 2 | type ActionFn = (name: string) => ActionReturnFn; 3 | type DecoratorFn = (args: any[]) => any[]; 4 | declare module '@storybook/addon-actions' { 5 | const action: ActionFn; 6 | const decorateAction: (decorators: DecoratorFn[]) => ActionFn; 7 | } 8 | -------------------------------------------------------------------------------- /types/@storybook/addon-knobs/angular/index.d.ts: -------------------------------------------------------------------------------- 1 | type WithKnob = (...args: any[]) => any; 2 | interface WithKnobOptions { 3 | debounce: { 4 | wait: number; 5 | leading: boolean; 6 | }; 7 | timestamp: boolean; 8 | } 9 | 10 | type KnobFn = (label: string, defaultValue: T, groupId?: string) => any; 11 | 12 | type KnobNumberRangeFn = ( 13 | label: string, 14 | defaultValue: T, 15 | options?: NumberRangeOptions, 16 | groupId?: string 17 | ) => any; 18 | type NumberRangeOptions = { 19 | range: boolean; 20 | min?: number; 21 | max?: number; 22 | step?: number; 23 | }; 24 | 25 | type KnobArrayFn = ( 26 | label: string, 27 | defaultValue: T, 28 | separator?: string, 29 | groupId?: string 30 | ) => any; 31 | 32 | type KnobButtonFn = (label: string, handler: (...args: any[]) => any, groupId?: string) => any; 33 | 34 | declare module '@storybook/addon-knobs/angular' { 35 | const withKnobs: WithKnob; 36 | const withKnobsOptions: (options?: Partial) => WithKnob; 37 | const text: KnobFn; 38 | const number: KnobFn | KnobNumberRangeFn; 39 | const boolean: KnobFn; 40 | const object: KnobFn; 41 | const array: KnobArrayFn; 42 | const select: KnobFn; 43 | const color: KnobFn; 44 | const date: KnobFn; 45 | const button: KnobButtonFn; 46 | } 47 | -------------------------------------------------------------------------------- /types/@storybook/addon-links/index.d.ts: -------------------------------------------------------------------------------- 1 | type LinkParams = string | ((...args: any[]) => string); 2 | declare module '@storybook/addon-links' { 3 | function linkTo(kind: LinkParams, story?: LinkParams): (...args: any[]) => any; 4 | function hrefTo(kind: string, story?: string): Promise; 5 | } 6 | -------------------------------------------------------------------------------- /types/@storybook/addon-notes/index.d.ts: -------------------------------------------------------------------------------- 1 | interface NotesOptions { 2 | text: string; 3 | } 4 | 5 | declare module '@storybook/addon-notes' { 6 | import { IGetStory, IApi } from '@storybook/angular'; 7 | 8 | type WithNotesFn = (textOrOptions: string | NotesOptions) => (getStory: IGetStory) => IGetStory; 9 | 10 | export const withMarkdownNotes: WithNotesFn; 11 | export const withNotes: WithNotesFn; 12 | } 13 | -------------------------------------------------------------------------------- /types/@storybook/addon-options/index.d.ts: -------------------------------------------------------------------------------- 1 | interface OptionsConfig { 2 | /** 3 | * name to display in the top left corner 4 | * @type {String} 5 | */ 6 | name: string; 7 | /** 8 | * URL for name in top left corner to link to 9 | * @type {String} 10 | */ 11 | url: string; 12 | /** 13 | * show story component as full screen 14 | * @type {Boolean} 15 | */ 16 | goFullScreen: boolean; 17 | /** 18 | * display panel that shows a list of stories 19 | * @type {Boolean} 20 | */ 21 | showStoriesPanel: boolean; 22 | /** 23 | * display panel that shows addon configurations 24 | * @type {Boolean} 25 | */ 26 | showAddonPanel: boolean; 27 | /** 28 | * display floating search box to search through stories 29 | * @type {Boolean} 30 | */ 31 | showSearchBox: boolean; 32 | /** 33 | * show addon panel as a vertical panel on the right 34 | * @type {Boolean} 35 | */ 36 | addonPanelInRight: boolean; 37 | /** 38 | * sorts stories 39 | * @type {Boolean} 40 | */ 41 | sortStoriesByKind: boolean; 42 | /** 43 | * regex for finding the hierarchy separator 44 | * @example: 45 | * null - turn off hierarchy 46 | * /\// - split by `/` 47 | * /\./ - split by `.` 48 | * /\/|\./ - split by `/` or `.` 49 | * @type {Regex} 50 | */ 51 | hierarchySeparator: null | RegExp; 52 | /** 53 | * regex for finding the hierarchy root separator 54 | * @example: 55 | * null - turn off mulitple hierarchy roots 56 | * /\|/ - split by `|` 57 | * @type {Regex} 58 | */ 59 | hierarchyRootSeparator: null | RegExp; 60 | /** 61 | * sidebar tree animations 62 | * @type {Boolean} 63 | */ 64 | sidebarAnimations: boolean; 65 | /** 66 | * id to select an addon panel 67 | * @type {String} 68 | */ 69 | selectedAddonPanel: string; // The order of addons in the "Addon panel" is the same as you import them in 'addons.js'. The first panel will be opened by default as you run Storybook 70 | } 71 | declare module '@storybook/addon-options' { 72 | const setOptions: (config: Partial) => any; 73 | } 74 | --------------------------------------------------------------------------------