Skip to content

Commit 4dbee9d

Browse files
committed
refactor: refactor integration
1 parent 81e1974 commit 4dbee9d

30 files changed

+275
-667
lines changed

.github/actions/setup/action.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 0 additions & 151 deletions
This file was deleted.

README.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ The primary objective of this library is to significantly decrease the size of c
44

55
## Installation
66

7-
```sh
8-
npm install react-native-code-push-diff
9-
```
10-
117
```sh
128
yarn add react-native-code-push-diff
139
```
@@ -25,40 +21,39 @@ import { name as appName } from './app.json'
2521
AppRegistry.registerComponent(appName, () => App)
2622
```
2723

28-
2. Run the `code-push-diff release-react -a {YOUR_APP_NAME} -base {BRANCH_OR_COMMIT}` if you need to create and release a codepush bundle.
24+
2. Run the `code-push-diff release-react --app {YOUR_APP_NAME} --base {BRANCH_OR_COMMIT}` if you need to create and release a codepush bundle.
2925

3026
## How does it work?
3127
The `bundle` or `release-react` scripts initiate their process by generating bundles corresponding to the current active `git commit` and a specified `base` commit, which is provided as an argument. This step is crucial for identifying the exact changes in assets that have occurred between these two states. Following this, the scripts compute the differences in assets across the generated bundles to pinpoint which files have been modified or added.
3228

33-
To streamline the integration of these changes into the final bundle, the process involves creating a bundle_config.json file. This file acts as a manifest, listing the paths of all files that have undergone changes. With this configuration in hand, the scripts proceed to rebuild the bundle for a third and final time, this time incorporating only the assets that have been identified as changed, ensuring an optimized bundle size.
34-
35-
The `react-native-code-push-diff/setup` plays a key role by setting up a custom source transformer based on [the specified transformer mechanism](https://github.com/facebook/react-native/blob/v0.71.7/Libraries/Image/resolveAssetSource.js#L77) in React Native. This transformer is designed to consult the `bundle_config.json` file at runtime. If it encounters a file whose path is listed in `bundle_config.json`, it recognises that file as modified. It makes sure that this file is extracted from the codepush bundle and not the main bundle, otherwise the file will be extracted from the `main` bundle.
29+
The `react-native-code-push-diff/setup` plays a key role by setting up a custom source transformer based on [the specified transformer mechanism](https://github.com/facebook/react-native/blob/v0.71.7/Libraries/Image/resolveAssetSource.js#L77) in React Native. It makes sure that this file is extracted from the codepush bundle and not the main bundle, otherwise the file will be extracted from the `main` bundle.
3630

3731
## Script Usage
3832

3933
### bundle
4034

4135
The `bundle` command is designed to generate a codepush bundle incorporating only the assets that have changed:
4236
```sh
43-
code-push-diff bundle {appOrOs} -base {branchOrCommit}
37+
yarn code-push-diff bundle {appOrOs} --base {branchOrCommit}
4438
```
4539

46-
- `appOrOs` -This parameter specifies the context in which the bundle is to be built. You can either input the name of an application as defined within your appcenter configuration or directly specify the platform for which you are building the bundle (`ios` or `android`).
40+
- `appOrOs` - this parameter specifies the context in which the bundle is to be built. You can either input the name of an application as defined within your appcenter configuration or directly specify the platform for which you are building the bundle (`ios` or `android`).
41+
42+
- `branchOrCommit` - this argument determines the reference point for calculating asset differences. It should be the identifier of the branch or commit that served as the basis for your most recent application build. By specifying this, the script can accurately assess which assets have changed and need to be included in the codepush bundle, ensuring that your updates are both efficient and relevant.
4743

48-
- `branchOrCommit` - This argument determines the reference point for calculating asset differences. It should be the identifier of the branch or commit that served as the basis for your most recent application build. By specifying this, the script can accurately assess which assets have changed and need to be included in the codepush bundle, ensuring that your updates are both efficient and relevant.
4944

5045
For example:
51-
`code-push-diff i.kuchaev/AwesomeProject release-2.1`
46+
`code-push-diff bundle i.kuchaev/AwesomeProject --base release-2.1`
5247

53-
Also the script apply all args for the [release-react](https://github.com/microsoft/code-push/tree/v3.0.1/cli#releasing-updates-react-native) command, like `plistFile`, `outputDir` etc.
48+
Also the script apply all args for the [release-react](https://github.com/microsoft/code-push/tree/v3.0.1/cli#releasing-updates-react-native) command, like `plist-file`, `output-dir` etc.
5449

5550
For example:
56-
`code-push-diff i.kuchaev/AwesomeProject release-2.1 -plistFile ios/project/Info.plist`
51+
`code-push-diff bundle i.kuchaev/AwesomeProject --base release-2.1 --plist-file ios/project/Info.plist`
5752

5853
### release-react
5954
The `release-react` command leverages the code-push-diff bundle functionality to construct a bundle and then releases it to App Center:
6055
```sh
61-
code-push-diff release-react -a {appName} -base {branchOrCommit}
56+
code-push-diff release-react --app {appName} --base {branchOrCommit}
6257
```
6358

6459
- `app` - This should be the exact name of your application as registered in App Center. It enables the script to correctly identify and target the application for the update release.
@@ -68,7 +63,7 @@ code-push-diff release-react -a {appName} -base {branchOrCommit}
6863
This script also supports all the parameters available for the [release-react command](https://github.com/microsoft/code-push/tree/v3.0.1/cli#releasing-updates-react-native) used by CodePush, , like `plistFile`, `outputDir` etc.
6964

7065
```sh
71-
code-push-diff i.kuchaev/AwesomeProject release-2.1 -plistFile ios/project/Info.plist -rallout 50
66+
code-push-diff release-react --app i.kuchaev/AwesomeProject --base release-2.1 --plist-file ios/project/Info.plist --rallout 50
7267
```
7368

7469
## Contributing

bundle_config.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/babel.config.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
const path = require('path')
2-
const pak = require('../package.json')
3-
41
module.exports = {
52
presets: ['module:@react-native/babel-preset'],
6-
plugins: [
7-
[
8-
'module-resolver',
9-
{
10-
extensions: ['.tsx', '.ts', '.js', '.json'],
11-
alias: {
12-
[pak.name]: path.join(__dirname, '..', pak.source),
13-
},
14-
},
15-
],
16-
],
173
}

example/metro.config.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config')
2-
const path = require('path')
3-
const escape = require('escape-string-regexp')
4-
const exclusionList = require('metro-config/src/defaults/exclusionList')
5-
const pak = require('../package.json')
6-
7-
const root = path.resolve(__dirname, '..')
8-
const modules = Object.keys({ ...pak.peerDependencies })
92

103
/**
114
* Metro configuration
@@ -14,19 +7,6 @@ const modules = Object.keys({ ...pak.peerDependencies })
147
* @type {import('metro-config').MetroConfig}
158
*/
169
const config = {
17-
watchFolders: [root],
18-
19-
// We need to make sure that only one version is loaded for peerDependencies
20-
// So we block them at the root, and alias them to the versions in example's node_modules
21-
resolver: {
22-
blacklistRE: exclusionList(modules.map((m) => new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`))),
23-
24-
extraNodeModules: modules.reduce((acc, name) => {
25-
acc[name] = path.join(__dirname, 'node_modules', name)
26-
return acc
27-
}, {}),
28-
},
29-
3010
transformer: {
3111
getTransformOptions: async () => ({
3212
transform: {

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": {
1414
"react": "18.2.0",
1515
"react-native": "0.73.4",
16-
"react-native-code-push-diff": "../react-native-code-push-diff-0.0.0-local.40.tgz"
16+
"react-native-code-push-diff": "../react-native-code-push-diff-1.0.0-local-7.tgz"
1717
},
1818
"devDependencies": {
1919
"@babel/core": "^7.20.0",

example/yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3540,7 +3540,7 @@ __metadata:
35403540
pod-install: ^0.1.0
35413541
react: 18.2.0
35423542
react-native: 0.73.4
3543-
react-native-code-push-diff: ../react-native-code-push-diff-0.0.0-local.40.tgz
3543+
react-native-code-push-diff: ../react-native-code-push-diff-1.0.0-local-7.tgz
35443544
languageName: unknown
35453545
linkType: soft
35463546

@@ -7434,9 +7434,9 @@ __metadata:
74347434
languageName: node
74357435
linkType: hard
74367436

7437-
"react-native-code-push-diff@file:../react-native-code-push-diff-0.0.0-local.40.tgz::locator=codepushdiffexample%40workspace%3A.":
7438-
version: 0.0.0-local.40
7439-
resolution: "react-native-code-push-diff@file:../react-native-code-push-diff-0.0.0-local.40.tgz::locator=codepushdiffexample%40workspace%3A."
7437+
"react-native-code-push-diff@file:../react-native-code-push-diff-1.0.0-local-7.tgz::locator=codepushdiffexample%40workspace%3A.":
7438+
version: 1.0.0-local-7
7439+
resolution: "react-native-code-push-diff@file:../react-native-code-push-diff-1.0.0-local-7.tgz::locator=codepushdiffexample%40workspace%3A."
74407440
dependencies:
74417441
simple-git: ^3.22.0
74427442
yargs: ^17.7.2
@@ -7446,7 +7446,7 @@ __metadata:
74467446
react-native: "*"
74477447
bin:
74487448
code-push-diff: ./commonjs/cli/index.js
7449-
checksum: f36e5238d0273f72c72e2c38ac2383ed3b629a3a19d21b45b11be79f1426b74d64b2420de949294f5a1624fe72df9d04d2e85a9f8e7922616892ec2ddc60aa10
7449+
checksum: 7c7d97d98e255bb3d04e7bf5352dc7de20207f6bc3af2733a7ce6f93ce5aaa05ab868a80b78cadaf92dec78db95784543a2f219f5211217c935ffaea587106ed
74507450
languageName: node
74517451
linkType: hard
74527452

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "react-native-code-push-diff",
3-
"version": "0.0.0-local.40",
3+
"version": "1.0.0",
44
"description": "This library builds upon the foundational strengths of the react-native-code-push library, adding advanced functionality to precisely identify and manage differences between code-push builds.",
5-
"main": "commonjs/setup/index.js",
6-
"module": "module/setup/index.js",
7-
"types": "typescript/src/setup/index.d.ts",
8-
"react-native": "src/setup/index.ts",
5+
"main": "commonjs/react-native/index.js",
6+
"module": "module/react-native/index.js",
7+
"types": "typescript/src/react-native/index.d.ts",
8+
"react-native": "src/react-native/index.ts",
99
"source": "src",
1010
"files": [
1111
"bundle",

setup/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "react-native-code-push-diff/setup",
33
"private": true,
4-
"main": "../commonjs/setup/index.js",
5-
"module": "../module/setup/index.js",
6-
"types": "../typescript/src/setup/index.d.ts",
7-
"react-native": "../src/setup/index.ts"
4+
"main": "../commonjs/react-native/setup.js",
5+
"module": "../module/react-native/setup.js",
6+
"types": "../typescript/src/react-native/setup.d.ts",
7+
"react-native": "../src/react-native/setup.ts"
88
}

0 commit comments

Comments
 (0)