diff --git a/lib/commands/typings.ts b/lib/commands/typings.ts index 9159e6f5f5..0a53485063 100644 --- a/lib/commands/typings.ts +++ b/lib/commands/typings.ts @@ -219,19 +219,35 @@ export class TypingsCommand implements ICommand { path.resolve(this.$projectData.projectDir, "typings", "ios"), ); + const env: Record = { + ...process.env, + TNS_TYPESCRIPT_DECLARATIONS_PATH: path.resolve( + this.$projectData.projectDir, + "typings", + "ios", + ), + }; + + if (this.$options.yaml) { + const yamlDir = path.resolve(this.$options.yaml); + this.$fs.ensureDirectoryExists(yamlDir); + env.NS_DEBUG_METADATA_PATH = yamlDir; + this.$logger.info(`Metadata YAML output will be written to: ${yamlDir}`); + } + + if (this.$options.jsonMetadata) { + const jsonDir = path.resolve(this.$options.jsonMetadata); + this.$fs.ensureDirectoryExists(jsonDir); + env.NS_JSON_METADATA_PATH = jsonDir; + this.$logger.info(`Metadata JSON output will be written to: ${jsonDir}`); + } + await this.$childProcess.spawnFromEvent( "node", [this.$staticConfig.cliBinPath, "build", "ios"], "exit", { - env: { - ...process.env, - TNS_TYPESCRIPT_DECLARATIONS_PATH: path.resolve( - this.$projectData.projectDir, - "typings", - "ios", - ), - }, + env, stdio: "inherit", }, ); diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index edb18142ed..c4f67d882b 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -31,7 +31,7 @@ interface INodePackageManager { install( packageName: string, pathToSave: string, - config: INodePackageManagerInstallOptions + config: INodePackageManagerInstallOptions, ): Promise; /** @@ -44,7 +44,7 @@ interface INodePackageManager { uninstall( packageName: string, config?: IDictionary, - path?: string + path?: string, ): Promise; /** @@ -84,7 +84,7 @@ interface INodePackageManager { */ search( filter: string[], - config: IDictionary + config: IDictionary, ): Promise; /** @@ -130,7 +130,7 @@ interface IPerformanceService { methodInfo: string, startTime: number, endTime: number, - args: any[] + args: any[], ): void; // Will return a reference time in milliseconds @@ -141,39 +141,39 @@ interface IPackageInstallationManager { install( packageName: string, packageDir: string, - options?: INpmInstallOptions + options?: INpmInstallOptions, ): Promise; uninstall( packageName: string, packageDir: string, - options?: IDictionary + options?: IDictionary, ): Promise; getLatestVersion(packageName: string): Promise; getNextVersion(packageName: string): Promise; getLatestCompatibleVersion( packageName: string, - referenceVersion?: string + referenceVersion?: string, ): Promise; getMaxSatisfyingVersion( packageName: string, - versionRange: string + versionRange: string, ): Promise; getLatestCompatibleVersionSafe( packageName: string, - referenceVersion?: string + referenceVersion?: string, ): Promise; getInspectorFromCache( inspectorNpmPackageName: string, - projectDir: string + projectDir: string, ): Promise; clearInspectorCache(): void; getInstalledDependencyVersion( packageName: string, - projectDir?: string + projectDir?: string, ): Promise; getMaxSatisfyingVersionSafe( packageName: string, - versionIdentifier: string + versionIdentifier: string, ): Promise; } @@ -181,8 +181,7 @@ interface IPackageInstallationManager { * Describes options that can be passed to manipulate package installation. */ interface INodePackageManagerInstallOptions - extends INpmInstallConfigurationOptions, - IDictionary { + extends INpmInstallConfigurationOptions, IDictionary { /** * Destination of the installation. * @type {string} @@ -266,7 +265,7 @@ interface INpmPeerDependencyInfo { * @type {string} */ requires: string; - } + }, ]; /** * Dependencies of the dependency. @@ -550,8 +549,7 @@ interface INpmInstallConfigurationOptionsBase { ignoreScripts: boolean; //npm flag } -interface INpmInstallConfigurationOptions - extends INpmInstallConfigurationOptionsBase { +interface INpmInstallConfigurationOptions extends INpmInstallConfigurationOptionsBase { disableNpmInstall: boolean; } @@ -596,8 +594,11 @@ interface ITypingsOptions { filter: string; } +yaml: string; +jsonMetadata: string; interface IOptions - extends IRelease, + extends + IRelease, IDeviceIdentifier, IJustLaunch, IAvd, @@ -622,7 +623,7 @@ interface IOptions argv: IYargArgv; validateOptions( commandSpecificDashedOptions?: IDictionary, - projectData?: IProjectData + projectData?: IProjectData, ): void; options: IDictionary; shorthands: string[]; @@ -719,26 +720,22 @@ interface IEnvOptions { } interface IAndroidBuildOptionsSettings - extends IAndroidReleaseOptions, - IRelease, - Partial {} + extends IAndroidReleaseOptions, IRelease, Partial {} interface IHasAndroidBundle { androidBundle: boolean; } interface IPlatformBuildData - extends IRelease, - IHasUseHotModuleReloadOption, - IBuildConfig, - IEnvOptions {} + extends IRelease, IHasUseHotModuleReloadOption, IBuildConfig, IEnvOptions {} interface IDeviceEmulator extends IHasEmulatorOption, IDeviceIdentifier {} interface IRunPlatformOptions extends IJustLaunch, IDeviceEmulator {} interface IDeployPlatformOptions - extends IAndroidReleaseOptions, + extends + IAndroidReleaseOptions, IRelease, IClean, IDeviceEmulator, @@ -834,7 +831,7 @@ interface IAndroidToolsInfo { */ validateJavacVersion( installedJavaVersion: string, - options?: IAndroidToolsInfoOptions + options?: IAndroidToolsInfoOptions, ): boolean; /** @@ -913,14 +910,14 @@ interface IAppDebugSocketProxyFactory extends NodeJS.EventEmitter { device: Mobile.IiOSDevice, appId: string, projectName: string, - projectDir: string + projectDir: string, ): Promise; ensureWebSocketProxy( device: Mobile.IiOSDevice, appId: string, projectName: string, - projectDir: string + projectDir: string, ): Promise; removeAllProxies(): void; @@ -939,12 +936,12 @@ interface IiOSSocketRequestExecutor { executeAttachRequest( device: Mobile.IiOSDevice, timeout: number, - projectId: string + projectId: string, ): Promise; executeRefreshRequest( device: Mobile.IiOSDevice, timeout: number, - appId: string + appId: string, ): Promise; } @@ -995,7 +992,7 @@ interface IProjectNameService { */ ensureValidName( projectName: string, - validateOptions?: { force: boolean } + validateOptions?: { force: boolean }, ): Promise; } @@ -1089,7 +1086,7 @@ interface IBundleValidatorHelper { */ getBundlerDependencyVersion( projectData: IProjectData, - bundlerName?: string + bundlerName?: string, ): string; } @@ -1171,7 +1168,7 @@ interface IAssetsGenerationService { * @returns {Promise} */ generateSplashScreens( - splashesGenerationData: IResourceGenerationData + splashesGenerationData: IResourceGenerationData, ): Promise; } @@ -1207,7 +1204,7 @@ interface IPlatformValidationService { provision: true | string, teamId: true | string, projectData: IProjectData, - platform?: string + platform?: string, ): Promise; validatePlatformInstalled(platform: string, projectData: IProjectData): void; @@ -1220,7 +1217,7 @@ interface IPlatformValidationService { */ isPlatformSupportedForOS( platform: string, - projectData: IProjectData + projectData: IProjectData, ): boolean; } @@ -1228,27 +1225,27 @@ interface IPlatformCommandHelper { addPlatforms( platforms: string[], projectData: IProjectData, - frameworkPath?: string + frameworkPath?: string, ): Promise; cleanPlatforms( platforms: string[], projectData: IProjectData, - frameworkPath: string + frameworkPath: string, ): Promise; removePlatforms( platforms: string[], - projectData: IProjectData + projectData: IProjectData, ): Promise; updatePlatforms( platforms: string[], - projectData: IProjectData + projectData: IProjectData, ): Promise; getInstalledPlatforms(projectData: IProjectData): string[]; getAvailablePlatforms(projectData: IProjectData): string[]; getPreparedPlatforms(projectData: IProjectData): string[]; getCurrentPlatformVersion( platform: string, - projectData: IProjectData + projectData: IProjectData, ): string; } diff --git a/lib/options.ts b/lib/options.ts index d5dcd1b509..cb1b5aff25 100644 --- a/lib/options.ts +++ b/lib/options.ts @@ -42,7 +42,7 @@ export class Options { public options: IDictionary; public setupOptions( - commandSpecificDashedOptions?: IDictionary + commandSpecificDashedOptions?: IDictionary, ): void { if (commandSpecificDashedOptions) { _.extend(this.options, commandSpecificDashedOptions); @@ -54,7 +54,7 @@ export class Options { // Check if the user has explicitly provide --hmr and --release options from command line if (this.initialArgv.release && this.initialArgv.hmr) { this.$errors.fail( - "The options --release and --hmr cannot be used simultaneously." + "The options --release and --hmr cannot be used simultaneously.", ); } @@ -75,7 +75,7 @@ export class Options { constructor( private $errors: IErrors, - private $settingsService: ISettingsService + private $settingsService: ISettingsService, ) { this.options = _.extend({}, this.commonOptions, this.globalOptions); this.setArgv(); @@ -244,6 +244,8 @@ export class Options { jar: { type: OptionType.String, hasSensitiveValue: true }, aar: { type: OptionType.String, hasSensitiveValue: true }, filter: { type: OptionType.String, hasSensitiveValue: true }, + yaml: { type: OptionType.String, hasSensitiveValue: false }, + jsonMetadata: { type: OptionType.String, hasSensitiveValue: false }, git: { type: OptionType.Boolean, hasSensitiveValue: false, @@ -264,7 +266,7 @@ export class Options { } public validateOptions( - commandSpecificDashedOptions?: IDictionary + commandSpecificDashedOptions?: IDictionary, ): void { this.setupOptions(commandSpecificDashedOptions); const parsed: any = {}; @@ -284,7 +286,7 @@ export class Options { if (!_.includes(this.optionsWhiteList, optionName)) { if (!this.isOptionSupported(optionName)) { this.$errors.failWithHelp( - `The option '${originalOptionName}' is not supported.` + `The option '${originalOptionName}' is not supported.`, ); } @@ -294,7 +296,7 @@ export class Options { if (_.isArray(optionValue) && optionType !== OptionType.Array) { this.$errors.failWithHelp( "The '%s' option requires a single value.", - originalOptionName + originalOptionName, ); } else if ( optionType === OptionType.String && @@ -302,14 +304,14 @@ export class Options { ) { this.$errors.failWithHelp( "The option '%s' requires non-empty value.", - originalOptionName + originalOptionName, ); } else if ( optionType === OptionType.Array && optionValue.length === 0 ) { this.$errors.failWithHelp( - `The option '${originalOptionName}' requires one or more values, separated by a space.` + `The option '${originalOptionName}' requires one or more values, separated by a space.`, ); } } @@ -350,7 +352,7 @@ export class Options { // This way your code will work in case "$ emulate android --profile-dir" or "$ emulate android --profileDir" is used by user. private getNonDashedOptionName(optionName: string): string { const matchUpperCaseLetters = optionName.match( - Options.NONDASHED_OPTION_REGEX + Options.NONDASHED_OPTION_REGEX, ); if (matchUpperCaseLetters) { // get here if option with upperCase letter is specified, for example profileDir @@ -410,7 +412,7 @@ export class Options { .map((match) => { return match[currentDepth]; }) - .filter(Boolean) + .filter(Boolean), ), ];