cimi - a fully automated tool for publishing NPM packages
Published: 2022-10-22 15:31:27

# Preface

Bloggers have been investing in the development of the `concis` component library recently. Every time a bug is fixed or some component functions are added, they need to send packages and update online documents. This step by step is actually quite troublesome.

To ship a new NPM package you may need these steps:

* Manually modify `version` in `package.json`.
* `git add .`, `git commit -m "xxxx"` generate a commit.
* `git push origin master` pushes to the remote.
* Hit a new `tag` in github.
* `npm publish` to submit code to NPM.

Is it troublesome? This is where `cimi` comes from.

# Cimi

`cimi` is a fully automatic npm package distribution tool, one line of commands helps you git replase, create git tags, and publish npm packages.

Cimi automatically generates a new version number, automatically generates a commit message, creates a tag, pushes it to github, and finally publishes it to npm. The whole process only requires one line of commands, freeing your hands!

An example is as follows:


![image.png](https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/f63728c690fa43e6b12ae4f6b23a1e53~tplv-k3u1fbpfcp-watermark.image?)

It can be seen that all tasks of `manual revision number`, `git add/commit`, `git push`, `git taps`, `npm publish` have been completed through one line of `cimi patch master`.

Combined with the actual project, you can also use it with `cimi` like this:

````
 "scripts": {
    "build": "rollup -c ./rollup.config.js",
    "replase": "npm run build && cimi patch master",
 }
````

First package the file through the build tool and publish the file to NPM. This is also a practice of `cimi` in the `concis` component library, and it is very convenient for personal testing. The blogger also deleted the script in the automatic update `package.json` in the project~

# Cimi modify version rules

`Cimi` has three rules to issue packages, which is actually to determine the version number.

* `cimi patch` update a minor version like 1.1.0 -> 1.1.1 like bug fixes;
* `cimi minor` update a medium version, such as 1.1.0 -> 1.2.0, such as new features;
* `cimi major` update a major version, such as 1.1.0 -> 2.1.0, such as refactoring the architecture;

The branch defaults to `master`, if the master branch is another branch, it should be used like this:

`cimi patch main`
`cimi patch beta`

# use
Install `cimi`:

```bash
# Install cimi globally
npm i cimi -g
# Install cimi locally
npm i cimi -D
````

Here is the output of `cimi -h`:

````
Usage: cimi [options]

Options:
  -v, --version output the version number
  patch patch your new npm package
  minor minor your new npm package
  major major your new npm package
  -h, --help display help for command

  Tip:

    You should run this script in the root directory of you project or run by npm scripts.

  Examples:

    $ cimi patch [branch] (default: master)
    $ cimi minor [branch] (default: master)
    $ cimi major [branch] (default: master)

````

# write at the end

`cimi` is a wheel that bloggers started to make recently. At present, the function is simple, and new inspiration will be obtained in actual projects, which will be substituted into `cimi`, and everyone is welcome to experience it.

Finally, I hope you can give some support to `concis` and `cimi`~ Give some stars or join us to develop together.

[cimi github](https://github.com/fengxinhhh/Cimi)
[concis github](https://github.com/fengxinhhh/Concis)
[concis documentation](http://concis.org.cn/)

Thanks for the support.