diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index 3b435e551..000000000 --- a/Gruntfile.js +++ /dev/null @@ -1,281 +0,0 @@ -/*global module:false*/ -module.exports = function (grunt) { - - require('load-grunt-tasks')(grunt); - var files = require('./files').files; - var systemjs = require('systemjs'); - //var jspm = require('jspm'); - - // Project configuration. - grunt.initConfig({ - builddir: 'build', - pkg: grunt.file.readJSON('package.json'), - buildtag: '-dev-' + grunt.template.today('yyyy-mm-dd'), - meta: { - banner: '/**\n' + - ' * <%= pkg.description %>\n' + - ' * @version v<%= pkg.version %><%= buildtag %>\n' + - ' * @link <%= pkg.homepage %>\n' + - ' * @license MIT License, http://www.opensource.org/licenses/MIT\n' + - ' */' - }, - clean: [ '<%= builddir %>' ], - ts: { - ng1: { tsconfig: 'tsconfig.json' }, - ng2: { tsconfig: 'tsconfig-ng2.json' } - }, - uglify: { - options: { - banner: '<%= meta.banner %>\n', - mangle: true - }, - build: { - files: { - '<%= builddir %>/ui-router-ng2.min.js': ['', '<%= builddir %>/ui-router-ng2.js'], - '<%= builddir %>/angular-ui-router.min.js': ['', '<%= builddir %>/angular-ui-router.js'], - '<%= builddir %>/ng1/stateEvents.min.js': ['', '<%= builddir %>/ng1/stateEvents.js'] - } - } - }, - webpack: { - build: { - entry: files.ng1CommonJsEntrypoint, - output: { - path: '<%= builddir %>', - filename: 'angular-ui-router.js', - library: 'ui.router', - libraryTarget: 'umd' - }, - module: { loaders: [] }, - externals: [ - { angular: { root: 'angular', commonjs2: 'angular', commonjs: 'angular' } } - ] - }, - ng2: { - entry: files.ng2CommonJsEntrypoint, - output: { - path: '<%= builddir %>', - filename: 'ui-router-ng2.js', - library: 'uiRouter', - libraryTarget: 'umd' - }, - module: { loaders: [] }, - externals: [{ - 'angular2/core': {root: ['ng', 'core'], commonjs: 'angular2/core', commonjs2: 'angular2/core', amd: 'angular2/core'}, - 'angular2/common': {root: ['ng', 'common'], commonjs: 'angular2/common', commonjs2: 'angular2/common', amd: 'angular2/common'} - }] - } - //,core: { - // entry: files.justjsCommonJsEntrypoint, - // output: { - // path: '<%= builddir %>', - // filename: 'ui-router-justjs.js', - // library: 'uiRouter', - // libraryTarget: 'umd' - // }, - // module: { - // loaders: [] - // } - //} - }, - release: { - files: ['<%= pkg.name %>.js', '<%= pkg.name %>.min.js'], - src: '<%= builddir %>', - dest: 'release' - }, - watch: { - files: ['src/**/*.ts', 'src/**/*.js', 'test/**/*.js'], - tasks: ['ts:es5', 'webpack', 'karma:ng14'] - }, - connect: { - server: {}, - sample: { - options:{ - port: 5555, - keepalive: true - } - } - }, - karma: { - options: { - configFile: 'config/karma.js', - // Serve and load angular files using regular Karma mode - browsers: [ grunt.option('browser') || 'PhantomJS' ] - }, - // Same as karma:base - unit: { - }, - // Launch Karma in Chrome, click debug button, debug tests - debug: { - singleRun: false, - background: false, - autoWatch: true, - autoWatchInterval: 1, - browsers: [ grunt.option('browser') || 'Chrome' ] - }, - // Test with angular 1.2 - ng12: { - options: { files: files.karmaServedFiles('1.2.28') } - }, - // Test with angular 1.3 - ng13: { - options: { files: files.karmaServedFiles('1.3.16') } - }, - // Test with angular 1.4 - ng14: { - options: { files: files.karmaServedFiles('1.4.9') } - }, - // Test with angular 1.5 - ng15: { - options: { files: files.karmaServedFiles('1.5.0') } - }, - background: { - background: true - }, - // PhantomJS in the console; watch for changes to tests/src - watch: { - singleRun: false, - autoWatch: true, - autoWatchInterval: 1 - } - }, - changelog: { - options: { - dest: 'CHANGELOG.md' - } - }, - ngdocs: { - options: { - dest: 'site', - styles: [ 'ngdoc_assets/uirouter-docs.css' ], - html5Mode: false, - title: 'UI Router', - startPage: '/api/ui.router', - navTemplate: 'ngdoc_assets/docnav.html' - }, - api: { - src: ['src/**/*.js'], - title: 'API Reference' - } - } - }); - - grunt.registerTask('integrate', ['clean', 'build', 'karma:ng12', 'karma:ng13', 'karma:ng14', 'karma:ng15']); - grunt.registerTask('default', ['build', 'karma:unit', 'docs']); - grunt.registerTask('build', 'Perform a normal build', ['clean', 'ts', 'bundles', 'uglify']); - grunt.registerTask('dist-docs', 'Perform a clean build and generate documentation', ['build', 'ngdocs']); - grunt.registerTask('release', 'Tag and perform a release', ['prepare-release', 'build', 'perform-release']); - grunt.registerTask('dev', 'Run dev server and watch for changes', ['build', 'connect:server', 'karma:background', 'watch']); - grunt.registerTask('sample', 'Run connect server with keepalive:true for sample app development', ['connect:sample']); - - grunt.registerTask('docs', 'Generate documentation to _doc', function() { - promising(this, - system('./node_modules/typedoc/bin/typedoc --experimentalDecorators --readme ./README.md --name "UI-Router" --theme ./typedoctheme --mode modules --module commonjs --target es5 --out _doc src typings/es6-shim/es6-shim.d.ts typings/angularjs/angular.d.ts') - ); - }); - - grunt.registerTask('bundles', 'Create the bundles and reorganize any additional dist files (addons, etc)', function() { - var builddir = grunt.config('builddir'); - grunt.task.requires([ 'clean', 'ts' ]); - grunt.task.run(['webpack']); - - ['stateEvents.js', 'stateEvents.js.map'].forEach(function(file) { - grunt.file.copy(builddir + "/es5/ng1/" + file, builddir + "/ng1/" + file); - }) - }); - - grunt.registerTask('publish-pages', 'Publish a clean build, docs, and sample to github.io', function () { - promising(this, - ensureCleanMaster().then(function () { - shjs.rm('-rf', 'build'); - return system('git checkout gh-pages'); - }).then(function () { - return system('git merge master'); - }).then(function () { - return system('grunt dist-docs'); - }).then(function () { - return system('git commit -a -m \'Automatic gh-pages build\''); - }).then(function () { - return system('git checkout master'); - }) - ); - }); - - grunt.registerTask('push-pages', 'Push published pages', function () { - promising(this, - ensureCleanMaster().then(function () { - shjs.rm('-rf', 'build'); - return system('git checkout gh-pages'); - }).then(function () { - return system('git push origin gh-pages'); - }).then(function () { - return system('git checkout master'); - }) - ); - }); - - grunt.registerTask('prepare-release', function () { - var bower = grunt.file.readJSON('bower.json'), - component = grunt.file.readJSON('component.json'), - version = bower.version; - if (version != grunt.config('pkg.version')) throw new Error('Version mismatch in bower.json'); - if (version != component.version) throw new Error('Version mismatch in component.json'); - - promising(this, - ensureCleanMaster().then(function () { - return exec('git tag -l \'' + version + '\''); - }).then(function (result) { - if (result.stdout.trim() !== '') throw new Error('Tag \'' + version + '\' already exists'); - grunt.config('buildtag', ''); - grunt.config('builddir', 'release'); - }) - ); - }); - - grunt.registerTask('perform-release', function () { - var version = grunt.config('pkg.version'), releasedir = grunt.config('builddir'); - grunt.task.requires([ 'prepare-release', 'build' ]); - grunt.file.delete(releasedir + "/es5"); - grunt.file.delete(releasedir + "/es6"); - promising(this, - system('git add \'' + releasedir + '\'').then(function () { - return system('git commit -m \'release ' + version + '\''); - }).then(function () { - return system('git tag \'' + version + '\''); - }) - ); - }); - - - // Helpers for custom tasks, mainly around promises / exec - var exec = require('faithful-exec'), shjs = require('shelljs'); - - function system(cmd) { - grunt.log.write('% ' + cmd + '\n'); - return exec(cmd).then(function (result) { - grunt.log.write(result.stderr + result.stdout); - }, function (error) { - grunt.log.write(error.stderr + '\n'); - throw new Error('Failed to run \'' + cmd + '\''); - }); - } - - function promising(task, promise) { - var done = task.async(); - promise.then(function () { - done(); - }, function (error) { - grunt.log.write(error + '\n'); - done(false); - }); - } - - function ensureCleanMaster() { - return exec('git symbolic-ref HEAD').then(function (result) { - if (result.stdout.trim() !== 'refs/heads/master') throw new Error('Not on master branch, aborting'); - return exec('git status --porcelain'); - }).then(function (result) { - if (result.stdout.trim() !== '') throw new Error('Working copy is dirty, aborting'); - }); - } -}; diff --git a/README.md b/README.md index d582bba35..95d48e9f5 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,16 @@ version 0.2.x, it can be found [here](https://github.com/angular-ui/ui-router/tr #### The de-facto solution to flexible routing in angular --- -**[Docs 1.0](https://ui-router.github.io/docs/latest/)** | -**[Download stable](http://angular-ui.github.io/ui-router/release/angular-ui-router.js)** (or **[Minified](http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js)**) **|** +**[Tutorials](https://ui-router.github.io/tutorials/)** | +**[API Docs](https://ui-router.github.io/docs/latest/)** | +**[Download stable](http://npmcdn.com/angular-ui-router@latest/release/angular-ui-router.js)** (or **[Minified](http://npmcdn.com/angular-ui-router@latest/release/angular-ui-router.min.js)**) **|** **[Guide](https://github.com/angular-ui/ui-router/wiki) |** -**[API](http://angular-ui.github.io/ui-router/site) |** -**[Sample](http://ui-router.github.io/sample-app/#/mymessages) ([Src](https://github.com/ui-router/sample-app)) |** +**[Sample App](http://ui-router.github.io/resources/sampleapp/) |** **[FAQ](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions) |** -**[Resources](#resources) |** **[Report an Issue](https://github.com/angular-ui/ui-router/blob/master/CONTRIBUTING.md#report-an-issue) |** **[Contribute](https://github.com/angular-ui/ui-router/blob/master/CONTRIBUTING.md#contribute) |** **[Help!](http://stackoverflow.com/questions/ask?tags=angularjs,angular-ui-router) |** - --- Angular UI-Router is a client-side [Single Page Application](https://en.wikipedia.org/wiki/Single-page_application) @@ -35,205 +33,16 @@ application states in a transaction-like manner. ## Get Started -**(1)** Get UI-Router in one of the following ways: - - clone & [build](CONTRIBUTING.md#developing) this repository - - [download the release](http://angular-ui.github.io/ui-router/release/angular-ui-router.js) (or [minified](http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js)) - - [link to cdn](http://cdnjs.com/libraries/angular-ui-router) - - via **[jspm](http://jspm.io/)**: by running `$ jspm install angular-ui-router` from your console - - or via **[npm](https://www.npmjs.org/)**: by running `$ npm install angular-ui-router` from your console - - or via **[Bower](http://bower.io/)**: by running `$ bower install angular-ui-router` from your console - - or via **[Component](https://github.com/component/component)**: by running `$ component install angular-ui/ui-router` from your console - -**(2)** Include `angular-ui-router.js` (or `angular-ui-router.min.js`) in your `index.html`, after including Angular itself (For Component users: ignore this step) - -**(3)** Add `'ui.router'` to your main module's list of dependencies (For Component users: replace `'ui.router'` with `require('angular-ui-router')`) - -When you're done, your setup should look similar to the following: - -> -```html - - - - - - - ... - - - ... - - -``` - -### [Nested States & Views](http://plnkr.co/edit/u18KQc?p=preview) - -The majority of UI-Router's power is in its ability to nest states & views. - -**(1)** First, follow the [setup](#get-started) instructions detailed above. - -**(2)** Then, add a [`ui-view` directive](https://github.com/angular-ui/ui-router/wiki/Quick-Reference#ui-view) to the `` of your app. - -> -```html - - -
- - State 1 - State 2 - -``` - -**(3)** You'll notice we also added some links with [`ui-sref` directives](https://github.com/angular-ui/ui-router/wiki/Quick-Reference#ui-sref). In addition to managing state transitions, this directive auto-generates the `href` attribute of the `` element it's attached to, if the corresponding state has a URL. Next we'll add some templates. These will plug into the `ui-view` within `index.html`. Notice that they have their own `ui-view` as well! That is the key to nesting states and views. - -> -```html - -

State 1

-
-
Show List -
-``` -```html - -

State 2

-
-Show List -
-``` - -**(4)** Next, we'll add some child templates. *These* will get plugged into the `ui-view` of their parent state templates. - -> -```html - -

List of State 1 Items

-
    -
  • {{ item }}
  • -
-``` - -> -```html - -

List of State 2 Things

-
    -
  • {{ thing }}
  • -
-``` - -**(5)** Finally, we'll wire it all up with `$stateProvider`. Set up your states in the module config, as in the following: - - -> -```javascript -myApp.config(function($stateProvider, $urlRouterProvider) { - // - // For any unmatched url, redirect to /state1 - $urlRouterProvider.otherwise("/state1"); - // - // Now set up the states - $stateProvider - .state('state1', { - url: "/state1", - templateUrl: "partials/state1.html" - }) - .state('state1.list', { - url: "/list", - templateUrl: "partials/state1.list.html", - controller: function($scope) { - $scope.items = ["A", "List", "Of", "Items"]; - } - }) - .state('state2', { - url: "/state2", - templateUrl: "partials/state2.html" - }) - .state('state2.list', { - url: "/list", - templateUrl: "partials/state2.list.html", - controller: function($scope) { - $scope.things = ["A", "Set", "Of", "Things"]; - } - }); -}); -``` - -**(6)** See this quick start example in action. ->**[Go to Quick Start Plunker for Nested States & Views](http://plnkr.co/edit/u18KQc?p=preview)** - -**(7)** This only scratches the surface ->**[Dive Deeper!](https://github.com/angular-ui/ui-router/wiki)** - - -### [Multiple & Named Views](http://plnkr.co/edit/SDOcGS?p=preview) - -Another great feature is the ability to have multiple `ui-view`s view per template. - -**Pro Tip:** *While multiple parallel views are a powerful feature, you'll often be able to manage your -interfaces more effectively by nesting your views, and pairing those views with nested states.* - -**(1)** Follow the [setup](#get-started) instructions detailed above. - -**(2)** Add one or more `ui-view` to your app, give them names. -> -```html - - -
-
- - Route 1 - Route 2 - -``` - -**(3)** Set up your states in the module config: -> -```javascript -myApp.config(function($stateProvider) { - $stateProvider - .state('index', { - url: "", - views: { - "viewA": { template: "index.viewA" }, - "viewB": { template: "index.viewB" } - } - }) - .state('route1', { - url: "/route1", - views: { - "viewA": { template: "route1.viewA" }, - "viewB": { template: "route1.viewB" } - } - }) - .state('route2', { - url: "/route2", - views: { - "viewA": { template: "route2.viewA" }, - "viewB": { template: "route2.viewB" } - } - }) -}); -``` - -**(4)** See this quick start example in action. ->**[Go to Quick Start Plunker for Multiple & Named Views](http://plnkr.co/edit/SDOcGS?p=preview)** +- [UI-Router for Angular 1](https://ui-router.github.io/ng1) +- [UI-Router for Angular 2](https://ui-router.github.io/ng2) +- [UI-Router for React](https://ui-router.github.io/react) ## Resources * [In-Depth Guide](https://github.com/angular-ui/ui-router/wiki) -* [API Reference](http://angular-ui.github.io/ui-router/site) -* [Sample App](http://angular-ui.github.com/ui-router/sample/) ([Source](https://github.com/angular-ui/ui-router/tree/gh-pages/sample)) -* [FAQ](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions) * [Slides comparing ngRoute to ui-router](http://slid.es/timkindberg/ui-router#/) -* [UI-Router Extras / Addons](http://christopherthielen.github.io/ui-router-extras/#/home) (@christopherthielen) +* [UI-Router Extras / Addons for legacy (0.x)](http://christopherthielen.github.io/ui-router-extras/#/home) (@christopherthielen) ### Videos @@ -242,8 +51,6 @@ myApp.config(function($stateProvider) { * [Activating States](https://egghead.io/lessons/angularjs-ui-router-activating-states) (egghead.io) * [Learn Angular.js using UI-Router](http://youtu.be/QETUuZ27N0w) (LearnCode.academy) - - ## Reporting issues and Contributing Please read our [Contributor guidelines](CONTRIBUTING.md) before reporting an issue or creating a pull request. diff --git a/package.json b/package.json index 4233dd0ce..0c59bfdbf 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,9 @@ "test:ng13": "karma start config/karma.ng13.js", "test:ng14": "karma start config/karma.ng14.js", "test:ng15": "karma start config/karma.ng15.js", - "test:integrate": "tsc && npm run test:core && npm run test:ng12 && npm run test:ng13 && npm run test:ng14 && npm run test:ng15" + "test:integrate": "tsc && npm run test:core && npm run test:ng12 && npm run test:ng13 && npm run test:ng14 && npm run test:ng15", + "build": "node ./scripts/package.js core && node ./scripts/package.js ng1 && node ./scripts/package.js ng2", + "docs": "./scripts/docs.sh" }, "homepage": "https://ui-router.github.io", "contributors": [ @@ -66,21 +68,8 @@ "es6-module-loader": "^0.17.3", "es6-promise": "^3.0.2", "es6-shim": "^0.35.0", - "faithful-exec": "~0.1.0", "glob": "^7.0.5", - "grunt": "~0.4.1", - "grunt-contrib-clean": "~0.5.0", - "grunt-contrib-connect": "~0.7.1", - "grunt-contrib-uglify": "~0.4.0", - "grunt-contrib-watch": "~0.5.3", - "grunt-conventional-changelog": "~1.1.0", - "grunt-karma": "~0.11.2", - "grunt-ngdocs": "~0.1.7", - "grunt-shell": "^1.1.2", - "grunt-ts": "^5.2.0", - "grunt-webpack": "^1.0.10", "jasmine-core": "^2.4.1", - "jsdoc": "git://github.com/jsdoc3/jsdoc.git#v3.2.2", "karma": "^1.2.0", "karma-chrome-launcher": "~0.1.0", "karma-coverage": "^0.5.3", @@ -88,7 +77,6 @@ "karma-phantomjs-launcher": "~0.1.0", "karma-script-launcher": "~0.1.0", "karma-systemjs": "^0.7.2", - "load-grunt-tasks": "~0.4.0", "lodash": "^4.5.1", "parallelshell": "^2.0.0", "phantomjs-polyfill": "0.0.1",