{"id":19269291,"url":"https://github.com/listenzz/react-native-create-lib","last_synced_at":"2026-02-27T01:32:12.871Z","repository":{"id":36294318,"uuid":"223151862","full_name":"listenzz/react-native-create-lib","owner":"listenzz","description":"Tool to create a React Native library module or view module with a single command","archived":false,"fork":false,"pushed_at":"2025-06-01T05:58:19.000Z","size":411,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-16T08:07:29.394Z","etag":null,"topics":["create","library","react-native"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/listenzz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-21T10:47:57.000Z","updated_at":"2025-06-01T15:08:28.000Z","dependencies_parsed_at":"2025-06-13T17:34:44.614Z","dependency_job_id":"b5700b57-71e5-45a5-ad90-e73c38b4684e","html_url":"https://github.com/listenzz/react-native-create-lib","commit_stats":{"total_commits":72,"total_committers":1,"mean_commits":72.0,"dds":0.0,"last_synced_commit":"08e8a574aa45a6dc18b1b3fe03e6810395d5a795"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/listenzz/react-native-create-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2Freact-native-create-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2Freact-native-create-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2Freact-native-create-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2Freact-native-create-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/listenzz","download_url":"https://codeload.github.com/listenzz/react-native-create-lib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2Freact-native-create-lib/sbom","scorecard":{"id":592583,"data":{"date":"2025-08-11","repo":{"name":"github.com/listenzz/react-native-create-lib","commit":"e6347aeebe06571488caae471760ae1d022477eb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":2,"reason":"3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":6,"reason":"4 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T22:20:47.658Z","repository_id":36294318,"created_at":"2025-08-20T22:20:47.658Z","updated_at":"2025-08-20T22:20:47.658Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29880743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T23:51:21.483Z","status":"ssl_error","status_checked_at":"2026-02-26T23:50:46.793Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["create","library","react-native"],"created_at":"2024-11-09T20:19:20.192Z","updated_at":"2026-02-27T01:32:12.863Z","avatar_url":"https://github.com/listenzz.png","language":"JavaScript","readme":"# react-native-create-lib\n\n一行命令创建原生模块/组件库，支持 Monorepo 模式。已迁移到 ReactNative 新架构。\n\n\u003e 如何支持 Monorepo 模式？请参考 [Monorepo 使用说明](#monorepo-使用说明)\n\n## 基本用法\n\n创建基础库（默认创建原生模块）：\n```bash\n$ npx react-native-create-lib MyLib\n```\n\n创建自定义包名的库：\n```bash\n$ react-native-create-lib --module-name @sdcx/wechat --repo-name react-native-wechat wechat\n```\n\n创建原生组件库：\n```bash\n$ react-native-create-lib --module-type components ImageCrop\n```\n\n创建同时包含模块和组件的库：\n```bash\n$ react-native-create-lib --module-type all MyLib\n```\n\n创建完成后，在新创建的库目录中安装依赖：\n\n```bash\n$ cd MyLib\n$ npm install\n```\n\n## 参数说明\n\n### 必需参数\n\n- **`\u003cname\u003e`**: 库的名称（必需），将用于生成类名和默认包名\n\n### 可选参数\n\n#### `--module-type \u003cmoduleType\u003e`\n指定要生成的原生代码类型。\n\n- **可选值**: `modules` | `components` | `all`\n- **默认值**: `modules`\n- **说明**:\n  - `modules`: 创建原生模块（TurboModule），用于提供原生功能接口\n  - `components`: 创建原生组件（NativeComponent），用于渲染原生 UI 组件\n  - `all`: 同时创建原生模块和原生组件\n\n**示例**:\n```bash\n# 创建原生模块（默认）\n$ react-native-create-lib MyModule\n\n# 创建原生组件\n$ react-native-create-lib --module-type components ImageCrop\n\n# 同时创建模块和组件\n$ react-native-create-lib --module-type all MyLib\n```\n\n#### `--module-name \u003cmoduleName\u003e`\n指定 npm 包名，将写入 `package.json` 的 `name` 字段。\n\n- **默认值**: `react-native-{name}` (name 转换为 param-case)\n- **示例**: \n  ```bash\n  $ react-native-create-lib --module-name @sdcx/wechat wechat\n  # 生成的 package.json 中 name 为 \"@sdcx/wechat\"\n  ```\n\n#### `--repo-name \u003crepoName\u003e`\n指定仓库名称，用于生成 GitHub 链接和目录名。\n\n- **默认值**: `react-native-{name}` (name 转换为 param-case)\n- **示例**:\n  ```bash\n  $ react-native-create-lib --repo-name my-custom-repo MyLib\n  # 将创建 my-custom-repo 目录\n  ```\n\n#### `--prefix \u003cprefix\u003e`\n指定类名前缀，用于生成原生代码中的类名。\n\n- **默认值**: `RN`\n- **示例**:\n  ```bash\n  $ react-native-create-lib --prefix SDCX MyLib\n  # 生成的类名将为 SDCXMyLib 而不是 RNMyLib\n  ```\n\n#### `--package-identifier \u003cpackageIdentifier\u003e`\n指定 Android 的 Java 包标识符。\n\n- **默认值**: `com.reactnative.{name}` (name 转换为小写)\n- **示例**:\n  ```bash\n  $ react-native-create-lib --package-identifier com.mycompany.mylib MyLib\n  # Android 代码将使用 com.mycompany.mylib 作为包名\n  ```\n\n#### `--platforms \u003cplatforms\u003e`\n指定要生成的平台，多个平台用逗号分隔。\n\n- **默认值**: `ios,android`\n- **可选值**: `ios` | `android` | `ios,android`\n- **示例**:\n  ```bash\n  # 只生成 iOS 平台\n  $ react-native-create-lib --platforms ios MyLib\n  \n  # 只生成 Android 平台\n  $ react-native-create-lib --platforms android MyLib\n  ```\n\n#### `--github-account \u003cgithubAccount\u003e`\n指定 GitHub 账户名，用于生成仓库链接。\n\n- **默认值**: `github-account`\n- **示例**:\n  ```bash\n  $ react-native-create-lib --github-account myusername MyLib\n  # 生成的链接为 https://github.com/myusername/react-native-mylib\n  ```\n\n#### `--author-name \u003cauthorName\u003e`\n指定作者名称，将写入 `package.json` 和 `LICENSE`。\n\n- **默认值**: `author-name`\n- **示例**:\n  ```bash\n  $ react-native-create-lib --author-name \"John Doe\" MyLib\n  ```\n\n#### `--author-email \u003cauthorEmail\u003e`\n指定作者邮箱，将写入 `package.json` 和 `LICENSE`。\n\n- **默认值**: `author-email@gmail.com`\n- **示例**:\n  ```bash\n  $ react-native-create-lib --author-email john@example.com MyLib\n  ```\n\n#### `--license \u003clicense\u003e`\n指定许可证类型，将写入 `package.json` 和 `LICENSE` 文件。\n\n- **默认值**: `MIT`\n- **示例**:\n  ```bash\n  $ react-native-create-lib --license Apache-2.0 MyLib\n  ```\n\n### 其他选项\n\n- **`-V, --version`**: 显示版本号\n- **`-h, --help`**: 显示帮助信息\n\n## 完整示例\n\n创建一个完整的自定义库：\n\n```bash\n$ react-native-create-lib \\\n  --module-name @mycompany/image-crop \\\n  --repo-name react-native-image-crop \\\n  --module-type components \\\n  --prefix MyCompany \\\n  --package-identifier com.mycompany.imagecrop \\\n  --github-account mycompany \\\n  --author-name \"Jane Doe\" \\\n  --author-email jane@mycompany.com \\\n  --license MIT \\\n  image-crop\n```\n\n## Monorepo 使用说明\n\n在 Monorepo 中，建议先用官方命令创建主 React Native 工程，再通过 **Yarn Workspaces** 或 **pnpm Workspaces** 在 `packages/` 下管理多个原生库，主工程通过 workspace 依赖和路径配置感知这些库。\n\n### 1. 创建主工程\n\n使用 React Native 官方 CLI 创建主项目（不要用本库创建整个项目）：\n\n```bash\nnpx @react-native-community/cli init MyApp\ncd MyApp\n```\n\n### 2. 启用 Workspace\n\n在项目根目录的 `package.json` 中声明 workspaces，使主工程能识别 `packages/` 下的包。\n\n**Yarn：**\n\n```json\n{\n  \"name\": \"my-app\",\n  \"private\": true,\n  \"workspaces\": [\n    \"packages/*\"\n  ]\n}\n```\n\n**pnpm：**\n\n```json\n{\n  \"name\": \"my-app\",\n  \"private\": true,\n  \"packageManager\": \"pnpm@9.0.0\",\n  \"pnpm\": {\n    \"overrides\": {}\n  }\n}\n```\n\n并在项目根创建 `pnpm-workspace.yaml`：\n\n```yaml\npackages:\n  - 'packages/*'\n```\n\n然后执行 `yarn install` 或 `pnpm install` 以链接 workspace 包。\n\n### 3. 添加模块包\n\n在 `packages/` 目录下使用本库创建新的原生模块/组件库（`--repo-name` 可省略 `react-native-` 前缀以保持简短）：\n\n```bash\ncd packages/\n# 原生模块（如 wechat）\nnpx react-native-create-lib --module-name @sdcx/wechat --repo-name wechat --prefix RN --package-identifier com.sdcx.wechat wechat\n# 原生组件（如 image-crop）\nnpx react-native-create-lib --module-name @sdcx/image-crop --repo-name image-crop --module-type components --prefix RN --package-identifier com.sdcx.imagecrop image-crop\n```\n\n创建完成后，在对应库目录中安装依赖（若使用 workspace，根目录执行一次 `yarn` / `pnpm install` 即可）。\n\n### 4. 主工程感知 lib：配置 tsconfig\n\n在主工程根目录的 `tsconfig.json` 中配置 `paths`，让 TypeScript 能解析 workspace 包源码：\n\n```json\n{\n  \"compilerOptions\": {\n    \"paths\": {\n      \"@sdcx/wechat\": [\"./packages/wechat/src\"],\n      \"@sdcx/image-crop\": [\"./packages/image-crop/src\"],\n      \"@sdcx/*\": [\"app/sdcx/*\"]\n    }\n  }\n}\n```\n\n按实际包名与路径增减或修改 `paths` 条目。\n\n### 5. 主工程感知 lib：配置 Babel alias\n\n在主工程的 `babel.config.js` 中为 `module-resolver` 配置与 `paths` 一致的 alias，保证运行时和打包能正确解析：\n\n```js\nmodule.exports = {\n  presets: ['module:@react-native/babel-preset'],\n  plugins: [\n    [\n      'module-resolver',\n      {\n        root: ['./'],\n        extensions: ['.ts', '.tsx', '.ios.js', '.android.js', '.js', '.json'],\n        alias: {\n          '@sdcx/wechat': './packages/wechat/src',\n          '@sdcx/image-crop': './packages/image-crop/src',\n          '@sdcx/*': 'app/sdcx/*',\n        },\n      },\n    ],\n  ],\n};\n```\n\n若尚未安装 `babel-plugin-module-resolver`，需先安装：\n\n```bash\nyarn add -D babel-plugin-module-resolver\n# 或\npnpm add -D babel-plugin-module-resolver\n```\n\n### 6. 主工程依赖 workspace 包\n\n在主工程根目录的 `package.json` 中，将 lib 作为 workspace 依赖加入：\n\n```json\n{\n  \"dependencies\": {\n    \"@sdcx/wechat\": \"*\",\n    \"@sdcx/image-crop\": \"*\"\n  }\n}\n```\n\n使用 `*` 表示使用当前 workspace 内的版本；也可写为 `\"workspace:*\"`（Yarn 3+ / pnpm）明确指定 workspace 协议。配置完成后执行 `yarn install` 或 `pnpm install`，即可在业务代码中 `import` 并使用这些包。\n\n## License\n\n[MIT](./LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flistenzz%2Freact-native-create-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flistenzz%2Freact-native-create-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flistenzz%2Freact-native-create-lib/lists"}