diff --git a/kit/bun.lockb b/kit/bun.lockb new file mode 100644 index 0000000..49526a7 Binary files /dev/null and b/kit/bun.lockb differ diff --git a/kit/package-lock.json b/kit/package-lock.json index dfded14..fb2b06e 100644 --- a/kit/package-lock.json +++ b/kit/package-lock.json @@ -1,555 +1,622 @@ -{ - "name": "kit", - "version": "0.1", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "kit", - "version": "0.1", - "dependencies": { - "cross-port-killer": "^1.4.0", - "extract-zip": "^2.0.1", - "get-port": "^7.0.0", - "json5": "^2.2.3", - "log4js": "^6.9.1", - "sm-crypto": "^0.3.13", - "webdav": "^5.3.1" - }, - "bin": { - "kit": "src/index.js" - } - }, - "node_modules/@buttercup/fetch": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/@buttercup/fetch/-/fetch-0.1.2.tgz", - "integrity": "sha512-mDBtsysQ0Gnrp4FamlRJGpu7HUHwbyLC4uUav1I7QAqThFAa/4d1cdZCxrV5gKvh6zO1fu95bILNJi4Y2hALhQ==", - "optionalDependencies": { - "node-fetch": "^3.3.0" - } - }, - "node_modules/@types/node": { - "version": "20.10.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.8.tgz", - "integrity": "sha512-f8nQs3cLxbAFc00vEU59yf9UyGUftkPaLGfvbVOIDdx2i1b8epBqj2aNGyP19fiyXWvlmZ7qC1XLjAzw/OKIeA==", - "optional": true, - "dependencies": { - "undici-types": "~5.26.4" - } - }, - "node_modules/@types/yauzl": { - "version": "2.10.3", - "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz", - "integrity": "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==", - "optional": true, - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" - }, - "node_modules/base-64": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/base-64/-/base-64-1.0.0.tgz", - "integrity": "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg==" - }, - "node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/buffer-crc32": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", - "engines": { - "node": "*" - } - }, - "node_modules/byte-length": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/byte-length/-/byte-length-1.0.2.tgz", - "integrity": "sha512-ovBpjmsgd/teRmgcPh23d4gJvxDoXtAzEL9xTfMU8Yc2kqCDb7L9jAG0XHl1nzuGl+h3ebCIF1i62UFyA9V/2Q==" - }, - "node_modules/charenc": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", - "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", - "engines": { - "node": "*" - } - }, - "node_modules/cross-port-killer": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/cross-port-killer/-/cross-port-killer-1.4.0.tgz", - "integrity": "sha512-ujqfftKsSeorFMVI6JP25xMBixHEaDWVK+NarRZAGnJjR5AhebRQU+g+k/Lj8OHwM6f+wrrs8u5kkCdI7RLtxQ==", - "bin": { - "kill-port": "source/cli.js" - } - }, - "node_modules/crypt": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", - "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", - "engines": { - "node": "*" - } - }, - "node_modules/data-uri-to-buffer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", - "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", - "optional": true, - "engines": { - "node": ">= 12" - } - }, - "node_modules/date-format": { - "version": "4.0.14", - "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz", - "integrity": "sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg==", - "engines": { - "node": ">=4.0" - } - }, - "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/end-of-stream": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "dependencies": { - "once": "^1.4.0" - } - }, - "node_modules/extract-zip": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", - "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", - "dependencies": { - "debug": "^4.1.1", - "get-stream": "^5.1.0", - "yauzl": "^2.10.0" - }, - "bin": { - "extract-zip": "cli.js" - }, - "engines": { - "node": ">= 10.17.0" - }, - "optionalDependencies": { - "@types/yauzl": "^2.9.1" - } - }, - "node_modules/fast-xml-parser": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.3.tgz", - "integrity": "sha512-coV/D1MhrShMvU6D0I+VAK3umz6hUaxxhL0yp/9RjfiYUfAv14rDhGQL+PLForhMdr0wq3PiV07WtkkNjJjNHg==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/NaturalIntelligence" - }, - { - "type": "paypal", - "url": "https://paypal.me/naturalintelligence" - } - ], - "dependencies": { - "strnum": "^1.0.5" - }, - "bin": { - "fxparser": "src/cli/cli.js" - } - }, - "node_modules/fd-slicer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", - "dependencies": { - "pend": "~1.2.0" - } - }, - "node_modules/fetch-blob": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", - "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "paypal", - "url": "https://paypal.me/jimmywarting" - } - ], - "optional": true, - "dependencies": { - "node-domexception": "^1.0.0", - "web-streams-polyfill": "^3.0.3" - }, - "engines": { - "node": "^12.20 || >= 14.13" - } - }, - "node_modules/flatted": { - "version": "3.2.9", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.9.tgz", - "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==" - }, - "node_modules/formdata-polyfill": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", - "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", - "optional": true, - "dependencies": { - "fetch-blob": "^3.1.2" - }, - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, - "node_modules/get-port": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/get-port/-/get-port-7.0.0.tgz", - "integrity": "sha512-mDHFgApoQd+azgMdwylJrv2DX47ywGq1i5VFJE7fZ0dttNq3iQMfsU4IvEgBHojA3KqEudyu7Vq+oN8kNaNkWw==", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/get-stream": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", - "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", - "dependencies": { - "pump": "^3.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" - }, - "node_modules/he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "bin": { - "he": "bin/he" - } - }, - "node_modules/hot-patcher": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/hot-patcher/-/hot-patcher-2.0.1.tgz", - "integrity": "sha512-ECg1JFG0YzehicQaogenlcs2qg6WsXQsxtnbr1i696u5tLUjtJdQAh0u2g0Q5YV45f263Ta1GnUJsc8WIfJf4Q==" - }, - "node_modules/is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" - }, - "node_modules/jsbn": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", - "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==" - }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/layerr": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/layerr/-/layerr-2.0.1.tgz", - "integrity": "sha512-z0730CwG/JO24evdORnyDkwG1Q7b7mF2Tp1qRQ0YvrMMARbt1DFG694SOv439Gm7hYKolyZyaB49YIrYIfZBdg==" - }, - "node_modules/log4js": { - "version": "6.9.1", - "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.9.1.tgz", - "integrity": "sha512-1somDdy9sChrr9/f4UlzhdaGfDR2c/SaD2a4T7qEkG4jTS57/B3qmnjLYePwQ8cqWnUHZI0iAKxMBpCZICiZ2g==", - "dependencies": { - "date-format": "^4.0.14", - "debug": "^4.3.4", - "flatted": "^3.2.7", - "rfdc": "^1.3.0", - "streamroller": "^3.1.5" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/md5": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", - "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", - "dependencies": { - "charenc": "0.0.2", - "crypt": "0.0.2", - "is-buffer": "~1.1.6" - } - }, - "node_modules/minimatch": { - "version": "7.4.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-7.4.6.tgz", - "integrity": "sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "node_modules/nested-property": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/nested-property/-/nested-property-4.0.0.tgz", - "integrity": "sha512-yFehXNWRs4cM0+dz7QxCd06hTbWbSkV0ISsqBfkntU6TOY4Qm3Q88fRRLOddkGh2Qq6dZvnKVAahfhjcUvLnyA==" - }, - "node_modules/node-domexception": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "github", - "url": "https://paypal.me/jimmywarting" - } - ], - "optional": true, - "engines": { - "node": ">=10.5.0" - } - }, - "node_modules/node-fetch": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", - "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", - "optional": true, - "dependencies": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/path-posix": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/path-posix/-/path-posix-1.0.0.tgz", - "integrity": "sha512-1gJ0WpNIiYcQydgg3Ed8KzvIqTsDpNwq+cjBCssvBtuTWjEqY1AW+i+OepiEMqDCzyro9B2sLAe4RBPajMYFiA==" - }, - "node_modules/pend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==" - }, - "node_modules/pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dependencies": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "node_modules/querystringify": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", - "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" - }, - "node_modules/requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" - }, - "node_modules/rfdc": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", - "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==" - }, - "node_modules/sm-crypto": { - "version": "0.3.13", - "resolved": "https://registry.npmjs.org/sm-crypto/-/sm-crypto-0.3.13.tgz", - "integrity": "sha512-ztNF+pZq6viCPMA1A6KKu3bgpkmYti5avykRHbcFIdSipFdkVmfUw2CnpM2kBJyppIalqvczLNM3wR8OQ0pT5w==", - "dependencies": { - "jsbn": "^1.1.0" - } - }, - "node_modules/streamroller": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.1.5.tgz", - "integrity": "sha512-KFxaM7XT+irxvdqSP1LGLgNWbYN7ay5owZ3r/8t77p+EtSUAfUgtl7be3xtqtOmGUl9K9YPO2ca8133RlTjvKw==", - "dependencies": { - "date-format": "^4.0.14", - "debug": "^4.3.4", - "fs-extra": "^8.1.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/strnum": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz", - "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==" - }, - "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", - "optional": true - }, - "node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/url-join": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/url-join/-/url-join-5.0.0.tgz", - "integrity": "sha512-n2huDr9h9yzd6exQVnH/jU5mr+Pfx08LRXXZhkLLetAMESRj+anQsTAh940iMrIetKAmry9coFuZQ2jY8/p3WA==", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - } - }, - "node_modules/url-parse": { - "version": "1.5.10", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", - "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", - "dependencies": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" - } - }, - "node_modules/web-streams-polyfill": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.2.tgz", - "integrity": "sha512-3pRGuxRF5gpuZc0W+EpwQRmCD7gRqcDOMt688KmdlDAgAyaB1XlN0zq2njfDNm44XVdIouE7pZ6GzbdyH47uIQ==", - "optional": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/webdav": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/webdav/-/webdav-5.3.1.tgz", - "integrity": "sha512-wzZdTHtMuSIXqHGBznc8FM2L94Mc/17Tbn9ppoMybRO0bjWOSIeScdVXWX5qqHsg00EjfiOcwMqGFx6ghIhccQ==", - "dependencies": { - "@buttercup/fetch": "^0.1.1", - "base-64": "^1.0.0", - "byte-length": "^1.0.2", - "fast-xml-parser": "^4.2.4", - "he": "^1.2.0", - "hot-patcher": "^2.0.0", - "layerr": "^2.0.1", - "md5": "^2.3.0", - "minimatch": "^7.4.6", - "nested-property": "^4.0.0", - "path-posix": "^1.0.0", - "url-join": "^5.0.0", - "url-parse": "^1.5.10" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" - }, - "node_modules/yauzl": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", - "dependencies": { - "buffer-crc32": "~0.2.3", - "fd-slicer": "~1.1.0" - } - } - } -} +{ + "name": "kit", + "version": "0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "kit", + "version": "0.1", + "dependencies": { + "auto-launch": "^5.0.6", + "cross-port-killer": "^1.4.0", + "extract-zip": "^2.0.1", + "get-port": "^7.0.0", + "json5": "^2.2.3", + "log4js": "^6.9.1", + "physical-cpu-count": "^2.0.0", + "sm-crypto": "^0.3.13", + "webdav": "^5.3.1" + }, + "bin": { + "kit": "src/index.js" + } + }, + "node_modules/@buttercup/fetch": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@buttercup/fetch/-/fetch-0.1.2.tgz", + "integrity": "sha512-mDBtsysQ0Gnrp4FamlRJGpu7HUHwbyLC4uUav1I7QAqThFAa/4d1cdZCxrV5gKvh6zO1fu95bILNJi4Y2hALhQ==", + "optionalDependencies": { + "node-fetch": "^3.3.0" + } + }, + "node_modules/@types/node": { + "version": "20.10.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.8.tgz", + "integrity": "sha512-f8nQs3cLxbAFc00vEU59yf9UyGUftkPaLGfvbVOIDdx2i1b8epBqj2aNGyP19fiyXWvlmZ7qC1XLjAzw/OKIeA==", + "optional": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/yauzl": { + "version": "2.10.3", + "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz", + "integrity": "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==", + "optional": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/applescript": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/applescript/-/applescript-1.0.0.tgz", + "integrity": "sha512-yvtNHdWvtbYEiIazXAdp/NY+BBb65/DAseqlNiJQjOx9DynuzOYDbVLBJvuc0ve0VL9x6B3OHF6eH52y9hCBtQ==" + }, + "node_modules/auto-launch": { + "version": "5.0.6", + "resolved": "https://registry.npmmirror.com/auto-launch/-/auto-launch-5.0.6.tgz", + "integrity": "sha512-OgxiAm4q9EBf9EeXdPBiVNENaWE3jUZofwrhAkWjHDYGezu1k3FRZHU8V2FBxGuSJOHzKmTJEd0G7L7/0xDGFA==", + "dependencies": { + "applescript": "^1.0.0", + "mkdirp": "^0.5.1", + "path-is-absolute": "^1.0.0", + "untildify": "^3.0.2", + "winreg": "1.2.4" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/base-64": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-1.0.0.tgz", + "integrity": "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg==" + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "engines": { + "node": "*" + } + }, + "node_modules/byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/byte-length/-/byte-length-1.0.2.tgz", + "integrity": "sha512-ovBpjmsgd/teRmgcPh23d4gJvxDoXtAzEL9xTfMU8Yc2kqCDb7L9jAG0XHl1nzuGl+h3ebCIF1i62UFyA9V/2Q==" + }, + "node_modules/charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", + "engines": { + "node": "*" + } + }, + "node_modules/cross-port-killer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/cross-port-killer/-/cross-port-killer-1.4.0.tgz", + "integrity": "sha512-ujqfftKsSeorFMVI6JP25xMBixHEaDWVK+NarRZAGnJjR5AhebRQU+g+k/Lj8OHwM6f+wrrs8u5kkCdI7RLtxQ==", + "bin": { + "kill-port": "source/cli.js" + } + }, + "node_modules/crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", + "engines": { + "node": "*" + } + }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "optional": true, + "engines": { + "node": ">= 12" + } + }, + "node_modules/date-format": { + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz", + "integrity": "sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg==", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/extract-zip": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", + "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", + "dependencies": { + "debug": "^4.1.1", + "get-stream": "^5.1.0", + "yauzl": "^2.10.0" + }, + "bin": { + "extract-zip": "cli.js" + }, + "engines": { + "node": ">= 10.17.0" + }, + "optionalDependencies": { + "@types/yauzl": "^2.9.1" + } + }, + "node_modules/fast-xml-parser": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.3.tgz", + "integrity": "sha512-coV/D1MhrShMvU6D0I+VAK3umz6hUaxxhL0yp/9RjfiYUfAv14rDhGQL+PLForhMdr0wq3PiV07WtkkNjJjNHg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", + "dependencies": { + "pend": "~1.2.0" + } + }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "optional": true, + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, + "node_modules/flatted": { + "version": "3.2.9", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.9.tgz", + "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==" + }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "optional": true, + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, + "node_modules/get-port": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/get-port/-/get-port-7.0.0.tgz", + "integrity": "sha512-mDHFgApoQd+azgMdwylJrv2DX47ywGq1i5VFJE7fZ0dttNq3iQMfsU4IvEgBHojA3KqEudyu7Vq+oN8kNaNkWw==", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dependencies": { + "pump": "^3.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "bin": { + "he": "bin/he" + } + }, + "node_modules/hot-patcher": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/hot-patcher/-/hot-patcher-2.0.1.tgz", + "integrity": "sha512-ECg1JFG0YzehicQaogenlcs2qg6WsXQsxtnbr1i696u5tLUjtJdQAh0u2g0Q5YV45f263Ta1GnUJsc8WIfJf4Q==" + }, + "node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, + "node_modules/jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==" + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/layerr": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/layerr/-/layerr-2.0.1.tgz", + "integrity": "sha512-z0730CwG/JO24evdORnyDkwG1Q7b7mF2Tp1qRQ0YvrMMARbt1DFG694SOv439Gm7hYKolyZyaB49YIrYIfZBdg==" + }, + "node_modules/log4js": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.9.1.tgz", + "integrity": "sha512-1somDdy9sChrr9/f4UlzhdaGfDR2c/SaD2a4T7qEkG4jTS57/B3qmnjLYePwQ8cqWnUHZI0iAKxMBpCZICiZ2g==", + "dependencies": { + "date-format": "^4.0.14", + "debug": "^4.3.4", + "flatted": "^3.2.7", + "rfdc": "^1.3.0", + "streamroller": "^3.1.5" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "dependencies": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, + "node_modules/minimatch": { + "version": "7.4.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-7.4.6.tgz", + "integrity": "sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmmirror.com/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmmirror.com/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/nested-property": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/nested-property/-/nested-property-4.0.0.tgz", + "integrity": "sha512-yFehXNWRs4cM0+dz7QxCd06hTbWbSkV0ISsqBfkntU6TOY4Qm3Q88fRRLOddkGh2Qq6dZvnKVAahfhjcUvLnyA==" + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "optional": true, + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "optional": true, + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-posix": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/path-posix/-/path-posix-1.0.0.tgz", + "integrity": "sha512-1gJ0WpNIiYcQydgg3Ed8KzvIqTsDpNwq+cjBCssvBtuTWjEqY1AW+i+OepiEMqDCzyro9B2sLAe4RBPajMYFiA==" + }, + "node_modules/pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==" + }, + "node_modules/physical-cpu-count": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/physical-cpu-count/-/physical-cpu-count-2.0.0.tgz", + "integrity": "sha512-rxJOljMuWtYlvREBmd6TZYanfcPhNUKtGDZBjBBS8WG1dpN2iwPsRJZgQqN/OtJuiQckdRFOfzogqJClTrsi7g==" + }, + "node_modules/pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" + }, + "node_modules/requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" + }, + "node_modules/rfdc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", + "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==" + }, + "node_modules/sm-crypto": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/sm-crypto/-/sm-crypto-0.3.13.tgz", + "integrity": "sha512-ztNF+pZq6viCPMA1A6KKu3bgpkmYti5avykRHbcFIdSipFdkVmfUw2CnpM2kBJyppIalqvczLNM3wR8OQ0pT5w==", + "dependencies": { + "jsbn": "^1.1.0" + } + }, + "node_modules/streamroller": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.1.5.tgz", + "integrity": "sha512-KFxaM7XT+irxvdqSP1LGLgNWbYN7ay5owZ3r/8t77p+EtSUAfUgtl7be3xtqtOmGUl9K9YPO2ca8133RlTjvKw==", + "dependencies": { + "date-format": "^4.0.14", + "debug": "^4.3.4", + "fs-extra": "^8.1.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/strnum": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz", + "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==" + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "optional": true + }, + "node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/untildify": { + "version": "3.0.3", + "resolved": "https://registry.npmmirror.com/untildify/-/untildify-3.0.3.tgz", + "integrity": "sha512-iSk/J8efr8uPT/Z4eSUywnqyrQU7DSdMfdqK4iWEaUVVmcP5JcnpRqmVMwcwcnmI1ATFNgC5V90u09tBynNFKA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/url-join": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/url-join/-/url-join-5.0.0.tgz", + "integrity": "sha512-n2huDr9h9yzd6exQVnH/jU5mr+Pfx08LRXXZhkLLetAMESRj+anQsTAh940iMrIetKAmry9coFuZQ2jY8/p3WA==", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, + "node_modules/url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "dependencies": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, + "node_modules/web-streams-polyfill": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.2.tgz", + "integrity": "sha512-3pRGuxRF5gpuZc0W+EpwQRmCD7gRqcDOMt688KmdlDAgAyaB1XlN0zq2njfDNm44XVdIouE7pZ6GzbdyH47uIQ==", + "optional": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/webdav": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/webdav/-/webdav-5.3.1.tgz", + "integrity": "sha512-wzZdTHtMuSIXqHGBznc8FM2L94Mc/17Tbn9ppoMybRO0bjWOSIeScdVXWX5qqHsg00EjfiOcwMqGFx6ghIhccQ==", + "dependencies": { + "@buttercup/fetch": "^0.1.1", + "base-64": "^1.0.0", + "byte-length": "^1.0.2", + "fast-xml-parser": "^4.2.4", + "he": "^1.2.0", + "hot-patcher": "^2.0.0", + "layerr": "^2.0.1", + "md5": "^2.3.0", + "minimatch": "^7.4.6", + "nested-property": "^4.0.0", + "path-posix": "^1.0.0", + "url-join": "^5.0.0", + "url-parse": "^1.5.10" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/winreg": { + "version": "1.2.4", + "resolved": "https://registry.npmmirror.com/winreg/-/winreg-1.2.4.tgz", + "integrity": "sha512-IHpzORub7kYlb8A43Iig3reOvlcBJGX9gZ0WycHhghHtA65X0LYnMRuJs+aH1abVnMJztQkvQNlltnbPi5aGIA==" + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", + "dependencies": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + } + } +} diff --git a/kit/package.json b/kit/package.json index 683e782..8b636b2 100644 --- a/kit/package.json +++ b/kit/package.json @@ -3,17 +3,22 @@ "version": "0.1", "bin": "src/index.js", "scripts": { - "linux": "pkg --compress GZip . -t node18-linux -o ./dist/linux/kit", + "linux": "bun build ./src/index.js --compile --bytecode --minify --target=bun-linux-x64-baseline --outfile=./dist/linux/kit", "windows": "pkg --compress GZip . -t win -o ./dist/windows/kit.exe", - "alpine" : "pkg --compress GZip . -t node14-alpine-arm64 -o ./dist/linux/kit" + "alpine": "pkg --compress GZip . -t node14-alpine-arm64 -o ./dist/linux/kit", + "centos": "pkg --compress GZip . -t node14-linux-arm64 -o ./dist/linux/kit" }, "dependencies": { + "auto-launch": "^5.0.6", "cross-port-killer": "^1.4.0", + "diskusage-ng": "^1.0.4", "extract-zip": "^2.0.1", "get-port": "^7.0.0", "json5": "^2.2.3", "log4js": "^6.9.1", + "physical-cpu-count": "^2.0.0", "sm-crypto": "^0.3.13", + "systeminformation": "^5.25.11", "webdav": "^5.3.1" } } diff --git a/kit/src/index.js b/kit/src/index.js index c7663f0..77862c3 100644 --- a/kit/src/index.js +++ b/kit/src/index.js @@ -1,328 +1,364 @@ -/** - * kit cli 注册和调用执行 - */ -require("./init") -const { CliCmdParser } = require("../../argv") -const parser = new CliCmdParser("kit V" + $version); -const net = require("./net") -const shell = require("./shell") -const {sm4en3, sm4de3} = require("./crypto"); -const convutil = require("./util/convutil") -const path = require("path"); -const fs = require("fs"); -const {sm3} = require("sm-crypto"); -const zlib = require("zlib"); -const mem = require("./mem") - -parser.addCmdLine("man", "打开在线帮助;", async function (){ - const uConfig = await $context.get("uConfig") - shell.execSync("start " + uConfig.get("man")) -}); -parser.addCmdLine("manu", "人工维护配置;", function (){ - shell.execSync("start " + $sConfig.getUserConfigPath()) -}); - -parser.addCmdLine("run [--file] [func]", "运行项目脚本;", function (cli) { - $logger.info( "kit 当前执行目录 " + process.cwd()); - const fs = require("fs"); - - let step = cli.getParamValue("func"); - if ( ! step ) { - step = "main" - } - - let file = cli.getParamValue("file"); - if ( ! file ) { - file = "kit" - } - - const stat = fs.existsSync(`./${file}.js`) - if ( ! stat ) { - if ( ! cli.getParamValue("file") ) { - fs.writeFileSync("./kit.js", - ` -async function main(){ - console.log("hello kit!") -} -`); - } else { - $logger.info( `文件 ${file} 不存在` ); - return - } - } - - - const projectScript = fs.readFileSync("./kit.js", "utf-8"); - const vm = require('node:vm'); - const script = new vm.Script(projectScript + ";" + step + "()"); - const context = { - animal: 'cat', - count: 2, - $logger - }; - - script.runInNewContext(context, { - timeout : 10 * 60 * 1000, - breakOnSigint : true, - }); - $logger.info( "暂未实现" ); -}); - -parser.addCmdLine("config [value]", "查询/设置配置;", async function (cli){ - let key = cli.getParamValue("key"); - let value = cli.getParamValue("value"); - const uConfig = await $context.get("uConfig") - if (null != key && null == value) { - let v = uConfig.get(key); - $logger.info("{} : {}", key, v); - } else if (null != key && null != value) { - uConfig.set(key, value); - $logger.info("set {} : {}", key, value); - } else { - $logger.error("参数异常"); - } -}); - -parser.addCmdLine("remote-check", "验证远程仓库;", async function (){ - let remote = await $context.get("remote") - if (! ( await remote.check()) ) { - $logger.error("远程仓库不可用") - return - } else { - $logger.info("远程仓库可用") - } -}); - -parser.addCmdLine("publish", "发布到远程仓库;", async function (){ - let remote = await $context.get("remote") - if (! ( await remote.check()) ) { - $logger.error("远程仓库不可用") - return - } else { - $logger.info("远程仓库可用") - } - remote.publish() -}); -parser.addCmdLine("install [module]", "安装/更新模块;", async function (cli){ - let remote = await $context.get("remote") - if (! ( await remote.check()) ) { - $logger.error("远程仓库不可用") - return - } else { - $logger.info("远程仓库可用") - } - remote.install(cli.getParamValue("module")) -}); - - -parser.addCmdLine("freem [level]", "释放内存", function (cli) { - let level = cli.getParamValue("level") - mem.free( level ) -}); - - -parser.addCmdLine("killport ", "释放端口", function (cli) { - let port = cli.getParamValue("port") - net.killport( parseInt(port, 10) ); -}); - - -parser.addCmdLine("getport [--port]", "获取一个可用端口;或查询指定端口状态;", async function (cli) { - const getPort = await import('get-port').then(psl => psl.default); - let port = cli.getParamValue("port") - if( ! port ) { - let ret = await getPort() - $logger.info(`端口 ${ret} 未被使用`) - } else { - await net.getport( port ) - - } -}); - -parser.addCmdLine("checkip", "获取自己的公网 ip;", async function (cli) { - let ret = await net.checkip() - if( "ok" === ret.ret ) { - $logger.info( "ip : " + ret.data.ip ) - $logger.info( "location : " + ret.data.location.join(" ") ) - $logger.info("\n" + ret.data.ip) - } else { - $logger.error("获取失败") - } -}); - - -parser.addCmdLine("telnet [--timeout] [port]", "验证远程 TCP 端口是否可用;", async function (cli) { - let ip = cli.getParamValue("ip-port") - let port = 80; - - // 允许冒号形式指定端口 - const re = /^(?.*):(?[0-9]+)$/ - const match = ip.match( re ); - if ( match ) { - ip = match.groups.ip; - port = match.groups.port; - } else { - // 如果指定了 port 参数,那么使用 port 参数 - let dport = cli.getParamValue("port") - if ( dport ) { - port = dport; - } - } - - // 支持不填写 ip,默认访问本地 - if( "" === ip.trim() ) { - ip = "127.0.0.1"; - } - - try { - await net.telnet(port, ip, cli.getParamValue("timeout")) - $logger.info("连接成功") - }catch (e) { - $logger.error( e ) - } - -}); - -parser.addCmdLine("checklist ", "生成/验证文件 hash", async function (cli) { - let checkListFile = cli.getParamValue("checkListFile") - if ( !fs.existsSync( checkListFile ) ) { - $logger.error(`file ${checkListFile} 不存在`) - process.exit(-2) - } - const sm3 = require('sm-crypto').sm3 - const list = fs.readFileSync(checkListFile, "UTF-8") - const files = list.split('\n').filter(line => line.trim() !== ''); - for ( let file of files ) { - const infos = file.split(/\s+/) - const info = {} - if ( infos.length > 2 ) { - info.file = infos[0] - info.hash = infos[1] - info.alg = infos[2] - } else { - info.file = infos[0] - info.hash = infos[1] - info.alg = "md5" - } - if ( "sm3" === info.alg ) { - if ( !fs.existsSync( info.file ) ) { - $logger.error(`file ${info.file} 不存在`) - process.exit(-2) - } - - const data = fs.readFileSync(info.file); - const arrayBuffer = Buffer.from(data); - const uint8Array = new Uint8Array(arrayBuffer); - let hashData = sm3( uint8Array ) // 杂凑 - if ( hashData === info.hash ) { - $logger.info(`file ${file} 验证通过`) - } else { - $logger.error(`file ${file} 验证不通过`) - process.exit(-400) - } - - } else { - $logger.error(`不支持 file ${file} `) - process.exit(-2) - } - } - - $logger.info(`${checkListFile} 中的文件全部验证通过`) - -}) - -parser.addCmdLine("sm3 [--file] [--text] [--hash]", "生成/验证 SM3 值;", async function (cli) { - let filePath = cli.getParamValue("file") - let text = cli.getParamValue("text") - if( !filePath && !text ) { - $logger.error(`file 和 text 入参不能同时有`) - process.exit(-1) - } - const sm3 = require('sm-crypto').sm3 - if ( text ) { - let hashData = sm3( text ) // 杂凑 - $logger.info( hashData ) - } - if ( filePath ) { - if ( !fs.existsSync( filePath ) ) { - $logger.error(`file ${filePath} 不存在`) - process.exit(-2) - } - const data = fs.readFileSync(filePath); - const arrayBuffer = Buffer.from(data); - const uint8Array = new Uint8Array(arrayBuffer); - let hashData = sm3( uint8Array ) // 杂凑 - $logger.info( hashData ) - } -}); - -parser.addCmdLine("sm4en3 ", "sm4 加密,密钥通过 sm3 制备;", function (cli) { - const {sm4en3} = require("./crypto"); - let key = cli.getParamValue("key") - let data = cli.getParamValue("data") - let out = sm4en3( key, data ) - $logger.info( out ); -}); - -parser.addCmdLine("sm4de3 ", "sm4 解密,密钥通过 sm3 制备;", function (cli) { - const {sm4de3} = require("./crypto"); - let key = cli.getParamValue("key") - let data = cli.getParamValue("data") - let out = sm4de3( key, data ) - $logger.info( out ); -}); - -// parser.addCmdLine("base64 <-en/-de> ", "base64 编解码", function (cli) { -parser.addCmdLine("base64 [-en] [-de] [-hex] ", "base64 编解码;", function (cli) { - let data = cli.getParamValue("data") - if ( cli.hasFlag("de") ) { - if ( cli.hasFlag("hex") ) { - $logger.info( "执行 base64 decode to hex: " ); - $logger.info( convutil.base64ToHex( data ) ); - } else { - $logger.info( "执行 base64 decode to string: " ); - $logger.info( convutil.base64ToString( data ) ); - } - } else { - if ( cli.hasFlag("hex") ) { - $logger.info( "执行 hex encode to base64: " ); - $logger.info( convutil.hexToBase64( data ) ); - } else { - $logger.info( "执行 string encode to base64: " ); - $logger.info( convutil.stringToBase64( data ) ); - } - } -}); - -parser.addCmdLine("replace [-d] ", "文件内容正则替换;", function (cli) { - $logger.info( "暂未实现" ); -}); - -parser.addCmdLine("crlf [-d] [-r] [--path] [--filter-name] [--filter-path] ", "回车一致化", function (cli) { - $logger.info( "暂未实现" ); -}); - -parser.addCmdLine("tcpc [-d] [-x] [--host] [--ip] [--port] [--headlen] [--timeout] [--filepath]", "tcp 报文发收", function (cli) { - $logger.info( "暂未实现" ); -}); - -async function main(){ - - try { - let cmd = parser.parse(process.argv.slice(2)) - if ( ! cmd ) { - console.log( parser.help() ) - } else { - $logger.info(`执行命令 ${cmd.cmdline.cmd}`) - if ( cmd.canEval() ){ - await cmd.eval() - } else { - console.log( parser.help() ) - } - } - } catch ( e ) { - console.error( e ) - } -} - -main() +/** + * kit cli 注册和调用执行 + */ +require("./init") +const { CliCmdParser } = require("../../argv") +const parser = new CliCmdParser("kit V" + $version); +const net = require("./net") +const shell = require("./shell") +const {sm4en3, sm4de3} = require("./crypto"); +const convutil = require("./util/convutil") +const path = require("path"); +const fs = require("fs"); +const {sm3} = require("sm-crypto"); +const zlib = require("zlib"); +const mem = require("./mem") +const { getAllDeviceInfo } = require("./platform") +const kitcommand = require("./kitcommand") +kitcommand.init() +kitcommand.regTo( parser ) + + +// parser.addCmdLine("man", "打开在线帮助;", async function (){ +// const uConfig = await $context.get("uConfig") +// shell.execSync("start " + uConfig.get("man")) +// }); +// parser.addCmdLine("manu", "人工维护配置;", function (){ +// shell.execSync("start " + $sConfig.getUserConfigPath()) +// }); +// +// parser.addCmdLine("run [--file] [func]", "运行项目脚本;", function (cli) { +// $logger.info( "kit 当前执行目录 " + process.cwd()); +// const fs = require("fs"); +// +// let step = cli.getParamValue("func"); +// if ( ! step ) { +// step = "main" +// } +// +// let file = cli.getParamValue("file"); +// if ( ! file ) { +// file = "kit" +// } +// +// const stat = fs.existsSync(`./${file}.js`) +// if ( ! stat ) { +// if ( ! cli.getParamValue("file") ) { +// fs.writeFileSync("./kit.js", +// ` +// async function main(){ +// console.log("hello kit!") +// } +// `); +// } else { +// $logger.info( `文件 ${file} 不存在` ); +// return +// } +// } +// +// +// const projectScript = fs.readFileSync("./kit.js", "utf-8"); +// const vm = require('node:vm'); +// const script = new vm.Script(projectScript + ";" + step + "()"); +// const context = { +// animal: 'cat', +// count: 2, +// $logger, +// shell +// }; +// +// script.runInNewContext(context, { +// timeout : 10 * 60 * 1000, +// breakOnSigint : true, +// }); +// $logger.info( "暂未实现" ); +// }); +// +// parser.addCmdLine("config [value]", "查询/设置配置;", async function (cli){ +// let key = cli.getParamValue("key"); +// let value = cli.getParamValue("value"); +// const uConfig = await $context.get("uConfig") +// if (null != key && null == value) { +// let v = uConfig.get(key); +// $logger.info("{} : {}", key, v); +// } else if (null != key && null != value) { +// uConfig.set(key, value); +// $logger.info("set {} : {}", key, value); +// } else { +// $logger.error("参数异常"); +// } +// }); +// +// parser.addCmdLine("remote-check", "验证远程仓库;", async function (){ +// let remote = await $context.get("remote") +// if (! ( await remote.check()) ) { +// $logger.error("远程仓库不可用") +// return +// } else { +// $logger.info("远程仓库可用") +// } +// }); +// +// parser.addCmdLine("publish", "发布到远程仓库;", async function (){ +// let remote = await $context.get("remote") +// if (! ( await remote.check()) ) { +// $logger.error("远程仓库不可用") +// return +// } else { +// $logger.info("远程仓库可用") +// } +// remote.publish() +// }); +// parser.addCmdLine("install [module]", "安装/更新模块;", async function (cli){ +// let remote = await $context.get("remote") +// if (! ( await remote.check()) ) { +// $logger.error("远程仓库不可用") +// return +// } else { +// $logger.info("远程仓库可用") +// } +// remote.install(cli.getParamValue("module")) +// }); + + +parser.addCmdLine("platform", "平台信息", function (cli) { +// 调用主函数并打印结果 + getAllDeviceInfo().then(info => { + console.log('Device Information:'); + console.log( JSON.stringify(info, null, 4)); + }).catch(error => { + console.error('Error getting device information:', error); + }); +}); + + + +parser.addCmdLine("freem [level]", "释放内存", function (cli) { + let level = cli.getParamValue("level") + mem.free( level ) +}); + + +parser.addCmdLine("killport ", "释放端口", function (cli) { + let port = cli.getParamValue("port") + net.killport( parseInt(port, 10) ); +}); + + +parser.addCmdLine("getport [--port]", "获取一个可用端口;或查询指定端口状态;", async function (cli) { + const getPort = await import('get-port').then(psl => psl.default); + let port = cli.getParamValue("port") + if( ! port ) { + let ret = await getPort() + $logger.info(`端口 ${ret} 未被使用`) + } else { + await net.getport( port ) + + } +}); + +parser.addCmdLine("checkip", "获取自己的公网 ip;", async function (cli) { + let ret = await net.checkip() + if( "ok" === ret.ret ) { + $logger.info( "ip : " + ret.data.ip ) + $logger.info( "location : " + ret.data.location.join(" ") ) + $logger.info("\n" + ret.data.ip) + } else { + $logger.error("获取失败") + } +}); + + +parser.addCmdLine("telnet [--timeout] [port]", "验证远程 TCP 端口是否可用;", async function (cli) { + let ip = cli.getParamValue("ip-port") + let port = 80; + + // 允许冒号形式指定端口 + const re = /^(?.*):(?[0-9]+)$/ + const match = ip.match( re ); + if ( match ) { + ip = match.groups.ip; + port = match.groups.port; + } else { + // 如果指定了 port 参数,那么使用 port 参数 + let dport = cli.getParamValue("port") + if ( dport ) { + port = dport; + } + } + + // 支持不填写 ip,默认访问本地 + if( "" === ip.trim() ) { + ip = "127.0.0.1"; + } + + try { + await net.telnet(port, ip, cli.getParamValue("timeout")) + $logger.info("连接成功") + process.exit(0) + }catch (e) { + $logger.error( e ) + process.exit(-1) + } + +}); + +parser.addCmdLine("checklist ", "生成/验证文件 hash", async function (cli) { + let checkListFile = cli.getParamValue("checkListFile") + if ( !fs.existsSync( checkListFile ) ) { + $logger.error(`file ${checkListFile} 不存在`) + process.exit(-2) + } + const sm3 = require('sm-crypto').sm3 + const list = fs.readFileSync(checkListFile, "UTF-8") + const files = list.split('\n').filter(line => line.trim() !== ''); + for ( let file of files ) { + const infos = file.split(/\s+/) + const info = {} + if ( infos.length > 2 ) { + info.file = infos[0] + info.hash = infos[1] + info.alg = infos[2] + } else { + info.file = infos[0] + info.hash = infos[1] + info.alg = "md5" + } + if ( "sm3" === info.alg ) { + if ( !fs.existsSync( info.file ) ) { + $logger.error(`file ${info.file} 不存在`) + process.exit(-2) + } + + const data = fs.readFileSync(info.file); + const arrayBuffer = Buffer.from(data); + const uint8Array = new Uint8Array(arrayBuffer); + let hashData = sm3( uint8Array ) // 杂凑 + if ( hashData === info.hash ) { + $logger.info(`file ${file} 验证通过`) + } else { + $logger.error(`file ${file} 验证不通过`) + process.exit(-400) + } + + } else { + $logger.error(`不支持 file ${file} `) + process.exit(-2) + } + } + + $logger.info(`${checkListFile} 中的文件全部验证通过`) + +}) + +parser.addCmdLine("sm3 [--file] [--text] [--hash]", "生成/验证 SM3 值;", async function (cli) { + let filePath = cli.getParamValue("file") + let text = cli.getParamValue("text") + if( !filePath && !text ) { + $logger.error(`file 和 text 入参不能同时有`) + process.exit(-1) + } + const sm3 = require('sm-crypto').sm3 + if ( text ) { + let hashData = sm3( text ) // 杂凑 + $logger.info( hashData ) + } + if ( filePath ) { + if ( !fs.existsSync( filePath ) ) { + $logger.error(`file ${filePath} 不存在`) + process.exit(-2) + } + const data = fs.readFileSync(filePath); + const arrayBuffer = Buffer.from(data); + const uint8Array = new Uint8Array(arrayBuffer); + let hashData = sm3( uint8Array ) // 杂凑 + $logger.info( hashData ) + } +}); + +parser.addCmdLine("sm4en3 ", "sm4 加密,密钥通过 sm3 制备;", function (cli) { + const {sm4en3} = require("./crypto"); + let key = cli.getParamValue("key") + let data = cli.getParamValue("data") + let out = sm4en3( key, data ) + $logger.info( out ); +}); + +parser.addCmdLine("sm4de3 ", "sm4 解密,密钥通过 sm3 制备;", function (cli) { + const {sm4de3} = require("./crypto"); + let key = cli.getParamValue("key") + let data = cli.getParamValue("data") + let out = sm4de3( key, data ) + $logger.info( out ); +}); + +// parser.addCmdLine("base64 <-en/-de> ", "base64 编解码", function (cli) { +parser.addCmdLine("base64 [-en] [-de] [-hex] ", "base64 编解码;", function (cli) { + let data = cli.getParamValue("data") + if ( cli.hasFlag("de") ) { + if ( cli.hasFlag("hex") ) { + $logger.info( "执行 base64 decode to hex: " ); + $logger.info( convutil.base64ToHex( data ) ); + } else { + $logger.info( "执行 base64 decode to string: " ); + $logger.info( convutil.base64ToString( data ) ); + } + } else { + if ( cli.hasFlag("hex") ) { + $logger.info( "执行 hex encode to base64: " ); + $logger.info( convutil.hexToBase64( data ) ); + } else { + $logger.info( "执行 string encode to base64: " ); + $logger.info( convutil.stringToBase64( data ) ); + } + } +}); + + +parser.addCmdLine("touch [-d] ", "文件时间修改为当前时间;", function (cli) { + const fs = require('fs'); + const path = cli.getParamValue("file_name") +// 获取当前日期时间 + const now = new Date(); +// 修改文件的访问时间和修改时间为当前时间 + fs.utimes(path, now, now, (err) => { + if (err) { + $logger.error('修改文件时间出错:', err); + } else { + $logger.info('文件时间修改成功'); + } + }); +}); + +parser.addCmdLine("replace [-d] ", "文件内容正则替换;", function (cli) { + $logger.info( "暂未实现" ); +}); + +parser.addCmdLine("crlf [-d] [-r] [--path] [--filter-name] [--filter-path] ", "回车一致化", function (cli) { + $logger.info( "暂未实现" ); +}); + +parser.addCmdLine("tcpc [-d] [-x] [--host] [--ip] [--port] [--headlen] [--timeout] [--filepath]", "tcp 报文发收", function (cli) { + $logger.info( "暂未实现" ); +}); + +async function main(){ + + try { + let cmd = parser.parse(process.argv.slice(2)) + if ( ! cmd ) { + console.log( parser.help() ) + } else { + $logger.info(`执行命令 ${cmd.cmdline.cmd}`) + if ( cmd.canEval() ){ + await cmd.eval() + } else { + console.log( parser.help() ) + } + } + } catch ( e ) { + console.error( e ) + } +} + +main() diff --git a/kit/src/kitcommand.js b/kit/src/kitcommand.js index 0067a19..031b694 100644 --- a/kit/src/kitcommand.js +++ b/kit/src/kitcommand.js @@ -1,108 +1,107 @@ -const shell = require("./shell"); -const fs = require("fs"); -const vm = require("node:vm"); - - -module.exports = { - init : function () { - return this; - }, - regTo: function (parser) { - - parser.addCmdLine("help", "打开在线帮助;", async function () { - const uConfig = await $context.get("uConfig") - shell.execSync("start " + uConfig.get("man")) - }); - parser.addCmdLine("manu", "人工维护配置;", function () { - shell.execSync("start " + $sConfig.getUserConfigPath()) - }); - - parser.addCmdLine("run [--file] [func]", "运行项目脚本;", function (cli) { - $logger.info("kit 当前执行目录 " + process.cwd()); - const fs = require("fs"); - - let step = cli.getParamValue("func"); - if (!step) { - step = "main" - } - - let file = cli.getParamValue("file"); - if (!file) { - file = "kit" - } - - const stat = fs.existsSync(`./${file}.js`) - if (!stat) { - if (!cli.getParamValue("file")) { - fs.writeFileSync("./kit.js", ` -async function main(){ - console.log("hello kit!") -} -`); - } else { - $logger.info(`文件 ${file} 不存在`); - return - } - } - - - const projectScript = fs.readFileSync("./kit.js", "utf-8"); - const vm = require('node:vm'); - const script = new vm.Script(projectScript + ";" + step + "()"); - const context = { - animal: 'cat', count: 2, $logger - }; - - script.runInNewContext(context, { - timeout: 10 * 60 * 1000, breakOnSigint: true, - }); - $logger.info("暂未实现"); - }); - - parser.addCmdLine("config [value]", "查询/设置配置;", async function (cli) { - let key = cli.getParamValue("key"); - let value = cli.getParamValue("value"); - const uConfig = await $context.get("uConfig") - if (null != key && null == value) { - let v = uConfig.get(key); - $logger.info("{} : {}", key, v); - } else if (null != key && null != value) { - uConfig.set(key, value); - $logger.info("set {} : {}", key, value); - } else { - $logger.error("参数异常"); - } - }); - - parser.addCmdLine("remote-check", "验证远程仓库;", async function () { - let remote = await $context.get("remote") - if (!(await remote.check())) { - $logger.error("远程仓库不可用") - return - } else { - $logger.info("远程仓库可用") - } - }); - - parser.addCmdLine("publish", "发布到远程仓库;", async function () { - let remote = await $context.get("remote") - if (!(await remote.check())) { - $logger.error("远程仓库不可用") - return - } else { - $logger.info("远程仓库可用") - } - remote.publish() - }); - parser.addCmdLine("install [module]", "安装/更新模块;", async function (cli) { - let remote = await $context.get("remote") - if (!(await remote.check())) { - $logger.error("远程仓库不可用") - return - } else { - $logger.info("远程仓库可用") - } - remote.install(cli.getParamValue("module")) - }); - } -} +const shell = require("./shell"); + + +module.exports = { + init : function () { + return this; + }, + regTo: function (parser) { + + parser.addCmdLine("help", "打开在线帮助;", async function () { + const uConfig = await $context.get("uConfig") + shell.execSync("start " + uConfig.get("man")) + }); + parser.addCmdLine("manu", "人工维护配置;", function () { + shell.execSync("start " + $sConfig.getUserConfigPath()) + }); + + parser.addCmdLine("run [--file] [func]", "运行项目脚本;", function (cli) { + $logger.info("kit 当前执行目录 " + process.cwd()); + const fs = require("fs"); + + let step = cli.getParamValue("func"); + if (!step) { + step = "main" + } + + let file = cli.getParamValue("file"); + if (!file) { + file = "kit" + } + + const stat = fs.existsSync(`./${file}.js`) + if (!stat) { + if (!cli.getParamValue("file")) { + fs.writeFileSync("./kit.js", ` +async function main(){ + console.log("hello kit!") +} +`); + } else { + $logger.info(`文件 ${file} 不存在`); + return + } + } + + + const projectScript = fs.readFileSync("./kit.js", "utf-8"); + const vm = require('node:vm'); + const script = new vm.Script(projectScript + ";" + step + "()"); + const context = { + animal: 'cat', count: 2, $logger, shell + }; + + script.runInNewContext(context, { + timeout: 10 * 60 * 1000, breakOnSigint: true, + }); + $logger.info("执行结束"); + }); + + parser.addCmdLine("config [value]", "查询/设置配置;", async function (cli) { + let key = cli.getParamValue("key"); + let value = cli.getParamValue("value"); + const uConfig = await $context.get("uConfig") + if (null != key && null == value) { + let v = uConfig.get(key); + $logger.info("{} : {}", key, v); + } else if (null != key && null != value) { + uConfig.set(key, value); + $logger.info("set {} : {}", key, value); + } else { + $logger.error("参数异常"); + } + }); + + parser.addCmdLine("remote-check", "验证远程仓库;", async function () { + let remote = await $context.get("remote") + if (!(await remote.check())) { + $logger.error("远程仓库不可用") + return + } else { + $logger.info("远程仓库可用") + } + }); + + parser.addCmdLine("publish", "发布到远程仓库;", async function () { + let remote = await $context.get("remote") + if (!(await remote.check())) { + $logger.error("远程仓库不可用") + return + } else { + $logger.info("远程仓库可用") + } + remote.publish() + }); + parser.addCmdLine("install [module]", "安装/更新模块;", async function (cli) { + let remote = await $context.get("remote") + if (!(await remote.check())) { + $logger.error("远程仓库不可用") + return + } else { + $logger.info("远程仓库可用") + } + remote.install(cli.getParamValue("module")) + }); + + } +} diff --git a/kit/src/launch.js b/kit/src/launch.js new file mode 100644 index 0000000..6ad2e59 --- /dev/null +++ b/kit/src/launch.js @@ -0,0 +1,21 @@ +/** + * 将 kit 或其他文件注册为开机启动 + * kit 启动通过 auto-launch 模块实现,其他文件通过 kit 调用系统命令启动。 + */ + +const AutoLaunch = require('auto-launch'); + + + +function reg(){ + var launch = new AutoLaunch({ + name: 'Kit', + path: 'node D:\\fullstack\\TDevOps\\kit\\src\\index.js launch', + }); + + launch.enable(); +} + + + +reg() diff --git a/kit/src/mem.js b/kit/src/mem.js index 707b7f2..3258a2f 100644 --- a/kit/src/mem.js +++ b/kit/src/mem.js @@ -1,22 +1,22 @@ -const osutil = require("./util/osutil") -const shell = require("./shell") - -function free(level) { - osutil.choise({ - [osutil.Windows] : ( level ) => { - throw Error("暂不支持") - }, - [osutil.Linux] : ( level ) => { - if ( [1,2,3].indexOf( parseInt(level,10)) === -1 ) { - level = 1 - } - shell.execSync("sync") - shell.execSync(`echo ${level} > /proc/sys/vm/drop_caches`) - }, - }) -} - - -module.exports = { - free +const osutil = require("./util/osutil") +const shell = require("./shell") + +function free(level) { + osutil.choise({ + [osutil.Windows] : ( level ) => { + throw Error("暂不支持") + }, + [osutil.Linux] : ( level ) => { + if ( [1,2,3].indexOf( parseInt(level,10)) === -1 ) { + level = 1 + } + shell.execSync("sync") + shell.execSync(`echo ${level} > /proc/sys/vm/drop_caches`) + }, + }) +} + + +module.exports = { + free } \ No newline at end of file diff --git a/kit/src/net.js b/kit/src/net.js index 7db8bee..acbc3e7 100644 --- a/kit/src/net.js +++ b/kit/src/net.js @@ -1,84 +1,84 @@ -require("./init") -const osutil = require("./util/osutil") -const killer = require('cross-port-killer'); -const net = require('node:net'); - - -/** - * 模拟 telnet ,检测端口是否开放 - * @param port - * @param host - * @param timeout - * @returns {Promise} - */ -async function telnet(port, host, timeout=3000){ - $logger.debug(`port=${port} host=${host} timeout=${timeout}`) - return new Promise(function (resolve, reject){ - const socket = new net.Socket(); - - socket.setTimeout(timeout, function() { - socket.end(); - reject("链接超时") - }); - - socket.connect(port, host); - - socket.on('connect', function() { - resolve('连接成功'); - socket.end(); - }); - - socket.on('error', function(err) { - reject('连接失败'); - }); - }) - -} - -async function killport(port) { - return killer.kill( port ); - // let func = osutil.choise([ - // require("./windows/net").killport, - // require("./linux/net").killport, - // ]) - // return func && func(port); -} - -/** - * 获取端口信息 - * 因为命令输出缓存问题,有缺陷。 - * @param port - * @returns {Promise} - */ -async function getport(port) { - $logger.info( "暂未实现" ); -} - - -async function checkip(){ - const url = "https://myip.ipip.net/json" - const http = url.startsWith("https:") ? require("node:https") : require('node:http'); - return new Promise((resolve, reject) => { - http.get(url, (res) => { - let data = ''; - - // A chunk of data has been recieved. - res.on('data', (chunk) => { - data += chunk; - }); - - // The whole response has been received. Resolve the promise with result - res.on('end', () => { - resolve(JSON.parse(data)); - }); - - }).on("error", (err) => { - // In case of any error reject the promise - reject(err); - }); - }); -} - -module.exports = { - killport, getport, telnet, checkip +require("./init") +const osutil = require("./util/osutil") +const killer = require('cross-port-killer'); +const net = require('node:net'); + + +/** + * 模拟 telnet ,检测端口是否开放 + * @param port + * @param host + * @param timeout + * @returns {Promise} + */ +async function telnet(port, host, timeout=3000){ + $logger.debug(`port=${port} host=${host} timeout=${timeout}`) + return new Promise(function (resolve, reject){ + const socket = new net.Socket(); + + socket.setTimeout(timeout, function() { + socket.end(); + reject("链接超时") + }); + + socket.connect(port, host); + + socket.on('connect', function() { + resolve('连接成功'); + socket.end(); + }); + + socket.on('error', function(err) { + reject('连接失败'); + }); + }) + +} + +async function killport(port) { + return killer.kill( port ); + // let func = osutil.choise([ + // require("./windows/net").killport, + // require("./linux/net").killport, + // ]) + // return func && func(port); +} + +/** + * 获取端口信息 + * 因为命令输出缓存问题,有缺陷。 + * @param port + * @returns {Promise} + */ +async function getport(port) { + $logger.info( "暂未实现" ); +} + + +async function checkip(){ + const url = "https://myip.ipip.net/json" + const http = url.startsWith("https:") ? require("node:https") : require('node:http'); + return new Promise((resolve, reject) => { + http.get(url, (res) => { + let data = ''; + + // A chunk of data has been recieved. + res.on('data', (chunk) => { + data += chunk; + }); + + // The whole response has been received. Resolve the promise with result + res.on('end', () => { + resolve(JSON.parse(data)); + }); + + }).on("error", (err) => { + // In case of any error reject the promise + reject(err); + }); + }); +} + +module.exports = { + killport, getport, telnet, checkip } \ No newline at end of file diff --git a/kit/src/platform.js b/kit/src/platform.js new file mode 100644 index 0000000..5581908 --- /dev/null +++ b/kit/src/platform.js @@ -0,0 +1,87 @@ +const os = require('os'); +const diskusage = require('diskusage-ng'); +const { physicalCpuCount } = require('physical-cpu-count'); +const { formatBytes } = require("./util/convutil") + +// 获取操作系统信息 +function getOSInfo() { + return { + type: os.type(), + platform: os.platform(), + release: os.release(), + arch: os.arch() + }; +} + +// 获取 CPU 信息 +function getCPUInfo() { + const cpus = os.cpus(); + return { + model: cpus[0].model, + speed: cpus[0].speed, + cores: cpus.length, + physicalCores: physicalCpuCount + }; +} + +// 获取内存信息 +function getMemoryInfo() { + let info = { + totalSize: os.totalmem(), + freeSize: os.freemem() + } + + return Object.assign(info, { + total : formatBytes(info.totalSize), + free : formatBytes(info.freeSize), + }); +} + +// 获取硬盘信息 +async function getDiskInfo() { + try { + const path = os.platform() === 'win32' ? 'C:' : '/'; + return new Promise(function (resolve, reject) { + diskusage(path, function (err, usage) { + if (err) { + console.error('Error getting disk information:', err); + reject(err); + } + resolve({ + totalSize: usage.total, + freeSize: usage.available, + total : formatBytes(usage.total), + free : formatBytes(usage.available), + }); + }); + }) + + + } catch (error) { + console.error('Error getting disk information:', error); + return null; + } +} + +// 主函数,调用上述函数获取所有信息 +async function getAllDeviceInfo() { + const osInfo = getOSInfo(); + const cpuInfo = getCPUInfo(); + const memoryInfo = getMemoryInfo(); + const diskInfo = await getDiskInfo(); + + return { + os: osInfo, + cpu: cpuInfo, + memory: memoryInfo, + disk: diskInfo + }; +} + +module.exports = { + getOSInfo, + getCPUInfo, + getMemoryInfo, + getDiskInfo, + getAllDeviceInfo +}; diff --git a/kit/src/shell/index.js b/kit/src/shell/index.js index 4e7bdfd..6232dbe 100644 --- a/kit/src/shell/index.js +++ b/kit/src/shell/index.js @@ -23,5 +23,11 @@ module.exports = { $logger.debug(`execSync ${cmd}`) const output = execSync(cmd); return output.toString() + }, + + callSync(cmd){ + $logger.debug(`callSync ${cmd}`) + const output = execSync(cmd); + console.log(output.toString()) } } \ No newline at end of file diff --git a/kit/src/util/convutil.js b/kit/src/util/convutil.js index 891b9d6..b310349 100644 --- a/kit/src/util/convutil.js +++ b/kit/src/util/convutil.js @@ -1,3 +1,21 @@ + +function formatBytes(bytes, decimals = 2) { + if (bytes === 0) return "0 B"; // 处理 0 字节的情况 + + const units = ["B", "K", "M", "G", "T", "P", "E", "Z", "Y"]; + let unitIndex = 0; + + // 循环除以 1024,直到字节数小于 1024 或单位用完 + while (bytes >= 1024 && unitIndex < units.length - 1) { + bytes /= 1024; + unitIndex++; + } + + // 保留小数位数,并移除末尾多余的零(如 2.0 → 2) + const formattedNumber = bytes.toFixed(decimals).replace(/\.0+$/, ""); + return `${formattedNumber} ${units[unitIndex]}`; +} + var codePoint2utf8 = function (code) { var bin = parseInt(code).toString(2) var ln = 0; @@ -209,135 +227,6 @@ function base64ArrayBuffer(arrayBuffer) { return base64 } -(function() { - var base64EncodeChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', - base64DecodeChars = new Array(( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), 62, ( - 1), ( - 1), ( - 1), 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, ( - 1), ( - 1), ( - 1), ( - 1), ( - 1)); - this.base64encode = function(e) { - var r, a, c, h, o, t; - for (c = e.length, a = 0, r = ''; a < c;) { - if (h = 255 & e.charCodeAt(a++), a == c) { - r += base64EncodeChars.charAt(h >> 2), - r += base64EncodeChars.charAt((3 & h) << 4), - r += '=='; - break - } - if (o = e.charCodeAt(a++), a == c) { - r += base64EncodeChars.charAt(h >> 2), - r += base64EncodeChars.charAt((3 & h) << 4 | (240 & o) >> 4), - r += base64EncodeChars.charAt((15 & o) << 2), - r += '='; - break - } - t = e.charCodeAt(a++), - r += base64EncodeChars.charAt(h >> 2), - r += base64EncodeChars.charAt((3 & h) << 4 | (240 & o) >> 4), - r += base64EncodeChars.charAt((15 & o) << 2 | (192 & t) >> 6), - r += base64EncodeChars.charAt(63 & t) - } - return r - } - this.base64decode = function(e) { - var r, a, c, h, o, t, d; - for (t = e.length, o = 0, d = ''; o < t;) { - do r = base64DecodeChars[255 & e.charCodeAt(o++)]; - while (o < t && r == -1); - if (r == -1) break; - do a = base64DecodeChars[255 & e.charCodeAt(o++)]; - while (o < t && a == -1); - if (a == -1) break; - d += String.fromCharCode(r << 2 | (48 & a) >> 4); - do { - if (c = 255 & e.charCodeAt(o++), 61 == c) return d; - c = base64DecodeChars[c] - } while ( o < t && c == - 1 ); - if (c == -1) break; - d += String.fromCharCode((15 & a) << 4 | (60 & c) >> 2); - do { - if (h = 255 & e.charCodeAt(o++), 61 == h) return d; - h = base64DecodeChars[h] - } while ( o < t && h == - 1 ); - if (h == -1) break; - d += String.fromCharCode((3 & c) << 6 | h) - } - return d - } - this.HexToBase64 = function(str) { - return base64encode(String.fromCharCode.apply(null, str.replace(/\r|\n/g, "").replace(/([\da-fA-F]{2}) ?/g, "0x$1 ").replace(/ +$/, "").split(" "))); - } - this.Base64Tohex = function(str) { - for (var i = 0, - bin = base64decode(str.replace(/[ \r\n]+$/, "")), hex = []; i < bin.length; ++i) { - var tmp = bin.charCodeAt(i).toString(16); - if (tmp.length === 1) tmp = "0" + tmp; - hex[hex.length] = tmp; - } - return hex.join(""); - }, - this.toBytes = function(str) { - for (var bytes = [], c = 0; c < str.length; c += 2) - bytes.push(parseInt(str.substr(c, 2), 16)); - return bytes; - } - -}) (); -//hexToBase64 Base64Tohex base64decode base64encode - -var bytesToString = function(bytes){ - return hexToString(bytesToHex(bytes)); -} - - -var bytesToBase64 = function(bytes){ - return base64ArrayBuffer(bytes); -} - -// Convert a byte array to a hex string -var bytesToHex = function(bytes) { - for (var hex = [], i = 0; i < bytes.length; i++) { - hex.push((bytes[i] >>> 4).toString(16)); - hex.push((bytes[i] & 0xF).toString(16)); - } - return hex.join(""); -} - - -var stringToBase64 = function(str){ - return base64encode(str); -} - -var stringToBytes = function(str){ - return hexToBytes(stringToHex(str)); -} - -// Convert a ASCII string to a hex string -var stringToHex = function(str) { - return str.split("").map(function(c) { - return ("0" + c.charCodeAt(0).toString(16)).slice(-2); - }).join(""); -} - -var hexToBytes= function(hex) { - for (var bytes = [], c = 0; c < hex.length; c += 2) - bytes.push(parseInt(hex.substr(c, 2), 16)); - return bytes; -} - -// Convert a hex string to a ASCII string -var hexToString = function(hexStr) { - var hex = hexStr.toString();//force conversion - var str = ''; - for (var i = 0; i < hex.length; i += 2) - str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); - return str; -} - -var hexToBase64 = function(hexStr){ - return HexToBase64(hexStr); -} - -var base64ToString = function(base64str){ - return base64decode(base64str); -} const Base64 = { @@ -434,6 +323,138 @@ const Base64 = { } } + +// (function() { +// var base64EncodeChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', +// base64DecodeChars = new Array(( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), 62, ( - 1), ( - 1), ( - 1), 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), ( - 1), 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, ( - 1), ( - 1), ( - 1), ( - 1), ( - 1)); +// this.base64encode = function(e) { +// var r, a, c, h, o, t; +// for (c = e.length, a = 0, r = ''; a < c;) { +// if (h = 255 & e.charCodeAt(a++), a == c) { +// r += base64EncodeChars.charAt(h >> 2), +// r += base64EncodeChars.charAt((3 & h) << 4), +// r += '=='; +// break +// } +// if (o = e.charCodeAt(a++), a == c) { +// r += base64EncodeChars.charAt(h >> 2), +// r += base64EncodeChars.charAt((3 & h) << 4 | (240 & o) >> 4), +// r += base64EncodeChars.charAt((15 & o) << 2), +// r += '='; +// break +// } +// t = e.charCodeAt(a++), +// r += base64EncodeChars.charAt(h >> 2), +// r += base64EncodeChars.charAt((3 & h) << 4 | (240 & o) >> 4), +// r += base64EncodeChars.charAt((15 & o) << 2 | (192 & t) >> 6), +// r += base64EncodeChars.charAt(63 & t) +// } +// return r +// } +// this.base64decode = function(e) { +// var r, a, c, h, o, t, d; +// for (t = e.length, o = 0, d = ''; o < t;) { +// do r = base64DecodeChars[255 & e.charCodeAt(o++)]; +// while (o < t && r == -1); +// if (r == -1) break; +// do a = base64DecodeChars[255 & e.charCodeAt(o++)]; +// while (o < t && a == -1); +// if (a == -1) break; +// d += String.fromCharCode(r << 2 | (48 & a) >> 4); +// do { +// if (c = 255 & e.charCodeAt(o++), 61 == c) return d; +// c = base64DecodeChars[c] +// } while ( o < t && c == - 1 ); +// if (c == -1) break; +// d += String.fromCharCode((15 & a) << 4 | (60 & c) >> 2); +// do { +// if (h = 255 & e.charCodeAt(o++), 61 == h) return d; +// h = base64DecodeChars[h] +// } while ( o < t && h == - 1 ); +// if (h == -1) break; +// d += String.fromCharCode((3 & c) << 6 | h) +// } +// return d +// } +// this.HexToBase64 = function(str) { +// return base64encode(String.fromCharCode.apply(null, str.replace(/\r|\n/g, "").replace(/([\da-fA-F]{2}) ?/g, "0x$1 ").replace(/ +$/, "").split(" "))); +// } +// this.Base64Tohex = function(str) { +// for (var i = 0, +// bin = base64decode(str.replace(/[ \r\n]+$/, "")), hex = []; i < bin.length; ++i) { +// var tmp = bin.charCodeAt(i).toString(16); +// if (tmp.length === 1) tmp = "0" + tmp; +// hex[hex.length] = tmp; +// } +// return hex.join(""); +// }, +// this.toBytes = function(str) { +// for (var bytes = [], c = 0; c < str.length; c += 2) +// bytes.push(parseInt(str.substr(c, 2), 16)); +// return bytes; +// } +// +// }) (); +//hexToBase64 Base64Tohex base64decode base64encode + +var bytesToString = function(bytes){ + return hexToString(bytesToHex(bytes)); +} + + +var bytesToBase64 = function(bytes){ + return base64ArrayBuffer(bytes); +} + +// Convert a byte array to a hex string +var bytesToHex = function(bytes) { + for (var hex = [], i = 0; i < bytes.length; i++) { + hex.push((bytes[i] >>> 4).toString(16)); + hex.push((bytes[i] & 0xF).toString(16)); + } + return hex.join(""); +} + + +var stringToBase64 = function(str){ + return base64encode(str); +} + +var stringToBytes = function(str){ + return hexToBytes(stringToHex(str)); +} + +// Convert a ASCII string to a hex string +var stringToHex = function(str) { + return str.split("").map(function(c) { + return ("0" + c.charCodeAt(0).toString(16)).slice(-2); + }).join(""); +} + +var hexToBytes= function(hex) { + for (var bytes = [], c = 0; c < hex.length; c += 2) + bytes.push(parseInt(hex.substr(c, 2), 16)); + return bytes; +} + +// Convert a hex string to a ASCII string +var hexToString = function(hexStr) { + var hex = hexStr.toString();//force conversion + var str = ''; + for (var i = 0; i < hex.length; i += 2) + str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); + return str; +} + +var hexToBase64 = function(hexStr){ + return HexToBase64(hexStr); +} + +var base64ToString = function(base64str){ + return base64decode(base64str); +} + + function encodeUtf8(text) { const code = encodeURIComponent(text); const bytes = []; @@ -546,6 +567,10 @@ if ( module ) { utf8ToBase64, base64ToUtf8, utf8ToHex, - hexToUtf8 + hexToUtf8, + formatBytes } } + + + diff --git a/kit/src/util/osutil.js b/kit/src/util/osutil.js index eea5a88..9ffdd2d 100644 --- a/kit/src/util/osutil.js +++ b/kit/src/util/osutil.js @@ -1,51 +1,51 @@ -const os = require('os'); -const fs = require("fs"); -const Windows = "Windows"; -const Linux = "Linux"; - -module.exports = { - - Windows, Linux, - - /** - * 根据 os 不同,载入不同的方法 - */ - choise : function ( cbs ) { - if (os.type() === 'Windows_NT') { - // windows平台 - return cbs && cbs[ Windows ] - } - else if (os.type() === 'Linux') { - // Linux平台 - return cbs && cbs[ Linux ] - } - else { - throw { message : "不支持的 OS" } - } - }, - - cur : function () { - let isLinux = false; - // 操作系统不同,安装方式不同 - let curOS = os.type() - if ( curOS === "Windows_NT" ) { - curOS = "Windows" - } - else if ( curOS === "Linux" ) { - isLinux = true; - const fs = require('fs'); - if( fs.existsSync('/etc/alpine-release') ){ - curOS = "Alpine" - } - } - - let curPlatform = os.arch() - if ( curPlatform === "x64" ) { - curPlatform = "X86_64" - } else if ( curPlatform.startsWith("arm") ) { - curPlatform = "ARM64" - } - - return { isLinux, curOS, curPlatform } - } +const os = require('os'); +const fs = require("fs"); +const Windows = "Windows"; +const Linux = "Linux"; + +module.exports = { + + Windows, Linux, + + /** + * 根据 os 不同,载入不同的方法 + */ + choise : function ( cbs ) { + if (os.type() === 'Windows_NT') { + // windows平台 + return cbs && cbs[ Windows ] + } + else if (os.type() === 'Linux') { + // Linux平台 + return cbs && cbs[ Linux ] + } + else { + throw { message : "不支持的 OS" } + } + }, + + cur : function () { + let isLinux = false; + // 操作系统不同,安装方式不同 + let curOS = os.type() + if ( curOS === "Windows_NT" ) { + curOS = "Windows" + } + else if ( curOS === "Linux" ) { + isLinux = true; + const fs = require('fs'); + if( fs.existsSync('/etc/alpine-release') ){ + curOS = "Alpine" + } + } + + let curPlatform = os.arch() + if ( curPlatform === "x64" ) { + curPlatform = "X86_64" + } else if ( curPlatform.startsWith("arm") ) { + curPlatform = "ARM64" + } + + return { isLinux, curOS, curPlatform } + } } \ No newline at end of file diff --git a/kit/test/kit b/kit/test/kit new file mode 100644 index 0000000..ecb085f Binary files /dev/null and b/kit/test/kit differ diff --git a/kit/test/net_test.js b/kit/test/net_test.js index 45ce4f1..2fdd467 100644 --- a/kit/test/net_test.js +++ b/kit/test/net_test.js @@ -1,4 +1,4 @@ -const net = require(__dirname + "/../src/net") - -net.killport(6667); - +const net = require(__dirname + "/../src/net") + +net.killport(6667); + diff --git a/kit/test/webdav_test.js b/kit/test/webdav_test.js index 26670a5..b3761ba 100644 --- a/kit/test/webdav_test.js +++ b/kit/test/webdav_test.js @@ -1,7 +1,56 @@ const fs = require("fs"); -const { pipeline } = require('node:stream/promises'); +const { Transform } = require('stream'); +const { pipeline } = require('node:stream/promises'); +const paths = require('path'); +function convertBytes(bytes) { + if (bytes >= 1024 * 1024 * 1024) { + const gigabytes = bytes / (1024 * 1024 * 1024); + return `${gigabytes.toFixed(2)}GB`; + } else if (bytes >= 1024 * 1024) { + const megabytes = bytes / (1024 * 1024); + return `${megabytes.toFixed(2)}MB`; + } else if (bytes >= 1024 ) { + const megabytes = bytes / (1024 ); + return `${megabytes.toFixed(2)}KB`; + } else { + return `${bytes} B`; + } +} + +// 创建一个用于统计字节数的Transform流 +class ByteCounter extends Transform { + constructor(totalSize) { + super(); + this.bytesCount = 0; + this.totalSize = totalSize; + this.timestamp = (new Date()).getTime() + this.recordBytesCount = 0; + this.speed = 0; + this.intervalId = setInterval(()=>{ + let now = (new Date()).getTime() + let timecost = now - this.timestamp; + this.speed = ((this.bytesCount - this.recordBytesCount ) * 1000 / timecost).toFixed(2) + this.timestamp = now; + this.recordBytesCount = this.bytesCount; + }, 2000); + + } + _transform(chunk, encoding, callback) { + this.bytesCount += chunk.length; + let process = (this.bytesCount * 100 / this.totalSize).toFixed(2) + console.log(`进度 ${process}%\t速度${ convertBytes(this.speed) }/s\t${convertBytes(this.bytesCount)} / ${convertBytes(this.totalSize)}`); + callback(null, chunk); + } + _flush(callback) { + if (this.intervalId) { + clearInterval(this.intervalId); + } + callback(); + } +} + async function wUpload(client , from, to){ const totalSize = fs.statSync(from).size; const rs = fs.createReadStream( from ); @@ -22,33 +71,53 @@ async function wUpload(client , from, to){ return pipeline( rs, ws ); } +/** + * 文件不存在会抛出异常 + * @param client + * @param file + * @param to + * @returns {Promise} + */ +async function wDownload(client, file, to){ + // 确认文件存在以及大小 + let stat = await client.stat(file); + let totalSize = stat.size; + + if ( ! to ) { + to = paths.basename(file); + } + const byteCounter = new ByteCounter(totalSize); + await pipeline( + client.createReadStream(file), + byteCounter, + fs.createWriteStream(to) + ); + await pipeline(rs , ws ); +} + async function main(){ const webdav = await import("webdav"); - const client = webdav.createClient( - "http://baishe.fullstack.club:5244/dav", - { - username: "cheney", - password: "722V587" - } - ); // const client = webdav.createClient( - // "http://172.16.17.230:5244/dav", + // "http://baishe.fullstack.club:5244/dav", // { - // username: "kit", - // password: "kitkit" + // username: "cheney", + // password: "722V587" // } // ); + const client = webdav.createClient( + "http://172.16.18.45:5244/dav", + { + username: "kit", + password: "kitkit" + } + ); // Get directory contents const directoryItems = await client.getDirectoryContents("/"); console.log(directoryItems) - // await pipeline( - // client.createReadStream( - // "/index.json" - // ), - // fs.createWriteStream("./xxx.json") - // ); + // 下载测试 + await wDownload(client, "/kit") // let rs = fs.createReadStream("D:\\fullstack\\TDevOps\\kit\\dist\\windows\\kit.exe") // rs.on("data", (r)=>{ @@ -64,10 +133,10 @@ async function main(){ // ws.on("data", (r)=>{ // console.log("w", r.length) // }) - // await pipeline(rs , ws ); + // console.log("end") - await wUpload( client, "./kit", "/kit" ) + // await wUpload( client, "./kit", "/kit" ) // await wUpload( client, "../dist/windows/kit.exe", "/modules/kit/0.1.20240227094429/Windows/X86_64/kit.exe" ) console.log("over") } diff --git a/kit/~/.kit/logs/kit.2024-09-02.log b/kit/~/.kit/logs/kit.2024-09-02.log deleted file mode 100644 index f05665e..0000000 --- a/kit/~/.kit/logs/kit.2024-09-02.log +++ /dev/null @@ -1,7 +0,0 @@ -[2024-09-02T17:10:24.971] [INFO] default - 执行命令 checkip -[2024-09-02T17:10:25.242] [INFO] default - ip : 61.164.40.82 -[2024-09-02T17:10:25.243] [INFO] default - location : 中国 浙江 杭州 电信 -[2024-09-02T17:10:25.244] [INFO] default - -61.164.40.82 -[2024-09-02T17:32:08.694] [INFO] default - 执行命令 freem -[2024-09-02T17:32:22.663] [INFO] default - 执行命令 freem