capacitor-standard-version 1.0.16 → 1.0.18
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/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/bin/android.ts +7 -19
- package/src/bin/index.ts +18 -17
- package/src/bin/ios.ts +8 -20
- package/src/bin/utils.ts +33 -0
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
(()=>{"use strict";var e={572:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeVersion=t.readVersion=void 0
|
|
2
|
+
(()=>{"use strict";var e={572:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeVersion=t.readVersion=void 0;const o=r(800);t.readVersion=e=>e.split('versionName "')[1].split('"')[0],t.writeVersion=(e,t)=>{const[r,n]=t.split("-"),i=e.replace(/(.*(?:versionName[ \t]+).*)/g,`\t\tversionName "${r}"`);let s=(0,o.versionPureToCode)(r),a=(0,o.versionBetaToCode)(n);const u=(0,o.versionCodeToCodeBeta)(s,a);return i.replace(/(.*(?:versionCode[ \t]+).*)/g,`\t\tversionCode ${u}`)}},91:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t},s=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const u=i(r(572)),d=i(r(489)),c=a(r(389)),l=a(r(322)),p=a(r(731)),f={noVerify:!0,tagPrefix:"",packageFiles:[{filename:"./package.json",type:"json"}],bumpFiles:[{filename:"./android/app/build.gradle",updater:u},{filename:"./package.json",type:"json"},{filename:"./package-lock.json",type:"json"},{filename:"./ios/App/App.xcodeproj/project.pbxproj",updater:d}]};!function(){s(this,void 0,void 0,(function*(){try{const e=(0,c.default)(p.default.argv,f);yield(0,l.default)(e)}catch(e){throw console.error(e),e}}))}()},489:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeVersion=t.readVersion=void 0;const o=r(800);t.readVersion=e=>e.match(/MARKETING_VERSION = [0-9]*.[0-9]*.[0-9]*/).toString().split("=")[1].trim(),t.writeVersion=(e,t)=>{const[r,n]=t.split("-"),i=e.replace(/(.*(?:MARKETING_VERSION[ \t]+).*)/g,`\t\t\t\tMARKETING_VERSION = ${r};`);let s=(0,o.versionPureToCode)(r),a=(0,o.versionBetaToCode)(n);const u=(0,o.versionCodeToCodeBeta)(s,a);return i.replace(/(.*(?:CURRENT_PROJECT_VERSION[ \t]+).*)/g,`\t\t\t\tCURRENT_PROJECT_VERSION = ${u};`)}},800:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.versionCodeToCodeBeta=t.versionBetaToCode=t.versionPureToCode=void 0,t.versionPureToCode=e=>Number(e.split(".").map((e=>1===e.length?`0${e}`:e)).join("")),t.versionBetaToCode=e=>{if(!e)return 999;let t=Number(e.split(".")[1]||0);if(t>100)throw new Error("versionCodeBeta should be less than 100");return e.startsWith("rc.")?t=800+t:e.startsWith("beta.")?t=700+t:e.startsWith("alpha.")&&(t=600+t),t},t.versionCodeToCodeBeta=(e,t)=>1e3*e+t},389:e=>{e.exports=require("merge-deep")},322:e=>{e.exports=require("standard-version")},731:e=>{e.exports=require("standard-version/command")}},t={};!function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,r),i.exports}(91)})();
|
package/package.json
CHANGED
package/src/bin/android.ts
CHANGED
|
@@ -1,34 +1,22 @@
|
|
|
1
|
+
import { versionBetaToCode, versionCodeToCodeBeta, versionPureToCode } from './utils';
|
|
2
|
+
|
|
1
3
|
export const readVersion = contents => {
|
|
2
4
|
const version = contents.split('versionName "')[1].split('"')[0];
|
|
3
5
|
return version;
|
|
4
6
|
};
|
|
5
7
|
|
|
6
8
|
export const writeVersion = (contents, version) => {
|
|
7
|
-
const [versionPure,
|
|
9
|
+
const [versionPure, versionBeta] = version.split('-');
|
|
8
10
|
const newContent = contents.replace(
|
|
9
11
|
/(.*(?:versionName[ \t]+).*)/g,
|
|
10
12
|
`\t\tversionName "${versionPure}"`
|
|
11
13
|
);
|
|
12
|
-
let versionCode =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.map(v => (v.length === 1 ? `0${v}` : v))
|
|
16
|
-
.join('')
|
|
17
|
-
);
|
|
18
|
-
if (versionBata) {
|
|
19
|
-
const versionCodeBeta = Number(versionBata.split('.')[1]);
|
|
20
|
-
if (versionCodeBeta < 100) {
|
|
21
|
-
versionCode = versionCode * 100 + versionCodeBeta;
|
|
22
|
-
} else {
|
|
23
|
-
versionCode += versionCodeBeta;
|
|
24
|
-
}
|
|
25
|
-
} else {
|
|
26
|
-
// keep the order of the versionCode main version should be bigger than beta version
|
|
27
|
-
versionCode = versionCode * 100 + 99;
|
|
28
|
-
}
|
|
14
|
+
let versionCode = versionPureToCode(versionPure);
|
|
15
|
+
let versionCodeBeta = versionBetaToCode(versionBeta);
|
|
16
|
+
const versionCodeFinal = versionCodeToCodeBeta(versionCode, versionCodeBeta);
|
|
29
17
|
const finalContent = newContent.replace(
|
|
30
18
|
/(.*(?:versionCode[ \t]+).*)/g,
|
|
31
|
-
`\t\tversionCode ${
|
|
19
|
+
`\t\tversionCode ${versionCodeFinal}`
|
|
32
20
|
);
|
|
33
21
|
return finalContent;
|
|
34
22
|
};
|
package/src/bin/index.ts
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
+
import * as android from './android';
|
|
2
|
+
import * as ios from './ios';
|
|
3
|
+
|
|
4
|
+
import merge from 'merge-deep';
|
|
1
5
|
import standardVersion from 'standard-version';
|
|
2
6
|
import command from 'standard-version/command';
|
|
3
|
-
import merge from 'merge-deep';
|
|
4
|
-
import * as ios from './ios';
|
|
5
|
-
import * as android from './android';
|
|
6
7
|
|
|
7
8
|
const baseConfig = {
|
|
8
9
|
noVerify: true,
|
|
9
10
|
tagPrefix: '',
|
|
10
11
|
packageFiles: [
|
|
11
12
|
{
|
|
12
|
-
filename:
|
|
13
|
-
type:
|
|
13
|
+
filename: './package.json',
|
|
14
|
+
type: 'json',
|
|
14
15
|
},
|
|
15
16
|
],
|
|
16
17
|
bumpFiles: [
|
|
17
18
|
{
|
|
18
|
-
filename:
|
|
19
|
-
updater: android
|
|
19
|
+
filename: './android/app/build.gradle',
|
|
20
|
+
updater: android,
|
|
20
21
|
},
|
|
21
22
|
{
|
|
22
|
-
filename:
|
|
23
|
-
type:
|
|
23
|
+
filename: './package.json',
|
|
24
|
+
type: 'json',
|
|
24
25
|
},
|
|
25
26
|
{
|
|
26
|
-
filename:
|
|
27
|
-
type:
|
|
27
|
+
filename: './package-lock.json',
|
|
28
|
+
type: 'json',
|
|
28
29
|
},
|
|
29
30
|
{
|
|
30
|
-
filename:
|
|
31
|
-
updater: ios
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
}
|
|
31
|
+
filename: './ios/App/App.xcodeproj/project.pbxproj',
|
|
32
|
+
updater: ios,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
35
36
|
|
|
36
37
|
async function run() {
|
|
37
38
|
try {
|
|
@@ -44,4 +45,4 @@ async function run() {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
run();
|
|
48
|
+
run();
|
package/src/bin/ios.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { versionBetaToCode, versionCodeToCodeBeta, versionPureToCode } from './utils';
|
|
2
|
+
|
|
1
3
|
export const readVersion = contents => {
|
|
2
4
|
const marketingVersionString = contents.match(/MARKETING_VERSION = [0-9]*.[0-9]*.[0-9]*/);
|
|
3
5
|
const version = marketingVersionString.toString().split('=')[1].trim();
|
|
@@ -5,31 +7,17 @@ export const readVersion = contents => {
|
|
|
5
7
|
};
|
|
6
8
|
|
|
7
9
|
export const writeVersion = (contents, version) => {
|
|
8
|
-
const [versionPure,
|
|
10
|
+
const [versionPure, versionBeta] = version.split('-');
|
|
9
11
|
const newContent = contents.replace(
|
|
10
12
|
/(.*(?:MARKETING_VERSION[ \t]+).*)/g,
|
|
11
|
-
`\t\t\t\tMARKETING_VERSION =
|
|
12
|
-
);
|
|
13
|
-
let versionCode = Number(
|
|
14
|
-
versionPure
|
|
15
|
-
.split('.')
|
|
16
|
-
.map(v => (v.length === 1 ? `0${v}` : v))
|
|
17
|
-
.join('')
|
|
13
|
+
`\t\t\t\tMARKETING_VERSION = ${versionPure};`
|
|
18
14
|
);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
versionCode = versionCode * 100 + versionCodeBeta;
|
|
23
|
-
} else {
|
|
24
|
-
versionCode += versionCodeBeta;
|
|
25
|
-
}
|
|
26
|
-
} else {
|
|
27
|
-
// keep the order of the versionCode main version should be bigger than beta version
|
|
28
|
-
versionCode = versionCode * 100 + 99;
|
|
29
|
-
}
|
|
15
|
+
let versionCode = versionPureToCode(versionPure);
|
|
16
|
+
let versionCodeBeta = versionBetaToCode(versionBeta);
|
|
17
|
+
const versionCodeFinal = versionCodeToCodeBeta(versionCode, versionCodeBeta);
|
|
30
18
|
const finalContent = newContent.replace(
|
|
31
19
|
/(.*(?:CURRENT_PROJECT_VERSION[ \t]+).*)/g,
|
|
32
|
-
`\t\t\t\tCURRENT_PROJECT_VERSION =
|
|
20
|
+
`\t\t\t\tCURRENT_PROJECT_VERSION = ${versionCodeFinal};`
|
|
33
21
|
);
|
|
34
22
|
return finalContent;
|
|
35
23
|
};
|
package/src/bin/utils.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const versionPureToCode = (versionPure: string): number => {
|
|
2
|
+
let versionCode = Number(
|
|
3
|
+
versionPure
|
|
4
|
+
.split('.')
|
|
5
|
+
.map(v => (v.length === 1 ? `0${v}` : v))
|
|
6
|
+
.join('')
|
|
7
|
+
);
|
|
8
|
+
return versionCode;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const versionBetaToCode = (versionBeta: string): number => {
|
|
12
|
+
// Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.2 < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0
|
|
13
|
+
// Become 600 < 601 < 602 < 700 < 702 < 711 < 801 < 900
|
|
14
|
+
if (!versionBeta) {
|
|
15
|
+
return 999;
|
|
16
|
+
}
|
|
17
|
+
let versionCodeBeta = Number(versionBeta.split('.')[1] || 0);
|
|
18
|
+
if (versionCodeBeta > 100) {
|
|
19
|
+
throw new Error('versionCodeBeta should be less than 100');
|
|
20
|
+
}
|
|
21
|
+
if (versionBeta.startsWith('rc.')) {
|
|
22
|
+
versionCodeBeta = 800 + versionCodeBeta;
|
|
23
|
+
} else if (versionBeta.startsWith('beta.')) {
|
|
24
|
+
versionCodeBeta = 700 + versionCodeBeta;
|
|
25
|
+
} else if (versionBeta.startsWith('alpha.')) {
|
|
26
|
+
versionCodeBeta = 600 + versionCodeBeta;
|
|
27
|
+
}
|
|
28
|
+
return versionCodeBeta;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const versionCodeToCodeBeta = (versionCode: number, versionCodeBeta: number): number => {
|
|
32
|
+
return versionCode * 1000 + versionCodeBeta;
|
|
33
|
+
};
|