38 |
${dates.threeDaysAgo.format('D MMM YYYY')}
39 |
${environment.osVersion} and beyond
40 |
${environment.buildVersion}
41 |
42 | `,
43 | storeParsedPage: {
44 | date: dates.threeDaysAgo.format('D MMM YYYY'),
45 | os: environment.osVersion,
46 | version: environment.buildVersion,
47 | },
48 | }
49 |
50 | const config = {
51 | majorUpdateAlertType: AlertTypesConstants.FORCE,
52 | minorUpdateAlertType: AlertTypesConstants.OPTION,
53 | patchUpdateAlertType: AlertTypesConstants.NONE,
54 | revisionUpdateAlertType: AlertTypesConstants.OPTION,
55 | notifyNbDaysAfterRelease: 2,
56 | countryCode: environment.countryCode,
57 | }
58 |
59 | const HTTPResponse = {
60 | success: { status: 200 },
61 | error: { status: 404 },
62 | }
63 |
64 | const ios = {
65 | urlWithCountryCode: `https://itunes.apple.com/lookup?bundleId=${environment.appId}&hl=${environment.countryCode}`,
66 | urlWithoutCountryCode: `https://itunes.apple.com/lookup?bundleId=${environment.appId}`,
67 | trackViewUrl: `https://itunes.apple.com/us/app/bitmoji/id868077558?mt=8&uo=4`,
68 | storeURL: `itms-apps://itunes.apple.com/us/app/bitmoji/id868077558?mt=8&uo=4`,
69 | validResource: {
70 | resultCount: 3,
71 | results: [1, 2, 3],
72 | },
73 | nonValidResource: {
74 | resultCount: 0,
75 | },
76 | }
77 |
78 | const translation = {
79 | key: 'ALERT_TITLE',
80 | value: 'Update available',
81 | }
82 |
83 | const updates = {
84 | major: '2.1.1.1',
85 | minor: '1.2.1.1',
86 | patch: '1.1.2.1',
87 | revision: '1.1.1.2',
88 | past: '0.0.0.1',
89 | }
90 |
91 | const os = {
92 | lower: '0.1',
93 | higher: '100.2',
94 | }
95 |
96 | module.exports = {
97 | alerts,
98 | android,
99 | config,
100 | dates,
101 | environment,
102 | HTTPResponse,
103 | ios,
104 | os,
105 | translation,
106 | updates,
107 | }
108 |
--------------------------------------------------------------------------------
/demo/app/tests/version.helper.spec.js:
--------------------------------------------------------------------------------
1 | const StoreUpdate = require('nativescript-store-update')
2 | const VersionHelper = StoreUpdate.VersionHelper
3 |
4 | describe('VersionHelper ', () => {
5 | describe('_compareVersions function', () => {
6 | it('returns 1 if a version is > b version', () => {
7 | expect(VersionHelper._compareVersions('2.0.0.0', '1.0.0.0')).toEqual(1)
8 | expect(VersionHelper._compareVersions('1.2.0.0', '1.0.0.0')).toEqual(1)
9 | expect(VersionHelper._compareVersions('1.0.2.0', '1.0.0.0')).toEqual(1)
10 | })
11 |
12 | it('returns -1 if a version is < b version', () => {
13 | expect(VersionHelper._compareVersions('1.0.0.0', '2.0.0.0')).toEqual(-1)
14 | expect(VersionHelper._compareVersions('1.0.0.0', '1.2.0.0')).toEqual(-1)
15 | expect(VersionHelper._compareVersions('1.0.0.0', '1.0.2.0')).toEqual(-1)
16 | })
17 |
18 | it('returns 0 if a version is === b version', () => {
19 | expect(VersionHelper._compareVersions('1.0.0.0', '1.0.0.0')).toEqual(0)
20 | })
21 | })
22 |
23 | describe('_isIndexSectionHigher function', () => {
24 | it('returns true if version section a is higher than b', () => {
25 | expect(VersionHelper._isIndexSectionHigher('2.0.0.0', '1.0.0.0', 0)).toBe(true)
26 | expect(VersionHelper._isIndexSectionHigher('1.2.0.0', '1.0.0.0', 1)).toBe(true)
27 | expect(VersionHelper._isIndexSectionHigher('1.0.2.0', '1.0.0.0', 2)).toBe(true)
28 | expect(VersionHelper._isIndexSectionHigher('1.0.0.2', '1.0.0.0', 3)).toBe(true)
29 | })
30 |
31 | it('returns false if version section a is lower than b', () => {
32 | expect(VersionHelper._isIndexSectionHigher('1.0.0.0', '2.0.0.0', 0)).toBe(false)
33 | expect(VersionHelper._isIndexSectionHigher('1.0.0.0', '1.2.0.0', 1)).toBe(false)
34 | expect(VersionHelper._isIndexSectionHigher('1.0.0.0', '1.0.2.0', 2)).toBe(false)
35 | expect(VersionHelper._isIndexSectionHigher('1.0.0.0', '1.0.0.2', 3)).toBe(false)
36 | })
37 |
38 | it(`returns false if version section doesn't exists on a`, () => {
39 | expect(VersionHelper._isIndexSectionHigher('2', '1.0', 1)).toBe(false)
40 | })
41 |
42 | it(`returns true if version section doesn't exists on b`, () => {
43 | expect(VersionHelper._isIndexSectionHigher('2.0', '1', 1)).toBe(true)
44 | })
45 | })
46 |
47 | describe('isHigher function', () => {
48 | it('returns true if version a is higher than b', () => {
49 | expect(VersionHelper.isHigher('2.0.0.0', '1.0.0.0')).toBe(true)
50 | })
51 |
52 | it('returns false if version a is equal to b', () => {
53 | expect(VersionHelper.isHigher('2.0.0.0', '2.0.0.0')).toBe(false)
54 | })
55 |
56 | it('returns false if version a is lower than b', () => {
57 | expect(VersionHelper.isHigher('1.0.0.0', '2.0.0.0')).toBe(false)
58 | })
59 | })
60 |
61 | describe('isEqualOrHigher function', () => {
62 | it('returns true if version a is higher than b', () => {
63 | expect(VersionHelper.isEqualOrHigher('2.0.0.0', '1.0.0.0')).toBe(true)
64 | })
65 |
66 | it('returns true if version a is equal to b', () => {
67 | expect(VersionHelper.isEqualOrHigher('2.0.0.0', '2.0.0.0')).toBe(true)
68 | })
69 |
70 | it('returns false if version a is lower than b', () => {
71 | expect(VersionHelper.isEqualOrHigher('1.0.0.0', '2.0.0.0')).toBe(false)
72 | })
73 | })
74 |
75 | describe('isMajorUpdate function', () => {
76 | it('returns true if major version a is higher than major b', () => {
77 | expect(VersionHelper.isMajorUpdate('2.0.0.0', '1.0.0.0')).toBe(true)
78 | })
79 |
80 | it('returns false if major version a is equal to major b', () => {
81 | expect(VersionHelper.isMajorUpdate('2.0.0.0', '2.0.0.0')).toBe(false)
82 | })
83 |
84 | it('returns false if major version a is lower than major b', () => {
85 | expect(VersionHelper.isMajorUpdate('1.0.0.0', '2.0.0.0')).toBe(false)
86 | })
87 | })
88 |
89 | describe('isMinorUpdate function', () => {
90 | it('returns true if minor version a is higher than minor b', () => {
91 | expect(VersionHelper.isMinorUpdate('1.2.0.0', '1.0.0.0')).toBe(true)
92 | })
93 |
94 | it('returns false if minor version a is equal to minor b', () => {
95 | expect(VersionHelper.isMinorUpdate('1.2.0.0', '1.2.0.0')).toBe(false)
96 | })
97 |
98 | it('returns false if minor version a is lower than minor b', () => {
99 | expect(VersionHelper.isMinorUpdate('1.0.0.0', '1.2.0.0')).toBe(false)
100 | })
101 | })
102 |
103 | describe('isPatchUpdate function', () => {
104 | it('returns true if patch version a is higher than patch b', () => {
105 | expect(VersionHelper.isPatchUpdate('1.0.2.0', '1.0.0.0')).toBe(true)
106 | })
107 |
108 | it('returns false if patch version a is equal to patch b', () => {
109 | expect(VersionHelper.isPatchUpdate('1.0.2.0', '1.0.2.0')).toBe(false)
110 | })
111 |
112 | it('returns false if patch version a is lower than patch b', () => {
113 | expect(VersionHelper.isPatchUpdate('1.0.0.0', '1.0.2.0')).toBe(false)
114 | })
115 | })
116 |
117 | describe('isRevisionUpdate function', () => {
118 | it('returns true if revision version a is higher than revision b', () => {
119 | expect(VersionHelper.isRevisionUpdate('1.0.0.2', '1.0.0.0')).toBe(true)
120 | })
121 |
122 | it('returns false if revision version a is equal to revision b', () => {
123 | expect(VersionHelper.isRevisionUpdate('1.0.0.2', '1.0.0.2')).toBe(false)
124 | })
125 |
126 | it('returns false if revision version a is lower than revision b', () => {
127 | expect(VersionHelper.isRevisionUpdate('1.0.0.0', '1.0.0.2')).toBe(false)
128 | })
129 | })
130 | })
131 |
--------------------------------------------------------------------------------
/demo/app/vendor-platform.android.ts:
--------------------------------------------------------------------------------
1 | require('application')
2 | /* tslint:disable-next-line: no-string-literal */
3 | if (!global['__snapshot']) {
4 | /*
5 | In case snapshot generation is enabled these modules will get into the bundle but will not be required/evaluated.
6 | The snapshot webpack plugin will add them to the tns-java-classes.js bundle file. This way, they will be evaluated on app start as early as possible.
7 | */
8 | require('ui/frame')
9 | require('ui/frame/activity')
10 | }
11 |
--------------------------------------------------------------------------------
/demo/app/vendor-platform.ios.ts:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chronogolf/nativescript-store-update/10d58971c6a5350b8988f443a1f47f3ba921a0bd/demo/app/vendor-platform.ios.ts
--------------------------------------------------------------------------------
/demo/app/vendor-platform.ts:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chronogolf/nativescript-store-update/10d58971c6a5350b8988f443a1f47f3ba921a0bd/demo/app/vendor-platform.ts
--------------------------------------------------------------------------------
/demo/app/vendor.ts:
--------------------------------------------------------------------------------
1 | require('./vendor-platform')
2 |
3 | require('bundle-entry-points')
4 |
--------------------------------------------------------------------------------
/demo/karma.conf.js:
--------------------------------------------------------------------------------
1 | module.exports = function(config) {
2 | config.set({
3 |
4 | // base path that will be used to resolve all patterns (eg. files, exclude)
5 | basePath: '',
6 |
7 |
8 | // frameworks to use
9 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
10 | frameworks: ['jasmine'],
11 |
12 |
13 | // list of files / patterns to load in the browser
14 | files: [
15 | 'app/**/*.js'
16 | ],
17 |
18 |
19 | // list of files to exclude
20 | exclude: [
21 | ],
22 |
23 |
24 | // preprocess matching files before serving them to the browser
25 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
26 | preprocessors: {
27 | },
28 |
29 |
30 | // test results reporter to use
31 | // possible values: 'dots', 'progress'
32 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter
33 | reporters: ['progress'],
34 |
35 |
36 | // web server port
37 | port: 9876,
38 |
39 |
40 | // enable / disable colors in the output (reporters and logs)
41 | colors: true,
42 |
43 |
44 | // level of logging
45 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
46 | logLevel: config.LOG_INFO,
47 |
48 |
49 | // enable / disable watching file and executing tests whenever any file changes
50 | autoWatch: true,
51 |
52 |
53 | // start these browsers
54 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
55 | browsers: [],
56 |
57 | customLaunchers: {
58 | android: {
59 | base: 'NS',
60 | platform: 'android'
61 | },
62 | ios: {
63 | base: 'NS',
64 | platform: 'ios'
65 | },
66 | ios_simulator: {
67 | base: 'NS',
68 | platform: 'ios',
69 | arguments: ['--emulator']
70 | }
71 | },
72 |
73 | // Continuous Integration mode
74 | // if true, Karma captures browsers, runs the tests and exits
75 | singleRun: true
76 | });
77 | };
78 |
--------------------------------------------------------------------------------
/demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "nativescript": {
3 | "id": "com.bitstrips.imoji",
4 | "tns-ios": {
5 | "version": "3.2.0"
6 | },
7 | "tns-android": {
8 | "version": "3.2.0"
9 | }
10 | },
11 | "dependencies": {
12 | "moment": "2.18.1",
13 | "nativescript-appversion": "^1.4.1",
14 | "nativescript-store-update": "file:../src",
15 | "nativescript-unit-test-runner": "^0.3.4",
16 | "tns-core-modules": "^3.2.0"
17 | },
18 | "devDependencies": {
19 | "awesome-typescript-loader": "~3.1.3",
20 | "babel-traverse": "6.12.0",
21 | "babel-types": "6.11.1",
22 | "babylon": "6.8.4",
23 | "copy-webpack-plugin": "~4.0.1",
24 | "extract-text-webpack-plugin": "~3.0.0",
25 | "filewalker": "0.1.2",
26 | "jasmine-core": "^2.5.2",
27 | "karma": "^1.3.0",
28 | "karma-jasmine": "^1.0.2",
29 | "karma-nativescript-launcher": "^0.4.0",
30 | "lazy": "1.0.11",
31 | "nativescript-css-loader": "~0.26.0",
32 | "nativescript-dev-typescript": "libs",
33 | "nativescript-dev-webpack": "^0.7.3",
34 | "raw-loader": "~0.5.1",
35 | "resolve-url-loader": "~2.1.0",
36 | "tns-platform-declarations": "^3.1.0",
37 | "tslint": "~5.4.3",
38 | "typescript": "~2.3.0",
39 | "webpack": "~3.2.0",
40 | "webpack-bundle-analyzer": "^2.8.2",
41 | "webpack-sources": "~1.0.1"
42 | },
43 | "scripts": {
44 | "build.plugin": "cd ../src && npm run build",
45 | "ci.tslint": "npm i && tslint --config '../tslint.json' 'app/**/*.ts' --exclude '**/node_modules/**'",
46 | "ns-bundle": "ns-bundle",
47 | "publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
48 | "generate-android-snapshot": "generate-android-snapshot --targetArchs arm,arm64,ia32 --install",
49 | "start-android-bundle": "npm run ns-bundle --android --run-app",
50 | "start-ios-bundle": "npm run ns-bundle --ios --run-app",
51 | "build-android-bundle": "npm run ns-bundle --android --build-app",
52 | "build-ios-bundle": "npm run ns-bundle --ios --build-app"
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/demo/references.d.ts:
--------------------------------------------------------------------------------
1 | ///