Skip to content

Commit

Permalink
feat(cli): 生成 swan 的项目配置文件
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Sep 29, 2018
1 parent cfdcb1c commit a49c65e
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 121 deletions.
2 changes: 1 addition & 1 deletion packages/taro-cli/src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function build (args, buildConfig) {
buildForUILibrary({ watch })
break
default:
console.log(chalk.red('输入类型错误,目前只支持weapp/h5/rn三端类型'))
console.log(chalk.red('输入类型错误,目前只支持 weapp/h5/rn/swan 四端类型'))
}
}

Expand Down
37 changes: 27 additions & 10 deletions packages/taro-cli/src/weapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -927,17 +927,34 @@ async function compileScriptFile (content) {
}

function buildProjectConfig () {
const projectConfigPath = path.join(appPath, 'project.config.json')
if (!fs.existsSync(projectConfigPath)) {
return
let projectConfigFileName = ''
if (buildAdapter === Util.BUILD_TYPES.WEAPP) {
projectConfigFileName = 'project.config.json'
const projectConfigPath = path.join(appPath, projectConfigFileName)
if (!fs.existsSync(projectConfigPath)) {
return
}
const origProjectConfig = fs.readJSONSync(projectConfigPath)
fs.ensureDirSync(outputDir)
fs.writeFileSync(
path.join(outputDir, projectConfigFileName),
JSON.stringify(Object.assign({}, origProjectConfig, { miniprogramRoot: './' }), null, 2)
)
} else if (buildAdapter === Util.BUILD_TYPES.SWAN) {
projectConfigFileName = 'project.swan.json'
const projectConfigObj = {
appid: 'testappid',
setting: {
urlCheck: false
}
}
fs.ensureDirSync(outputDir)
fs.writeFileSync(
path.join(outputDir, projectConfigFileName),
JSON.stringify(projectConfigObj, null, 2)
)
}
const origProjectConfig = fs.readJSONSync(projectConfigPath)
fs.ensureDirSync(outputDir)
fs.writeFileSync(
path.join(outputDir, 'project.config.json'),
JSON.stringify(Object.assign({}, origProjectConfig, { miniprogramRoot: './' }), null, 2)
)
Util.printLog(Util.pocessTypeEnum.GENERATE, '工具配置', `${outputDirName}/project.config.json`)
Util.printLog(Util.pocessTypeEnum.GENERATE, '工具配置', `${outputDirName}/${projectConfigFileName}`)
}

async function buildEntry () {
Expand Down
Loading

0 comments on commit a49c65e

Please sign in to comment.