Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class PackageJSONManager {
private readonly basePath: () => string;
public content: {
version: string;
versionCode?: string;
} | null = null;

constructor(basePath: () => string) {
Expand Down Expand Up @@ -212,6 +213,32 @@ class PackageJSONManager {

return { next, current };
}

getVersionCode() {
return this.read().versionCode;
}

setVersionCode(next: string) {
const current = this.getVersionCode();
this.content!.versionCode = next;

return { next, current };
}

bumpVersionCode() {
const current = this.getVersionCode();
if (current) {
const currentCode = parseInt(current, 10);
const nextCode = currentCode + 1;
const next = nextCode.toString();

this.content!.versionCode = next;

return { next, current };
}

return null;
}
}

class ProjectFilesManager {
Expand Down Expand Up @@ -278,6 +305,13 @@ class ProjectFilesManager {
} = this.buildGradle.bumpCode();
console.log(`Android build.gradle code: ${gradleCurrent} -> ${gradleNext}`);
}

// Bump package.json versionCode
const packageVersionCodeResult = this.packageJSON.bumpVersionCode();
if (packageVersionCodeResult) {
const { next: packageNext, current: packageCurrent } = packageVersionCodeResult;
console.log(`package.json versionCode: ${packageCurrent} -> ${packageNext}`);
}
}

run() {
Expand Down