Skip to content

Commit

Permalink
Update docs for the latest CLI version
Browse files Browse the repository at this point in the history
  • Loading branch information
shalithasuranga committed Oct 28, 2023
1 parent 0712fc5 commit 95fbbc3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
14 changes: 10 additions & 4 deletions docs/cli/neu-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,26 @@ the Neutralinojs application will be reloaded automatically.

You can see Neutralinojs process and extensions output streams while the application is running.

If you use the [`cli.frontendLibrary`](../configuration/neutralino.config.json.md#clifrontendlibrary-object)
key in app configuration, the CLI enables both frontend library's development environment and Neutralinojs's
development evironment at the same time. This option patches the main HTML file with the Neutralinojs
client library global variables to expose the native API to the frontend library's development server.
Learn how to setup this feature from [this](../getting-started/using-frontend-libraries.md) guide.

#### Options
- `--disable-auto-reload`: Disables the auto-reloading feature.
- `--arch=<arch>`: Explicitly set the CPU architecture. This option is helpful if you use a 32-bit Node.js process
on a 64-bit computer.
- `--frontend-lib-dev`: Enables both frontend library's development environment and Neutralinojs's
development evironment at the same time. This option patches the main HTML file with the Neutralinojs
client library path to expose the native API to the frontend library's development server.
Learn how to setup this feature from [this](../getting-started/using-frontend-libraries.md) guide.
- `-- <process-args>`: Sets additional CLI arguments for the Neutralinojs application process. For example you can enable the `browser` mode by entering `neu run -- --mode=browser`. See all accepted arguments from [here](./internal-cli-arguments.md).

### `neu update`
This command will update the existing Neutralinojs binaries and client library from the internet. You can
use the `nightly` tag for the `cli.binaryVersion` and `cli.clientVersion` in the `neutralino.config.json` file to use experimental daily pre-releases.

#### Options
- `--latest`: Fetches the latest framework version details via the GitHub API, downloads from official releases
, and update the app configuration with fetched version details.

:::warning
Nightly builds refers to automatically generated daily builds, so these builds can contain experimental or
incomplete features. Therefore, avoid using `nightly` versions in your production apps. Use `nightly` versions
Expand Down
45 changes: 30 additions & 15 deletions docs/getting-started/using-frontend-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ to build Neutralinojs apps with a frontend library, first try to use an existing

```bash
neu create myapp --template codezri/neutralinojs-react
cd myapp

# Start the React development server with Neutralinojs
neu run

# Build the React and Neutralinojs app
neu build
```
- Repository: [codezri/neutralinojs-react](https://github.com/codezri/neutralinojs-react)

Expand Down Expand Up @@ -191,7 +198,7 @@ neu run -- --window-enable-inspector

The current directory should be logged to the console. To open developer tools right click anywhere in the Neutralinojs application and press `inspect element`.

### Enabling hot-reload
### Enabling hot-reload and configuration

Building every code change and testing your application is undoubtedly time-consuming. Therefore, you can use
your frontend framework's HMR (Hot Module Replacement) features to speed up your development activities.
Expand All @@ -215,37 +222,45 @@ You can add the following section to your configuration file for activating hot-

The above options tell neu CLI about the main HTML file and development server URL.

Now, start your frontend development server. In React, we can do it with the following command.
Next, configure your project by adding frontend-library-specific development commands as follows:

```bash
npm start
```json
"cli": {
// --- other options
"frontendLibrary": {
"patchFile": "/react-src/public/index.html",
"devUrl": "http://localhost:3000",
"projectPath": "/react-src/",
"initCommand": "npm install",
"devCommand": "BROWSER=none npm start",
"buildCommand": "npm run build"
}
}
}
```

Finally, run the Neutralinojs application with the following command.

```
neu run --frontend-lib-dev
neu run
```

![](../media/hmr-preview.gif)
The above command executes the `devCommand`, starts the React development server, and run the Neutralinojs app
in development mode.

:::tip
Make sure to build your frontend app once before entering the above command since it loads the client
library globals from the Neutralinojs application resources directory (not from your frontend framework's directory).
:::
![](../media/hmr-preview.gif)

### Packaging

To produce the app binaries, first we need to generate static resources via the frontend development tooling. Then, we can generate the Neutralinojs app bundle, as shown in the following command snippet:
To produce the app binaries, you can use the following command, as usual:

```bash
cd react-src
npm run build

cd ..
neu build --release
```

The above command executes the `buildCommand` first, so the application bundle will use the currect React project
source.

See the full source code of this tutorial [here](https://github.com/codezri/neutralinojs-react).


Expand Down

0 comments on commit 95fbbc3

Please sign in to comment.