first commit
This commit is contained in:
1
vant/packages/create-vant-cli-app/.pydio
Normal file
1
vant/packages/create-vant-cli-app/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
4a848747-b0de-4fe8-a636-8aecb24ee3de
|
||||
1
vant/packages/create-vant-cli-app/generators/.pydio
Normal file
1
vant/packages/create-vant-cli-app/generators/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
d6d89bb3-9916-4e8d-ac56-a3bd71552b71
|
||||
@@ -0,0 +1 @@
|
||||
4a93d437-eba6-40ec-b788-2528b7d4220a
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
presets: ['@vant/cli/preset'],
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
c6aef35f-69ff-4e94-a2c6-bcad4032480c
|
||||
@@ -0,0 +1,11 @@
|
||||
# 介绍
|
||||
|
||||
### 关于
|
||||
|
||||
这是一段组件库的介绍
|
||||
|
||||
### 特性
|
||||
|
||||
- 特性一
|
||||
- 特性二
|
||||
- 特性三
|
||||
@@ -0,0 +1,11 @@
|
||||
# 快速上手
|
||||
|
||||
### 安装
|
||||
|
||||
```bash
|
||||
# 通过 npm 安装
|
||||
npm i <%= name %> -S
|
||||
|
||||
# 通过 yarn 安装
|
||||
yarn add <%= name %>
|
||||
```
|
||||
@@ -0,0 +1,4 @@
|
||||
es
|
||||
lib
|
||||
dist
|
||||
node_modules
|
||||
@@ -0,0 +1,17 @@
|
||||
*.log*
|
||||
.cache
|
||||
.DS_Store
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
# npm
|
||||
node_modules
|
||||
package-lock.json
|
||||
|
||||
# dist file
|
||||
es
|
||||
lib
|
||||
site
|
||||
|
||||
# test
|
||||
test/coverage
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"name": "<%= name %>",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "lib/<%= name %>.js",
|
||||
"style": "lib/index.css",
|
||||
"files": [
|
||||
"lib",
|
||||
"es"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "vant-cli dev",
|
||||
"test": "vant-cli test",
|
||||
"lint": "vant-cli lint",
|
||||
"build": "vant-cli build",
|
||||
"release": "vant-cli release",
|
||||
"test:coverage": "open test/coverage/index.html",
|
||||
"build-site": "vant-cli build-site && gh-pages -d site"
|
||||
},
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged",
|
||||
"commit-msg": "vant-cli commit-lint"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,tsx,js,jsx,vue}": [
|
||||
"eslint --fix",
|
||||
"git add"
|
||||
],
|
||||
"*.{vue,css,less,scss}": [
|
||||
"stylelint --fix",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "^2.6.11",
|
||||
"vue-template-compiler": "^2.6.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vant/cli": "^2.0.0",
|
||||
"babel-plugin-import": "^1.13.0",
|
||||
"vue": "^2.6.11",
|
||||
"vue-template-compiler": "^2.6.11"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
"extends": [
|
||||
"@vant"
|
||||
]
|
||||
},
|
||||
"stylelint": {
|
||||
"extends": [
|
||||
"@vant/stylelint-config"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true
|
||||
},
|
||||
"browserslist": [
|
||||
"Android >= 4.0",
|
||||
"iOS >= 8"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
1f7b797d-f8bb-4eec-9206-309003f22b93
|
||||
@@ -0,0 +1 @@
|
||||
e3e24d50-1d42-4639-afaa-bc6d9312d493
|
||||
@@ -0,0 +1,43 @@
|
||||
# DemoButton 按钮
|
||||
|
||||
### 介绍
|
||||
|
||||
DemoButton 是一个示例按钮组件
|
||||
|
||||
### 引入
|
||||
|
||||
```js
|
||||
import Vue from 'vue';
|
||||
import { DemoButton } from '<%= name %>';
|
||||
|
||||
Vue.use(DemoButton);
|
||||
```
|
||||
|
||||
## 代码演示
|
||||
|
||||
### 基础用法
|
||||
|
||||
```html
|
||||
<demo-button type="primary" />
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### Props
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|------|------|------|------|
|
||||
| type | 按钮类型 | *string* | `primary` |
|
||||
| color `1.0.0` | 按钮颜色 | *string* | - |
|
||||
|
||||
### Events
|
||||
|
||||
| 事件名 | 说明 | 回调参数 |
|
||||
|------|------|------|
|
||||
| click | 点击时触发 | event: Event |
|
||||
|
||||
### Slots
|
||||
|
||||
| 名称 | 说明 |
|
||||
|------|------|
|
||||
| default | 默认插槽 |
|
||||
@@ -0,0 +1 @@
|
||||
22dc34dc-e3e8-43b5-99e2-ea9aab9bcc4d
|
||||
@@ -0,0 +1,11 @@
|
||||
<template>
|
||||
<demo-section>
|
||||
<demo-block title="基础用法">
|
||||
<demo-button type="primary" style="margin-left: 15px;">按钮</demo-button>
|
||||
</demo-block>
|
||||
|
||||
<demo-block title="自定义颜色">
|
||||
<demo-button color="#03a9f4" style="margin-left: 15px;">按钮</demo-button>
|
||||
</demo-block>
|
||||
</demo-section>
|
||||
</template>
|
||||
@@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<button class="demo-button">
|
||||
<slot />
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'demo-button',
|
||||
|
||||
props: {
|
||||
color: String,
|
||||
type: {
|
||||
type: String,
|
||||
default: 'primary',
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="<%= cssLang %>">
|
||||
.demo-button {
|
||||
min-width: 120px;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
line-height: 36px;
|
||||
background-color: #f44;
|
||||
border: none;
|
||||
border-radius: 30px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1 @@
|
||||
880a5847-13d7-4fb0-957c-9b1f9cb9c050
|
||||
@@ -0,0 +1 @@
|
||||
5792c86b-75c0-4d46-9475-ae7c5aa63be4
|
||||
@@ -0,0 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`render demo button 1`] = `<button class="demo-button"></button>`;
|
||||
@@ -0,0 +1,7 @@
|
||||
import { mount } from '@vue/test-utils';
|
||||
import DemoButton from '..';
|
||||
|
||||
test('render demo button', () => {
|
||||
const wrapper = mount(DemoButton);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
module.exports = {
|
||||
name: '<%= name %>',
|
||||
build: {
|
||||
css: {
|
||||
preprocessor: '<%= preprocessor %>',
|
||||
},
|
||||
site: {
|
||||
publicPath: '/<%= name %>/',
|
||||
},
|
||||
},
|
||||
site: {
|
||||
title: '<%= name %>',
|
||||
logo: 'https://img.yzcdn.cn/vant/logo.png',
|
||||
nav: [
|
||||
{
|
||||
title: '开发指南',
|
||||
items: [
|
||||
{
|
||||
path: 'home',
|
||||
title: '介绍',
|
||||
},
|
||||
{
|
||||
path: 'quickstart',
|
||||
title: '快速上手',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '基础组件',
|
||||
items: [
|
||||
{
|
||||
path: 'demo-button',
|
||||
title: 'DemoButton 按钮',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
45
vant/packages/create-vant-cli-app/package.json
Normal file
45
vant/packages/create-vant-cli-app/package.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "create-vant-cli-app",
|
||||
"version": "0.1.1",
|
||||
"description": "Create Vant Cli App",
|
||||
"main": "lib/index.js",
|
||||
"bin": {
|
||||
"create-vant-cli-app": "./lib/index.js"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "tsc --watch",
|
||||
"release": "tsc & release-it"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/youzan/vant/tree/dev/packages/create-vant-cli-app"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"generators"
|
||||
],
|
||||
"keywords": [
|
||||
"vant"
|
||||
],
|
||||
"author": "chenjiahan",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^8.0.1",
|
||||
"@types/yeoman-generator": "^3.1.4",
|
||||
"release-it": "^12.4.3",
|
||||
"typescript": "^3.7.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^3.0.0",
|
||||
"consola": "^2.11.3",
|
||||
"fs-extra": "^8.1.0",
|
||||
"inquirer": "^7.0.3",
|
||||
"yeoman-generator": "^4.4.0"
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
"tag": false,
|
||||
"commitMessage": "chore: release create-vant-cli-app@${version}"
|
||||
}
|
||||
}
|
||||
}
|
||||
1
vant/packages/create-vant-cli-app/src/.pydio
Normal file
1
vant/packages/create-vant-cli-app/src/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
581186e1-63af-4a90-a85a-f0f17ad1c9b7
|
||||
4
vant/packages/create-vant-cli-app/src/constant.ts
Normal file
4
vant/packages/create-vant-cli-app/src/constant.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { join } from 'path';
|
||||
|
||||
export const CWD = process.cwd();
|
||||
export const GENERATOR_DIR = join(__dirname, '../generators');
|
||||
92
vant/packages/create-vant-cli-app/src/generator.ts
Normal file
92
vant/packages/create-vant-cli-app/src/generator.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
import chalk from 'chalk';
|
||||
import consola from 'consola';
|
||||
import { join } from 'path';
|
||||
import { CWD, GENERATOR_DIR } from './constant';
|
||||
import Generator from 'yeoman-generator';
|
||||
|
||||
const TEMPLATES = join(GENERATOR_DIR, 'templates');
|
||||
const PROMPTS = [
|
||||
{
|
||||
name: 'preprocessor',
|
||||
message: 'Select css preprocessor',
|
||||
type: 'list',
|
||||
choices: ['Less', 'Sass'],
|
||||
},
|
||||
];
|
||||
|
||||
export class VanGenerator extends Generator {
|
||||
inputs = {
|
||||
name: '',
|
||||
cssLang: '',
|
||||
preprocessor: '',
|
||||
};
|
||||
|
||||
constructor(name: string) {
|
||||
super([], {
|
||||
env: {
|
||||
cwd: join(CWD, name),
|
||||
},
|
||||
resolved: GENERATOR_DIR,
|
||||
});
|
||||
|
||||
this.inputs.name = name;
|
||||
}
|
||||
|
||||
async prompting() {
|
||||
return this.prompt<Record<string, string>>(PROMPTS).then(inputs => {
|
||||
const preprocessor = inputs.preprocessor.toLowerCase();
|
||||
const cssLang = preprocessor === 'sass' ? 'scss' : preprocessor;
|
||||
|
||||
this.inputs.cssLang = cssLang;
|
||||
this.inputs.preprocessor = preprocessor;
|
||||
});
|
||||
}
|
||||
|
||||
writing() {
|
||||
consola.info(`Creating project in ${join(CWD, this.inputs.name)}\n`);
|
||||
|
||||
const copy = (from: string, to?: string) => {
|
||||
this.fs.copy(join(TEMPLATES, from), this.destinationPath(to || from));
|
||||
};
|
||||
|
||||
const copyTpl = (from: string, to?: string) => {
|
||||
this.fs.copyTpl(
|
||||
join(TEMPLATES, from),
|
||||
this.destinationPath(to || from),
|
||||
this.inputs
|
||||
);
|
||||
};
|
||||
|
||||
copyTpl('package.json.tpl', 'package.json');
|
||||
copyTpl('vant.config.js');
|
||||
copyTpl('src/**/*', 'src');
|
||||
copyTpl('docs/**/*', 'docs');
|
||||
copy('babel.config.js');
|
||||
copy('gitignore.tpl', '.gitignore');
|
||||
copy('eslintignore.tpl', '.eslintignore');
|
||||
}
|
||||
|
||||
install() {
|
||||
console.log();
|
||||
consola.info('Install dependencies...\n');
|
||||
|
||||
process.chdir(this.inputs.name);
|
||||
|
||||
this.installDependencies({
|
||||
npm: false,
|
||||
bower: false,
|
||||
yarn: true,
|
||||
skipMessage: true,
|
||||
});
|
||||
}
|
||||
|
||||
end() {
|
||||
const { name } = this.inputs;
|
||||
|
||||
console.log();
|
||||
consola.success(`Successfully created ${chalk.yellow(name)}.`);
|
||||
consola.success(
|
||||
`Run ${chalk.yellow(`cd ${name} && yarn dev`)} to start development!`
|
||||
);
|
||||
}
|
||||
}
|
||||
24
vant/packages/create-vant-cli-app/src/index.ts
Normal file
24
vant/packages/create-vant-cli-app/src/index.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import inquirer from 'inquirer';
|
||||
import { ensureDir } from 'fs-extra';
|
||||
import { VanGenerator } from './generator';
|
||||
|
||||
const PROMPTS = [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'Your package name',
|
||||
},
|
||||
];
|
||||
|
||||
export default async function run() {
|
||||
const { name } = await inquirer.prompt(PROMPTS);
|
||||
|
||||
ensureDir(name);
|
||||
|
||||
const generator = new VanGenerator(name);
|
||||
generator.run();
|
||||
}
|
||||
|
||||
run();
|
||||
13
vant/packages/create-vant-cli-app/tsconfig.json
Normal file
13
vant/packages/create-vant-cli-app/tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2017",
|
||||
"outDir": "./lib",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["esnext"]
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
3379
vant/packages/create-vant-cli-app/yarn.lock
Normal file
3379
vant/packages/create-vant-cli-app/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user