@bravemobile/react-native-code-push 12.0.1 → 12.1.0

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.
Files changed (99) hide show
  1. package/README.md +1 -1
  2. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +1 -52
  3. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +4 -43
  4. package/bin/code-push.js +6 -0
  5. package/cli/commands/bundleCommand/{bundleCodePush.js → bundleCodePush.ts} +16 -24
  6. package/cli/commands/bundleCommand/{index.js → index.ts} +13 -14
  7. package/cli/commands/createHistoryCommand/{createReleaseHistory.js → createReleaseHistory.ts} +11 -28
  8. package/cli/commands/createHistoryCommand/{index.js → index.ts} +12 -13
  9. package/cli/commands/initCommand/{index.js → index.ts} +3 -3
  10. package/cli/commands/initCommand/{initAndroid.js → initAndroid.ts} +6 -11
  11. package/cli/commands/initCommand/initIos.ts +123 -0
  12. package/cli/commands/initCommand/test/{initAndroid.test.js → initAndroid.test.ts} +5 -4
  13. package/cli/commands/initCommand/test/{initIos.test.js → initIos.test.ts} +2 -1
  14. package/cli/commands/releaseCommand/{addToReleaseHistory.js → addToReleaseHistory.ts} +17 -45
  15. package/cli/commands/releaseCommand/{index.js → index.ts} +24 -25
  16. package/cli/commands/releaseCommand/release.ts +72 -0
  17. package/cli/commands/showHistoryCommand/{index.js → index.ts} +11 -12
  18. package/cli/commands/updateHistoryCommand/{index.js → index.ts} +17 -18
  19. package/cli/commands/updateHistoryCommand/{updateReleaseHistory.js → updateReleaseHistory.ts} +15 -41
  20. package/cli/constant.ts +4 -0
  21. package/cli/dist/commands/bundleCommand/bundleCodePush.js +34 -0
  22. package/cli/dist/commands/bundleCommand/index.js +14 -0
  23. package/cli/dist/commands/createHistoryCommand/createReleaseHistory.js +25 -0
  24. package/cli/dist/commands/createHistoryCommand/index.js +14 -0
  25. package/cli/dist/commands/initCommand/index.js +12 -0
  26. package/cli/dist/commands/initCommand/initAndroid.js +37 -0
  27. package/cli/{commands → dist/commands}/initCommand/initIos.js +13 -33
  28. package/cli/dist/commands/initCommand/test/initAndroid.test.js +75 -0
  29. package/cli/dist/commands/initCommand/test/initIos.test.js +95 -0
  30. package/cli/dist/commands/releaseCommand/addToReleaseHistory.js +32 -0
  31. package/cli/dist/commands/releaseCommand/index.js +38 -0
  32. package/cli/dist/commands/releaseCommand/release.js +36 -0
  33. package/cli/dist/commands/showHistoryCommand/index.js +14 -0
  34. package/cli/dist/commands/updateHistoryCommand/index.js +30 -0
  35. package/cli/dist/commands/updateHistoryCommand/updateReleaseHistory.js +26 -0
  36. package/cli/dist/constant.js +4 -0
  37. package/cli/dist/functions/getReactTempDir.js +10 -0
  38. package/cli/{functions → dist/functions}/makeCodePushBundle.js +5 -11
  39. package/cli/{functions → dist/functions}/prepareToBundleJS.js +2 -5
  40. package/cli/{functions → dist/functions}/runExpoBundleCommand.js +3 -21
  41. package/cli/{functions → dist/functions}/runHermesEmitBinaryCommand.js +12 -68
  42. package/cli/{functions → dist/functions}/runReactNativeBundleCommand.js +3 -23
  43. package/cli/dist/index.js +38 -0
  44. package/cli/dist/utils/file-utils.js +19 -0
  45. package/cli/dist/utils/fsUtils.js +37 -0
  46. package/cli/{utils → dist/utils}/hash-utils.js +19 -127
  47. package/cli/{utils → dist/utils}/promisfied-fs.js +5 -16
  48. package/cli/dist/utils/showLogo.js +21 -0
  49. package/cli/{utils → dist/utils}/zip.js +15 -51
  50. package/cli/functions/{getReactTempDir.js → getReactTempDir.ts} +2 -6
  51. package/cli/functions/makeCodePushBundle.ts +26 -0
  52. package/cli/functions/prepareToBundleJS.ts +10 -0
  53. package/cli/functions/runExpoBundleCommand.ts +45 -0
  54. package/cli/functions/runHermesEmitBinaryCommand.ts +186 -0
  55. package/cli/functions/runReactNativeBundleCommand.ts +51 -0
  56. package/cli/index.ts +48 -0
  57. package/cli/package.json +33 -0
  58. package/cli/utils/{file-utils.js → file-utils.ts} +4 -21
  59. package/cli/utils/{fsUtils.js → fsUtils.ts} +12 -19
  60. package/cli/utils/hash-utils.ts +146 -0
  61. package/cli/utils/promisfied-fs.ts +19 -0
  62. package/cli/utils/{showLogo.js → showLogo.ts} +1 -3
  63. package/cli/utils/zip.ts +65 -0
  64. package/expo/plugin/withCodePush.js +1 -2
  65. package/package.json +42 -12
  66. package/{AlertAdapter.js → src/AlertAdapter.js} +5 -5
  67. package/CONTRIBUTING.md +0 -134
  68. package/SECURITY.md +0 -41
  69. package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +0 -17
  70. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  71. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  72. package/android/gradlew +0 -164
  73. package/android/gradlew.bat +0 -90
  74. package/app.plugin.js +0 -1
  75. package/babel.config.js +0 -3
  76. package/cli/commands/releaseCommand/release.js +0 -114
  77. package/cli/constant.js +0 -6
  78. package/cli/index.js +0 -49
  79. package/docs/api-android.md +0 -83
  80. package/docs/api-ios.md +0 -31
  81. package/docs/api-js.md +0 -592
  82. package/docs/multi-deployment-testing-android.md +0 -148
  83. package/docs/multi-deployment-testing-ios.md +0 -59
  84. package/eslint.config.mjs +0 -32
  85. package/scripts/generateBundledResourcesHash.js +0 -125
  86. package/scripts/getFilesInFolder.js +0 -19
  87. package/scripts/recordFilesBeforeBundleCommand.js +0 -41
  88. package/tsconfig.json +0 -18
  89. package/tslint.json +0 -32
  90. /package/{CodePush.js → src/CodePush.js} +0 -0
  91. /package/{logging.js → src/logging.js} +0 -0
  92. /package/{package-mixins.js → src/package-mixins.js} +0 -0
  93. /package/{versioning → src/versioning}/BaseVersioning.js +0 -0
  94. /package/{versioning → src/versioning}/BaseVersioning.test.js +0 -0
  95. /package/{versioning → src/versioning}/IncrementalVersioning.js +0 -0
  96. /package/{versioning → src/versioning}/IncrementalVersioning.test.js +0 -0
  97. /package/{versioning → src/versioning}/SemverVersioning.js +0 -0
  98. /package/{versioning → src/versioning}/SemverVersioning.test.js +0 -0
  99. /package/{versioning → src/versioning}/index.js +0 -0
@@ -1,148 +0,0 @@
1
- ### Android
2
-
3
- > NOTE
4
- >
5
- > Complete demo configured with "multi-deployment testing" feature is [here](https://github.com/microsoft/react-native-code-push/files/1314118/rncp1004.zip).
6
-
7
- The [Android Gradle plugin](https://google.github.io/android-gradle-dsl/current/index.html) allows you to define custom config settings for each "build type" (like debug, release). This mechanism allows you to easily configure your debug builds to use your CodePush staging deployment key and your release builds to use your CodePush production deployment key.
8
-
9
- *NOTE: As a reminder, you can retrieve these keys by running `appcenter codepush deployment list -a <ownerName>/<appName> -k` from your terminal.*
10
-
11
- To set this up, perform the following steps:
12
-
13
- **For React Native >= v0.60**
14
-
15
- 1. Open the project's app level `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)
16
-
17
- 2. Find the `android { buildTypes {} }` section and define `resValue` entries for both your `debug` and `release` build types, which reference your `Staging` and `Production` deployment keys respectively.
18
-
19
- ```groovy
20
- android {
21
- ...
22
- buildTypes {
23
- debug {
24
- ...
25
- // Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
26
- resValue "string", "CodePushDeploymentKey", '""'
27
- ...
28
- }
29
-
30
- releaseStaging {
31
- ...
32
- resValue "string", "CodePushDeploymentKey", '"<INSERT_STAGING_KEY>"'
33
-
34
- // Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
35
- // Add the following line if not already there
36
- matchingFallbacks = ['release']
37
- ...
38
- }
39
-
40
- release {
41
- ...
42
- resValue "string", "CodePushDeploymentKey", '"<INSERT_PRODUCTION_KEY>"'
43
- ...
44
- }
45
- }
46
- ...
47
- }
48
- ```
49
-
50
- *NOTE: Remember to remove the key from `strings.xml` if you are configuring the deployment key in the build process*
51
-
52
- *NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*
53
-
54
- **For React Native v0.29 - v0.59**
55
-
56
- 1. Open up your `MainApplication.java` file and make the following changes:
57
-
58
- ```java
59
- @Override
60
- protected List<ReactPackage> getPackages() {
61
- return Arrays.<ReactPackage>asList(
62
- ...
63
- new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG), // Add/change this line.
64
- ...
65
- );
66
- }
67
- ```
68
-
69
- 2. Open your app's `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)
70
-
71
- 3. Find the `android { buildTypes {} }` section and define `buildConfigField` entries for both your `debug` and `release` build types, which reference your `Staging` and `Production` deployment keys respectively. If you prefer, you can define the key literals in your `gradle.properties` file, and then reference them here. Either way will work, and it's just a matter of personal preference.
72
-
73
- ```groovy
74
- android {
75
- ...
76
- buildTypes {
77
- debug {
78
- ...
79
- // Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
80
- buildConfigField "String", "CODEPUSH_KEY", '""'
81
- ...
82
- }
83
-
84
- releaseStaging {
85
- ...
86
- buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_STAGING_KEY>"'
87
- // Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
88
- // Add the following line if not already there
89
- matchingFallbacks = ['release']
90
- ...
91
- }
92
-
93
- release {
94
- ...
95
- buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_PRODUCTION_KEY>"'
96
- ...
97
- }
98
- }
99
- ...
100
- }
101
- ```
102
-
103
- *NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*
104
-
105
- 4. Pass the deployment key to the `CodePush` constructor via the build config you defined, as opposed to a string literal.
106
-
107
- **For React Native v0.19 - v0.28**
108
-
109
- Open up your `MainActivity.java` file and make the following changes:
110
-
111
- ```java
112
- @Override
113
- protected List<ReactPackage> getPackages() {
114
- return Arrays.<ReactPackage>asList(
115
- ...
116
- new CodePush(BuildConfig.CODEPUSH_KEY, this, BuildConfig.DEBUG), // Add/change this line.
117
- ...
118
- );
119
- }
120
- ```
121
-
122
- *Note: If you gave your build setting a different name in your Gradle file, simply make sure to reflect that in your Java code.*
123
-
124
- And that's it! Now when you run or build your app, your debug builds will automatically be configured to sync with your `Staging` deployment, and your release builds will be configured to sync with your `Production` deployment.
125
-
126
- *NOTE: By default, the `react-native run-android` command builds and deploys the debug version of your app, so if you want to test out a release/production build, simply run `react-native run-android --variant release. Refer to the [React Native docs](http://facebook.github.io/react-native/docs/signed-apk-android.html#conten) for details about how to configure and create release builds for your Android apps.*
127
-
128
- If you want to be able to install both debug and release builds simultaneously on the same device (highly recommended!), then you need to ensure that your debug build has a unique identity and icon from your release build. Otherwise, neither the OS nor you will be able to differentiate between the two. You can achieve this by performing the following steps:
129
-
130
- 1. In your `build.gradle` file, specify the [`applicationIdSuffix`](http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html#com.android.build.gradle.internal.dsl.BuildType:applicationIdSuffix) field for your debug build type, which gives your debug build a unique identity for the OS (like `com.foo` vs. `com.foo.debug`).
131
-
132
- ```groovy
133
- buildTypes {
134
- debug {
135
- applicationIdSuffix ".debug"
136
- }
137
- }
138
- ```
139
-
140
- 2. Create the `app/src/debug/res` directory structure in your app, which allows overriding resources (like strings, icons, layouts) for your debug builds
141
-
142
- 3. Create a `values` directory underneath the debug res directory created in #2, and copy the existing `strings.xml` file from the `app/src/main/res/values` directory
143
-
144
- 4. Open up the new debug `strings.xml` file and change the `<string name="app_name">` element's value to something else (like `foo-debug`). This ensures that your debug build now has a distinct display name, so that you can differentiate it from your release build.
145
-
146
- 5. Optionally, create "mirrored" directories in the `app/src/debug/res` directory for all of your app's icons that you want to change for your debug build. This part isn't technically critical, but it can make it easier to quickly spot your debug builds on a device if its icon is noticeable different.
147
-
148
- And that's it! View [here](http://tools.android.com/tech-docs/new-build-system/resource-merging) for more details on how resource merging works in Android.
@@ -1,59 +0,0 @@
1
- ### iOS
2
-
3
- > NOTE
4
- >
5
- > Complete demos configured with "multi-deployment testing" feature are [here]:
6
- > * **without using cocoa pods**: [link](https://github.com/microsoft/react-native-code-push/files/1259957/rncp976.copy.zip)
7
- > * **using cocoa pods**: [link](https://github.com/microsoft/react-native-code-push/files/1172217/rncp893.copy.zip)
8
-
9
- Xcode allows you to define custom build settings for each "configuration" (like debug, release), which can then be referenced as the value of keys within the `Info.plist` file (like the `CodePushDeploymentKey` setting). This mechanism allows you to easily configure your builds to produce binaries, which are configured to synchronize with different CodePush deployments.
10
-
11
- To set this up, perform the following steps:
12
-
13
- 1. Open up your Xcode project and select your project in the `Project navigator` window
14
-
15
- 2. Ensure the project node is selected, as opposed to one of your targets
16
-
17
- 3. Select the `Info` tab
18
-
19
- 4. Click the `+` button within the `Configurations` section and select `Duplicate "Release" Configuration`
20
-
21
- ![Configuration](https://cloud.githubusercontent.com/assets/116461/16101597/088714c0-331c-11e6-9504-5469d9a59d74.png)
22
-
23
- 5. Name the new configuration `Staging` (or whatever you prefer)
24
-
25
- 6. Select the `Build Settings` tab
26
-
27
- 7. Click the `+` button on the toolbar and select `Add User-Defined Setting`
28
-
29
- ![Setting](https://cloud.githubusercontent.com/assets/116461/15764165/a16dbe30-28dd-11e6-94f2-fa3b7eb0c7de.png)
30
-
31
- Name this new setting something like `Multi_Deployment_Config`. Go to the setting and add value `$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)` for Release. After that add value `$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)` for Staging
32
-
33
- ![MultiDeploymentConfig](https://user-images.githubusercontent.com/48414875/87178636-1d6a6500-c2e6-11ea-890d-b7773f07e503.png)
34
-
35
- *NOTE: For Xcode 10 and lower version: Go to Build Location -> Per-configuration Build Products Path -> Staging and change Staging value from $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to $(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)*
36
-
37
- ![BuildFilesPath1](https://cloud.githubusercontent.com/assets/4928157/22645377/b1d7df0e-ec77-11e6-83c6-291a27bcdb17.png)
38
-
39
- *NOTE: Due to https://github.com/facebook/react-native/issues/11813, we have to do this step to make it possible to use other configurations than Debug or Release on RN 0.40.0 or higher.*
40
-
41
- 8. Click the `+` button again on the toolbar and select `Add User-Defined Setting`
42
-
43
- Name this new setting something like `CODEPUSH_KEY`, expand it, and specify your `Staging` deployment key for the `Staging` config and your `Production` deployment key for the `Release` config.
44
-
45
- ![Setting Keys](https://cloud.githubusercontent.com/assets/8598682/16821919/fc1eac4a-490d-11e6-9b11-128129c24b80.png)
46
-
47
- *NOTE: As a reminder, you can retrieve these keys by running `appcenter codepush deployment list -a <ownerName>/<appName> -k` from your terminal.*
48
-
49
- 9. Open your project's `Info.plist` file and change the value of your `CodePushDeploymentKey` entry to `$(CODEPUSH_KEY)`
50
-
51
- ![Infoplist](https://cloud.githubusercontent.com/assets/116461/15764252/3ac8aed2-28de-11e6-8c19-2270ae9857a7.png)
52
-
53
- And that's it! Now when you run or build your app, your staging builds will automatically be configured to sync with your `Staging` deployment, and your release builds will be configured to sync with your `Production` deployment.
54
-
55
- *NOTE: CocoaPods users may need to run `pod install` before building with their new release configuration.*
56
-
57
- *Note: If you encounter the error message `ld: library not found for ...`, please consult [this issue](https://github.com/microsoft/react-native-code-push/issues/426) for a possible solution.*
58
-
59
- Additionally, if you want to give them seperate names and/or icons, you can modify the `Product Bundle Identifier`, `Product Name` and `Asset Catalog App Icon Set Name` build settings, which will allow your staging builds to be distinguishable from release builds when installed on the same device.
package/eslint.config.mjs DELETED
@@ -1,32 +0,0 @@
1
- import globals from "globals";
2
- import pluginJs from "@eslint/js";
3
- import tseslint from "typescript-eslint";
4
- import pluginReact from "eslint-plugin-react";
5
-
6
-
7
- export default [
8
- {files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"]},
9
- {languageOptions: { globals: {
10
- ...globals.node,
11
- ...globals.mocha,
12
- ...globals.browser,
13
- ...globals.jest
14
- } }},
15
- pluginJs.configs.recommended,
16
- ...tseslint.configs.recommended,
17
- pluginReact.configs.flat.recommended,
18
- {"rules": {
19
- "@typescript-eslint/no-require-imports": "warn",
20
- "@typescript-eslint/no-unused-vars": "warn",
21
- "@typescript-eslint/no-unused-expressions": "warn",
22
- "no-empty": "warn",
23
- "@typescript-eslint/no-explicit-any": "warn",
24
- "no-var": "warn",
25
- "@typescript-eslint/no-this-alias": "warn",
26
- "@typescript-eslint/no-empty-object-type": "warn",
27
- "react/no-deprecated": "warn",
28
- "no-extra-boolean-cast": "warn",
29
- "no-useless-escape": "warn",
30
- "no-control-regex": "warn",
31
- }}
32
- ];
@@ -1,125 +0,0 @@
1
- /*
2
- * This script generates a hash of all the React Native bundled assets and writes it into
3
- * into the APK. The hash in "updateCheck" requests to prevent downloading an identical
4
- * update to the one already present in the binary.
5
- *
6
- * It first creates a snapshot of the contents in the resource directory by creating
7
- * a map with the modified time of all the files in the directory. It then compares this
8
- * snapshot with the one saved earlier in "recordFilesBeforeBundleCommand.js" to figure
9
- * out which files were generated by the "react-native bundle" command. It then computes
10
- * the hash for each file to generate a manifest, and then computes a hash over the entire
11
- * manifest to generate the final hash, which is saved to the APK's assets directory.
12
- */
13
-
14
- var crypto = require("crypto");
15
- var fs = require("fs");
16
- var path = require("path");
17
-
18
- var getFilesInFolder = require("./getFilesInFolder");
19
-
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
-
25
- var resourcesDir = process.argv[2];
26
- var jsBundleFilePath = process.argv[3];
27
- var assetsDir = process.argv[4];
28
- var tempFileName = process.argv[5];
29
-
30
- var oldFileToModifiedTimeMap = {};
31
- var tempFileLocalPath = null;
32
- if (tempFileName) {
33
- tempFileLocalPath = path.join(require("os").tmpdir(), tempFileName);
34
- oldFileToModifiedTimeMap = require(tempFileLocalPath);
35
- }
36
- var resourceFiles = [];
37
-
38
- getFilesInFolder(resourcesDir, resourceFiles);
39
-
40
- var newFileToModifiedTimeMap = {};
41
-
42
- resourceFiles.forEach(function(resourceFile) {
43
- newFileToModifiedTimeMap[resourceFile.path.substring(resourcesDir.length)] = resourceFile.mtime;
44
- });
45
-
46
- var bundleGeneratedAssetFiles = [];
47
-
48
- for (var newFilePath in newFileToModifiedTimeMap) {
49
- if (!oldFileToModifiedTimeMap[newFilePath] || oldFileToModifiedTimeMap[newFilePath] < newFileToModifiedTimeMap[newFilePath].getTime()) {
50
- bundleGeneratedAssetFiles.push(newFilePath);
51
- }
52
- }
53
-
54
- var manifest = [];
55
-
56
- if (bundleGeneratedAssetFiles.length) {
57
- bundleGeneratedAssetFiles.forEach(function(assetFile) {
58
- // Generate hash for each asset file
59
- addFileToManifest(resourcesDir, assetFile, manifest, function() {
60
- if (manifest.length === bundleGeneratedAssetFiles.length) {
61
- addJsBundleAndMetaToManifest();
62
- }
63
- });
64
- });
65
- } else {
66
- addJsBundleAndMetaToManifest();
67
- }
68
-
69
- function addJsBundleAndMetaToManifest() {
70
- addFileToManifest(path.dirname(jsBundleFilePath), path.basename(jsBundleFilePath), manifest, function() {
71
- var jsBundleMetaFilePath = jsBundleFilePath + ".meta";
72
- addFileToManifest(path.dirname(jsBundleMetaFilePath), path.basename(jsBundleMetaFilePath), manifest, function() {
73
- manifest = manifest.sort();
74
- var finalHash = crypto.createHash(HASH_ALGORITHM)
75
- .update(JSON.stringify(manifest))
76
- .digest("hex");
77
-
78
- console.log(finalHash);
79
-
80
- var savedResourcesManifestPath = assetsDir + "/" + CODE_PUSH_HASH_FILE_NAME;
81
- fs.writeFileSync(savedResourcesManifestPath, finalHash);
82
-
83
- // "CodePushHash.json" file name breaks flow type checking.
84
- // To fix the issue we need to delete "CodePushHash.json" file and
85
- // use "CodePushHash" file name instead to store the hash value.
86
- // Relates to https://github.com/microsoft/react-native-code-push/issues/577
87
- var oldSavedResourcesManifestPath = assetsDir + "/" + CODE_PUSH_HASH_OLD_FILE_NAME;
88
- if (fs.existsSync(oldSavedResourcesManifestPath)) {
89
- fs.unlinkSync(oldSavedResourcesManifestPath);
90
- }
91
- });
92
- });
93
- }
94
-
95
- function addFileToManifest(folder, assetFile, manifest, done) {
96
- var fullFilePath = path.join(folder, assetFile);
97
- if (!fileExists(fullFilePath)) {
98
- done();
99
- return;
100
- }
101
-
102
- var readStream = fs.createReadStream(path.join(folder, assetFile));
103
- var hashStream = crypto.createHash(HASH_ALGORITHM);
104
-
105
- readStream.pipe(hashStream)
106
- .on("error", function(error) {
107
- throw error;
108
- })
109
- .on("finish", function() {
110
- hashStream.end();
111
- var buffer = hashStream.read();
112
- var fileHash = buffer.toString("hex");
113
- manifest.push(path.join(CODE_PUSH_FOLDER_PREFIX, assetFile).replace(/\\/g, "/") + ":" + fileHash);
114
- done();
115
- });
116
- }
117
-
118
- function fileExists(file) {
119
- try { return fs.statSync(file).isFile(); }
120
- catch (e) { return false; }
121
- }
122
-
123
- if (tempFileLocalPath) {
124
- fs.unlinkSync(tempFileLocalPath);
125
- }
@@ -1,19 +0,0 @@
1
- var fs = require("fs");
2
- var path = require("path");
3
-
4
- // Utility function that collects the stats of every file in a directory
5
- // as well as in its subdirectories.
6
- function getFilesInFolder(folderName, fileList) {
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
- }
18
-
19
- module.exports = getFilesInFolder;
@@ -1,41 +0,0 @@
1
- /*
2
- * This script creates a snapshot of the contents in the resource directory
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
5
- * "generatePackageHash.js" to figure out which files have changed or were
6
- * newly generated by the "react-native bundle" command.
7
- */
8
-
9
- var fs = require("fs");
10
- var path = require("path");
11
-
12
- var getFilesInFolder = require("./getFilesInFolder");
13
-
14
-
15
- var resourcesDir = process.argv[2];
16
- var tempFileName = process.argv[3];
17
-
18
- var tempFileLocalPath = path.join(require("os").tmpdir(), tempFileName);
19
- var resourceFiles = [];
20
-
21
- try {
22
- getFilesInFolder(resourcesDir, resourceFiles);
23
- } catch(error) {
24
- var targetPathNotFoundExceptionMessage = "\nResources directory path does not exist.\n";
25
- targetPathNotFoundExceptionMessage += "Unable to find '" + resourcesDir;
26
- targetPathNotFoundExceptionMessage += "' directory. Please check version of Android Plugin for Gradle.";
27
- error.message += targetPathNotFoundExceptionMessage;
28
- throw error;
29
- }
30
-
31
- var fileToModifiedTimeMap = {};
32
-
33
- resourceFiles.forEach(function(resourceFile) {
34
- fileToModifiedTimeMap[resourceFile.path.substring(resourcesDir.length)] = resourceFile.mtime.getTime();
35
- });
36
-
37
- fs.writeFile(tempFileLocalPath, JSON.stringify(fileToModifiedTimeMap), function(err) {
38
- if (err) {
39
- throw err;
40
- }
41
- });
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES5",
4
- "module": "commonjs",
5
- "lib": ["es6"],
6
- "noImplicitAny": true,
7
- "noEmitOnError": true,
8
- "moduleResolution": "node",
9
- "sourceMap": true,
10
- "rootDir": "test",
11
- "outDir": "bin",
12
- "removeComments": true
13
- },
14
- "exclude": [
15
- "Examples/CodePushDemoApp",
16
- "code-push.config.example.*"
17
- ]
18
- }
package/tslint.json DELETED
@@ -1,32 +0,0 @@
1
- {
2
- "defaultSeverity": "error",
3
- "rules": {
4
- "class-name": true,
5
- "comment-format": [true,
6
- "check-space"
7
- ],
8
- "indent": [true,
9
- "spaces"
10
- ],
11
- "one-line": [true,
12
- "check-open-brace"
13
- ],
14
- "quotemark": [true,
15
- "double"
16
- ],
17
- "semicolon": true,
18
- "whitespace": [true,
19
- "check-branch",
20
- "check-operator",
21
- "check-separator",
22
- "check-type"
23
- ],
24
- "typedef-whitespace": [true, {
25
- "call-signature": "nospace",
26
- "index-signature": "nospace",
27
- "parameter": "nospace",
28
- "property-declaration": "nospace",
29
- "variable-declaration": "nospace"
30
- }]
31
- }
32
- }
File without changes
File without changes
File without changes
File without changes