├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── bin └── index.js ├── lib ├── config.js ├── download.js ├── init.js ├── mirror.js └── update.js ├── package.json └── tpl └── v0.1.0.zip /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | yarn.lock 8 | 9 | # Runtime data 10 | pids 11 | *.pid 12 | *.seed 13 | *.pid.lock 14 | 15 | # Directory for instrumented libs generated by jscoverage/JSCover 16 | lib-cov 17 | 18 | # Coverage directory used by tools like istanbul 19 | coverage 20 | 21 | # nyc test coverage 22 | .nyc_output 23 | 24 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 25 | .grunt 26 | 27 | # Bower dependency directory (https://bower.io/) 28 | bower_components 29 | 30 | # node-waf configuration 31 | .lock-wscript 32 | 33 | # Compiled binary addons (http://nodejs.org/api/addons.html) 34 | build/Release 35 | 36 | # Dependency directories 37 | node_modules/ 38 | jspm_packages/ 39 | 40 | # Typescript v1 declaration files 41 | typings/ 42 | 43 | # Optional npm cache directory 44 | .npm 45 | 46 | # Optional eslint cache 47 | .eslintcache 48 | 49 | # Optional REPL history 50 | .node_repl_history 51 | 52 | # Output of 'npm pack' 53 | *.tgz 54 | 55 | # Yarn Integrity file 56 | .yarn-integrity 57 | 58 | # dotenv environment variables file 59 | .prettierrc 60 | .git 61 | .vscode 62 | .env 63 | .idea 64 | .DS_Store 65 | dist 66 | es 67 | _site 68 | /coverage 69 | 70 | # useless files 71 | .bak 72 | template/ 73 | config.json 74 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | yarn.lock 8 | 9 | # Runtime data 10 | pids 11 | *.pid 12 | *.seed 13 | *.pid.lock 14 | 15 | # Directory for instrumented libs generated by jscoverage/JSCover 16 | lib-cov 17 | 18 | # Coverage directory used by tools like istanbul 19 | coverage 20 | 21 | # nyc test coverage 22 | .nyc_output 23 | 24 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 25 | .grunt 26 | 27 | # Bower dependency directory (https://bower.io/) 28 | bower_components 29 | 30 | # node-waf configuration 31 | .lock-wscript 32 | 33 | # Compiled binary addons (http://nodejs.org/api/addons.html) 34 | build/Release 35 | 36 | # Dependency directories 37 | node_modules/ 38 | jspm_packages/ 39 | 40 | # Typescript v1 declaration files 41 | typings/ 42 | 43 | # Optional npm cache directory 44 | .npm 45 | 46 | # Optional eslint cache 47 | .eslintcache 48 | 49 | # Optional REPL history 50 | .node_repl_history 51 | 52 | # Output of 'npm pack' 53 | *.tgz 54 | 55 | # Yarn Integrity file 56 | .yarn-integrity 57 | 58 | # dotenv environment variables file 59 | .prettierrc 60 | .git 61 | .vscode 62 | .env 63 | .idea 64 | .DS_Store 65 | dist 66 | es 67 | _site 68 | /coverage 69 | 70 | # useless files 71 | .bak 72 | tpl/ 73 | template/ 74 | config.json 75 | tpl/ 76 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Feng L.H. 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 |

js-plugin-cli

2 | 3 |

A lightweight javascript plugin CLI.

4 | 5 |

6 | Build Status 7 | Version 8 | MIT 9 | npm 10 |

11 | 12 | # Installation 13 | ``` 14 | $ npm i js-plugin-cli -g 15 | ``` 16 | # Usage 17 | Run the following command line to create the project: 18 | ``` 19 | $ js-plugin-cli init myproject 20 | ``` 21 | 22 | # Parameter 23 | ## init 24 | Create the JavaScript plugin project: 25 | ``` 26 | $ js-plugin-cli init myproject 27 | ``` 28 | 29 | ## upgrade 30 | Check the new version is available or not: 31 | ``` 32 | $ js-plugin-cli upgrade 33 | ``` 34 | 35 | ## template 36 | You can download or upgrade the template from mirror: 37 | ``` 38 | $ js-plugin-cli template 39 | ``` 40 | 41 | ## mirror 42 | You can also set the template mirror like this: 43 | ``` 44 | $ js-plugin-cli mirror https://zpfz.vercel.app/download/files/frontend/tpl/js-plugin-cli/ 45 | ``` 46 | **NOTE** 47 | You can customize the template mirror link by youself, but the template file name must be `template.zip`, and the mirror link should be `/` ending. 48 | For example, the full link to your custom template mirror is `https://example.com/mirror/template.zip`, the mirror link that js-plugin-cli can recognize should be `https://example.com/mirror/`. 49 | 50 | You can download the js-plugin-cli template from [js-plugin-cli/tpl](https://github.com/zpfz/js-plugin-cli/tree/master/tpl). 51 | -------------------------------------------------------------------------------- /bin/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const program = require('commander') 4 | 5 | const updateChk = require('../lib/update') 6 | const setMirror = require('../lib/mirror') 7 | const dlTemplate = require('../lib/download') 8 | const initProject = require('../lib/init') 9 | 10 | // version 11 | program.version(require('../package.json').version, '-v, --version') 12 | 13 | // upgrade 14 | program 15 | .command('upgrade') 16 | .description('Check the js-plugin-cli version.') 17 | .action(() => { 18 | updateChk() 19 | }) 20 | 21 | // mirror 22 | program 23 | .command('mirror ') 24 | .description('Set the template mirror.') 25 | .action((tplMirror) => { 26 | setMirror(tplMirror) 27 | }) 28 | 29 | // template 30 | program 31 | .command('template') 32 | .description('Download template from mirror.') 33 | .action(() => { 34 | dlTemplate() 35 | }) 36 | 37 | // init 38 | program 39 | .name('js-plugin-cli') 40 | .usage(' [options]') 41 | .command('init ') 42 | .description('Create a javascript plugin project.') 43 | .action(project => { 44 | initProject(project) 45 | }) 46 | 47 | program.parse(process.argv) 48 | -------------------------------------------------------------------------------- /lib/config.js: -------------------------------------------------------------------------------- 1 | const fse = require('fs-extra') 2 | const path = require('path') 3 | 4 | const jsonConfig = { 5 | "name": "js-plugin-cli", 6 | "mirror": "https://zpfz.vercel.app/download/files/frontend/tpl/js-plugin-cli/" 7 | } 8 | 9 | const configPath = path.resolve(__dirname,'../config.json') 10 | 11 | async function defConfig() { 12 | try { 13 | await fse.outputJson(configPath, jsonConfig) 14 | } catch (err) { 15 | console.error(err) 16 | process.exit() 17 | } 18 | } 19 | 20 | module.exports = defConfig 21 | -------------------------------------------------------------------------------- /lib/download.js: -------------------------------------------------------------------------------- 1 | const download = require('download') 2 | const ora = require('ora') 3 | const chalk = require('chalk') 4 | const path = require('path') 5 | const fse = require('fs-extra') 6 | 7 | const defConfig = require('./config') 8 | 9 | const cfgPath = path.resolve(__dirname,'../config.json') 10 | const tplPath = path.resolve(__dirname,'../template') 11 | 12 | async function dlTemplate() { 13 | const exists = await fse.pathExists(cfgPath) 14 | if (exists){ 15 | await dlAction() 16 | }else{ 17 | await defConfig() 18 | await dlAction() 19 | } 20 | } 21 | 22 | async function dlAction(){ 23 | // Remove