Skip to content

Commit 2e7d860

Browse files
committed
feat: add yaml and jsonMetadata options to TypingsCommand
1 parent 7d540b6 commit 2e7d860

3 files changed

Lines changed: 75 additions & 60 deletions

File tree

lib/commands/typings.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,19 +219,35 @@ export class TypingsCommand implements ICommand {
219219
path.resolve(this.$projectData.projectDir, "typings", "ios"),
220220
);
221221

222+
const env: Record<string, string> = {
223+
...process.env,
224+
TNS_TYPESCRIPT_DECLARATIONS_PATH: path.resolve(
225+
this.$projectData.projectDir,
226+
"typings",
227+
"ios",
228+
),
229+
};
230+
231+
if (this.$options.yaml) {
232+
const yamlDir = path.resolve(this.$options.yaml);
233+
this.$fs.ensureDirectoryExists(yamlDir);
234+
env.NS_DEBUG_METADATA_PATH = yamlDir;
235+
this.$logger.info(`Metadata YAML output will be written to: ${yamlDir}`);
236+
}
237+
238+
if (this.$options.jsonMetadata) {
239+
const jsonDir = path.resolve(this.$options.jsonMetadata);
240+
this.$fs.ensureDirectoryExists(jsonDir);
241+
env.NS_JSON_METADATA_PATH = jsonDir;
242+
this.$logger.info(`Metadata JSON output will be written to: ${jsonDir}`);
243+
}
244+
222245
await this.$childProcess.spawnFromEvent(
223246
"node",
224247
[this.$staticConfig.cliBinPath, "build", "ios"],
225248
"exit",
226249
{
227-
env: {
228-
...process.env,
229-
TNS_TYPESCRIPT_DECLARATIONS_PATH: path.resolve(
230-
this.$projectData.projectDir,
231-
"typings",
232-
"ios",
233-
),
234-
},
250+
env,
235251
stdio: "inherit",
236252
},
237253
);

lib/declarations.d.ts

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface INodePackageManager {
3131
install(
3232
packageName: string,
3333
pathToSave: string,
34-
config: INodePackageManagerInstallOptions
34+
config: INodePackageManagerInstallOptions,
3535
): Promise<INpmInstallResultInfo>;
3636

3737
/**
@@ -44,7 +44,7 @@ interface INodePackageManager {
4444
uninstall(
4545
packageName: string,
4646
config?: IDictionary<string | boolean>,
47-
path?: string
47+
path?: string,
4848
): Promise<string>;
4949

5050
/**
@@ -84,7 +84,7 @@ interface INodePackageManager {
8484
*/
8585
search(
8686
filter: string[],
87-
config: IDictionary<string | boolean>
87+
config: IDictionary<string | boolean>,
8888
): Promise<string>;
8989

9090
/**
@@ -130,7 +130,7 @@ interface IPerformanceService {
130130
methodInfo: string,
131131
startTime: number,
132132
endTime: number,
133-
args: any[]
133+
args: any[],
134134
): void;
135135

136136
// Will return a reference time in milliseconds
@@ -141,48 +141,47 @@ interface IPackageInstallationManager {
141141
install(
142142
packageName: string,
143143
packageDir: string,
144-
options?: INpmInstallOptions
144+
options?: INpmInstallOptions,
145145
): Promise<any>;
146146
uninstall(
147147
packageName: string,
148148
packageDir: string,
149-
options?: IDictionary<string | boolean>
149+
options?: IDictionary<string | boolean>,
150150
): Promise<any>;
151151
getLatestVersion(packageName: string): Promise<string>;
152152
getNextVersion(packageName: string): Promise<string>;
153153
getLatestCompatibleVersion(
154154
packageName: string,
155-
referenceVersion?: string
155+
referenceVersion?: string,
156156
): Promise<string>;
157157
getMaxSatisfyingVersion(
158158
packageName: string,
159-
versionRange: string
159+
versionRange: string,
160160
): Promise<string>;
161161
getLatestCompatibleVersionSafe(
162162
packageName: string,
163-
referenceVersion?: string
163+
referenceVersion?: string,
164164
): Promise<string>;
165165
getInspectorFromCache(
166166
inspectorNpmPackageName: string,
167-
projectDir: string
167+
projectDir: string,
168168
): Promise<string>;
169169
clearInspectorCache(): void;
170170
getInstalledDependencyVersion(
171171
packageName: string,
172-
projectDir?: string
172+
projectDir?: string,
173173
): Promise<string>;
174174
getMaxSatisfyingVersionSafe(
175175
packageName: string,
176-
versionIdentifier: string
176+
versionIdentifier: string,
177177
): Promise<string>;
178178
}
179179

180180
/**
181181
* Describes options that can be passed to manipulate package installation.
182182
*/
183183
interface INodePackageManagerInstallOptions
184-
extends INpmInstallConfigurationOptions,
185-
IDictionary<string | boolean> {
184+
extends INpmInstallConfigurationOptions, IDictionary<string | boolean> {
186185
/**
187186
* Destination of the installation.
188187
* @type {string}
@@ -266,7 +265,7 @@ interface INpmPeerDependencyInfo {
266265
* @type {string}
267266
*/
268267
requires: string;
269-
}
268+
},
270269
];
271270
/**
272271
* Dependencies of the dependency.
@@ -550,8 +549,7 @@ interface INpmInstallConfigurationOptionsBase {
550549
ignoreScripts: boolean; //npm flag
551550
}
552551

553-
interface INpmInstallConfigurationOptions
554-
extends INpmInstallConfigurationOptionsBase {
552+
interface INpmInstallConfigurationOptions extends INpmInstallConfigurationOptionsBase {
555553
disableNpmInstall: boolean;
556554
}
557555

@@ -596,8 +594,11 @@ interface ITypingsOptions {
596594
filter: string;
597595
}
598596

597+
yaml: string;
598+
jsonMetadata: string;
599599
interface IOptions
600-
extends IRelease,
600+
extends
601+
IRelease,
601602
IDeviceIdentifier,
602603
IJustLaunch,
603604
IAvd,
@@ -622,7 +623,7 @@ interface IOptions
622623
argv: IYargArgv;
623624
validateOptions(
624625
commandSpecificDashedOptions?: IDictionary<IDashedOption>,
625-
projectData?: IProjectData
626+
projectData?: IProjectData,
626627
): void;
627628
options: IDictionary<IDashedOption>;
628629
shorthands: string[];
@@ -719,26 +720,22 @@ interface IEnvOptions {
719720
}
720721

721722
interface IAndroidBuildOptionsSettings
722-
extends IAndroidReleaseOptions,
723-
IRelease,
724-
Partial<IHasAndroidBundle> {}
723+
extends IAndroidReleaseOptions, IRelease, Partial<IHasAndroidBundle> {}
725724

726725
interface IHasAndroidBundle {
727726
androidBundle: boolean;
728727
}
729728

730729
interface IPlatformBuildData
731-
extends IRelease,
732-
IHasUseHotModuleReloadOption,
733-
IBuildConfig,
734-
IEnvOptions {}
730+
extends IRelease, IHasUseHotModuleReloadOption, IBuildConfig, IEnvOptions {}
735731

736732
interface IDeviceEmulator extends IHasEmulatorOption, IDeviceIdentifier {}
737733

738734
interface IRunPlatformOptions extends IJustLaunch, IDeviceEmulator {}
739735

740736
interface IDeployPlatformOptions
741-
extends IAndroidReleaseOptions,
737+
extends
738+
IAndroidReleaseOptions,
742739
IRelease,
743740
IClean,
744741
IDeviceEmulator,
@@ -834,7 +831,7 @@ interface IAndroidToolsInfo {
834831
*/
835832
validateJavacVersion(
836833
installedJavaVersion: string,
837-
options?: IAndroidToolsInfoOptions
834+
options?: IAndroidToolsInfoOptions,
838835
): boolean;
839836

840837
/**
@@ -913,14 +910,14 @@ interface IAppDebugSocketProxyFactory extends NodeJS.EventEmitter {
913910
device: Mobile.IiOSDevice,
914911
appId: string,
915912
projectName: string,
916-
projectDir: string
913+
projectDir: string,
917914
): Promise<any>;
918915

919916
ensureWebSocketProxy(
920917
device: Mobile.IiOSDevice,
921918
appId: string,
922919
projectName: string,
923-
projectDir: string
920+
projectDir: string,
924921
): Promise<any>;
925922

926923
removeAllProxies(): void;
@@ -939,12 +936,12 @@ interface IiOSSocketRequestExecutor {
939936
executeAttachRequest(
940937
device: Mobile.IiOSDevice,
941938
timeout: number,
942-
projectId: string
939+
projectId: string,
943940
): Promise<void>;
944941
executeRefreshRequest(
945942
device: Mobile.IiOSDevice,
946943
timeout: number,
947-
appId: string
944+
appId: string,
948945
): Promise<boolean>;
949946
}
950947

@@ -995,7 +992,7 @@ interface IProjectNameService {
995992
*/
996993
ensureValidName(
997994
projectName: string,
998-
validateOptions?: { force: boolean }
995+
validateOptions?: { force: boolean },
999996
): Promise<string>;
1000997
}
1001998

@@ -1089,7 +1086,7 @@ interface IBundleValidatorHelper {
10891086
*/
10901087
getBundlerDependencyVersion(
10911088
projectData: IProjectData,
1092-
bundlerName?: string
1089+
bundlerName?: string,
10931090
): string;
10941091
}
10951092

@@ -1171,7 +1168,7 @@ interface IAssetsGenerationService {
11711168
* @returns {Promise<void>}
11721169
*/
11731170
generateSplashScreens(
1174-
splashesGenerationData: IResourceGenerationData
1171+
splashesGenerationData: IResourceGenerationData,
11751172
): Promise<void>;
11761173
}
11771174

@@ -1207,7 +1204,7 @@ interface IPlatformValidationService {
12071204
provision: true | string,
12081205
teamId: true | string,
12091206
projectData: IProjectData,
1210-
platform?: string
1207+
platform?: string,
12111208
): Promise<boolean>;
12121209

12131210
validatePlatformInstalled(platform: string, projectData: IProjectData): void;
@@ -1220,35 +1217,35 @@ interface IPlatformValidationService {
12201217
*/
12211218
isPlatformSupportedForOS(
12221219
platform: string,
1223-
projectData: IProjectData
1220+
projectData: IProjectData,
12241221
): boolean;
12251222
}
12261223

12271224
interface IPlatformCommandHelper {
12281225
addPlatforms(
12291226
platforms: string[],
12301227
projectData: IProjectData,
1231-
frameworkPath?: string
1228+
frameworkPath?: string,
12321229
): Promise<void>;
12331230
cleanPlatforms(
12341231
platforms: string[],
12351232
projectData: IProjectData,
1236-
frameworkPath: string
1233+
frameworkPath: string,
12371234
): Promise<void>;
12381235
removePlatforms(
12391236
platforms: string[],
1240-
projectData: IProjectData
1237+
projectData: IProjectData,
12411238
): Promise<void>;
12421239
updatePlatforms(
12431240
platforms: string[],
1244-
projectData: IProjectData
1241+
projectData: IProjectData,
12451242
): Promise<void>;
12461243
getInstalledPlatforms(projectData: IProjectData): string[];
12471244
getAvailablePlatforms(projectData: IProjectData): string[];
12481245
getPreparedPlatforms(projectData: IProjectData): string[];
12491246
getCurrentPlatformVersion(
12501247
platform: string,
1251-
projectData: IProjectData
1248+
projectData: IProjectData,
12521249
): string;
12531250
}
12541251

0 commit comments

Comments
 (0)