@20i/mrm-preset 中文文档教程

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

mrm-preset

mrm 预设以设置 nvm、eslint、prettier、lint-staged、husky 和 ​​typescript。

还包括用于发布 npm 库 的单独任务。

Usage

设置所有的东西!

npx mrm all --preset @20i/mrm-preset
# or for yarn berry
yarn dlx mrm all --preset @20i/mrm-preset

Details

这些中的每一个都可以单独设置。 要查看所有可用任务,请运行 npx mrm --preset @20i/mrm-preset

nvm

npx mrm nvm --preset @20i/mrm-preset

每个项目都应该有一个 .nvmrc 文件。 目前默认为 16,但您可以将其更改为您需要的任何值。

可以按照他们的安装说明安装 nvm

eslint

npx mrm eslint --preset @20i/mrm-preset

@20i/eslint-config 默认会安装 prettier 和 typescript 支持。 有关详细信息,请参阅包装。

如果发现 React 或 React Native 作为依赖项,则会安装额外的 eslint 包。 如果需要,可以在添加 react 后再次运行此命令。

lint-staged

npx mrm lint-staged --preset @20i/mrm-preset

这也将 husky 设置为作为预提交挂钩运行。 默认命令是使用 precommit npm 脚本,但可以在 .husky/pre-commitpackage.json 中进行调整.

.gitignore

npx mrm gitignore --preset @20i/mrm-preset

配置了节点项目和 yarn berry 的默认值。

Default mrm presets

可以使用 npx mrm 运行任何默认预设

typescript

。 -task-typescript">打字稿的 mrm 预设。 欢迎 PRs 更新此 :D

readme

仅当自述文件不存在时才会运行。

license

仅当许可证不存在时才会运行。

editorconfig

这是一个漂亮的配置,可以帮助您的编辑器拥有更好的默认值。 有关更多选项,请查看 editorconfig 文档

Not included in all

ci-publish

npx mrm ci-publish --preset @20i/mrm-preset

ci-publish 将向您的项目添加一个 .github/workflows/ci-publish.yml 文件,以便在发布时自动发布到 npm。 它还添加了一个 release.yml 模板来帮助 Github 的自动发布说明。

Dev

Publish to npm

这个包使用 [Publish CI]( https://github.com/twentyideas/20i-cdk/.github/workflows/publish.yml)工作流程。

工作流配置为在成功发布和 package.json 版本提升后将包发布到 npm。

要使用,

  1. Add a publish NPM_TOKEN to your github repo secrets
  2. Bump the package.json version
  3. Make a release

为了有效的变更日志,请务必将 release.yml 中的标签添加到 PR。

mrm-preset

mrm preset to set up nvm, eslint, prettier, lint-staged, husky, and typescript.

Also includes a separate task for publishing npm libraries.

Usage

Setup all the things!

npx mrm all --preset @20i/mrm-preset
# or for yarn berry
yarn dlx mrm all --preset @20i/mrm-preset

Details

Each of these can be set up individually. To see all available tasks, run npx mrm --preset @20i/mrm-preset

nvm

npx mrm nvm --preset @20i/mrm-preset

Every project should have a .nvmrc file. Currently this defaults to 16, but you can change it to whatever you need.

nvm can be installed by following their installation instructions

eslint

npx mrm eslint --preset @20i/mrm-preset

The @20i/eslint-config will be installed with prettier and typescript support by default. See the package for more details.

If React or React Native are found as dependencies, additional eslint packages will be installed. This command can be run again after adding react if needed.

lint-staged

npx mrm lint-staged --preset @20i/mrm-preset

This also sets up husky to run as a pre-commit hook. The default command is to use a precommit npm script, but that can be adjusted in .husky/pre-commit and in your package.json.

.gitignore

npx mrm gitignore --preset @20i/mrm-preset

Configured with default values for a node project and yarn berry.

Default mrm presets

Any default preset can be run with npx mrm <PRESET>

typescript

Currently, this just runs the mrm preset for typescript. PRs are welcome to update this :D

readme

Will only run if a readme is not already present.

license

Will only run if a license is not already present.

editorconfig

This is a nifty config to help your editor have better default values. For more options, check out editorconfig docs.

Not included in all

ci-publish

npx mrm ci-publish --preset @20i/mrm-preset

ci-publish will add a .github/workflows/ci-publish.yml file to your project for auto publishing to npm on releases. It also adds a release.yml template to help with Github's auto release notes.

Dev

Publish to npm

This package is published to npm using the [Publish CI]( https://github.com/twentyideas/20i-cdk/.github/workflows/publish.yml) workflow.

The workflow is configured to publish the package to npm after a successful release and package.json version bump.

To use,

  1. Add a publish NPM_TOKEN to your github repo secrets
  2. Bump the package.json version
  3. Make a release

For effective changelogs, be sure to add the labels found in release.yml to PRs.

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