# auto-export

> A cli can automatically export files

Latest version **0.3.7** (published 2022-08-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install auto-export
pnpm add auto-export
yarn add auto-export
bun add auto-export
```

Provides the command `autoexport`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.7 |
| Published | 2022-08-01 |
| First published | 2022-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 3.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | sudongyuer |
| Maintainers | sudongyuer |

## Links

- npm: https://www.npmjs.com/package/auto-export
- Repository: https://github.com/sudongyuer/auto-export
- Homepage: https://github.com/sudongyuer/auto-export#readme
- Issues: https://github.com/sudongyuer/auto-export/issues
- Funding: https://github.com/sponsors/sudongyuer
- npm.io page: https://npm.io/package/auto-export

## Dependencies (5)

- [cac](https://npm.io/package/cac.md) ^6.7.12
- [chalk](https://npm.io/package/chalk.md) 4.1.2
- [pathe](https://npm.io/package/pathe.md) ^0.3.2
- [unconfig](https://npm.io/package/unconfig.md) ^0.3.5
- [commander](https://npm.io/package/commander.md) ^9.3.0

## Recent versions

- 0.3.7 (latest) — 2022-08-01
- 0.3.6 — 2022-07-31
- 0.3.5 — 2022-07-31
- 0.3.4 — 2022-07-31
- 0.3.3 — 2022-07-27
- 0.3.2 — 2022-07-18
- 0.3.1 — 2022-07-17
- 0.3.0 — 2022-07-16
- 0.2.6 — 2022-07-13
- 0.2.5 — 2022-07-13
- 0.2.4 — 2022-07-11
- 0.2.3 — 2022-07-11
- 0.2.2 — 2022-07-10
- 0.2.1 — 2022-07-10
- 0.1.1 — 2022-07-10
- … 1 more at https://npm.io/package/auto-export/versions

## README

# auto-export

A cli can automatically export files

[![NPM version](https://img.shields.io/github/package-json/v/sudongyuer/auto-export)](https://www.npmjs.com/package/auto-export)


<p align='center'>
<img src='https://git.poker/sudongyuer/image-bed/blob/master/20220710/---assets----images----a.159jjelqs5hc.png?raw=true' width='200'/>
</p>

## Why

When you want to export many files of the same type in one folder, you may cost a lot of time to `copy and paste` the same code. eg if you want to export all `images `in one folder, you need to copy and paste the same code for each image, and export these images in a `index.ts` file.Why not have a try to use `auto-export`👻

## 🚀 Features
- Multiple directory generate support
- Nested directory generate support
- Custom output directory support
- Custom import statement support
- Auto Prefix support

## Usage

### Install

```ball
pnpm add -D auto-export
```

### Config `export.config.ts`

- targetDir (require) : the directory to export files

- outputDir (optional,default targetDir) : the directory to generate the `index.ts` file to export files

- customImport (optional) : custom the import statement to use in the `index.ts` file 

- depth (optional , default true) : traverse all subdirectories

- autoPrefix (optional , default false) : auto add prefix to the file name. Note that the if you open the customImport option,this option will be ignored

```js
import { defineExportConfig } from 'auto-export'
export default defineExportConfig({
  configs: [
    {
      targetDir: './src/assets/images',
    },
    {
      targetDir: './src/assets/img',
      depth: true,
      autoPrefix: true
    },
    {
      targetDir: './src/assets/css',
      outputDir: './src/assets/css',
    },
    {
      targetDir: './src/assets/svgs',
      customImport: (fileName, file) => {
        return `import { ReactComponent as ${fileName} } from '${file}'`
      },
    },
    {
      targetDir: './src/assets/gif',
      customImport: (fileName, file, fileType) => {
        return `import ${fileType}${fileName} from '${file}'`
      },
      depth: true
    },
  ],
})

```

### Generate `index.ts`

```bash
pnpm run autoexport
```

## Author

sudongyuer email:976499226@qq.com

## License

[MIT](./LICENSE) License © 2021 [SuDongYu](https://github.com/sudongyuer)

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