diff --git a/README.md b/README.md index c7e94a2..b3e018b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,103 @@ -# cleants -Convert TypeScript to a cleaner JavaScript project \ No newline at end of file +# Cleants + +[![npm version][]](https://www.npmjs.com/package/cleants)[![License: MIT][]](https://opensource.org/licenses/MIT) + +🧹 Convert TypeScript to a cleaner JavaScript project + +## Features + +- Vue: 对 Vue 项目转换具有第一优先级的支持 +- 可扩展: 通过插件扩展对不同类型文件转换支持 +- 快速的: 使用 ts.transpileModule 具有极快的转译速度 +- 便捷性: 提供 CLI 命令只需要一句命令即可快速转换 +- 集成: 你可以导入NPM包将集成到你的项目中 + +## Install + +```bash +npm install cleants +# or +yarn add cleants +# or +pnpm add cleants +``` + +## Usage + +1. CLI Usage + +```bash +npx cleants +``` + +2. Programmatic Usage + +```javascript +import { Cleants } from 'cleants' + +const cleaner = new Cleants(inputDir, outputDir, options) +await cleaner.run() +``` + +当然,我可以为您将该 JSDoc 转换为简洁美观的 Markdown 格式。以下是转换后的 API 文档: + +## API + +### `Cleants` + +主要类,用于将 TypeScript 项目转换为更清洁的 JavaScript 项目。 + +#### 构造函数 + +```typescript +constructor(inputDir: string, outputDir: string, options?: CleantsOptions) +``` + +##### 参数 + +- `inputDir: string` - 输入目录路径 +- `outputDir: string` - 输出目录路径 +- `options?: CleantsOptions` - 可选配置选项 + +##### CleantsOptions + +| 选项 | 类型 | 描述 | +| ---------------------------- | ------------------------------------- | --------------------- | +| `progressCallback?` | `Function` | 进度回调函数 | +| `compilerOptions?` | `Object` | TypeScript 编译器选项 | +| `ignoredCopyPatterns?` | `Array` | 复制时要忽略的模式 | +| `ignoredConversionPatterns?` | `Array` | 转换时要忽略的模式 | +| `getOutputDir?` | `Function` | 获取输出目录的函数 | +| `removeDependencies?` | `Array` | 要移除的依赖项 | +| `replaceInternalImports?` | `boolean` | 是否替换内部导入 | + +## Contributing + +Contributions, issues and feature requests are welcome! Feel free to check [issues page](https://github.com/viarotel-org/cleants/issues). + +## Support + +If you feel that this project is helpful for your work or study, please help me order a ✨ Star, which will be a great encouragement and support for me, or you can buy me a cup of coffee below + +
+ viarotel-wepay + viarotel-alipay + + viarotel-paypal + +
+ +## Contributors + +Thanks for all their contributions! + + + contributors + + +## 📚 Keywords +`typescript` `javascript` `converter` `electron` `vue` + +## License + +This project is licensed under the [MIT](LICENSE) License. diff --git a/eslint.config.js b/eslint.config.js index 6aae4ab..33da67e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -3,7 +3,6 @@ import antfu from '@antfu/eslint-config' export default antfu( { typescript: false, - markdown: false, ignores: [ '.github', '.vscode', @@ -36,12 +35,12 @@ export default antfu( 'prefer-promise-reject-errors': 'off', 'no-unused-expressions': 'off', 'sort-imports': 'off', + 'no-useless-constructor': 'off', 'unicorn/consistent-function-scoping': 'off', 'regexp/no-unused-capturing-group': 'off', 'regexp/no-dupe-disjunctions': 'off', 'perfectionist/sort-imports': 'off', - 'antfu/no-top-level-await': 'off', }, }, ) diff --git a/package.json b/package.json index 7abf4a1..372a440 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "typescript", "javascript", "converter", - "electron", "vue" ], "publishConfig": { diff --git a/src/bin.js b/src/bin.js index 9e4eab0..5955489 100755 --- a/src/bin.js +++ b/src/bin.js @@ -1,6 +1,7 @@ #!/usr/bin/env node import Cleants from './index.js' +import { capitalizeFirstLetter } from './helpers/index.js' import yargs from 'yargs' import { hideBin } from 'yargs/helpers' import * as p from '@clack/prompts' @@ -9,7 +10,7 @@ import ora from 'ora' yargs(hideBin(process.argv)) .command('$0', description, () => {}, async (argv) => { - p.intro(`Welcome to ${name} v${version}`) + p.intro(`${capitalizeFirstLetter(name)}: ${description}. Supported by Viarotel v${version}`) const inputDir = await p.text({ message: 'Enter the TypeScript project directory to convert:', diff --git a/src/helpers/index.js b/src/helpers/index.js index 7e18cba..63f2936 100755 --- a/src/helpers/index.js +++ b/src/helpers/index.js @@ -58,3 +58,14 @@ export function getNewFilePath(filePath) { return filePath.replace(ext, extensionMap[ext]) } + +/** + * 将字符串首字母转为大写 + * @param {*} str + * @returns {string} + */ +export function capitalizeFirstLetter(str) { + if (!str) + return str + return str.charAt(0).toUpperCase() + str.slice(1) +}