diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..eba1110b5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9b3a09fc9..9fe153944 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,107 @@ -.idea -node_modules -jspm_packages + +# Created by https://www.gitignore.io/api/node,angular,visualstudiocode + +### Angular ### +## Angular ## +# compiled output +/dist +/tmp +/app/**/*.js +/app/**/*.js.map + +# dependencies +/node_modules +/bower_components + +# IDEs and editors +/.idea + +# misc +/.sass-cache +/connect.lock +/coverage/* +/libpeerconnection.log npm-debug.log -debug.log -src/**/*.js -!src/systemjs.config.extras.js -!src/systemjs.config.js -!src/systemjs-angular-loader.js -*.js.map -e2e/**/*.js -e2e/**/*.js.map -_test-output -_temp +testem.log +/typings + +# e2e +/e2e/*.js +/e2e/*.map + +#System Files +.DS_Store + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +.history + +# End of https://www.gitignore.io/api/node,angular,visualstudiocode + +*.js +*.map \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 808bc2c4e..000000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -dist: trusty -sudo: required -language: node_js -node_js: - - "5" -os: - - linux -env: - global: - - DBUS_SESSION_BUS_ADDRESS=/dev/null - - DISPLAY=:99.0 - - CHROME_BIN=chromium-browser -before_script: - - sh -e /etc/init.d/xvfb start -install: - - npm install -script: - - npm run lint - - npm run test:once - - npm run e2e diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 4c991b119..000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,213 +0,0 @@ -## Angular Documentation QuickStart Changelog -Upgraders: for a fresh start, consider running these commands -* `git clean -xdf` -* `npm install` - - -# 0.4.1 (2017-03-24) -* Replace systemjs-angular-loader with version that works for IE - - -# 0.4.0 (2017-03-24) -* Update to Angular 4.0.0 - - -# 0.3.0 (2017-03-22) -* Remove moduleId with a systemjs loader. - - -# 0.2.22 (2017-01-05) -* Add `non-essential-files.txt` and instructions to use it to README - - -# 0.2.21 (2016-12-14) -* Update to in-memory-web-api v.0.2.1 - - -# 0.2.20 (2016-12-07) -* Update to Angular 2.3.0 - - -# 0.2.19 (2016-11-30) -* remove upgrade mappings from `systemjs.config.js` PR #301 - - -# 0.2.18 (2016-11-30) -* remove `exclude` clause from `tsconfig.json`; it was just confusing people -* karma.config + karma-test-shim can handle multiple spec source paths (issue #294) -* cosmetic `app.component.spec.ts` changes -* cosmetic `karma.config.js` changes - - -# 0.2.17 (2016-11-16) -* Conform to updated QuickStart advice - * removed docker everywhere (was nice but not necessary) - * removed wallaby - * shrink styles.css - * refine tsconfig.json - * `AppComponent` uses interpolation - - -# 0.2.16 (2016-11-14) -* Update to Angular 2.2.0 - - -# 0.2.15 (2016-10-29) -* Revert to Jasmine 2.4.1 because bug in 2.5.x (see [jasmine issue #1231](https://github.com/jasmine/jasmine/issues/1231)) - - -# 0.2.14 (2016-10-29) -* Remove bootstrap.css install -* Angular v2.1.2 - - -# 0.2.13 (2016-10-20) -* Protractor 4 -* Move from `typings` to `@types`. See `tsconfig.json` changes. -* Angular v2.1.1 - - -# 0.2.12 (2016-10-06) -* Angular v2.1.0 - - -# 0.2.11 (2016-10-06) -* Angular v2.0.2 -* License is MIT -* Current testing configuration -* No code changes - - -# 0.2.10 (2016-09-19) -* All "Angular 2" references become just "Angular" -* No code changes - - -# 0.2.9 (2016-09-14) -* Angular 2.0.0 version -* Update to Typescript 2.0.2 -* Fix e2e test missing dir - - -# 0.2.8 (2016-09-01) -* remove @angular test libraries from system.js (now in shim) -* update test related files -* wallaby doesn't completely work. Researching. - - -# 0.2.7 (2016-08-31) -* Angular 2 RC6 version -* Updated new forms, router, angular2-in-memory-web-api, karma, core-js, rxjs and zone.js packages -* Removed router-deprecated package -* Updated karma.conf.js and systemjs.config.js - - -# 0.2.6 (2016-08-09) -* Angular 2 RC5 version -* Updated new forms, router and angular2-in-memory-web-api - - -# 0.2.5 (2016-06-30) -* Angular 2 RC4 version -* Updated new forms and router - - -# 0.2.4 (2016-06-21) -* Angular 2 RC3 version -* Add new forms and router -* Add support for TS e2e tests - - -# 0.2.3 (2016-06-15) -* Angular 2 RC2 version - - -# 0.2.2 (2016-05-21) -* Update to Typings 1.x - - -# 0.2.1 (2016-05-03) -* Angular 2 RC01 version - - -# 0.2.0 (2016-05-02) -* Angular 2 RC0 version - - -# 0.1.17 (2016-04-29) -* update packages - * Angular 2 beta 17 - * RxJS 5.0.0-beta.6 - * a2-in-memory-web-api 0.1.17 - - -# 0.1.16 (2016-04-26) -* update packages - * Angular 2 beta 16 - * a2-in-memory-web-api 0.1.6 - * protractor 3.3.0 - * typings 0.8.1 - * zone.js 0.6.12 - - * added favicon.ico - - * testing - - updated wallaby.js and karma.conf.js - - updated app.component.spec.ts - - - -# 0.1.15 (2016-04-13) -* Add testing support - * npm scripts - * karma/jasmine - * protractor - -* update packages - * Angular 2 beta 15 - * lite-server 2.2.0 - * systemjs 0.19.26 - * typescript 1.8.10 - * typings 0.7.12 - -* add run packages - * a2-in-memory-web-api - -* add testing dev-dependency packages - * canonical-path: 0.0.2, - * http-server: ^0.9.0, - * jasmine-core: ~2.4.1, - * karma: ^0.13.22, - * karma-chrome-launcher: ^0.2.3, - * karma-cli: ^0.1.2, - * karma-htmlfile-reporter: ^0.2.2, - * karma-jasmine: ^0.3.8, - * protractor: ^3.2.2, - * rimraf: ^2.5.2 - - -# 0.1.14 (2016-04-07) -* update packages - * Angular 2 beta 14 - * lite-server 2.2.0 - * typings 0.7.12 - - -# 0.1.13 (2016-03-31) -* update packages - * Angular 2 beta 13 - - -# 0.1.12 (2016-03-23) -* update packages - * Angular 2 beta 12 - * zones 0.6.6 -* remove es6-promise because no longer needed. - - -# 0.1.11 (2016-03-18) -* update packages - * Angular 2 beta 11 - * zones 0.6.4 - * typescript 1.8.9 - * typings 0.7.9 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 51b127e82..000000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License - -Copyright (c) 2014-2016 Google, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index aeccb7d76..000000000 --- a/README.md +++ /dev/null @@ -1,195 +0,0 @@ -# Angular QuickStart Source -[![Build Status][travis-badge]][travis-badge-url] - -**This repository is now deprecated. The Angular Quickstart project was a nice starting point for creating Angular applications. Now we recommend using the [Angular CLI](https://github.com/angular/angular-cli) to create new Angular projects.** - -**Starting from 1 November 2017, all the Angular documentation, at [angular.io](https://angular.io), is based on the Angular CLI.** - -**Let's [get started](https://angular.io/guide/quickstart)** - ---- - -This repository holds the TypeScript source code of the [angular.io quickstart](https://angular.io/docs/ts/latest/quickstart.html), -the foundation for most of the documentation samples and potentially a good starting point for your application. - -It's been extended with testing support so you can start writing tests immediately. - -**This is not the perfect arrangement for your application. It is not designed for production. -It exists primarily to get you started quickly with learning and prototyping in Angular** - -We are unlikely to accept suggestions about how to grow this QuickStart into something it is not. -Please keep that in mind before posting issues and PRs. - -## Updating to a newer version of the Quickstart Repo - -From time to time the QuickStart will be enhanced with support for new features or to reflect -changes to the [official Style Guide](https://angular.io/docs/ts/latest/guide/style-guide.html). - -You can update your existing project to an up-to-date QuickStart by following these instructions: -- Create a new project using the [instructions below](#create-a-new-project-based-on-the-quickstart) -- Copy the code you have in your project's `main.ts` file onto `src/app/main.ts` in the new project -- Copy your old `app` folder into `src/app` -- Delete `src/app/main.ts` if you have one (we now use `src/main.ts` instead) -- Copy your old `index.html`, `styles.css` and `tsconfig.json` into `src/` -- Install all your third party dependencies -- Copy your old `e2e/` folder into `e2e/` -- Copy over any other files you added to your project -- Copy your old `.git` folder into your new project's root - -Now you can continue working on the new project. - -## Prerequisites - -Node.js and npm are essential to Angular development. - - -Get it now if it's not already installed on your machine. - -**Verify that you are running at least node `v4.x.x` and npm `3.x.x`** -by running `node -v` and `npm -v` in a terminal/console window. -Older versions produce errors. - -We recommend [nvm](https://github.com/creationix/nvm) for managing multiple versions of node and npm. - -## Create a new project based on the QuickStart - -Clone this repo into new project folder (e.g., `my-proj`). -```shell -git clone https://github.com/angular/quickstart my-proj -cd my-proj -``` - -We have no intention of updating the source on `angular/quickstart`. -Discard the `.git` folder.. -```shell -rm -rf .git # OS/X (bash) -rd .git /S/Q # windows -``` -### Delete _non-essential_ files (optional) - -You can quickly delete the _non-essential_ files that concern testing and QuickStart repository maintenance -(***including all git-related artifacts*** such as the `.git` folder and `.gitignore`!) -by entering the following commands while in the project folder: - -##### OS/X (bash) -```shell -xargs rm -rf < non-essential-files.osx.txt -rm src/app/*.spec*.ts -rm non-essential-files.osx.txt -``` - -##### Windows -```shell -for /f %i in (non-essential-files.txt) do del %i /F /S /Q -rd .git /s /q -rd e2e /s /q -``` - -### Create a new git repo -You could [start writing code](#start-development) now and throw it all away when you're done. -If you'd rather preserve your work under source control, consider taking the following steps. - -Initialize this project as a *local git repo* and make the first commit: -```shell -git init -git add . -git commit -m "Initial commit" -``` - ->Recover the deleted `.gitignore` from the QuickStart repository -if you lost it in the _Delete non-essential files_ step. - -Create a *remote repository* for this project on the service of your choice. - -Grab its address (e.g. *`https://github.com//my-proj.git`*) and push the *local repo* to the *remote*. -```shell -git remote add origin -git push -u origin master -``` -## Install npm packages - -> See npm and nvm version notes above - -Install the npm packages described in the `package.json` and verify that it works: - -```shell -npm install -npm start -``` - ->Doesn't work in _Bash for Windows_ which does not support servers as of January, 2017. - -The `npm start` command first compiles the application, -then simultaneously re-compiles and runs the `lite-server`. -Both the compiler and the server watch for file changes. - -Shut it down manually with `Ctrl-C`. - -You're ready to write your application. - -### npm scripts - -We've captured many of the most useful commands in npm scripts defined in the `package.json`: - -* `npm start` - runs the compiler and a server at the same time, both in "watch mode". -* `npm run build` - runs the TypeScript compiler once. -* `npm run build:w` - runs the TypeScript compiler in watch mode; the process keeps running, awaiting changes to TypeScript files and re-compiling when it sees them. -* `npm run serve` - runs the [lite-server](https://www.npmjs.com/package/lite-server), a light-weight, static file server, written and maintained by -[John Papa](https://github.com/johnpapa) and -[Christopher Martin](https://github.com/cgmartin) -with excellent support for Angular apps that use routing. - -Here are the test related scripts: -* `npm test` - compiles, runs and watches the karma unit tests -* `npm run e2e` - compiles and run protractor e2e tests, written in Typescript (*e2e-spec.ts) - -## Testing - -The QuickStart documentation doesn't discuss testing. -This repo adds both karma/jasmine unit test and protractor end-to-end testing support. - -These tools are configured for specific conventions described below. - -*It is unwise and rarely possible to run the application, the unit tests, and the e2e tests at the same time. -We recommend that you shut down one before starting another.* - -### Unit Tests -TypeScript unit-tests are usually in the `src/app` folder. Their filenames must end in `.spec.ts`. - -Look for the example `src/app/app.component.spec.ts`. -Add more `.spec.ts` files as you wish; we configured karma to find them. - -Run it with `npm test` - -That command first compiles the application, then simultaneously re-compiles and runs the karma test-runner. -Both the compiler and the karma watch for (different) file changes. - -Shut it down manually with `Ctrl-C`. - -Test-runner output appears in the terminal window. -We can update our app and our tests in real-time, keeping a weather eye on the console for broken tests. -Karma is occasionally confused and it is often necessary to shut down its browser or even shut the command down (`Ctrl-C`) and -restart it. No worries; it's pretty quick. - -### End-to-end (E2E) Tests - -E2E tests are in the `e2e` directory, side by side with the `src` folder. -Their filenames must end in `.e2e-spec.ts`. - -Look for the example `e2e/app.e2e-spec.ts`. -Add more `.e2e-spec.js` files as you wish (although one usually suffices for small projects); -we configured Protractor to find them. - -Thereafter, run them with `npm run e2e`. - -That command first compiles, then simultaneously starts the `lite-server` at `localhost:8080` -and launches Protractor. - -The pass/fail test results appear at the bottom of the terminal window. -A custom reporter (see `protractor.config.js`) generates a `./_test-output/protractor-results.txt` file -which is easier to read; this file is excluded from source control. - -Shut it down manually with `Ctrl-C`. - -[travis-badge]: https://travis-ci.org/angular/quickstart.svg?branch=master -[travis-badge-url]: https://travis-ci.org/angular/quickstart diff --git a/bs-config.e2e.json b/bs-config.e2e.json deleted file mode 100644 index 24570dbcc..000000000 --- a/bs-config.e2e.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "open": false, - "logLevel": "silent", - "port": 8080, - "server": { - "baseDir": "src", - "routes": { - "/node_modules": "node_modules" - }, - "middleware": { - "0": null - } - } -} diff --git a/e2e/app.e2e-spec.ts b/e2e/app.e2e-spec.ts deleted file mode 100644 index 67f5d8d6a..000000000 --- a/e2e/app.e2e-spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { browser, element, by } from 'protractor'; - -describe('QuickStart E2E Tests', function () { - - let expectedMsg = 'Hello Angular'; - - beforeEach(function () { - browser.get(''); - }); - - it('should display: ' + expectedMsg, function () { - expect(element(by.css('h1')).getText()).toEqual(expectedMsg); - }); - -}); diff --git a/e2e/tsconfig.json b/e2e/tsconfig.json deleted file mode 100644 index 2c7260d1b..000000000 --- a/e2e/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "moduleResolution": "node", - "sourceMap": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "lib": [ "es2015", "dom" ], - "noImplicitAny": true, - "suppressImplicitAnyIndexErrors": true - } -} diff --git a/karma-test-shim.js b/karma-test-shim.js deleted file mode 100644 index fe5aa7761..000000000 --- a/karma-test-shim.js +++ /dev/null @@ -1,96 +0,0 @@ -// /*global jasmine, __karma__, window*/ -Error.stackTraceLimit = 0; // "No stacktrace"" is usually best for app testing. - -// Uncomment to get full stacktrace output. Sometimes helpful, usually not. -// Error.stackTraceLimit = Infinity; // - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; - -// builtPaths: root paths for output ("built") files -// get from karma.config.js, then prefix with '/base/' (default is 'src/') -var builtPaths = (__karma__.config.builtPaths || ['src/']) - .map(function(p) { return '/base/'+p;}); - -__karma__.loaded = function () { }; - -function isJsFile(path) { - return path.slice(-3) == '.js'; -} - -function isSpecFile(path) { - return /\.spec\.(.*\.)?js$/.test(path); -} - -// Is a "built" file if is JavaScript file in one of the "built" folders -function isBuiltFile(path) { - return isJsFile(path) && - builtPaths.reduce(function(keep, bp) { - return keep || (path.substr(0, bp.length) === bp); - }, false); -} - -var allSpecFiles = Object.keys(window.__karma__.files) - .filter(isSpecFile) - .filter(isBuiltFile); - -System.config({ - // Base URL for System.js calls. 'base/' is where Karma serves files from. - baseURL: 'base/src', - // Extend usual application package list with test folder - packages: { 'testing': { main: 'index.js', defaultExtension: 'js' } }, - - // Assume npm: is set in `paths` in systemjs.config - // Map the angular testing umd bundles - map: { - '@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js', - '@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js', - '@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js', - '@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js', - '@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js', - '@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js', - '@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js', - '@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js', - }, -}); - -System.import('systemjs.config.js') - .then(importSystemJsExtras) - .then(initTestBed) - .then(initTesting); - -/** Optional SystemJS configuration extras. Keep going w/o it */ -function importSystemJsExtras(){ - return System.import('systemjs.config.extras.js') - .catch(function(reason) { - console.log( - 'Warning: System.import could not load the optional "systemjs.config.extras.js". Did you omit it by accident? Continuing without it.' - ); - console.log(reason); - }); -} - -function initTestBed(){ - return Promise.all([ - System.import('@angular/core/testing'), - System.import('@angular/platform-browser-dynamic/testing') - ]) - - .then(function (providers) { - var coreTesting = providers[0]; - var browserTesting = providers[1]; - - coreTesting.TestBed.initTestEnvironment( - browserTesting.BrowserDynamicTestingModule, - browserTesting.platformBrowserDynamicTesting()); - }) -} - -// Import all spec files and start karma -function initTesting () { - return Promise.all( - allSpecFiles.map(function (moduleName) { - return System.import(moduleName); - }) - ) - .then(__karma__.start, __karma__.error); -} diff --git a/karma.conf.js b/karma.conf.js deleted file mode 100644 index 5a51e814f..000000000 --- a/karma.conf.js +++ /dev/null @@ -1,97 +0,0 @@ -module.exports = function(config) { - - var appBase = 'src/'; // transpiled app JS and map files - var appSrcBase = appBase; // app source TS files - - // Testing helpers (optional) are conventionally in a folder called `testing` - var testingBase = 'testing/'; // transpiled test JS and map files - var testingSrcBase = 'testing/'; // test source TS files - - config.set({ - basePath: '', - frameworks: ['jasmine'], - - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter') - ], - - client: { - builtPaths: [appBase, testingBase], // add more spec base paths as needed - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - - customLaunchers: { - // From the CLI. Not used here but interesting - // chrome setup for travis CI using chromium - Chrome_travis_ci: { - base: 'Chrome', - flags: ['--no-sandbox'] - } - }, - - files: [ - // System.js for module loading - 'node_modules/systemjs/dist/system.src.js', - - // Polyfills - 'node_modules/core-js/client/shim.js', - - // zone.js - 'node_modules/zone.js/dist/zone.js', - 'node_modules/zone.js/dist/long-stack-trace-zone.js', - 'node_modules/zone.js/dist/proxy.js', - 'node_modules/zone.js/dist/sync-test.js', - 'node_modules/zone.js/dist/jasmine-patch.js', - 'node_modules/zone.js/dist/async-test.js', - 'node_modules/zone.js/dist/fake-async-test.js', - - // RxJs - { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false }, - { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false }, - - // Paths loaded via module imports: - // Angular itself - { pattern: 'node_modules/@angular/**/*.js', included: false, watched: false }, - { pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false }, - - { pattern: appBase + '/systemjs.config.js', included: false, watched: false }, - { pattern: appBase + '/systemjs.config.extras.js', included: false, watched: false }, - 'karma-test-shim.js', // optionally extend SystemJS mapping e.g., with barrels - - // transpiled application & spec code paths loaded via module imports - { pattern: appBase + '**/*.js', included: false, watched: true }, - { pattern: testingBase + '**/*.js', included: false, watched: true }, - - - // Asset (HTML & CSS) paths loaded via Angular's component compiler - // (these paths need to be rewritten, see proxies section) - { pattern: appBase + '**/*.html', included: false, watched: true }, - { pattern: appBase + '**/*.css', included: false, watched: true }, - - // Paths for debugging with source maps in dev tools - { pattern: appBase + '**/*.ts', included: false, watched: false }, - { pattern: appBase + '**/*.js.map', included: false, watched: false }, - { pattern: testingSrcBase + '**/*.ts', included: false, watched: false }, - { pattern: testingBase + '**/*.js.map', included: false, watched: false} - ], - - // Proxied base paths for loading assets - proxies: { - // required for modules fetched by SystemJS - '/base/src/node_modules/': '/base/node_modules/' - }, - - exclude: [], - preprocessors: {}, - reporters: ['progress', 'kjhtml'], - - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false - }) -} diff --git a/non-essential-files.osx.txt b/non-essential-files.osx.txt deleted file mode 100644 index 653a8db9b..000000000 --- a/non-essential-files.osx.txt +++ /dev/null @@ -1 +0,0 @@ -.git .gitignore .travis.yml bs-config.e2e.json CHANGELOG.md e2e favicon.ico karma.conf.js karma-test-shim.js LICENSE non-essential-files.txt protractor.config.js README.md \ No newline at end of file diff --git a/non-essential-files.txt b/non-essential-files.txt deleted file mode 100644 index 644808a66..000000000 --- a/non-essential-files.txt +++ /dev/null @@ -1,15 +0,0 @@ -.git -.gitignore -.travis.yml -*.spec*.ts -bs-config.e2e.json -CHANGELOG.md -e2e -favicon.ico -karma.conf.js -karma-test-shim.js -LICENSE -non-essential-files.txt -non-essential-files.osx.txt -protractor.config.js -README.md diff --git a/package.json b/package.json index 25513978a..df18ef0e2 100644 --- a/package.json +++ b/package.json @@ -24,14 +24,14 @@ "author": "", "license": "MIT", "dependencies": { - "@angular/common": "~4.3.4", - "@angular/compiler": "~4.3.4", - "@angular/core": "~4.3.4", - "@angular/forms": "~4.3.4", - "@angular/http": "~4.3.4", - "@angular/platform-browser": "~4.3.4", - "@angular/platform-browser-dynamic": "~4.3.4", - "@angular/router": "~4.3.4", + "@angular/common": "~4.0.0", + "@angular/compiler": "~4.0.0", + "@angular/core": "~4.0.0", + "@angular/forms": "~4.0.0", + "@angular/http": "~4.0.0", + "@angular/platform-browser": "~4.0.0", + "@angular/platform-browser-dynamic": "~4.0.0", + "@angular/router": "~4.0.0", "angular-in-memory-web-api": "~0.3.0", "systemjs": "0.19.40", diff --git a/protractor.config.js b/protractor.config.js deleted file mode 100644 index 8d4e0416a..000000000 --- a/protractor.config.js +++ /dev/null @@ -1,183 +0,0 @@ -// FIRST TIME ONLY- run: -// ./node_modules/.bin/webdriver-manager update -// -// Try: `npm run webdriver:update` -// -// AND THEN EVERYTIME ... -// 1. Compile with `tsc` -// 2. Make sure the test server (e.g., lite-server: localhost:8080) is running. -// 3. ./node_modules/.bin/protractor protractor.config.js -// -// To do all steps, try: `npm run e2e` - -var fs = require('fs'); -var path = require('canonical-path'); -var _ = require('lodash'); - - -exports.config = { - directConnect: true, - - // Capabilities to be passed to the webdriver instance. - capabilities: { - 'browserName': 'chrome' - }, - - // Framework to use. Jasmine is recommended. - framework: 'jasmine', - - // Spec patterns are relative to this config file - specs: ['**/*e2e-spec.js' ], - - - // For angular tests - useAllAngular2AppRoots: true, - - // Base URL for application server - baseUrl: 'http://localhost:8080', - - // doesn't seem to work. - // resultJsonOutputFile: "foo.json", - - onPrepare: function() { - //// SpecReporter - //var SpecReporter = require('jasmine-spec-reporter'); - //jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'none'})); - //// jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'})); - - // debugging - // console.log('browser.params:' + JSON.stringify(browser.params)); - jasmine.getEnv().addReporter(new Reporter( browser.params )) ; - - // Allow changing bootstrap mode to NG1 for upgrade tests - global.setProtractorToNg1Mode = function() { - browser.useAllAngular2AppRoots = false; - browser.rootEl = 'body'; - }; - }, - - jasmineNodeOpts: { - // defaultTimeoutInterval: 60000, - defaultTimeoutInterval: 10000, - showTiming: true, - print: function() {} - } -}; - -// Custom reporter -function Reporter(options) { - var _defaultOutputFile = path.resolve(process.cwd(), './_test-output', 'protractor-results.txt'); - options.outputFile = options.outputFile || _defaultOutputFile; - - initOutputFile(options.outputFile); - options.appDir = options.appDir || './'; - var _root = { appDir: options.appDir, suites: [] }; - log('AppDir: ' + options.appDir, +1); - var _currentSuite; - - this.suiteStarted = function(suite) { - _currentSuite = { description: suite.description, status: null, specs: [] }; - _root.suites.push(_currentSuite); - log('Suite: ' + suite.description, +1); - }; - - this.suiteDone = function(suite) { - var statuses = _currentSuite.specs.map(function(spec) { - return spec.status; - }); - statuses = _.uniq(statuses); - var status = statuses.indexOf('failed') >= 0 ? 'failed' : statuses.join(', '); - _currentSuite.status = status; - log('Suite ' + _currentSuite.status + ': ' + suite.description, -1); - }; - - this.specStarted = function(spec) { - - }; - - this.specDone = function(spec) { - var currentSpec = { - description: spec.description, - status: spec.status - }; - if (spec.failedExpectations.length > 0) { - currentSpec.failedExpectations = spec.failedExpectations; - } - - _currentSuite.specs.push(currentSpec); - log(spec.status + ' - ' + spec.description); - }; - - this.jasmineDone = function() { - outputFile = options.outputFile; - //// Alternate approach - just stringify the _root - not as pretty - //// but might be more useful for automation. - // var output = JSON.stringify(_root, null, 2); - var output = formatOutput(_root); - fs.appendFileSync(outputFile, output); - }; - - function ensureDirectoryExistence(filePath) { - var dirname = path.dirname(filePath); - if (directoryExists(dirname)) { - return true; - } - ensureDirectoryExistence(dirname); - fs.mkdirSync(dirname); - } - - function directoryExists(path) { - try { - return fs.statSync(path).isDirectory(); - } - catch (err) { - return false; - } - } - - function initOutputFile(outputFile) { - ensureDirectoryExistence(outputFile); - var header = "Protractor results for: " + (new Date()).toLocaleString() + "\n\n"; - fs.writeFileSync(outputFile, header); - } - - // for output file output - function formatOutput(output) { - var indent = ' '; - var pad = ' '; - var results = []; - results.push('AppDir:' + output.appDir); - output.suites.forEach(function(suite) { - results.push(pad + 'Suite: ' + suite.description + ' -- ' + suite.status); - pad+=indent; - suite.specs.forEach(function(spec) { - results.push(pad + spec.status + ' - ' + spec.description); - if (spec.failedExpectations) { - pad+=indent; - spec.failedExpectations.forEach(function (fe) { - results.push(pad + 'message: ' + fe.message); - }); - pad=pad.substr(2); - } - }); - pad = pad.substr(2); - results.push(''); - }); - results.push(''); - return results.join('\n'); - } - - // for console output - var _pad; - function log(str, indent) { - _pad = _pad || ''; - if (indent == -1) { - _pad = _pad.substr(2); - } - console.log(_pad + str); - if (indent == 1) { - _pad = _pad + ' '; - } - } - -} diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts new file mode 100644 index 000000000..63392b0f5 --- /dev/null +++ b/src/app/app-routing.module.ts @@ -0,0 +1,20 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; + +import { DashboardComponent } from './dashboard.component'; +import { HeroesComponent } from './heroes.component'; +import { HeroDetailComponent } from './hero-detail.component'; + +const routes: Routes = [ + { path: '', redirectTo: '/dashboard', pathMatch: 'full' }, + { path: 'dashboard', component: DashboardComponent }, + { path: 'detail/:id', component: HeroDetailComponent }, + { path: 'heroes', component: HeroesComponent } +]; + +@NgModule({ + imports: [RouterModule.forRoot(routes)], + exports: [RouterModule] +}) + +export class AppRoutingModule { } diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts deleted file mode 100644 index 776902446..000000000 --- a/src/app/app.component.spec.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { AppComponent } from './app.component'; - -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; -import { DebugElement } from '@angular/core'; - -describe('AppComponent', function () { - let de: DebugElement; - let comp: AppComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ AppComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(AppComponent); - comp = fixture.componentInstance; - de = fixture.debugElement.query(By.css('h1')); - }); - - it('should create component', () => expect(comp).toBeDefined() ); - - it('should have expected

text', () => { - fixture.detectChanges(); - const h1 = de.nativeElement; - expect(h1.innerText).toMatch(/angular/i, - '

should say something about "Angular"'); - }); -}); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 7fb173cd0..3126605b4 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,7 +1,18 @@ -import { Component } from '@angular/core'; +import { Component } from "@angular/core"; + @Component({ - selector: 'my-app', - template: `

Hello {{name}}

`, + selector: 'my-app', + template: ` +

{{title}}

+ + + `, }) -export class AppComponent { name = 'Angular'; } + +export class AppComponent { + title = 'Tour of Heroes' +} \ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 357b003a5..050a4d1f0 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,11 +1,36 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; +import { FormsModule } from '@angular/forms'; +import { AppRoutingModule } from "./app-routing.module"; -import { AppComponent } from './app.component'; +import { AppComponent } from './app.component'; +import { HeroDetailComponent } from "./hero-detail.component"; +import { HeroesComponent } from "./heroes.component"; +import { DashboardComponent } from "./dashboard.component"; + +import { HeroService } from "./hero.service"; @NgModule({ - imports: [ BrowserModule ], - declarations: [ AppComponent ], - bootstrap: [ AppComponent ] + imports: [ + BrowserModule, + FormsModule, + AppRoutingModule + ], + declarations: [ + AppComponent, + HeroDetailComponent, + HeroesComponent, + DashboardComponent + ], + providers: [ + HeroService + ], + bootstrap: [ + AppComponent + ], }) + + + export class AppModule { } + diff --git a/src/app/dashboard.component.html b/src/app/dashboard.component.html new file mode 100644 index 000000000..eb949be78 --- /dev/null +++ b/src/app/dashboard.component.html @@ -0,0 +1,8 @@ +

Top Heroes

+ \ No newline at end of file diff --git a/src/app/dashboard.component.ts b/src/app/dashboard.component.ts new file mode 100644 index 000000000..9a530152a --- /dev/null +++ b/src/app/dashboard.component.ts @@ -0,0 +1,20 @@ +import { Component, OnInit } from "@angular/core"; + +import { Hero } from "./hero"; +import { HeroService } from "./hero.service"; + +@Component({ + selector: 'my-dashboard', + templateUrl: './dashboard.component.html', +}) + +export class DashboardComponent { + heroes: Hero[] = []; + + constructor(private heroService: HeroService) { } + + ngOnInit(): void { + this.heroService.getHeroes() + .then(heroes => this.heroes = heroes.slice(1, 5)); + } +} \ No newline at end of file diff --git a/src/app/hero-detail.component.html b/src/app/hero-detail.component.html new file mode 100644 index 000000000..d6c4b0676 --- /dev/null +++ b/src/app/hero-detail.component.html @@ -0,0 +1,11 @@ +
+

{{hero.name}} details!

+
+ {{hero.id}} +
+
+ + +
+
+ \ No newline at end of file diff --git a/src/app/hero-detail.component.ts b/src/app/hero-detail.component.ts new file mode 100644 index 000000000..aa158dda1 --- /dev/null +++ b/src/app/hero-detail.component.ts @@ -0,0 +1,28 @@ +import { Component, Input, OnInit } from "@angular/core"; +import { ActivatedRoute, Params } from "@angular/router"; +import { Location } from "@angular/common"; + +import { Hero } from "./hero"; +import { HeroService } from "./hero.service"; + +import 'rxjs/add/operator/switchMap'; + +@Component({ + selector: 'hero-detail', + templateUrl: './hero-detail.component.html', +}) + +export class HeroDetailComponent implements OnInit{ + @Input() hero: Hero; + constructor( + private heroService: HeroService, + private route: ActivatedRoute, + private location: Location + ) { } + ngOnInit(): void { + this.route.params.switchMap((params: Params) => this.heroService.getHero(+params['id'])).subscribe(hero => this.hero); + } + goBack(): void { + this.location.back(); + } +} \ No newline at end of file diff --git a/src/app/hero.service.ts b/src/app/hero.service.ts new file mode 100644 index 000000000..36187a21b --- /dev/null +++ b/src/app/hero.service.ts @@ -0,0 +1,19 @@ +import { Injectable } from "@angular/core"; +import { Hero } from "./hero"; +import { HEROES } from "./mock-heroes"; + +@Injectable() +export class HeroService { + getHeroes(): Promise { + return Promise.resolve(HEROES); + }; + getHeroesSlowly(): Promise { + return new Promise(resolve => { + // Simulate server latency with 2 second delay + setTimeout(() => resolve(this.getHeroes()), 2000); + }); + }; + getHero(id: number): Promise { + return this.getHeroes().then(heroes => heroes.find(hero => hero.id === id)); + } +} \ No newline at end of file diff --git a/src/app/hero.ts b/src/app/hero.ts new file mode 100644 index 000000000..67dad7403 --- /dev/null +++ b/src/app/hero.ts @@ -0,0 +1,4 @@ +export class Hero { + id: number; + name: string; +} \ No newline at end of file diff --git a/src/app/heroes.component.ts b/src/app/heroes.component.ts new file mode 100644 index 000000000..fa5c237ac --- /dev/null +++ b/src/app/heroes.component.ts @@ -0,0 +1,92 @@ +import { Component, OnInit } from '@angular/core'; +import { Hero } from "./hero"; +import { HeroService } from "./hero.service"; + +@Component({ + selector: 'my-heroes', + template: ` +

My Heroes

+
    +
  • + {{hero.id}} {{hero.name}} +
  • +
+
+
+

+ {{selectedHero.name | uppercase}} is my hero +

+ +
+ `, + styles: [` + .selected { + background-color: #CFD8DC !important; + color: white; + } + .heroes { + margin: 0 0 2em 0; + list-style-type: none; + padding: 0; + width: 15em; + } + .heroes li { + cursor: pointer; + position: relative; + left: 0; + background-color: #EEE; + margin: .5em; + padding: .3em 0; + height: 1.6em; + border-radius: 4px; + } + .heroes li.selected:hover { + background-color: #BBD8DC !important; + color: white; + } + .heroes li:hover { + color: #607D8B; + background-color: #DDD; + left: .1em; + } + .heroes .text { + position: relative; + top: -3px; + } + .heroes .badge { + display: inline-block; + font-size: small; + color: white; + padding: 0.8em 0.7em 0 0.7em; + background-color: #607D8B; + line-height: 1em; + position: relative; + left: -1px; + top: -4px; + height: 1.8em; + margin-right: .8em; + border-radius: 4px 0 0 4px; + } + `], + +}) + + + +export class HeroesComponent implements OnInit { + constructor(private heroService: HeroService) { }; + + selectedHero: Hero; + heroes: Hero[]; + onSelect(hero: Hero): void { + this.selectedHero = hero; + }; + getHeroes(): void { + this.heroService.getHeroes().then(heroes => {this.heroes = heroes}); + }; + ngOnInit(): void { + this.getHeroes(); + } +} + + diff --git a/src/app/mock-heroes.ts b/src/app/mock-heroes.ts new file mode 100644 index 000000000..7075ec042 --- /dev/null +++ b/src/app/mock-heroes.ts @@ -0,0 +1,14 @@ +import { Hero } from "./hero"; + +export const HEROES: Hero[] = [ + { id: 11, name: 'Mr. Nice' }, + { id: 12, name: 'Narco' }, + { id: 13, name: 'Bombasto' }, + { id: 14, name: 'Celeritas' }, + { id: 15, name: 'Magneta' }, + { id: 16, name: 'RubberMan' }, + { id: 17, name: 'Dynama' }, + { id: 18, name: 'Dr IQ' }, + { id: 19, name: 'Magma' }, + { id: 20, name: 'Tornado' } +]; \ No newline at end of file diff --git a/src/favicon.ico b/src/favicon.ico deleted file mode 100644 index 8081c7cea..000000000 Binary files a/src/favicon.ico and /dev/null differ diff --git a/src/systemjs-angular-loader.js b/src/systemjs-angular-loader.js deleted file mode 100644 index 8b1005444..000000000 --- a/src/systemjs-angular-loader.js +++ /dev/null @@ -1,49 +0,0 @@ -var templateUrlRegex = /templateUrl\s*:(\s*['"`](.*?)['"`]\s*)/gm; -var stylesRegex = /styleUrls *:(\s*\[[^\]]*?\])/g; -var stringRegex = /(['`"])((?:[^\\]\\\1|.)*?)\1/g; - -module.exports.translate = function(load){ - if (load.source.indexOf('moduleId') != -1) return load; - - var url = document.createElement('a'); - url.href = load.address; - - var basePathParts = url.pathname.split('/'); - - basePathParts.pop(); - var basePath = basePathParts.join('/'); - - var baseHref = document.createElement('a'); - baseHref.href = this.baseURL; - baseHref = baseHref.pathname; - - if (!baseHref.startsWith('/base/')) { // it is not karma - basePath = basePath.replace(baseHref, ''); - } - - load.source = load.source - .replace(templateUrlRegex, function(match, quote, url){ - var resolvedUrl = url; - - if (url.startsWith('.')) { - resolvedUrl = basePath + url.substr(1); - } - - return 'templateUrl: "' + resolvedUrl + '"'; - }) - .replace(stylesRegex, function(match, relativeUrls) { - var urls = []; - - while ((match = stringRegex.exec(relativeUrls)) !== null) { - if (match[2].startsWith('.')) { - urls.push('"' + basePath + match[2].substr(1) + '"'); - } else { - urls.push('"' + match[2] + '"'); - } - } - - return "styleUrls: [" + urls.join(', ') + "]"; - }); - - return load; -}; diff --git a/src/systemjs.config.extras.js b/src/systemjs.config.extras.js deleted file mode 100644 index 027dfe58c..000000000 --- a/src/systemjs.config.extras.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Add barrels and stuff - * Adjust as necessary for your application needs. - */ -// (function (global) { -// System.config({ -// packages: { -// // add packages here -// } -// }); -// })(this); diff --git a/src/systemjs.config.js b/src/systemjs.config.js deleted file mode 100644 index 129704a37..000000000 --- a/src/systemjs.config.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * System configuration for Angular samples - * Adjust as necessary for your application needs. - */ -(function (global) { - System.config({ - paths: { - // paths serve as alias - 'npm:': 'node_modules/' - }, - // map tells the System loader where to look for things - map: { - // our app is within the app folder - 'app': 'app', - - // angular bundles - '@angular/core': 'npm:@angular/core/bundles/core.umd.js', - '@angular/common': 'npm:@angular/common/bundles/common.umd.js', - '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', - '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', - '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', - '@angular/http': 'npm:@angular/http/bundles/http.umd.js', - '@angular/router': 'npm:@angular/router/bundles/router.umd.js', - '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', - - // other libraries - 'rxjs': 'npm:rxjs', - 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js' - }, - // packages tells the System loader how to load when no filename and/or no extension - packages: { - app: { - defaultExtension: 'js', - meta: { - './*.js': { - loader: 'systemjs-angular-loader.js' - } - } - }, - rxjs: { - defaultExtension: 'js' - } - } - }); -})(this);