⚠️ DISCLAIMER
I am not saying that this is the standard nor that this is the best practice. I introduce this because I think it is 'handy' for me. Also, please note that there already might be a workflow better than this.
Motivations
I want to do the followings with an effort as little as possible:
- Avoid version collision between the installed app and a newly built app in production (for test)
- Exploit the existing commands or scripts for versioning
TL;DR
Here is my app.config.js
:
+import { readFileSync } from "fs";
+const { version } = JSON.parse(readFileSync("./package.json"), "utf8");
+const [major, minor] = version.split(".").map(Number);
+const now = new Date();
+const year = now.getFullYear().toString().padStart(4, "0");
+const month = (now.getMonth() + 1).toString().padStart(2, "0");
+const day = now.getDate().toString().padStart(2, "0");
+const hour = now.getHours().toString().padStart(2, "0");
+const minute = now.getMinutes().toString().padStart(2, "0");
export default {
expo {
- version: "1.0.0",
+ version: `${major}.${minor}.${year}${month}${day}${hour}${minute}`,
}
}
Explanation
PATCH version (${year}...${minute}
)
Whenever I run expo prebuild
, app version is refreshed and PATCH version is set to the date/time of prebuilding. Thus, it will never raise version collision with the already installed app.
MAJOR, MINOR version
I pulled MAJOR and MINOR versions from package.json
. This enables me to reuse the npm version
. By running npm version major
and npm version minor
, MAJOR and MINOR versions of package.json
get updated and so does app's version.
Top comments (0)