chore(mp-harmony): 修正子包 HAR name 字段 + 纳入元数据到 git
背景:
mp-harmony 项目的 5 个 ascf shared HAR 子包 (components_diy / pages_goods /
pages_order / pages_promotion / pages_tool) 在 ascf_build 目录下, 关键
元数据 (oh-package.json5 / module.json5 / build-profile.json5 /
Index.ets / hvigorfile.ts / obfuscation-rules.txt) 之前被 .gitignore
整体忽略, 从未被 git 跟踪, 导致 "module.name 被清空" 等回归无法被
git diff / blame 追踪。
改动:
1. .gitignore 改造
- 不再整体 ignore ascf_build
- 精确 ignore 已知产物路径 (rawfile/**/*.pack.js / rawfile/**/*.html
/ rawfile/**/*.json / build/ / oh_modules/ / .preview/ / .cxx/
/ .test/ / node_modules/)
- ! 取反保留 HAR 必需文件 (placeholder/index.*, rawfile/index.js,
base/element/*.json)
- 补充 entry / hvigor / 鸿蒙签名材料 / IDE 临时文件 ignore 规则
2. 首次将 5 个 HAR 包的元数据纳入 git (40 个文件)
3. 新增 scripts/fix-subpackage-module-names.js: 任何入口 require
vue.config.js 时自动修复 oh-package.json5.name + module.json5.module.name
双重覆盖, 防止 DevEco ohpm 报 "00604007 Field IS Empty Error" 或
hvigor 报 "Schema validate failed"
4. vue.config.js 顶层 IIFE 触发修复 (任何 require 立即生效, 不依赖
webpack 钩子)
5. entry/scripts/check-har-deps.js 扩展: 校验 ascf_build 子包
module.json5.module.name 字段 (兜底校验)
6. entry/har-deps-required.json5 扩展: 新增 subpackageModuleJson5
路径映射 + ohModulesRoots 校验资源齐备性
7. entry/README-HAR-DEPS.md 更新: 故障速查表新增 module.name 相关
报错条目
预期效果:
- HBuilderX 触发 vue-cli-service build → vue.config.js 自动修复子包
name → DevEco ohpm install / hvigor schema 校验通过
- check-har-deps.js 兜底, 任何回归立即被检测并报错
- 团队成员 git pull 后能立即看到 ascf_build 元数据, 可用 git diff
跟踪 module.name 等关键字段变更
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"apiType": "stageMode",
|
||||
"buildOption": {
|
||||
},
|
||||
"buildOptionSet": [
|
||||
{
|
||||
"name": "release",
|
||||
"arkOptions": {
|
||||
"obfuscation": {
|
||||
"ruleOptions": {
|
||||
"enable": true,
|
||||
"files": [
|
||||
"./obfuscation-rules.txt"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { hspTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
system: hspTasks,
|
||||
plugins: []
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Define project specific obfuscation rules here.
|
||||
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
||||
#
|
||||
# For more details, see
|
||||
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
|
||||
|
||||
# Obfuscation options:
|
||||
# -disable-obfuscation: disable all obfuscations
|
||||
# -enable-property-obfuscation: obfuscate the property names
|
||||
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
||||
# -compact: remove unnecessary blank spaces and all line feeds
|
||||
# -remove-log: remove all console.* statements
|
||||
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
||||
# -apply-namecache: reuse the given cache file
|
||||
|
||||
# Keep options:
|
||||
# -keep-property-name: specifies property names that you want to keep
|
||||
# -keep-global-name: specifies names that you want to keep in the global scope
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "components_diy",
|
||||
"version": "1.0.0",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "Index.ets",
|
||||
"author": "",
|
||||
"license": "Apache-2.0",
|
||||
"packageType": "InterfaceHar",
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"module": {
|
||||
"name": "components_diy",
|
||||
"type": "shared",
|
||||
"description": "subpackage",
|
||||
"deviceTypes": [
|
||||
"phone"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shared_desc",
|
||||
"value": "description"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0, viewport-fit=cover" />
|
||||
<link rel="stylesheet" href="assets://base.css" type="text/css" media="screen" charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="holder"></div>
|
||||
<script src='assets://renderer.js'></script>
|
||||
<script type="text/javascript" src='/app.css.js'></script>
|
||||
<script type="text/javascript" src="/components-diy/placeholder/index.pack.js" ></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* ATTENTION: An "eval-source-map" devtool has been used.
|
||||
* This devtool is neither made for production nor for readable output files.
|
||||
* It uses "eval()" calls to create a separate source file with attached SourceMaps in the browser devtools.
|
||||
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
||||
* or disable the default devtool with "devtool: false".
|
||||
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
||||
*/
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ "./components-diy/placeholder/index.css?type=page"
|
||||
/*!********************************************************!*\
|
||||
!*** ./components-diy/placeholder/index.css?type=page ***!
|
||||
\********************************************************/
|
||||
(module) {
|
||||
|
||||
eval("{module.exports = {\n segs:[\".placeholder.data-v-ddfc9ac4{padding:\",[2,40],\";color:#999;text-align:center;font-size:\",[2,24],\"}\"],\n info:{path:\"components-diy/placeholder/index\", type:\"page\"}\n }//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9jb21wb25lbnRzLWRpeS9wbGFjZWhvbGRlci9pbmRleC5jc3M/dHlwZT1wYWdlIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8vLy4vY29tcG9uZW50cy1kaXkvcGxhY2Vob2xkZXIvaW5kZXguY3NzPzE5OTkiXSwic291cmNlc0NvbnRlbnQiOlsibW9kdWxlLmV4cG9ydHMgPSB7XG4gICAgICAgICAgICBzZWdzOltcIi5wbGFjZWhvbGRlci5kYXRhLXYtZGRmYzlhYzR7cGFkZGluZzpcIixbMiw0MF0sXCI7Y29sb3I6Izk5OTt0ZXh0LWFsaWduOmNlbnRlcjtmb250LXNpemU6XCIsWzIsMjRdLFwifVwiXSxcbiAgICAgICAgICAgIGluZm86e3BhdGg6XCJjb21wb25lbnRzLWRpeS9wbGFjZWhvbGRlci9pbmRleFwiLCB0eXBlOlwicGFnZVwifVxuICAgICAgICB9Il0sIm5hbWVzIjpbXSwiaWdub3JlTGlzdCI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///./components-diy/placeholder/index.css?type=page\n\n}");
|
||||
|
||||
/***/ },
|
||||
|
||||
/***/ "./components-diy/placeholder/index.hxml"
|
||||
/*!***********************************************!*\
|
||||
!*** ./components-diy/placeholder/index.hxml ***!
|
||||
\***********************************************/
|
||||
(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
||||
|
||||
eval("{var render = function () {\n var _vm = this,\n _o = _vm._o,\n _n = _vm._n,\n _s = _vm._s,\n _l = _vm._l,\n _t = _vm._t,\n _q = _vm._q,\n _i = _vm._i,\n _m = _vm._m,\n _f = _vm._f,\n _k = _vm._k,\n _b = _vm._b,\n _v = _vm._v,\n _e = _vm._e,\n _u = _vm._u,\n _g = _vm._g,\n _d = _vm._d,\n _p = _vm._p,\n _c = _vm._c,\n $style = _vm.$style,\n $class = _vm.$class,\n $slots = _vm.$slots,\n eventHappen = _vm.eventHappen;\n return _c('q-page', {\n attrs: {\n \"data-internal-update-trigger\": _vm.$dataprops.internal__updateTrigger\n }\n }, [_c('q-view', {\n staticClass: \"placeholder data-v-ddfc9ac4\"\n })], 1);\n};\nvar staticRenderFns = [];\nrender._withStripped = true;\nconst pageConfig = {\n path: \"components-diy/placeholder/index\",\n globalComponents: {},\n jsonData: {},\n components: {},\n render: render,\n type: \"page\",\n staticRenderFns: staticRenderFns,\n _scopeId: \"data-q-afee7ca0\",\n asyncComponents: {},\n placeholderComponents: {}\n};\nglobal.pageLoaded(pageConfig);\nconst cssData = __webpack_require__(/*! ./components-diy/placeholder/index.css?type=page */ \"./components-diy/placeholder/index.css?type=page\");\ninjectStyle(cssData.segs, cssData.sourcemap, cssData.info);//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9jb21wb25lbnRzLWRpeS9wbGFjZWhvbGRlci9pbmRleC5oeG1sIiwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8vLy4vY29tcG9uZW50cy1kaXkvcGxhY2Vob2xkZXIvaW5kZXguaHhtbD9mYTdlIl0sInNvdXJjZXNDb250ZW50IjpbInZhciByZW5kZXIgPSBmdW5jdGlvbiAoKSB7XG4gIHZhciBfdm0gPSB0aGlzLFxuICAgIF9vID0gX3ZtLl9vLFxuICAgIF9uID0gX3ZtLl9uLFxuICAgIF9zID0gX3ZtLl9zLFxuICAgIF9sID0gX3ZtLl9sLFxuICAgIF90ID0gX3ZtLl90LFxuICAgIF9xID0gX3ZtLl9xLFxuICAgIF9pID0gX3ZtLl9pLFxuICAgIF9tID0gX3ZtLl9tLFxuICAgIF9mID0gX3ZtLl9mLFxuICAgIF9rID0gX3ZtLl9rLFxuICAgIF9iID0gX3ZtLl9iLFxuICAgIF92ID0gX3ZtLl92LFxuICAgIF9lID0gX3ZtLl9lLFxuICAgIF91ID0gX3ZtLl91LFxuICAgIF9nID0gX3ZtLl9nLFxuICAgIF9kID0gX3ZtLl9kLFxuICAgIF9wID0gX3ZtLl9wLFxuICAgIF9jID0gX3ZtLl9jLFxuICAgICRzdHlsZSA9IF92bS4kc3R5bGUsXG4gICAgJGNsYXNzID0gX3ZtLiRjbGFzcyxcbiAgICAkc2xvdHMgPSBfdm0uJHNsb3RzLFxuICAgIGV2ZW50SGFwcGVuID0gX3ZtLmV2ZW50SGFwcGVuO1xuICByZXR1cm4gX2MoJ3EtcGFnZScsIHtcbiAgICBhdHRyczoge1xuICAgICAgXCJkYXRhLWludGVybmFsLXVwZGF0ZS10cmlnZ2VyXCI6IF92bS4kZGF0YXByb3BzLmludGVybmFsX191cGRhdGVUcmlnZ2VyXG4gICAgfVxuICB9LCBbX2MoJ3EtdmlldycsIHtcbiAgICBzdGF0aWNDbGFzczogXCJwbGFjZWhvbGRlciBkYXRhLXYtZGRmYzlhYzRcIlxuICB9KV0sIDEpO1xufTtcbnZhciBzdGF0aWNSZW5kZXJGbnMgPSBbXTtcbnJlbmRlci5fd2l0aFN0cmlwcGVkID0gdHJ1ZTtcbmNvbnN0IHBhZ2VDb25maWcgPSB7XG4gIHBhdGg6IFwiY29tcG9uZW50cy1kaXkvcGxhY2Vob2xkZXIvaW5kZXhcIixcbiAgZ2xvYmFsQ29tcG9uZW50czoge30sXG4gIGpzb25EYXRhOiB7fSxcbiAgY29tcG9uZW50czoge30sXG4gIHJlbmRlcjogcmVuZGVyLFxuICB0eXBlOiBcInBhZ2VcIixcbiAgc3RhdGljUmVuZGVyRm5zOiBzdGF0aWNSZW5kZXJGbnMsXG4gIF9zY29wZUlkOiBcImRhdGEtcS1hZmVlN2NhMFwiLFxuICBhc3luY0NvbXBvbmVudHM6IHt9LFxuICBwbGFjZWhvbGRlckNvbXBvbmVudHM6IHt9XG59O1xuZ2xvYmFsLnBhZ2VMb2FkZWQocGFnZUNvbmZpZyk7XG5jb25zdCBjc3NEYXRhID0gcmVxdWlyZShcIkQ6L3Byb2plY3RzL3Nob3AtcHJvamVjdHMvZnJvbnRlbmQvc3R1Yi1hcHAtcHJvamVjdHMvbXAtaGFybW9ueS9hc2NmL2FzY2Zfc3JjL2NvbXBvbmVudHMtZGl5L3BsYWNlaG9sZGVyL2luZGV4LmNzcz90eXBlPXBhZ2VcIik7XG5pbmplY3RTdHlsZShjc3NEYXRhLnNlZ3MsIGNzc0RhdGEuc291cmNlbWFwLCBjc3NEYXRhLmluZm8pOyJdLCJuYW1lcyI6W10sImlnbm9yZUxpc3QiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./components-diy/placeholder/index.hxml\n\n}");
|
||||
|
||||
/***/ }
|
||||
|
||||
/******/ });
|
||||
/************************************************************************/
|
||||
/******/ // The module cache
|
||||
/******/ var __webpack_module_cache__ = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/ // Check if module is in cache
|
||||
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
||||
/******/ if (cachedModule !== undefined) {
|
||||
/******/ return cachedModule.exports;
|
||||
/******/ }
|
||||
/******/ // Check if module exists (development only)
|
||||
/******/ if (__webpack_modules__[moduleId] === undefined) {
|
||||
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
|
||||
/******/ e.code = 'MODULE_NOT_FOUND';
|
||||
/******/ throw e;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||||
/******/ // no module.id needed
|
||||
/******/ // no module.loaded needed
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/
|
||||
/******/ // startup
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ // This entry module can't be inlined because the eval-source-map devtool is used.
|
||||
/******/ var __webpack_exports__ = __webpack_require__("./components-diy/placeholder/index.hxml");
|
||||
/******/
|
||||
/******/ })()
|
||||
;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"apiType": "stageMode",
|
||||
"buildOption": {
|
||||
},
|
||||
"buildOptionSet": [
|
||||
{
|
||||
"name": "release",
|
||||
"arkOptions": {
|
||||
"obfuscation": {
|
||||
"ruleOptions": {
|
||||
"enable": true,
|
||||
"files": [
|
||||
"./obfuscation-rules.txt"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { hspTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
system: hspTasks,
|
||||
plugins: []
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Define project specific obfuscation rules here.
|
||||
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
||||
#
|
||||
# For more details, see
|
||||
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
|
||||
|
||||
# Obfuscation options:
|
||||
# -disable-obfuscation: disable all obfuscations
|
||||
# -enable-property-obfuscation: obfuscate the property names
|
||||
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
||||
# -compact: remove unnecessary blank spaces and all line feeds
|
||||
# -remove-log: remove all console.* statements
|
||||
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
||||
# -apply-namecache: reuse the given cache file
|
||||
|
||||
# Keep options:
|
||||
# -keep-property-name: specifies property names that you want to keep
|
||||
# -keep-global-name: specifies names that you want to keep in the global scope
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "pages_goods",
|
||||
"version": "1.0.0",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "Index.ets",
|
||||
"author": "",
|
||||
"license": "Apache-2.0",
|
||||
"packageType": "InterfaceHar",
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"module": {
|
||||
"name": "pages_goods",
|
||||
"type": "shared",
|
||||
"description": "subpackage",
|
||||
"deviceTypes": [
|
||||
"phone"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shared_desc",
|
||||
"value": "description"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"apiType": "stageMode",
|
||||
"buildOption": {
|
||||
},
|
||||
"buildOptionSet": [
|
||||
{
|
||||
"name": "release",
|
||||
"arkOptions": {
|
||||
"obfuscation": {
|
||||
"ruleOptions": {
|
||||
"enable": true,
|
||||
"files": [
|
||||
"./obfuscation-rules.txt"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { hspTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
system: hspTasks,
|
||||
plugins: []
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Define project specific obfuscation rules here.
|
||||
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
||||
#
|
||||
# For more details, see
|
||||
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
|
||||
|
||||
# Obfuscation options:
|
||||
# -disable-obfuscation: disable all obfuscations
|
||||
# -enable-property-obfuscation: obfuscate the property names
|
||||
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
||||
# -compact: remove unnecessary blank spaces and all line feeds
|
||||
# -remove-log: remove all console.* statements
|
||||
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
||||
# -apply-namecache: reuse the given cache file
|
||||
|
||||
# Keep options:
|
||||
# -keep-property-name: specifies property names that you want to keep
|
||||
# -keep-global-name: specifies names that you want to keep in the global scope
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "pages_order",
|
||||
"version": "1.0.0",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "Index.ets",
|
||||
"author": "",
|
||||
"license": "Apache-2.0",
|
||||
"packageType": "InterfaceHar",
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"module": {
|
||||
"name": "pages_order",
|
||||
"type": "shared",
|
||||
"description": "subpackage",
|
||||
"deviceTypes": [
|
||||
"phone"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shared_desc",
|
||||
"value": "description"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"apiType": "stageMode",
|
||||
"buildOption": {
|
||||
},
|
||||
"buildOptionSet": [
|
||||
{
|
||||
"name": "release",
|
||||
"arkOptions": {
|
||||
"obfuscation": {
|
||||
"ruleOptions": {
|
||||
"enable": true,
|
||||
"files": [
|
||||
"./obfuscation-rules.txt"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { hspTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
system: hspTasks,
|
||||
plugins: []
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Define project specific obfuscation rules here.
|
||||
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
||||
#
|
||||
# For more details, see
|
||||
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
|
||||
|
||||
# Obfuscation options:
|
||||
# -disable-obfuscation: disable all obfuscations
|
||||
# -enable-property-obfuscation: obfuscate the property names
|
||||
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
||||
# -compact: remove unnecessary blank spaces and all line feeds
|
||||
# -remove-log: remove all console.* statements
|
||||
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
||||
# -apply-namecache: reuse the given cache file
|
||||
|
||||
# Keep options:
|
||||
# -keep-property-name: specifies property names that you want to keep
|
||||
# -keep-global-name: specifies names that you want to keep in the global scope
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "pages_promotion",
|
||||
"version": "1.0.0",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "Index.ets",
|
||||
"author": "",
|
||||
"license": "Apache-2.0",
|
||||
"packageType": "InterfaceHar",
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"module": {
|
||||
"name": "pages_promotion",
|
||||
"type": "shared",
|
||||
"description": "subpackage",
|
||||
"deviceTypes": [
|
||||
"phone"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shared_desc",
|
||||
"value": "description"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"apiType": "stageMode",
|
||||
"buildOption": {
|
||||
},
|
||||
"buildOptionSet": [
|
||||
{
|
||||
"name": "release",
|
||||
"arkOptions": {
|
||||
"obfuscation": {
|
||||
"ruleOptions": {
|
||||
"enable": true,
|
||||
"files": [
|
||||
"./obfuscation-rules.txt"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { hspTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
system: hspTasks,
|
||||
plugins: []
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Define project specific obfuscation rules here.
|
||||
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
||||
#
|
||||
# For more details, see
|
||||
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
|
||||
|
||||
# Obfuscation options:
|
||||
# -disable-obfuscation: disable all obfuscations
|
||||
# -enable-property-obfuscation: obfuscate the property names
|
||||
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
||||
# -compact: remove unnecessary blank spaces and all line feeds
|
||||
# -remove-log: remove all console.* statements
|
||||
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
||||
# -apply-namecache: reuse the given cache file
|
||||
|
||||
# Keep options:
|
||||
# -keep-property-name: specifies property names that you want to keep
|
||||
# -keep-global-name: specifies names that you want to keep in the global scope
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "pages_tool",
|
||||
"version": "1.0.0",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "Index.ets",
|
||||
"author": "",
|
||||
"license": "Apache-2.0",
|
||||
"packageType": "InterfaceHar",
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"module": {
|
||||
"name": "pages_tool",
|
||||
"type": "shared",
|
||||
"description": "subpackage",
|
||||
"deviceTypes": [
|
||||
"phone"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shared_desc",
|
||||
"value": "description"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -70,4 +70,76 @@ node scripts/check-har-deps.js --rawfile --strict
|
||||
| 首页只显示 TabBar,无 DIY 内容 | components_diy 缺失 | 加 file: 依赖 + Sync + Build |
|
||||
| 12s splash 后页面空白 | 任意一个 HAR 子包缺失 | 跑校验脚本看哪个缺失 |
|
||||
| 商品分类页空白 | pages_goods 缺失 | 同上 |
|
||||
| "应用未关联服务空间" 报错 | uniCloud 服务未关联(与本依赖无关) | uniCloud 目录右键关联服务空间 |
|
||||
| "Schema validate failed: must match pattern '^[a-zA-Z][0-9a-zA-Z_.]*$'... module.name" | vue.config.js 重新生成时把 pages_tool 的 module.json5.module.name 清空了 | vue.config.js 已自动修复(`_copyMpHarmonyBuild` 末尾调用 `fixSubpackageModuleNames`)。如需手动跑:`node -e "require('./vue.config.js').fixSubpackageModuleNames()"` |
|
||||
| "00604007 Field IS Empty Error: The name of package .../pages_tool cannot be empty" (DevEco 打开项目时 ohpm install 报) | `pages_tool/oh-package.json5` 的 top-level `name` 是空字符串 | `node scripts/fix-subpackage-module-names.js`,会同时修 oh-package.json5 和 module.json5 |
|
||||
| "应用未关联服务空间" 报错 | uniCloud 服务未关联(与本依赖无关) | uniCloud 目录右键关联服务空间 |
|
||||
|
||||
## 子包 module.name 容易丢失的原因
|
||||
|
||||
`vue.config.js` 重新生成鸿蒙元服务产物时,会重新输出 `ascf_build/<pkg>/src/main/module.json5`。
|
||||
其中 `module.name` 字段如果模板里没正确读取 `pkgName`(或没设置),会被写成空串。
|
||||
|
||||
**已自动化修复**:
|
||||
|
||||
`vue.config.js` 暴露了 `fixSubpackageModuleNames()` 函数,会在以下场景自动触发:
|
||||
|
||||
1. **顶层副作用**:vue.config.js 被任何入口 require 时(**包括 HBuilderX 触发 vue-cli-service build**),
|
||||
立即遍历 5 个子包,强制把 `module.name` 修正为包目录名。
|
||||
2. **构建流程**:mp-harmony 生产构建的 `_copyMpHarmonyBuild()` 末尾也会再调一次。
|
||||
|
||||
**也就是说:只要 HBuilderX / 命令行 触发了 vue.config.js(构建必然触发),module.name 就被保证正确,无需任何手动操作。**
|
||||
|
||||
手动调用方式:
|
||||
|
||||
```bash
|
||||
# 直接跑独立脚本 (推荐)
|
||||
node scripts/fix-subpackage-module-names.js
|
||||
```
|
||||
|
||||
或者 require 模块(vue.config.js 内部用的就是这个):
|
||||
|
||||
```bash
|
||||
node -e "require('./scripts/fix-subpackage-module-names').fixSubpackageModuleNames()"
|
||||
```
|
||||
|
||||
> ⚠️ **重要**:vue.config.js 不再 export `fixSubpackageModuleNames`。历史教训:之前把 `fixSubpackageModuleNames` 放在 `module.exports` 上,vue-cli-service 校验 vue.config.js 导出的 keys 时会报:
|
||||
>
|
||||
> `Invalid options in vue.config.js: "fixSubpackageModuleNames" is not allowed`
|
||||
>
|
||||
> 现在函数在独立模块里,vue.config.js 通过顶层 IIFE 调用它,导出干净。
|
||||
|
||||
输出示例:
|
||||
|
||||
```
|
||||
🔧 [vue.config] 修正 ascf_build 子包 module.json5.module.name...
|
||||
✅ components_diy: module.name "(空)" → "components_diy"
|
||||
✅ pages_goods: module.name "(空)" → "pages_goods"
|
||||
✅ pages_order: module.name "(空)" → "pages_order"
|
||||
✅ pages_promotion: module.name "(空)" → "pages_promotion"
|
||||
✅ pages_tool: module.name "(空)" → "pages_tool"
|
||||
📊 修正完成: 5 个子包被更新
|
||||
```
|
||||
|
||||
校验脚本 `check-har-deps.js` 仍作为兜底防线,确保 module.name 不会再次被覆盖为空。
|
||||
|
||||
**完整工作流(HBuilderX "发行" → "鸿蒙元服务")**:
|
||||
|
||||
1. HBuilderX 调 uniapp 编译器生成 `unpackage/dist/build/.mp-harmony/`
|
||||
2. HBuilderX 调 vue-cli-service build → `require('./vue.config.js')`
|
||||
3. **顶层 IIFE 触发 → 自动修复 5 个子包 module.json5.module.name**
|
||||
4. webpack 编译 → `VersionInjectPlugin._copyMpHarmonyBuild()` 拷产物到 ascf_src
|
||||
5. **再次触发 `fixSubpackageModuleNames()`(防御性)**
|
||||
6. DevEco Studio 用 ascf_src 构建鸿蒙 HAP(此时 module.name 已正确)
|
||||
|
||||
**手动修复**(如需保留原 module.json5 内容但 name 字段错了):
|
||||
|
||||
```json5
|
||||
{
|
||||
"module": {
|
||||
"name": "<包目录名, 比如 pages_tool>",
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`name` 必须匹配 `[a-zA-Z][0-9a-zA-Z_.]*`(鸿蒙 schema 要求)。
|
||||
@@ -60,4 +60,16 @@
|
||||
pages_promotion:{ pkg: "pages_promotion",root: "pages_promotion" },
|
||||
pages_tool: { pkg: "pages_tool", root: "pages_tool" },
|
||||
},
|
||||
|
||||
// 每个子包在 ascf_build 中的 src/main/module.json5 路径 (相对 mp-harmony 目录)
|
||||
// 用于校验 module.name 字段是否被 vue.config.js 重新生成时清空
|
||||
// 现象: pages_tool 的 module.json5 的 module.name 被覆盖成 "",
|
||||
// 导致 hvigor schema 校验失败, build 阶段直接退出。
|
||||
subpackageModuleJson5: {
|
||||
components_diy: "./ascf/ascf_build/components_diy/src/main/module.json5",
|
||||
pages_goods: "./ascf/ascf_build/pages_goods/src/main/module.json5",
|
||||
pages_order: "./ascf/ascf_build/pages_order/src/main/module.json5",
|
||||
pages_promotion: "./ascf/ascf_build/pages_promotion/src/main/module.json5",
|
||||
pages_tool: "./ascf/ascf_build/pages_tool/src/main/module.json5",
|
||||
},
|
||||
}
|
||||
@@ -173,6 +173,38 @@ function main() {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 4. 校验 ascf_build 子包 module.json5 的 module.name 字段 ----
|
||||
// 防止 vue.config.js 重新生成时把 module.name 清空, 导致 hvigor schema 校验失败
|
||||
console.log();
|
||||
console.log(color('--- ascf_build 子包 module.json5 检查 ---', 'cyan'));
|
||||
const mpHarmonyDir = path.resolve(ENTRY_DIR, '..');
|
||||
const subpackageModuleJson5 = config.subpackageModuleJson5 || {};
|
||||
for (const har of requiredHarDeps) {
|
||||
const rel = subpackageModuleJson5[har];
|
||||
if (!rel) continue;
|
||||
const moduleJson5Path = path.resolve(mpHarmonyDir, rel);
|
||||
if (!exists(moduleJson5Path)) {
|
||||
warnings.push(`ascf_build/${har}/src/main/module.json5 缺失 (${moduleJson5Path})`);
|
||||
console.log(color(` ⚠ ${moduleJson5Path} 不存在`, 'yellow'));
|
||||
continue;
|
||||
}
|
||||
let mj;
|
||||
try {
|
||||
mj = loadJson5(moduleJson5Path);
|
||||
} catch (e) {
|
||||
errors.push(`${har} 的 module.json5 解析失败: ${e.message}`);
|
||||
console.log(color(` ✘ ${har} module.json5 解析失败`, 'red'));
|
||||
continue;
|
||||
}
|
||||
const moduleName = mj && mj.module && mj.module.name;
|
||||
if (!moduleName || moduleName !== har) {
|
||||
errors.push(`${har} 的 module.json5.module.name 异常: "${moduleName}" (应为 "${har}", 常见原因: vue.config.js 重新生成时未写入 packageName)`);
|
||||
console.log(color(` ✘ ${har} module.name = "${moduleName}" (应为 "${har}")`, 'red'));
|
||||
} else {
|
||||
console.log(color(` ✔ ${har} module.name = "${moduleName}"`, 'green'));
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 总结 ----
|
||||
console.log();
|
||||
if (warnings.length) {
|
||||
|
||||
Reference in New Issue
Block a user