|
1 | 1 | import { initializeProxy } from '@electron/get';
|
2 | 2 | import { api, PublishOptions } from '@electron-forge/core';
|
| 3 | +import chalk from 'chalk'; |
3 | 4 | import { program } from 'commander';
|
4 | 5 |
|
5 | 6 | import './util/terminate';
|
6 | 7 | import packageJSON from '../package.json';
|
7 | 8 |
|
8 | 9 | import { getMakeOptions } from './electron-forge-make';
|
9 |
| -import workingDir from './util/working-dir'; |
10 |
| - |
11 |
| -(async () => { |
12 |
| - let dir = process.cwd(); |
13 |
| - program |
14 |
| - .version(packageJSON.version, '-V, --version', 'Output the current version') |
15 |
| - .arguments('[cwd]') |
16 |
| - .option('--target [target[,target...]]', 'The comma-separated deployment targets, defaults to "github"') |
17 |
| - .option('--dry-run', "Triggers a publish dry run which saves state and doesn't upload anything") |
18 |
| - .option('--from-dry-run', 'Attempts to publish artifacts from the last saved dry run') |
19 |
| - .helpOption('-h, --help', 'Output usage information') |
20 |
| - .allowUnknownOption(true) |
21 |
| - .action((cwd) => { |
22 |
| - dir = workingDir(dir, cwd); |
23 |
| - }) |
24 |
| - .parse(process.argv); |
25 |
| - |
26 |
| - const options = program.opts(); |
27 |
| - |
28 |
| - initializeProxy(); |
29 |
| - |
30 |
| - const publishOpts: PublishOptions = { |
31 |
| - dir, |
32 |
| - interactive: true, |
33 |
| - dryRun: options.dryRun, |
34 |
| - dryRunResume: options.fromDryRun, |
35 |
| - }; |
36 |
| - if (options.target) publishOpts.publishTargets = options.target.split(','); |
37 |
| - |
38 |
| - publishOpts.makeOptions = await getMakeOptions(); |
39 |
| - |
40 |
| - await api.publish(publishOpts); |
41 |
| -})(); |
| 10 | +import { resolveWorkingDir } from './util/resolve-working-dir'; |
| 11 | + |
| 12 | +program |
| 13 | + .version(packageJSON.version, '-V, --version', 'Output the current version.') |
| 14 | + .helpOption('-h, --help', 'Output usage information.') |
| 15 | + .argument('[dir]', 'Directory to run the command in. (default: current directory)') |
| 16 | + .option('--target [target[,target...]]', 'A comma-separated list of deployment targets. (default: all publishers in your Forge config)') |
| 17 | + .option('--dry-run', `Run the ${chalk.green('make')} command and save publish metadata without uploading anything.`) |
| 18 | + .option('--from-dry-run', 'Publish artifacts from the last saved dry run.') |
| 19 | + .allowUnknownOption(true) |
| 20 | + .action(async (targetDir) => { |
| 21 | + const dir = resolveWorkingDir(targetDir); |
| 22 | + const options = program.opts(); |
| 23 | + |
| 24 | + initializeProxy(); |
| 25 | + |
| 26 | + const publishOpts: PublishOptions = { |
| 27 | + dir, |
| 28 | + interactive: true, |
| 29 | + dryRun: options.dryRun, |
| 30 | + dryRunResume: options.fromDryRun, |
| 31 | + }; |
| 32 | + if (options.target) publishOpts.publishTargets = options.target.split(','); |
| 33 | + |
| 34 | + publishOpts.makeOptions = await getMakeOptions(); |
| 35 | + |
| 36 | + await api.publish(publishOpts); |
| 37 | + }) |
| 38 | + .parse(process.argv); |
0 commit comments