@appzung/react-native-code-push 10.1.2 → 10.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/android/app/src/main/java/com/appzung/codepush/react/CodePushConstants.java +2 -0
- package/android/app/src/main/java/com/appzung/codepush/react/CodePushNativeModule.java +62 -0
- package/ios/CodePush/CodePush.h +2 -0
- package/ios/CodePush/CodePush.m +28 -0
- package/ios/CodePush/CodePushConfig.m +50 -0
- package/lib/commonjs/allowRestart.js +4 -2
- package/lib/commonjs/allowRestart.js.map +1 -1
- package/lib/commonjs/checkForUpdates.js +1 -1
- package/lib/commonjs/checkForUpdates.js.map +1 -1
- package/lib/commonjs/clearUpdates.js +4 -2
- package/lib/commonjs/clearUpdates.js.map +1 -1
- package/lib/commonjs/dataTransmission.js +28 -0
- package/lib/commonjs/dataTransmission.js.map +1 -0
- package/lib/commonjs/disallowRestart.js +4 -2
- package/lib/commonjs/disallowRestart.js.map +1 -1
- package/lib/commonjs/enums/LogLevel.enum.js +3 -0
- package/lib/commonjs/enums/LogLevel.enum.js.map +1 -1
- package/lib/commonjs/index.js +36 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internals/CodePushApiSdk.js +23 -1
- package/lib/commonjs/internals/CodePushApiSdk.js.map +1 -1
- package/lib/commonjs/internals/CodePushApiSdk.types.js.map +1 -1
- package/lib/commonjs/internals/logger.js +51 -0
- package/lib/commonjs/internals/logger.js.map +1 -0
- package/lib/commonjs/internals/utils/log.js +4 -2
- package/lib/commonjs/internals/utils/log.js.map +1 -1
- package/lib/commonjs/internals/version.js +1 -1
- package/lib/commonjs/logger.js +19 -0
- package/lib/commonjs/logger.js.map +1 -0
- package/lib/commonjs/notifyAppReady.js +4 -2
- package/lib/commonjs/notifyAppReady.js.map +1 -1
- package/lib/commonjs/restartApp.js +2 -2
- package/lib/commonjs/restartApp.js.map +1 -1
- package/lib/commonjs/sync.js +5 -3
- package/lib/commonjs/sync.js.map +1 -1
- package/lib/commonjs/telemetry.js +28 -0
- package/lib/commonjs/telemetry.js.map +1 -0
- package/lib/module/allowRestart.js +3 -1
- package/lib/module/allowRestart.js.map +1 -1
- package/lib/module/checkForUpdates.js +1 -1
- package/lib/module/checkForUpdates.js.map +1 -1
- package/lib/module/clearUpdates.js +3 -1
- package/lib/module/clearUpdates.js.map +1 -1
- package/lib/module/dataTransmission.js +24 -0
- package/lib/module/dataTransmission.js.map +1 -0
- package/lib/module/disallowRestart.js +3 -1
- package/lib/module/disallowRestart.js.map +1 -1
- package/lib/module/enums/LogLevel.enum.js +3 -0
- package/lib/module/enums/LogLevel.enum.js.map +1 -1
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/internals/CodePushApiSdk.js +23 -1
- package/lib/module/internals/CodePushApiSdk.js.map +1 -1
- package/lib/module/internals/CodePushApiSdk.types.js.map +1 -1
- package/lib/module/internals/logger.js +44 -0
- package/lib/module/internals/logger.js.map +1 -0
- package/lib/module/internals/utils/log.js +4 -2
- package/lib/module/internals/utils/log.js.map +1 -1
- package/lib/module/internals/version.js +1 -1
- package/lib/module/logger.js +4 -0
- package/lib/module/logger.js.map +1 -0
- package/lib/module/notifyAppReady.js +4 -2
- package/lib/module/notifyAppReady.js.map +1 -1
- package/lib/module/restartApp.js +2 -2
- package/lib/module/restartApp.js.map +1 -1
- package/lib/module/sync.js +5 -3
- package/lib/module/sync.js.map +1 -1
- package/lib/module/telemetry.js +24 -0
- package/lib/module/telemetry.js.map +1 -0
- package/lib/typescript/commonjs/src/allowRestart.d.ts +1 -1
- package/lib/typescript/commonjs/src/allowRestart.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/clearUpdates.d.ts +1 -1
- package/lib/typescript/commonjs/src/clearUpdates.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/dataTransmission.d.ts +13 -0
- package/lib/typescript/commonjs/src/dataTransmission.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/disallowRestart.d.ts +1 -1
- package/lib/typescript/commonjs/src/disallowRestart.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts +3 -0
- package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +3 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts +3 -1
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts +2 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts +4 -0
- package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/logger.d.ts +33 -0
- package/lib/typescript/commonjs/src/internals/logger.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/utils/log.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/version.d.ts +1 -1
- package/lib/typescript/commonjs/src/logLevel.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/logger.d.ts +3 -0
- package/lib/typescript/commonjs/src/logger.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/notifyAppReady.d.ts +2 -0
- package/lib/typescript/commonjs/src/notifyAppReady.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/restartApp.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/sync.d.ts +2 -0
- package/lib/typescript/commonjs/src/sync.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/telemetry.d.ts +13 -0
- package/lib/typescript/commonjs/src/telemetry.d.ts.map +1 -0
- package/lib/typescript/module/src/allowRestart.d.ts +1 -1
- package/lib/typescript/module/src/allowRestart.d.ts.map +1 -1
- package/lib/typescript/module/src/clearUpdates.d.ts +1 -1
- package/lib/typescript/module/src/clearUpdates.d.ts.map +1 -1
- package/lib/typescript/module/src/dataTransmission.d.ts +13 -0
- package/lib/typescript/module/src/dataTransmission.d.ts.map +1 -0
- package/lib/typescript/module/src/disallowRestart.d.ts +1 -1
- package/lib/typescript/module/src/disallowRestart.d.ts.map +1 -1
- package/lib/typescript/module/src/enums/LogLevel.enum.d.ts +3 -0
- package/lib/typescript/module/src/enums/LogLevel.enum.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +3 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts +3 -1
- package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts +2 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts +4 -0
- package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/logger.d.ts +33 -0
- package/lib/typescript/module/src/internals/logger.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/utils/log.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/version.d.ts +1 -1
- package/lib/typescript/module/src/logLevel.d.ts.map +1 -1
- package/lib/typescript/module/src/logger.d.ts +3 -0
- package/lib/typescript/module/src/logger.d.ts.map +1 -0
- package/lib/typescript/module/src/notifyAppReady.d.ts +2 -0
- package/lib/typescript/module/src/notifyAppReady.d.ts.map +1 -1
- package/lib/typescript/module/src/restartApp.d.ts.map +1 -1
- package/lib/typescript/module/src/sync.d.ts +2 -0
- package/lib/typescript/module/src/sync.d.ts.map +1 -1
- package/lib/typescript/module/src/telemetry.d.ts +13 -0
- package/lib/typescript/module/src/telemetry.d.ts.map +1 -0
- package/package.json +23 -14
- package/scripts/generateBundledResourcesHash.js +73 -68
- package/scripts/getFilesInFolder.js +12 -12
- package/scripts/recordFilesBeforeBundleCommand.js +19 -20
- package/src/allowRestart.ts +3 -1
- package/src/checkForUpdates.ts +1 -1
- package/src/clearUpdates.ts +3 -1
- package/src/dataTransmission.ts +21 -0
- package/src/disallowRestart.ts +3 -1
- package/src/enums/LogLevel.enum.ts +3 -0
- package/src/index.ts +3 -0
- package/src/internals/CodePushApiSdk.ts +27 -0
- package/src/internals/CodePushApiSdk.types.ts +2 -0
- package/src/internals/RNAppZungCodePushModuleSpec.ts +6 -0
- package/src/internals/logger.ts +46 -0
- package/src/internals/utils/log.ts +4 -2
- package/src/internals/version.ts +1 -1
- package/src/logger.ts +2 -0
- package/src/notifyAppReady.ts +4 -2
- package/src/restartApp.ts +2 -2
- package/src/sync.ts +5 -3
- package/src/telemetry.ts +21 -0
- package/typedoc.json +0 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { StatusReport } from './types';
|
|
2
2
|
/**
|
|
3
|
+
* @function
|
|
4
|
+
*
|
|
3
5
|
* Notifies the CodePush runtime that an installed update is considered successful.
|
|
4
6
|
*
|
|
5
7
|
* If you are manually checking for and installing updates (i.e. not using the `sync` method to handle it all for you), then this method **MUST** be called; otherwise CodePush will treat the update as failed and rollback to the previous version when the app next restarts.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifyAppReady.d.ts","sourceRoot":"","sources":["../../../../src/notifyAppReady.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"notifyAppReady.d.ts","sourceRoot":"","sources":["../../../../src/notifyAppReady.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,oCAYvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restartApp.d.ts","sourceRoot":"","sources":["../../../../src/restartApp.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,
|
|
1
|
+
{"version":3,"file":"restartApp.d.ts","sourceRoot":"","sources":["../../../../src/restartApp.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,qBAAqB,UAAQ,iBAEvD"}
|
|
@@ -6,6 +6,8 @@ import type { DownloadProgressCallback, HandleBinaryVersionMismatchCallback, Syn
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const DEFAULT_UPDATE_DIALOG: UpdateDialog;
|
|
8
8
|
/**
|
|
9
|
+
* @function
|
|
10
|
+
*
|
|
9
11
|
* Allows checking for an update, downloading it and installing it, all with a single call.
|
|
10
12
|
*
|
|
11
13
|
* Unless you need custom UI and/or behavior, we recommend most developers to use this method when integrating CodePush into their apps, if they are not using the `withCodePush` HOC.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/sync.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD,OAAO,KAAK,EACV,wBAAwB,EACxB,mCAAmC,EACnC,WAAW,EACX,yBAAyB,EACzB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,YASnC,CAAC;AAqLF
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/sync.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD,OAAO,KAAK,EACV,wBAAwB,EACxB,mCAAmC,EACnC,WAAW,EACX,yBAAyB,EACzB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,YASnC,CAAC;AAqLF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,aAUH,WAAW,8BACO,yBAAyB,6BAC1B,wBAAwB,wCACb,mCAAmC,KACxE,OAAO,CAAC,UAAU,CAgDnB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controls telemetry reporting.
|
|
3
|
+
*
|
|
4
|
+
* @param enabled - When false, updates on this device will stop appearing as failed, pending or succeeded in analytics.
|
|
5
|
+
*/
|
|
6
|
+
export declare function setTelemetryEnabled(enabled: boolean): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Gets the current telemetry enabled status.
|
|
9
|
+
*
|
|
10
|
+
* When setTelemetryEnabled has never been enabled, returns the default value set in your configuration.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getTelemetryEnabled(): Promise<boolean>;
|
|
13
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../../src/telemetry.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAEtD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appzung/react-native-code-push",
|
|
3
|
-
"version": "10.1
|
|
3
|
+
"version": "10.2.1",
|
|
4
4
|
"description": "React Native plugin for the CodePush service",
|
|
5
5
|
"author": "Louis Lagrange <lagrange.louis@gmail.com> (https://github.com/Minishlink)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
|
+
"genversion": "genversion src/internals/version.ts --esm -s",
|
|
30
|
+
"prepare": "yarn genversion && typedoc && bob build",
|
|
29
31
|
"clean": "shx rm -rf bin",
|
|
30
|
-
"
|
|
31
|
-
"prebuild:tests": "npm run clean && npm run tslint",
|
|
32
|
+
"prebuild:tests": "yarn clean",
|
|
32
33
|
"build:tests": "tsc",
|
|
33
|
-
"test": "
|
|
34
|
-
"test:
|
|
35
|
-
"test:ios": "npm run build:tests && npm run test:setup:ios && npm run test:fast:ios",
|
|
34
|
+
"test:android": "yarn build:tests && yarn test:setup:android && yarn test:fast:android",
|
|
35
|
+
"test:ios": "yarn build:tests && yarn test:setup:ios && yarn test:fast:ios",
|
|
36
36
|
"test:setup": "mocha --recursive bin/test --android --ios --setup",
|
|
37
37
|
"test:setup:android": "mocha --recursive bin/test --android --setup",
|
|
38
38
|
"test:setup:ios": "mocha --recursive bin/test --ios --setup",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"test:debugger:android": "mocha --recursive --inspect-brk=0.0.0.0 bin/test --android",
|
|
43
43
|
"test:debugger:ios": "mocha --recursive --inspect-brk=0.0.0.0 bin/test --ios",
|
|
44
44
|
"test:types": "tsc --noEmit",
|
|
45
|
-
"test:format": "prettier --check \"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
45
|
+
"test:format": "prettier --check \"docs/**/*.md\" README.md",
|
|
46
|
+
"test:lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
47
|
+
"test": "yarn test:lint && yarn test:format && yarn test:types"
|
|
48
48
|
},
|
|
49
49
|
"repository": {
|
|
50
50
|
"type": "git",
|
|
@@ -54,6 +54,10 @@
|
|
|
54
54
|
"hoist-non-react-statics": "^3.3.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
+
"@eslint/compat": "^1.2.7",
|
|
58
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
59
|
+
"@eslint/js": "^9.23.0",
|
|
60
|
+
"@react-native/eslint-config": "^0.78.1",
|
|
57
61
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
|
58
62
|
"@types/assert": "^1.5.2",
|
|
59
63
|
"@types/hoist-non-react-statics": "^3.3.6",
|
|
@@ -63,8 +67,11 @@
|
|
|
63
67
|
"@types/q": "^1.5.4",
|
|
64
68
|
"archiver": "^7.0.1",
|
|
65
69
|
"body-parser": "^1.20.3",
|
|
66
|
-
"code-push-plugin-testing-framework": "
|
|
70
|
+
"code-push-plugin-testing-framework": "workspace:./code-push-plugin-testing-framework",
|
|
67
71
|
"del": "v6.0.0",
|
|
72
|
+
"eslint": "^9.23.0",
|
|
73
|
+
"eslint-config-prettier": "^10.1.1",
|
|
74
|
+
"eslint-plugin-prettier": "^5.2.5",
|
|
68
75
|
"express": "^4.21.2",
|
|
69
76
|
"genversion": "^3.2.0",
|
|
70
77
|
"mkdirp": "latest",
|
|
@@ -75,9 +82,8 @@
|
|
|
75
82
|
"run-sequence": "latest",
|
|
76
83
|
"shx": "^0.3.4",
|
|
77
84
|
"slash": "^3.0.0",
|
|
78
|
-
"
|
|
79
|
-
"typedoc": "^
|
|
80
|
-
"typedoc-plugin-markdown": "^4.4.2",
|
|
85
|
+
"typedoc": "^0.28.1",
|
|
86
|
+
"typedoc-plugin-markdown": "^4.6.0",
|
|
81
87
|
"typescript": "^5.7.3"
|
|
82
88
|
},
|
|
83
89
|
"react-native-builder-bob": {
|
|
@@ -105,6 +111,9 @@
|
|
|
105
111
|
]
|
|
106
112
|
]
|
|
107
113
|
},
|
|
114
|
+
"workspaces": [
|
|
115
|
+
"code-push-plugin-testing-framework"
|
|
116
|
+
],
|
|
108
117
|
"keywords": [
|
|
109
118
|
"appzung",
|
|
110
119
|
"codepush",
|
|
@@ -118,5 +127,5 @@
|
|
|
118
127
|
"expo-ota",
|
|
119
128
|
"appcenter"
|
|
120
129
|
],
|
|
121
|
-
"packageManager": "yarn@
|
|
130
|
+
"packageManager": "yarn@4.8.1"
|
|
122
131
|
}
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
* manifest to generate the final hash, which is saved to the APK's assets directory.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var crypto = require(
|
|
15
|
-
var fs = require(
|
|
16
|
-
var path = require(
|
|
14
|
+
var crypto = require('crypto');
|
|
15
|
+
var fs = require('fs');
|
|
16
|
+
var path = require('path');
|
|
17
17
|
|
|
18
|
-
var getFilesInFolder = require(
|
|
18
|
+
var getFilesInFolder = require('./getFilesInFolder');
|
|
19
19
|
|
|
20
|
-
var CODE_PUSH_FOLDER_PREFIX =
|
|
21
|
-
var CODE_PUSH_HASH_FILE_NAME =
|
|
22
|
-
var CODE_PUSH_HASH_OLD_FILE_NAME =
|
|
23
|
-
var HASH_ALGORITHM =
|
|
20
|
+
var CODE_PUSH_FOLDER_PREFIX = 'CodePush';
|
|
21
|
+
var CODE_PUSH_HASH_FILE_NAME = 'CodePushHash';
|
|
22
|
+
var CODE_PUSH_HASH_OLD_FILE_NAME = 'CodePushHash.json';
|
|
23
|
+
var HASH_ALGORITHM = 'sha256';
|
|
24
24
|
|
|
25
25
|
var resourcesDir = process.argv[2];
|
|
26
26
|
var jsBundleFilePath = process.argv[3];
|
|
@@ -30,8 +30,8 @@ var tempFileName = process.argv[5];
|
|
|
30
30
|
var oldFileToModifiedTimeMap = {};
|
|
31
31
|
var tempFileLocalPath = null;
|
|
32
32
|
if (tempFileName) {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
tempFileLocalPath = path.join(require('os').tmpdir(), tempFileName);
|
|
34
|
+
oldFileToModifiedTimeMap = require(tempFileLocalPath);
|
|
35
35
|
}
|
|
36
36
|
var resourceFiles = [];
|
|
37
37
|
|
|
@@ -39,87 +39,92 @@ getFilesInFolder(resourcesDir, resourceFiles);
|
|
|
39
39
|
|
|
40
40
|
var newFileToModifiedTimeMap = {};
|
|
41
41
|
|
|
42
|
-
resourceFiles.forEach(function(resourceFile) {
|
|
43
|
-
|
|
42
|
+
resourceFiles.forEach(function (resourceFile) {
|
|
43
|
+
newFileToModifiedTimeMap[resourceFile.path.substring(resourcesDir.length)] = resourceFile.mtime;
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
var bundleGeneratedAssetFiles = [];
|
|
47
47
|
|
|
48
48
|
for (var newFilePath in newFileToModifiedTimeMap) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
if (
|
|
50
|
+
!oldFileToModifiedTimeMap[newFilePath] ||
|
|
51
|
+
oldFileToModifiedTimeMap[newFilePath] < newFileToModifiedTimeMap[newFilePath].getTime()
|
|
52
|
+
) {
|
|
53
|
+
bundleGeneratedAssetFiles.push(newFilePath);
|
|
54
|
+
}
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
var manifest = [];
|
|
55
58
|
|
|
56
59
|
if (bundleGeneratedAssetFiles.length) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
60
|
+
bundleGeneratedAssetFiles.forEach(function (assetFile) {
|
|
61
|
+
// Generate hash for each asset file
|
|
62
|
+
addFileToManifest(resourcesDir, assetFile, manifest, function () {
|
|
63
|
+
if (manifest.length === bundleGeneratedAssetFiles.length) {
|
|
64
|
+
addJsBundleAndMetaToManifest();
|
|
65
|
+
}
|
|
64
66
|
});
|
|
67
|
+
});
|
|
65
68
|
} else {
|
|
66
|
-
|
|
69
|
+
addJsBundleAndMetaToManifest();
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
function addJsBundleAndMetaToManifest() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
fs.unlinkSync(oldSavedResourcesManifestPath);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
73
|
+
addFileToManifest(path.dirname(jsBundleFilePath), path.basename(jsBundleFilePath), manifest, function () {
|
|
74
|
+
var jsBundleMetaFilePath = jsBundleFilePath + '.meta';
|
|
75
|
+
addFileToManifest(path.dirname(jsBundleMetaFilePath), path.basename(jsBundleMetaFilePath), manifest, function () {
|
|
76
|
+
manifest = manifest.sort();
|
|
77
|
+
var finalHash = crypto.createHash(HASH_ALGORITHM).update(JSON.stringify(manifest)).digest('hex');
|
|
78
|
+
|
|
79
|
+
console.log(finalHash);
|
|
80
|
+
|
|
81
|
+
var savedResourcesManifestPath = assetsDir + '/' + CODE_PUSH_HASH_FILE_NAME;
|
|
82
|
+
fs.writeFileSync(savedResourcesManifestPath, finalHash);
|
|
83
|
+
|
|
84
|
+
// "CodePushHash.json" file name breaks flow type checking.
|
|
85
|
+
// To fix the issue we need to delete "CodePushHash.json" file and
|
|
86
|
+
// use "CodePushHash" file name instead to store the hash value.
|
|
87
|
+
// Relates to https://github.com/microsoft/react-native-code-push/issues/577
|
|
88
|
+
var oldSavedResourcesManifestPath = assetsDir + '/' + CODE_PUSH_HASH_OLD_FILE_NAME;
|
|
89
|
+
if (fs.existsSync(oldSavedResourcesManifestPath)) {
|
|
90
|
+
fs.unlinkSync(oldSavedResourcesManifestPath);
|
|
91
|
+
}
|
|
92
92
|
});
|
|
93
|
+
});
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
function addFileToManifest(folder, assetFile, manifest, done) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
97
|
+
var fullFilePath = path.join(folder, assetFile);
|
|
98
|
+
if (!fileExists(fullFilePath)) {
|
|
99
|
+
done();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
var readStream = fs.createReadStream(path.join(folder, assetFile));
|
|
104
|
+
var hashStream = crypto.createHash(HASH_ALGORITHM);
|
|
105
|
+
|
|
106
|
+
readStream
|
|
107
|
+
.pipe(hashStream)
|
|
108
|
+
.on('error', function (error) {
|
|
109
|
+
throw error;
|
|
110
|
+
})
|
|
111
|
+
.on('finish', function () {
|
|
112
|
+
hashStream.end();
|
|
113
|
+
var buffer = hashStream.read();
|
|
114
|
+
var fileHash = buffer.toString('hex');
|
|
115
|
+
manifest.push(path.join(CODE_PUSH_FOLDER_PREFIX, assetFile).replace(/\\/g, '/') + ':' + fileHash);
|
|
116
|
+
done();
|
|
117
|
+
});
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
function fileExists(file) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
try {
|
|
122
|
+
return fs.statSync(file).isFile();
|
|
123
|
+
} catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
if (tempFileLocalPath) {
|
|
124
|
-
|
|
129
|
+
fs.unlinkSync(tempFileLocalPath);
|
|
125
130
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
var fs = require(
|
|
2
|
-
var path = require(
|
|
1
|
+
var fs = require('fs');
|
|
2
|
+
var path = require('path');
|
|
3
3
|
|
|
4
4
|
// Utility function that collects the stats of every file in a directory
|
|
5
5
|
// as well as in its subdirectories.
|
|
6
6
|
function getFilesInFolder(folderName, fileList) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
var folderFiles = fs.readdirSync(folderName);
|
|
8
|
+
folderFiles.forEach(function (file) {
|
|
9
|
+
var fileStats = fs.statSync(path.join(folderName, file));
|
|
10
|
+
if (fileStats.isDirectory()) {
|
|
11
|
+
getFilesInFolder(path.join(folderName, file), fileList);
|
|
12
|
+
} else {
|
|
13
|
+
fileStats.path = path.join(folderName, file);
|
|
14
|
+
fileList.push(fileStats);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
module.exports = getFilesInFolder;
|
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* This script creates a snapshot of the contents in the resource directory
|
|
3
3
|
* by creating a map with the modified time of all the files in the directory
|
|
4
|
-
* and saving it to a temp file. This snapshot is later referenced in
|
|
4
|
+
* and saving it to a temp file. This snapshot is later referenced in
|
|
5
5
|
* "generatePackageHash.js" to figure out which files have changed or were
|
|
6
6
|
* newly generated by the "react-native bundle" command.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
var fs = require(
|
|
10
|
-
var path = require(
|
|
11
|
-
|
|
12
|
-
var getFilesInFolder = require("./getFilesInFolder");
|
|
9
|
+
var fs = require('fs');
|
|
10
|
+
var path = require('path');
|
|
13
11
|
|
|
12
|
+
var getFilesInFolder = require('./getFilesInFolder');
|
|
14
13
|
|
|
15
14
|
var resourcesDir = process.argv[2];
|
|
16
15
|
var tempFileName = process.argv[3];
|
|
17
16
|
|
|
18
|
-
var tempFileLocalPath = path.join(require(
|
|
17
|
+
var tempFileLocalPath = path.join(require('os').tmpdir(), tempFileName);
|
|
19
18
|
var resourceFiles = [];
|
|
20
19
|
|
|
21
20
|
try {
|
|
22
|
-
|
|
23
|
-
} catch(error) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
getFilesInFolder(resourcesDir, resourceFiles);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
var targetPathNotFoundExceptionMessage = '\nResources directory path does not exist.\n';
|
|
24
|
+
targetPathNotFoundExceptionMessage += "Unable to find '" + resourcesDir;
|
|
25
|
+
targetPathNotFoundExceptionMessage += "' directory. Please check version of Android Plugin for Gradle.";
|
|
26
|
+
error.message += targetPathNotFoundExceptionMessage;
|
|
27
|
+
throw error;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
var fileToModifiedTimeMap = {};
|
|
32
31
|
|
|
33
|
-
resourceFiles.forEach(function(resourceFile) {
|
|
34
|
-
|
|
32
|
+
resourceFiles.forEach(function (resourceFile) {
|
|
33
|
+
fileToModifiedTimeMap[resourceFile.path.substring(resourcesDir.length)] = resourceFile.mtime.getTime();
|
|
35
34
|
});
|
|
36
35
|
|
|
37
|
-
fs.writeFile(tempFileLocalPath, JSON.stringify(fileToModifiedTimeMap), function(err) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
36
|
+
fs.writeFile(tempFileLocalPath, JSON.stringify(fileToModifiedTimeMap), function (err) {
|
|
37
|
+
if (err) {
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
});
|
package/src/allowRestart.ts
CHANGED
|
@@ -5,4 +5,6 @@ import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePu
|
|
|
5
5
|
*
|
|
6
6
|
* This is an advanced API and is only necessary if your app explicitly disallowed restarts via the `disallowRestart` method.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export function allowRestart() {
|
|
9
|
+
return NativeRNAppZungCodePushModule.allow();
|
|
10
|
+
}
|
package/src/checkForUpdates.ts
CHANGED
|
@@ -39,7 +39,7 @@ export async function checkForUpdate(
|
|
|
39
39
|
* release channels (e.g. an early access release channel for insiders).
|
|
40
40
|
*/
|
|
41
41
|
const config: Configuration = releaseChannelPublicId ? { ...nativeConfig, releaseChannelPublicId } : nativeConfig;
|
|
42
|
-
const sdk = new CodePushApiSdk(requestFetchAdapter, config);
|
|
42
|
+
const sdk = new CodePushApiSdk(requestFetchAdapter, log, config);
|
|
43
43
|
|
|
44
44
|
const localPackage = await getCurrentPackage();
|
|
45
45
|
|
package/src/clearUpdates.ts
CHANGED
|
@@ -7,4 +7,6 @@ import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePu
|
|
|
7
7
|
* Note: we don’t recommend using this method in scenarios other than that (CodePush will call
|
|
8
8
|
* this method automatically when needed in other cases) as it could lead to unpredictable behavior.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export function clearUpdates() {
|
|
11
|
+
return NativeRNAppZungCodePushModule.clearUpdates();
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule';
|
|
2
|
+
import { reloadCachedConfiguration } from './internals/getConfiguration';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Controls data transmission for CodePush. This may be used for privacy optIn.
|
|
6
|
+
*
|
|
7
|
+
* @param enabled - When false, disables all external API calls to CodePush servers. Checking for updates will be disabled.
|
|
8
|
+
*/
|
|
9
|
+
export async function setDataTransmissionEnabled(enabled: boolean): Promise<void> {
|
|
10
|
+
await NativeRNAppZungCodePushModule.setDataTransmissionEnabled(enabled);
|
|
11
|
+
await reloadCachedConfiguration();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the current data transmission status.
|
|
16
|
+
*
|
|
17
|
+
* When setDataTransmissionEnabled has never been called, returns the default value set in your configuration.
|
|
18
|
+
*/
|
|
19
|
+
export function getDataTransmissionEnabled(): Promise<boolean> {
|
|
20
|
+
return NativeRNAppZungCodePushModule.getDataTransmissionEnabled();
|
|
21
|
+
}
|
package/src/disallowRestart.ts
CHANGED
|
@@ -5,4 +5,6 @@ import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePu
|
|
|
5
5
|
*
|
|
6
6
|
* This is an advanced API, and is useful when a component within your app (for example an onboarding process) needs to ensure that no end-user interruptions can occur during its lifetime.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export function disallowRestart() {
|
|
9
|
+
return NativeRNAppZungCodePushModule.disallow();
|
|
10
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,9 @@ export * from './sync';
|
|
|
11
11
|
export * from './getClientUniqueId';
|
|
12
12
|
export * from './resetClientUniqueId';
|
|
13
13
|
export * from './logLevel';
|
|
14
|
+
export * from './logger';
|
|
15
|
+
export * from './telemetry';
|
|
16
|
+
export * from './dataTransmission';
|
|
14
17
|
|
|
15
18
|
export * from './types';
|
|
16
19
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LogLevel } from '../enums/LogLevel.enum';
|
|
1
2
|
import { CodePushError, CodePushHttpError } from './CodePushApiSdk.errors';
|
|
2
3
|
import {
|
|
3
4
|
type ApiSdkConfiguration,
|
|
@@ -22,6 +23,7 @@ export class CodePushApiSdk {
|
|
|
22
23
|
|
|
23
24
|
constructor(
|
|
24
25
|
private readonly httpRequester: Http.Requester,
|
|
26
|
+
private readonly log: (level: LogLevel, message: string) => void,
|
|
25
27
|
configuration: ApiSdkConfiguration,
|
|
26
28
|
) {
|
|
27
29
|
this.configuration = { ...configuration };
|
|
@@ -34,6 +36,11 @@ export class CodePushApiSdk {
|
|
|
34
36
|
async queryUpdateWithCurrentPackage(
|
|
35
37
|
currentPackageInfo: ApiSdkQueryUpdatePackageInfo,
|
|
36
38
|
): Promise<ApiSdkRemotePackage | ApiSdkNativeUpdateNotification | null> {
|
|
39
|
+
if (!this.configuration.dataTransmissionEnabled) {
|
|
40
|
+
this.log(LogLevel.DEBUG, 'Skipped querying for update because data transmission is disabled');
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
37
44
|
const query: CheckUpdateRequestInput = {
|
|
38
45
|
deployment_key: this.configuration.releaseChannelPublicId,
|
|
39
46
|
app_version: currentPackageInfo.appVersion,
|
|
@@ -86,6 +93,16 @@ export class CodePushApiSdk {
|
|
|
86
93
|
previousLabelOrAppVersion: string | null,
|
|
87
94
|
previousDeploymentKey: string | null,
|
|
88
95
|
): Promise<void> {
|
|
96
|
+
if (!this.configuration.dataTransmissionEnabled) {
|
|
97
|
+
this.log(LogLevel.DEBUG, 'Skipped reporting deploy status because data transmission is disabled');
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!this.configuration.telemetryEnabled) {
|
|
102
|
+
this.log(LogLevel.DEBUG, 'Skipped reporting deploy status because telemetry is disabled');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
89
106
|
const requestBody: ReportDeployInput = {
|
|
90
107
|
app_version: this.configuration.appVersion,
|
|
91
108
|
deployment_key: this.configuration.releaseChannelPublicId,
|
|
@@ -116,6 +133,16 @@ export class CodePushApiSdk {
|
|
|
116
133
|
}
|
|
117
134
|
|
|
118
135
|
async reportStatusDownload(downloadedPackage: ApiSdkDownloadReportPackageInfo): Promise<void> {
|
|
136
|
+
if (!this.configuration.dataTransmissionEnabled) {
|
|
137
|
+
this.log(LogLevel.DEBUG, 'Skipped reporting download because data transmission is disabled');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (!this.configuration.telemetryEnabled) {
|
|
142
|
+
this.log(LogLevel.DEBUG, 'Skipped reporting download because telemetry is disabled');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
119
146
|
const requestBody: ReportDownloadInput = {
|
|
120
147
|
client_unique_id: this.configuration.clientUniqueId,
|
|
121
148
|
deployment_key: this.configuration.releaseChannelPublicId,
|
|
@@ -52,4 +52,10 @@ export interface Spec extends TurboModule {
|
|
|
52
52
|
|
|
53
53
|
isFirstRun(packageHash: string): Promise<boolean>;
|
|
54
54
|
isFailedUpdate(packageHash: string): Promise<boolean>;
|
|
55
|
+
|
|
56
|
+
setTelemetryEnabled(enabled: boolean): Promise<void>;
|
|
57
|
+
getTelemetryEnabled(): Promise<boolean>;
|
|
58
|
+
|
|
59
|
+
setDataTransmissionEnabled(enabled: boolean): Promise<void>;
|
|
60
|
+
getDataTransmissionEnabled(): Promise<boolean>;
|
|
55
61
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { LogLevel } from '../enums/LogLevel.enum';
|
|
2
|
+
|
|
3
|
+
export type LoggerFunction = (level: LogLevel, message: string) => void;
|
|
4
|
+
|
|
5
|
+
const defaultLogger: LoggerFunction = (_level: LogLevel, message: string): void => {
|
|
6
|
+
console.log(`[CodePush] ${message}`);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
let currentLogger: LoggerFunction = defaultLogger;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Set a custom logger function to handle all CodePush logs
|
|
13
|
+
*
|
|
14
|
+
* @param logger A function that takes a log level and message and handles the logging
|
|
15
|
+
* @example
|
|
16
|
+
* ```
|
|
17
|
+
* import { setLogger, LogLevel } from '@appzung/react-native-code-push';
|
|
18
|
+
*
|
|
19
|
+
* // Custom logger that sends critical logs to a crash reporting service
|
|
20
|
+
* setLogger((level, message) => {
|
|
21
|
+
* // Always log to console
|
|
22
|
+
* console.log(`[CodePush] ${message}`);
|
|
23
|
+
*
|
|
24
|
+
* // Send error logs to crash reporting
|
|
25
|
+
* if (level === LogLevel.ERROR) {
|
|
26
|
+
* MyCrashReportingService.log(`CodePush error: ${message}`);
|
|
27
|
+
* }
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export const setLogger = (logger: LoggerFunction): void => {
|
|
32
|
+
currentLogger = logger;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get the current logger function
|
|
37
|
+
* @returns The current logger function
|
|
38
|
+
*/
|
|
39
|
+
export const getLogger = (): LoggerFunction => currentLogger;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Reset the logger to the default implementation
|
|
43
|
+
*/
|
|
44
|
+
export const resetLogger = (): void => {
|
|
45
|
+
currentLogger = defaultLogger;
|
|
46
|
+
};
|