Skip to content

Commit

Permalink
Feature/vue (#2)
Browse files Browse the repository at this point in the history
1: done vue base
  • Loading branch information
Jetsly authored Sep 17, 2018
1 parent 729eb2e commit cd508cf
Show file tree
Hide file tree
Showing 27 changed files with 786 additions and 4 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ typings/
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
**/*.ejs
**/*.html
package.json
**/template/app/.umirc.js
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# umi-plugin

* [@ddot/umi-plugin-service](https://www.npmjs.com/package/@ddot/umi-plugin-service)
* [@ddot/umi-plugin-service](https://www.npmjs.com/package/@ddot/umi-plugin-service)
* [@ddot/umi-plugin-vue](https://www.npmjs.com/package/@ddot/umi-plugin-vue)
10 changes: 10 additions & 0 deletions packages/create-umi-vue/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/node_modules
/templates/**/node_modules
/templates/**/npm-debug.log*
/templates/**/yarn-error.log
/templates/**/yarn.lock
/templates/**/package-lock.json
/templates/**/.umi
/templates/**/.umi-production
/templates/**/dist
/yarn.lock
15 changes: 15 additions & 0 deletions packages/create-umi-vue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# create-umi-vue

Creates a Vue UmiJS application using the command line.

## Usage

```bash
$ yarn create umi-vue <appName>
```

## LICENSE

MIT


45 changes: 45 additions & 0 deletions packages/create-umi-vue/bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env node

const { existsSync } = require("fs");
const { join } = require("path");
const semver = require("semver");
const chalk = require("chalk");
const mkdirp = require("mkdirp");
const clipboardy = require("clipboardy");

if (!semver.satisfies(process.version, ">= 8.0.0")) {
console.error(
chalk.red("✘ The generator will only work with Node v8.0.0 and up!")
);
process.exit(1);
}

const script = process.argv[2];
if (script === "-v" || script === "--version") {
console.log(require("../package").version);
if (existsSync(join(__dirname, "../.local"))) {
console.log(chalk.cyan("@local"));
}
process.exit(0);
}

if (script) {
mkdirp.sync(script);
process.chdir(script);
}

const BasicGenerator = require("../lib/BasicGenerator");
const generator = new BasicGenerator(process.argv.slice(2), {
name: "basic",
env: {
cwd: process.cwd()
},
resolved: __dirname
});
generator.run(() => {
if (script) {
clipboardy.writeSync(`cd ${script}`);
console.log("📋 Copied to clipboard, just use Ctrl+V");
}
console.log("✨ File Generate Done");
});
98 changes: 98 additions & 0 deletions packages/create-umi-vue/lib/BasicGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
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 = {};
}

// prompting() {
// const prompts = [
// {
// name: "vue",
// message: "What functionality do your want to enable?",
// type: "checkbox",
// choices: [ ]
// }
// ];
// return this.prompt(prompts).then(props => {
// this.props = Object.assign(this.props, 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("app", "mock", ".*"),
this.destinationPath("mock")
);
this.fs.copy(
this.templatePath("app", "src", "assets"),
this.destinationPath("src/assets")
);
this.fs.copy(
this.templatePath("app", "src", "layouts"),
this.destinationPath("src/layouts")
);
this.fs.copy(
this.templatePath("app", "src", "pages"),
this.destinationPath("src/pages")
);
this.fs.copy(
this.templatePath("app", "src", "global.css"),
this.destinationPath("src/global.css")
);
this.fs.copyTpl(
this.templatePath("app", "package.json"),
this.destinationPath("package.json"),
context
);
this.fs.copy(
this.templatePath("app", "_gitignore"),
this.destinationPath(".gitignore")
);
this.fs.copy(
this.templatePath("app", ".env"),
this.destinationPath(".env")
);
this.fs.copyTpl(
this.templatePath("app", ".umirc.js"),
this.destinationPath(".umirc.js"),
context
);
this.fs.copy(
this.templatePath("app", ".eslintrc"),
this.destinationPath(".eslintrc")
);
this.fs.copy(
this.templatePath("app", ".prettierrc"),
this.destinationPath(".prettierrc")
);
this.fs.copy(
this.templatePath("app", ".prettierignore"),
this.destinationPath(".prettierignore")
);

if (this.props.react.includes("dva")) {
this.fs.copy(
this.templatePath("app", "src", "models", ".*"),
this.destinationPath("src/models")
);
this.fs.copy(
this.templatePath("app", "src", "dva.js"),
this.destinationPath("src/dva.js")
);
}
}
};
38 changes: 38 additions & 0 deletions packages/create-umi-vue/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "create-umi-vue",
"version": "0.0.2",
"description": "Creates a vue UmiJS application using the command line.",
"bin": {
"create-umi": "./bin/cli.js"
},
"dependencies": {
"chalk": "^2.4.1",
"clipboardy": "^1.2.3",
"debug": "^3.1.0",
"mkdirp": "^0.5.1",
"semver": "^5.5.1",
"yeoman-generator": "^3.1.1"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/jetsly/umi-plugin/tree/master/packages/create-umi-vue"
},
"homepage": "https://github.com/jetsly/umi-plugin/tree/master/packages/create-umi-vue",
"authors": [
"jetsly <cnljli@live.com (https://github.com/jetsly)"
],
"bugs": {
"url": "https://github.com/jetsly/umi-plugin/issues"
},
"files": [
"bin",
"lib",
"templates"
],
"keywords": [
"umi",
"create-umi",
"vue"
]
}
1 change: 1 addition & 0 deletions packages/create-umi-vue/template/app/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BROWSER=none
122 changes: 122 additions & 0 deletions packages/create-umi-vue/template/app/.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
8 changes: 8 additions & 0 deletions packages/create-umi-vue/template/app/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**/*.md
**/*.svg
**/*.ejs
**/*.html
dist
package.json
.umi
.umi-production
5 changes: 5 additions & 0 deletions packages/create-umi-vue/template/app/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 100
}
7 changes: 7 additions & 0 deletions packages/create-umi-vue/template/app/.umirc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// ref: https://umijs.org/config/
export default {
plugins: [
// ref: https://github.com/jetsly/umi-plugin/tree/master/packages/create-umi-vue
["@ddot/umi-plugin-vue"]
]
};
Loading

0 comments on commit cd508cf

Please sign in to comment.