Considering Angular 2 for a large project? Do you need potential i18n support? Enhanced testing support? Oh and building for multiple platforms too? Web, native Mobile (Android/iOS), and even Desktop (Mac, Windows and Linux)?
This is an advanced seed project for Angular 2 apps based on Minko Gechev's angular2-seed that expands on all of it's great features to include core support for:
- ngrx/store RxJS powered state management, inspired by Redux
- ngrx-store-router middleware for syncing state with Angular 2 Router.
- ng2-translate for i18n
- Usage is optional but on by default
- Up to you and your team how you want to utilize it. It can be easily removed if not needed.
- angulartics2 Vendor-agnostic analytics for Angular2 applications.
- Out of box support for Segment
- When using the seed, be sure to change your
write_keyhere
- When using the seed, be sure to change your
- Can be changed to any vendor, learn more here
- Out of box support for Segment
- lodash Helps reduce blocks of code down to single lines and enhances readability
- NativeScript cross platform mobile (w/ native UI) apps. Setup instructions here.
- Electron cross platform desktop apps (Mac, Windows and Linux). Setup instructions here.
| The zen of multiple platforms. Chrome, Android and iPhone all running the same code. |
| Programming Nirvana. Mac and Windows desktop both running the same code. |
- Enhanced development workflow
- Enhanced testing support options
- Additional features coming soon...
- Prerequisites
- Usage
- Progressive Web Apps
- NativeScript App
- Electron App
- Testing
- Web Configuration Options
- How best to use for your project
- Contributing
- License
- Decorators for components which reduce boilerplate for common component setups
- Introduction of
frameworksto help organize your code for different platforms:app.framework: your shared application architecture code (grow your app here or create new frameworks)core.framework: foundation layer (decorators and low-level services)analytics.framework: analytics provided by Segment- Only reports data in production build
i18n.framework: internationalization featuresnativescript.framework: NativeScript specific codeelectron.framework: Electron specific codetest.framework: test specific code providing conveniences to make testing your code easier and faster
- mocks for various services
- configurable provider blocks for easy test setup of common application providers
- tired of setting up similar providers over and over again for different tests?
- configure a reusable test provider which can be configured on a case-by-base basis
- see example here
- watch video explanation coming soon
- helpers for end-to-end (e2e, integration) tests
- convenient shorthand to reduce test setup boilerplate and enhance speed of writing tests
- are your test cases buried by multiple import lines requiring you to scroll just to get to the substance of the test?
- removes noise allowing you to better focus on the substance of the test
- provides full intellisense support
- allows your team to add unique shorthands for various testing scenarios specific to your application needs
- plays nice with
tslintoptions like"no-unused-variable": trueas the api hangs off a plainObjectinstead of globals- what's the value of that you ask? have you ever isolated a test with
iitorddescribebut didn't import those or vice versa, usediitleaving an unuseditnow in your tests? yeah,tslintwill be all over you :/ - avoids
unusedvariable warnings altogether in tests since you are always using a valid key from the shorthandObject
- what's the value of that you ask? have you ever isolated a test with
- see example here
- watch video explanation coming soon
Advice: If your project is intended to target a single platform (i.e, web only), then angular2-seed is likely more than suitable for your needs. However if your project goals are to target multiple platforms (web, native mobile and native desktop), with powerful out of the box library support and highly configurable/flexible testing options, then you might want to keep reading.
- provider for LocalStorage (abstraction for IndexedDB, WebSQL, localStorage, perhaps a port of localForage)
- sophisticated setup for Service Worker
-
node v5.x.x or higher and npm 3 or higher.
-
To run the NativeScript app:
npm install -g nativescript npm install -g typescript git clone --depth 1 https://github.com/NathanWalker/angular2-seed-advanced.git cd angular2-seed-advanced # install the project's dependencies npm install # watches your files and uses livereload by default npm start # api document for the app npm run serve.docs # dev build npm run build.dev # prod build npm run build.prodangular2-seed-advanced supports progressive web apps with angular/progressive.
The seed can generate a file manifest.appcache which lists all files included in a project's output, along with SHA1 hashes of all file contents. This file can be used directly as an AppCache manifest (for now, index.html must be manually edited to set this up).
The manifest is also annotated for use with angular2-service-worker. Some manual operations are currently required to enable this usage. The package must be installed, and worker.js manually copied into the project src directory:
cp node_modules/angular2-service-worker/dist/worker.js src/clientIn order to generate the manifest file run:
# ENV can be both prod or dev npm run generate.manifest -- --env ENVThen, the commented snippet at the bottom of main.web.ts must be uncommented to register the worker script as a service worker.
npm install -g nativescript // we set things up from the 'src/nativescript' directory // at the moment, {N} does not use the seed build cd src/nativescript tns install You will see TypeScript warnings when running the following commands. This is normal at the moment and you can ignore. This will be improved in the future.
- Mac users:
npm run start.ios // iOS simulator // or... npm run start.android // Android emulator* - Windows users:
npm run start.ios.windows // iOS simulator // or... npm run start.android.windows // Android emulator* - Requires an image setup via AVD Manager. Learn more here and here.
- Mac:
npm run start.desktop - Windows:
npm run start.desktop.windows - Mac:
npm run build.desktop.mac - Windows:
npm run build.desktop.windows - Linux:
npm run build.desktop.linux npm test # Debug - In two different shell windows npm run build.test.watch # 1st window npm run karma.start # 2nd window # code coverage (istanbul) # auto-generated at the end of `npm test` # view coverage report: npm run serve.coverage # e2e (aka. end-to-end, integration) - In three different shell windows # Make sure you don't have a global instance of Protractor # npm run webdriver-update <- You will need to run this the first time npm run webdriver-start npm run serve.e2e npm run e2e # e2e live mode - Protractor interactive mode # Instead of last command above, you can use: npm run e2e.liveYou can learn more about Protractor Interactive Mode here
Default application server configuration
var PORT = 5555; var LIVE_RELOAD_PORT = 4002; var DOCS_PORT = 4003; var APP_BASE = '/';Configure at runtime
npm start -- --port 8080 --reload-port 4000 --base /my-app/- Download a zip of the seed. This allows you to manually setup origin/upstream
git remote add origin ....your private repo....git remote add upstream https://github.com/NathanWalker/angular2-seed-advanced.git- Create a new
frameworkfor your application insrc/client/app/frameworksto build your codebase out. Say your app is calledAwesomeApp, then createawesomeapp.frameworkand start building out all your components and services in there. Create other frameworks as you see fit to organize. - If you don't want an integration that comes out of box with this seed; for example. let's say you don't want to use i18n. Then just delete the
i18n.framework, removeng2-translateas dependency rootpackage.jsonandnativescript/package.json. Then remove the references toi18nthroughout. - Remove
src/componentssince those are just samples and create a new folder for your components, let's saysrc/pages. It's not absolutely necessary to remove and create a new differently named folder for your components but it might make merging in upstream changes a bit smoother.
You can read more about configuring a remote for a fork here
git fetch upstreamgit merge upstream/masteryou could rebase, but it wouldn't be worth it as the conflict resolution can often be more painful if there are conflicts- Handle any conflicts to get latest upstream into your application. If you removed
src/componentsas mentioned above, they may show back up when merging in latest upstream. You can just remove the folder again. - Continue building your app.
You can read more about syncing a fork here.
If you have any suggestions to this workflow, please post here.
Please see the CONTRIBUTING file for guidelines.
MIT
