Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
If you want to create your own React Native module, scaffolding the project can be a daunting task. `create-react-native-library` can scaffold a new project for you with the following things:

- Simple example modules for Android and iOS which you can build upon
- Simple example modules for Windows using both C++/WinRT and C#
- [Kotlin](https://kotlinlang.org/) configured for building the module on Android
- C++ support for native modules on Android and iOS
- [Expo](https://expo.io/) support for libraries without native code and web support
- Example React Native app to manually test your modules
- Example React Native app (including Windows) to manually test your modules
- [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/), [Husky](https://github.com/typicode/husky) and [Release It](https://github.com/release-it/release-it) pre-configured
- `react-native-builder-bob` pre-configured to compile your files
- [CircleCI](https://circleci.com/) pre-configured to run tests on the CI
Expand Down
51 changes: 48 additions & 3 deletions packages/create-react-native-library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,32 @@ const SWIFT_FILES = (moduleType: ModuleType) => {
}
};

// Windows Csharp
const WINDOWS_CSHARP_FILES = (moduleType: ModuleType) => {
switch (moduleType) {
case 'module':
return path.resolve(__dirname, '../templates/windows-uwp-csharp-library');
case 'view':
return path.resolve(
__dirname,
'../templates/windows-uwp-csharp-view-library'
);
}
};

// Windows Cpp
const WINDOWS_CPP_FILES = (moduleType: ModuleType) => {
switch (moduleType) {
case 'module':
return path.resolve(__dirname, '../templates/windows-uwp-cpp-library');
case 'view':
return path.resolve(
__dirname,
'../templates/windows-uwp-cpp-view-library'
);
}
};

type ArgName =
| 'slug'
| 'description'
Expand All @@ -89,6 +115,8 @@ type Answers = {
| 'kotlin-objc'
| 'kotlin-swift'
| 'cpp'
| 'windows-uwp-cpp'
| 'windows-uwp-csharp'
| 'js';
type?: 'module' | 'view';
example?: 'expo' | 'native';
Expand Down Expand Up @@ -256,13 +284,20 @@ async function create(argv: yargs.Arguments<any>) {
{ title: 'Kotlin & Swift', value: 'kotlin-swift' },
{ title: 'C++ for both iOS & Android', value: 'cpp' },
{ title: 'JavaScript only', value: 'js' },
{ title: 'Windows UWP with C++', value: 'windows-uwp-cpp' },
{ title: 'Windows UWP with C#', value: 'windows-uwp-csharp' },
],
},
'type': {
type: (prev: string) =>
['java-objc', 'java-swift', 'kotlin-objc', 'kotlin-swift'].includes(
prev
)
[
'java-objc',
'java-swift',
'kotlin-objc',
'kotlin-swift',
'windows-uwp-cpp',
'windows-uwp-csharp',
].includes(prev)
? 'select'
: null,
name: 'type',
Expand Down Expand Up @@ -356,6 +391,8 @@ async function create(argv: yargs.Arguments<any>) {
cpp: languages === 'cpp',
kotlin: languages === 'kotlin-objc' || languages === 'kotlin-swift',
swift: languages === 'java-swift' || languages === 'kotlin-swift',
windows:
languages === 'windows-uwp-cpp' || languages === 'windows-uwp-csharp',
module: languages !== 'js',
moduleType: type,
},
Expand Down Expand Up @@ -421,6 +458,14 @@ async function create(argv: yargs.Arguments<any>) {
await copyDir(CPP_FILES, folder);
}

if (options.project.windows) {
const WINDOWS_FILES =
languages === 'windows-uwp-csharp'
? WINDOWS_CSHARP_FILES
: WINDOWS_CPP_FILES;
await copyDir(WINDOWS_FILES(type), folder);
}

if (options.project.swift) {
await copyDir(SWIFT_FILES(type), folder);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"android",
"ios",
"cpp",
"windows",
"<%- project.podspec %>.podspec",
"!lib/typescript/example",
"!android/build",
Expand Down Expand Up @@ -63,6 +64,7 @@
"prettier": "^2.0.5",
"react": "16.13.1",
"react-native": "0.63.4",
"react-native-windows": "0.63.4",
"react-native-builder-bob": "^<%- bob.version %>",
"release-it": "^14.2.2",
"typescript": "^4.1.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"windows": "react-native run-windows",
"start": "react-native start"
},
"dependencies": {
"react": "16.13.1",
"react-native": "0.63.4"
"react-native": "0.63.4",
"react-native-windows": "0.63.4"
},
"devDependencies": {
"@babel/core": "^7.12.10",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
*AppPackages*
*BundleArtifacts*

#OS junk files
[Tt]humbs.db
*.DS_Store

#Visual Studio files
*.[Oo]bj
*.user
*.aps
*.pch
*.vspscc
*.vssscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.[Cc]ache
*.ilk
*.log
*.lib
*.sbr
*.sdf
*.opensdf
*.opendb
*.unsuccessfulbuild
ipch/
[Oo]bj/
[Bb]in
[Dd]ebug*/
[Rr]elease*/
Ankh.NoLoad

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb

#MonoDevelop
*.pidb
*.userprefs

#Tooling
_ReSharper*/
*.resharper
[Tt]est[Rr]esult*
*.sass-cache

#Project files
[Bb]uild/

#Subversion files
.svn

# Office Temp Files
~$*

# vim Temp Files
*~

#NuGet
packages/
*.nupkg

#ncrunch
*ncrunch*
*crunch*.local.xml

# visual studio database projects
*.dbmdl

#Test files
*.testsettings

#Other files
*.DotSettings
.vs/
*project.lock.json

#Files generated by the VS build
**/Generated Files/**

Loading