@microprogram/plugin-router
Advanced tools
+37
-1
@@ -12,3 +12,35 @@ 'use strict' | ||
| function plugin(jsonPath, platform) { | ||
| function rewritePrivateConfig(pages) { | ||
| const privateJsonPath = path.resolve(cwd, 'project.private.config.json') | ||
| if (fs.existsSync(privateJsonPath)) { | ||
| const privateJson = readJsonFile(privateJsonPath) | ||
| // filter non-existent paths | ||
| const pureList = privateJson.condition.miniprogram.list.filter((item) => pages.indexOf(item.pathName) !== -1) | ||
| function hasSamePath(page) { | ||
| return pureList.find(item => item.pathName === page) | ||
| } | ||
| pages.forEach((page) => { | ||
| if (!hasSamePath(page)) { | ||
| pureList.push({ | ||
| "name": page.replace('pages/', '').replace('/index', ''), | ||
| "pathName": page, | ||
| "query": "", | ||
| "scene": null | ||
| }) | ||
| } | ||
| }) | ||
| privateJson.condition.miniprogram.list = pureList | ||
| fs.writeFileSync(privateJsonPath, JSON.stringify(privateJson, null, 2)) | ||
| } | ||
| } | ||
| function plugin(jsonPath, config) { | ||
| const { platform, plugins } = config | ||
| const { autoGenPrivateConfig } = plugins.router | ||
| return through.obj(function (chunk, _, cb) { | ||
@@ -61,2 +93,3 @@ if (chunk.isNull()) { | ||
| // rewrite app.json | ||
| var json = readJsonFile(appJsonPath) || {} | ||
@@ -76,2 +109,5 @@ json.pages = pages | ||
| fs.writeFileSync(appJsonPath, JSON.stringify(json, null, 2)) | ||
| // rewrite project.private.config.json | ||
| autoGenPrivateConfig && rewritePrivateConfig(pages) | ||
| } | ||
@@ -78,0 +114,0 @@ |
+2
-2
| { | ||
| "name": "@microprogram/plugin-router", | ||
| "version": "1.0.0-beta.16", | ||
| "version": "1.0.0-beta.29", | ||
| "author": "JserWang", | ||
@@ -31,3 +31,3 @@ "files": [ | ||
| }, | ||
| "gitHead": "1904f773b00b2bea54b43f9bbe088e2ae2a8705e" | ||
| "gitHead": "2001822e2bf606b8f67431afa62b8f2d00e4e225" | ||
| } |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
5431
24.48%98
40%