Skip to content

Commit 329d1cd

Browse files
committed
Refactor build automation to use single file (run.js)
1 parent 37a8a89 commit 329d1cd

39 files changed

+301
-475
lines changed

README.md

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616

1717
### Features
1818

19-
&nbsp; &nbsp; ✓ Component-based front-end development via [Webpack](https://webpack.github.io/), [CSS Modules](https://github.com/css-modules/css-modules) and [React](https://facebook.github.io/react) (see [`tools/webpack.config.js`](./tools/webpack.config.js))<br>
19+
&nbsp; &nbsp; ✓ Component-based front-end development via [Webpack](https://webpack.github.io/), [CSS Modules](https://github.com/css-modules/css-modules) and [React](https://facebook.github.io/react) (see [`tools/webpack.config.js`](webpack.config.js))<br>
2020
&nbsp; &nbsp; ✓ Modern JavaScript syntax ([ES2015](http://babeljs.io/docs/learn-es2015/)+) via [Babel](http://babeljs.io/); modern CSS syntax (CSS3+) via [PostCSS](https://github.com/postcss/postcss)<br>
21-
&nbsp; &nbsp; ✓ Application state management via [Redux](http://redux.js.org/) (see [`client/core/store.js`](./client/core/store.js))<br>
22-
&nbsp; &nbsp; ✓ Universal cross-stack routing and navigation via [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp) and [`history`](https://github.com/ReactJSTraining/history) (see [`client/routes.json`](./client/routes.json))<br>
21+
&nbsp; &nbsp; ✓ Application state management via [Redux](http://redux.js.org/) (see [`client/core/store.js`](client/core/store.js))<br>
22+
&nbsp; &nbsp; ✓ Universal cross-stack routing and navigation via [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp) and [`history`](https://github.com/ReactJSTraining/history) (see [`client/routes.json`](client/routes.json))<br>
2323
&nbsp; &nbsp;[Code-splitting](https://github.com/webpack/docs/wiki/code-splitting) and async chunk loading with [Webpack](https://webpack.github.io/) and [ES6 System.import()](http://www.2ality.com/2014/09/es6-modules-final.html)<br>
2424
&nbsp; &nbsp; ✓ Hot Module Replacement ([HMR](https://webpack.github.io/docs/hot-module-replacement.html)) /w [React Hot Loader](http://gaearon.github.io/react-hot-loader/) (coming soon)<br>
25+
&nbsp; &nbsp; ✓ Lightweight build automation with plain JavaScript (see [`run.js`](run.js))<br>
2526
&nbsp; &nbsp; ✓ Cross-device testing with [Browsersync](https://browsersync.io/) (coming soon)<br>
26-
&nbsp; &nbsp; ✓ Git-based deployment to [Azure App Service](https://azure.microsoft.com/services/app-service/) (see [`tools/deploy.js`](./tools/deploy.js))<br>
27+
&nbsp; &nbsp; ✓ Git-based deployment to [Azure App Service](https://azure.microsoft.com/services/app-service/) (see [`run.js/publish`](run.js))<br>
2728
&nbsp; &nbsp; ✓ 24/7 community support on [Gitter](https://gitter.im/kriasoft/aspnet-starter-kit) or [StackOverflow](http://stackoverflow.com/questions/tagged/aspnet-starter-kit); customization requests on [Codementor](https://www.codementor.io/koistya)<br>
2829

2930

@@ -34,23 +35,37 @@
3435
├── /.vscode/ # Visual Studio Code settings
3536
├── /build/ # The folder for compiled output
3637
├── /client/ # Client-side app (frontend)
38+
│ ├── /components/ # Common or shared UI components
39+
│ ├── /core/ # Core framework files such as router, store etc.
40+
│ ├── /utils/ # Helper functions and utility classes
41+
│ ├── /views/ # UI components for web pages (screens)
42+
│ ├── history.js # HTML5 History API wrapper used for navigation
43+
│ ├── main.js # Entry point that bootstraps the app
44+
│ ├── router.js # Lightweight application router
45+
│ ├── routes.json # The list of application routes
46+
│ └── store.js # Application state manager (Redux)
3747
├── /client.test/ # Unit and integration tests for the frontend app
3848
├── /public/ # Static files such as favicon.ico etc.
3949
├── /server/ # Web server and data API (backend)
50+
│ ├── /Controllers/ # ASP.NET Web API and MVC controllers
51+
│ ├── /Models/ # Entity Framework models (entities)
52+
│ ├── /Views/ # Server-side rendered views
53+
│ ├── appsettings.json # Server-side application settings
54+
│ ├── Startup.cs # Server-side application entry point
55+
│ └── web.config # Web server settings for IIS
4056
├── /server.test/ # Unit and integration tests for the backend app
41-
├── /tools/ # Build automation scripts and utilities
4257
│── jsconfig.json # Visual Studio Code settings for JavaScript
43-
│── LICENSE.txt # Licensing information
4458
│── package.json # The list of project dependencies and NPM scripts
45-
└── README.md # Project overview / getting started guide
59+
│── run.js # Build automation script (similar to gulpfile.js)
60+
└── webpack.config.js # Bundling and optimization settings for Webpack
4661
```
4762

4863

4964
### Prerequisites
5065

5166
* OS X, Windows or Linux
5267
* [Node.js](https://nodejs.org) v6 or newer
53-
* [.NET Core v1.0 RC2](https://blogs.msdn.microsoft.com/dotnet/2016/05/16/announcing-net-core-rc2/)
68+
* [.NET Core SDK](https://www.microsoft.com/net/core)
5469
* [Visual Studio Code](https://code.visualstudio.com/) with [C# extension](https://github.com/OmniSharp/omnisharp-vscode)
5570

5671

@@ -72,8 +87,8 @@ $ npm install -g generator-aspnetcore
7287
$ yo aspnetcore
7388
```
7489

75-
`2`. Install project dependencies listed in [`project.json`](./server/project.json) and
76-
[`package.json`](./package.json) files:
90+
`2`. Install project dependencies listed in [`project.json`](server/project.json) and
91+
[`package.json`](package.json) files:
7792

7893
```shell
7994
$ npm install # Install both Node.js and .NET Core dependencies
@@ -82,22 +97,23 @@ $ npm install # Install both Node.js and .NET Core dependencie
8297
`3`. Finally, launch the web app:
8398

8499
```shell
85-
$ npm start # Compile and lanch the app
100+
$ npm start # Compile and lanch the app, same as running: node run
86101
```
87102

88-
The app should become available at [http://localhost:5000/](http://localhost:5000/)
103+
The app should become available at [http://localhost:5000/](http://localhost:5000/).
104+
See [`run.js`](run.js) for other available commands such as `npm run build`, `npm run publish` etc.
89105

90106

91107
### How to Deploy
92108

93109
Before you can deploy your app to [Azure App Service](https://azure.microsoft.com/services/app-service/),
94110
you need to open Web App settings in [Azure Portal](https://portal.azure.com/), go to "Deployment
95111
Source", select "Local Git Repository" and hit [OK]. Then copy and paste "Git clone URL" of your
96-
Web App into [`tools/deploy.js`](./tools/deploy.js) file. Then, whenever you need to compile your
112+
Web App into [`run.js/publish`](run.js) file. Finally, whenever you need to compile your
97113
app into a distributable format and upload that to Windows Azure App Service, simply run:
98114

99115
```shell
100-
$ npm run deploy # Same as running: node tools/deploy --production
116+
$ npm run publish # Same as running: node run publish --release
101117
```
102118

103119
### How to Update

client.test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* ASP.NET Core Starter Kit
2+
* ASP.NET Core Starter Kit (https://dotnetreact.com)
33
*
4-
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
4+
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE.txt file in the root directory of this source tree.

client/components/Button/Button.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* ASP.NET Core Starter Kit
2+
* ASP.NET Core Starter Kit (https://dotnetreact.com)
33
*
4-
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
4+
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE.txt file in the root directory of this source tree.

client/components/Layout/Header.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* ASP.NET Core Starter Kit
2+
* ASP.NET Core Starter Kit (https://dotnetreact.com)
33
*
4-
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
4+
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE.txt file in the root directory of this source tree.

client/components/Layout/Header.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* ASP.NET Core Starter Kit
2+
* ASP.NET Core Starter Kit (https://dotnetreact.com)
33
*
4-
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
4+
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE.txt file in the root directory of this source tree.

client/components/Layout/Layout.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* ASP.NET Core Starter Kit
2+
* ASP.NET Core Starter Kit (https://dotnetreact.com)
33
*
4-
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
4+
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE.txt file in the root directory of this source tree.

client/components/Layout/Layout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* ASP.NET Core Starter Kit
2+
* ASP.NET Core Starter Kit (https://dotnetreact.com)
33
*
4-
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
4+
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE.txt file in the root directory of this source tree.

client/components/Layout/Logo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* ASP.NET Core Starter Kit
2+
* ASP.NET Core Starter Kit (https://dotnetreact.com)
33
*
4-
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
4+
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE.txt file in the root directory of this source tree.

client/components/Layout/Navigation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* ASP.NET Core Starter Kit
2+
* ASP.NET Core Starter Kit (https://dotnetreact.com)
33
*
4-
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
4+
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE.txt file in the root directory of this source tree.

client/components/Link/Link.js

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,56 @@
11
/**
2-
* ASP.NET Core Starter Kit
2+
* ASP.NET Core Starter Kit (https://dotnetreact.com)
33
*
4-
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
4+
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
55
*
66
* This source code is licensed under the MIT license found in the
77
* LICENSE.txt file in the root directory of this source tree.
88
*/
99

10-
import React, { Component, PropTypes } from 'react';
10+
import React, { PropTypes } from 'react';
11+
import history from '../../history';
1112

12-
function isLeftClickEvent(event) {
13-
return event.button === 0;
14-
}
15-
16-
function isModifiedEvent(event) {
17-
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
18-
}
13+
class Link extends React.Component {
1914

20-
class Link extends Component {
21-
22-
constructor() {
23-
super();
24-
this.handleClick = this.handleClick.bind(this);
25-
}
26-
27-
handleClick(event) {
28-
let allowTransition = true;
15+
static propTypes = {
16+
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
17+
onClick: PropTypes.func,
18+
};
2919

20+
handleClick = (event) => {
3021
if (this.props.onClick) {
3122
this.props.onClick(event);
3223
}
3324

34-
if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
25+
if (event.button !== 0 /* left click */) {
26+
return;
27+
}
28+
29+
if (event.metaKey || event.altKey || event.ctrlKey || event.shiftKey) {
3530
return;
3631
}
3732

3833
if (event.defaultPrevented === true) {
39-
allowTransition = false;
34+
return;
4035
}
4136

4237
event.preventDefault();
4338

44-
if (allowTransition) {
45-
if (this.props.to) {
46-
this.context.history.push(this.props.to);
47-
} else {
48-
this.context.history.push({
49-
pathname: event.currentTarget.pathname,
50-
search: event.currentTarget.search,
51-
});
52-
}
39+
if (this.props.to) {
40+
history.push(this.props.to);
41+
} else {
42+
history.push({
43+
pathname: event.currentTarget.pathname,
44+
search: event.currentTarget.search,
45+
});
5346
}
54-
}
47+
};
5548

5649
render() {
5750
const { to, ...props } = this.props; // eslint-disable-line no-use-before-define
58-
return <a href={this.context.history.createHref(to)} {...props} onClick={this.handleClick} />;
51+
return <a href={history.createHref(to)} {...props} onClick={this.handleClick} />;
5952
}
6053

6154
}
6255

63-
Link.contextTypes = {
64-
history: PropTypes.shape({
65-
push: PropTypes.func.isRequired,
66-
}).isRequired,
67-
};
68-
69-
Link.propTypes = {
70-
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
71-
onClick: PropTypes.func,
72-
};
73-
7456
export default Link;

0 commit comments

Comments
 (0)