Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
.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);
})();
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'
});
}
};
.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);
})();
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;
});
}
(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,
});
})();
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,
});
})();
(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,
});
})();
(async () => {
const makeOpts = await getMakeOptions();
initializeProxy();
await api.make(makeOpts);
})();
}
.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);
})();