@atomicservice/ascf-toolkit-hvigor-plugin 1.0.6-beta.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,n,
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var r=e(t),o=0;o<r.length;o++)"default"!==r[o]&&__createBinding(n,t,r[o]);return __setModuleDefault(n,t),n}}(),__awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function l(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,l)}a((r=r.apply(e,t||[])).next())})},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.doInstallAscfHspPlugin=doInstallAscfHspPlugin,exports.default=installAscfHspPlugin;const hvigor_1=require("@ohos/hvigor"),hvigor_ohos_plugin_1=require("@ohos/hvigor-ohos-plugin"),child_process_1=require("child_process"),path_1=__importDefault(require("path")),fs_1=__importDefault(require("fs")),JSON5=__importStar(require("json5")),logger=hvigor_1.HvigorLogger.getLogger("installAscfHspPlugin");function execSafe(e){var t;try{return null===(t=(0,child_process_1.execSync)(e))||void 0===t?void 0:t.toString("utf8")}catch(e){logger.warn("exec cmd error",e)}}function checkProjectAscfVer(e){var t;logger.debug("Check project ascf dependency version.");let n=path_1.default.resolve(e,"./oh-package.json");if(!fs_1.default.existsSync(n)&&(n+="5",!fs_1.default.existsSync(n)))return logger.warn(`Check oh-package failed. Not found ${n}.`),!1;const r=null===(t=JSON5.parse(fs_1.default.readFileSync(n).toString()))||void 0===t?void 0:t.dependencies;return logger.debug(`ohPkgDeps: ${JSON.stringify(r)}`),!!Object.prototype.hasOwnProperty.call(r,"@atomicservice/ascf")}function checkAscfHsp(e){var t;logger.debug(`Check and install ${e} for local development`);const n=null!==(t=execSafe("hdc shell bm dump-shared -a"))&&void 0!==t?t:"";if(new RegExp(`${e}(\\r?\\n|$)`).test(n)){const t=execSafe(`hdc shell "bm dump-shared -n ${e} | grep versionName"`);return logger.debug(`found ${e} ${t}`),!0}return!1}function doInstallAscfHsp(e,t,n){var r;const o=checkProjectAscfVer(null===(r=e.getNodeByName("entry"))||void 0===r?void 0:r.getNodePath()),i=o?"com.huawei.hms.ascf":"com.huawei.hms.ascfruntime",s=`${i} install failed, please open helloUniapp manually.`;if(checkAscfHsp(i))return void t();logger.debug(`trying to install ${i}`);const l=path_1.default.resolve(__dirname,"../config.json"),a=JSON.parse(fs_1.default.readFileSync(l).toString()),c=execSafe(`hdc shell aa start -b com.huawei.hmos.browser -a MainAbility -A ohos.want.action.viewData -U "${o?a.ascfHspUrl:a.ascfRuntimeHspUrl}"`);if(!(null==c?void 0:c.includes("successfully")))return logger.warn(`${s} errorInfo=${c}`),void n(s);logger.debug("begin to wait install hsp");let u=0,g=setInterval(()=>{const e=checkAscfHsp(i);if(u++,e||u>5)return clearInterval(g),void(e?t():(logger.warn(s),n(s)))},1e3)}function doInstallAscfHspPlugin(e,t){return __awaiter(this,void 0,void 0,function*(){logger.debug("start exec install ascf hsp plugin");const n=e.getContext(hvigor_ohos_plugin_1.OhosPluginId.OHOS_APP_PLUGIN),r=t.getNodeByName("entry"),o=r.getContext(hvigor_ohos_plugin_1.OhosPluginId.OHOS_HAP_PLUGIN);"debug"===(null==n?void 0:n.getBuildMode())&&(null==o||o.targets(e=>{const n=e.getTargetName();logger.debug(`installAscfHspPlugin targetName:${n}`),r.registerTask({name:"installAscfHspTask",run:()=>new Promise((e,n)=>doInstallAscfHsp(t,e,n)).catch(e=>logger.error(e)),dependencies:[`${n}@CompileArkTS`],postDependencies:[`${n}@PackageHap`]})}),logger.debug("exec install ascf hsp plugin completed"))})}function installAscfHspPlugin(){return{pluginId:"installAscfHspPlugin",apply:e=>doInstallAscfHspPlugin(e,hvigor_1.hvigor)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,o,t,n){void 0===n&&(n=t);var r=Object.getOwnPropertyDescriptor(o,t);r&&!("get"in r?!o.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return o[t]}}),Object.defineProperty(e,n,r)}:function(e,o,t,n){void 0===n&&(n=t),e[n]=o[t]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,o){Object.defineProperty(e,"default",{enumerable:!0,value:o})}:function(e,o){e.default=o}),__importStar=this&&this.__importStar||function(){var e=function(o){return e=Object.getOwnPropertyNames||function(e){var o=[];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(o[o.length]=t);return o},e(o)};return function(o){if(o&&o.__esModule)return o;var t={};if(null!=o)for(var n=e(o),r=0;r<n.length;r++)"default"!==n[r]&&__createBinding(t,o,n[r]);return __setModuleDefault(t,o),t}}(),__awaiter=this&&this.__awaiter||function(e,o,t,n){return new(t||(t=Promise))(function(r,i){function l(e){try{d(n.next(e))}catch(e){i(e)}}function u(e){try{d(n.throw(e))}catch(e){i(e)}}function d(e){var o;e.done?r(e.value):(o=e.value,o instanceof t?o:new t(function(e){e(o)})).then(l,u)}d((n=n.apply(e,o||[])).next())})},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.doModifyShareInfoPlugin=doModifyShareInfoPlugin,exports.default=modifyShareInfoPlugin;const hvigor_1=require("@ohos/hvigor"),hvigor_ohos_plugin_1=require("@ohos/hvigor-ohos-plugin"),path_1=__importDefault(require("path")),fs_1=__importDefault(require("fs")),common_utils_1=require("../common/common-utils"),JSON5=__importStar(require("json5")),logger=hvigor_1.HvigorLogger.getLogger("modifyShareInfoPlugin");function addShareInfo(e,o){var t,n,r,i,l,u,d,a;logger.debug(`addShareInfo srcPath ${o}`);let s=path_1.default.resolve(o,"src/main/module.json");if(!fs_1.default.existsSync(s)&&(s+="5",!fs_1.default.existsSync(s)))return;logger.debug(`addShareInfo modulePath ${s}`);const f=JSON5.parse(fs_1.default.readFileSync(s).toString());logger.debug(`addShareInfo srcModuleJson ${JSON.stringify(f,null," ")}`);const g=null!==(n=null===(t=null==f?void 0:f.app)||void 0===t?void 0:t.bundleName)&&void 0!==n?n:"",c=null!==(i=null===(r=null==f?void 0:f.app)||void 0===r?void 0:r.versionCode)&&void 0!==i?i:0,h=null!==(u=null===(l=null==f?void 0:f.module)||void 0===l?void 0:l.name)&&void 0!==u?u:"",_=null!==(a=null===(d=null==f?void 0:f.module)||void 0===d?void 0:d.type)&&void 0!==a?a:"";if("shared"===_&&g&&0!==c&&h){const o={bundleName:g,moduleName:h,versionCode:c};e.push(o)}else if("shared"===_&&!g&&0===c&&h){const o={moduleName:h};e.push(o)}}function getSharedInfos(e){const o=[],t=path_1.default.resolve(e,"oh_modules"),n=fs_1.default.readdirSync(t);return logger.debug(`moduleFileNames=${n}`),n.filter(e=>e&&!e.startsWith(".")).forEach(n=>{if(logger.debug(`moduleFileName=${n}`),n.startsWith("@")){const t=path_1.default.resolve(e,`oh_modules/${n}`),r=fs_1.default.readdirSync(t);logger.debug(`cloudModuleFileNames=${r}`),r.forEach(e=>{logger.debug(`cloudModuleFileName=${e}`),addShareInfo(o,path_1.default.resolve(t,`${e}`))})}else addShareInfo(o,path_1.default.resolve(t,`${n}`))}),o}function updateSharedInfo(e){const o=path_1.default.resolve(e,"build");if(!fs_1.default.existsSync(o))return void logger.debug("buildFilePath:"+o);const t=getSharedInfos(e);if(!(null==t?void 0:t.length))return void logger.debug("dependencies is empty");const n=fs_1.default.readdirSync(o);logger.debug("buildFileNames:"+n),n.filter(e=>e).forEach(e=>{logger.debug("productName: "+e);const n=path_1.default.resolve(o,`${e}/intermediates/res/${e}/module.json`);if(logger.debug("module.json filePath: "+n),fs_1.default.existsSync(n)){const e=(0,common_utils_1.readJson)(n);e.module.dependencies=t,(0,common_utils_1.writeJson)(n,e),logger.debug(`final moduleJson ${JSON.stringify(e,null," ")}`)}else logger.debug("module.json filePath: "+n+" is not Exists");const r=path_1.default.resolve(o,`${e}/intermediates/hap_metadata/${e}/output_metadata.json`);if(logger.debug("output_metadata.json filePath: "+r),fs_1.default.existsSync(r)){const e=(0,common_utils_1.readJson)(r);null==e||e.forEach(e=>{var o;const t=null===(o=e.dependRemoteHsps)||void 0===o?void 0:o.findIndex(e=>{var o;return null===(o=e.hspName)||void 0===o?void 0:o.includes("ascf")});e.dependRemoteHsps&&-1!==t&&e.dependRemoteHsps.splice(t,1)}),(0,common_utils_1.writeJson)(r,e),logger.debug(`final metadataJson ${JSON.stringify(e,null," ")}`)}})}function doModifyShareInfoPlugin(e){return __awaiter(this,void 0,void 0,function*(){logger.debug("start exec modify share info plugin");const o=e.getContext(hvigor_ohos_plugin_1.OhosPluginId.OHOS_HAP_PLUGIN);null==o||o.targets(o=>{const t=o.getTargetName();logger.debug(`targetName:${t}`),e.registerTask({name:"modifyShareInfoTask",run:e=>{logger.debug("moduleName="+e.moduleName+" modulePath="+e.modulePath),updateSharedInfo(e.modulePath)},dependencies:[`${t}@CompileArkTS`],postDependencies:[`${t}@PackageHap`]})}),logger.debug("exec modify share info plugin completed")})}function modifyShareInfoPlugin(){return{pluginId:"modifyShareInfoPlugin",apply:doModifyShareInfoPlugin}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomicservice/ascf-toolkit-hvigor-plugin",
|
|
3
|
-
"version": "1.0.6
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"title": "ASCF toolkit hvigor plugin for atomicservice",
|
|
5
5
|
"description": "ASCF toolkit hvigor plugin for atomicservice",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"gulp-terser": "2.1.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@atomicservice/ascf-toolkit": "1.0.6
|
|
18
|
+
"@atomicservice/ascf-toolkit": "1.0.6",
|
|
19
|
+
"json5": "2.2.3"
|
|
19
20
|
},
|
|
20
21
|
"overrides": {
|
|
21
22
|
"minipass": "3.3.6",
|