@2600hz/commio-native-utilities 中文文档教程

发布于 3年前 浏览 23 项目主页 更新于 3年前

React Native Components

@2600hz/commio-native-utilities

包含所有可共享实用程序和配置文件的库,用 Javascript 编写。

[![NPM 版本](https://img.shields.io/npm/v/@2600hz/commio-native-utilities?style=flat-square)](https://img.shields.io/npm/ v/@2600hz/commio-native-utilities?style=flat-square) [![代码风格:更漂亮](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)


2600Hz - Commio

JS Utilities Library

Installation

yarn add @2600hz/commio-native-utilities

Usage

import { capitalize, humanize } from '@2600hz/commio-native-utilities';

// ...

<Text>{capitalize(headerText)}</Text>
<Button title={humanize(buttonName)} onPress={}.... />

您还可以直接从文件夹

const {
  prettierBaseConfig,
} = require('@2600hz/commio-native-utilities/lib/prettier-config');

prettierBaseConfig.jsxBracketSameLine = false;

module.exports = prettierBaseConfig;

配置文件 导入或要求 您可以扩展以下任何配置:

  • eslint (.eslintrc.js)
  • prettier (..prettierrc.js)
  • release-it (.release-it.js)
  • commitlint (commitlint.config.js)
  • svgrrc (.svgrrc.js)
  • jest (jest.config.js)
  • lint-staged (lint-staged.config.js)
  • tsconfig (tsconfig.json)

所有配置文件都以相同的方式导入和使用,只有两个文件需要不同的处理

eslint Eslint文件导出一个接收根文件夹

const {
  eslintBaseConfig,
} = require('@2600hz/commio-native-utilities/lib/eslint-config');

module.exports = eslintBaseConfig(__dirname);

tsconfig 的函数 此文件必须从任何可用的 ts 配置文件扩展

{
  "extends": "@2600hz/commio-native-utilities/tsconfig.base",
  "compilerOptions": {
    "baseUrl": "./",
    ...
  },
  "exclude": [...],
  "include": [...],
}

Development

此项目需要 Node.js v14+ 才能运行。

使用 .nvmrc 文件有助于规范所有维护者使用的节点版本。 如果您需要使用此文件中指定的版本,请运行这些命令。

nvm use
nvm install

使用包管理器 yarn v1+ 安装依赖项和 devDependencies。

yarn install
# Or just
yarn

创建符号链接 在包根文件夹上运行以下命令,以便您可以在本地使用应用

yarn link

观看项目 每当有变化时构建包

yarn watch

使用包 两个项目必须放在同一个文件夹中,否则将无法工作

yarn link @2600hz/commio-native-utilities

构建包 将自动构建项目

yarn build

Utilities

使用 Eslint

yarn run lint:fix

格式化代码 使用 Prettier

yarn run format

使用 PrettierEslint

yarn run prettify

检查文件上的 Typescript

yarn run typescript

运行全面检查

yarn run full-check

Tech

Components 库使用了一些开源项目来正常工作:

  • Typescript - Strongly typed programming language which builds on JavaScript
  • NodeJs - Allows execute javascript scripts on the terminal
  • Luxon - library for dealing with dates and times in JavaScript (better alternative than Moment.js)

Contributing

欢迎请求请求。 对于重大更改,请先打开一个问题来讨论您想要更改的内容。

请参阅贡献指南,了解如何为存储库和开发工作流程做出贡献。

承诺 提交必须遵循常规提交格式 确保您的消息看起来像以下示例

feat: Adding new badge component
fix: Touchable component not being exported correctly
fix!: Drop support for Typescript

请注意,最后一个将生成主要提交。 它与添加重大更改页脚具有相同的结果

按照Semantic Versioning 2.0.0 更新项目版本。

Release-It 将负责版本控制,您只需提供正确的类型即可提交:

  • fix - to indicate a bug fix (PATCH) ex . v0.0.1
  • feat - to indicate a new feature (MINOR) ex. v0.1.0
  • chore - for updates that do not require a version bump (.gitignore, comments, etc.)
  • docs - for updates to the documentation
  • BREAKING CHANGE - regardless of type, indicates a Major release (MAJOR) ex. v1.0.0

访问 常规提交 获取更多示例。

发布 在上次提交/修改后运行以下命令。 然后用 Y/N 回答提示

yarn release

License

MIT

React Native Components

@2600hz/commio-native-utilities

Library that contains all sharable utilities and configuration files, written in Javascript.

[![NPM version](https://img.shields.io/npm/v/@2600hz/commio-native-utilities?style=flat-square)](https://img.shields.io/npm/v/@2600hz/commio-native-utilities?style=flat-square) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)


2600Hz - Commio

JS Utilities Library

Installation

yarn add @2600hz/commio-native-utilities

Usage

import { capitalize, humanize } from '@2600hz/commio-native-utilities';

// ...

<Text>{capitalize(headerText)}</Text>
<Button title={humanize(buttonName)} onPress={}.... />

You can also import or require directly from folder

const {
  prettierBaseConfig,
} = require('@2600hz/commio-native-utilities/lib/prettier-config');

prettierBaseConfig.jsxBracketSameLine = false;

module.exports = prettierBaseConfig;

Configuration files You can extend any of the following configs:

  • eslint (.eslintrc.js)
  • prettier (..prettierrc.js)
  • release-it (.release-it.js)
  • commitlint (commitlint.config.js)
  • svgrrc (.svgrrc.js)
  • jest (jest.config.js)
  • lint-staged (lint-staged.config.js)
  • tsconfig (tsconfig.json)

All configuration files are imported and used same way, there are just two files that need different treatment

eslint Eslint file exports a function that receives the root folder

const {
  eslintBaseConfig,
} = require('@2600hz/commio-native-utilities/lib/eslint-config');

module.exports = eslintBaseConfig(__dirname);

tsconfig This file must extends from any of the ts config files available

{
  "extends": "@2600hz/commio-native-utilities/tsconfig.base",
  "compilerOptions": {
    "baseUrl": "./",
    ...
  },
  "exclude": [...],
  "include": [...],
}

Development

This project requires Node.js v14+ to run.

Using .nvmrc file helps to normalize node version used by all maintainers. If you are required to use version specified in this file, run these commands.

nvm use
nvm install

Use the package manager yarn v1+ to install dependencies and devDependencies.

yarn install
# Or just
yarn

Create symlink Run the following command on package root folder, so you can consume on an app locally

yarn link

Watch project Build package whenever there is a change

yarn watch

Consume the package Both projects must be placed on same folder, otherwise won't work

yarn link @2600hz/commio-native-utilities

Build the package Automatically will build the project

yarn build

Utilities

Format code using Eslint

yarn run lint:fix

Format code using Prettier

yarn run format

Format code using Prettier and Eslint

yarn run prettify

Check Typescript on files

yarn run typescript

Run full check

yarn run full-check

Tech

Components library uses a number of open source projects to work properly:

  • Typescript - Strongly typed programming language which builds on JavaScript
  • NodeJs - Allows execute javascript scripts on the terminal
  • Luxon - library for dealing with dates and times in JavaScript (better alternative than Moment.js)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

See the contributing guide to learn how to contribute to the repository and the development workflow.

Commits Commits must follow conventional commit format Make sure your messages look like the following examples

feat: Adding new badge component
fix: Touchable component not being exported correctly
fix!: Drop support for Typescript

Note that the last one will generate a Major commit. It has the same result as adding a breaking change footer

Follow Semantic Versioning 2.0.0 to update project version.

Release-It will take care of versioning, you just have to give the correct type to commit:

  • fix - to indicate a bug fix (PATCH) ex . v0.0.1
  • feat - to indicate a new feature (MINOR) ex. v0.1.0
  • chore - for updates that do not require a version bump (.gitignore, comments, etc.)
  • docs - for updates to the documentation
  • BREAKING CHANGE - regardless of type, indicates a Major release (MAJOR) ex. v1.0.0

Visit Conventional Commits for more examples.

Make a release Run following command after your last commit/amend. Then answer with Y/N the prompt

yarn release

License

MIT

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文