1 | ### Build App
|
2 |
|
3 | **Build App** is a full-stack JS App build system. Inspired by Facebook's create-react-app and other client build systems it is going one step futher providing similar facilities for full-stack JS development.
|
4 |
|
5 | The aim of the project is to simplify development of modern full-stack JS applications, providing most of basic dev operations out of the box (build, run dev mode, lint, etc).
|
6 |
|
7 | Besides that it provides number of build in starter templates which will help you get started ASAP. There are number of technology choises such as React/Vue/Angular for client, Mongo/Postgres for storage.
|
8 |
|
9 | *Build App* works on macOS, Windows, and Linux.
|
10 | Project is in early stage of development.
|
11 | If something doesn’t work please file an issue.
|
12 |
|
13 | ## Getting started
|
14 |
|
15 | ```sh
|
16 | # install build-app globally
|
17 | npm install -g build-app
|
18 |
|
19 | # see list of available commands
|
20 | app-scripts --help
|
21 |
|
22 | # init empty project with default templates
|
23 | app-scripts init my-app --default
|
24 |
|
25 | # change directory to new project folder
|
26 | cd my-app
|
27 |
|
28 | # install project dependencies
|
29 | app-scripts install
|
30 |
|
31 | # build project for production (and before running in dev mode)
|
32 | app-scripts build
|
33 |
|
34 | # serve project in dev mode
|
35 | app-scripts serve --server (--client)
|
36 |
|
37 | ```
|
38 |
|
39 | ## Project structure
|
40 |
|
41 | *Build App* assumes some predifined project structure.
|
42 |
|
43 | Project consists of server and client parts.
|
44 |
|
45 | By default server part is located in {root}/server folder and client in {root}/client.
|
46 |
|
47 | Those values can be overriden in build-app.config.
|
48 |
|
49 | ### Client:
|
50 |
|
51 | Client is SPA written in one modern JS front-end frameworks. Officially supported are React, Vue and Angular2. They are using existing client side build systems (create-react-app, vbuild and angular-cli respectively).
|
52 |
|
53 | Build system expects to be able to create client build by running 'npm run build' command in client folder. Output is expected in {client}/build folder and index.html starts client SPA application.
|
54 |
|
55 | More details how to setup client-side build you can find in docs for particualr build system:
|
56 |
|
57 | React: [create-react-app](https://github.com/facebookincubator/create-react-app)
|
58 |
|
59 | Vue: [vbuild](https://github.com/egoist/vbuild)
|
60 |
|
61 | Angular: [angular-cli](https://github.com/angular/angular-cli)
|
62 |
|
63 | ### Server:
|
64 |
|
65 | Both JS/TS js flavors are supported. For JS you can use latest language features like ES6, async/await and others. Code is compiled to ES5 during the build.
|
66 |
|
67 | Server entry file should be located at ./src/index (.ts or .js).
|
68 |
|
69 | There are some special folders
|
70 |
|
71 | **data**: folder with data assets like data json files, email templates, etc.
|
72 |
|
73 | **local**: folder where server writes data to, here you can have logs output, local overrided values for config file, file uploads, etc.
|
74 |
|
75 | ## app-script commands
|
76 |
|
77 | After build-app is installed globally app-scripts command is available globally. It has different commands (scripts).
|
78 |
|
79 | ### Init
|
80 | *init* command seeds empty project. There are separate templates for server and client parts.
|
81 |
|
82 | To see all available templates run:
|
83 |
|
84 | ```sh
|
85 | app-scripts init --list
|
86 | ```
|
87 |
|
88 | To seed project with particular templates use --project --server --client options:
|
89 |
|
90 | ```sh
|
91 | app-scripts init my-app --project simple --server ts --client react
|
92 | ```
|
93 | To init basic IDE settings use option --ide (currently supported ws/code)
|
94 |
|
95 | ```
|
96 | app-scripts init my-app --default --ide code
|
97 | ```
|
98 |
|
99 | ### Install
|
100 |
|
101 | *install* command installs dependencies for both client and server project parts. It can use one of following package managers under the hood: npm, yarn, pnpm. If pnpm is installed globally it is used, then yarn used if available, then npm.
|
102 |
|
103 | The same can be done manually with
|
104 |
|
105 | ```sh
|
106 | cd {server_dir}
|
107 | npm install
|
108 |
|
109 | cd ../{client_dir}
|
110 | npm install
|
111 | ```
|
112 |
|
113 | ### Build
|
114 |
|
115 | *build* command creates production ready build in build folder (./build by default).
|
116 |
|
117 | To start server run index.js file. You may need to install dependencies first.
|
118 |
|
119 | Build command builds server and client separately and then combines them together into build package.
|
120 |
|
121 | ### Deploy
|
122 |
|
123 | Deploys application in various modes (by using target parameter):
|
124 |
|
125 | *local* deployments:
|
126 |
|
127 | ```bash
|
128 | napp deploy
|
129 | ```
|
130 |
|
131 | Build package copied to deployment folder (./deploy by default) and starts the application with one of supported process managers (forever or pm2). Following deployments will stop application first and clear all deploy folder content except local folder.
|
132 |
|
133 | *heroku* deployments:
|
134 |
|
135 | Initial setup
|
136 |
|
137 | ```bash
|
138 | cd deploy/
|
139 | git init
|
140 | heroku git:remote -a {APP_ID} -r {REMOTE_NAME}
|
141 | git fetch {REMOTE_NAME}
|
142 | git checkout {REMOTE_NAME}/master -b {REMOTE_NAME}
|
143 | ```
|
144 |
|
145 | Note that that you can have multiple remotes corresponding to different environments (dev/staging)
|
146 |
|
147 | After that you can do:
|
148 |
|
149 | ```bash
|
150 | napp deploy --target heroku --remote dev
|
151 | ```
|
152 |
|
153 | ## Npm Scripts
|
154 |
|
155 | Some operations are expected to be configured as particular npm scripts:
|
156 |
|
157 | Build client - 'build' script (in client folder)
|
158 |
|
159 | Serve client - 'start' script
|
160 |
|
161 | Serve server - 'start' script (in server folder)
|
162 |
|
163 | Also if pre-build/post-build scripts are defined in server/client package.json files corresponding scripts will be executed before/after server/client builds. |
\ | No newline at end of file |