automan-cmd 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/README.md +56 -0
- package/bin/automan +3 -0
- package/bin/automan-build +3 -0
- package/bin/automan-config +3 -0
- package/bin/automan-create +3 -0
- package/bin/automan-publish +3 -0
- package/lib/automan-build.js +41 -0
- package/lib/automan-config.js +82 -0
- package/lib/automan-create.js +137 -0
- package/lib/automan-publish.js +331 -0
- package/lib/index.js +13 -0
- package/lib/install.js.tpl +47 -0
- package/lib/util.js +174 -0
- package/package.json +37 -0
- package/tpl/.babelrc +16 -0
- package/tpl/.browserslistrc +3 -0
- package/tpl/.eslintignore +2 -0
- package/tpl/.eslintrc.js +228 -0
- package/tpl/.gitignore.ejs +12 -0
- package/tpl/.postcssrc.js +12 -0
- package/tpl/README.md +1 -0
- package/tpl/changelog.md +1 -0
- package/tpl/editor/index.vue +45 -0
- package/tpl/icon.png +0 -0
- package/tpl/jsconfig.json +7 -0
- package/tpl/package.json.ejs +66 -0
- package/tpl/preview/app.vue +326 -0
- package/tpl/preview/attr/Data.vue +69 -0
- package/tpl/preview/attr/Resource.vue +79 -0
- package/tpl/preview/attr/com.vue +21 -0
- package/tpl/preview/attr/index.js +16 -0
- package/tpl/preview/components/Attribute.vue +365 -0
- package/tpl/preview/components/FitImg.vue +152 -0
- package/tpl/preview/components/ImgViewer.vue +80 -0
- package/tpl/preview/components/Loading.vue +55 -0
- package/tpl/preview/components/Toast.vue +111 -0
- package/tpl/preview/index.js +22 -0
- package/tpl/preview/index.tpl +13 -0
- package/tpl/preview/lib/ESlog.js +46 -0
- package/tpl/preview/lib/Util.js +57 -0
- package/tpl/preview/lib/fetch.js +139 -0
- package/tpl/preview/lib/index.js +15 -0
- package/tpl/preview/lib/vue/filters.js +53 -0
- package/tpl/preview/lib/vue/index.js +9 -0
- package/tpl/preview/lib/vue/mixin.js +166 -0
- package/tpl/preview/mint-ui/message-box/index.js +1503 -0
- package/tpl/preview/mint-ui/message-box/style.css +159 -0
- package/tpl/preview/mint-ui/popup/index.js +1046 -0
- package/tpl/preview/mint-ui/popup/style.css +115 -0
- package/tpl/preview/mint-ui/spinner/index.js +657 -0
- package/tpl/preview/mint-ui/spinner/style.css +227 -0
- package/tpl/preview/mint-ui/swipe/index.js +907 -0
- package/tpl/preview/mint-ui/swipe/style.css +43 -0
- package/tpl/preview/mint-ui/swipe-item/index.js +171 -0
- package/tpl/preview/mint-ui/swipe-item/style.css +1 -0
- package/tpl/preview/style.css +126 -0
- package/tpl/server.config.js +6 -0
- package/tpl/src/assets/css/index.scss +29 -0
- package/tpl/src/example.vue +165 -0
- package/tpl/src/index.vue.ejs +32 -0
- package/tpl/webpack.config.js.ejs +267 -0
- package/tpl/yarn.lock +6037 -0
package/CHANGELOG.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
## 1.0.13
|
2
|
+
> 使用Axios的自定义封装替换原有的fetch.js的网络请求方式,使前端请求API方式与H5活动保持一致。
|
3
|
+
|
4
|
+
## 1.0.14
|
5
|
+
> 增加publish register选项
|
6
|
+
> 删除手动输入token覆盖本地已有配置的逻辑
|
7
|
+
|
8
|
+
## 1.0.15
|
9
|
+
> 本地解决预览时候分辨率切换的问题
|
10
|
+
> 添加组件环境字段
|
11
|
+
|
12
|
+
## 1.0.16
|
13
|
+
> 发布的长选项 register 改成 registry 使其与config名称统一,短选项不受影响。
|
14
|
+
> README 修改
|
15
|
+
|
16
|
+
## 1.1.0
|
17
|
+
> 用axios替换utils中已经不建议使用的包request-promise
|
18
|
+
|
19
|
+
## 1.1.1
|
20
|
+
> 创建时增加是否公开询问,公开代表官方组件,私有代表个人组件。
|
21
|
+
|
22
|
+
## 1.1.5
|
23
|
+
> 修改组件公开的询问方式
|
24
|
+
|
25
|
+
## 1.2.0
|
26
|
+
> 移除组件打包进度显示
|
27
|
+
> 删除全部request、request-promise过期的node包,使用axios替换,涉及功能:组件上传、组件检查、组件新增、获取认证信息
|
28
|
+
|
29
|
+
## 1.3.1
|
30
|
+
> 添加组件开发时支持编辑器调试功能
|
31
|
+
|
32
|
+
## 1.3.2
|
33
|
+
> 添加自定义编辑器配置
|
34
|
+
> 删除错误警告
|
35
|
+
|
36
|
+
## 1.4.0
|
37
|
+
> 更改公共路径配置方式
|
38
|
+
|
39
|
+
## 2.0.1
|
40
|
+
> 修改devtool模式
|
41
|
+
|
42
|
+
## 2.0.2
|
43
|
+
> build失败终止进程
|
44
|
+
> 细节修复
|
45
|
+
|
46
|
+
## 2.0.3
|
47
|
+
> 增加postcss依赖&升级postcss-loader至4版本
|
48
|
+
|
49
|
+
## 2.1.0
|
50
|
+
> 使用vue-draggable-resizable替换vue-drag-resize
|
51
|
+
|
52
|
+
## 2.1.1
|
53
|
+
> 修改组件导出机制
|
54
|
+
|
55
|
+
## 2.1.2
|
56
|
+
> 添加postcss-unit-processor默认配置
|
57
|
+
|
58
|
+
## 2.1.3
|
59
|
+
> 修复一处问题代码
|
60
|
+
|
61
|
+
## 2.1.4
|
62
|
+
> 修改初始文件assets结构并给定页面默认初始样式
|
63
|
+
|
64
|
+
## 2.1.5
|
65
|
+
> 调整webpack中babel-loader选项,使用独立配置
|
package/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# 奥特曼脚手架
|
2
|
+
|
3
|
+
## 全局安装
|
4
|
+
|
5
|
+
```
|
6
|
+
npm install automan-cmd -g
|
7
|
+
```
|
8
|
+
|
9
|
+
## 查看命令
|
10
|
+
|
11
|
+
```
|
12
|
+
automan
|
13
|
+
```
|
14
|
+
|
15
|
+
## 新建项目
|
16
|
+
|
17
|
+
```
|
18
|
+
automan create projectName
|
19
|
+
```
|
20
|
+
|
21
|
+
## 查看配置
|
22
|
+
|
23
|
+
```
|
24
|
+
automan config
|
25
|
+
```
|
26
|
+
|
27
|
+
## 配置域名
|
28
|
+
|
29
|
+
```
|
30
|
+
automan config registry xxx
|
31
|
+
```
|
32
|
+
|
33
|
+
## 配置token
|
34
|
+
|
35
|
+
```
|
36
|
+
automan config token xxx
|
37
|
+
```
|
38
|
+
|
39
|
+
## 打包项目
|
40
|
+
|
41
|
+
```
|
42
|
+
automan build
|
43
|
+
```
|
44
|
+
|
45
|
+
## 发布项目
|
46
|
+
|
47
|
+
```
|
48
|
+
使用已经配置好的token
|
49
|
+
automan publish
|
50
|
+
|
51
|
+
手动替换想设置的 registry
|
52
|
+
automan publish -r [host]
|
53
|
+
|
54
|
+
手动替换想设置的token
|
55
|
+
automan publish -t [access-token]
|
56
|
+
```
|
package/bin/automan
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
const path = require('path')
|
2
|
+
const fs = require('fs-extra')
|
3
|
+
const util = require('./util')
|
4
|
+
|
5
|
+
const CWD = process.cwd()
|
6
|
+
const resolve = (...file) => path.resolve(process.cwd(), ...file)
|
7
|
+
|
8
|
+
let pkg = {}
|
9
|
+
|
10
|
+
async function pkgImport () {
|
11
|
+
try {
|
12
|
+
pkg = await fs.readJson(path.resolve(CWD, 'package.json'))
|
13
|
+
} catch (err) {
|
14
|
+
util.logRed(err.toString())
|
15
|
+
}
|
16
|
+
if (!pkg.scripts || !pkg.scripts['dist']) {
|
17
|
+
util.logRed('请检查package.json文件是否提供了`dist`脚本')
|
18
|
+
process.exit()
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
async function executeCmd ({namespace,name,version,publicpath}) {
|
23
|
+
const BUILD_CMD = `npm run build --AUTO_NAMESPACE=${namespace} --AUTO_NAME=${name} --AUTO_VERSION=${version} --AUTO_PUBLICPATH=${publicpath}`
|
24
|
+
await util.asyncExec(BUILD_CMD)
|
25
|
+
}
|
26
|
+
|
27
|
+
async function start ({pack = false, build = true, push = true, token, namespace, name, version, publicpath} = {}) {
|
28
|
+
await pkgImport()
|
29
|
+
if (build) {
|
30
|
+
util.logGreen('构建中...')
|
31
|
+
await executeCmd({
|
32
|
+
namespace,
|
33
|
+
name,
|
34
|
+
version,
|
35
|
+
publicpath
|
36
|
+
})
|
37
|
+
util.logGreen('构建完成')
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
module.exports = start
|
@@ -0,0 +1,82 @@
|
|
1
|
+
const path = require('path')
|
2
|
+
const fs = require('fs-extra')
|
3
|
+
const util = require('./util')
|
4
|
+
const commander = require('commander')
|
5
|
+
const os = require('os')
|
6
|
+
|
7
|
+
let CONFIG_FILE = path.resolve(os.homedir(), './automan-config.json')
|
8
|
+
let OPTIONS = ['env', 'token', 'registry', 'shop-token']
|
9
|
+
|
10
|
+
async function readConfig () {
|
11
|
+
let config
|
12
|
+
if (!config) {
|
13
|
+
try {
|
14
|
+
config = await fs.readJson(CONFIG_FILE)
|
15
|
+
} catch (e) {
|
16
|
+
config = {token: '', registry: ''}
|
17
|
+
await fs.writeJson(CONFIG_FILE, config)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
return config
|
21
|
+
}
|
22
|
+
|
23
|
+
async function getConfig (key) {
|
24
|
+
let config = await readConfig()
|
25
|
+
if (key) return config[key]
|
26
|
+
return config
|
27
|
+
}
|
28
|
+
|
29
|
+
async function setConfig (key, val) {
|
30
|
+
if (!OPTIONS.includes(key)) {
|
31
|
+
util.logRed(`无效配置项 ${key}`)
|
32
|
+
process.exit()
|
33
|
+
}
|
34
|
+
let config = await readConfig()
|
35
|
+
if (key && val) {
|
36
|
+
config[key] = val
|
37
|
+
await fs.writeJson(CONFIG_FILE, config, 'utf-8')
|
38
|
+
}
|
39
|
+
return config
|
40
|
+
}
|
41
|
+
|
42
|
+
async function removeConfig (key) {
|
43
|
+
let config = await readConfig()
|
44
|
+
delete config[key]
|
45
|
+
await fs.writeJson(CONFIG_FILE, config, 'utf-8')
|
46
|
+
}
|
47
|
+
|
48
|
+
async function start () {
|
49
|
+
commander
|
50
|
+
.arguments('<key> [val]', '设置或者读取全局配置如`token`、`env`、`host`等')
|
51
|
+
.option('-r, --rm', '移除配置')
|
52
|
+
.parse(process.argv)
|
53
|
+
|
54
|
+
let configKey = commander.args[0]
|
55
|
+
let configVal = commander.args[1]
|
56
|
+
let rm = commander['rm']
|
57
|
+
|
58
|
+
let config
|
59
|
+
if(!configKey) {
|
60
|
+
config = await getConfig()
|
61
|
+
return util.log(config)
|
62
|
+
}
|
63
|
+
if (configKey) {
|
64
|
+
if (rm) {
|
65
|
+
await removeConfig(configKey)
|
66
|
+
return
|
67
|
+
} else if (!configVal) {
|
68
|
+
config = await getConfig(configKey)
|
69
|
+
return util.log(config)
|
70
|
+
}
|
71
|
+
}
|
72
|
+
if (configKey && configVal) {
|
73
|
+
config = await setConfig(configKey, configVal)
|
74
|
+
util.log(config)
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
module.exports = {
|
79
|
+
start,
|
80
|
+
getConfig,
|
81
|
+
setConfig
|
82
|
+
}
|
@@ -0,0 +1,137 @@
|
|
1
|
+
const process = require('process')
|
2
|
+
const commander = require('commander')
|
3
|
+
const path = require('path')
|
4
|
+
const ejs = require('ejs')
|
5
|
+
const fs = require('fs-extra')
|
6
|
+
const package = require('../package.json')
|
7
|
+
const util = require('./util.js')
|
8
|
+
const configUtil = require('./automan-config.js')
|
9
|
+
const glob = require('glob')
|
10
|
+
|
11
|
+
commander
|
12
|
+
.arguments('<name>', '项目文件目录')
|
13
|
+
.parse(process.argv)
|
14
|
+
|
15
|
+
let name = commander.args[0] || 'test'
|
16
|
+
if (!name) {
|
17
|
+
util.logRed('请输入创建项目的文件目录')
|
18
|
+
process.exit(1)
|
19
|
+
}
|
20
|
+
|
21
|
+
async function projectDirCheck (projectDir) {
|
22
|
+
let status = await util.dirCheck(projectDir)
|
23
|
+
switch (status) {
|
24
|
+
case 'na': break
|
25
|
+
case 'keep': process.exit()
|
26
|
+
case 'clear': util.logGreen(`移除 ${projectDir} 成功.`)
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
async function generateProject (projectDir, tpl) {
|
31
|
+
let goon = await util.confirm(`准备创建项目,是否继续?`)
|
32
|
+
|
33
|
+
if (!goon) process.exit()
|
34
|
+
await fs.copy(tpl, projectDir, {
|
35
|
+
filter: function (src) {
|
36
|
+
return !/tpl(\\|\/)node_modules/.test(src)
|
37
|
+
}
|
38
|
+
})
|
39
|
+
// util.logGreen('模板获取完毕')
|
40
|
+
}
|
41
|
+
|
42
|
+
async function renderEjs (files, context) {
|
43
|
+
for(let tpl of files) {
|
44
|
+
await render(tpl)
|
45
|
+
}
|
46
|
+
util.logGreen('项目初始化完成')
|
47
|
+
async function render(tpl) {
|
48
|
+
let content = await ejs.renderFile(tpl, context, {async: true})
|
49
|
+
await fs.writeFile(tpl.replace('.ejs', ''), content, 'utf8')
|
50
|
+
await fs.remove(tpl)
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
async function pleaseAnswerMe (questions) {
|
55
|
+
var answers = {}
|
56
|
+
for (let key of Object.keys(questions)) {
|
57
|
+
let question = questions[key]
|
58
|
+
let answer
|
59
|
+
while (!(question.pattern || /^.+$/).test(answer = await getAnswer(question))) {
|
60
|
+
util.logRed(question.message || `不要包含特殊字符哦${String(question.pattern)}`)
|
61
|
+
}
|
62
|
+
answers[key] = answer
|
63
|
+
}
|
64
|
+
|
65
|
+
async function getAnswer (question) {
|
66
|
+
let answer
|
67
|
+
switch (question.type) {
|
68
|
+
case 'confirm':
|
69
|
+
answer = await util.confirm(question.desc, question.default)
|
70
|
+
break
|
71
|
+
case 'select':
|
72
|
+
answer = await util.select(question.desc, question.options, question.default)
|
73
|
+
break
|
74
|
+
case 'checks':
|
75
|
+
answer = await util.checks(question.desc, question.options)
|
76
|
+
break
|
77
|
+
default:
|
78
|
+
answer = (await util.quiz(question.desc, question.default)).trim()
|
79
|
+
}
|
80
|
+
return answer
|
81
|
+
}
|
82
|
+
return answers
|
83
|
+
}
|
84
|
+
|
85
|
+
async function start() {
|
86
|
+
const CWD = process.cwd()
|
87
|
+
const PROJECT_DIR = path.resolve(CWD, name)
|
88
|
+
const TPL_DIR = path.resolve(__dirname, '../', 'tpl')
|
89
|
+
let tags = []
|
90
|
+
|
91
|
+
await Promise.all([new Promise(async resolve => {
|
92
|
+
await projectDirCheck(PROJECT_DIR)
|
93
|
+
await generateProject(PROJECT_DIR, TPL_DIR)
|
94
|
+
resolve()
|
95
|
+
})])
|
96
|
+
|
97
|
+
let questions = {
|
98
|
+
'name': {
|
99
|
+
desc: '请输入组件名(英文)',
|
100
|
+
default: name,
|
101
|
+
pattern: /^[A-Za-z_][\w-]+$/
|
102
|
+
},
|
103
|
+
'label': {
|
104
|
+
desc: '请输入组件名(中文, 2-8个字)',
|
105
|
+
pattern: /^[^\s\r\n\t]{2,8}$/
|
106
|
+
},
|
107
|
+
'type': {
|
108
|
+
desc: '请选择组件类型',
|
109
|
+
type: 'select',
|
110
|
+
options: [
|
111
|
+
{name: 'web', value: '0'},
|
112
|
+
{name: 'flutter', value: 1},
|
113
|
+
],
|
114
|
+
default: 0
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
let answer = await pleaseAnswerMe(questions)
|
119
|
+
answer.description = answer.label // 不再分别设置 description 和 label
|
120
|
+
const PROJECT_EJS = glob.sync('**/*.ejs', {cwd: PROJECT_DIR, absolute: true, dot: true})
|
121
|
+
await renderEjs(PROJECT_EJS, answer)
|
122
|
+
|
123
|
+
util.logGreen('\n开发')
|
124
|
+
util.log(`cd ${name}`)
|
125
|
+
util.log('npm install')
|
126
|
+
util.log('npm run dev')
|
127
|
+
|
128
|
+
util.logGreen('\n打包')
|
129
|
+
util.log('automan build')
|
130
|
+
|
131
|
+
util.logGreen('\n发布')
|
132
|
+
util.log('automan publish')
|
133
|
+
util.log('')
|
134
|
+
util.log('')
|
135
|
+
}
|
136
|
+
|
137
|
+
module.exports = start
|