Skip to content

重构 CLI 工具#19

Merged
nighca merged 9 commits intoqiniu:masterfrom
nighca:cli
Sep 20, 2017
Merged

重构 CLI 工具#19
nighca merged 9 commits intoqiniu:masterfrom
nighca:cli

Conversation

@nighca
Copy link
Collaborator

@nighca nighca commented Sep 18, 2017

  • 重构 CLI 工具实现,添加更多 option & command
  • image 的逻辑中也走 CLI 工具,保持一致性
  • 添加更多 debug 信息
  • debug extract-style 的功能

doxiaodong and others added 4 commits September 11, 2017 12:51
add global ENV config
eg: fec-builder -e staing

add fec-builder production build
eg: fec-builder --build
@nighca
Copy link
Collaborator Author

nighca commented Sep 18, 2017

envVariables 好像还没实现...稍等我加下

@nighca
Copy link
Collaborator Author

nighca commented Sep 18, 2017

done

@nighca nighca requested a review from doxiaodong September 18, 2017 07:42
Copy link
Contributor

@doxiaodong doxiaodong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

趁机删掉yarn ?

},
ENV_VARIABLES_FILE: {
alias: 'f',
desc: 'Target file path for env variables',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里写清楚点支持的格式

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个我感觉不用吧,路径支持绝对路径跟 ./xxx 这种相对路径,相对路径是相对于 cwd,跟普遍的行为是一致的

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还是说 envVariables 的格式?我文档里加了下,我来提交下

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

绝对路径是要从 /Users/xxx/repo/env, 还是 <rootDir>/env, 还是 /env 这样的

Copy link
Collaborator Author

@nighca nighca Sep 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

绝对路径就是文件完整的路径...没有额外的设定,所以感觉不用特别说明

build: {
desc: 'Clean, generate & upload result file',
handler() {
return clean().then(generate).then(upload)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upload 这一步 做成可选的?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fec-builder clean && fec-builder generate 就可以了

bin/fec-builder Outdated

const path = require('path')
const child_process = require('child_process')
let yargs = require('yargs')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

@nighca
Copy link
Collaborator Author

nighca commented Sep 19, 2017

yarn 先不急,单独 PR 做吧。

现在基础 image 用的是 node:6.9.1,对应的 npm 版本是 3.10.8,而 npm 5.x 才支持 lock 吧我记得,所以要换的话还得换 image,或者在 build 时更新 npm,怕有坑哈哈

则代码中:

```js
const apiUrl = API_PREFIX + 'test'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样子的话,会不会太占全局变量了,起名字的时候负担比较大, 改成 ENV.API_PREFIX, 或者其他名字 ?

Copy link
Collaborator Author

@nighca nighca Sep 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得这个能力可以放开来,用户可以自己配置成:

{
	"ENV.API_PREFIX": "http://foobar.com/api",
	"ENV.DEV": true
}

这个样子的

Copy link
Collaborator Author

@nighca nighca Sep 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们默认加一层 ENV 的话,一来会限制能力,如果需求就是某个非 ENV.* 的变量名,那就满足不了了(比如很多第三方库会默认读 process.env.NODE_ENV);二来会多一层变量名的转换逻辑,不直观,也需要额外的文档说明

Copy link
Contributor

@doxiaodong doxiaodong Sep 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在的实现应该是可以写成下面这样的吧

{
    "ENV": {
        "API_PREFIX": "http://foobar.com/api",
        "DEV": true
    }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按现在的实现,会把 ENV 替换成这个 object

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所以还是推荐写完整 ENV.API_PREFIX 这样的方式,webpack 倒也推荐这种方式,不过是针对 process.*,理由不同:https://webpack.js.org/plugins/define-plugin/#feature-flags

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

en

@nighca
Copy link
Collaborator Author

nighca commented Sep 19, 2017

@doxiaodong 你看还有别的问题不

@nighca
Copy link
Collaborator Author

nighca commented Sep 19, 2017

最好是拉下去代码你本地用试试,没有集成测试好慌…

@doxiaodong
Copy link
Contributor

不要慌,不要慌,我空了看看

@doxiaodong
Copy link
Contributor

已测试

@doxiaodong doxiaodong mentioned this pull request Sep 20, 2017
@nighca nighca merged commit ebefae9 into qiniu:master Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants