Skip to content

Commit 512d702

Browse files
committed
feat: add setup and bundle packages
1 parent 5cf19f2 commit 512d702

25 files changed

Lines changed: 2626 additions & 262 deletions

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
node_modules/
22
lib/
3-
.codepush

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,10 @@ android/keystores/debug.keystore
7676

7777
# generated by bob
7878
lib/
79+
typescript/
80+
module/
81+
commonjs/
82+
83+
# generated by npm pack
84+
*.tgz
85+
package/

bundle/package.json

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

bundle_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

example/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'react-native-code-push-diff/setup'
12
import { AppRegistry } from 'react-native'
23
import App from './src/App'
34
import { name as appName } from './app.json'

example/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
},
1212
"dependencies": {
1313
"react": "18.2.0",
14-
"react-native": "0.73.4"
14+
"react-native": "0.73.4",
15+
"react-native-code-push-diff": "../react-native-code-push-diff-0.0.0-local.21.tgz"
1516
},
1617
"devDependencies": {
1718
"@babel/core": "^7.20.0",
@@ -20,6 +21,8 @@
2021
"@react-native/babel-preset": "0.73.21",
2122
"@react-native/metro-config": "0.73.5",
2223
"@react-native/typescript-config": "0.73.1",
24+
"appcenter": "^5.0.1",
25+
"appcenter-cli": "^2.14.0",
2326
"babel-plugin-module-resolver": "^5.0.0",
2427
"pod-install": "^0.1.0"
2528
},

example/scripts/codepush.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const { bundle } = require('react-native-code-push-diff/bundle')
2+
const { execSync } = require('child_process')
3+
4+
async function codepush() {
5+
const output = await bundle({
6+
entry: 'index.js',
7+
os: 'android',
8+
base: 'main',
9+
reinstallNodeModulesCommand: 'yarn install',
10+
})
11+
12+
console.log(output)
13+
14+
//execSync(`yarn appcenter codepush release -a ${app} -c ${content} -t ${version} -d Staging`)
15+
}
16+
17+
codepush()

ios/CodePushDiff.mm

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
@interface RCT_EXTERN_MODULE(CodePushDiff, NSObject)
44

5-
RCT_EXTERN_METHOD(multiply:(float)a withB:(float)b
6-
withResolver:(RCTPromiseResolveBlock)resolve
7-
withRejecter:(RCTPromiseRejectBlock)reject)
8-
95
+ (BOOL)requiresMainQueueSetup
106
{
11-
return NO;
7+
return YES;
128
}
139

1410
@end

ios/CodePushDiff.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
import React
2+
13
@objc(CodePushDiff)
24
class CodePushDiff: NSObject {
5+
@objc var bundleManager: RCTBundleManager!
6+
7+
@objc
8+
static func requiresMainQueueSetup() -> Bool {
9+
return true
10+
}
11+
12+
@objc
13+
func constantsToExport() -> [String: Any]! {
14+
let bundlePath = Bundle.main.bundlePath
315

4-
@objc(multiply:withB:withResolver:withRejecter:)
5-
func multiply(a: Float, b: Float, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
6-
resolve(a*b)
16+
return [
17+
"mainBundlePath": bundlePath,
18+
]
719
}
820
}

package.json

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
{
22
"name": "react-native-code-push-diff",
3-
"version": "0.1.0",
3+
"version": "0.0.0-local.21",
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": "lib/commonjs/index",
6-
"module": "lib/module/index",
7-
"types": "lib/typescript/src/index.d.ts",
8-
"react-native": "src/index",
9-
"source": "src/index",
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",
9+
"source": "src",
1010
"files": [
11+
"bundle",
12+
"setup",
13+
"bundle_config.json",
1114
"src",
12-
"lib",
15+
"module",
16+
"commonjs",
17+
"typescript",
1318
"android",
1419
"ios",
1520
"cpp",
@@ -30,7 +35,7 @@
3035
"test": "jest",
3136
"typecheck": "tsc --noEmit",
3237
"lint": "eslint \"**/*.{js,ts,tsx}\"",
33-
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
38+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib typescript module commonjs package",
3439
"prepare": "bob build",
3540
"release": "release-it"
3641
},
@@ -60,6 +65,7 @@
6065
"@types/jest": "^28.1.2",
6166
"@types/react": "~17.0.21",
6267
"@types/react-native": "0.70.0",
68+
"appcenter-cli": "^2.14.0",
6369
"commitlint": "^17.0.2",
6470
"del-cli": "^5.0.0",
6571
"eslint": "^8.4.1",
@@ -79,6 +85,7 @@
7985
"@types/react": "17.0.21"
8086
},
8187
"peerDependencies": {
88+
"appcenter-cli": "*",
8289
"react": "*",
8390
"react-native": "*"
8491
},
@@ -130,7 +137,7 @@
130137
},
131138
"react-native-builder-bob": {
132139
"source": "src",
133-
"output": "lib",
140+
"output": "./",
134141
"targets": [
135142
"commonjs",
136143
"module",
@@ -141,5 +148,8 @@
141148
}
142149
]
143150
]
151+
},
152+
"dependencies": {
153+
"simple-git": "^3.22.0"
144154
}
145155
}

0 commit comments

Comments
 (0)