Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
7e7ba33
Add 'hero platform build android' command to Android Build APK
Derek-Hu May 22, 2017
9a1c593
Build android command support windows
Derek-Hu May 23, 2017
4b1cc6a
Dynamic Read Android SDK, Get Build Version and Support Version
Derek-Hu May 23, 2017
cd36d8c
Support User Specify the Android Version
Derek-Hu May 23, 2017
e23a2ce
List apk(s) after build android
Derek-Hu May 23, 2017
dbe0f83
disable appcache in npm start
Derek-Hu May 23, 2017
24ed5c6
Dynamic Set Android Package Entry Path
Derek-Hu May 23, 2017
27e3f6c
Show tips when error occurs
Derek-Hu May 23, 2017
f625919
Move Template to Project
Derek-Hu May 23, 2017
393da8f
Add command in template for build android app
Derek-Hu May 23, 2017
b8862d9
Inline JS when execute npm run build-basic
Derek-Hu May 23, 2017
63596a2
update java template
cxss May 23, 2017
803385c
Fix @Entry template property cause restart webpack serve
Derek-Hu May 24, 2017
a4a55b2
README for Build Android App
Derek-Hu May 24, 2017
511399a
README for Build Android App in initial application
Derek-Hu May 24, 2017
61b8e11
Using English Label in Sample Code
Derek-Hu May 24, 2017
e85fa3a
Update REAMD using English
Derek-Hu May 24, 2017
a904db1
Update Links
Derek-Hu May 24, 2017
9b640f5
remove gradle zip file
cxss Jun 15, 2017
f05536d
Merge branch 'master' of https://github.com/hero-mobile/hero-cli
cxss Jun 15, 2017
4257179
Remove un-related info in sample code
Derek-Hu Jun 9, 2017
f6f9ef2
Custom Webpack
Derek-Hu Jun 22, 2017
0ca5883
Support Default Webpack
Derek-Hu Jun 23, 2017
3084d3b
Fix Issue
Derek-Hu Jun 23, 2017
b78fcbd
Support CSS
Derek-Hu Jun 23, 2017
6bca183
Css,Less, Scss Support
Derek-Hu Jun 23, 2017
7a899e7
Support . in webpack publicPath
Derek-Hu Jun 26, 2017
1cb81ab
Inline CSS&JS
Derek-Hu Jun 26, 2017
d750a78
@Entry rename filename to path
Derek-Hu Jun 27, 2017
f2a6b41
Add ZH README
Derek-Hu Jun 29, 2017
69d54ee
Update README.zh.md && Refactor template Folder structure
Derek-Hu Jun 29, 2017
83c6e1a
Update README
Derek-Hu Jul 4, 2017
a6e6088
增加README中英文链接
Derek-Hu Jul 5, 2017
fa11780
增加README中英文链接名称
Derek-Hu Jul 5, 2017
b161ad3
更新@Entry
Derek-Hu Jul 5, 2017
be598f2
Support Relative Using HTML Base Tag
Derek-Hu Jul 6, 2017
5d56f6e
Remove Console Log
Derek-Hu Jul 6, 2017
8237c59
Add Debug Info
Derek-Hu Jul 6, 2017
1fa039c
Add Logger
Derek-Hu Jul 6, 2017
086e2b8
Support --verbose output logs
Derek-Hu Jul 6, 2017
1878b30
Fix Build with Relative Path
Derek-Hu Jul 7, 2017
d426785
Set Default Logger Level Info
Derek-Hu Jul 7, 2017
1b02424
Outpu Settings during build
Derek-Hu Jul 7, 2017
4bd84bb
Set Default using relative path in template
Derek-Hu Jul 7, 2017
6a9dfaf
Add --verbose into README
Derek-Hu Jul 7, 2017
2c25ac0
Template code turn on --verbose
Derek-Hu Jul 7, 2017
31f68ea
More Beautify Tips
Derek-Hu Jul 7, 2017
3a65e18
Show Warnings if generated html file name conflict
Derek-Hu Jul 7, 2017
23e3860
Pretty output
Derek-Hu Jul 7, 2017
13578b2
Fix no homepage attribute start error
Derek-Hu Jul 11, 2017
ec9afeb
Pretty Output
Derek-Hu Jul 11, 2017
a653e59
Exit Proccess if not want to use another port when default port occup…
Derek-Hu Jul 11, 2017
1740f89
Remove unused package
Derek-Hu Jul 11, 2017
ddc1e69
Fix Relative Issue
Derek-Hu Jul 11, 2017
54d698d
Fix Relative Path in Safari
Derek-Hu Jul 14, 2017
d3c530e
add ipfs publish
Aug 3, 2017
11b0aef
* brand new builder
lmnhot Aug 22, 2017
5060261
* update to 2.1.0
lmnhot Aug 29, 2017
b3e3947
* update to 2.1.1
lmnhot Sep 1, 2017
72d4695
* update merge entries
lmnhot Sep 4, 2017
7328671
* remove useless loader
lmnhot Oct 13, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ root = true
[*]
end_of_line = lf
indent_style = space
indent_size = 4
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[package.json]
indent_style = space
indent_size = 2
27 changes: 27 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"root": true,
"parser": "babel-eslint",
"extends": "standard",
"env": {
"browser": true
},
"rules": {
"object-curly-spacing": [
2,
"always"
],
"space-before-function-paren": [
2,
{
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}
],
"no-var": 2,
"semi": [
2,
"never"
]
}
}
65 changes: 35 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# hero-cli

[中文文档](https://github.com/hero-mobile/hero-cli/blob/master/README.zh.md)

Create Hero apps with no build configuration.

* [Getting Started](#getting-started) – How to create a new app.
Expand Down Expand Up @@ -61,14 +63,17 @@ It will create a directory called `my-app` inside the current folder.<br>
Inside that directory, it will generate the initial project structure and then you can run command `npm install` to install the dependencies manually:

```
├── environments
│   ├── environment-dev.js
│   └── environment-prod.js
├── platforms
│   ├── android
│   └── iOS
├── public
│   ├── ...
│   └── favicon.ico
├── src
│   ├── ...
│   ├── environments
│   │   ├── environment-dev.js
│   │   └── environment-prod.js
│   ├── index.html
│   └── index.js
├── .babelrc
Expand All @@ -82,15 +87,16 @@ Inside that directory, it will generate the initial project structure and then y
```
For the project to build, **these files must exist with exact filenames**:

* `platforms` folder contains Android/iOS codes.
* `src/index.html` is the entry page;
* `src/index.js` is the JavaScript entry point.
* `.hero-cli.json` is the configuration file for hero-cli build, it tell hero loads which configuration when you run command `hero start -e dev` or `hero build -e prod`(which is invoked by `npm start` or `npm build`) according to the value of `-e` parameter. For more build options please refer to [Build Scripts](#build-scripts).
* `.hero-cli.json` is the configuration file for hero-cli build, it tell hero loads which configuration when you run command `hero start -e dev` or `hero build -e prod`(which is invoked by `npm start` or `npm run build`) according to the value of `-e` parameter. For more build options please refer to [Build Scripts](#build-scripts).

You can delete or rename the other files.

* `public` assets like images inside this folder will **copied into the build folder untouched**. It will not be processed by Webpack.
* `src` For faster rebuilds, only files inside this folder are processed by Webpack. You need to **put any JS and CSS files inside this folder**, or Webpack won’t see them.
* `src/environments` where your configurations exists(these file path configured in file `.hero-cli.json`, you can change it later) and you can access the configuration values in JavaScript or HTML code. See [Adding Custom Environment Variables](#adding-custom-environment-variables).
* `environments` where your configurations exists(these file path configured in file `.hero-cli.json`, you can change it later) and you can access the configuration values in JavaScript or HTML code. See [Adding Custom Environment Variables](#adding-custom-environment-variables).

You may curious about where is the `pages/start.html`. Yes, it's generated by hero-cli. See [Generate HTML](#generate-html)

Expand All @@ -107,7 +113,7 @@ You may curious about where is the `pages/start.html`. Yes, it's generated by he
* [Android](#android)
* [iOS](#ios)
* [Build Scripts](#build-scripts)
* [`hero start`](#hero-start)
* [`hero dev`](#hero-dev)
* [`hero build`](#hero-build)
* [`hero serve`](#hero-serve)
* [`hero init`](#hero-init)
Expand All @@ -122,26 +128,16 @@ Any JS file meet the following 2 conditions will treat as JavaScript entry point

Which would cause a HTML file generated using Webpack plugin [html-webpack-plugin](https://www.npmjs.com/package/html-webpack-plugin):

* Options specified in `@Entry(options)` will passed to `html-webpack-plugin` transparently.
* Destination of generated HTML file will keep the file path structure of the Javascript entry, or you can override it using the option `filename` provided by `html-webpack-plugin`.
* You can specify options during generate HTML via `@Entry(options)`.
* Destination of generated HTML file will keep the file path structure of the Javascript entry, or you can override it using the option `path`.
* Generated HTML file can access the [Custom Environment Variables](#adding-custom-environment-variables).

Example:<br>

Below JavaScript file `src/pages/start.js` will generate a HTML file access by URL `/pages/start.html`, that's why we can visit [http://localhost:3000/pages/start.html](http://localhost:3000/pages/start.html).

```javascript
// content of file: src/pages/start.js
import { Entry } from 'hero-cli/decorator';

// class marked by @Entry
// will generate HTML accessed by URL /pages/start.html
// Equal to
// @Entry({
// filename: 'pages/start.html'
// })
//
@Entry()

export class DecoratePage {

sayHello(data){
Expand All @@ -151,6 +147,14 @@ export class DecoratePage {
}

```
If you want to rename filename, you can add a key/val to `router.js`:
````javascript
// router.js
module.exports = {
rename_home: require.resolve('./src/pages/start.js')
}
````
than build will emit `rename_home.html`

### Adding Custom Environment Variables
Your project can consume variables declared in your environment as if they were declared locally in your JS files. By default you will have any environment variables starting with `HERO_APP_`. These environment variables can be useful for consuming sensitive data that lives outside of version control.<br>
Expand Down Expand Up @@ -243,11 +247,10 @@ module.exports = environment;
When you run command `hero start -e dev` or `hero build -e dev`, all variables from `src/environments/environment-dev.js` can be accessed via `process.env`.

### Proxying API Requests in Development
People often serve the front-end React app from the same host and port as their backend implementation.
People often serve the front-end appplication from the same host and port as their backend implementation.
For example, a production setup might look like this after the app is deployed:
```
/ - static server returns index.html with React app
/todos - static server returns index.html with React app
/ - static server returns index.html with application
/api/todos - server handles any /api/* requests using the backend implementation

```
Expand All @@ -270,7 +273,7 @@ To tell the development server to proxy any unknown requests to your API server

```

This way, when you `fetch('/api/v2/todos')` in development, the development server will proxy your request to `http://localhost:4000/api/v2/todos`, and when you `fetch('/feapi/todos')`, the request will proxy to `https://localhost:4001`.
This way, when you `fetch('/api/v2/todos')` in development, the development server will proxy your request to `https://localhost:4000/api/v2/todos`, and when you `fetch('/feapi/todos')`, the request will proxy to `https://localhost:4001/feapi/todos`.

### Build Native App
#### Android
Expand All @@ -286,12 +289,13 @@ This way, when you `fetch('/api/v2/todos')` in development, the development serv
* `ANDROID_HOME`
* `GRADLE_HOME`

Currently, generated android apk will loads resources hosted by remote server. In order to make the appliation available in the your mobile.
Currently, generated native app will loads resources hosted by remote server. In order to make the appliation available in the your mobile.

Firstly, you have to deploy the codes generate by command [`hero build`](#hero-build) into remote server.<br>
Secondly, before you generate the apk, you should using parameter `-e` to tell the apk loads which url when it startup.
* Firstly, you can using command [`hero build`](#hero-build) to generate the package which contains the application codes for deploy.<br>
* Secondly, specify the entry url in file `.hero-cli.json` when native app startup.
* Finally, using command [`hero platform build`](#hero- platform-build) build the native app. before you generate the apk, you should using parameter `-e` to tell the apk loads which url when it startup.

For example, you can config the url in file `.hero-cli.json` like this:
For example:

```json
{
Expand All @@ -316,6 +320,7 @@ For more options, see command of Build Scripts: [`Build Android App`](#build-and


### Build Scripts
Below scripts support option `--verbose` to output more details.

#### `hero start`

Expand All @@ -342,7 +347,7 @@ You will see the build errors and lint warnings in the console.

* `-e`<br>Environment name of the configuration when start the application
* `-s`<br>Build the boundle as standalone version, which should run in Native App environment. That's to say, build version without libarary like [webcomponent polyfills](http://webcomponents.org/polyfills/) or [hero-js](https://github.com/hero-mobile/hero-js)(These libarary is necessary for Hero App run in web browser, not Native App).
* `-i`<br>Inline JavaScript code into HTML. Default value is [false].
* `-i`<br>Inline JavaScript/CSS code into HTML. Default value is [false].
* `-b`<br>Build pakcage only contain dependecies like hero-js or webcomponents, withou code in <you-project-path>/src folder. Default value is [false]
* `-m`<br>Build without sourcemap. Default value is [false], will generate sourcemap.
* `-f`<br>Generate AppCache file, default file name is "app.appcache". Default value is [false], will not generate this file.
Expand Down Expand Up @@ -385,7 +390,7 @@ This will let Hero App correctly infer the root path to use in the generated HTM
After `hero build` process completedly, `build` folder will generated. You can serve a static server using `hero serve`.

#### `hero init`
You can run `hero build -h` for help. It will generate the initial project structure of Hero App. See [Creating an App](#creating-an-app).
You can run `hero build -h` for help. It will generate the initial project structure of Hero App. See [Quick Overview](#quick-overview).

#### `hero platform build`
This command used for build native app. And you can run `hero platform build -h` for help.<br>
Expand Down Expand Up @@ -418,7 +423,7 @@ Once command `hero platform build android -e prod` execute successfully, a andro

###### How to specify the android build tool version in SDK
Hero will dynamic using the lastest available one from your local install versions by default.
You might have multiple available versions in the Android SDK. You can specify the `ANDROID_HOME/build-toos` version and compile `com.android.support:appcompat-v7` version following the keyword `android` and seperated by colon.
You might have multiple available versions in the Android SDK. You can specify the `ANDROID_HOME/build-toos` version and compile `com.android.support:appcompat-v7` version following the command `hero platform build android` and seperated by colon.

For example, you can using the below command specify the `ANDROID_HOME/build-toos` version `23.0.2` and compile `com.android.support:appcompat-v7` version `24.0.0-alpha1`:

Expand Down
Loading