Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

add versioning

ammarahm-ed3306e11a2aa3
diff --git a/apps/mobile/patches/react-native-cli-bump-version+1.3.0.patch b/apps/mobile/patches/react-native-cli-bump-version+1.3.0.patch
new file mode 100644
index 000000000..8e910ae55
--- /dev/null
+++ b/apps/mobile/patches/react-native-cli-bump-version+1.3.0.patch
@@ -0,0 +1,96 @@
+diff --git a/node_modules/react-native-cli-bump-version/lib/index.js b/node_modules/react-native-cli-bump-version/lib/index.js
+index a319832..f400a70 100644
+--- a/node_modules/react-native-cli-bump-version/lib/index.js
++++ b/node_modules/react-native-cli-bump-version/lib/index.js
+@@ -23,6 +23,7 @@ const incrementSemVer = (current, type) => {
+ if (type === 'minor') {
+ return [major, minor + 1, 0].join('.');
+ }
++
+ if (type === 'patch') {
+ return [major, minor, patch + 1].join('.');
+ }
+@@ -46,11 +47,23 @@ class BaseFileManager {
+ }
+ }
+ class PBXManager extends BaseFileManager {
+- bumpProjectVersion() {
++ bumpProjectVersion(type) {
+ const currentFile = this.read();
+ const codeRegex = /CURRENT_PROJECT_VERSION = (\d+);/g;
+ const currentCode = ramda_1.pipe(matchFirst(codeRegex), parseDecimal)(currentFile);
+- const nextCode = currentCode + 1;
++ let nextCode = currentCode;
++ if (type === "minor") {
++ nextCode = parseInt((currentCode/100).toFixed(0)) * 100;
++ };
++
++ if (type === "major") {
++ nextCode = parseInt((currentCode/1000).toFixed(0)) * 1000;
++ }
++
++ if (type ==="patch" || !type) {
++ nextCode = currentCode + 1;
++ }
++
+ this.content = ramda_1.replace(codeRegex, `CURRENT_PROJECT_VERSION = ${nextCode};`, currentFile);
+ return {
+ current: currentCode,
+@@ -69,12 +82,25 @@ class PBXManager extends BaseFileManager {
+ }
+ }
+ class BuildGradleManager extends BaseFileManager {
+- bumpCode() {
++ bumpCode(type) {
+ const currentFile = this.read();
+ const codeExp = /versionCode (\d+)/;
+ const versionMatch = matchFirst(codeExp, currentFile);
+ const current = parseDecimal(versionMatch);
+- const next = current + 1;
++ let next = current;
++
++ if (type === "minor") {
++ next = parseInt((current/100).toFixed(0)) * 100;
++ };
++
++ if (type === "major") {
++ next = parseInt((current/1000).toFixed(0)) * 1000;
++ }
++
++ if (type === "patch" || !type) {
++ next = current + 1;
++ }
++
+ if (isNaN(next)) {
+ throw new Error(`Invalid versionCode version parsed (${versionMatch})`);
+ }
+@@ -144,13 +170,13 @@ class ProjectFilesManager {
+ console.log(success(`package.json: ${packageCurrent} -> ${packageNext}`));
+ }
+ bumpCodes() {
+- const { skipCodeFor } = this.configs;
++ const { skipCodeFor,type } = this.configs;
+ if (!skipCodeFor.includes('ios')) {
+- const { next: pbxNext, current: pbxCurrent } = this.pbx.bumpProjectVersion();
++ const { next: pbxNext, current: pbxCurrent } = this.pbx.bumpProjectVersion(type);
+ console.log(success(`iOS project.pbxproj code: ${pbxCurrent} -> ${pbxNext}`));
+ }
+ if (!skipCodeFor.includes('android')) {
+- const { next: gradleNext, current: gradleCurrent } = this.buildGradle.bumpCode();
++ const { next: gradleNext, current: gradleCurrent } = this.buildGradle.bumpCode(type);
+ console.log(success(`Android build.gradle code: ${gradleCurrent} -> ${gradleNext}`));
+ }
+ }
+diff --git a/node_modules/react-native-cli-bump-version/src/index.ts b/node_modules/react-native-cli-bump-version/src/index.ts
+index 906180f..d12406e 100644
+--- a/node_modules/react-native-cli-bump-version/src/index.ts
++++ b/node_modules/react-native-cli-bump-version/src/index.ts
+@@ -41,7 +41,7 @@ const incrementSemVer = (current: string, type: SemVer | undefined) => {
+ if (type === 'minor') {
+ return [major, minor + 1, 0].join('.')
+ }
+-
++ console.log(patch);
+ if (type === 'patch') {
+ return [major, minor, patch + 1].join('.')
+ }