Skip to content

Commit 8d62b0d

Browse files
chore(core): Switch from ui-router-core to @uirouter/core
1 parent af0b8d4 commit 8d62b0d

34 files changed

+595
-462
lines changed

.travis.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ before_script:
2121

2222
script:
2323
- echo "CORE_BRANCH = x${CORE_BRANCH}x";
24-
# Fetch and build the ui-router-core branch from github, then install it
24+
# Fetch and build the @uirouter/core branch from github, then install it
2525
- >
2626
if [ "x${CORE_BRANCH}x" != "xx" ] ; then
27-
echo "Installing ui-router-core from ${CORE_BRANCH}" && \
28-
git clone --depth=10 --branch="${CORE_BRANCH}" https://github.com/ui-router/core.git ui-router-core && \
29-
pushd ui-router-core && \
27+
echo "Installing @uirouter/core from ${CORE_BRANCH}" && \
28+
git clone --depth=10 --branch="${CORE_BRANCH}" https://github.com/ui-router/core.git @uirouter/core && \
29+
pushd @uirouter/core && \
3030
yarn > /dev/null && \
3131
yarn build && \
3232
popd && \
33-
npm install ./ui-router-core ;
33+
npm install ./@uirouter/core ;
3434
fi
3535
- tsc && npm test
3636

@@ -40,11 +40,11 @@ matrix:
4040

4141
env:
4242
matrix:
43-
# CORE_BRANCH env variable specifies the branch of ui-router-core to use during build/test
43+
# CORE_BRANCH env variable specifies the branch of @uirouter/core to use during build/test
4444
# Each CORE_BRANCH listed here will trigger a SEPARATE job in travis
4545
- CORE_BRANCH=master
4646

47-
# If CORE_BRANCH is empty, it will use the ui-router-core from npm dependencies
47+
# If CORE_BRANCH is empty, it will use the @uirouter/core from npm dependencies
4848
# (as specified in package.json)
4949
- CORE_BRANCH=
5050

CONTRIBUTING.md

+26-24
Original file line numberDiff line numberDiff line change
@@ -49,63 +49,65 @@ If your issue gets labeled with purple label, no further action will be taken un
4949

5050
# Developing
5151

52-
UI-Router uses <code>npm</code> and <code>webpack</code>.
52+
UI-Router uses <code>npm</code> and <code>Rollup</code>.
5353

5454
## Fetch the source code
5555

5656
The code for Angular UI-Router is split into two source repositories:
5757

58-
* [UI-Router Core](https://github.com/ui-router/core) (`ui-router-core` on npm)
59-
* [UI-Router for Angular 1](https://github.com/angular-ui/ui-router) (`angular-ui-router` on npm)
58+
* [UI-Router Core](https://github.com/ui-router/core) (`@uirouter/core` on npm)
59+
* [UI-Router for Angular 1](https://github.com/angular-ui/ui-router) (`@ui-router/angularjs` on npm)
6060

6161
Clone both repositories into directories next to each other.
6262

6363
```
64-
git clone https://github.com/angular-ui/ui-router.git angular-ui-router
65-
git clone https://github.com/ui-router/core.git ui-router-core
64+
mkdir uirouter
65+
cd uirouter
66+
git clone https://github.com/angular-ui/ui-router.git angularjs
67+
git clone https://github.com/ui-router/core.git core
6668
```
6769

6870
## Install dependencies
6971

70-
Use `npm` to install the development dependencies for each repositor.
72+
Use `npm` to install the development dependencies for each repository.
7173

7274
```
73-
cd ui-router-core
75+
cd core
7476
npm install
75-
cd ../angular-ui-router
77+
cd ../angularjs
7678
npm install
7779
cd ..
7880
```
7981

8082
## Link the directories
8183

82-
This step is necessary if you need to modify any code in `ui-router-core`.
83-
Using `npm`, link `ui-router-core` into `angular-ui-router`
84+
This step is necessary if you need to modify any code in `@uirouter/core`.
85+
Using `npm`, link `@uirouter/core` into `angular-ui-router`
8486

8587
```
86-
cd ui-router-core
88+
cd core
8789
npm link
88-
cd ../angular-ui-router
89-
npm link ui-router-core
90+
cd ../angularjs
91+
npm link '@uirouter/core'
9092
```
9193

92-
After executing these steps, `angular-ui-router` will be built using your local copy of `ui-router-core`.
94+
After executing these steps, `@uirouter/angularjs` will be depend on your local copy of `@uirouter/core` instead of the version listed in `package.json`.
9395

9496
## Develop
9597

96-
These scripts may be run in `angular-ui-router`:
98+
These scripts may be run in the `angularjs` directory:
9799

98100
* `npm run build`: Compiles TypeScript source
99-
* `npm run package`: Compiles TypeScript source and creates webpack bundles.
100-
* `npm test`: Runs the `angular-ui-router` test suite (against Angular 1.2 through 1.5).
101-
* `npm run watch`: Continuously compiles the source and runs the `angular-ui-router` tests (when source or tests change).
101+
* `npm run package`: Compiles TypeScript source and creates the Rollup bundles.
102+
* `npm test`: Runs the test suite (against Angular 1.2 through 1.5).
103+
* `npm run watch`: Continuously compiles the source and runs the test suite (when either source or tests change).
102104

103-
Scripts of the same name (in `ui-router-core`) can be used.
105+
Scripts of the same name (in the `core` directory) can be used.
104106

105-
* `npm run build`: Compiles `ui-router-core` TypeScript source
106-
* `npm test`: Runs the `ui-router-core` test suite
107-
* `npm run watch`: Continuously compiles the source and runs the `ui-router-core` test suite (when core source or tests change).
107+
* `npm run build`: Compiles `@uirouter/core` TypeScript source
108+
* `npm test`: Runs the `@uirouter/core` test suite
109+
* `npm run watch`: Continuously compiles the source and runs the `@uirouter/core` test suite (when core source or tests change).
108110

109111
If you've followed the [linking instructions](#link-the-directories), it's useful to run both
110-
`npm run watch` tasks (each task from `ui-router-core` *and* `angular-ui-router`).
111-
This ensures that changes to either `ui-router-core` and `angular-ui-router` compile successfully and are run against the test suite.
112+
`npm run watch` tasks (each task from `@uirouter/core` *and* `@uirouter/angularjs`).
113+
This ensures that changes to either `@uirouter/core` and `@uirouter/angularjs` compile successfully and are run against their test suites.

DOCS.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ The documentation reflects the Typescript classes, interfaces, and parameter typ
3737

3838
#### Contributing
3939

40-
Angular UI-Router depends on the framework agnostic `ui-router-core`.
40+
Angular UI-Router depends on the framework agnostic `@uirouter/core`.
4141
To contribute to the documentation, please submit a PR to either
42-
[angular-ui-router](http://github.com/angular-ui/ui-router)
42+
[@uirouter/angularjs](http://github.com/angular-ui/ui-router)
4343
or
44-
[ui-router-core](http://github.com/ui-router/core).
44+
[@uirouter/core](http://github.com/ui-router/core).
4545
To find where a specific piece of documentation is written, follow the links that say:
4646
> _Defined in ui-router/somedir/somefile.ts_
4747

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "angular-ui-router",
33
"description": "State-based routing for AngularJS 1.x",
4-
"version": "1.0.0-rc.1",
4+
"version": "1.0.0",
55
"scripts": {
66
"clean": "shx rm -rf lib lib-esm _doc build release *.log",
77
"build": "tsc && tsc -m es6 --outDir lib-esm && npm run fixdts",
@@ -11,6 +11,7 @@
1111
"bundle_router": "rollup -c --environment ROUTER && rollup -c --environment ROUTER,MINIFY",
1212
"bundle_events": "rollup -c --environment EVENTS && rollup -c --environment EVENTS,MINIFY",
1313
"bundle_resolve": "rollup -c --environment RESOLVE && rollup -c --environment RESOLVE,MINIFY",
14+
"prepare": "npm run package",
1415
"noimplicitany": "tsc --noEmit --noImplicitAny --moduleResolution node --target es6 test/noimplicitany.ts",
1516
"test": "npm run test:integrate",
1617
"test:ng12": "karma start --ngversion 1.2",
@@ -65,7 +66,7 @@
6566
"jsnext:main": "lib-esm/index.js",
6667
"typings": "lib/index.d.ts",
6768
"dependencies": {
68-
"ui-router-core": "^5.0.0"
69+
"@uirouter/core": "5.0.0"
6970
},
7071
"peerDependencies": {
7172
"angular": ">=1.2.0"
@@ -106,7 +107,7 @@
106107
"shelljs": "^0.7.0",
107108
"shx": "^0.1.4",
108109
"systemjs": "^0.18.4",
109-
"tslint": "=2.5.0",
110+
"tslint": "^5.1.0",
110111
"typedoc": "~0.5.0",
111112
"typedoc-plugin-external-module-name": "^1.0.2",
112113
"typedoc-plugin-internal-external": "^1.0.0",

rollup.config.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ const EVENTS_CONFIG = Object.assign({}, BASE_CONFIG, {
5454
moduleName: 'angular-ui-router-state-events',
5555
entry: 'lib-esm/legacy/stateEvents.js',
5656
dest: 'release/stateEvents' + extension,
57-
globals: { angular: 'angular', 'ui-router-core': 'ui-router-core' },
58-
external: ['angular', 'ui-router-core'],
57+
globals: { angular: 'angular', '@uirouter/core': '@uirouter/core' },
58+
external: ['angular', '@uirouter/core'],
5959
});
6060

6161
const RESOLVE_CONFIG = Object.assign({}, BASE_CONFIG, {
6262
moduleName: 'angular-ui-router-resolve-service',
6363
entry: 'lib-esm/legacy/resolveService.js',
6464
dest: 'release/resolveService' + extension,
65-
globals: { angular: 'angular', 'ui-router-core': 'ui-router-core' },
66-
external: ['angular', 'ui-router-core'],
65+
globals: { angular: 'angular', '@uirouter/core': '@uirouter/core' },
66+
external: ['angular', '@uirouter/core'],
6767
});
6868

6969
const CONFIG =

scripts/docs.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ let typedocCmd = [
1616
].join(" ");
1717

1818
let PROJECTDIR = path.join(__dirname, '..');
19-
let PROJ2 = 'ui-router-core';
2019

2120
shelljs.pushd(PROJECTDIR);
2221

@@ -25,25 +24,25 @@ shelljs.mv('src', 'src.bak');
2524
shelljs.cp('-r', 'src.bak', 'src');
2625

2726
let arr = [];
28-
// This replaces "ui-router-core" with "../../../ui-router-core"
27+
// This replaces "@uirouter/core" with "../../../core"
2928
// while accounting for how many "../../" should be prepended
3029
for (var i = 0; i < 5; i++) {
3130
arr.push(arr.length);
3231

3332
let dots = arr.map((val) => '..').join('/');
3433
let stars = arr.map((val) => '*').join('/');
3534

36-
// Replace references to "ui-router-core/lib" with "../ui-router-core/lib" for typedoc
35+
// Replace references to "@uirouter/core/lib" with "../core/lib" for typedoc
3736
replaceInFiles.sync({
38-
replace: / (['"])ui-router-core\/lib/g,
39-
with: ' $1' + dots + '/../ui-router-core/src',
37+
from: / (['"])\@uirouter\/core\/lib/g,
38+
to: ' $1' + dots + '/../core/src',
4039
files: 'src/' + stars + '.ts'
4140
});
4241

43-
// Replace references to "ui-router-core" with "../ui-router-core" for typedoc
42+
// Replace references to "@uirouter/core" with "../core" for typedoc
4443
replaceInFiles.sync({
45-
replace: / (['"])ui-router-core/g,
46-
with: ' $1' + dots + '/../ui-router-core/src',
44+
from: / (['"])\@uirouter\/core/g,
45+
to: ' $1' + dots + '/../core/src',
4746
files: 'src/' + stars + '.ts'
4847
});
4948
}

scripts/show_core_changelog.js

+23-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
#!env node
22
"use strict";
3+
34
var gitSemverTags = require('git-semver-tags');
45
var shelljs = require('shelljs');
56
var path = require('path');
67
var fs = require('fs');
78

8-
var CORE_PKG = 'ui-router-core';
9-
var CORE_DIR = path.join(__dirname, "..", "..", CORE_PKG);
9+
var CORE_PKG = `@uirouter/core`;
10+
var ALT_CORE_PKG = `ui-router-core`;
11+
var CORE_DIR = path.join(__dirname, "..", "..", 'core');
1012
var SHOWCHANGELOG_SCRIPT = path.join(CORE_DIR, "scripts", "show_changelog.js");
1113

1214
var currentPackage = require('../package.json');
13-
if (!currentPackage.dependencies || !currentPackage.dependencies[CORE_PKG]) {
15+
if (!currentPackage.dependencies || (!currentPackage.dependencies[CORE_PKG] && !currentPackage[ALT_CORE_PKG])) {
16+
console.error(stringify(currentPackage.dependencies));
1417
throw new Error("No dependency on " + CORE_PKG + " found in package.json.")
1518
}
1619

@@ -33,23 +36,34 @@ gitSemverTags(function (err, val) {
3336
try {
3437
prevPackage = JSON.parse(prevRaw);
3538
} catch (error) {
36-
console.error("Unable to parse previous package.json");
39+
console.error("Unable to parse previous package.json in ${val[0]}");
3740
console.error(prevRaw);
3841
throw error;
3942
}
4043

4144
if (!prevPackage.dependencies) {
42-
throw new Error("previous package.json has no `dependencies` key.");
43-
} else if (!prevPackage.dependencies[CORE_PKG]) {
44-
throw new Error("previous package.json has no `dependencies['ui-router-core']` key.");
45+
console.error(stringify(prevPackage));
46+
throw new Error(`previous package.json in ${val[0]} has no "dependencies" key.`);
47+
} else if (!prevPackage.dependencies[CORE_PKG] && !prevPackage.dependencies[ALT_CORE_PKG]) {
48+
console.error(stringify(prevPackage.dependencies));
49+
throw new Error(`previous package.json in ${val[0]} has no "dependencies['${CORE_PKG}']" key.`);
4550
}
4651

47-
fromTag = prevPackage.dependencies[CORE_PKG].replace(/[=~^]/, "");
52+
var prevDep = prevPackage.dependencies[CORE_PKG] || prevPackage.dependencies[ALT_CORE_PKG];
53+
fromTag = prevDep.replace(/[=~^]/, "");
4854
}
4955

50-
var toTag = require("../package.json").dependencies[CORE_PKG].replace(/[=~^]/g, "");
56+
let pkg = require("../package.json");
57+
let currentDep = pkg.dependencies[CORE_PKG] || pkg.dependencies[ALT_CORE_PKG];
58+
var toTag = currentDep.replace(/[=~^]/g, "");
59+
5160
shelljs.pushd(CORE_DIR);
5261
// console.log("node " + SHOWCHANGELOG_SCRIPT + " " + fromTag + " " + toTag)
5362
shelljs.config.silent = false;
5463
shelljs.exec("node " + SHOWCHANGELOG_SCRIPT + " " + fromTag + " " + toTag)
5564
});
65+
66+
67+
function stringify(object) {
68+
return JSON.stringify(object, null, 2);
69+
}

src/directives/stateDirectives.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { IAugmentedJQuery, ITimeoutService, IScope, IInterpolateService } from "
1414
import {
1515
Obj, extend, forEach, tail, isString, isObject, isArray, parse, noop, unnestR, identity, uniqR, inArray, removeFrom,
1616
RawParams, PathNode, StateOrName, StateService, StateDeclaration, UIRouter
17-
} from "ui-router-core";
17+
} from "@uirouter/core";
1818
import { UIViewData } from "./viewDirective";
1919

2020
/** @hidden Used for typedoc */

src/directives/viewDirective.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
extend, unnestR, filter, tail, isDefined, isFunction, isString, trace, parse,
1313
ActiveUIView, TransitionService, ResolveContext, Transition, PathNode, StateDeclaration,
1414
Param, kebobString, HookRegOptions, ViewService, $QLike, Obj, TypedMap
15-
} from "ui-router-core";
15+
} from "@uirouter/core";
1616
import {Ng1ViewConfig} from "../statebuilders/views";
1717
import {Ng1Controller, Ng1StateDeclaration} from "../interface";
1818
import {getLocals} from "../services";

src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* @module ng1
44
*/ /** */
55

6-
import * as core from "ui-router-core";
6+
import * as core from "@uirouter/core";
77
export { core };
8-
export * from "ui-router-core";
8+
export * from "@uirouter/core";
99

1010
export * from "./interface";
1111
export * from "./services";

src/injectables.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import { StateProvider } from "./stateProvider";
5555
import {
5656
StateService, TransitionService, Transition, UrlRouter, UrlMatcherFactory,
5757
StateParams, StateRegistry, UIRouterGlobals, UIRouter, Trace, UrlService
58-
} from "ui-router-core";
58+
} from "@uirouter/core";
5959
import { UIViewScrollProvider } from "./viewScroll";
6060
import { UrlRouterProvider } from "./urlRouterProvider";
6161

src/interface.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @ng1api
33
* @module ng1
44
*/ /** */
5-
import { StateDeclaration, _ViewDeclaration, IInjectable, Transition, HookResult } from "ui-router-core";
5+
import { StateDeclaration, _ViewDeclaration, IInjectable, Transition, HookResult } from "@uirouter/core";
66

77

88
/**
@@ -45,7 +45,7 @@ import { StateDeclaration, _ViewDeclaration, IInjectable, Transition, HookResult
4545
* @returns an optional [[HookResult]] which may alter the transition
4646
*/
4747
export interface Ng1StateTransitionHook {
48-
(...injectables: any[]) : HookResult
48+
(...injectables: any[]) : HookResult;
4949
}
5050

5151
/**
@@ -741,8 +741,8 @@ export interface TemplateFactoryProvider {
741741
useHttpService(useUnsafeHttpService: boolean);
742742
}
743743

744-
declare module "ui-router-core/lib/state/stateRegistry" {
744+
declare module "@uirouter/core/lib/state/stateRegistry" {
745745
interface StateRegistry {
746-
register(state: Ng1StateDeclaration)
746+
register(state: Ng1StateDeclaration);
747747
}
748748
}

src/legacy/resolveService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @module ng1 */ /** */
2-
import { StateObject, PathNode, ResolveContext, Obj, mapObj, resolvablesBuilder } from "ui-router-core";
2+
import { StateObject, PathNode, ResolveContext, Obj, mapObj, resolvablesBuilder } from "@uirouter/core";
33
import * as angular from "angular";
44

55
/**

src/legacy/stateEvents.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { ng as angular } from "../angular";
2222
import { IScope, IAngularEvent, IServiceProviderFactory } from "angular";
2323
import {
2424
Obj, TargetState, StateService, Transition, TransitionService, UrlRouter, HookResult, UIInjector
25-
} from "ui-router-core";
25+
} from "@uirouter/core";
2626
import { StateProvider } from "../stateProvider";
2727

2828
/**

src/locationServices.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @internalapi
33
* @module ng1
44
*/ /** */
5-
import { LocationConfig, LocationServices, UIRouter, ParamType } from "ui-router-core";
6-
import { val, createProxyFunctions, removeFrom, isObject } from "ui-router-core";
5+
import { LocationConfig, LocationServices, UIRouter, ParamType } from "@uirouter/core";
6+
import { val, createProxyFunctions, removeFrom, isObject } from "@uirouter/core";
77
import { ILocationService, ILocationProvider } from "angular";
88

99
/**

0 commit comments

Comments
 (0)