├── .gitignore ├── LICENSE ├── README.md ├── bin ├── iview-theme ├── iview-theme-build └── iview-theme-init ├── lib └── build.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 jingsam 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iview-theme 2 | 3 | Theme generator cli tool for iview 4 | 5 | ## Installation 6 | 7 | ``` 8 | npm i iview-theme -g 9 | ``` 10 | 11 | ## Usage 12 | 13 | Initialize a theme project 14 | "xxx" means iview tags or releases number, example: v2.14.3. 15 | If you havn't defined the version number, it will use the latest version. 16 | 17 | ``` 18 | iview-theme init my-theme 19 | 20 | or 21 | 22 | iview-theme init my-theme xxx 23 | ``` 24 | 25 | 2. Edit `my-theme/custom.less` and build your theme project 26 | 27 | ``` 28 | cd my-theme 29 | iview-theme build -o dist/ 30 | ``` 31 | -------------------------------------------------------------------------------- /bin/iview-theme: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('commander') 4 | .version(require('../package').version) 5 | .usage(' [options]') 6 | .command('init', 'init a new theme template') 7 | .command('build', 'build the theme') 8 | .parse(process.argv) 9 | -------------------------------------------------------------------------------- /bin/iview-theme-build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const program = require('commander') 4 | const path = require('path') 5 | const build = require('../lib/build') 6 | 7 | program 8 | .option('-o, --output ', 'output to a directory', 'dist') 9 | .parse(process.argv) 10 | 11 | const output = path.resolve(program.output) 12 | build(output) 13 | -------------------------------------------------------------------------------- /bin/iview-theme-init: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const program = require('commander') 4 | const path = require('path') 5 | const exists = require('fs').existsSync 6 | const inquirer = require('inquirer') 7 | const ora = require('ora') 8 | const download = require('download-git-repo') 9 | const rimraf = require('rimraf') 10 | const ncp = require('ncp').ncp 11 | 12 | program 13 | .usage('[dir]') 14 | .parse(process.argv) 15 | 16 | const dir = program.args[0] 17 | const tag = program.args[1] ? '#' + program.args[1] : '' 18 | const inPlace = !dir || dir === '.' 19 | const to = path.resolve(dir || '.') 20 | const tmp = path.resolve(to, './tmp') 21 | 22 | if (exists(to)) { 23 | inquirer.prompt([{ 24 | type: 'confirm', 25 | message: inPlace 26 | ? 'Generate project in current directory?' 27 | : 'Target directory exists. Continue?', 28 | name: 'ok' 29 | }]).then(answers => { 30 | if (answers.ok) downloadAndGenerate() 31 | }) 32 | } else { 33 | downloadAndGenerate() 34 | } 35 | 36 | 37 | function downloadAndGenerate () { 38 | const spinner1 = ora('downloading template').start() 39 | download('iview/iview' + tag, tmp, err => { 40 | if (err) return spinner1.fail('Failed to download template') 41 | spinner1.succeed() 42 | 43 | const spinner2 = ora('copying styles').start() 44 | ncp(path.resolve(tmp, './src/styles'), to, err => { 45 | if (err) return spinner2.fail('Failed to copy styles') 46 | spinner2.succeed() 47 | 48 | const spinner3 = ora('deleting template').start() 49 | rimraf(tmp, err => { 50 | if (err) return spinner3.fail('Failed to copy styles') 51 | spinner3.succeed('succeed! Now you can edit `custom.less` to make your theme.') 52 | }) 53 | }) 54 | }) 55 | } 56 | -------------------------------------------------------------------------------- /lib/build.js: -------------------------------------------------------------------------------- 1 | const gulp = require('gulp') 2 | const cleanCSS = require('gulp-clean-css') 3 | const less = require('gulp-less') 4 | const rename = require('gulp-rename') 5 | const autoprefixer = require('gulp-autoprefixer') 6 | const series = require('run-sequence').use(gulp) 7 | const path = require('path') 8 | const ora = require('ora') 9 | 10 | 11 | module.exports = function(output) { 12 | // 编译less 13 | const spinner = ora('compiling less').start() 14 | gulp.task('css', function() { 15 | gulp.src('./index.less') 16 | .pipe(less()) 17 | .pipe(autoprefixer({ 18 | browsers: ['last 2 versions', 'ie > 8'] 19 | })) 20 | .pipe(cleanCSS()) 21 | .pipe(rename('iview.css')) 22 | .pipe(gulp.dest(output)) 23 | .on('err', err => spinner.failed(err)) 24 | .on('end', () => spinner.succeed()) 25 | }) 26 | 27 | // 拷贝字体文件 28 | const spinner2 = ora('copying fonts').start() 29 | gulp.task('fonts', function() { 30 | gulp.src('./common/iconfont/fonts/*.*') 31 | .pipe(gulp.dest(path.resolve(output, './fonts'))) 32 | .on('err', err => spinner.failed(err)) 33 | .on('end', () => spinner2.succeed()) 34 | }) 35 | 36 | series('css', 'fonts') 37 | } 38 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iview-theme", 3 | "version": "1.1.0", 4 | "description": "Theme generator cli tool for iview", 5 | "main": "index.js", 6 | "bin": { 7 | "iview-theme": "./bin/iview-theme", 8 | "iview-theme-init": "./bin/iview-theme-init", 9 | "iview-theme-build": "./bin/iview-theme-build" 10 | }, 11 | "files": [ 12 | "bin", 13 | "lib" 14 | ], 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/jingsam/iview-theme.git" 18 | }, 19 | "keywords": [ 20 | "iview", 21 | "vue", 22 | "theme", 23 | "cli" 24 | ], 25 | "author": "jingsam", 26 | "license": "MIT", 27 | "bugs": { 28 | "url": "https://github.com/jingsam/iview-theme/issues" 29 | }, 30 | "homepage": "https://github.com/jingsam/iview-theme#readme", 31 | "dependencies": { 32 | "commander": "^2.9.0", 33 | "download-git-repo": "^1.1.0", 34 | "gulp": "^3.9.1", 35 | "gulp-autoprefixer": "^3.1.1", 36 | "gulp-clean-css": "^3.0.2", 37 | "gulp-less": "^3.3.0", 38 | "gulp-rename": "^1.2.2", 39 | "inquirer": "^3.0.1", 40 | "ncp": "^2.0.0", 41 | "ora": "^1.1.0", 42 | "rimraf": "^2.5.4", 43 | "run-sequence": "^1.2.2" 44 | } 45 | } 46 | --------------------------------------------------------------------------------