Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add umi vue template #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions lib/generators/vue/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const Generator = require("yeoman-generator");
const { basename } = require("path");
const debug = require("debug")("create-umi");

module.exports = class BasicGenerator extends Generator {
constructor(args, opts) {
super(args, opts);

this.name = basename(process.cwd());
this.props = {};
}

writing() {
debug(`this.name: ${this.name}`);
debug(`this.props: ${JSON.stringify(this.props)}`);

const context = {
name: this.name,
props: this.props
};

this.fs.copy(this.templatePath("mock", ".*"), this.destinationPath("mock"));
this.fs.copy(
this.templatePath("src", "layouts"),
this.destinationPath("src/layouts")
);
this.fs.copy(
this.templatePath("src", "models"),
this.destinationPath("src/models")
);
this.fs.copy(
this.templatePath("src", "pages", "index"),
this.destinationPath("src/pages/index")
);

this.fs.copy(
this.templatePath("src", "pages", "list"),
this.destinationPath("src/pages/list")
);
this.fs.copy(
this.templatePath("src", "global.less"),
this.destinationPath("src/global.less")
);
this.fs.copyTpl(
this.templatePath("tsconfig.json"),
this.destinationPath("tsconfig.json")
);
this.fs.copyTpl(
this.templatePath("package.json"),
this.destinationPath("package.json"),
context
);
this.fs.copy(
this.templatePath("_gitignore"),
this.destinationPath(".gitignore")
);
this.fs.copy(this.templatePath(".env"), this.destinationPath(".env"));
this.fs.copyTpl(
this.templatePath(".umirc.js"),
this.destinationPath(".umirc.js"),
context
);
this.fs.copy(
this.templatePath(".eslintrc"),
this.destinationPath(".eslintrc")
);
this.fs.copy(
this.templatePath(".prettierrc"),
this.destinationPath(".prettierrc")
);
this.fs.copy(
this.templatePath(".prettierignore"),
this.destinationPath(".prettierignore")
);
}
};
3 changes: 3 additions & 0 deletions lib/generators/vue/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "Create project with default vuex and vue-router"
}
1 change: 1 addition & 0 deletions lib/generators/vue/templates/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BROWSER=none
4 changes: 4 additions & 0 deletions lib/generators/vue/templates/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["plugin:vue/essential"]
}

122 changes: 122 additions & 0 deletions lib/generators/vue/templates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@


# Created by https://www.gitignore.io/api/osx,node,visualstudiocode

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

### OSX ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json


# End of https://www.gitignore.io/api/osx,node,visualstudiocode

# dependencies
/yarn.lock
/package-lock.json

# umi
.umi
.umi-production
7 changes: 7 additions & 0 deletions lib/generators/vue/templates/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/*.md
**/*.svg
**/*.ejs
**/*.html
dist
.umi
.umi-production
5 changes: 5 additions & 0 deletions lib/generators/vue/templates/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 100
}
4 changes: 4 additions & 0 deletions lib/generators/vue/templates/.umirc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// ref: https://umijs.org/config/
export default {
plugins: [['@didi/umi-plugin-vue']],
};
122 changes: 122 additions & 0 deletions lib/generators/vue/templates/_gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@


# Created by https://www.gitignore.io/api/osx,node,visualstudiocode

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

### OSX ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json


# End of https://www.gitignore.io/api/osx,node,visualstudiocode

# dependencies
/yarn.lock
/package-lock.json

# umi
.umi
.umi-production
Empty file.
27 changes: 27 additions & 0 deletions lib/generators/vue/templates/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"private": true,
"scripts": {
"start": "umi dev",
"build": "umi build",
"test": "umi test",
"lint": "pretty-quick --staged",
"inpsect": "umi inspect > webpack.js"
},
"devDependencies": {
"@didi/umi-plugin-vue": "^0.0.7",
"eslint": "^5.6.0",
"eslint-plugin-vue": "^5.0.0-beta.3",
"husky": "^1.0.0-rc.14",
"prettier": "^1.14.2",
"pretty-quick": "^1.6.0",
"umi": "2.10.7"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
},
"engines": {
"node": ">=8.0.0"
}
}
Empty file.
3 changes: 3 additions & 0 deletions lib/generators/vue/templates/src/global.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
html {
background: #fff;
}
3 changes: 3 additions & 0 deletions lib/generators/vue/templates/src/layouts/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<router-view></router-view>
</template>
6 changes: 6 additions & 0 deletions lib/generators/vue/templates/src/models/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
state: {
lang: 'js',
},
getters: {},
};
Loading