@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,114 +0,0 @@
1
- const fs = require('fs');
2
- const { bundleCodePush } = require("../bundleCommand/bundleCodePush");
3
- const { addToReleaseHistory } = require("./addToReleaseHistory");
4
-
5
- /**
6
- * @param bundleUploader {
7
- * function(
8
- * source: string,
9
- * platform: "ios" | "android",
10
- * identifier?: string
11
- * ): Promise<{ downloadUrl: string }>}
12
- * @param getReleaseHistory {
13
- * function(
14
- * targetBinaryVersion: string,
15
- * platform: "ios" | "android",
16
- * identifier?: string
17
- * ): Promise<ReleaseHistoryInterface>}
18
- * @param setReleaseHistory {
19
- * function(
20
- * targetBinaryVersion: string,
21
- * jsonFilePath: string,
22
- * releaseInfo: ReleaseHistoryInterface,
23
- * platform: "ios" | "android",
24
- * identifier?: string
25
- * ): Promise<void>}
26
- * @param binaryVersion {string}
27
- * @param appVersion {string}
28
- * @param framework {string|undefined} 'expo'
29
- * @param platform {"ios" | "android"}
30
- * @param identifier {string?}
31
- * @param outputPath {string}
32
- * @param entryFile {string}
33
- * @param jsBundleName {string}
34
- * @param mandatory {boolean}
35
- * @param enable {boolean}
36
- * @param rollout {number}
37
- * @param skipBundle {boolean}
38
- * @param skipCleanup {boolean}
39
- * @param bundleDirectory {string}
40
- * @return {Promise<void>}
41
- */
42
- async function release(
43
- bundleUploader,
44
- getReleaseHistory,
45
- setReleaseHistory,
46
- binaryVersion,
47
- appVersion,
48
- framework,
49
- platform,
50
- identifier,
51
- outputPath,
52
- entryFile,
53
- jsBundleName,
54
- mandatory,
55
- enable,
56
- rollout,
57
- skipBundle,
58
- skipCleanup,
59
- bundleDirectory,
60
- ) {
61
- const bundleFileName = skipBundle
62
- ? readBundleFileNameFrom(bundleDirectory)
63
- : await bundleCodePush(framework, platform, outputPath, entryFile, jsBundleName, bundleDirectory);
64
- const bundleFilePath = `${bundleDirectory}/${bundleFileName}`;
65
-
66
- const downloadUrl = await (async () => {
67
- try {
68
- const { downloadUrl } = await bundleUploader(bundleFilePath, platform, identifier);
69
- return downloadUrl
70
- } catch (error) {
71
- console.error('Failed to upload the bundle file. Exiting the program.\n', error)
72
- process.exit(1)
73
- }
74
- })();
75
-
76
- await addToReleaseHistory(
77
- appVersion,
78
- binaryVersion,
79
- downloadUrl,
80
- bundleFileName,
81
- getReleaseHistory,
82
- setReleaseHistory,
83
- platform,
84
- identifier,
85
- mandatory,
86
- enable,
87
- rollout,
88
- )
89
-
90
- if (!skipCleanup) {
91
- cleanUpOutputs(outputPath);
92
- }
93
- }
94
-
95
- function cleanUpOutputs(dir) {
96
- fs.rmSync(dir, { recursive: true });
97
- }
98
-
99
- /**
100
- * @param bundleDirectory {string}
101
- * @return {string}
102
- */
103
- function readBundleFileNameFrom(bundleDirectory) {
104
- const files = fs.readdirSync(bundleDirectory);
105
- if (files.length !== 1) {
106
- console.error('The bundlePath must contain only one file.');
107
- process.exit(1);
108
- }
109
- const path = require('path');
110
- const bundleFilePath = path.join(bundleDirectory, files[0]);
111
- return path.basename(bundleFilePath);
112
- }
113
-
114
- module.exports = { release: release }
package/cli/constant.js DELETED
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- CONFIG_FILE_NAME: "code-push.config.ts",
3
- OUTPUT_BUNDLE_DIR: "bundleOutput",
4
- ROOT_OUTPUT_DIR: "build",
5
- ENTRY_FILE: "index.ts",
6
- };
package/cli/index.js DELETED
@@ -1,49 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { program } = require("commander");
4
- const shell = require("shelljs");
5
- const { showLogo } = require("./utils/showLogo");
6
-
7
- shell.set("-e");
8
- shell.set("+v");
9
-
10
- program
11
- .name("npx code-push")
12
- .description("Command line interface for @bravemobile/react-native-code-push")
13
- .version("1.0.0")
14
- .action(() => {
15
- showLogo();
16
- });
17
-
18
- /**
19
- * npx code-push bundle
20
- */
21
- require("./commands/bundleCommand");
22
-
23
- /**
24
- * npx code-push create-history
25
- */
26
- require('./commands/createHistoryCommand');
27
-
28
- /**
29
- * npx code-push update-history
30
- */
31
- require('./commands/updateHistoryCommand');
32
-
33
- /**
34
- * npx code-push release
35
- */
36
- require('./commands/releaseCommand');
37
-
38
- /**
39
- * npx code-push show-history
40
- */
41
- require('./commands/showHistoryCommand')
42
-
43
- /**
44
- * npx code-push init
45
- */
46
- require('./commands/initCommand')
47
-
48
-
49
- program.parse();
@@ -1,83 +0,0 @@
1
- ### Java API Reference (Android)
2
-
3
- ### API for React Native 0.60 version and above
4
-
5
- Since `autolinking` uses `react-native.config.js` to link plugins, constructors are specified in that file. But you can override custom variables to manage the CodePush plugin by placing these values in string resources.
6
-
7
- * __Public Key__ - used for bundle verification in the Code Signing Feature. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more details about the Code Signing Feature.
8
- To set the public key, you should add the content of the public key to `strings.xml` with name `CodePushPublicKey`. CodePush automatically gets this property and enables the Code Signing feature. For example:
9
- ```xml
10
- <string moduleConfig="true" name="CodePushPublicKey">your-public-key</string>
11
- ```
12
-
13
- * __Server Url__ - used for specifying CodePush Server Url.
14
- The Default value: "https://codepush.appcenter.ms/" is overridden by adding your path to `strings.xml` with name `CodePushServerUrl`. CodePush automatically gets this property and will use this path to send requests. For example:
15
- ```xml
16
- <string moduleConfig="true" name="CodePushServerUrl">https://yourcodepush.server.com</string>
17
- ```
18
-
19
- ### API for React Native lower than 0.60
20
-
21
- The Java API is made available by importing the `com.microsoft.codepush.react.CodePush` class into your `MainActivity.java` file, and consists of a single public class named `CodePush`.
22
-
23
- #### CodePush
24
-
25
- Constructs the CodePush client runtime and represents the `ReactPackage` instance that you add to you app's list of packages.
26
-
27
- ##### Constructors
28
-
29
- - __CodePush(String deploymentKey, Activity mainActivity)__ - Creates a new instance of the CodePush runtime, that will be used to query the service for updates via the provided deployment key. The `mainActivity` parameter should always be set to `this` when configuring your React packages list inside the `MainActivity` class. This constructor puts the CodePush runtime into "release mode", so if you want to enable debugging behavior, use the following constructor instead.
30
-
31
- - __CodePush(String deploymentKey, Activity mainActivity, bool isDebugMode)__ - Equivalent to the previous constructor but allows you to specify whether you want the CodePush runtime to be in debug mode or not. When using this constructor, the `isDebugMode` parameter should always be set to `BuildConfig.DEBUG` in order to stay synchronized with your build type. When putting CodePush into debug mode, the following behaviors are enabled:
32
-
33
- 1. Old CodePush updates aren't deleted from storage whenever a new binary is deployed to the emulator/device. This behavior enables you to deploy new binaries, without bumping the version during development, and without continuously getting the same update every time your app calls `sync`.
34
-
35
- 2. The local cache that the React Native runtime maintains in debug mode is deleted whenever a CodePush update is installed. This ensures that when the app is restarted after an update is applied, you will see the expected changes. As soon as [this PR](https://github.com/facebook/react-native/pull/4738) is merged, we won't need to do this anymore.
36
-
37
- - __CodePush(String deploymentKey, Context context, boolean isDebugMode, Integer publicKeyResourceDescriptor)__ - Equivalent to the previous constructor, but allows you to specify the public key resource descriptor needed to read public key content. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more details about the Code Signing Feature.
38
-
39
- - __CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl)__ Constructor allows you to specify CodePush Server Url. The Default value: `"https://codepush.appcenter.ms/"` is overridden by value specified in `serverUrl`.
40
-
41
- ##### Builder
42
-
43
- As an alternative to constructors *you can also use `CodePushBuilder`* to setup a CodePush instance configured with *only parameters you want*.
44
-
45
- ```java
46
- @Override
47
- protected List<ReactPackage> getPackages() {
48
- return Arrays.<ReactPackage>asList(
49
- new MainReactPackage(),
50
- new CodePushBuilder("deployment-key-here",getApplicationContext())
51
- .setIsDebugMode(BuildConfig.DEBUG)
52
- .setPublicKeyResourceDescriptor(R.string.publicKey)
53
- .setServerUrl("https://yourcodepush.server.com")
54
- .build() //return configured CodePush instance
55
- );
56
- }
57
- ```
58
-
59
- `CodePushBuilder` methods:
60
-
61
- * __public CodePushBuilder(String deploymentKey, Context context)__ - setup same parameters as via __CodePush(String deploymentKey, Activity mainActivity)__
62
-
63
- * __public CodePushBuilder setIsDebugMode(boolean isDebugMode)__ - allows you to specify whether you want the CodePush runtime to be in debug mode or not. Default value: `false`.
64
-
65
- * __public CodePushBuilder setServerUrl(String serverUrl)__ - allows you to specify CodePush Server Url. Default value: `"https://codepush.appcenter.ms/"`.
66
-
67
- * __public CodePushBuilder setPublicKeyResourceDescriptor(int publicKeyResourceDescriptor)__ - allows you to specify Public Key resource descriptor which will be used for reading Public Key content for `strings.xml` file. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more detailed information about purpose of this parameter.
68
-
69
- * __public CodePush build()__ - return configured `CodePush` instance.
70
-
71
- ##### Public Methods
72
-
73
- - __setDeploymentKey(String deploymentKey)__ - Sets the deployment key that the app should use when querying for updates. This is a dynamic alternative to setting the deployment key in Codepush constructor/builder and/or specifying a deployment key in JS when calling `checkForUpdate` or `sync`.
74
-
75
- ##### Static Methods
76
-
77
- - __getBundleUrl()__ - Returns the path to the most recent version of your app's JS bundle file, assuming that the resource name is `index.android.bundle`. If your app is using a different bundle name, then use the overloaded version of this method which allows specifying it. This method has the same resolution behavior as the Objective-C equivalent described above.
78
-
79
- - __getBundleUrl(String bundleName)__ - Returns the path to the most recent version of your app's JS bundle file, using the specified resource name (like `index.android.bundle`). This method has the same resolution behavior as the Objective-C equivalent described above.
80
-
81
- - __getPackageFolder()__ - Returns the path to the current update folder.
82
-
83
- - __overrideAppVersion(String appVersionOverride)__ - Sets the version of the application's binary interface, which would otherwise default to the Play Store version specified as the `versionName` in the `build.gradle`. This should be called a single time, before the CodePush instance is constructed.
package/docs/api-ios.md DELETED
@@ -1,31 +0,0 @@
1
- ### Objective-C API Reference (iOS)
2
-
3
- The Objective-C API is made available by importing the `CodePush.h` header into your `AppDelegate.m` file, and consists of a single public class named `CodePush`.
4
-
5
- #### CodePush
6
-
7
- Contains static methods for retreiving the `NSURL` that represents the most recent JavaScript bundle file, and can be passed to the `RCTRootView`'s `initWithBundleURL` method when bootstrapping your app in the `AppDelegate.m` file.
8
-
9
- The `CodePush` class' methods can be thought of as composite resolvers which always load the appropriate bundle, in order to accommodate the following scenarios:
10
-
11
- 1. When an end-user installs your app from the store (like `1.0.0`), they will get the JS bundle that is contained within the binary. This is the behavior you would get without using CodePush, but we make sure it doesn't break :)
12
-
13
- 2. As soon as you begin releasing CodePush updates, your end-users will get the JS bundle that represents the latest release for the configured deployment. This is the behavior that allows you to iterate beyond what you shipped to the store.
14
-
15
- 3. As soon as you release an update to the app store (like `1.1.0`), and your end-users update it, they will once again get the JS bundle that is contained within the binary. This behavior ensures that CodePush updates that targetted a previous binary version aren't used (since we don't know if they would work), and your end-users always have a working version of your app.
16
-
17
- 4. Repeat #2 and #3 as the CodePush releases and app store releases continue on into infinity (and beyond?)
18
-
19
- Because of this behavior, you can safely deploy updates to both the app store(s) and CodePush as necesary, and rest assured that your end-users will always get the most recent version.
20
-
21
- ##### Methods
22
-
23
- - __(NSURL \*)bundleURL__ - Returns the most recent JS bundle `NSURL` as described above. This method assumes that the name of the JS bundle contained within your app binary is `main.jsbundle`.
24
-
25
- - __(NSURL \*)bundleURLForResource:(NSString \*)resourceName__ - Equivalent to the `bundleURL` method, but also allows customizing the name of the JS bundle that is looked for within the app binary. This is useful if you aren't naming this file `main` (which is the default convention). This method assumes that the JS bundle's extension is `*.jsbundle`.
26
-
27
- - __(NSURL \*)bundleURLForResource:(NSString \*)resourceName withExtension:(NSString \*)resourceExtension__: Equivalent to the `bundleURLForResource:` method, but also allows customizing the extension used by the JS bundle that is looked for within the app binary. This is useful if you aren't naming this file `*.jsbundle` (which is the default convention).
28
-
29
- - __(void)overrideAppVersion:(NSString \*)appVersionOverride__ - Sets the version of the application's binary interface, which would otherwise default to the App Store version specified as the `CFBundleShortVersionString` in the `Info.plist`. This should be called a single time, before the bundle URL is loaded.
30
-
31
- - __(void)setDeploymentKey:(NSString \*)deploymentKey__ - Sets the deployment key that the app should use when querying for updates. This is a dynamic alternative to setting the deployment key in your `Info.plist` and/or specifying a deployment key in JS when calling `checkForUpdate` or `sync`.