Skip to content

Commit d416cce

Browse files
authored
Merge pull request #2180 from NativeScript/pete/android-dts-build-flag
Add androidTypings experimental flag
2 parents d0f0c2b + 7f58349 commit d416cce

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

lib/android-tools-info.ts

+5
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
8686
infoData.buildToolsVersion = this.getBuildToolsVersion().wait();
8787
infoData.targetSdkVersion = this.getTargetSdk().wait();
8888
infoData.supportRepositoryVersion = this.getAndroidSupportRepositoryVersion().wait();
89+
infoData.generateTypings = this.shouldGenerateTypings();
8990

9091
this.toolsInfo = infoData;
9192
}
@@ -196,6 +197,10 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
196197
}).future<string>()();
197198
}
198199

200+
private shouldGenerateTypings(): boolean {
201+
return this.$options.androidTypings;
202+
}
203+
199204
/**
200205
* Prints messages on the screen. In case the showWarningsAsErrors flag is set to true, warnings are shown, else - errors.
201206
* Uses logger.warn for warnings and errors.failWithoutHelp when erros must be shown.

lib/declarations.ts

+6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ interface IOptions extends ICommonOptions {
9191
linkTo: string;
9292
ng: boolean;
9393
tsc: boolean;
94+
androidTypings: boolean;
9495
bundle: boolean;
9596
platformTemplate: string;
9697
port: Number;
@@ -224,6 +225,11 @@ interface IAndroidToolsInfoData {
224225
* In case it is not specified, compileSdkVersion will be used for targetSdkVersion.
225226
*/
226227
targetSdkVersion: number;
228+
229+
/**
230+
* Whether or not `.d.ts` typings should be generated for compileSdk. Experimental feature
231+
*/
232+
generateTypings: boolean;
227233
}
228234

229235
interface ISocketProxyFactory {

lib/options.ts

+13-12
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,35 @@ export class Options extends commonOptionsLibPath.OptionsBase {
1515
framework: { type: OptionType.String },
1616
frameworkVersion: { type: OptionType.String },
1717
copyFrom: { type: OptionType.String },
18-
linkTo: { type: OptionType.String },
18+
linkTo: { type: OptionType.String },
1919
symlink: { type: OptionType.Boolean },
2020
forDevice: { type: OptionType.Boolean },
21-
client: { type: OptionType.Boolean, default: true},
21+
client: { type: OptionType.Boolean, default: true },
2222
production: { type: OptionType.Boolean },
23-
debugTransport: {type: OptionType.Boolean},
23+
debugTransport: { type: OptionType.Boolean },
2424
keyStorePath: { type: OptionType.String },
25-
keyStorePassword: { type: OptionType.String,},
25+
keyStorePassword: { type: OptionType.String, },
2626
keyStoreAlias: { type: OptionType.String },
2727
keyStoreAliasPassword: { type: OptionType.String },
28-
ignoreScripts: {type: OptionType.Boolean },
29-
disableNpmInstall: {type: OptionType.Boolean },
28+
ignoreScripts: { type: OptionType.Boolean },
29+
disableNpmInstall: { type: OptionType.Boolean },
3030
tnsModulesVersion: { type: OptionType.String },
31-
compileSdk: {type: OptionType.Number },
31+
compileSdk: { type: OptionType.Number },
3232
port: { type: OptionType.Number },
3333
copyTo: { type: OptionType.String },
3434
baseConfig: { type: OptionType.String },
3535
platformTemplate: { type: OptionType.String },
36-
ng: {type: OptionType.Boolean },
37-
tsc: {type: OptionType.Boolean },
38-
bundle: {type: OptionType.Boolean },
39-
all: {type: OptionType.Boolean },
36+
ng: { type: OptionType.Boolean },
37+
tsc: { type: OptionType.Boolean },
38+
androidTypings: { type: OptionType.Boolean },
39+
bundle: { type: OptionType.Boolean },
40+
all: { type: OptionType.Boolean },
4041
teamId: { type: OptionType.String },
4142
rebuild: { type: OptionType.Boolean, default: true },
4243
syncAllFiles: { type: OptionType.Boolean },
4344
liveEdit: { type: OptionType.Boolean }
4445
},
45-
path.join($hostInfo.isWindows ? process.env.AppData : path.join(osenv.home(), ".local/share"), ".nativescript-cli"),
46+
path.join($hostInfo.isWindows ? process.env.AppData : path.join(osenv.home(), ".local/share"), ".nativescript-cli"),
4647
$errors, $staticConfig);
4748

4849
// On Windows we moved settings from LocalAppData to AppData. Move the existing file to keep the existing settings

lib/services/android-project-service.ts

+2
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,13 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
275275
let targetSdk = this.getTargetFromAndroidManifest().wait() || compileSdk;
276276
let buildToolsVersion = androidToolsInfo.buildToolsVersion;
277277
let appCompatVersion = androidToolsInfo.supportRepositoryVersion;
278+
let generateTypings = androidToolsInfo.generateTypings;
278279
let buildOptions = [
279280
`-PcompileSdk=android-${compileSdk}`,
280281
`-PtargetSdk=${targetSdk}`,
281282
`-PbuildToolsVersion=${buildToolsVersion}`,
282283
`-PsupportVersion=${appCompatVersion}`,
284+
`-PgenerateTypings=${generateTypings}`
283285
];
284286

285287
if (this.$options.release) {

0 commit comments

Comments
 (0)