Commit 75888856 authored by super-lin0's avatar super-lin0

package init

parent 6b946183
Pipeline #155 canceled with stages
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;
{
"description": "Create a umi block."
}
**/*.md
**/*.svg
**/*.ejs
**/*.html
package.json
.umi
.umi-production
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100,
"overrides": [
{
"files": ".prettierrc",
"options": { "parser": "json" }
}
]
}
export default {
plugins: [
['umi-plugin-block-dev', {}],
],
}
import { IConfig } from 'umi-types';
const config: IConfig = {
plugins: [
['umi-plugin-block-dev', {}],
],
}
export default config;
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.
# @umi-material/<%= name %>
<%= description %>
## Usage
```sh
umi block https://github.com/<%= repo %>/tree/master/<%= name %>
```
## LICENSE
MIT
/yarn.lock
/package-lock.json
/dist
/node_modules
/pages
.umi
.umi-production
{
"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"
}
import styles from './index.css';
export default function() {
return (
<div className={styles.normal}>
<h1>I am a umi block!</h1>
</div>
);
}
import React from 'react';
import styles from './index.css';
const Block: React.FC = () => {
return (
<div className={styles.normal}>
<h1>I am a umi block!</h1>
</div>
);
}
export default Block;
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"jsx": "react",
"esModuleInterop": true,
"sourceMap": true,
"baseUrl": ".",
"strict": true,
"paths": {
"@/*": ["src/*"]
},
"allowSyntheticDefaultImports": true
}
}
declare module '*.css';
declare module "*.png";
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;
{
"description": "Create a library with umi."
}
export default {
cjs: 'rollup',
esm: 'rollup',
}
import { IBundleOptions } from 'father';
const options: IBundleOptions = {
cjs: 'rollup',
esm: 'rollup',
doc: { typescript: true },
};
export default options;
**/*.md
**/*.mdx
package.json
.umi
.umi-production
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100,
"overrides": [
{
"files": ".prettierrc",
"options": { "parser": "json" }
}
]
}
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.
# @umi-material/<%= name %>
<%= description %>
## Usage
```sh
umi block https://github.com/<%= repo %>/tree/master/<%= name %>
```
## LICENSE
MIT
/yarn.lock
/package-lock.json
/dist
/.docz
/node_modules
{
"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"
}
import React from 'react';
import styles from './index.css';
export default function(props) {
return (
<button
className={styles.button}
style={{
fontSize: props.size === 'large' ? 40 : 20,
}}
>
{ props.children }
</button>
);
}
---
name: Home
route: /
order: -1
sidebar: true
---
import Button from './';
# Button Component
## Normal Button
<Button>Hi</Button>
## Large Button
<Button size="large">Hi</Button>
import React from 'react';
import styles from './index.css';
export interface ButtonProps {
size?: 'large' | 'default';
}
const Button: React.FC<ButtonProps> = function(props) {
return (
<button
className={styles.button}
style={{
fontSize: props.size === 'large' ? 40 : 20,
}}
>
{props.children}
</button>
);
};
export default Button;
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"jsx": "react",
"esModuleInterop": true,
"sourceMap": true,
"baseUrl": ".",
"strict": true,
"paths": {
"@/*": ["src/*"]
},
"allowSyntheticDefaultImports": true
}
}
declare module '*.css';
declare module "*.png";
const BasicGenerator = require('../../BasicGenerator');
class Generator extends BasicGenerator {
prompting() {
const prompts = [
{
name: 'name',
message: `What's the plugin name?`,
default: this.name,
},
{
name: 'description',
message: `What's your plugin used for?`,
},
{
name: 'mail',
message: `What's your email?`,
},
{
name: 'author',
message: `What's your name?`,
},
{
name: 'org',
message: `Which organization is your plugin stored under github?`,
},
{
name: 'isTypeScript',
type: 'confirm',
message: 'Do you want to use typescript?',
default: false,
},
{
name: 'withUmiUI',
type: 'confirm',
message: 'Does your plugin have ui interaction(umi ui)?',
default: false,
},
];
return this.prompt(prompts).then(props => {
this.prompts = props;
});
}
// lang: ts || js
isUIFiles(file, lang) {
const uiFile = lang === 'ts'
? 'ui/index.tsx'
: 'ui/index.js';
return file === uiFile;
}
writing() {
this.writeFiles({
context: this.prompts,
filterFiles: f => {
const { isTypeScript, withUmiUI } = this.prompts;
if (isTypeScript) {
if (f.endsWith('.js')) return false;
// filter ui files
if (!withUmiUI && this.isUIFiles(f, 'ts')) return false;
} else {
if (this.isTsFile(f)) return false;
// filter ui files
if (!withUmiUI && this.isUIFiles(f)) return false;
}
return true;
},
});
}
}
module.exports = Generator;
{
"description": "Create a umi plugin."
}
\ No newline at end of file
export default [
{
cjs: 'babel',
},
<% if (withUmiUI) { -%>
{
entry: 'ui/index.js',
umd: {
name: '<%= name %>',
minFile: false,
},
},
<% } -%>
];
export default [
{
cjs: 'babel',
},
<% if (withUmiUI) { -%>
{
entry: 'ui/index.tsx',
typescriptOpts: {
check: false,
},
umd: {
name: '<%= name %>',
minFile: false,
},
},
<% } -%>
];
The MIT License (MIT)
Copyright (c) 2018-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.
# umi-plugin-<%= name %>
[![NPM version](https://img.shields.io/npm/v/umi-plugin-<%= name %>.svg?style=flat)](https://npmjs.org/package/umi-plugin-<%= name %>)
[![NPM downloads](http://img.shields.io/npm/dm/umi-plugin-<%= name %>.svg?style=flat)](https://npmjs.org/package/umi-plugin-<%= name %>)
<%= description %>
## Install
```bash
# or yarn
$ npm install
```
## Development UI
UI start:
```bash
$ npm run build --watch
$ npm run start
```
<img src="https://user-images.githubusercontent.com/13595509/67025108-10925980-f138-11e9-8f46-899eef3e098b.png" width="768" />
UI mini start:
```bash
$ npm run build --watch
$ npm run start:mini
```
<img src="https://user-images.githubusercontent.com/13595509/67024897-bbeede80-f137-11e9-9f19-6a3f0ea3f6cd.png" width="768" />
## Usage
Configure in `.umirc.js`,
```js
export default {
plugins: [
['umi-plugin-<%= name %>', options],
],
}
```
## Options
TODO
## LICENSE
MIT
/node_modules
/yarn.lock
/package-lock.json
/example/dist
/example/node_modules
/example/pages/.umi
/example/pages/.umi-production
/lib
<% if (withUmiUI) { -%>
/dist
<% } -%>
import { join } from 'path';
export default {
routes: [
{ path: '/', component: './index' },
],
plugins: [
join(__dirname, '..', require('../package').main || 'index.js'),
],
}
import { join } from 'path';
import { IConfig } from 'umi-types';
export default {
routes: [
{ path: '/', component: './index' },
],
plugins: [
join(__dirname, '..', require('../package').main || 'index.js'),
],
} as IConfig;
declare module '*.css';
declare module '*.less';
import React from 'react';
import styles from './index.css';
export default function() {
return (
<div className={styles.normal}>
<h1>Page index</h1>
</div>
);
}
import React from 'react';
import styles from './index.css';
export default function() {
return (
<div className={styles.normal}>
<h1>Page index</h1>
</div>
);
}
{
"name": "umi-plugin-<%= name %>",
"version": "0.0.1",
"description": "<%= description %>",
"authors": {
"name": "<%= author %>",
"email": "<%= mail %>"
},
"repository": "<%= org %>/<%= name %>",
"peerDependencies": {
<% if (withUmiUI) { -%>
"antd": "4.x",
"react": "^16.8.6",
"react-dom": "^16.8.6",
<% } -%>
"umi": "2.x || ^2.9.0-0"
},
"main": "lib/index.js",
"scripts": {
<% if (withUmiUI) { -%>
"start:mini": "cross-env UMI_UI=1 APP_ROOT=$PWD/example umi dev",
"start": "cross-env CURRENT_PROJECT=example umi ui",
<% } else { -%>
"start": "cross-env APP_ROOT=$PWD/example umi dev",
<% } -%>
"build": "father-build",
"prepublishOnly": "npm run build && np --no-cleanup --yolo --no-publish"
},
"devDependencies": {
"cross-env": "^6.0.3",
"father-build": "^1.8.0",
<% if (withUmiUI) { -%>
"antd": "^4.0.0-alpha.0",
<% } -%>
"np": "^5.0.3",
"umi": "^2.9.0",
"umi-types": "^0.4.0-beta.4"
},
"files": [
<% if (withUmiUI) { -%>
"dist",
<% } -%>
"lib",
"src",
"ui"
],
"license": "MIT"
}
// ref:
// - https://umijs.org/plugin/develop.html
export default function (api, options) {
// Example: output the webpack config
api.chainWebpackConfig(config => {
// console.log(config.toString());
});
<% if (withUmiUI) { -%>
api.addUIPlugin(require.resolve('../dist/index.umd'));
api.onUISocket(({ action, failure, success }) => {
if (action.type === 'org.<%= author %>.<%= name %>.test') {
success({
data: '<%= name %>.test',
});
}
});
<% } %>
}
// ref:
// - https://umijs.org/plugin/develop.html
import { IApi } from 'umi-types';
export default function (api: IApi, options) {
// Example: output the webpack config
api.chainWebpackConfig(config => {
// console.log(config.toString());
});
<% if (withUmiUI) { -%>
api.addUIPlugin(require.resolve('../dist/index.umd'));
api.onUISocket(({ action, failure, success }) => {
if (action.type === 'org.<%= author %>.<%= name %>.test') {
success({
data: '<%= name %>.test',
});
}
});
<% } %>
}
{
"compilerOptions": {
"module": "esnext",
"target": "esnext",
"lib": ["esnext", "dom"],
"sourceMap": true,
"baseUrl": ".",
"jsx": "react",
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"experimentalDecorators": true,
"declaration": false
}
}
import { Button } from 'antd';
export default (api) => {
const { callRemote } = api;
function PluginPanel() {
return (
<div style={{ padding: 20 }}>
<Button
type="primary"
onClick={async () => {
const { data } = await callRemote({
type: 'org.<%= author %>.<%= name %>.test',
});
alert(data);
}}
>Test</Button>
</div>
);
}
api.addPanel({
title: '<%= name %>',
path: '/<%= name %>',
icon: 'home',
component: PluginPanel,
});
}
import { Button } from 'antd';
import { IUiApi } from 'umi-types'
export default (api: IUiApi) => {
const { callRemote } = api;
function PluginPanel() {
return (
<div style={{ padding: 20 }}>
<Button
type="primary"
onClick={async () => {
const { data } = await callRemote({
type: 'org.<%= author %>.<%= name %>.test',
});
alert(data);
}}
>Test</Button>
</div>
);
}
api.addPanel({
title: '<%= name %>',
path: '/<%= name %>',
icon: 'home',
component: PluginPanel,
});
}
{ {
"name": "create-nemean", "name": "create-nemean",
"version": "0.0.22", "version": "0.0.23",
"description": "Creates a UmiJS application using the command line.", "description": "Creates a UmiJS application using the command line.",
"homepage": "https://github.com/umijs/create-umi", "homepage": "https://github.com/umijs/create-umi",
"bugs": { "bugs": {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment