@dcloudio/uni-cli-shared
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -0,1 +1,2 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
@@ -20,6 +21,6 @@ | ||
function filterPages (pages = []) { | ||
function filterPages (pages = [], root) { | ||
for (let i = pages.length - 1; i >= 0; i--) { | ||
const page = pages[i] | ||
if (!isValidPage(page.path)) { | ||
if (!isValidPage(page, root)) { | ||
pages.splice(i, 1) | ||
@@ -31,2 +32,7 @@ } | ||
function processPagesJson (pagesJson) { | ||
if (pagesJson.pages && pagesJson.pages.length) { // 如果首页是 nvue | ||
if (isNVuePage(pagesJson.pages[0])) { | ||
process.UNI_NVUE_ENTRY_PAGE_PATH = pagesJson.pages[0].path | ||
} | ||
} | ||
// pages | ||
@@ -37,13 +43,43 @@ filterPages(pagesJson.pages) | ||
pagesJson.subPackages.forEach(subPackage => { | ||
filterPages(subPackage.pages) | ||
filterPages(subPackage.pages, subPackage.root) | ||
}) | ||
} | ||
if (Object.keys(process.UNI_NVUE_PAGES).length) { // 跨进程无法访问到 process 设置好的数据,直接挂在 pagesJson 上 | ||
pagesJson.nvue = { | ||
pages: process.UNI_NVUE_PAGES | ||
} | ||
if (process.UNI_NVUE_ENTRY_PAGE_PATH) { | ||
pagesJson.nvue.entryPagePath = process.UNI_NVUE_ENTRY_PAGE_PATH | ||
} | ||
} | ||
return pagesJson | ||
} | ||
function isValidPage (pagePath) { | ||
function isNVuePage (page, root = '') { | ||
if (process.env.UNI_PLATFORM === 'app-plus') { | ||
const pagePath = path.join(root, page.path) | ||
if (fs.existsSync(path.resolve(process.env.UNI_INPUT_DIR, pagePath + '.nvue'))) { // cache一下结果?如果文件被删除,cache 就会出现错误 | ||
// 存储 nvue 相关信息 | ||
process.UNI_NVUE_ENTRY[pagePath] = path.resolve(process.env.UNI_INPUT_DIR, pagePath + '.nvue') + '?entry' | ||
process.UNI_NVUE_PAGES[pagePath + '.html'] = { | ||
'window': page.style || {} | ||
} | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
function isValidPage (page, root) { | ||
const pagePath = page.path | ||
if (pagePath.indexOf('platforms') === 0) { // 平台相关 | ||
return pagePath.indexOf('platforms/' + process.env.UNI_PLATFORM) === 0 | ||
} | ||
if (isNVuePage(page, root)) { | ||
return false | ||
} | ||
return true | ||
@@ -58,2 +94,6 @@ } | ||
process.UNI_ENTRY = {} | ||
process.UNI_NVUE_ENTRY = {} | ||
process.UNI_NVUE_PAGES = {} | ||
function parsePages (pagesJson, pageCallback, subPageCallback) { | ||
@@ -67,2 +107,6 @@ if (!pagesJson) { | ||
} | ||
process.UNI_NVUE_ENTRY = {} | ||
process.UNI_NVUE_PAGES = {} | ||
process.UNI_SUB_PACKAGES_ROOT = {} | ||
@@ -69,0 +113,0 @@ |
{ | ||
"name": "@dcloudio/uni-cli-shared", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "uni-cli-shared", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
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
24206
429
18