Skip to content

Commit c481e45

Browse files
committed
fix: more android typings options
1 parent 5d807ce commit c481e45

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

lib/commands/typings.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class TypingsCommand implements ICommand {
5858
const gradleHome = path.resolve(
5959
process.env.GRADLE_USER_HOME ?? path.join(homedir(), `/.gradle`)
6060
);
61-
const gradleFiles = path.resolve(gradleHome, "caches/modules-2/files-2.1/");
61+
const gradleFiles = this.$options.lookupPath ?? path.resolve(gradleHome, "caches/modules-2/files-2.1/");
6262

6363
if (!this.$fs.exists(gradleFiles)) {
6464
this.$logger.warn("No gradle files found");
@@ -160,21 +160,30 @@ export class TypingsCommand implements ICommand {
160160
path.resolve(this.$projectData.projectDir, "typings", "android")
161161
);
162162

163-
const dtsGeneratorPath = path.resolve(
163+
const dtsGeneratorPath = this.$options.dtsGeneratorPath ?? path.resolve(
164164
this.$projectData.projectDir,
165165
this.$projectData.getBuildRelativeDirectoryPath(),
166166
"android",
167167
"build-tools",
168168
"dts-generator.jar"
169169
);
170170
if (!this.$fs.exists(dtsGeneratorPath)) {
171-
this.$logger.warn("No platforms folder found, preparing project now...");
172-
await this.$childProcess.spawnFromEvent(
173-
this.$hostInfo.isWindows ? "ns.cmd" : "ns",
174-
["prepare", "android"],
175-
"exit",
176-
{ stdio: "inherit", shell: this.$hostInfo.isWindows }
177-
);
171+
if (this.$options.dtsGeneratorPath) {
172+
this.$logger.warn(
173+
[
174+
`dts-generator.jar not found at ${this.$options.dtsGeneratorPath} used with --dtsGeneratorPath`,
175+
].join("\n")
176+
);
177+
return false;
178+
} else {
179+
this.$logger.warn("No platforms folder found, preparing project now...");
180+
await this.$childProcess.spawnFromEvent(
181+
this.$hostInfo.isWindows ? "ns.cmd" : "ns",
182+
["prepare", "android"],
183+
"exit",
184+
{ stdio: "inherit", shell: this.$hostInfo.isWindows }
185+
);
186+
}
178187
}
179188

180189
const asArray = (input: string | string[]) => {
@@ -194,12 +203,13 @@ export class TypingsCommand implements ICommand {
194203
...asArray(this.$options.aar),
195204
...paths,
196205
];
197-
198206
await this.$childProcess.spawnFromEvent(
199207
"java",
200208
[
201209
"-jar",
202210
dtsGeneratorPath,
211+
...(this.$options.skipDeclarations?["--skip-declarations"]:[]),
212+
...(this.$options.super?["-super", this.$options.super]:[]),
203213
"-input",
204214
...inputs,
205215
"-output",

lib/declarations.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,10 @@ interface ITypingsOptions {
596596
jar: string;
597597
aar: string;
598598
filter: string;
599+
dtsGeneratorPath: string;
600+
lookupPath: string;
601+
super: string;
602+
skipDeclarations: boolean;
599603
}
600604

601605
interface IOptions

lib/options.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ export class Options {
252252
jar: { type: OptionType.String, hasSensitiveValue: true },
253253
aar: { type: OptionType.String, hasSensitiveValue: true },
254254
filter: { type: OptionType.String, hasSensitiveValue: true },
255+
lookupPath: { type: OptionType.String, hasSensitiveValue: true },
256+
dtsGeneratorPath: { type: OptionType.String, hasSensitiveValue: true },
257+
super: { type: OptionType.String, hasSensitiveValue: true },
258+
skipDeclarations: { type: OptionType.Boolean, hasSensitiveValue: false },
255259
git: {
256260
type: OptionType.Boolean,
257261
hasSensitiveValue: false,

0 commit comments

Comments
 (0)