From 6bb3a58af72a838551da6b80fe547aaf5bec7991 Mon Sep 17 00:00:00 2001 From: Cris Stringfellow <22254235+crislin2046@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:30:57 +0800 Subject: [PATCH] ok --- package-lock.json | 214 ++++++++++++++++++++++-------------------- scripts/build_only.sh | 3 +- src/app.js | 58 +++++++++--- src/common.js | 2 + 4 files changed, 159 insertions(+), 118 deletions(-) diff --git a/package-lock.json b/package-lock.json index 447b38f..69fc3c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "ws": "latest" }, "bin": { - "downloadnet": "global-run.cjs" + "dn": "global-run.cjs" }, "devDependencies": { "@eslint/js": "latest", @@ -552,9 +552,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.8.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.8.0.tgz", - "integrity": "sha512-MfluB7EUfxXtv3i/++oh89uzAr4PDI4nn201hsp+qaXqsjAWzinlZEHEfPgAX4doIlKvPG/i0A9dpKxOLII8yA==", + "version": "9.9.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.9.0.tgz", + "integrity": "sha512-hhetes6ZHP3BlXLxmd8K2SNgkhNSi+UcecbnwWKwpP7kyi/uC75DJ1lOOBO3xrC4jyojtGE3YxKZPHfk4yrgug==", "dev": true, "license": "MIT", "engines": { @@ -600,14 +600,14 @@ } }, "node_modules/@inquirer/checkbox": { - "version": "2.4.5", - "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-2.4.5.tgz", - "integrity": "sha512-+YlCyS6JBWeZugIvReh/YL5HJcowlklz5RykQuYKQfgWQeCJh5Us0nWcRddvIVkjmYa0I/8bwWioSLu850J8sA==", + "version": "2.4.7", + "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-2.4.7.tgz", + "integrity": "sha512-5YwCySyV1UEgqzz34gNsC38eKxRBtlRDpJLlKcRtTjlYA/yDKuc1rfw+hjw+2WJxbAZtaDPsRl5Zk7J14SBoBw==", "license": "MIT", "dependencies": { - "@inquirer/core": "^9.0.8", + "@inquirer/core": "^9.0.10", "@inquirer/figures": "^1.0.5", - "@inquirer/type": "^1.5.1", + "@inquirer/type": "^1.5.2", "ansi-escapes": "^4.3.2", "yoctocolors-cjs": "^2.1.2" }, @@ -616,28 +616,28 @@ } }, "node_modules/@inquirer/confirm": { - "version": "3.1.20", - "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-3.1.20.tgz", - "integrity": "sha512-UvG5Plh0MfCqUvZB8RKzBBEWB/EeMzO59Awy/Jg4NgeSjIPqhPaQFnnmxiyWUTwZh4uENB7wCklEFUwckioXWg==", + "version": "3.1.22", + "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-3.1.22.tgz", + "integrity": "sha512-gsAKIOWBm2Q87CDfs9fEo7wJT3fwWIJfnDGMn9Qy74gBnNFOACDNfhUzovubbJjWnKLGBln7/NcSmZwj5DuEXg==", "license": "MIT", "dependencies": { - "@inquirer/core": "^9.0.8", - "@inquirer/type": "^1.5.1" + "@inquirer/core": "^9.0.10", + "@inquirer/type": "^1.5.2" }, "engines": { "node": ">=18" } }, "node_modules/@inquirer/core": { - "version": "9.0.8", - "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-9.0.8.tgz", - "integrity": "sha512-ttnI/BGlP9SxjbQnv1nssv7dPAwiR82KmjJZx2SxSZyi2mGbaEvh4jg0I4yU/4mVQf7QvCVGGr/hGuJFEYhwnw==", + "version": "9.0.10", + "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-9.0.10.tgz", + "integrity": "sha512-TdESOKSVwf6+YWDz8GhS6nKscwzkIyakEzCLJ5Vh6O3Co2ClhCJ0A4MG909MUWfaWdpJm7DE45ii51/2Kat9tA==", "license": "MIT", "dependencies": { "@inquirer/figures": "^1.0.5", - "@inquirer/type": "^1.5.1", + "@inquirer/type": "^1.5.2", "@types/mute-stream": "^0.0.4", - "@types/node": "^22.0.0", + "@types/node": "^22.1.0", "@types/wrap-ansi": "^3.0.0", "ansi-escapes": "^4.3.2", "cli-spinners": "^2.9.2", @@ -653,13 +653,13 @@ } }, "node_modules/@inquirer/editor": { - "version": "2.1.20", - "resolved": "https://registry.npmjs.org/@inquirer/editor/-/editor-2.1.20.tgz", - "integrity": "sha512-vtIN9NwXldX8SWbPt5biJhnTpHJCzF5nSymcv4hcOxiCrOpXmgOvFYGpAY729KODF+5e1OLqPbJ8ApiwPu/peQ==", + "version": "2.1.22", + "resolved": "https://registry.npmjs.org/@inquirer/editor/-/editor-2.1.22.tgz", + "integrity": "sha512-K1QwTu7GCK+nKOVRBp5HY9jt3DXOfPGPr6WRDrPImkcJRelG9UTx2cAtK1liXmibRrzJlTWOwqgWT3k2XnS62w==", "license": "MIT", "dependencies": { - "@inquirer/core": "^9.0.8", - "@inquirer/type": "^1.5.1", + "@inquirer/core": "^9.0.10", + "@inquirer/type": "^1.5.2", "external-editor": "^3.1.0" }, "engines": { @@ -667,13 +667,13 @@ } }, "node_modules/@inquirer/expand": { - "version": "2.1.20", - "resolved": "https://registry.npmjs.org/@inquirer/expand/-/expand-2.1.20.tgz", - "integrity": "sha512-ruUTCUGKhe6TvDM3/gKjX9v7D5cWbiuawFE6aF/cFmNO79R/zMjrFFVoueDM8FRw8yXqnREb0jFkYF1LUxnDNA==", + "version": "2.1.22", + "resolved": "https://registry.npmjs.org/@inquirer/expand/-/expand-2.1.22.tgz", + "integrity": "sha512-wTZOBkzH+ItPuZ3ZPa9lynBsdMp6kQ9zbjVPYEtSBG7UulGjg2kQiAnUjgyG4SlntpTce5bOmXAPvE4sguXjpA==", "license": "MIT", "dependencies": { - "@inquirer/core": "^9.0.8", - "@inquirer/type": "^1.5.1", + "@inquirer/core": "^9.0.10", + "@inquirer/type": "^1.5.2", "yoctocolors-cjs": "^2.1.2" }, "engines": { @@ -690,39 +690,39 @@ } }, "node_modules/@inquirer/input": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/@inquirer/input/-/input-2.2.7.tgz", - "integrity": "sha512-QFk31Gq4Wr+Ve9ilMiFGGrSjGZQBilV0cgTN1zubD98Bx65fsNrh8++Biy/9mjNKRaqHFbZBw5baAcQvOmW8OQ==", + "version": "2.2.9", + "resolved": "https://registry.npmjs.org/@inquirer/input/-/input-2.2.9.tgz", + "integrity": "sha512-7Z6N+uzkWM7+xsE+3rJdhdG/+mQgejOVqspoW+w0AbSZnL6nq5tGMEVASaYVWbkoSzecABWwmludO2evU3d31g==", "license": "MIT", "dependencies": { - "@inquirer/core": "^9.0.8", - "@inquirer/type": "^1.5.1" + "@inquirer/core": "^9.0.10", + "@inquirer/type": "^1.5.2" }, "engines": { "node": ">=18" } }, "node_modules/@inquirer/number": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@inquirer/number/-/number-1.0.8.tgz", - "integrity": "sha512-GamytM0a3fLh8xjgWbGb/DmDA1SmW6sc6ZyfiiWL1my2NAkV6mrTEKMOA4LSK2gB43uf8vcOS7Hp/LeVjIqLwg==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@inquirer/number/-/number-1.0.10.tgz", + "integrity": "sha512-kWTxRF8zHjQOn2TJs+XttLioBih6bdc5CcosXIzZsrTY383PXI35DuhIllZKu7CdXFi2rz2BWPN9l0dPsvrQOA==", "license": "MIT", "dependencies": { - "@inquirer/core": "^9.0.8", - "@inquirer/type": "^1.5.1" + "@inquirer/core": "^9.0.10", + "@inquirer/type": "^1.5.2" }, "engines": { "node": ">=18" } }, "node_modules/@inquirer/password": { - "version": "2.1.20", - "resolved": "https://registry.npmjs.org/@inquirer/password/-/password-2.1.20.tgz", - "integrity": "sha512-il2TG7xDlfiLE3cnOCxfDfrwvsiSmXjVd26hvf4tdzHvdisgLiEjbN6mi51/TnlSQ+2Qc69+9jIq3ws93nhS2w==", + "version": "2.1.22", + "resolved": "https://registry.npmjs.org/@inquirer/password/-/password-2.1.22.tgz", + "integrity": "sha512-5Fxt1L9vh3rAKqjYwqsjU4DZsEvY/2Gll+QkqR4yEpy6wvzLxdSgFhUcxfDAOtO4BEoTreWoznC0phagwLU5Kw==", "license": "MIT", "dependencies": { - "@inquirer/core": "^9.0.8", - "@inquirer/type": "^1.5.1", + "@inquirer/core": "^9.0.10", + "@inquirer/type": "^1.5.2", "ansi-escapes": "^4.3.2" }, "engines": { @@ -730,34 +730,34 @@ } }, "node_modules/@inquirer/prompts": { - "version": "5.3.6", - "resolved": "https://registry.npmjs.org/@inquirer/prompts/-/prompts-5.3.6.tgz", - "integrity": "sha512-go5DXxasCIZvztWapYPUSFXg7GceDSQPM1ew3MahFF7degA5kfIVe5kB4KAlARXt83fApyEczvE1H4bh0HLObA==", + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/@inquirer/prompts/-/prompts-5.3.8.tgz", + "integrity": "sha512-b2BudQY/Si4Y2a0PdZZL6BeJtl8llgeZa7U2j47aaJSCeAl1e4UI7y8a9bSkO3o/ZbZrgT5muy/34JbsjfIWxA==", "license": "MIT", "dependencies": { - "@inquirer/checkbox": "^2.4.5", - "@inquirer/confirm": "^3.1.20", - "@inquirer/editor": "^2.1.20", - "@inquirer/expand": "^2.1.20", - "@inquirer/input": "^2.2.7", - "@inquirer/number": "^1.0.8", - "@inquirer/password": "^2.1.20", - "@inquirer/rawlist": "^2.2.2", - "@inquirer/search": "^1.0.5", - "@inquirer/select": "^2.4.5" + "@inquirer/checkbox": "^2.4.7", + "@inquirer/confirm": "^3.1.22", + "@inquirer/editor": "^2.1.22", + "@inquirer/expand": "^2.1.22", + "@inquirer/input": "^2.2.9", + "@inquirer/number": "^1.0.10", + "@inquirer/password": "^2.1.22", + "@inquirer/rawlist": "^2.2.4", + "@inquirer/search": "^1.0.7", + "@inquirer/select": "^2.4.7" }, "engines": { "node": ">=18" } }, "node_modules/@inquirer/rawlist": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/@inquirer/rawlist/-/rawlist-2.2.2.tgz", - "integrity": "sha512-U4OsvqjdLB6nmf5ZDshPYMq0b+qd6JWxTrvRTiMfwUY6cFxkR9YWKarLXFhndf7tawQ8f3DwU9P9wryDc2ESSA==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@inquirer/rawlist/-/rawlist-2.2.4.tgz", + "integrity": "sha512-pb6w9pWrm7EfnYDgQObOurh2d2YH07+eDo3xQBsNAM2GRhliz6wFXGi1thKQ4bN6B0xDd6C3tBsjdr3obsCl3Q==", "license": "MIT", "dependencies": { - "@inquirer/core": "^9.0.8", - "@inquirer/type": "^1.5.1", + "@inquirer/core": "^9.0.10", + "@inquirer/type": "^1.5.2", "yoctocolors-cjs": "^2.1.2" }, "engines": { @@ -765,14 +765,14 @@ } }, "node_modules/@inquirer/search": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@inquirer/search/-/search-1.0.5.tgz", - "integrity": "sha512-25nyVAbO0NwFZTXP/cW++W1QGHlHY+hmsehMM1sPKvp4wYcxMQcm6xNCor0bU2Pv/L33IkPV/NV9SuJyFC85EQ==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@inquirer/search/-/search-1.0.7.tgz", + "integrity": "sha512-p1wpV+3gd1eST/o5N3yQpYEdFNCzSP0Klrl+5bfD3cTTz8BGG6nf4Z07aBW0xjlKIj1Rp0y3x/X4cZYi6TfcLw==", "license": "MIT", "dependencies": { - "@inquirer/core": "^9.0.8", + "@inquirer/core": "^9.0.10", "@inquirer/figures": "^1.0.5", - "@inquirer/type": "^1.5.1", + "@inquirer/type": "^1.5.2", "yoctocolors-cjs": "^2.1.2" }, "engines": { @@ -780,14 +780,14 @@ } }, "node_modules/@inquirer/select": { - "version": "2.4.5", - "resolved": "https://registry.npmjs.org/@inquirer/select/-/select-2.4.5.tgz", - "integrity": "sha512-DbCthH3l7vrrK+Ewll3bgzxC3dzMle8xkWYta4if31p9NOmFNhZKhSfdYMjaOtGFBCUEwo4D5LMgN6sPKgUWIw==", + "version": "2.4.7", + "resolved": "https://registry.npmjs.org/@inquirer/select/-/select-2.4.7.tgz", + "integrity": "sha512-JH7XqPEkBpNWp3gPCqWqY8ECbyMoFcCZANlL6pV9hf59qK6dGmkOlx1ydyhY+KZ0c5X74+W6Mtp+nm2QX0/MAQ==", "license": "MIT", "dependencies": { - "@inquirer/core": "^9.0.8", + "@inquirer/core": "^9.0.10", "@inquirer/figures": "^1.0.5", - "@inquirer/type": "^1.5.1", + "@inquirer/type": "^1.5.2", "ansi-escapes": "^4.3.2", "yoctocolors-cjs": "^2.1.2" }, @@ -796,9 +796,9 @@ } }, "node_modules/@inquirer/type": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-1.5.1.tgz", - "integrity": "sha512-m3YgGQlKNS0BM+8AFiJkCsTqHEFCWn6s/Rqye3mYwvqY6LdfUv12eSwbsgNzrYyrLXiy7IrrjDLPysaSBwEfhw==", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-1.5.2.tgz", + "integrity": "sha512-w9qFkumYDCNyDZmNQjf/n6qQuvQ4dMC3BJesY4oF+yr0CxR5vxujflAVeIcS6U336uzi9GM0kAfZlLrZ9UTkpA==", "license": "MIT", "dependencies": { "mute-stream": "^1.0.0" @@ -923,12 +923,12 @@ } }, "node_modules/@types/node": { - "version": "22.0.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.2.tgz", - "integrity": "sha512-yPL6DyFwY5PiMVEwymNeqUTKsDczQBJ/5T7W/46RwLU/VH+AA8aT5TZkvBviLKLbbm0hlfftEkGrNzfRk/fofQ==", + "version": "22.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz", + "integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==", "license": "MIT", "dependencies": { - "undici-types": "~6.11.1" + "undici-types": "~6.19.2" } }, "node_modules/@types/webidl-conversions": { @@ -1597,9 +1597,9 @@ } }, "node_modules/eslint": { - "version": "9.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.8.0.tgz", - "integrity": "sha512-K8qnZ/QJzT2dLKdZJVX6W4XOwBzutMYmt0lqUS+JdXgd+HTYFlonFgkJ8s44d/zMPPCnOOk0kMWCApCPhiOy9A==", + "version": "9.9.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.9.0.tgz", + "integrity": "sha512-JfiKJrbx0506OEerjK2Y1QlldtBxkAlLxT5OEcRF8uaQ86noDe2k31Vw9rnSWv+MXZHj7OOUV/dA0AhdLFcyvA==", "dev": true, "license": "MIT", "dependencies": { @@ -1607,7 +1607,7 @@ "@eslint-community/regexpp": "^4.11.0", "@eslint/config-array": "^0.17.1", "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "9.8.0", + "@eslint/js": "9.9.0", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.3.0", "@nodelib/fs.walk": "^1.2.8", @@ -1646,6 +1646,14 @@ }, "funding": { "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } } }, "node_modules/eslint-scope": { @@ -2088,9 +2096,9 @@ } }, "node_modules/globals": { - "version": "15.8.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-15.8.0.tgz", - "integrity": "sha512-VZAJ4cewHTExBWDHR6yptdIBlx9YSSZuwojj9Nt5mBRXQzrKakDsVKQ1J63sklLvzAJm0X5+RpO4i3Y2hcOnFw==", + "version": "15.9.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.9.0.tgz", + "integrity": "sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA==", "dev": true, "license": "MIT", "engines": { @@ -2260,9 +2268,9 @@ } }, "node_modules/ignore": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", - "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true, "license": "MIT", "engines": { @@ -2303,13 +2311,13 @@ "license": "ISC" }, "node_modules/inquirer": { - "version": "10.1.6", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-10.1.6.tgz", - "integrity": "sha512-TDqkT2B9MpzzsuJYi139mJDmhRwE9iJejdIy4hWIDmBkmkg8aKB0O4F2/Dz1Zex77zyqm9GrYK1xFhlD6yn4zg==", + "version": "10.1.8", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-10.1.8.tgz", + "integrity": "sha512-syxGpOzLyqVeZi1KDBjRTnCn5PiGWySGHP0BbqXbqsEK0ckkZk3egAepEWslUjZXj0rhkUapVXM/IpADWe4D6w==", "license": "MIT", "dependencies": { - "@inquirer/prompts": "^5.3.6", - "@inquirer/type": "^1.5.1", + "@inquirer/prompts": "^5.3.8", + "@inquirer/type": "^1.5.2", "@types/mute-stream": "^0.0.4", "ansi-escapes": "^4.3.2", "mute-stream": "^1.0.0", @@ -2695,9 +2703,9 @@ } }, "node_modules/mongoose": { - "version": "8.5.2", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.5.2.tgz", - "integrity": "sha512-GZB4rHMdYfGatV+23IpCrqFbyCOjCNOHXgWbirr92KRwTEncBrtW3kgU9vmpKjsGf7nMmnAy06SwWUv1vhDkSg==", + "version": "8.5.3", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.5.3.tgz", + "integrity": "sha512-OubSDbsAclDFGHjV82MsKyIGQWFc42Ot1l+0dhRS6U9xODM7rm/ES/WpOQd8Ds9j0Mx8QzxZtrSCnBh6o9wUqw==", "license": "MIT", "dependencies": { "bson": "^6.7.0", @@ -2759,9 +2767,9 @@ } }, "node_modules/natural": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/natural/-/natural-7.1.0.tgz", - "integrity": "sha512-GBhiRgF0VUX+zPWahBVir1ajARQDZF1Fe6UpQORNzyQT57JQ2KLKYvubecvjIYh/uDaociusmySeRh+WL5OdxQ==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/natural/-/natural-8.0.1.tgz", + "integrity": "sha512-VVw8O5KrfvwqAFeNZEgBbdgA+AQaBlHcXEootWU7TWDaFWFI0VLfzyKMsRjnfdS3cVCpWmI04xLJonCvEv11VQ==", "license": "MIT", "dependencies": { "afinn-165": "^1.0.2", @@ -3714,9 +3722,9 @@ "license": "MIT" }, "node_modules/undici-types": { - "version": "6.11.1", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.11.1.tgz", - "integrity": "sha512-mIDEX2ek50x0OlRgxryxsenE5XaQD4on5U2inY7RApK3SOJpofyw7uW2AyfMKkhAxXIceo2DeWGVGwyvng1GNQ==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", "license": "MIT" }, "node_modules/union": { diff --git a/scripts/build_only.sh b/scripts/build_only.sh index 3909070..c6a4353 100755 --- a/scripts/build_only.sh +++ b/scripts/build_only.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +set -x source $HOME/.nvm/nvm.sh rm -rf build @@ -32,6 +33,6 @@ if [[ "$OSTYPE" == darwin* ]]; then elif [[ "$OSTYPE" == win* ]]; then ./stampers/win.sh dn build/cjs/dn.cjs build/bin/ else - ./stampers/nix.sh build/cjs/dn.cjs build/bin/ + ./stampers/nix.sh dn build/cjs/dn.cjs build/bin/ fi diff --git a/src/app.js b/src/app.js index 72c57bd..8e12f22 100644 --- a/src/app.js +++ b/src/app.js @@ -24,6 +24,22 @@ const CHROME_OPTS = !NO_SANDBOX ? [ `--aggressive-cache-discard`, '--no-sandbox', ]; +CHROME_OPTS.push( + ...(process.env.DK_HEADLESS ? [ + `--headless` + ] : [ ]) +); +if ( process.env.DK_HEADLESS ) { + console.info(` + ============= INFO ============== + + Your browser is running in headless mode so you need to attach a display (like BrowserBox) to it, if you want to interact with it + normally. + + + ================================== + `); +} const LAUNCH_OPTS = { logLevel: DEBUG ? 'verbose' : 'silent', port: chrome_port, @@ -40,7 +56,8 @@ const KILL_ON = (browser) => ({ }); let Browser; -let quitting; +let quitting = false; +let startingArchivist = false; start(); @@ -63,26 +80,29 @@ async function start() { const list = await psList(); - const chromeOpen = list.filter(({name,cmd}) => name?.match?.(/^(chrome|google chrome)/gi) || cmd?.match?.(/[\/\\]chrome/gi)); - const vivaldiOpen = list.filter(({name,cmd}) => name?.match?.(/^vivaldi/gi) || cmd?.match?.(/[\/\\]vivaldi/gi)); - const braveOpen = list.filter(({name,cmd}) => name?.match?.(/^brave/gi) || cmd?.match?.(/[\/\\]brave/gi)); - const edgeOpen = list.filter(({name,cmd}) => name?.match?.(/^edge/gi) || cmd?.match?.(/[\/\\]edge/gi)); + DEBUG.showList && console.log({list}); + + const chromeOpen = list.find(({name,cmd}) => name?.match?.(/^(chrome|google chrome)/gi) || cmd?.match?.(/[\/\\]chrome/gi)); + const vivaldiOpen = list.find(({name,cmd}) => name?.match?.(/^vivaldi/gi) || cmd?.match?.(/[\/\\]vivaldi/gi)); + const braveOpen = list.find(({name,cmd}) => name?.match?.(/^brave/gi) || cmd?.match?.(/[\/\\]brave/gi)); + const edgeOpen = list.find(({name,cmd}) => name?.match?.(/^edge/gi) || cmd?.match?.(/[\/\\]edge/gi)); const browserOpen = chromeOpen || vivaldiOpen || braveOpen || edgeOpen; const browsers = [{chromeOpen}, {vivaldiOpen}, {braveOpen}, {edgeOpen}]; + DEBUG.showList && console.log({browserOpen, browsers}); if ( browserOpen ) { const rl = readline.createInterface({input, output}); let shutOne = false; for( const status of browsers ) { const keyName = Object.keys(status)[0]; - if ( !status[keyName] || !status[keyName].length ) continue; - console.log(status); + if ( !status[keyName] ) continue; + DEBUG.showList && console.log(status); const openBrowserCode = keyName.replace('Open', ''); Browser = openBrowserCode; - console.info(`Seems ${openBrowserCode} is open`); + console.info(`Seems ${openBrowserCode} is already open`); if ( DEBUG.askFirst ) { const question = util.promisify(rl.question).bind(rl); - console.info(`\nDo you want to use it for your archiving? The reason we ask is, because if you don't shut down ${openBrowserCode} and restart it under DownloadNet control you will not be able to use it to save or serve your archives.\n`); + console.info(`\nDo you want to use it for your archiving? The reason we ask is, because if you don't shut down ${openBrowserCode} and restart it under DownloadNet control you will not be able to use it to save or serve your archives.\n\n`); const answer = await question(`Would you like to shutdown ${openBrowserCode} browser now (y/N) ? `); if ( answer?.match(/^y/i) ) { await killBrowser(openBrowserCode); @@ -109,21 +129,31 @@ async function start() { await LibraryServer.start({server_port}); console.log(`Library server started.`); - console.log(`Waiting 1 second...`); + console.log(`Waiting 1 seconds...`); await sleep(1000); - console.log(`Launching browser...`); + let b; try { - await ChromeLaunch(LAUNCH_OPTS); + b = await ChromeLaunch(LAUNCH_OPTS); } catch(e) { console.log(`Could not launch browser.`); DEBUG.verboseSlow && console.info('Chrome launch error:', e); process.exit(1); } + b.on('exit', async err => { + console.log('Browser shutting down. Will exit...'); + if ( ! startingArchivist ) { + console.info(`===========INFO===========\n\nLooks like this shutdown happened pretty quickly. Could be because you are running from a terminal without a display?\nIn that case you'll need to connect BrowserBox and run your DownloadNet/DiskerNet/Archivist browser with the headless flag by specifying the environment variable\n\n\t\t"export DK_HEADLESS=true"\n\nAnd also ensure you download BrowserBox and set it up correctly to attach to this headless browser.\n\n==========FIN==============\n`); + } + await cleanup('Browser exited', err, {exit:true}); + }); + console.log(`Browser started.`); + console.log(`Waiting 2 seconds...`); + await sleep(2000); - console.log(`Waiting 1 second...`); - await sleep(1000); + if ( quitting ) return; + startingArchivist = true; console.log(`Launching archivist and connecting to browser...`); await Archivist.collect({chrome_port, mode}); console.log(`System ready.`); diff --git a/src/common.js b/src/common.js index f831577..449183e 100644 --- a/src/common.js +++ b/src/common.js @@ -7,6 +7,8 @@ import {APP_ROOT as __ROOT} from './root.js'; const DEEB = false; export const DEBUG = { + showList: false, + showStatus: false, debugSec: false, askFirst: true, verboseSlow: process.env.VERBOSE_DEBUG_22120 || DEEB,