Skip to content

Commit ea48d5a

Browse files
committed
feat: add platform-specific IDE open scripts to generated package.json
1 parent b70f280 commit ea48d5a

File tree

2 files changed

+67
-38
lines changed
  • packages

2 files changed

+67
-38
lines changed

packages/create-react-native-library/templates/common/$package.json

Lines changed: 67 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
"cpp",
2121
<% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
2222
"nitrogen",
23-
"nitro.json",
24-
<% } -%>
23+
"nitro.json",
24+
<%
25+
} -%>
2526
"*.podspec",
2627
"react-native.config.js",
2728
"!ios/build",
@@ -38,17 +39,36 @@
3839
"scripts": {
3940
<% if (example !== 'none') { -%>
4041
"example": "yarn workspace <%- project.slug -%>-example",
41-
<% } -%>
42+
<%
43+
} -%>
4244
<% if (example !== 'expo') { -%>
4345
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
44-
<% } else { -%>
46+
<%
47+
} else { -%>
4548
"clean": "del-cli lib",
46-
<% } -%>
49+
<%
50+
} -%>
4751
"prepare": "bob build",
4852
<% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
4953
"nitrogen": "nitrogen",
50-
<% } -%>
51-
"typecheck": "tsc"
54+
<%
55+
} -%>
56+
"typecheck": "tsc"<% if (example !== 'none' && example !== 'expo') { %>,
57+
<%# Platform-specific IDE commands %>
58+
<% const platform = process.platform; %>
59+
<% if (platform === 'darwin') { %>
60+
"open:android": "open -a \\\"Android Studio\\\" example/android",
61+
"open:ios": "xed example/ios"
62+
<%
63+
} else if (platform === 'linux') { %>
64+
"open:android": "studio example/android"
65+
<%
66+
} else if (platform === 'win32') { %>
67+
"open:android": "start /d example\\\\android ."
68+
<%
69+
} %>
70+
<%
71+
} %>
5272
},
5373
"keywords": [
5474
"react-native",
@@ -71,49 +91,56 @@
7191
"devDependencies": {
7292
<% if (example === 'vanilla' && (project.moduleConfig === 'turbo-modules' || project.viewConfig === 'fabric-view')) { -%>
7393
"@react-native-community/cli": "20.0.1",
74-
<% } -%>
94+
<%
95+
} -%>
7596
"@react-native/babel-preset": "0.81.1",
7697
"@types/react": "^19.1.12",
7798
"del-cli": "^6.0.0",
7899
<% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
79100
"nitrogen": "^<%- versions.nitro %>",
80-
<% } -%>
101+
<%
102+
} -%>
81103
"react": "19.1.0",
82104
"react-native": "0.81.1",
83105
"react-native-builder-bob": "^<%- versions.bob %>",
84106
<% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
85107
"react-native-nitro-modules": "^<%- versions.nitro %>",
86-
<% } -%>
108+
<%
109+
} -%>
87110
"typescript": "^5.9.2"
88111
},
89112
"peerDependencies": {
90113
"react": "*",
91114
<% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%>
92115
"react-native": "*",
93-
"react-native-nitro-modules": "^<%- versions.nitro %>"
94-
<% } else { -%>
116+
"react-native-nitro-modules": "^<%- versions.nitro %>"
117+
<%
118+
} else { -%>
95119
"react-native": "*"
96-
<% } -%>
120+
<%
121+
} -%>
97122
},
98123
<% if (example !== 'none') { -%>
99124
"workspaces": [
100-
"example"
101-
],
102-
<% } -%>
125+
"example"
126+
],
127+
<%
128+
} -%>
103129
"packageManager": "yarn@4.11.0",
104130
"react-native-builder-bob": {
105131
"source": "src",
106132
"output": "lib",
107133
"targets": [
108134
<% if (project.moduleConfig === "nitro-modules" || project.viewConfig === "nitro-view") { -%>
109135
[
110-
"custom",
111-
{
112-
"script": "nitrogen",
113-
"clean": "nitrogen/"
114-
}
115-
],
116-
<% } -%>
136+
"custom",
137+
{
138+
"script": "nitrogen",
139+
"clean": "nitrogen/"
140+
}
141+
],
142+
<%
143+
} -%>
117144
[
118145
"module",
119146
{
@@ -128,21 +155,23 @@
128155
]
129156
]
130157
<% if (project.moduleConfig === 'turbo-modules' || project.viewConfig === 'fabric-view') { -%>
131-
},
132-
"codegenConfig": {
133-
"name": "<%- project.name -%><%- project.viewConfig !== null ? 'View': '' -%>Spec",
134-
"type": "<%- project.viewConfig !== null ? 'all': 'modules' -%>",
135-
"jsSrcsDir": "src",
136-
"android": {
137-
"javaPackageName": "com.<%- project.package %>"
138-
<% if (project.viewConfig === 'fabric-view') { -%>
139158
},
140-
"ios": {
141-
"componentProvider": {
142-
"<%- project.name -%>View": "<%- project.name -%>View"
159+
"codegenConfig": {
160+
"name": "<%- project.name -%><%- project.viewConfig !== null ? 'View': '' -%>Spec",
161+
"type": "<%- project.viewConfig !== null ? 'all': 'modules' -%>",
162+
"jsSrcsDir": "src",
163+
"android": {
164+
"javaPackageName": "com.<%- project.package %>"
165+
<% if (project.viewConfig === 'fabric-view') { -%>
166+
},
167+
"ios": {
168+
"componentProvider": {
169+
"<%- project.name -%>View": "<%- project.name -%>View"
170+
}
171+
<%
172+
} -%>
143173
}
144-
<% } -%>
145-
}
146-
<% } -%>
174+
<%
175+
} -%>
147176
}
148-
}
177+
}

packages/react-native-builder-bob/bin/bob.cmd

100644100755
File mode changed.

0 commit comments

Comments
 (0)