UNPKG

vivo-hap-toolkit

Version:

A command line toolkit for developing Quick Apps.

3 lines (2 loc) 1.28 kB
"use strict";const path=require("path"),{colorconsole:colorconsole}=require("@vivo-hap-toolkit/shared-utils"),{ENTRY_TYPE:ENTRY_TYPE}=require("@vivo-hap-toolkit/packager/lib/common/utils"),{resolveFile:resolveFile}=require("@vivo-hap-toolkit/packager/lib/common/info");exports.resolveEntries=function(e,o,r){if(!e.router)throw Error("manifest.json 中未配置路由!");const t={},s=e.router.pages||{},i=[{confs:e.router.widgets||{},type:ENTRY_TYPE.CARD}];i.unshift({confs:s,type:ENTRY_TYPE.PAGE});const n=resolveFile(path.join(o,"app"));n||(colorconsole.error("app 文件不存在"),process.exit(1)),t.app="./"+path.relative(r,n)+"?uxType="+ENTRY_TYPE.APP,i.forEach(({confs:e,type:s})=>{Object.keys(e).forEach(i=>{const n=e[i],l=path.join(i,n.component),c=resolveFile(path.join(o,l));c||colorconsole.throw("编译失败:请确认manifest.json中配置的文件路径存在:"+l),/^\//.test(i)&&colorconsole.throw(`编译失败:请确认manifest.json中router.pages配置的 '${i}' 为目录名`);let a=path.relative(r,c);a="./"+a+"?uxType="+s,a=a.replace(/\\/g,"/"),t[l]=a})});const l=e.workers;return l&&l.entries&&l.entries instanceof Array&&l.entries.filter(e=>e.file).forEach(e=>{t[e.file.replace(/\.js$/,"")]="./src/"+e.file}),t}; //# sourceMappingURL=utils.js.map