Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 52022ee

Browse files
gkalpakpetebacondarwin
authored andcommitted
chore(*): switch from bower to npm for frontend dependencies
Closes #385 Closes #389
1 parent 9ca1782 commit 52022ee

9 files changed

+38
-57
lines changed

.bowerrc

-3
This file was deleted.

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
logs/*
22
!.gitkeep
33
node_modules/
4-
bower_components/
4+
app/lib/
55
tmp
66
.DS_Store
77
.idea

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ dist: trusty
33

44
language: node_js
55
node_js:
6-
- '4.5'
6+
- 6
77

88
install:
99
- export DISPLAY=:99.0

README.md

+11-14
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,26 @@ The `depth=1` tells git to only pull down one commit worth of historical data.
4242
We have two kinds of dependencies in this project: tools and Angular framework code. The tools help
4343
us manage and test the application.
4444

45-
* We get the tools we depend upon via `npm`, the [Node package manager][npm].
46-
* We get the Angular code via `bower`, a [client-side code package manager][bower].
45+
* We get the tools we depend upon and the Angular code via `npm`, the [Node package manager][npm].
4746
* In order to run the end-to-end tests, you will also need to have the
4847
[Java Development Kit (JDK)][jdk] installed on your machine. Check out the section on
4948
[end-to-end testing](#e2e-testing) for more info.
5049

51-
We have preconfigured `npm` to automatically run `bower` so we can simply do:
50+
We have preconfigured `npm` to automatically copy the downloaded Angular files to `app/lib` so we
51+
can simply do:
5252

5353
```
5454
npm install
5555
```
5656

57-
Behind the scenes this will also call `bower install`. After that, you should find out that you have
58-
two new folders in your project.
57+
Behind the scenes this will also call `npm run copy-libs`, which copies the AngularJS files and other
58+
frontend dependencies. After that, you should find out that you have two new directories in your project.
5959

6060
* `node_modules` - contains the npm packages for the tools we need
61-
* `app/bower_components` - contains the Angular framework files
61+
* `app/lib` - contains the Angular framework files and other frontend dependencies
6262

63-
*Note that the `bower_components` folder would normally be installed in the root folder but
64-
`angular-seed` changes this location through the `.bowerrc` file. Putting it in the `app` folder
65-
makes it easier to serve the files by a web server.*
63+
*Note copying the Angular files from `node_modules` to `app/lib` makes it easier to serve the files
64+
by a web server.*
6665

6766
### Run the Application
6867

@@ -198,9 +197,8 @@ script:
198197
npm run update-deps
199198
```
200199

201-
This will call `npm update` and `bower update`, which in turn will find and install the latest
202-
versions that match the version ranges specified in the `package.json` and `bower.json` files
203-
respectively.
200+
This will call `npm update` and `npm run copy-libs`, which in turn will find and install the latest
201+
versions that match the version ranges specified in the `package.json` file.
204202

205203

206204
## Loading Angular Asynchronously
@@ -236,7 +234,7 @@ choose to install the tool globally:
236234
sudo npm install -g http-server
237235
```
238236

239-
Then you can start your own development web server to serve static files from a folder by running:
237+
Then you can start your own development web server to serve static files from any folder by running:
240238

241239
```
242240
http-server -a localhost -p 8000
@@ -279,7 +277,6 @@ For more information on AngularJS please check out [angularjs.org][angularjs].
279277

280278

281279
[angularjs]: https://angularjs.org/
282-
[bower]: http://bower.io/
283280
[git]: https://git-scm.com/
284281
[http-server]: https://github.com/indexzero/http-server
285282
[jasmine]: https://jasmine.github.io/

app/index-async.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/normalize.css">
6-
<link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/main.css">
5+
<link rel="stylesheet" href="lib/html5-boilerplate/dist/css/normalize.css">
6+
<link rel="stylesheet" href="lib/html5-boilerplate/dist/css/main.css">
77
<style>
88
[ng-cloak] {
99
display: none;
1010
}
1111
</style>
12-
<script src="bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
12+
<script src="lib/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
1313
<script>
1414
// include angular loader, which allows the files to load in any order
1515
//@@NG_LOADER_START@@
@@ -28,8 +28,8 @@
2828

2929
// load all of the dependencies asynchronously.
3030
$script([
31-
'bower_components/angular/angular.js',
32-
'bower_components/angular-route/angular-route.js',
31+
'lib/angular/angular.js',
32+
'lib/angular-route/angular-route.js',
3333
'app.js',
3434
'view1/view1.js',
3535
'view2/view2.js',

app/index.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
<title>My AngularJS App</title>
1010
<meta name="description" content="">
1111
<meta name="viewport" content="width=device-width, initial-scale=1">
12-
<link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/normalize.css">
13-
<link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/main.css">
12+
<link rel="stylesheet" href="lib/html5-boilerplate/dist/css/normalize.css">
13+
<link rel="stylesheet" href="lib/html5-boilerplate/dist/css/main.css">
1414
<link rel="stylesheet" href="app.css">
15-
<script src="bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
15+
<script src="lib/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
1616
</head>
1717
<body>
1818
<ul class="menu">
@@ -31,8 +31,8 @@
3131
<!-- In production use:
3232
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
3333
-->
34-
<script src="bower_components/angular/angular.js"></script>
35-
<script src="bower_components/angular-route/angular-route.js"></script>
34+
<script src="lib/angular/angular.js"></script>
35+
<script src="lib/angular-route/angular-route.js"></script>
3636
<script src="app.js"></script>
3737
<script src="view1/view1.js"></script>
3838
<script src="view2/view2.js"></script>

bower.json

-15
This file was deleted.

karma.conf.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module.exports = function(config) {
55
basePath: './app',
66

77
files: [
8-
'bower_components/angular/angular.js',
9-
'bower_components/angular-route/angular-route.js',
10-
'bower_components/angular-mocks/angular-mocks.js',
8+
'lib/angular/angular.js',
9+
'lib/angular-route/angular-route.js',
10+
'../node_modules/angular-mocks/angular-mocks.js',
1111
'components/**/*.js',
1212
'view*/**/*.js'
1313
],

package.json

+12-10
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55
"description": "A starter project for AngularJS",
66
"repository": "https://github.com/angular/angular-seed",
77
"license": "MIT",
8+
"dependencies": {
9+
"angular": "^1.5.9",
10+
"angular-loader": "^1.5.9",
11+
"angular-route": "^1.5.9",
12+
"html5-boilerplate": "0.0.1"
13+
},
814
"devDependencies": {
9-
"bower": "^1.7.7",
15+
"angular-mocks": "^1.5.9",
16+
"cpx": "^1.5.0",
1017
"http-server": "^0.9.0",
1118
"jasmine-core": "^2.4.1",
1219
"karma": "^0.13.22",
@@ -17,24 +24,19 @@
1724
"protractor": "^4.0.9"
1825
},
1926
"scripts": {
20-
"postinstall": "bower install",
21-
27+
"postinstall": "npm run copy-libs",
2228
"update-deps": "npm update",
23-
"postupdate-deps": "bower update",
24-
29+
"postupdate-deps": "npm run copy-libs",
30+
"copy-libs": "cpx \"node_modules/{angular,angular-*,html5-boilerplate}/**/*\" app/lib -C",
2531
"prestart": "npm install",
2632
"start": "http-server -a localhost -p 8000 -c-1 ./app",
27-
2833
"pretest": "npm install",
2934
"test": "karma start karma.conf.js",
3035
"test-single-run": "karma start karma.conf.js --single-run",
31-
3236
"preupdate-webdriver": "npm install",
3337
"update-webdriver": "webdriver-manager update",
34-
3538
"preprotractor": "npm run update-webdriver",
3639
"protractor": "protractor e2e-tests/protractor.conf.js",
37-
38-
"update-index-async": "node -e \"var fs=require('fs'),indexFile='app/index-async.html',loaderFile='app/bower_components/angular-loader/angular-loader.min.js',loaderText=fs.readFileSync(loaderFile,'utf-8').split(/sourceMappingURL=angular-loader.min.js.map/).join('sourceMappingURL=bower_components/angular-loader/angular-loader.min.js.map'),indexText=fs.readFileSync(indexFile,'utf-8').split(/\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/).join('//@@NG_LOADER_START@@\\n'+loaderText+' //@@NG_LOADER_END@@');fs.writeFileSync(indexFile,indexText);\""
40+
"update-index-async": "node -e \"var fs=require('fs'),indexFile='app/index-async.html',loaderFile='app/lib/angular-loader/angular-loader.min.js',loaderText=fs.readFileSync(loaderFile,'utf-8').split(/sourceMappingURL=angular-loader.min.js.map/).join('sourceMappingURL=lib/angular-loader/angular-loader.min.js.map'),indexText=fs.readFileSync(indexFile,'utf-8').split(/\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/).join('//@@NG_LOADER_START@@\\n'+loaderText+' //@@NG_LOADER_END@@');fs.writeFileSync(indexFile,indexText);\""
3941
}
4042
}

0 commit comments

Comments
 (0)