android-versions@1.4.0 update in 7.1.x (add Pie)

This commit is contained in:
Christopher J. Brody 2018-11-22 09:49:22 -05:00
parent afdffe4028
commit d918c7a83c
5 changed files with 78 additions and 69 deletions

View File

@ -1,4 +1,5 @@
{ {
"esversion": 6,
"indent": 2, "indent": 2,
"forin": true, "forin": true,
"noarg": true, "noarg": true,

View File

@ -30,35 +30,42 @@
*/ */
var VERSIONS = { var VERSIONS = {
BASE: { api: 1, ndk: 0, semver: "1.0", name: "(no code name)", versionCode: "BASE" }, BASE: { api: 1, ndk: 0, semver: "1.0", name: "(no code name)", },
BASE_1_1: { api: 2, ndk: 0, semver: "1.1", name: "(no code name)", versionCode: "BASE_1_1" }, BASE_1_1: { api: 2, ndk: 0, semver: "1.1", name: "(no code name)", },
CUPCAKE: { api: 3, ndk: 1, semver: "1.5", name: "Cupcake", versionCode: "CUPCAKE" }, CUPCAKE: { api: 3, ndk: 1, semver: "1.5", name: "Cupcake", },
DONUT: { api: 4, ndk: 2, semver: "1.6", name: "Donut", versionCode: "DONUT" }, DONUT: { api: 4, ndk: 2, semver: "1.6", name: "Donut", },
ECLAIR: { api: 5, ndk: 2, semver: "2.0", name: "Eclair", versionCode: "ECLAIR" }, ECLAIR: { api: 5, ndk: 2, semver: "2.0", name: "Eclair", },
ECLAIR_0_1: { api: 6, ndk: 2, semver: "2.0.1", name: "Eclair", versionCode: "ECLAIR_0_1" }, ECLAIR_0_1: { api: 6, ndk: 2, semver: "2.0.1", name: "Eclair", },
ECLAIR_MR1: { api: 7, ndk: 3, semver: "2.1", name: "Eclair", versionCode: "ECLAIR_MR1" }, ECLAIR_MR1: { api: 7, ndk: 3, semver: "2.1", name: "Eclair", },
FROYO: { api: 8, ndk: 4, semver: "2.2.x", name: "Froyo", versionCode: "FROYO" }, FROYO: { api: 8, ndk: 4, semver: "2.2.x", name: "Froyo", },
GINGERBREAD: { api: 9, ndk: 5, semver: "2.3.0 - 2.3.2", name: "Gingerbread", versionCode: "GINGERBREAD" }, GINGERBREAD: { api: 9, ndk: 5, semver: "2.3.0 - 2.3.2", name: "Gingerbread", },
GINGERBREAD_MR1: { api: 10, ndk: 5, semver: "2.3.3 - 2.3.7", name: "Gingerbread", versionCode: "GINGERBREAD_MR1" }, GINGERBREAD_MR1: { api: 10, ndk: 5, semver: "2.3.3 - 2.3.7", name: "Gingerbread", },
HONEYCOMB: { api: 11, ndk: 5, semver: "3.0", name: "Honeycomb", versionCode: "HONEYCOMB" }, HONEYCOMB: { api: 11, ndk: 5, semver: "3.0", name: "Honeycomb", },
HONEYCOMB_MR1: { api: 12, ndk: 6, semver: "3.1", name: "Honeycomb", versionCode: "HONEYCOMB_MR1" }, HONEYCOMB_MR1: { api: 12, ndk: 6, semver: "3.1", name: "Honeycomb", },
HONEYCOMB_MR2: { api: 13, ndk: 6, semver: "3.2.x", name: "Honeycomb", versionCode: "HONEYCOMB_MR2" }, HONEYCOMB_MR2: { api: 13, ndk: 6, semver: "3.2.x", name: "Honeycomb", },
ICE_CREAM_SANDWICH: { api: 14, ndk: 7, semver: "4.0.1 - 4.0.2", name: "Ice Cream Sandwich", versionCode: "ICE_CREAM_SANDWICH" }, ICE_CREAM_SANDWICH: { api: 14, ndk: 7, semver: "4.0.1 - 4.0.2", name: "Ice Cream Sandwich", },
ICE_CREAM_SANDWICH_MR1: { api: 15, ndk: 8, semver: "4.0.3 - 4.0.4", name: "Ice Cream Sandwich", versionCode: "ICE_CREAM_SANDWICH_MR1" }, ICE_CREAM_SANDWICH_MR1: { api: 15, ndk: 8, semver: "4.0.3 - 4.0.4", name: "Ice Cream Sandwich", },
JELLY_BEAN: { api: 16, ndk: 8, semver: "4.1.x", name: "Jellybean", versionCode: "JELLY_BEAN" }, JELLY_BEAN: { api: 16, ndk: 8, semver: "4.1.x", name: "Jellybean", },
JELLY_BEAN_MR1: { api: 17, ndk: 8, semver: "4.2.x", name: "Jellybean", versionCode: "JELLY_BEAN_MR1" }, JELLY_BEAN_MR1: { api: 17, ndk: 8, semver: "4.2.x", name: "Jellybean", },
JELLY_BEAN_MR2: { api: 18, ndk: 8, semver: "4.3.x", name: "Jellybean", versionCode: "JELLY_BEAN_MR2" }, JELLY_BEAN_MR2: { api: 18, ndk: 8, semver: "4.3.x", name: "Jellybean", },
KITKAT: { api: 19, ndk: 8, semver: "4.4.0 - 4.4.4", name: "KitKat", versionCode: "KITKAT" }, KITKAT: { api: 19, ndk: 8, semver: "4.4.0 - 4.4.4", name: "KitKat", },
KITKAT_WATCH: { api: 20, ndk: 8, semver: "4.4", name: "KitKat Watch", versionCode: "KITKAT_WATCH" }, KITKAT_WATCH: { api: 20, ndk: 8, semver: "4.4", name: "KitKat Watch", },
LOLLIPOP: { api: 21, ndk: 8, semver: "5.0", name: "Lollipop", versionCode: "LOLLIPOP" }, LOLLIPOP: { api: 21, ndk: 8, semver: "5.0", name: "Lollipop", },
LOLLIPOP_MR1: { api: 22, ndk: 8, semver: "5.1", name: "Lollipop", versionCode: "LOLLIPOP_MR1" }, LOLLIPOP_MR1: { api: 22, ndk: 8, semver: "5.1", name: "Lollipop", },
M: { api: 23, ndk: 8, semver: "6.0", name: "Marshmallow", versionCode: "M" }, M: { api: 23, ndk: 8, semver: "6.0", name: "Marshmallow", },
N: { api: 24, ndk: 8, semver: "7.0", name: "Nougat", versionCode: "N" }, N: { api: 24, ndk: 8, semver: "7.0", name: "Nougat", },
N_MR1: { api: 25, ndk: 8, semver: "7.1", name: "Nougat", versionCode: "N_MR1" }, N_MR1: { api: 25, ndk: 8, semver: "7.1", name: "Nougat", },
O: { api: 26, ndk: 8, semver: "8.0.0", name: "Oreo", versionCode: "O" }, O: { api: 26, ndk: 8, semver: "8.0.0", name: "Oreo", },
O_MR1: { api: 27, ndk: 8, semver: "8.1.0", name: "Oreo", versionCode: "O_MR1" } O_MR1: { api: 27, ndk: 8, semver: "8.1.0", name: "Oreo", },
P: { api: 28, ndk: 8, semver: "9", name: "Pie", }
} }
// Add a key to each version of Android for the "versionCode".
// This is the same key we use in the VERSIONS map above.
Object.keys(VERSIONS).forEach(function(version) {
VERSIONS[version].versionCode = version
})
var semver = require('semver'); var semver = require('semver');
// semver format requires <major>.<minor>.<patch> but we allow just <major>.<minor> format. // semver format requires <major>.<minor>.<patch> but we allow just <major>.<minor> format.
@ -82,8 +89,8 @@ function getFromDefaultPredicate(arg) {
return true return true
} }
let argSemver = formatSemver(arg); var argSemver = formatSemver(arg)
let versionSemver = formatSemver(version.semver); var versionSemver = formatSemver(version.semver)
if (semver.valid(argSemver) && semver.satisfies(argSemver, versionSemver)) { if (semver.valid(argSemver) && semver.satisfies(argSemver, versionSemver)) {
return true return true

View File

@ -1,26 +1,27 @@
{ {
"_from": "android-versions@1.3.0", "_from": "android-versions@1",
"_id": "android-versions@1.3.0", "_id": "android-versions@1.4.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-d/i1G16Oaw/T1EvskUA7Oo1vIQVK/0ZlpQgZfYVBwg6v/9FBE3QV66g5N1/bTHpRml8tFLxh+KoTw5DokK9c+A==", "_integrity": "sha512-GnomfYsBq+nZh3c3UH/4r9Jt6FuTxdhUJbeHIdYOH5xBhQ8I0ZzC2/RM5IFFIjrzuNWSHb8JWP1lPK0/a26jrg==",
"_location": "/android-versions", "_location": "/android-versions",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "android-versions@1.3.0", "raw": "android-versions@1",
"name": "android-versions", "name": "android-versions",
"escapedName": "android-versions", "escapedName": "android-versions",
"rawSpec": "1.3.0", "rawSpec": "1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "1.3.0" "fetchSpec": "1"
}, },
"_requiredBy": [ "_requiredBy": [
"#USER",
"/" "/"
], ],
"_resolved": "https://registry.npmjs.org/android-versions/-/android-versions-1.3.0.tgz", "_resolved": "https://registry.npmjs.org/android-versions/-/android-versions-1.4.0.tgz",
"_shasum": "ce6f3eae2e165ce4ed49b89beb68014741093044", "_shasum": "807ea2941d7e5780e6dd61c5d9b7b6f3c0706e09",
"_spec": "android-versions@1.3.0", "_spec": "android-versions@1",
"_where": "/Users/brodybits/Documents/cordova/cordova-android", "_where": "/Users/brodybits/Documents/cordova/cordova-android",
"author": { "author": {
"name": "dvoiss" "name": "dvoiss"
@ -63,5 +64,5 @@
"jshint": "jshint .", "jshint": "jshint .",
"test": "tape tests/**/*.js" "test": "tape tests/**/*.js"
}, },
"version": "1.3.0" "version": "1.4.0"
} }

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
var test = require('tape') const test = require('tape')
var android = require('..') const android = require('..')
test('get specific version by API level', (t) => { test('get specific version by API level', (t) => {
t.plan(1) t.plan(1)
@ -16,7 +16,7 @@ test('getAll versions by API level', (t) => {
test('get specific version by predicate', (t) => { test('get specific version by predicate', (t) => {
t.plan(2) t.plan(2)
var actual = android.get((version) => { let actual = android.get((version) => {
return version.name.indexOf("on") !== -1 return version.name.indexOf("on") !== -1
}) })
t.equal(actual.name, "Donut") t.equal(actual.name, "Donut")
@ -30,7 +30,7 @@ test('get specific version by predicate', (t) => {
test('getAll versions by predicate', (t) => { test('getAll versions by predicate', (t) => {
t.plan(3) t.plan(3)
var actual = android.getAll((version) => { let actual = android.getAll((version) => {
return version.name.indexOf("on") !== -1 return version.name.indexOf("on") !== -1
}).map((version) => version.name) }).map((version) => version.name)
t.deepEqual(actual, ["Donut", "Honeycomb", "Honeycomb", "Honeycomb"]) t.deepEqual(actual, ["Donut", "Honeycomb", "Honeycomb", "Honeycomb"])
@ -43,7 +43,7 @@ test('getAll versions by predicate', (t) => {
actual = android.getAll((version) => { actual = android.getAll((version) => {
return version.api > 22 return version.api > 22
}).map((version) => version.versionCode) }).map((version) => version.versionCode)
t.deepEqual(actual, ["M", "N", "N_MR1", "O", "O_MR1"]) t.deepEqual(actual, ["M", "N", "N_MR1", "O", "O_MR1", "P"])
}) })
test('get version by semantic version', (t) => { test('get version by semantic version', (t) => {
@ -54,32 +54,31 @@ test('get version by semantic version', (t) => {
t.equal(android.get("2.3.3").versionCode, android.GINGERBREAD_MR1.versionCode) t.equal(android.get("2.3.3").versionCode, android.GINGERBREAD_MR1.versionCode)
}) })
test('support major version only', (t) => {
t.plan(2)
t.equal(android.get("9.0").versionCode, android.P.versionCode)
t.equal(android.get("9.0.0").versionCode, android.P.versionCode)
})
test('support version ranges', (t) => { test('support version ranges', (t) => {
t.plan(7); t.plan(7)
t.equal(android.get("4.4").versionCode, android.KITKAT.versionCode); let tests = [ "4.4", "4.4.0", "4.4.1", "4.4.2", "4.4.3", "4.4.4" ]
t.equal(android.get("4.4.0").versionCode, android.KITKAT.versionCode); tests.forEach((versionCode) => {
t.equal(android.get("4.4.1").versionCode, android.KITKAT.versionCode); t.equal(android.get(versionCode).versionCode, android.KITKAT.versionCode)
t.equal(android.get("4.4.2").versionCode, android.KITKAT.versionCode); })
t.equal(android.get("4.4.3").versionCode, android.KITKAT.versionCode); t.equal(android.get("4.4.5"), null)
t.equal(android.get("4.4.4").versionCode, android.KITKAT.versionCode);
t.equal(android.get("4.4.5"), null);
}) })
test('support x-ranges', (t) => { test('support x-ranges', (t) => {
t.plan(12); t.plan(12)
t.equal(android.get("4.1").versionCode, android.JELLY_BEAN.versionCode); let tests = [
t.equal(android.get("4.1.0").versionCode, android.JELLY_BEAN.versionCode); "4.1", "4.1.0", "4.1.1", "4.1.2", "4.1.3", "4.1.4",
t.equal(android.get("4.1.1").versionCode, android.JELLY_BEAN.versionCode); "4.1.5", "4.1.6", "4.1.7", "4.1.8", "4.1.9", "4.1.10"
t.equal(android.get("4.1.2").versionCode, android.JELLY_BEAN.versionCode); ]
t.equal(android.get("4.1.3").versionCode, android.JELLY_BEAN.versionCode); tests.forEach((versionCode) => {
t.equal(android.get("4.1.4").versionCode, android.JELLY_BEAN.versionCode); t.equal(android.get(versionCode).versionCode, android.JELLY_BEAN.versionCode)
t.equal(android.get("4.1.5").versionCode, android.JELLY_BEAN.versionCode); })
t.equal(android.get("4.1.6").versionCode, android.JELLY_BEAN.versionCode); })
t.equal(android.get("4.1.7").versionCode, android.JELLY_BEAN.versionCode);
t.equal(android.get("4.1.8").versionCode, android.JELLY_BEAN.versionCode);
t.equal(android.get("4.1.9").versionCode, android.JELLY_BEAN.versionCode);
t.equal(android.get("4.1.10").versionCode, android.JELLY_BEAN.versionCode);
});
test('access version codes object', (t) => { test('access version codes object', (t) => {
t.plan(1) t.plan(1)
@ -87,7 +86,7 @@ test('access version codes object', (t) => {
}) })
test('access specific versions directly', (t) => { test('access specific versions directly', (t) => {
t.plan(27) t.plan(28)
t.ok(android.BASE) t.ok(android.BASE)
t.ok(android.BASE_1_1) t.ok(android.BASE_1_1)
t.ok(android.CUPCAKE) t.ok(android.CUPCAKE)
@ -115,4 +114,5 @@ test('access specific versions directly', (t) => {
t.ok(android.N_MR1) t.ok(android.N_MR1)
t.ok(android.O) t.ok(android.O)
t.ok(android.O_MR1) t.ok(android.O_MR1)
t.ok(android.P)
}) })

View File

@ -29,7 +29,7 @@
"author": "Apache Software Foundation", "author": "Apache Software Foundation",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"android-versions": "1.3.0", "android-versions": "1.4.0",
"base64-js": "1.2.0", "base64-js": "1.2.0",
"big-integer": "1.6.32", "big-integer": "1.6.32",
"cordova-common": "2.2.5", "cordova-common": "2.2.5",