From 5d38aa5fedc66828fb9c7f06eab6d83a957f1274 Mon Sep 17 00:00:00 2001 From: Michael Romashov Date: Sun, 13 Nov 2022 00:59:15 -0500 Subject: [PATCH] feat: cli argument to skip simulator package --- README.md | 1 + environment.d.ts | 5 +---- index.ts | 7 +++++-- src/esbuild.ts | 2 +- src/logger.ts | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7d3b19b..04a05b9 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Mach also allows you to create nested instruments, enabling you to bundle MSFS A - `-f, --filter ` regex filter of included instrument names - `-v, --verbose` output additional build information - `-m, --output-metafile` output `build_meta.json` file to bundles directory +- `-s, --skip-simulator-package` skips writing simulator package templates #### `mach build [options]` diff --git a/environment.d.ts b/environment.d.ts index 306447b..6a2e369 100644 --- a/environment.d.ts +++ b/environment.d.ts @@ -3,17 +3,14 @@ * SPDX-License-Identifier: MIT */ -import { Plugin } from 'esbuild'; - declare global { namespace NodeJS { interface ProcessEnv { CONFIG_PATH: string; BUNDLES_DIR: string; - OUTPUT_METAFILE: boolean; + OUTPUT_METAFILE: string; PACKAGE_DIR: string; PACKAGE_NAME: string; - BUILD_PLUGINS: Plugin[]; } } } diff --git a/index.ts b/index.ts index 78876dd..775cacb 100644 --- a/index.ts +++ b/index.ts @@ -23,6 +23,7 @@ interface ParsedCommandArgs { filter?: RegExp; verbose?: boolean; outputMetafile?: boolean; + skipSimulatorPackage?: boolean; } const cli = new Command(); @@ -31,8 +32,9 @@ const commandWithOptions = (name: string) => cli.command(name) .option('-c, --config ', 'specify path to configuration file', './mach.config.js') .option('-b, --bundles ', 'bundles output directory', './bundles') .option('-f, --filter ', 'regex filter of included instrument names') - .option('-v', '--verbose', 'output additional build information') - .option('-m', '--output-metafile', 'output `build_meta.json` file to bundles directory') + .option('-v, --verbose', 'output additional build information') + .option('-m, --output-metafile', 'output `build_meta.json` file to bundles directory') + .option('-s, --skip-simulator-package', 'skips writing simulator package templates') .hook('preAction', async (thisCommand, actionCommand) => { signale.info(`Welcome to ${chalk.cyanBright('Mach')}, v${version}`); @@ -40,6 +42,7 @@ const commandWithOptions = (name: string) => cli.command(name) process.env.BUNDLES_DIR = path.join(process.cwd(), actionCommand.getOptionValue('bundles')); process.env.VERBOSE_OUTPUT = actionCommand.getOptionValue('verbose') ?? false; process.env.OUTPUT_METAFILE = actionCommand.getOptionValue('outputMetafile') ?? false; + process.env.SKIP_SIM_PACKAGE = actionCommand.getOptionValue('skipSimulatorPackage') ?? false; actionCommand.setOptionValue('filter', new RegExp(actionCommand.getOptionValue('filter'))); diff --git a/src/esbuild.ts b/src/esbuild.ts index 1d5d0c9..7105188 100644 --- a/src/esbuild.ts +++ b/src/esbuild.ts @@ -53,7 +53,7 @@ async function build(config: MachConfig, instrument: Instrument, logger: BuildLo ); } - if (instrument.simulatorPackage && !module) { + if (instrument.simulatorPackage && process.env.SKIP_SIM_PACKAGE !== 'true' && !module) { buildOptions.plugins!.push(writePackageSources(logger, instrument)); } diff --git a/src/logger.ts b/src/logger.ts index 674534d..7870ef4 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -36,7 +36,7 @@ export class BuildLogger { } else { this.logger.success(`Built ${name} in ${chalk.greenBright((time).toFixed(), 'ms')}`); } - if (process.env.VERBOSE_OUTPUT) { + if (process.env.VERBOSE_OUTPUT === 'true') { for (const [file, meta] of Object.entries(result.metafile.outputs)) { this.logger.file(chalk.gray(`${file} — ${chalk.cyan(filesize(meta.bytes))}`)); }