Skip to content

Commit 60b6d29

Browse files
committed
Merge branch '@atlj/unify-view-templates' into @atlj/diff-commentor
2 parents 73a3a35 + 8656a9b commit 60b6d29

File tree

22 files changed

+557
-484
lines changed

22 files changed

+557
-484
lines changed

docs/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [0.0.3](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.0.3) (2023-10-19)
7+
8+
**Note:** Version bump only for package docs
9+
610
## 0.0.2 (2023-10-04)
711

812
**Note:** Version bump only for package docs

docs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "docs",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"private": true,
55
"description": "Documentation for react-native-builder-bob",
66
"scripts": {

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
"@lerna-lite/run": "^1.13.0",
2828
"commitlint": "^17.0.2",
2929
"concurrently": "^7.2.2",
30-
"eslint": "^8.18.0",
31-
"eslint-config-satya164": "^3.1.11",
32-
"prettier": "^2.7.1",
33-
"typescript": "^5.0.2"
30+
"eslint": "^8.52.0",
31+
"eslint-config-satya164": "^3.2.0",
32+
"prettier": "^3.0.3",
33+
"typescript": "^5.2.2"
3434
},
3535
"commitlint": {
3636
"extends": [

packages/create-react-native-library/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [0.34.2](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.34.2) (2023-10-19)
7+
8+
**Note:** Version bump only for package create-react-native-library
9+
610
## [0.34.1](https://github.com/callstack/react-native-builder-bob/compare/[email protected]@0.34.1) (2023-10-04)
711

812
### Bug Fixes

packages/create-react-native-library/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-react-native-library",
3-
"version": "0.34.1",
3+
"version": "0.34.2",
44
"description": "CLI to scaffold React Native libraries",
55
"keywords": [
66
"react-native",

packages/create-react-native-library/src/index.ts

+18-29
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ const SWIFT_FILES = {
7676
view_legacy: path.resolve(__dirname, '../templates/swift-view-legacy'),
7777
} as const;
7878

79-
const CPP_VIEW_FILES = {
80-
// view_legacy does NOT need component registration
81-
view_mixed: path.resolve(__dirname, '../templates/cpp-view-mixed'),
82-
view_new: path.resolve(__dirname, '../templates/cpp-view-new'),
83-
} as const;
84-
8579
type ArgName =
8680
| 'slug'
8781
| 'description'
@@ -131,8 +125,8 @@ const LANGUAGE_CHOICES: {
131125
types: ProjectType[];
132126
}[] = [
133127
{
134-
title: 'Java & Objective-C',
135-
value: 'java-objc',
128+
title: 'Kotlin & Objective-C',
129+
value: 'kotlin-objc',
136130
types: [
137131
'module-legacy',
138132
'module-new',
@@ -143,8 +137,8 @@ const LANGUAGE_CHOICES: {
143137
],
144138
},
145139
{
146-
title: 'Kotlin & Objective-C',
147-
value: 'kotlin-objc',
140+
title: 'Java & Objective-C',
141+
value: 'java-objc',
148142
types: [
149143
'module-legacy',
150144
'module-new',
@@ -155,13 +149,13 @@ const LANGUAGE_CHOICES: {
155149
],
156150
},
157151
{
158-
title: 'Java & Swift',
159-
value: 'java-swift',
152+
title: 'Kotlin & Swift',
153+
value: 'kotlin-swift',
160154
types: ['module-legacy', 'view-legacy'],
161155
},
162156
{
163-
title: 'Kotlin & Swift',
164-
value: 'kotlin-swift',
157+
title: 'Java & Swift',
158+
value: 'java-swift',
165159
types: ['module-legacy', 'view-legacy'],
166160
},
167161
{
@@ -269,13 +263,15 @@ const args: Record<ArgName, yargs.Options> = {
269263
},
270264
};
271265

266+
// FIXME: fix the type
267+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
272268
async function create(argv: yargs.Arguments<any>) {
273269
let local = false;
274270

275271
if (typeof argv.local === 'boolean') {
276272
local = argv.local;
277273
} else {
278-
let hasPackageJson = await fs.pathExists(
274+
const hasPackageJson = await fs.pathExists(
279275
path.join(process.cwd(), 'package.json')
280276
);
281277

@@ -403,7 +399,7 @@ async function create(argv: yargs.Arguments<any>) {
403399
type: local ? null : 'text',
404400
name: 'authorUrl',
405401
message: 'What is the URL for the package author?',
406-
// @ts-ignore: this is supported, but types are wrong
402+
// @ts-expect-error this is supported, but types are wrong
407403
initial: async (previous: string) => {
408404
try {
409405
const username = await githubUsername(previous);
@@ -421,7 +417,6 @@ async function create(argv: yargs.Arguments<any>) {
421417
type: local ? null : 'text',
422418
name: 'repoUrl',
423419
message: 'What is the URL for the repository?',
424-
// @ts-ignore: this is supported, but types are wrong
425420
initial: (_: string, answers: Answers) => {
426421
if (/^https?:\/\/github.com\/[^/]+/.test(answers.authorUrl)) {
427422
return `${answers.authorUrl}/${answers.slug
@@ -556,9 +551,9 @@ async function create(argv: yargs.Arguments<any>) {
556551

557552
try {
558553
version = await Promise.race([
559-
new Promise<string>((resolve) =>
560-
setTimeout(() => resolve(FALLBACK_BOB_VERSION), 1000)
561-
),
554+
new Promise<string>((resolve) => {
555+
setTimeout(() => resolve(FALLBACK_BOB_VERSION), 1000);
556+
}),
562557
spawn('npm', ['view', 'react-native-builder-bob', 'dist-tags.latest']),
563558
]);
564559
} catch (e) {
@@ -747,12 +742,6 @@ async function create(argv: yargs.Arguments<any>) {
747742
await copyDir(CPP_FILES, folder);
748743
await fs.remove(path.join(folder, 'ios', `${options.project.name}.m`));
749744
}
750-
751-
if (moduleType === 'view') {
752-
if (arch === 'new' || arch === 'mixed') {
753-
await copyDir(CPP_VIEW_FILES[`${moduleType}_${arch}`], folder);
754-
}
755-
}
756745
}
757746

758747
if (example !== 'none') {
@@ -882,8 +871,8 @@ async function create(argv: yargs.Arguments<any>) {
882871
.map(
883872
([script, { name, color }]) => `
884873
${kleur[color](`Run the example app on ${kleur.bold(name)}`)}${kleur.gray(
885-
':'
886-
)}
874+
':'
875+
)}
887876
888877
${kleur.gray('$')} yarn example ${script}`
889878
)
@@ -896,7 +885,7 @@ async function create(argv: yargs.Arguments<any>) {
896885
);
897886
}
898887
}
899-
// eslint-disable-next-line babel/no-unused-expressions
888+
900889
yargs
901890
.command('$0 [name]', 'create a react native library', args, create)
902891
.demandCommand()

packages/create-react-native-library/templates/cpp-view-mixed/android/Android.mk

-45
This file was deleted.

packages/create-react-native-library/templates/cpp-view-mixed/android/registration.cpp

-18
This file was deleted.

packages/create-react-native-library/templates/cpp-view-new/android/Android.mk

-45
This file was deleted.

packages/create-react-native-library/templates/cpp-view-new/android/registration.cpp

-18
This file was deleted.

packages/create-react-native-library/templates/java-view-mixed/android/src/newarch/{%- project.name %}ViewManagerSpec.java

-7
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,8 @@
88
import com.facebook.react.uimanager.ViewManagerDelegate;
99
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerDelegate;
1010
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerInterface;
11-
import com.facebook.soloader.SoLoader;
1211

1312
public abstract class <%- project.name -%>ViewManagerSpec<T extends View> extends SimpleViewManager<T> implements <%- project.name -%>ViewManagerInterface<T> {
14-
static {
15-
if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) {
16-
SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION);
17-
}
18-
}
19-
2013
private final ViewManagerDelegate<T> mDelegate;
2114

2215
public <%- project.name -%>ViewManagerSpec() {

packages/create-react-native-library/templates/java-view-new/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}ViewManager.java

-7
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,12 @@
1111
import com.facebook.react.uimanager.annotations.ReactProp;
1212
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerDelegate;
1313
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerInterface;
14-
import com.facebook.soloader.SoLoader;
1514

1615
@ReactModule(name = <%- project.name -%>ViewManager.NAME)
1716
public class <%- project.name -%>ViewManager extends SimpleViewManager<<%- project.name -%>View> implements <%- project.name -%>ViewManagerInterface<<%- project.name -%>View> {
1817

1918
public static final String NAME = "<%- project.name -%>View";
2019

21-
static {
22-
if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) {
23-
SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION);
24-
}
25-
}
26-
2720
private final ViewManagerDelegate<<%- project.name -%>View> mDelegate;
2821

2922
public <%- project.name -%>ViewManager() {

packages/create-react-native-library/templates/kotlin-view-mixed/android/src/newarch/{%- project.name %}ViewManagerSpec.kt

-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import com.facebook.react.uimanager.SimpleViewManager
77
import com.facebook.react.uimanager.ViewManagerDelegate
88
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerDelegate
99
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerInterface
10-
import com.facebook.soloader.SoLoader
1110

1211
abstract class <%- project.name -%>ViewManagerSpec<T : View> : SimpleViewManager<T>(), <%- project.name -%>ViewManagerInterface<T> {
1312
private val mDelegate: ViewManagerDelegate<T>
@@ -19,12 +18,4 @@ abstract class <%- project.name -%>ViewManagerSpec<T : View> : SimpleViewManager
1918
override fun getDelegate(): ViewManagerDelegate<T>? {
2019
return mDelegate
2120
}
22-
23-
companion object {
24-
init {
25-
if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) {
26-
SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION)
27-
}
28-
}
29-
}
3021
}

packages/create-react-native-library/templates/kotlin-view-new/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}ViewManager.kt

-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import com.facebook.react.uimanager.ViewManagerDelegate
88
import com.facebook.react.uimanager.annotations.ReactProp
99
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerInterface
1010
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerDelegate
11-
import com.facebook.soloader.SoLoader
1211

1312
@ReactModule(name = <%- project.name -%>ViewManager.NAME)
1413
class <%- project.name -%>ViewManager : SimpleViewManager<<%- project.name -%>View>(),
@@ -38,11 +37,5 @@ class <%- project.name -%>ViewManager : SimpleViewManager<<%- project.name -%>Vi
3837

3938
companion object {
4039
const val NAME = "<%- project.name -%>View"
41-
42-
init {
43-
if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) {
44-
SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION)
45-
}
46-
}
4740
}
4841
}

0 commit comments

Comments
 (0)