Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
meshareL committed Dec 13, 2020
1 parent faceb16 commit 00dfd8f
Show file tree
Hide file tree
Showing 23 changed files with 4,424 additions and 578 deletions.
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
maintained node versions
57 changes: 57 additions & 0 deletions .svgo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
multipass: true

plugins:
- cleanupAttrs: true
- inlineStyles: true
- removeDoctype: true
- removeXMLProcInst: true
- removeComments: true
- removeMetadata: true
- removeTitle: true
- removeDesc: true
- removeUselessDefs: true
- removeXMLNS: false
- removeEditorsNSData: true
- removeEmptyAttrs: true
- removeHiddenElems: true
- removeEmptyText: true
- removeEmptyContainers: true
- removeViewBox: false
- cleanupEnableBackground: true
- minifyStyles: true
- convertStyleToAttrs: true
- convertColors: true
- convertPathData: true
- convertTransform: true
- removeUnknownsAndDefaults: true
- removeNonInheritableGroupAttrs: true
- removeUselessStrokeAndFill: true
- removeUnusedNS: true
- prefixIds: false
- cleanupIDs: true
- cleanupNumericValues: true
- cleanupListOfValues: false
- moveElemsAttrsToGroup: true
- moveGroupAttrsToElems: true
- collapseGroups: true
- removeRasterImages: false
- mergePaths: true
- convertShapeToPath: true
- convertEllipseToCircle: true
- sortAttrs: false
- sortDefsChildren: true
- removeDimensions: true
- removeAttrs:
attrs:
# - xmlns:xlink
# - id
# - class
# - fill
# - transform
# - href
# - clip-path
# - clip-rule
- data-.*
- removeStyleElement: false
- removeScriptElement: false
- reusePaths: false
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# j-icon-cli
自动将 `SVG` 图标转换为 [Icon](https://github.com/meshareL/j-icon/blob/master/index.d.ts#L3) 对象的命令行工具

## 安装
```shell
npm install @tomoeed/j-icon-cli --save-dev
```

## 使用
```shell
j-icon -i svgs -o dist
```

## 选项
```text
-i, --input <path> 文件或文件夹路径
-o, --output <path> 文件输出目录
-m, --minify 是否压缩文件 (默认值: false)
-f, --format 输出文件格式 (默认值: json esm umd ts type)
-t, --target Vue 版本. 2 或 3 (默认值: 3)
-n, --name 输出文件名称 (默认值: index)
```

## API
```js
const process = require('@tomoeed/j-icon-cli');
process({input: '', output: ''});
```
17 changes: 17 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

module.exports = {
presets: [
['@babel/preset-env', {
bugfixes: true,
useBuiltIns: 'usage',
corejs: 3
}]
],
plugins: [
['@babel/plugin-transform-runtime', {
corejs: false,
version: '^7.12.5'
}]
]
};
3 changes: 3 additions & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node
'use strict';
require('../dist/command');
33 changes: 33 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
interface Option {
/** 文件或目录路径(绝对路径) */
input: string;
/** 文件输出路径(绝对路径) */
output: string;
/**
* 输出文件格式
*
* @default ['json', 'esm', 'umd', 'ts', 'type']
*/
format?: Array<'json' | 'esm' | 'umd' | 'ts' | 'type'>;
/**
* 是否压缩文件
*
* @default false
*/
minify?: boolean;
/**
* 目标 Vue 代码. 2 或 3
*
* @default 3
*/
target?: number;
/**
* 输出文件名称
*
* @default index
*/
name?: string;
}

export default function (option: Option): Promise<void>;
export { Option };
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

module.exports = {
testEnvironment: 'node',
testRegex: 'test/.*.spec.js$'
};
Loading

0 comments on commit 00dfd8f

Please sign in to comment.