@hanzogui/helpers-node 2.0.0-rc.41-hanzoai.5

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nate Wienert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
22
+ }), mod);
23
+ var getDefaultHanzoguiOptions_exports = {};
24
+ __export(getDefaultHanzoguiOptions_exports, {
25
+ getDefaultHanzoguiOptions: () => getDefaultHanzoguiOptions
26
+ });
27
+ module.exports = __toCommonJS(getDefaultHanzoguiOptions_exports);
28
+ var import_getHanzoguiDefaultPath = require("./getHanzoguiDefaultPath.cjs");
29
+ async function getDefaultHanzoguiOptions({
30
+ cwd = "."
31
+ }) {
32
+ return {
33
+ platform: "native",
34
+ components: ["hanzogui"],
35
+ config: await (0, import_getHanzoguiDefaultPath.getDefaultHanzoguiConfigPath)({
36
+ cwd
37
+ })
38
+ };
39
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
+ value: true
24
+ }), mod);
25
+ var getDefaultHanzoguiOptions_exports = {};
26
+ __export(getDefaultHanzoguiOptions_exports, {
27
+ getDefaultHanzoguiOptions: () => getDefaultHanzoguiOptions
28
+ });
29
+ module.exports = __toCommonJS(getDefaultHanzoguiOptions_exports);
30
+ var import_getHanzoguiDefaultPath = require("./getHanzoguiDefaultPath.native.js");
31
+ async function getDefaultHanzoguiOptions(param) {
32
+ var {
33
+ cwd = "."
34
+ } = param;
35
+ return {
36
+ platform: "native",
37
+ components: ["hanzogui"],
38
+ config: await (0, import_getHanzoguiDefaultPath.getDefaultHanzoguiConfigPath)({
39
+ cwd
40
+ })
41
+ };
42
+ }
43
+ //# sourceMappingURL=getDefaultHanzoguiOptions.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","getDefaultHanzoguiOptions_exports","__export","getDefaultHanzoguiOptions","module","exports","import_getHanzoguiDefaultPath","require","param","cwd","platform","components","config","getDefaultHanzoguiConfigPath"],"sources":["../src/getDefaultHanzoguiOptions.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,iCAAA;AAAAC,QAAA,CAAAD,iCAAA;EAAAE,yBAAA,EAAAA,CAAA,KAAAA;AAAA;AAEAC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAAAK,iCAA6C;AAE7C,IAAAK,6BAAsB,GAAAC,OAA0B;AAAA,eACxCJ,0BAAAK,KAAA;EACR,IAE6B;IAAAC,GAAA;EAAA,IAAAD,KAAA;EAC3B,OAAO;IACLE,QAAA,EAAU;IACVC,UAAA,EAAY,CACZ,UAAQ,CACV;IACFC,MAAA,YAAAN,6BAAA,CAAAO,4BAAA","ignoreList":[]}
@@ -0,0 +1,46 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
22
+ }), mod);
23
+ var getHanzoguiDefaultPath_exports = {};
24
+ __export(getHanzoguiDefaultPath_exports, {
25
+ getDefaultHanzoguiConfigPath: () => getDefaultHanzoguiConfigPath
26
+ });
27
+ module.exports = __toCommonJS(getHanzoguiDefaultPath_exports);
28
+ var import_node_path = require("node:path");
29
+ var import_fs_extra = require("fs-extra");
30
+ let cachedPath = "";
31
+ async function getDefaultHanzoguiConfigPath({
32
+ cwd = ".",
33
+ cache = true
34
+ }) {
35
+ if (cache && cachedPath) {
36
+ return cachedPath;
37
+ }
38
+ const defaultPaths = ["hanzogui.config.ts", (0, import_node_path.join)("src", "hanzogui.config.ts")].map(p => (0, import_node_path.join)(cwd, p));
39
+ const existing = (await Promise.all(defaultPaths.map(path => (0, import_fs_extra.pathExists)(path)))).findIndex(x => !!x);
40
+ const found = defaultPaths[existing];
41
+ if (!found) {
42
+ throw new Error(`No found hanzogui.config.ts`);
43
+ }
44
+ cachedPath = found;
45
+ return found;
46
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
+ value: true
24
+ }), mod);
25
+ var getHanzoguiDefaultPath_exports = {};
26
+ __export(getHanzoguiDefaultPath_exports, {
27
+ getDefaultHanzoguiConfigPath: () => getDefaultHanzoguiConfigPath
28
+ });
29
+ module.exports = __toCommonJS(getHanzoguiDefaultPath_exports);
30
+ var import_path = require("path");
31
+ var import_fs_extra = require("fs-extra");
32
+ var cachedPath = "";
33
+ async function getDefaultHanzoguiConfigPath(param) {
34
+ var {
35
+ cwd = ".",
36
+ cache = true
37
+ } = param;
38
+ if (cache && cachedPath) {
39
+ return cachedPath;
40
+ }
41
+ var defaultPaths = ["hanzogui.config.ts", (0, import_path.join)("src", "hanzogui.config.ts")].map(function (p) {
42
+ return (0, import_path.join)(cwd, p);
43
+ });
44
+ var existing = (await Promise.all(defaultPaths.map(function (path) {
45
+ return (0, import_fs_extra.pathExists)(path);
46
+ }))).findIndex(function (x) {
47
+ return !!x;
48
+ });
49
+ var found = defaultPaths[existing];
50
+ if (!found) {
51
+ throw new Error(`No found hanzogui.config.ts`);
52
+ }
53
+ cachedPath = found;
54
+ return found;
55
+ }
56
+ //# sourceMappingURL=getHanzoguiDefaultPath.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","getHanzoguiDefaultPath_exports","__export","getDefaultHanzoguiConfigPath","module","exports","import_path","require","import_fs_extra","cachedPath","param","cwd","cache","defaultPaths","join","map","p","existing","Promise","all","path","pathExists","findIndex","x","found"],"sources":["../src/getHanzoguiDefaultPath.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,8BAAA;AAAAC,QAAA,CAAAD,8BAAA;EAAAE,4BAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAqB,CAAAK,8BAAA;AAErB,IAAAK,WAAA,GAAAC,OAA2B;AAE3B,IAAIC,eAAa,GAAAD,OAAA;AAEjB,IAAAE,UAAA,GAAsB;AAA6B,eAC3CN,6BAAAO,KAAA;EACN;IAAAC,GAAQ;IAAAC,KAAA;EAAA,IAAAF,KAAA;EACV,IAIoBE,KAAA,IAAAH,UAAA;IAClB,OAAIA,UAAS;EACX;EACF,IAAAI,YAAA,IAEA,oBAAsB,EAA6D,CAAC,GAAAP,WAClF,CAAAQ,IAAA,6BAAW,EACb,CAAAC,GAAA,WAAAC,CAAA;IACA,OAAM,IAAAV,WACE,CAAAQ,IAAA,EAAAH,GAAQ,EAAIK,CAAA;EAEpB;EACA,IAAIC,QAAQ,UAAAC,OAAA,CAAAC,GAAA,CAAAN,YAAA,CAAAE,GAAA,WAAAK,IAAA;IACV,OAAM,IAAIZ,eAAM,CAAAa,UAAA,EAAAD,IAAA;EAClB,KAAAE,SAAA,WAAAC,CAAA;IAEA,SAAAA,CAAA;EACA;EACF,IAAAC,KAAA,GAAAX,YAAA,CAAAI,QAAA","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
22
+ }), mod);
23
+ var getHanzoguiOptions_exports = {};
24
+ __export(getHanzoguiOptions_exports, {
25
+ getHanzoguiOptions: () => getHanzoguiOptions
26
+ });
27
+ module.exports = __toCommonJS(getHanzoguiOptions_exports);
28
+ var import_readHanzoguiOptions = require("./readHanzoguiOptions.cjs");
29
+ async function getHanzoguiOptions({
30
+ cwd = "."
31
+ }) {
32
+ return (await (0, import_readHanzoguiOptions.readHanzoguiOptions)({
33
+ cwd
34
+ })).options;
35
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
+ value: true
24
+ }), mod);
25
+ var getHanzoguiOptions_exports = {};
26
+ __export(getHanzoguiOptions_exports, {
27
+ getHanzoguiOptions: () => getHanzoguiOptions
28
+ });
29
+ module.exports = __toCommonJS(getHanzoguiOptions_exports);
30
+ var import_readHanzoguiOptions = require("./readHanzoguiOptions.native.js");
31
+ async function getHanzoguiOptions(param) {
32
+ var {
33
+ cwd = "."
34
+ } = param;
35
+ return (await (0, import_readHanzoguiOptions.readHanzoguiOptions)({
36
+ cwd
37
+ })).options;
38
+ }
39
+ //# sourceMappingURL=getHanzoguiOptions.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","getHanzoguiOptions_exports","__export","getHanzoguiOptions","module","exports","import_readHanzoguiOptions","require","param","cwd","readHanzoguiOptions"],"sources":["../src/getHanzoguiOptions.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,0BAAA;AAAAC,QAAA,CAAAD,0BAAA;EAAAE,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAAAK,0BAAoC;AAEpC,IAAAK,0BAAsB,GAAAC,OAAmB;AAAA,eACjCJ,mBAAAK,KAAA;EACR,IAE6D;IAAAC,GAAA;EAAA,IAAAD,KAAA;EAC3D,QAAQ,UAAMF,0BAAA,CAAAI,mBAAA,EAAoB;IACpCD","ignoreList":[]}
package/dist/index.cjs ADDED
@@ -0,0 +1,22 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
+ get: () => from[key],
9
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
+ });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
+ value: true
17
+ }), mod);
18
+ var index_exports = {};
19
+ module.exports = __toCommonJS(index_exports);
20
+ __reExport(index_exports, require("./readHanzoguiOptions.cjs"), module.exports);
21
+ __reExport(index_exports, require("./getHanzoguiDefaultPath.cjs"), module.exports);
22
+ __reExport(index_exports, require("./getHanzoguiOptions.cjs"), module.exports);
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
10
+ get: () => from[key],
11
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
+ });
13
+ }
14
+ return to;
15
+ };
16
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
18
+ value: true
19
+ }), mod);
20
+ var index_exports = {};
21
+ module.exports = __toCommonJS(index_exports);
22
+ __reExport(index_exports, require("./readHanzoguiOptions.native.js"), module.exports);
23
+ __reExport(index_exports, require("./getHanzoguiDefaultPath.native.js"), module.exports);
24
+ __reExport(index_exports, require("./getHanzoguiOptions.native.js"), module.exports);
25
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA;AACdG,UAAA,CAAAH,aAAA,EAAcI,OAAA,qCAAAH,MADd,CAAAC,OAAA;AAEAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,qCAFd,GAAAH,MAAA,CAAAC,OAAA","ignoreList":[]}
@@ -0,0 +1,66 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
22
+ }), mod);
23
+ var readHanzoguiOptions_exports = {};
24
+ __export(readHanzoguiOptions_exports, {
25
+ readHanzoguiOptions: () => readHanzoguiOptions
26
+ });
27
+ module.exports = __toCommonJS(readHanzoguiOptions_exports);
28
+ var import_node_path = require("node:path");
29
+ var import_fs_extra = require("fs-extra");
30
+ var import_getDefaultHanzoguiOptions = require("./getDefaultHanzoguiOptions.cjs");
31
+ async function readHanzoguiOptions({
32
+ cwd = "."
33
+ }) {
34
+ const filePath = (0, import_node_path.join)(cwd, "hanzogui.json");
35
+ if (!(await (0, import_fs_extra.pathExists)(filePath))) {
36
+ return {
37
+ exists: false,
38
+ options: await (0, import_getDefaultHanzoguiOptions.getDefaultHanzoguiOptions)({
39
+ cwd
40
+ })
41
+ };
42
+ }
43
+ try {
44
+ const options = await (0, import_fs_extra.readJSON)(filePath);
45
+ if (!Array.isArray(options.components)) {
46
+ throw new Error(`Invalid components: not string[]`);
47
+ }
48
+ return {
49
+ exists: true,
50
+ options: {
51
+ ...(!options.config && (await (0, import_getDefaultHanzoguiOptions.getDefaultHanzoguiOptions)({
52
+ cwd
53
+ }))),
54
+ ...options
55
+ }
56
+ };
57
+ } catch (err) {
58
+ console.error(`Error reading hanzogui.json: ${err.message} ${err.stack}`);
59
+ return {
60
+ exists: false,
61
+ options: await (0, import_getDefaultHanzoguiOptions.getDefaultHanzoguiOptions)({
62
+ cwd
63
+ })
64
+ };
65
+ }
66
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
+ value: true
24
+ }), mod);
25
+ var readHanzoguiOptions_exports = {};
26
+ __export(readHanzoguiOptions_exports, {
27
+ readHanzoguiOptions: () => readHanzoguiOptions
28
+ });
29
+ module.exports = __toCommonJS(readHanzoguiOptions_exports);
30
+ var import_path = require("path");
31
+ var import_fs_extra = require("fs-extra");
32
+ var import_getDefaultHanzoguiOptions = require("./getDefaultHanzoguiOptions.native.js");
33
+ async function readHanzoguiOptions(param) {
34
+ var {
35
+ cwd = "."
36
+ } = param;
37
+ var filePath = (0, import_path.join)(cwd, "hanzogui.json");
38
+ if (!(await (0, import_fs_extra.pathExists)(filePath))) {
39
+ return {
40
+ exists: false,
41
+ options: await (0, import_getDefaultHanzoguiOptions.getDefaultHanzoguiOptions)({
42
+ cwd
43
+ })
44
+ };
45
+ }
46
+ try {
47
+ var options = await (0, import_fs_extra.readJSON)(filePath);
48
+ if (!Array.isArray(options.components)) {
49
+ throw new Error(`Invalid components: not string[]`);
50
+ }
51
+ return {
52
+ exists: true,
53
+ options: {
54
+ ...(!options.config && (await (0, import_getDefaultHanzoguiOptions.getDefaultHanzoguiOptions)({
55
+ cwd
56
+ }))),
57
+ ...options
58
+ }
59
+ };
60
+ } catch (err) {
61
+ console.error(`Error reading hanzogui.json: ${err.message} ${err.stack}`);
62
+ return {
63
+ exists: false,
64
+ options: await (0, import_getDefaultHanzoguiOptions.getDefaultHanzoguiOptions)({
65
+ cwd
66
+ })
67
+ };
68
+ }
69
+ }
70
+ //# sourceMappingURL=readHanzoguiOptions.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","readHanzoguiOptions_exports","__export","readHanzoguiOptions","module","exports","import_path","require","import_fs_extra","import_getDefaultHanzoguiOptions","param","cwd","filePath","join","pathExists","exists","options","getDefaultHanzoguiOptions","readJSON","Array","isArray","components","Error","config","err","console","error","message","stack"],"sources":["../src/readHanzoguiOptions.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,2BAAA;AAAAC,QAAA,CAAAD,2BAAA;EAAAE,mBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAqB,CAAAK,2BAAA;AAGrB,IAAAK,WAAA,GAAAC,OAAqC;AAErC,IAAAC,eAAA,GAAAD,OAAA,WAA0C;AAE1C,IAAAE,gCAA0C,GAAEF,OAAM,CAAI,uCAGnD;AACD,eAAMJ,mBAAWA,CAAAO,KAAA;EAEjB,IAAI;IAAEC,GAAA;EAAM,IAAAD,KAAA;EACV,IAAAE,QAAO,OAAAN,WAAA,CAAAO,IAAA,EAAAF,GAAA;EAAA,IACL,SAAQ,GAAAH,eAAA,CAAAM,UAAA,EAAAF,QAAA;IAAA,OACR;MACFG,MAAA;MACFC,OAAA,YAAAP,gCAAA,CAAAQ,yBAAA;QAEIN;MACF;IAEA;EACE;EAAkD,IACpD;IAEA,IAAAK,OAAO,aAAAR,eAAA,CAAAU,QAAA,EAAAN,QAAA;IAAA,IACL,CAAAO,KAAQ,CAAAC,OAAA,CAAAJ,OAAA,CAAAK,UAAA;MACR,UAASC,KAAA;IAAA;IACwD,OAC5D;MACLP,MAAA;MACFC,OAAA;QACF,IAAS,CAAAA,OAAU,CAAAO,MAAA,eAAAd,gCAAA,CAAAQ,yBAAA;UACjBN;QAEA;QACE,GAAAK;MACA;IACF;EACF,SAAAQ,GAAA;IACFC,OAAA,CAAAC,KAAA,iCAAAF,GAAA,CAAAG,OAAA,IAAAH,GAAA,CAAAI,KAAA","ignoreList":[]}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@hanzogui/helpers-node",
3
+ "version": "2.0.0-rc.41-hanzoai.5",
4
+ "source": "src/index.ts",
5
+ "files": [
6
+ "src",
7
+ "types",
8
+ "dist"
9
+ ],
10
+ "sideEffects": false,
11
+ "main": "./dist",
12
+ "types": "./types/index.d.ts",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "scripts": {
17
+ "build": "hanzogui-build",
18
+ "watch": "hanzogui-build --watch",
19
+ "clean": "hanzogui-build clean",
20
+ "clean:build": "hanzogui-build clean:build"
21
+ },
22
+ "dependencies": {
23
+ "@hanzogui/types": "2.0.0-rc.41-hanzoai.5"
24
+ },
25
+ "devDependencies": {
26
+ "@hanzogui/build": "2.0.0-rc.41-hanzoai.5",
27
+ "fs-extra": "^11.2.0"
28
+ }
29
+ }
@@ -0,0 +1,15 @@
1
+ import type { HanzoguiOptions } from '@hanzogui/types'
2
+
3
+ import { getDefaultHanzoguiConfigPath } from './getHanzoguiDefaultPath'
4
+
5
+ export async function getDefaultHanzoguiOptions({
6
+ cwd = '.',
7
+ }: {
8
+ cwd: string
9
+ }): Promise<HanzoguiOptions> {
10
+ return {
11
+ platform: 'native',
12
+ components: ['hanzogui'],
13
+ config: await getDefaultHanzoguiConfigPath({ cwd }),
14
+ }
15
+ }
@@ -0,0 +1,32 @@
1
+ import { join } from 'node:path'
2
+
3
+ import { pathExists } from 'fs-extra'
4
+
5
+ let cachedPath = ''
6
+
7
+ export async function getDefaultHanzoguiConfigPath({
8
+ cwd = '.',
9
+ cache = true,
10
+ }: {
11
+ cwd?: string
12
+ // TODO this isn't passed down / could avoid
13
+ cache?: boolean
14
+ }): Promise<string> {
15
+ if (cache && cachedPath) {
16
+ return cachedPath
17
+ }
18
+
19
+ const defaultPaths = ['hanzogui.config.ts', join('src', 'hanzogui.config.ts')].map((p) =>
20
+ join(cwd, p)
21
+ )
22
+ const existing = (
23
+ await Promise.all(defaultPaths.map((path) => pathExists(path)))
24
+ ).findIndex((x) => !!x)
25
+ const found = defaultPaths[existing]
26
+ if (!found) {
27
+ throw new Error(`No found hanzogui.config.ts`)
28
+ }
29
+
30
+ cachedPath = found
31
+ return found
32
+ }
@@ -0,0 +1,9 @@
1
+ import { readHanzoguiOptions } from './readHanzoguiOptions'
2
+
3
+ export async function getHanzoguiOptions({
4
+ cwd = '.',
5
+ }: {
6
+ cwd?: string
7
+ }): Promise<import('@hanzogui/types/types').HanzoguiOptions> {
8
+ return (await readHanzoguiOptions({ cwd })).options
9
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './readHanzoguiOptions'
2
+ export * from './getHanzoguiDefaultPath'
3
+ export * from './getHanzoguiOptions'
@@ -0,0 +1,43 @@
1
+ import { join } from 'node:path'
2
+
3
+ import type { HanzoguiOptions } from '@hanzogui/types'
4
+ import { pathExists, readJSON } from 'fs-extra'
5
+
6
+ import { getDefaultHanzoguiOptions } from './getDefaultHanzoguiOptions'
7
+
8
+ export async function readHanzoguiOptions({ cwd = '.' }: { cwd: string }): Promise<{
9
+ exists: boolean
10
+ options: HanzoguiOptions
11
+ }> {
12
+ const filePath = join(cwd, 'hanzogui.json')
13
+
14
+ if (!(await pathExists(filePath))) {
15
+ return {
16
+ exists: false,
17
+ options: await getDefaultHanzoguiOptions({ cwd }),
18
+ }
19
+ }
20
+
21
+ try {
22
+ const options = (await readJSON(filePath)) as HanzoguiOptions
23
+
24
+ if (!Array.isArray(options.components)) {
25
+ throw new Error(`Invalid components: not string[]`)
26
+ }
27
+
28
+ return {
29
+ exists: true,
30
+ options: {
31
+ ...(!options.config && (await getDefaultHanzoguiOptions({ cwd }))),
32
+ ...options,
33
+ },
34
+ }
35
+ } catch (err: any) {
36
+ console.error(`Error reading hanzogui.json: ${err.message} ${err.stack}`)
37
+
38
+ return {
39
+ exists: false,
40
+ options: await getDefaultHanzoguiOptions({ cwd }),
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,6 @@
1
+ import type { HanzoguiOptions } from "@hanzogui/types";
2
+ export declare function getDefaultHanzoguiOptions({ cwd }: {
3
+ cwd: string;
4
+ }): Promise<HanzoguiOptions>;
5
+
6
+ //# sourceMappingURL=getDefaultHanzoguiOptions.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAAA,cAAc,uBAAuB;AAIrC,OAAO,iBAAe,0BAA0B,EAC9C,OACC;CACD;IACE,QAAQ",
3
+ "names": [],
4
+ "sources": [
5
+ "src/getDefaultHanzoguiOptions.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "import type { HanzoguiOptions } from '@hanzogui/types'\n\nimport { getDefaultHanzoguiConfigPath } from './getHanzoguiDefaultPath'\n\nexport async function getDefaultHanzoguiOptions({\n cwd = '.',\n}: {\n cwd: string\n}): Promise<HanzoguiOptions> {\n return {\n platform: 'native',\n components: ['hanzogui'],\n config: await getDefaultHanzoguiConfigPath({ cwd }),\n }\n}\n"
10
+ ]
11
+ }
@@ -0,0 +1,6 @@
1
+ export declare function getDefaultHanzoguiConfigPath({ cwd, cache }: {
2
+ cwd?: string;
3
+ cache?: boolean;
4
+ }): Promise<string>;
5
+
6
+ //# sourceMappingURL=getHanzoguiDefaultPath.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAMA,OAAO,iBAAe,6BAA6B,EACjD,KACA,SACC;CACD;CAEA;IACE",
3
+ "names": [],
4
+ "sources": [
5
+ "src/getHanzoguiDefaultPath.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "import { join } from 'node:path'\n\nimport { pathExists } from 'fs-extra'\n\nlet cachedPath = ''\n\nexport async function getDefaultHanzoguiConfigPath({\n cwd = '.',\n cache = true,\n}: {\n cwd?: string\n // TODO this isn't passed down / could avoid\n cache?: boolean\n}): Promise<string> {\n if (cache && cachedPath) {\n return cachedPath\n }\n\n const defaultPaths = ['hanzogui.config.ts', join('src', 'hanzogui.config.ts')].map((p) =>\n join(cwd, p)\n )\n const existing = (\n await Promise.all(defaultPaths.map((path) => pathExists(path)))\n ).findIndex((x) => !!x)\n const found = defaultPaths[existing]\n if (!found) {\n throw new Error(`No found hanzogui.config.ts`)\n }\n\n cachedPath = found\n return found\n}\n"
10
+ ]
11
+ }
@@ -0,0 +1,5 @@
1
+ export declare function getHanzoguiOptions({ cwd }: {
2
+ cwd?: string;
3
+ }): Promise<import("@hanzogui/types/types").HanzoguiOptions>;
4
+
5
+ //# sourceMappingURL=getHanzoguiOptions.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAEA,OAAO,iBAAe,mBAAmB,EACvC,OACC;CACD;IACE,eAAe",
3
+ "names": [],
4
+ "sources": [
5
+ "src/getHanzoguiOptions.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "import { readHanzoguiOptions } from './readHanzoguiOptions'\n\nexport async function getHanzoguiOptions({\n cwd = '.',\n}: {\n cwd?: string\n}): Promise<import('@hanzogui/types/types').HanzoguiOptions> {\n return (await readHanzoguiOptions({ cwd })).options\n}\n"
10
+ ]
11
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./readHanzoguiOptions";
2
+ export * from "./getHanzoguiDefaultPath";
3
+ export * from "./getHanzoguiOptions";
4
+
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc",
3
+ "names": [],
4
+ "sources": [
5
+ "src/index.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "export * from './readHanzoguiOptions'\nexport * from './getHanzoguiDefaultPath'\nexport * from './getHanzoguiOptions'\n"
10
+ ]
11
+ }
@@ -0,0 +1,9 @@
1
+ import type { HanzoguiOptions } from "@hanzogui/types";
2
+ export declare function readHanzoguiOptions({ cwd }: {
3
+ cwd: string;
4
+ }): Promise<{
5
+ exists: boolean;
6
+ options: HanzoguiOptions;
7
+ }>;
8
+
9
+ //# sourceMappingURL=readHanzoguiOptions.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAEA,cAAc,uBAAuB;AAKrC,OAAO,iBAAe,oBAAoB,EAAE,OAAa;CAAE;IAAgB,QAAQ;CACjF;CACA,SAAS",
3
+ "names": [],
4
+ "sources": [
5
+ "src/readHanzoguiOptions.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "import { join } from 'node:path'\n\nimport type { HanzoguiOptions } from '@hanzogui/types'\nimport { pathExists, readJSON } from 'fs-extra'\n\nimport { getDefaultHanzoguiOptions } from './getDefaultHanzoguiOptions'\n\nexport async function readHanzoguiOptions({ cwd = '.' }: { cwd: string }): Promise<{\n exists: boolean\n options: HanzoguiOptions\n}> {\n const filePath = join(cwd, 'hanzogui.json')\n\n if (!(await pathExists(filePath))) {\n return {\n exists: false,\n options: await getDefaultHanzoguiOptions({ cwd }),\n }\n }\n\n try {\n const options = (await readJSON(filePath)) as HanzoguiOptions\n\n if (!Array.isArray(options.components)) {\n throw new Error(`Invalid components: not string[]`)\n }\n\n return {\n exists: true,\n options: {\n ...(!options.config && (await getDefaultHanzoguiOptions({ cwd }))),\n ...options,\n },\n }\n } catch (err: any) {\n console.error(`Error reading hanzogui.json: ${err.message} ${err.stack}`)\n\n return {\n exists: false,\n options: await getDefaultHanzoguiOptions({ cwd }),\n }\n }\n}\n"
10
+ ]
11
+ }