# @iicoding/release

> ## Setup

Latest version **0.0.18** (published 2025-04-04) · 0 weekly downloads

## Install

```sh
npm install @iicoding/release
pnpm add @iicoding/release
yarn add @iicoding/release
bun add @iicoding/release
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.18 |
| Published | 2025-04-04 |
| First published | 2024-01-16 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 9 |
| Unpacked size | 58.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | iiCoding |
| Maintainers | iicoding |

## Links

- npm: https://www.npmjs.com/package/@iicoding/release
- Repository: https://github.com/Tddtest/release
- Homepage: https://github.com/Tddtest/iicoding-release#readme
- Issues: https://github.com/Tddtest/iicoding-release/issues
- npm.io page: https://npm.io/package/@iicoding/release

## Dependencies (9)

- [ora](https://npm.io/package/ora.md) ^8.2.0
- [chalk](https://npm.io/package/chalk.md) ^5.4.1
- [semver](https://npm.io/package/semver.md) ^7.7.1
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.3.0
- [inquirer](https://npm.io/package/inquirer.md) ^12.5.0
- [cli-spinners](https://npm.io/package/cli-spinners.md) ^3.2.0
- [@iicoding/utils](https://npm.io/package/@iicoding/utils.md) ^0.0.63
- [progress-estimator](https://npm.io/package/progress-estimator.md) ^0.3.1
- [@iicoding/utils-node](https://npm.io/package/@iicoding/utils-node.md) ^0.0.8

## Recent versions

- 0.0.18 (latest) — 2025-04-04
- 0.0.17 — 2025-04-01
- 0.0.16 — 2025-04-01
- 0.0.15 — 2025-03-27
- 0.0.14 — 2025-03-27
- 0.0.13 — 2025-03-27
- 0.0.12 — 2025-03-27
- 0.0.11 — 2024-02-27
- 0.0.10 — 2024-02-27
- 0.0.9 — 2024-02-25
- 0.0.8 — 2024-02-25
- 0.0.7 — 2024-02-21
- 0.0.6 — 2024-02-21
- 0.0.5 — 2024-01-16
- 0.0.4 — 2024-01-16
- … 2 more at https://npm.io/package/@iicoding/release/versions

## README

# npm release util

## Setup

Install the dependencies:

```bash
pnpm install @iicoding/release
```

## Get started

release your npm library:

```bash
pnpm run icd-release [暂未实现]
```

手动调用方式
1. 根目录下新建 script 文件夹
2. script 文件夹下新建 index.ts
   ```bash
    # 进入到根目录
   mkdir script
   touch index.ts
   
   # or 手动新建
    ```
3. 从 @iicoding/release 中引入各个任务执行函数[每个函数被称为task]
   ```typescript
    import {
    eslint,
    gitPush,
    gitTag,
    executeEnd,
    publishAuth,
    publishAfter,
    publishBefore,
    updateVersion,
    publishing,
    getVersion,
    build,
    release,
    } from '@iicoding/release';

    const defaultTaskQueen = [
   // 该函数需要在这里执行，传入指定的配置文件。默认为[eslint.config.mjs]
    eslint({ configFile: './eslint.config.mjs' }),
    build,
    getVersion,
    updateVersion,
    publishAuth,
   // 发布之前的操作，提供了一个函数，返回 package 的配置项 如果需要求他操作，可以自定义 task
    publishBefore((record) => {
    const omitKeys = ['devDependencies', 'scripts'];
    const newRecord: Record<string, any> = {};
    
        Object.keys(record)
          .filter((key) => {
            return !omitKeys.includes(key);
          })
          .forEach((key) => {
            newRecord[key] = record[key];
          });
    
        return newRecord;
    }),
    publishing,
    publishAfter,
    gitPush,
    gitTag,
    executeEnd,
    ];
    
    const defaultTask = release(defaultTaskQueen);
    
    defaultTask();
    ```
4. 在 package.json 中 script 字段中 添加执行命令
    ```
   "release": "ts-node script/index.ts"
   ```
5. 自定义 task
    ```typescript
    import { NextMethod, NextParams } from "@iicoding/release"; 
    export const customTaskName = (
      next: NextMethod,
      params: NextParams
    ) => {
    // doSomething
    // 期望的执行成功之后，
    next(params);
    // 或者执行失败
   // 执行失败，如果需要回退版本，则调用下方函数,其他逻辑可自行定制
    params.getRegisterProps('rollbackPackage')(
      `发布失败即将进入回退操作 ${error.message}`,
    );
   }
   ```

---
_Source: https://npm.io/package/@iicoding/release · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
