@hap-toolkit/shared-utils
Advanced tools
Comparing version
/* | ||
* Copyright (C) 2017, hapjs.org. All rights reserved. | ||
* Copyright (c) 2021-present, the hapjs-platform Project Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
@@ -4,0 +5,0 @@ |
@@ -0,1 +1,6 @@ | ||
/* | ||
* Copyright (c) 2021-present, the hapjs-platform Project Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
const path = require('@jayfate/path') | ||
@@ -2,0 +7,0 @@ // 用户home目录 |
/* | ||
* Copyright (C) 2017, hapjs.org. All rights reserved. | ||
* Copyright (c) 2021-present, the hapjs-platform Project Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
@@ -4,0 +5,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";var _fs=_interopRequireDefault(require("fs")),_path=_interopRequireDefault(require("@jayfate/path")),_index=require("../index"),_util=require("./util"),_eventBus=_interopRequireDefault(require("../../event-bus"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const{PACKAGER_BUILD_DONE:PACKAGER_BUILD_DONE}=_eventBus.default;function BuildModeManager(e){(0,_util.initProjectConfig)(e),this.setRoot(e)}BuildModeManager.prototype._read=function(){let e={};try{e=(0,_index.readJson)(this._configFile)}catch(e){console.log("ENOENT"===e.code?e.message:e)}e.modeOptions||(e.modeOptions={current:-1,list:[]});const t=e.modeOptions;return t.list=t.list.filter((e=>null!==e.id&&-1!==e.id)),e},BuildModeManager.prototype._write=function(e){const t=e.modeOptions;t.list=t.list.filter((e=>null!==e.id&&-1!==e.id)).reduce(((e,t)=>(e.find((e=>e.id===t.id))||e.push(t),e)),[]),this._configFile&&_fs.default.writeFileSync(this._configFile,JSON.stringify(e,null,2))},BuildModeManager.prototype.getConfig=function(){return this._read().modeOptions},BuildModeManager.prototype.getAllPages=function(){if(!this.root)return[];const e=_path.default.join(this.root,"src/manifest.json");try{const t=(0,_index.readJson)(e).router.pages||{};return Object.keys(t)}catch(e){return console.log("ENOENT"===e.code?e.message:e),[]}},BuildModeManager.prototype._addMode=function(e,t,i){const o=e.modeOptions;let n;return n=o.list.length?Math.max.apply(null,o.list.map((e=>e.id)))+1:0,t.id=n,o.list.push(t),o.current=t.id,i||this._write(e),o},BuildModeManager.prototype.addMode=function(e){const t=this._read();return this._addMode(t,e,!1)},BuildModeManager.prototype.addModes=function(e){const t=this._read();return e.forEach((e=>{this._addMode(t,e,!0)})),this._write(t),t.modeOptions},BuildModeManager.prototype.delete=function(e){const t=this._read(),i=t.modeOptions,o=i.list.findIndex((t=>t.id===e));return i.current=-1,-1!==o&&(i.list.splice(o,1),this._write(t)),i},BuildModeManager.prototype.update=function(e){const t=this._read(),i=t.modeOptions,o=i.list.findIndex((t=>t.id===e.id));return-1!==o&&(i.list[o]=e),this._write(t),i},BuildModeManager.prototype.select=function(e){const t=this._read(),i=t.modeOptions;return-1!==i.list.findIndex((t=>t.id===e))&&(i.current=e,this._write(t),_eventBus.default.emit(PACKAGER_BUILD_DONE)),i},BuildModeManager.prototype.setToNormal=function(){const e=this._read(),t=e.modeOptions;return t.current=-1,this._write(e),_eventBus.default.emit(PACKAGER_BUILD_DONE),t},BuildModeManager.prototype.setRoot=function(e){if("string"==typeof e){this.root=e,this._configFile=_path.default.resolve(e,_util.CONFIG_FILE);return this._read().modeOptions}return null},module.exports=BuildModeManager; | ||
"use strict";var _fs=_interopRequireDefault(require("fs")),_path=_interopRequireDefault(require("@jayfate/path")),_index=require("../index"),_util=require("./util"),_eventBus=_interopRequireDefault(require("../../event-bus"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}const{PACKAGER_BUILD_DONE:PACKAGER_BUILD_DONE}=_eventBus.default;function BuildModeManager(t){(0,_util.initProjectConfig)(t),this.setRoot(t)}BuildModeManager.prototype._read=function(){let t={};try{t=(0,_index.readJson)(this._configFile)}catch(t){console.log("ENOENT"===t.code?t.message:t)}t.modeOptions||(t.modeOptions={current:-1,list:[]});const e=t.modeOptions;return e.list=e.list.filter((t=>null!==t.id&&-1!==t.id)),t},BuildModeManager.prototype._write=function(t){const e=t.modeOptions;e.list=e.list.filter((t=>null!==t.id&&-1!==t.id)).reduce(((t,e)=>(t.find((t=>t.id===e.id))||t.push(e),t)),[]),this._configFile&&_fs.default.writeFileSync(this._configFile,JSON.stringify(t,null,2))},BuildModeManager.prototype.getConfig=function(){return this._read().modeOptions},BuildModeManager.prototype.getAllPages=function(){if(!this.root)return[];const t=_path.default.join(this.root,"src/manifest.json");try{const e=(0,_index.readJson)(t).router.pages||{};return Object.keys(e)}catch(t){return console.log("ENOENT"===t.code?t.message:t),[]}},BuildModeManager.prototype.getAllCards=function(){if(!this.root)return[];const t=_path.default.join(this.root,"src/manifest.json");try{const e=(0,_index.readJson)(t).router.widgets||{};return Object.keys(e)}catch(t){return console.log("ENOENT"===t.code?t.message:t),[]}},BuildModeManager.prototype._addMode=function(t,e,i){const o=t.modeOptions;let n;return n=o.list.length?Math.max.apply(null,o.list.map((t=>t.id)))+1:0,e.id=n,o.list.push(e),o.current=e.id,i||this._write(t),o},BuildModeManager.prototype.addMode=function(t){const e=this._read();return this._addMode(e,t,!1)},BuildModeManager.prototype.addModes=function(t){const e=this._read(),i=e.modeOptions.current;return t.forEach((t=>{this._addMode(e,t,!0)})),e.modeOptions.current=i,this._write(e),e.modeOptions},BuildModeManager.prototype.delete=function(t){const e=this._read(),i=e.modeOptions,o=i.list.findIndex((e=>e.id===t));return i.current=-1,-1!==o&&(i.list.splice(o,1),this._write(e)),i},BuildModeManager.prototype.deleteModes=function(t){const e=this._read(),i=e.modeOptions,o=i.current,n=i.list.filter((e=>!t.find((t=>t.id===e.id))));if(i.list.length!==n.length){const t=n.find((t=>t.id===o));i.list=n,t||(i.current=-1),this._write(e)}return i},BuildModeManager.prototype.update=function(t){const e=this._read(),i=e.modeOptions,o=i.list.findIndex((e=>e.id===t.id));return-1!==o&&(i.list[o]=t),this._write(e),i},BuildModeManager.prototype.select=function(t){const e=this._read(),i=e.modeOptions;return-1!==i.list.findIndex((e=>e.id===t))&&(i.current=t,this._write(e),_eventBus.default.emit(PACKAGER_BUILD_DONE)),i},BuildModeManager.prototype.setToNormal=function(){const t=this._read(),e=t.modeOptions;return e.current=-1,this._write(t),_eventBus.default.emit(PACKAGER_BUILD_DONE),e},BuildModeManager.prototype.setRoot=function(t){if("string"==typeof t){this.root=t,this._configFile=_path.default.resolve(t,_util.CONFIG_FILE);return this._read().modeOptions}return null},module.exports=BuildModeManager; | ||
//# sourceMappingURL=BuildModeManager.js.map |
{ | ||
"name": "@hap-toolkit/shared-utils", | ||
"version": "1.9.11", | ||
"version": "1.9.12-beta", | ||
"description": "hap shared utils", | ||
@@ -33,3 +33,3 @@ "engines": { | ||
}, | ||
"gitHead": "ef7ee372fd393ca0e4495fd6daf18f969fd77eaa" | ||
"gitHead": "415f60d0570373530017f45b2647078e6dea44fa" | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
27128
57.9%10
11.11%0
-100%187
4.47%6
20%