@getik-public/cli 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### v1.2.1
2
+ Fixed typo on versionCode extraction.
3
+
4
+
5
+ ### v1.2.0
6
+ FEATURE: Generate `versionCode` from `versionName`, so no longer needed to maintain `versionCode` in `package.json` file, only `version` needs to be updated.
7
+
8
+
1
9
  ### v1.1.0
2
10
  FEATURE: read versions from package.json and apply to android or ios project for that specific environment
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getik-public/cli",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -65,20 +65,29 @@ async function applyPatchersForExternalNpmPackages() {
65
65
  }
66
66
 
67
67
 
68
- function readVersionsFromPackageJson(options) {
68
+ function readVersionsFromPackageJson() {
69
69
  console.log('Checking versions in package.json file...');
70
70
  const packageJsonBuffer = fs.readFileSync(path.join(process.cwd(), 'package.json'));
71
71
  const packageJson = JSON.parse(packageJsonBuffer);
72
72
 
73
- const environment = (options.environment.split('Debug')[0]);
74
- const capitalizedEnvironment = (environment.charAt(0).toUpperCase() + environment.slice(1));
75
-
76
73
  const versionName = packageJson.version;
77
- const versionCode = packageJson['versionCode' + capitalizedEnvironment];
78
74
 
79
- if (!versionName || !versionCode) {
80
- throw new Error(`Missing properties in "package.json". Make sure you have defined next properties: "version", "versionCode${capitalizedEnvironment}".`);
75
+ if (!versionName) {
76
+ throw new Error(`Missing properties in "package.json". Make sure you have defined next properties: "version".`);
77
+ }
78
+ const splitVersion = versionName.split('.');
79
+ const x = parseInt(splitVersion[0], 10);
80
+ const y = parseInt(splitVersion[1], 10);
81
+ const z = parseInt(splitVersion[2], 10);
82
+
83
+ if (y > 99 || z > 99) {
84
+ throw new Error(`Second and last number in versionName can't be bigger than 99.`);
81
85
  }
86
+
87
+ const yTransformed = (y < 10) ? `0${y}` : y;
88
+ const zTransformed = (z < 10) ? `0${z}` : z;
89
+ const versionCode = `${x}${yTransformed}${zTransformed}`;
90
+
82
91
  console.log(`Extracted versions: versionName = ${versionName}, versionCode = ${versionCode}.`);
83
92
 
84
93
  return {
@@ -360,7 +369,7 @@ export const mobileBuild = () => {
360
369
  console.log('INPUT OPTIONS: ', options);
361
370
  const cliCommands = createCliCommands(options);
362
371
 
363
- const versions = readVersionsFromPackageJson(options);
372
+ const versions = readVersionsFromPackageJson();
364
373
  if (options.platform === 'android') {
365
374
  checkKeystorePropertiesFile();
366
375
  applyVersionForAndroid(versions);