Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/template tags #15

Merged
merged 9 commits into from
Dec 4, 2024
Merged
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
8 changes: 8 additions & 0 deletions .changeset/smart-buckets-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'create-nitro-module': patch
---

- fix: nitro tags
- chore: prefix lib name with react-native-
- fix: windows paths
- feat: adds react-native.config.js to locally autolink the module
2 changes: 1 addition & 1 deletion .github/workflows/lint-and-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
name: Lint and Format
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ A CLI tool that simplifies creating React Native modules powered by Nitro Module
- 📦 Automatic linking and installation
- 📚 TypeScript support out of the box

## Project Structure

```
.
├── bun.lockb
├── example
├── react-native-awesome-library
│   ├── AwesomeLibrary.podspec
│   ├── android
│   ├── ios
│   ├── src
│   ├── index.ts
│   └── specs
│   ├── nitrogen
│   ├── nitro.json
│   ├── babel.config.js
│   ├── package.json
│   └── tsconfig.json
└── package.json
```

## Installation & Usage

### Quick Start
Expand Down
27 changes: 24 additions & 3 deletions assets/nitro-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Nitro Modules Configuration",
"type": "object",
"required": ["cxxNamespace", "ios", "android", "autolinking", "ignorePaths"],
"required": ["cxxNamespace", "ios", "android", "ignorePaths"],
"properties": {
"cxxNamespace": {
"type": "array",
Expand Down Expand Up @@ -43,8 +43,29 @@
},
"autolinking": {
"type": "object",
"description": "Required: Autolinking configuration",
"minProperties": 1
"description": "Optional: Autolinking configuration",
"patternProperties": {
"^.*$": {
"type": "object",
"oneOf": [
{
"properties": {
"cpp": { "type": "string" }
},
"additionalProperties": false,
"required": ["cpp"]
},
{
"properties": {
"swift": { "type": "string" },
"kotlin": { "type": "string" }
},
"minProperties": 1,
"additionalProperties": false
}
]
}
}
},
"ignorePaths": {
"type": "array",
Expand Down
13 changes: 13 additions & 0 deletions assets/nitro-temp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://raw.githubusercontent.com/patrickkabwe/create-nitro-module/refs/heads/main/assets/nitro-schema.json",
"cxxNamespace": ["$$cxxNamespace$$"],
"ios": {
"iosModuleName": "$$iosModuleName$$"
},
"android": {
"androidNamespace": ["$$androidNamespace$$"],
"androidCxxLibName": "$$androidCxxLibName$$"
},
"autolinking": {},
"ignorePaths": ["node_modules"]
}
4 changes: 2 additions & 2 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"typecheck": "tsc --noEmit",
"clean": "rm -rf android/build node_modules/**/android/build lib android/.cxx node_modules/**/android/.cxx",
"release": "release-it",
"specs": "bun typecheck && nitro-codegen --logLevel=\"debug\"",
"postspecs": "bun run build"
"codegen": "bun typecheck && nitro-codegen --logLevel=\"debug\"",
"postcodegen": "bun run build"
},
"keywords": [
"react-native"
Expand Down
13 changes: 13 additions & 0 deletions assets/react-native.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const path = require('path')
const pkg = require('../$$packageName$$/package.json')

/**
* @type {import('@react-native-community/cli-types').Config}
*/
module.exports = {
dependencies: {
[pkg.name]: {
root: path.join(__dirname, '..', '$$packageName$$'),
},
},
}
7 changes: 6 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export default [
},
},
{
ignores: ['lib/', 'node_modules/', 'eslint.config.js'],
ignores: [
'lib/',
'node_modules/',
'eslint.config.js',
'assets/react-native.config.js',
],
},
]
43 changes: 37 additions & 6 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import kleur from 'kleur'

export const ANDROID_NAME_SPACE_TAG = '<<androidNamespace>>'
export const ANDROID_CXX_LIB_NAME_TAG = '<<androidCxxLibName>>'
export const CXX_NAME_SPACE_TAG = '<<cxxNamespace>>'
export const IOS_MODULE_NAME_TAG = '<<iosModuleName>>'
export const ANDROID_NAME_SPACE_TAG = '$$androidNamespace$$'
export const ANDROID_CXX_LIB_NAME_TAG = '$$androidCxxLibName$$'
export const CXX_NAME_SPACE_TAG = '$$cxxNamespace$$'
export const IOS_MODULE_NAME_TAG = '$$iosModuleName$$'
export const JS_PACKAGE_NAME_TAG = '$$packageName$$'

export const messages = {
creating: '🔄 Creating your Nitro Module...',
installing: '📦 Installing packages...',
success: '✨ Nitro Module created successfully!',
}

export const nosIcon = `
export const nosIcon = (moduleName: string, pm: string) => `
${kleur.cyan().bold(`
┌─────┐
│ ⏲️ |
Expand All @@ -23,4 +24,34 @@ ${kleur.cyan().bold(`
│ │
└─┬─┬─┘
│ │
└─┘`)}`
└─┘`)}

${kleur.red().bold('Next steps:')}

${kleur.yellow('1)')} Run your example app:
${kleur.green('cd example')}
${kleur.green(`${pm} ios`)} ${kleur.dim('# Run iOS example')}
${kleur.green(`${pm} android`)} ${kleur.dim('# Run Android example')}

${kleur.yellow('2)')} Begin development:
${kleur.green(`cd ${moduleName}`)}

${kleur.cyan('Define your module:')}
${kleur.white('src/specs/')} ${kleur.dim('# Define your module specifications')}
${kleur.green(`${pm} codegen`)} ${kleur.dim('# Generates native interfaces from TypeScript definitions')}

${kleur.cyan('Implement native code:')}
${kleur.white('ios/')} ${kleur.dim('# iOS native implementation')}
${kleur.white('android/')} ${kleur.dim('# Android native implementation')}

${kleur.green('Run your example app to test changes!')}

${kleur.yellow('Pro Tips:')}
${kleur.dim('• iOS:')} Open ${kleur.green('example/ios/example.xcworkspace')} in Xcode for native debugging
${kleur.dim('• Android:')} Open ${kleur.green('example/android')} in Android Studio
${kleur.dim('• Metro:')} Clear cache with ${kleur.green(`${pm} start`)} if needed

${kleur.yellow('Need help?')} Create an issue: ${kleur.blue().underline('https://github.com/mrousavy/nitro/issues')}

${kleur.yellow('Love this tool?')} Leave a ⭐️ on ${kleur.blue().underline('https://github.com/patrickkabwe/create-nitro-module')}
`
Loading
Loading