-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gorgechan
committed
May 24, 2022
1 parent
d12d0c6
commit 3e383b5
Showing
30 changed files
with
1,277 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import path from "path"; | ||
import minimist from "minimist"; | ||
import { fileURLToPath } from "url"; | ||
import { Plop, run } from "plop"; | ||
|
||
// == Types ================================================================ | ||
|
||
// == Constants ============================================================ | ||
|
||
const args = process.argv.slice(2); | ||
const argv = minimist(args); | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
// == Exports ============================================================== | ||
|
||
Plop.prepare( | ||
{ | ||
cwd: argv.cwd, | ||
configPath: path.resolve(__dirname, "plopfile.ts"), | ||
preload: argv.preload || [], | ||
completion: argv.completion, | ||
}, | ||
(env) => { | ||
return run(env, undefined, true); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import path from 'path'; | ||
import { fileURLToPath } from "url"; | ||
import { NodePlopAPI } from 'plop'; | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
export default function (plop: NodePlopAPI) { | ||
plop.setGenerator('component', { | ||
description: '创建一个新组件', | ||
prompts: [ | ||
{ type: 'input', name: 'name', message: '请输入组件名称(多个单词以中横线命名)' }, | ||
{ type: 'input', name: 'CN', message: '请输入组件中文名称' }, | ||
{ type: 'input', name: 'description', message: '请输入组件描述' }, | ||
], | ||
actions: [ | ||
{ | ||
type: 'add', | ||
path: path.resolve(__dirname, '../src/{{kebabCase name}}/index.ts'), | ||
templateFile: path.resolve(__dirname, './template/index.hbs'), | ||
}, | ||
{ | ||
type: 'add', | ||
path: path.resolve(__dirname, '../src/{{kebabCase name}}/{{pascalCase name}}.tsx'), | ||
templateFile: path.resolve(__dirname, './template/comp.hbs'), | ||
}, | ||
{ | ||
type: 'add', | ||
path: path.resolve(__dirname, '../src/{{kebabCase name}}/style/index.less'), | ||
templateFile: path.resolve(__dirname, './template/style/style.hbs'), | ||
}, | ||
{ | ||
type: 'add', | ||
path: path.resolve(__dirname, '../src/{{kebabCase name}}/style/index.ts'), | ||
templateFile: path.resolve(__dirname, './template/style/index.hbs'), | ||
}, | ||
{ | ||
type: 'add', | ||
path: path.resolve(__dirname, '../docs/components/{{kebabCase name}}.md'), | ||
templateFile: path.resolve(__dirname, './template/doc.hbs'), | ||
}, | ||
{ | ||
type: 'add', | ||
path: path.resolve(__dirname, '../src/{{kebabCase name}}/{{camelCase name}}Types.ts'), | ||
templateFile: path.resolve(__dirname, './template/types.hbs'), | ||
}, | ||
{ | ||
type: 'add', | ||
path: path.resolve(__dirname, '../src/{{kebabCase name}}/demos/basic.tsx'), | ||
templateFile: path.resolve(__dirname, './template/demos/basic.hbs'), | ||
}, | ||
{ | ||
type: 'add', | ||
path: path.resolve(__dirname, '../src/{{kebabCase name}}/__tests__/{{pascalCase name}}.spec.tsx'), | ||
templateFile: path.resolve(__dirname, './template/__tests__/index.spec.hbs'), | ||
}, | ||
{ | ||
type: 'append', | ||
path: path.resolve(__dirname, '../src/index.ts'), | ||
pattern: '/* PLOP_INJECT_EXPORT */', | ||
template: "export { default as {{pascalCase name}} } from './{{kebabCase name}}'", | ||
}, | ||
{ | ||
type: 'append', | ||
path: path.resolve(__dirname, '../.umirc.ts'), | ||
pattern: '/* PLOP_INJECT_MD */', | ||
template: "'/components/{{kebabCase name}}.md',", | ||
}, | ||
], | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import {{pascalCase name}} from '../index'; | ||
|
||
describe('{{pascalCase name}}', () => { | ||
it('renders without error', () => { | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import { {{pascalCase name}}Props } from './{{camelCase name}}Types'; | ||
|
||
const defaultProps = { | ||
|
||
}; | ||
|
||
const {{pascalCase name}}: React.FC<{{pascalCase name}}Props> = userProps => { | ||
const props = { ...defaultProps, ...userProps }; | ||
|
||
return <>{{pascalCase name}}</>; | ||
}; | ||
|
||
export default {{pascalCase name}}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from 'react'; | ||
import {{pascalCase name}} from '../{{pascalCase name}}'; | ||
|
||
export default () => ( | ||
<{{pascalCase name}} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# {{pascalCase name}} {{CN}} | ||
|
||
{{description}} | ||
|
||
## 代码演示 | ||
|
||
### 基本用法 | ||
|
||
<code src="../../src/{{kebabCase name}}/demos/basic.tsx"></code> | ||
|
||
|
||
<API src="../../src/{{kebabCase name}}/{{pascalCase name}}.tsx"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './{{camelCase name}}Types'; | ||
|
||
export { default } from './{{pascalCase name}}'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './index.less'; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface {{pascalCase name}}Props { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# 组件们 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Button | ||
|
||
基础按钮 | ||
|
||
## 代码演示 | ||
|
||
### 基本用法 | ||
|
||
<code src="../../src/button/demos/basic.tsx"></code> | ||
|
||
|
||
<API src="../../src/button/Button.tsx"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# PopupBox 弹窗 | ||
|
||
测试gen脚本 | ||
|
||
## 代码演示 | ||
|
||
### 基本用法 | ||
|
||
<code src="../../src/popup-box/demos/basic.tsx"></code> | ||
|
||
|
||
<API src="../../src/popup-box/PopupBox.tsx"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# 贡献指南 | ||
|
||
|
||
## Install | ||
```bash | ||
|
||
``` | ||
|
||
## Pull Request | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 介绍 | ||
|
||
基于 typescript 的 React 组件库 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# quick start | ||
|
||
## Install | ||
|
||
```bash | ||
|
||
npm i -S k-view-react | ||
|
||
``` | ||
|
||
|
||
## Usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,15 @@ | |
"description": "", | ||
"typings": "lib/index.d.ts", | ||
"main": "lib/index.js", | ||
"module": "es/index.js", | ||
"authors": { | ||
"name": "cgj", | ||
"email": "[email protected]" | ||
}, | ||
"files": [ | ||
"lib", | ||
"es" | ||
], | ||
"scripts": { | ||
"dev": "dumi dev", | ||
"build:preview": "npm run build:site && serve site", | ||
|
@@ -15,7 +24,8 @@ | |
"commit": "git add . && git-cz", | ||
"test": "jest --coverage", | ||
"test:watch": "jest --watch", | ||
"test:update": "jest --updateSnapshot" | ||
"test:update": "jest --updateSnapshot", | ||
"gen": "node --experimental-loader esbuild-node-loader .plop/index.ts" | ||
}, | ||
"author": "cgj", | ||
"license": "MIT", | ||
|
@@ -39,6 +49,9 @@ | |
"cross-env": "^7.0.3", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"dumi": "^1.1.42", | ||
"esbuild": "^0.14.39", | ||
"esbuild-node-loader": "^0.8.0", | ||
"esmo": "^0.16.3", | ||
"gh-pages": "^4.0.0", | ||
"git-cz": "^4.9.0", | ||
"gulp": "^4.0.2", | ||
|
@@ -51,12 +64,14 @@ | |
"jest": "^28.1.0", | ||
"jest-environment-jsdom": "^28.1.0", | ||
"lint-staged": "^12.4.1", | ||
"plop": "^3.1.0", | ||
"prettier": "^2.6.2", | ||
"react": "^18.1.0", | ||
"react-dom": "^18.1.0", | ||
"serve": "^13.0.2", | ||
"through2": "^4.0.2", | ||
"ts-jest": "^28.0.2", | ||
"ts-node": "^10.8.0", | ||
"typescript": "^4.6.4" | ||
}, | ||
"sideEffects": [ | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export { default as Button } from './button/Button' | ||
export { default as Button } from './button/Button' | ||
/* PLOP_INJECT_EXPORT */ | ||
export { default as PopupBox } from './popup-box' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import { PopupBoxProps } from './popupBoxTypes'; | ||
|
||
const defaultProps = { | ||
|
||
}; | ||
|
||
const PopupBox: React.FC<PopupBoxProps> = userProps => { | ||
const props = { ...defaultProps, ...userProps }; | ||
|
||
return <>PopupBox</>; | ||
}; | ||
|
||
export default PopupBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import PopupBox from '../index'; | ||
|
||
describe('PopupBox', () => { | ||
it('renders without error', () => { | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from 'react'; | ||
import PopupBox from '../PopupBox'; | ||
|
||
export default () => ( | ||
<PopupBox /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './popupBoxTypes'; | ||
|
||
export { default } from './PopupBox'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface PopupBoxProps { | ||
|
||
} |
Empty file.
Oops, something went wrong.