diff --git a/README.md b/README.md index d58d4fc..101392c 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,7 @@ Creates a UmiJS application/plugin/block/library using the command line. -[![codecov](https://codecov.io/gh/umijs/create-umi/branch/master/graph/badge.svg)](https://codecov.io/gh/umijs/create-umi) -[![NPM version](https://img.shields.io/npm/v/create-umi.svg?style=flat)](https://npmjs.org/package/create-umi) -[![CircleCI](https://circleci.com/gh/umijs/create-umi/tree/master.svg?style=svg)](https://circleci.com/gh/umijs/create-umi/tree/master) -[![NPM downloads](http://img.shields.io/npm/dm/create-umi.svg?style=flat)](https://npmjs.org/package/create-umi) -[![GitHub Actions status](https://github.com/umijs/create-umi/workflows/Node%20CI/badge.svg)](https://github.com/umijs/create-umi) +[![codecov](https://codecov.io/gh/umijs/create-umi/branch/master/graph/badge.svg)](https://codecov.io/gh/umijs/create-umi) [![NPM version](https://img.shields.io/npm/v/create-umi.svg?style=flat)](https://npmjs.org/package/create-umi) [![CircleCI](https://circleci.com/gh/umijs/create-umi/tree/master.svg?style=svg)](https://circleci.com/gh/umijs/create-umi/tree/master) [![NPM downloads](http://img.shields.io/npm/dm/create-umi.svg?style=flat)](https://npmjs.org/package/create-umi) [![GitHub Actions status](https://github.com/umijs/create-umi/workflows/Node%20CI/badge.svg)](https://github.com/umijs/create-umi) ## Usage @@ -16,11 +12,9 @@ $ yarn create umi [appName] ## Boilerplates -* `ant-design-pro` - Create project with a layout-only ant-design-pro boilerplate, use together with umi block. -* `app ` - Create project with a simple boilerplate, support typescript. -* `block ` - Create a umi block. -* `library ` - Create a library with umi. -* `plugin ` - Create a umi plugin. +- `ant-design-pro` - Create project with a layout-only ant-design-pro boilerplate, use together with umi block. +- `app` - Create project with a simple boilerplate, support typescript. +- `plugin` - Create a umi plugin. ## Usage Example @@ -30,8 +24,6 @@ $ yarn create umi ? Select the boilerplate type (Use arrow keys) ant-design-pro - Create project with a layout-only ant-design-pro boilerplate, use together with umi block. ❯ app - Create project with a simple boilerplate, support typescript. - block - Create a umi block. - library - Create a library with umi. plugin - Create a umi plugin. ? Do you want to use typescript? (y/N) diff --git a/jest.config.js b/jest.config.js index ef0ab76..26f73be 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,15 +1,6 @@ module.exports = { - setupFilesAfterEnv: [ - './test/jest.setup.js' - ], - modulePathIgnorePatterns: [ - "/.*/templates", - ], - testPathIgnorePatterns: [ - "/lib/" - ], - collectCoverageFrom: [ - '!lib/**/templates/**', - 'lib/**/*.{js.ts}', - ], -} + setupFilesAfterEnv: ['./test/jest.setup.js'], + modulePathIgnorePatterns: ['/.*/templates'], + testPathIgnorePatterns: ['/lib/'], + collectCoverageFrom: ['!lib/**/templates/**', 'lib/**/*.{js.ts}'], +}; diff --git a/lib/generators/block/index.js b/lib/generators/block/index.js deleted file mode 100644 index ca2f791..0000000 --- a/lib/generators/block/index.js +++ /dev/null @@ -1,56 +0,0 @@ -const BasicGenerator = require('../../BasicGenerator'); - -class Generator extends BasicGenerator { - prompting() { - const prompts = [ - { - name: 'name', - message: `What's the block name?`, - default: this.name, - }, - { - name: 'description', - message: `What's your block description?`, - }, - { - name: 'mail', - message: `What's your email?`, - }, - { - name: 'author', - message: `What's your name?`, - }, - { - name: 'repo', - message: `Which repo is your block stored under github?`, - default: 'umijs/umi-blocks', - }, - { - name: 'isTypeScript', - type: 'confirm', - message: 'Do you want to use typescript?', - default: false, - }, - ]; - return this.prompt(prompts).then(props => { - this.prompts = props; - }); - } - - writing() { - this.writeFiles({ - context: this.prompts, - filterFiles: f => { - const { isTypeScript } = this.prompts; - if (isTypeScript) { - if (f.endsWith('.js')) return false; - } else { - if (this.isTsFile(f)) return false; - } - return true; - }, - }); - } -} - -module.exports = Generator; diff --git a/lib/generators/block/meta.json b/lib/generators/block/meta.json deleted file mode 100644 index 1e2801a..0000000 --- a/lib/generators/block/meta.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "description": "Create a umi block." -} diff --git a/lib/generators/block/templates/.prettierignore b/lib/generators/block/templates/.prettierignore deleted file mode 100644 index 2098c78..0000000 --- a/lib/generators/block/templates/.prettierignore +++ /dev/null @@ -1,7 +0,0 @@ -**/*.md -**/*.svg -**/*.ejs -**/*.html -package.json -.umi -.umi-production diff --git a/lib/generators/block/templates/.prettierrc b/lib/generators/block/templates/.prettierrc deleted file mode 100644 index d3698d4..0000000 --- a/lib/generators/block/templates/.prettierrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "all", - "printWidth": 100, - "overrides": [ - { - "files": ".prettierrc", - "options": { "parser": "json" } - } - ] -} diff --git a/lib/generators/block/templates/.umirc.js b/lib/generators/block/templates/.umirc.js deleted file mode 100644 index ade529c..0000000 --- a/lib/generators/block/templates/.umirc.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - plugins: [ - ['umi-plugin-block-dev', {}], - ], -} diff --git a/lib/generators/block/templates/.umirc.ts b/lib/generators/block/templates/.umirc.ts deleted file mode 100644 index c725816..0000000 --- a/lib/generators/block/templates/.umirc.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { IConfig } from 'umi-types'; - -const config: IConfig = { - plugins: [ - ['umi-plugin-block-dev', {}], - ], -} - -export default config; diff --git a/lib/generators/block/templates/LICENSE b/lib/generators/block/templates/LICENSE deleted file mode 100644 index c44fa56..0000000 --- a/lib/generators/block/templates/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2019-present <%= author %> (<%= mail %>) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/generators/block/templates/README.md b/lib/generators/block/templates/README.md deleted file mode 100644 index 1c5b9d0..0000000 --- a/lib/generators/block/templates/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# @umi-material/<%= name %> - -<%= description %> - -## Usage - -```sh -umi block https://github.com/<%= repo %>/tree/master/<%= name %> -``` - -## LICENSE - -MIT diff --git a/lib/generators/block/templates/_gitignore b/lib/generators/block/templates/_gitignore deleted file mode 100644 index 3f9b7a3..0000000 --- a/lib/generators/block/templates/_gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/yarn.lock -/package-lock.json -/dist -/node_modules -/pages -.umi -.umi-production diff --git a/lib/generators/block/templates/package.json b/lib/generators/block/templates/package.json deleted file mode 100644 index 82df3e9..0000000 --- a/lib/generators/block/templates/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@umi-block/<%= name %>", - "version": "0.0.1", - "description": "<%= description %>", - "main": "src/index.js", - "authors": { - "name": "<%= author %>", - "email": "<%= mail %>" - }, - "repository": "<%= repo %>/<%= name %>", - "scripts": { - "dev": "umi dev" - }, - "dependencies": { - "react": ">=16.0.0" - }, - "devDependencies": { - "umi": "^2.9.0", -<% if (isTypeScript) { -%> - "umi-plugin-block-dev": "^2.0.0", - "umi-types": "^0.3.0" -<% } else { -%> - "umi-plugin-block-dev": "^2.0.0" -<% } -%> - }, - "license": "MIT" -} diff --git a/lib/generators/block/templates/src/index.css b/lib/generators/block/templates/src/index.css deleted file mode 100644 index f604f20..0000000 --- a/lib/generators/block/templates/src/index.css +++ /dev/null @@ -1,3 +0,0 @@ -.normal { - background: #79F2AA; -} diff --git a/lib/generators/block/templates/src/index.js b/lib/generators/block/templates/src/index.js deleted file mode 100644 index a58be89..0000000 --- a/lib/generators/block/templates/src/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import styles from './index.css'; - -export default function() { - return ( -
-

I am a umi block!

-
- ); -} diff --git a/lib/generators/block/templates/src/index.tsx b/lib/generators/block/templates/src/index.tsx deleted file mode 100644 index 3c04a60..0000000 --- a/lib/generators/block/templates/src/index.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import styles from './index.css'; - -const Block: React.FC = () => { - return ( -
-

I am a umi block!

-
- ); -} - -export default Block; diff --git a/lib/generators/block/templates/tsconfig.json b/lib/generators/block/templates/tsconfig.json deleted file mode 100644 index 32b6637..0000000 --- a/lib/generators/block/templates/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext", - "module": "esnext", - "moduleResolution": "node", - "importHelpers": true, - "jsx": "react", - "esModuleInterop": true, - "sourceMap": true, - "baseUrl": ".", - "strict": true, - "paths": { - "@/*": ["src/*"], - "@tmp/*": ["src/pages/.umi/*"] - }, - "allowSyntheticDefaultImports": true - } -} diff --git a/lib/generators/block/templates/typings.d.ts b/lib/generators/block/templates/typings.d.ts deleted file mode 100644 index b0ac6c6..0000000 --- a/lib/generators/block/templates/typings.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -declare module '*.css'; -declare module "*.png"; diff --git a/lib/generators/library/index.js b/lib/generators/library/index.js deleted file mode 100644 index 9b08fad..0000000 --- a/lib/generators/library/index.js +++ /dev/null @@ -1,55 +0,0 @@ -const BasicGenerator = require('../../BasicGenerator'); - -class Generator extends BasicGenerator { - prompting() { - const prompts = [ - { - name: 'name', - message: `What's the library name?`, - default: this.name, - }, - { - name: 'description', - message: `What's your library description?`, - }, - { - name: 'mail', - message: `What's your email?`, - }, - { - name: 'author', - message: `What's your name?`, - }, - { - name: 'repo', - message: `Which repo is your library stored under github?`, - }, - { - name: 'isTypeScript', - type: 'confirm', - message: 'Do you want to use typescript?', - default: false, - }, - ]; - return this.prompt(prompts).then(props => { - this.prompts = props; - }); - } - - writing() { - this.writeFiles({ - context: this.prompts, - filterFiles: f => { - const { isTypeScript } = this.prompts; - if (isTypeScript) { - if (f.endsWith('.js')) return false; - } else { - if (this.isTsFile(f)) return false; - } - return true; - }, - }); - } -} - -module.exports = Generator; diff --git a/lib/generators/library/meta.json b/lib/generators/library/meta.json deleted file mode 100644 index bad2f16..0000000 --- a/lib/generators/library/meta.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "description": "Create a library with umi." -} diff --git a/lib/generators/library/templates/.fatherrc.js b/lib/generators/library/templates/.fatherrc.js deleted file mode 100644 index bb3384c..0000000 --- a/lib/generators/library/templates/.fatherrc.js +++ /dev/null @@ -1,4 +0,0 @@ -export default { - cjs: 'rollup', - esm: 'rollup', -} diff --git a/lib/generators/library/templates/.fatherrc.ts b/lib/generators/library/templates/.fatherrc.ts deleted file mode 100644 index 963b2be..0000000 --- a/lib/generators/library/templates/.fatherrc.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { IBundleOptions } from 'father'; - -const options: IBundleOptions = { - cjs: 'rollup', - esm: 'rollup', - doc: { typescript: true }, -}; - -export default options; diff --git a/lib/generators/library/templates/.prettierignore b/lib/generators/library/templates/.prettierignore deleted file mode 100644 index 6c5a2ed..0000000 --- a/lib/generators/library/templates/.prettierignore +++ /dev/null @@ -1,5 +0,0 @@ -**/*.md -**/*.mdx -package.json -.umi -.umi-production diff --git a/lib/generators/library/templates/.prettierrc b/lib/generators/library/templates/.prettierrc deleted file mode 100644 index d3698d4..0000000 --- a/lib/generators/library/templates/.prettierrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "all", - "printWidth": 100, - "overrides": [ - { - "files": ".prettierrc", - "options": { "parser": "json" } - } - ] -} diff --git a/lib/generators/library/templates/LICENSE b/lib/generators/library/templates/LICENSE deleted file mode 100644 index c44fa56..0000000 --- a/lib/generators/library/templates/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2019-present <%= author %> (<%= mail %>) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/lib/generators/library/templates/README.md b/lib/generators/library/templates/README.md deleted file mode 100644 index 1c5b9d0..0000000 --- a/lib/generators/library/templates/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# @umi-material/<%= name %> - -<%= description %> - -## Usage - -```sh -umi block https://github.com/<%= repo %>/tree/master/<%= name %> -``` - -## LICENSE - -MIT diff --git a/lib/generators/library/templates/_gitignore b/lib/generators/library/templates/_gitignore deleted file mode 100644 index cfc9c40..0000000 --- a/lib/generators/library/templates/_gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/yarn.lock -/package-lock.json -/dist -/.docz -/node_modules diff --git a/lib/generators/library/templates/package.json b/lib/generators/library/templates/package.json deleted file mode 100644 index a474773..0000000 --- a/lib/generators/library/templates/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "<%= name %>", - "version": "0.0.1", - "description": "<%= description %>", - "main": "dist/index.js", - "module": "dist/index.esm.js", - "authors": { - "name": "<%= author %>", - "email": "<%= mail %>" - }, - "repository": "<%= repo %>/<%= name %>", - "scripts": { - "dev": "father doc dev", - "build": "father build" - }, - "peerDependencies": { - "react": "16.x" - }, - "devDependencies": { -<% if (isTypeScript) { -%> - "father": "^2.16.0", - "typescript": "^3.3.3" -<% } else { -%> - "father": "^2.16.0" -<% } -%> - }, - "license": "MIT" -} diff --git a/lib/generators/library/templates/src/index.css b/lib/generators/library/templates/src/index.css deleted file mode 100644 index 72df5c6..0000000 --- a/lib/generators/library/templates/src/index.css +++ /dev/null @@ -1,4 +0,0 @@ - -.button { - color: red; -} diff --git a/lib/generators/library/templates/src/index.js b/lib/generators/library/templates/src/index.js deleted file mode 100644 index 9bc871c..0000000 --- a/lib/generators/library/templates/src/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; -import styles from './index.css'; - -export default function(props) { - return ( - - ); -} diff --git a/lib/generators/library/templates/src/index.mdx b/lib/generators/library/templates/src/index.mdx deleted file mode 100644 index a601163..0000000 --- a/lib/generators/library/templates/src/index.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: Home -route: / -order: -1 -sidebar: true ---- - -import Button from './'; - -# Button Component - -## Normal Button - - - -## Large Button - - diff --git a/lib/generators/library/templates/src/index.tsx b/lib/generators/library/templates/src/index.tsx deleted file mode 100644 index 703aa65..0000000 --- a/lib/generators/library/templates/src/index.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react'; -import styles from './index.css'; - -export interface ButtonProps { - size?: 'large' | 'default'; -} - -const Button: React.FC = function(props) { - return ( - - ); -}; - -export default Button; diff --git a/lib/generators/library/templates/tsconfig.json b/lib/generators/library/templates/tsconfig.json deleted file mode 100644 index 67d3bdf..0000000 --- a/lib/generators/library/templates/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext", - "module": "esnext", - "moduleResolution": "node", - "importHelpers": true, - "jsx": "react", - "esModuleInterop": true, - "sourceMap": true, - "baseUrl": ".", - "strict": true, - "paths": { - "@/*": ["src/*"] - }, - "allowSyntheticDefaultImports": true - } -} diff --git a/lib/generators/library/templates/typings.d.ts b/lib/generators/library/templates/typings.d.ts deleted file mode 100644 index b0ac6c6..0000000 --- a/lib/generators/library/templates/typings.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -declare module '*.css'; -declare module "*.png"; diff --git a/test/__snapshots__/index.test.js.snap b/test/__snapshots__/index.test.js.snap index 77926f7..f5cbead 100644 --- a/test/__snapshots__/index.test.js.snap +++ b/test/__snapshots__/index.test.js.snap @@ -6,9 +6,7 @@ exports[`test umi-create test generate antd pro project from gitee.org 1`] = ` , use together with umi block. app - Create project with a simple boilerplate, support typescript . - block - Create a umi block. - library - Create a library with umi. - plugin - Create a umi plugin. ? Select the boilerplate type ant-design-pro + plugin - Create a umi plugin. ? Select the boilerplate type ant-design-pro ? 🧙 Be the first to experience the new umi@3 ? (Use arrow keys) Pro V5 ❯ Pro V4 ? 🧙 Be the first to experience the new umi@3 ? Pro V4 @@ -33,9 +31,7 @@ exports[`test umi-create test generate antd pro project from github 1`] = ` , use together with umi block. app - Create project with a simple boilerplate, support typescript . - block - Create a umi block. - library - Create a library with umi. - plugin - Create a umi plugin. ? Select the boilerplate type ant-design-pro + plugin - Create a umi plugin. ? Select the boilerplate type ant-design-pro ? 🧙 Be the first to experience the new umi@3 ? (Use arrow keys) Pro V5 ❯ Pro V4 ? 🧙 Be the first to experience the new umi@3 ? Pro V4