DEV Community

幻城
幻城

Posted on

cimi - a fully automated tool for publishing NPM packages

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

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",
 }
Enter fullscreen mode Exit fullscreen mode


`

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.
Enter fullscreen mode Exit fullscreen mode

Examples:

$ cimi patch [branch] (default: master)
$ cimi minor [branch] (default: master)
$ cimi major [branch] (default: master)
Enter fullscreen mode Exit fullscreen mode

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
concis github
concis documentation

Thanks for the support.

Top comments (1)

Collapse
 
huancheng profile image
幻城

If you have any questions, please leave a message.