@imgcook/cli
Advanced tools
Comparing version 0.1.0-alpha.4 to 0.1.0-alpha.5
@@ -5,3 +5,3 @@ #!/usr/bin/env node | ||
// 检查Node版本 | ||
// Review Node Version | ||
if (!semver.gte(process.version, '9.0.0')) { | ||
@@ -54,3 +54,3 @@ console.log( | ||
'-a, --app', | ||
'Pull module into `mod` folder while your are in imgcook-app' | ||
'Pull module into `mod` folder while your are in imgcook app project' | ||
) | ||
@@ -57,0 +57,0 @@ .allowUnknownOption() |
@@ -1,27 +0,3 @@ | ||
const dsl = [ | ||
{ | ||
name: 'H5 标准开发规范', | ||
id: '5' | ||
}, | ||
{ | ||
name: 'React 开发规范', | ||
id: '12' | ||
}, | ||
{ | ||
name: 'Vue 开发规范', | ||
id: '29' | ||
}, | ||
{ | ||
name: '支付宝小程序开发规范', | ||
id: '79' | ||
}, | ||
{ | ||
name: 'Rax 标准开发规范', | ||
id: '1' | ||
}, | ||
{ | ||
name: '微信小程序开发规范', | ||
id: '21' | ||
} | ||
]; | ||
const { dsl } = require('./constant'); | ||
let curDslId = '12'; | ||
@@ -46,2 +22,3 @@ let promptConfig = [ | ||
'H5 标准开发规范', | ||
'React D2C Schema', | ||
'React 开发规范', | ||
@@ -119,3 +96,3 @@ 'Vue 开发规范', | ||
// 检查是否存在配置文件 | ||
// Check if a configuration file exists | ||
if (fse.existsSync(cliConfig.configFile)) { | ||
@@ -128,3 +105,3 @@ try { | ||
} else if (!option.set && !option.get && !option.remove) { | ||
// 如果配置为空则去设置 | ||
// If the configuration is empty then go to set | ||
value = 'set'; | ||
@@ -137,3 +114,3 @@ } | ||
// 编辑 | ||
// edit | ||
if (value === 'edit') { | ||
@@ -179,3 +156,3 @@ childProcess.exec(`open ${cliConfig.configFile}`); | ||
// 不存在指令 | ||
// No instruction exists | ||
if (value !== 'set' && !option.set && !option.get && !option.remove) { | ||
@@ -187,3 +164,3 @@ const result = JSON.stringify(configData, null, 2); | ||
// 设置 | ||
// setting | ||
if (value === 'set') { | ||
@@ -230,4 +207,5 @@ promptConfig = initConfig(promptConfig, configData); | ||
} | ||
const message = chalk.green(`设置 ${option.set} 成功`); | ||
const message = chalk.green(`Set up 「${option.set}」 success.`); | ||
console.log(message); | ||
return message; | ||
} | ||
@@ -255,3 +233,3 @@ if (option.remove) { | ||
} | ||
console.log(chalk.green(`删除 ${option.remove} 成功`)); | ||
console.log(chalk.green(`delete 「${option.remove}」 success.`)); | ||
} | ||
@@ -258,0 +236,0 @@ if (option.get) { |
@@ -24,3 +24,3 @@ const request = require('request'); | ||
// Post请求 | ||
// Post request | ||
const ajaxPost = (url, param) => { | ||
@@ -55,3 +55,3 @@ return new Promise(resolve => { | ||
// 写文件 | ||
// write file | ||
const writeFile = (content, filePath, code) => { | ||
@@ -231,3 +231,3 @@ return new Promise((resolve, reject) => { | ||
if (!id) { | ||
console.error(chalk.red('缺少id,执行 `imgcook config sync --id <moduleId>')); | ||
console.error(chalk.red('lack id,execution `imgcook config sync --id <moduleId>')); | ||
return {}; | ||
@@ -234,0 +234,0 @@ } |
@@ -16,7 +16,7 @@ const ora = require('ora'); | ||
} | ||
// 检查是否存在配置文件 | ||
// Check config file | ||
if (fse.existsSync(cliConfig.configFile)) { | ||
configData = await fse.readJson(cliConfig.configFile); | ||
} else { | ||
// 如果配置为空则去设置 | ||
// Set if the configuration is empty | ||
require('./config')('set', {}); | ||
@@ -23,0 +23,0 @@ } |
@@ -16,3 +16,3 @@ const chalk = require('chalk'); | ||
// 安装generator | ||
// install generator | ||
if (value === 'generator') { | ||
@@ -23,3 +23,3 @@ const generator = configData.generator; | ||
// 安装plugin | ||
// install plugin | ||
if (value === 'plugin') { | ||
@@ -30,3 +30,3 @@ const plugin = configData.plugin; | ||
// 安装generator和plugin | ||
// install generator and plugin | ||
if (value !== 'generator' && value !== 'plugin') { | ||
@@ -33,0 +33,0 @@ if (typeof option.name === 'function' && value === undefined) { |
@@ -11,4 +11,4 @@ const ora = require('ora'); | ||
getPlugin, | ||
cliConfig, | ||
installPluginSync | ||
cliConfig | ||
// installPluginSync | ||
} = require('./helper'); | ||
@@ -18,10 +18,11 @@ | ||
let filePath = cwd; | ||
if (option.path) { | ||
filePath = path.isAbsolute(option.path) | ||
? option.path | ||
: path.join(cwd, option.path); | ||
} | ||
option.path = option.path || value; | ||
filePath = path.isAbsolute(option.path) | ||
? option.path | ||
: path.join(cwd, option.path); | ||
if (!fs.existsSync(cliConfig.configFile)) { | ||
console.log('请先设置配置,执行`imgcook config set`'); | ||
console.log( | ||
'Please set the configuration first,Execute `imgcook config set`' | ||
); | ||
const inquirer = require('inquirer'); | ||
@@ -31,3 +32,3 @@ inquirer | ||
type: 'confirm', | ||
message: '是否开始设置?', | ||
message: 'Whether to start setting?', | ||
name: 'set' | ||
@@ -55,8 +56,14 @@ }) | ||
}); | ||
if (repoData.data && repoData.data.code) { | ||
let data = repoData.data; | ||
if (repoData.data) { | ||
let data = repoData.data; | ||
// fs.writeFile( | ||
// `${filePath}/demo.json`, | ||
// JSON.stringify(data, null, 2), | ||
// 'utf8', | ||
// () => {} | ||
// ); | ||
const moduleData = data.moduleData; | ||
let errorData; | ||
moduleData && spinner.start(`「${moduleData.name}」模块下载中...`); | ||
moduleData && spinner.start(`「${moduleData.name}」Downloading module...`); | ||
if (!fs.existsSync(filePath)) { | ||
@@ -71,24 +78,38 @@ fs.mkdirSync(filePath); | ||
// 拉取配置 | ||
// const pluginData = await getPlugin({ | ||
// config: configData, | ||
// id: value, | ||
// type: 'module' | ||
// }); | ||
const pluginData = await getPlugin({ | ||
config: configData, | ||
id: value, | ||
type: 'module' | ||
}); | ||
// if (pluginData && pluginData.plugin && pluginData.plugin.length > 0) { | ||
// plugin = pluginData.plugin; | ||
// await installPluginSync(plugin, imgcookModulesPath); | ||
// let needInstallPlugin = []; | ||
// try { | ||
// const files = fs.readdirSync(`${imgcookModulesPath}/node_modules/@imgcook`); | ||
// for (const item of plugin) { | ||
// if (files.indexOf(item.split('/')[1]) === -1) { | ||
// needInstallPlugin.push(item); | ||
// } | ||
// } | ||
// } catch (error) { | ||
// needInstallPlugin = plugin; | ||
// } | ||
// if (needInstallPlugin.length > 0) { | ||
// await installPluginSync(needInstallPlugin, imgcookModulesPath); | ||
// } | ||
// } | ||
if (plugin.length > 0) { | ||
let config = { | ||
...configData, | ||
value | ||
// ...option | ||
}; | ||
let rdata = { | ||
data, | ||
filePath, | ||
config | ||
}; | ||
for (const pluginItem of plugin) { | ||
const pluginItemPath = `${imgcookModulesPath}/node_modules/${pluginItem}`; | ||
data = await require(pluginItemPath)({ | ||
data, | ||
filePath, | ||
config: configData, | ||
cmd: { | ||
value, | ||
...option | ||
} | ||
}); | ||
rdata = await require(pluginItemPath)(rdata); | ||
} | ||
@@ -123,5 +144,5 @@ } | ||
if (isSuccess) { | ||
spinner.succeed(`「${moduleData.name}」下载完成`); | ||
spinner.succeed(`「${moduleData.name}」Download completed`); | ||
} else { | ||
spinner.fail(`「${moduleData.name}」下载失败`); | ||
spinner.fail(`「${moduleData.name}」Download failed`); | ||
errorData && console.error(errorData); | ||
@@ -131,4 +152,3 @@ data.errorList && console.error(data.errorList); | ||
} | ||
if (!repoData.success) { | ||
if (!repoData.success || repoData.success === 'false') { | ||
if (repoData.code && repoData.code.message) { | ||
@@ -135,0 +155,0 @@ console.log(chalk.red(`Error: ${repoData.code.message}`)); |
{ | ||
"name": "@imgcook/cli", | ||
"version": "0.1.0-alpha.4", | ||
"version": "0.1.0-alpha.5", | ||
"description": "", | ||
@@ -19,3 +19,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@imgcook/cli-utils": "^0.1.0-alpha.4", | ||
"@imgcook/cli-utils": "^0.1.0-alpha.5", | ||
"chalk": "^2.4.2", | ||
@@ -47,3 +47,3 @@ "commander": "^2.19.0", | ||
}, | ||
"gitHead": "7e8ec66cd5faf5fe759ce4dd823504831fdff6f2" | ||
"gitHead": "0fba1c2276fe9d64ce1612b816cf13132439d41f" | ||
} |
# imgcook-cli | ||
## 概述 | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/imgcook/imgcook-cli/blob/master/LICENSE) | ||
[![GitHub tag](https://img.shields.io/github/tag/imgcook/imgcook-cli.svg)]() | ||
[![Build Status](https://travis-ci.org/imgcook/imgcook-cli.svg?branch=master)](https://travis-ci.org/imgcook/imgcook-cli) | ||
imgcook-cli 可以结合 Plugin 的能力一键将 imgcook 平台生成的代码产物放置到你的本地项目工程里,无缝融合到你的研发流程,如果你有对 imgcook 生成代码的产物有加工需求(比如自动上传图片到自己的图床、文件目录转换等),imgcook-cli 是你非常好的选择。 | ||
## 安装 | ||
> imgcook-cli 安装依赖 Node.js 和 NPM,建议使用 Node.js 版本 9.x | ||
imgcook-cli can combine the capabilities of Plugin to place the code products generated by the imgcook platform into your local project project, and seamlessly integrate into your development process. Upload pictures to your own bed, file directory conversion, etc.), imgcook-cli is a very good choice for you. | ||
## Getting Started | ||
## Install | ||
> The imgcook-cli installation depends on Node.js and NPM. It is recommended to use Node.js version 9.x | ||
```shell | ||
@@ -18,22 +22,23 @@ # npm | ||
## 使用 | ||
## Use | ||
### 常用指令 | ||
### Common command | ||
#### imgcook config | ||
> 用户设置配置,默认初始化生成官方配置 | ||
> User settings configuration, default initialization generates official configuration | ||
```shell | ||
# 设置配置 | ||
# Setting config | ||
imgcook config set | ||
# 查看配置 | ||
# View config | ||
imgcook config ls | ||
# 直接打开配置文件编辑 | ||
# Open configuration file directly | ||
imgcook config edit | ||
``` | ||
> DSL 配置: | ||
> DSL config: | ||
> React D2C Schema:41 | ||
@@ -46,14 +51,14 @@ > Vue 开发规范:29 | ||
> | ||
> accessId 获取:官网右上角头像 -> 个人页面 -> 左上方 Icon | ||
> <image width="396" src="https://gw.alicdn.com/tfs/TB1rFW3qeL2gK0jSZFmXXc7iXXa-1156-480.png"> | ||
> Get accessId :Official website top right corner avatar -> Personal page -> Top left Icon | ||
> ![image.png](https://intranetproxy.alipay.com/skylark/lark/0/2019/png/199/1576161013370-acd72bac-c714-4653-828e-963d6aea3c8b.png#align=left&display=inline&height=164&name=image.png&originHeight=480&originWidth=1156&size=151842&status=done&style=none&width=396) | ||
#### imgcook pull | ||
> 拉取模块代码 | ||
> Pull module code | ||
```shell | ||
# 拉取某个模块代码到本地路径 | ||
# Pull a module code to a local path | ||
imgcook pull <moduleId> --path <path> | ||
# 例子 | ||
# Example | ||
imgcook pull 17108 --path mod | ||
@@ -63,21 +68,20 @@ ``` | ||
#### imgcook install | ||
> 安装 imgcook-cli 所需的 Plugin | ||
> Plugins required to install imgcook-cli | ||
```shell | ||
# 默认安装全部配置过的 Plugin | ||
# Install all configured plugins by default | ||
imgcook install | ||
# 安装指定的 Plugin | ||
# Install the specified plugin | ||
imgcook install plugin --name <value> | ||
# 例子 | ||
# Example | ||
imgcook install plugin --name @imgcook/plugin-images | ||
``` | ||
### 选项 | ||
### Options | ||
#### imgcook --version | ||
> 显示版本信息 | ||
> Display version information | ||
@@ -91,3 +95,3 @@ | ||
#### imgcook --help | ||
> 显示指令使用帮助 | ||
> Show command usage help | ||
@@ -98,2 +102,5 @@ | ||
imgcook -h | ||
``` | ||
``` | ||
## License | ||
[MIT](https://github.com/imgcook/imgcook-cli/blob/master/LICENSE) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27763
12
876
101
1