diff --git a/README.md b/README.md index 7130ab0f..eed75e73 100644 --- a/README.md +++ b/README.md @@ -54,33 +54,41 @@ installation/runtime requirements. Usage: electron-rebuild --version [version] --module-dir [path] Options: - -h, --help Show help [boolean] - -v, --version The version of Electron to build against + -v, --version The version of Electron to build against [string] -f, --force Force rebuilding modules, even if we would skip - it otherwise + it otherwise [boolean] -a, --arch Override the target architecture to something - other than your system's - -m, --module-dir The path to the app directory to rebuild + other than your system's [string] + -m, --module-dir The path to the node_modules directory to rebuild + [string] -w, --which-module A specific module to build, or comma separated - list of modules. Modules will only be rebuilt if they - also match the types of dependencies being rebuilt - (see --types). - -e, --electron-prebuilt-dir The path to the prebuilt electron module - -d, --dist-url Custom header tarball URL + list of modules. Modules will only be rebuilt if + they also match the types of dependencies being + rebuilt (see --types). [string] + -o, --only Only build specified module, or comma separated + list of modules. All others are ignored. [string] + -e, --electron-prebuilt-dir The path to the prebuilt electron module [string] + -d, --dist-url Custom header tarball URL [string] -t, --types The types of dependencies to rebuild. Comma separated list of "prod", "dev" and "optional". - Default is "prod,optional" + Default is "prod,optional" [string] -p, --parallel Rebuild in parallel, this is enabled by default - on macOS and Linux + on macOS and Linux [boolean] -s, --sequential Rebuild modules sequentially, this is enabled by - default on Windows - -o, --only Only build specified module, or comma separated - list of modules. All others are ignored. - -b, --debug Build debug version of modules - --prebuild-tag-prefix GitHub tag prefix passed to prebuild-install. - Default is "v" - -Copyright 2016 + default on Windows [boolean] + -b, --debug Build debug version of modules [boolean] + --prebuild-tag-prefix GitHub tag prefix passed to prebuild-install. + Default is "v" [string] + --force-abi Override the ABI version for the version of + Electron you are targeting. Only use when + targeting Nightly releases. [number] + --use-electron-clang Use the clang executable that Electron used when + building its binary. This will guarantee compiler + compatibility [boolean] + --disable-pre-gyp-copy Disables the pre-gyp copy step [boolean] + --build-from-source Skips prebuild download and rebuilds module from + source. [boolean] + -h, --help Show help [boolean] ``` ### How can I use this with [Electron Forge](https://github.com/electron/forge)? diff --git a/src/cli.ts b/src/cli.ts index caf8ea75..3235a2e8 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -31,6 +31,7 @@ const argv = yargs(process.argv.slice(2)).version(false).options({ 'force-abi': { type: 'number', description: 'Override the ABI version for the version of Electron you are targeting. Only use when targeting Nightly releases.' }, 'use-electron-clang': { type: 'boolean', description: 'Use the clang executable that Electron used when building its binary. This will guarantee compiler compatibility' }, 'disable-pre-gyp-copy': { type: 'boolean', description: 'Disables the pre-gyp copy step' }, + 'build-from-source': { type: 'boolean', description: 'Skips prebuild download and rebuilds module from source.'}, }).usage('Usage: $0 --version [version] --module-dir [path]') .help() .alias('help', 'h') diff --git a/src/rebuild.ts b/src/rebuild.ts index 44d8070a..ff08b416 100644 --- a/src/rebuild.ts +++ b/src/rebuild.ts @@ -11,24 +11,106 @@ import { ModuleRebuilder } from './module-rebuilder'; import { ModuleType, ModuleWalker } from './module-walker'; export interface RebuildOptions { + /** + * The path to the `node_modules` directory to rebuild. + */ buildPath: string; + /** + * The version of Electron to build against. + */ electronVersion: string; + /** + * Override the target rebuild architecture to something other than the host system architecture. + * + * @defaultValue The system {@link https://nodejs.org/api/process.html#processarch | `process.arch`} value + */ arch?: string; + /** + * An array of module names to rebuild in addition to detected modules + * @default [] + */ extraModules?: string[]; + /** + * An array of module names to rebuild. **Only** these modules will be rebuilt. + */ onlyModules?: string[] | null; + /** + * Force a rebuild of modules regardless of their current build state. + */ force?: boolean; + /** + * URL to download Electron header files from. + * @defaultValue `https://www.electronjs.org/headers` + */ headerURL?: string; + /** + * Array of types of dependencies to rebuild. Possible values are `prod`, `dev`, and `optional`. + * + * @defaultValue `['prod', 'optional']` + */ types?: ModuleType[]; + /** + * Whether to rebuild modules sequentially or in parallel. + * + * @defaultValue `sequential` + */ mode?: RebuildMode; + /** + * Rebuilds a Debug build of target modules. If this is `false`, a Release build will be generated instead. + * + * @defaultValue false + */ debug?: boolean; + /** + * Enables hash-based caching to speed up local rebuilds. + * + * @experimental + * @defaultValue false + */ useCache?: boolean; + /** + * Whether to use the `clang` executable that Electron uses when building. + * This will guarantee compiler compatibility. + * + * @defaultValue false + */ useElectronClang?: boolean; + /** + * Sets a custom cache path for the {@link useCache} option. + * @experimental + * @defaultValue a `.electron-rebuild-cache` folder in the `os.homedir()` directory + */ cachePath?: string; + /** + * GitHub tag prefix passed to {@link https://www.npmjs.com/package/prebuild-install | `prebuild-install`}. + * @defaultValue `v` + */ prebuildTagPrefix?: string; + /** + * Path to the root of the project if using npm or yarn workspaces. + */ projectRootPath?: string; + /** + * Override the Application Binary Interface (ABI) version for the version of Electron you are targeting. + * Only use when targeting nightly releases. + * + * @see the {@link https://github.com/electron/node-abi | electron/node-abi} repository for a list of Electron and Node.js ABIs + */ forceABI?: number; + /** + * Disables the copying of `.node` files if not needed. + * @defaultValue false + */ disablePreGypCopy?: boolean; + /** + * Skip prebuild download and rebuild module from source. + * + * @defaultValue false + */ buildFromSource?: boolean; + /** + * Array of module names to ignore during the rebuild process. + */ ignoreModules?: string[]; }