Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: unify code samples under npm #153

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
56 changes: 1 addition & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,16 @@ Electron Forge is an all-in-one tool for packaging and distributing Electron app
To get started with Electron Forge, we first need to initialize a new project with `create-electron-app`. This script is a convenient wrapper around Forge's [Init](cli.md#Init) command.

{% hint style="warning" %}
Electron Forge 6 works best with Yarn Classic (v1.x) and npm. If you are using a newer version of Yarn, you can downgrade to Classic using the [`yarn set version`](https://yarnpkg.com/cli/set/version) command.
Electron Forge 6 currently only supports Yarn Classic (v1.x) and npm. If you are using a newer version of Yarn, you can downgrade to Classic using the [`yarn set version`](https://yarnpkg.com/cli/set/version) command.
{% endhint %}

{% tabs %}
{% tab title="Yarn" %}
```bash
yarn create electron-app my-app
```
{% endtab %}

{% tab title="npm" %}
```bash
npm init electron-app@latest my-app
```
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
If you used the `create-electron-app` script before during Forge `6.0.0-beta`, we recommend you uninstall the package globally before running the command again.

```bash
yarn global remove create-electron-app
# or
npm uninstall -g create-electron-app
```
{% endhint %}
Expand All @@ -44,19 +31,9 @@ npm uninstall -g create-electron-app

Forge's initialization scripts can add additional template code with the `--template=[template-name]` flag.

{% tabs %}
{% tab title="yarn" %}
```bash
yarn create electron-app my-app --template=webpack
```
{% endtab %}

{% tab title="npm" %}
```bash
npm init electron-app@latest my-app -- --template=webpack
```
{% endtab %}
{% endtabs %}

There are currently two first-party templates:

Expand All @@ -75,57 +52,26 @@ To learn more about authoring your own templates for Electron Forge, check out t

You should now have a directory called `my-app` with all the files you need for a basic Electron app.

{% tabs %}
{% tab title="Yarn" %}
```bash
cd my-app
yarn start
```
{% endtab %}

{% tab title="npm" %}
```bash
cd my-app
npm start
```
{% endtab %}
{% endtabs %}

## Building distributables

So you've got an **amazing** application there, and you want to package it all up and share it with the world. If you run the `make` script, Electron Forge will generate you platform specific distributables for you to share with everyone. For more information on what kind of distributables you can make, check out the [Makers](config/makers/) documentation.

{% tabs %}
{% tab title="yarn" %}
```bash
yarn make
```
{% endtab %}

{% tab title="npm" %}
```bash
npm run make
```
{% endtab %}
{% endtabs %}

## Publishing your app

Now you have distributables that you can share with your users. If you run the `publish` script, Electron Forge will then publish the platform-specific distributables for you, using the publishing method of your choice. For more information on what publishers we currently support, check out the [Publishers](config/publishers/) documentation.

{% tabs %}
{% tab title="yarn" %}
```bash
yarn run publish
```
{% endtab %}

{% tab title="npm" %}
```bash
npm run publish
```
{% endtab %}
{% endtabs %}

## Advanced Usage

Expand Down
10 changes: 0 additions & 10 deletions advanced/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,9 @@ For more general information on debugging Electron apps, see the [main Electron

You can specify the `--inspect-electron` flag when running `electron-forge start`. Internally, this will activate the [Electron `--inspect`flag](http://electronjs.org/docs/tutorial/debugging-main-process#--inspectport), and the main process will listen for a debugging client on port 5858.

{% tabs %}
{% tab title="Yarn" %}
```bash
yarn start --inspect-electron
```
{% endtab %}

{% tab title="npm" %}
```bash
npm run start -- --inspect-electron
```
{% endtab %}
{% endtabs %}

Once your app is active, open [`chrome://inspect`](chrome://inspect) in any Chromium-based browser to attach a debugger to the main process of your app.

Expand Down
91 changes: 0 additions & 91 deletions cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,9 @@ Forge's CLI uses comma-separated value strings to pass multiple arguments into a

To use the Forge CLI, install the `@electron-forge/cli` module into your project as a devDependency. If you're using the `create-electron-app` script, this module will already be installed for you.

{% tabs %}
{% tab title="Yarn" %}
```bash
yarn add --dev @electron-forge/cli
```
{% endtab %}

{% tab title="npm" %}
```bash
npm install --save-dev @electron-forge/cli
```
{% endtab %}
{% endtabs %}

## Bootstrap commands

Expand All @@ -58,19 +48,9 @@ All flags are optional.

#### Usage

{% tabs %}
{% tab title="Yarn" %}
```bash
yarn electron-forge init --template=webpack
```
{% endtab %}

{% tab title="npm" %}
```bash
npx electron-forge init --template=webpack
```
{% endtab %}
{% endtabs %}

### Import

Expand All @@ -82,19 +62,9 @@ There are no options for the Import command.

#### Usage

{% tabs %}
{% tab title="Yarn" %}
```bash
yarn electron-forge import
```
{% endtab %}

{% tab title="npm" %}
```bash
npx electron-forge import
```
{% endtab %}
{% endtabs %}

## Build commands

Expand All @@ -119,25 +89,12 @@ All flags are optional.

#### Usage

{% tabs %}
{% tab title="Yarn" %}
```bash
# By default, the package command corresponds to a package npm script:
yarn package --arch="ia32"
# If there is no package script:
yarn electron-forge package --arch="ia32"
```
{% endtab %}

{% tab title="npm" %}
```bash
# By default, the package command corresponds to a package npm script:
npm run package -- --arch="ia32"
# If there is no package script:
npx electron-forge package --arch="ia32"
```
{% endtab %}
{% endtabs %}

### Make

Expand All @@ -160,41 +117,18 @@ All flags are optional.

Basic usage:

{% tabs %}
{% tab title="Yarn" %}
```bash
# By default, the make command corresponds to a make npm script:
yarn make --arch="ia32"
# If there is no make script:
yarn electron-forge make --arch="ia32"
```
{% endtab %}

{% tab title="npm" %}
```bash
# By default, the make command corresponds to a make npm script:
npm run make -- --arch="ia32"
# If there is no make script:
npx electron-forge make --arch="ia32"
```
{% endtab %}
{% endtabs %}

Building for ia32 and x64 architectures:

{% tabs %}
{% tab title="Yarn" %}
```bash
yarn make --arch="ia32,x64"
```
{% endtab %}

{% tab title="npm" %}
```bash
npm run make -- --arch="ia32,x64"
```
{% endtab %}
{% endtabs %}

### Publish

Expand All @@ -214,23 +148,11 @@ All flags are optional.

#### Usage

{% tabs %}
{% tab title="Yarn" %}
<pre class="language-bash"><code class="lang-bash"><strong># By default, the publish command corresponds to a publish npm script:
</strong>yarn run publish --from-dry-run
# If there is no publish script:
yarn electron-forge publish --from-dry-run
</code></pre>
{% endtab %}

{% tab title="npm" %}
<pre class="language-bash"><code class="lang-bash"><strong># By default, the publish command corresponds to a publish npm script:
</strong>npm run publish -- --from-dry-run
# If there is no publish script:
npx electron-forge publish -- --from-dry-run
</code></pre>
{% endtab %}
{% endtabs %}

## Dev commands

Expand All @@ -256,25 +178,12 @@ All flags are optional.

#### Usage

{% tabs %}
{% tab title="Yarn" %}
```bash
# By default, the start command corresponds to a start npm script:
yarn start --enable-logging
# if there is no start script
yarn electron-forge start --enable-logging
```
{% endtab %}

{% tab title="npm" %}
```bash
# By default, the start command corresponds to a start npm script:
npm start --enable-logging
# if there is no start script
npx electron-forge start --enable-logging
```
{% endtab %}
{% endtabs %}

## Programmatic usage

Expand Down
10 changes: 0 additions & 10 deletions config/plugins/auto-unpack-natives.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,9 @@ This plugin will automatically add all native Node modules in your `node_modules

## Installation

{% tabs %}
{% tab title="Yarn" %}
```shell
yarn add --dev @electron-forge/plugin-auto-unpack-natives
```
{% endtab %}

{% tab title="npm" %}
```shell
npm install --save-dev @electron-forge/plugin-auto-unpack-natives
```
{% endtab %}
{% endtabs %}

## Usage

Expand Down
10 changes: 0 additions & 10 deletions config/plugins/electronegativity.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,9 @@ The Electronegativity plugin integrates Doyensec's [Electronegativity tool](http

## Installation

{% tabs %}
{% tab title="Yarn" %}
```shell
yarn add --dev @electron-forge/plugin-electronegativity
```
{% endtab %}

{% tab title="npm" %}
```shell
npm install --save-dev @electron-forge/plugin-electronegativity
```
{% endtab %}
{% endtabs %}

## Usage

Expand Down
10 changes: 0 additions & 10 deletions config/plugins/local-electron.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,9 @@ If you want to set up a local build of Electron, you should check out [Electron

### Installation

{% tabs %}
{% tab title="Yarn" %}
```bash
yarn add --dev @electron-forge/plugin-local-electron
```
{% endtab %}

{% tab title="npm" %}
```bash
npm install --save-dev @electron-forge/plugin-local-electron
```
{% endtab %}
{% endtabs %}

### Usage

Expand Down
11 changes: 1 addition & 10 deletions config/plugins/webpack.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,10 @@ If you used the [Webpack](../../templates/webpack-template.md) or [TypeScript +

If you are setting up the plugin manually, you can make native modules work by adding the following two loaders to your `module.rules` configuration in your Webpack config. Ensure you install both [`node-loader`](https://www.npmjs.com/package/node-loader) and [`@vercel/webpack-asset-relocator-loader`](https://www.npmjs.com/package/@vercel/webpack-asset-relocator-loader) as development dependencies.

{% tabs %}
{% tab title="Yarn" %}
```shell
yarn add --dev node-loader @vercel/[email protected]
```
{% endtab %}

{% tab title="npm" %}
```shell
```bash
npm install --save-dev node-loader @vercel/[email protected]
```
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Electron Forge monkeypatches the asset relocator loader in order for it to work with Electron properly, so the version has been pinned to ensure compatibility. If you upgrade that version, you do so at your own risk.
Expand Down
Loading