How to use @electron-forge/core - 10 common examples

To help you get started, we’ve selected a few @electron-forge/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github electron-userland / electron-forge / packages / api / cli / src / electron-forge-start.ts View on Github external
enableLogging: !!program.enableLogging,
    runAsNode: !!program.runAsNode,
    inspect: !!program.inspectElectron,
  };

  if (program.vscode && appArgs) {
    // Args are in the format ~arg~ so we need to strip the "~"
    appArgs = appArgs
      .map((arg) => arg.substr(1, arg.length - 2))
      .filter((arg) => arg.length > 0);
  }

  if (program.appPath) opts.appPath = program.appPath;
  if (appArgs) opts.args = appArgs;

  const spawned = await api.start(opts);

  await new Promise((resolve) => {
    const listenForExit = (child: ElectronProcess) => {
      let onExit: NodeJS.ExitListener;
      let onRestart: (newChild: ElectronProcess) => void;
      const removeListeners = () => {
        child.removeListener('exit', onExit);
        child.removeListener('restarted', onRestart);
      };
      onExit = (code: number) => {
        removeListeners();
        if (spawned.restarted) return;
        if (code !== 0) {
          process.exit(code);
        }
        resolve();
github electron-userland / electron-forge / packages / api / cli / src / electron-forge-init.ts View on Github external
.arguments('[name]')
    .option('-t, --template [name]', 'Name of the Forge template to use')
    .option('-c, --copy-ci-files', 'Whether to copy the templated CI files (defaults to false)', false)
    .option('-f, --force', 'Whether to overwrite an existing directory (defaults to false)', false)
    .action((name) => { dir = workingDir(dir, name, false); })
    .parse(process.argv);

  const initOpts: InitOptions = {
    dir,
    interactive: true,
    copyCIFiles: !!program.copyCiFiles,
    force: !!program.force,
  };
  if (program.template) initOpts.template = program.template;

  await api.init(initOpts);
})();
github adopted-ember-addons / ember-electron / blueprints / ember-electron / index.js View on Github external
async createElectronProject() {
    this.ui.writeLine(chalk.green(`Creating electron-forge project at './${electronProjectPath}'`));

    await api.init({
      dir: electronProjectPath,
      interactive: true,
      template: 'ember-electron/forge/template'
    });
  }
};
github electron-userland / electron-forge / packages / api / cli / src / electron-forge-publish.ts View on Github external
.action((cwd) => { dir = workingDir(dir, cwd); })
    .parse(process.argv);

  initializeProxy();

  const publishOpts: PublishOptions = {
    dir,
    interactive: true,
    dryRun: program.dryRun,
    dryRunResume: program.fromDryRun,
  };
  if (program.target) publishOpts.publishTargets = program.target.split(',');

  publishOpts.makeOptions = await getMakeOptions();

  await api.publish(publishOpts);
})();
github electron-userland / electron-forge / packages / api / cli / src / util / check-system.ts View on Github external
async function checkPackageManagerVersion(ora: OraImpl) {
  return forgeUtils.yarnOrNpmSpawn(['--version'])
    .then((version) => {
      const versionString = version.toString();
      if (forgeUtils.hasYarn()) {
        warnIfPackageManagerIsntAKnownGoodVersion('Yarn', versionString, YARN_WHITELISTED_VERSIONS, ora);
      } else {
        warnIfPackageManagerIsntAKnownGoodVersion('NPM', versionString, NPM_WHITELISTED_VERSIONS, ora);
      }

      return true;
    });
}
github electron-userland / electron-forge / packages / api / cli / src / electron-forge-import.ts View on Github external
(async () => {
  let dir = process.cwd();
  program
    .version((await fs.readJson(path.resolve(__dirname, '../package.json'))).version)
    .arguments('[name]')
    .action((name) => { dir = workingDir(dir, name, false); })
    .parse(process.argv);

  await api.import({
    dir,
    interactive: true,
  });
})();
github electron-userland / electron-forge / packages / api / cli / src / electron-forge-install.ts View on Github external
const chooseAsset = async (assets: InstallAsset[]) => {
    const choices: { name: string, value: string }[] = [];
    assets.forEach((asset) => {
      choices.push({ name: asset.name, value: asset.id });
    });
    const { assetID } = await inquirer.createPromptModule()<{ assetID: string }>({
      choices,
      type: 'list',
      name: 'assetID',
      message: 'Multiple potential assets found, please choose one from the list below:'.cyan,
    });

    return assets.find((asset) => asset.id === assetID)!;
  };

  await api.install({
    chooseAsset,
    repo,
    interactive: true,
    prerelease: program.prerelease,
  });
})();
github electron-userland / electron-forge / packages / api / cli / src / electron-forge-lint.ts View on Github external
(async () => {
  let dir = process.cwd();
  program
    .version((await fs.readJson(path.resolve(__dirname, '../package.json'))).version)
    .arguments('[cwd]')
    .action((cwd) => { dir = workingDir(dir, cwd); })
    .parse(process.argv);

  await api.lint({
    dir,
    interactive: true,
  });
})();
github electron-userland / electron-forge / packages / api / cli / src / electron-forge-make.ts View on Github external
(async () => {
    const makeOpts = await getMakeOptions();

    initializeProxy();

    await api.make(makeOpts);
  })();
}
github electron-userland / electron-forge / packages / api / cli / src / electron-forge-package.ts View on Github external
.arguments('[cwd]')
    .option('-a, --arch [arch]', 'Target architecture')
    .option('-p, --platform [platform]', 'Target build platform')
    .action((cwd) => { dir = workingDir(dir, cwd); })
    .parse(process.argv);

  initializeProxy();

  const packageOpts: PackageOptions = {
    dir,
    interactive: true,
  };
  if (program.arch) packageOpts.arch = program.arch;
  if (program.platform) packageOpts.platform = program.platform;

  await api.package(packageOpts);
})();