diff --git a/.eslintrc b/.eslintrc
index 09c2e42..14fdb4b 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,3 +1,6 @@
{
- "extends": "@antfu"
+ "extends": "@antfu",
+ "rules": {
+ "no-cond-assign": "off"
+ }
}
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
deleted file mode 100644
index b7e0ede..0000000
--- a/.github/FUNDING.yml
+++ /dev/null
@@ -1 +0,0 @@
-github: [antfu]
diff --git a/README.md b/README.md
index f92f3c1..6f2ad8a 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,42 @@
-# ext-name
+# Tree Log
-
+
-## Sponsors
+
-
-
-
-
-
+
-## License
-[MIT](./LICENSE) License © 2022 [Anthony Fu](https://github.com/antfu)
+
+A plugin that automatically generates console.log statements in tree format. The default tree header is a random emoji, which can be customized.
+
+
+
+![shot](res/shot.png)
+
+
+
+## Features
+
+
+
+![shot](res/shot.gif)
+
+
+
+You can select the variable and use the shortcut key `alt`+`c` to automatically generate the console statement, or use `ctrl`+`alt`+`c` to delete the console statement of the file.
+
+You can also use the `Command Palette`, search for `Add Tree Log` to generate them, and `Delete Tree Log` to delete.
+
+Of course, you can also right-click and select `Tree Log` to operate it after selecting the variable.
+
+
+
+## Settings
+
+You can customize the tree head by adding text to settings.json (Command Palette -> Preferences: Open Settings (JSON))
+
+For example:
+
+* `tree-log.suffix`: "a custom text"
+
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b72b8e4..7886a20 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1,4 +1,4 @@
-lockfileVersion: '6.1'
+lockfileVersion: '6.0'
settings:
autoInstallPeers: true
@@ -787,6 +787,7 @@ packages:
/ansi-regex@2.1.1:
resolution: {integrity: sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==}
engines: {node: '>=0.10.0'}
+ requiresBuild: true
dev: true
optional: true
@@ -838,11 +839,13 @@ packages:
/aproba@1.2.0:
resolution: {integrity: sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==}
+ requiresBuild: true
dev: true
optional: true
/are-we-there-yet@1.1.7:
resolution: {integrity: sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==}
+ requiresBuild: true
dependencies:
delegates: 1.0.0
readable-stream: 2.3.7
@@ -918,6 +921,7 @@ packages:
/base64-js@1.5.1:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
+ requiresBuild: true
dev: true
optional: true
@@ -928,6 +932,7 @@ packages:
/bl@4.1.0:
resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==}
+ requiresBuild: true
dependencies:
buffer: 5.7.1
inherits: 2.0.4
@@ -973,6 +978,7 @@ packages:
/buffer@5.7.1:
resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==}
+ requiresBuild: true
dependencies:
base64-js: 1.5.1
ieee754: 1.2.1
@@ -1137,6 +1143,7 @@ packages:
/chownr@1.1.4:
resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==}
+ requiresBuild: true
dev: true
optional: true
@@ -1160,6 +1167,7 @@ packages:
/code-point-at@1.1.0:
resolution: {integrity: sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==}
engines: {node: '>=0.10.0'}
+ requiresBuild: true
dev: true
optional: true
@@ -1218,11 +1226,13 @@ packages:
/console-control-strings@1.1.0:
resolution: {integrity: sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==}
+ requiresBuild: true
dev: true
optional: true
/core-util-is@1.0.3:
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
+ requiresBuild: true
dev: true
optional: true
@@ -1289,6 +1299,7 @@ packages:
/decompress-response@6.0.0:
resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==}
engines: {node: '>=10'}
+ requiresBuild: true
dependencies:
mimic-response: 3.1.0
dev: true
@@ -1304,6 +1315,7 @@ packages:
/deep-extend@0.6.0:
resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==}
engines: {node: '>=4.0.0'}
+ requiresBuild: true
dev: true
optional: true
@@ -1325,6 +1337,7 @@ packages:
/delegates@1.0.0:
resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==}
+ requiresBuild: true
dev: true
optional: true
@@ -1335,6 +1348,7 @@ packages:
/detect-libc@2.0.1:
resolution: {integrity: sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==}
engines: {node: '>=8'}
+ requiresBuild: true
dev: true
optional: true
@@ -1420,6 +1434,7 @@ packages:
/emoji-regex@8.0.0:
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
+ requiresBuild: true
dev: true
/emoji-regex@9.2.2:
@@ -1428,6 +1443,7 @@ packages:
/end-of-stream@1.4.4:
resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==}
+ requiresBuild: true
dependencies:
once: 1.4.0
dev: true
@@ -2160,6 +2176,7 @@ packages:
/expand-template@2.0.3:
resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==}
engines: {node: '>=6'}
+ requiresBuild: true
dev: true
optional: true
@@ -2265,6 +2282,7 @@ packages:
/fs-constants@1.0.0:
resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==}
+ requiresBuild: true
dev: true
optional: true
@@ -2307,6 +2325,7 @@ packages:
/gauge@2.7.4:
resolution: {integrity: sha512-14x4kjc6lkD3ltw589k0NrPD6cCNTD6CWoVUNpB85+DrtONoZn+Rug6xZU5RvSC4+TZPxA5AnBibQYAvZn41Hg==}
+ requiresBuild: true
dependencies:
aproba: 1.2.0
console-control-strings: 1.1.0
@@ -2365,6 +2384,7 @@ packages:
/github-from-package@0.0.0:
resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==}
+ requiresBuild: true
dev: true
optional: true
@@ -2484,6 +2504,7 @@ packages:
/has-unicode@2.0.1:
resolution: {integrity: sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==}
+ requiresBuild: true
dev: true
optional: true
@@ -2540,6 +2561,7 @@ packages:
/ieee754@1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
+ requiresBuild: true
dev: true
optional: true
@@ -2579,6 +2601,7 @@ packages:
/ini@1.3.8:
resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==}
+ requiresBuild: true
dev: true
optional: true
@@ -2667,6 +2690,7 @@ packages:
/is-fullwidth-code-point@1.0.0:
resolution: {integrity: sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==}
engines: {node: '>=0.10.0'}
+ requiresBuild: true
dependencies:
number-is-nan: 1.0.1
dev: true
@@ -2675,6 +2699,7 @@ packages:
/is-fullwidth-code-point@3.0.0:
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
engines: {node: '>=8'}
+ requiresBuild: true
dev: true
/is-glob@4.0.3:
@@ -2760,6 +2785,7 @@ packages:
/isarray@1.0.0:
resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==}
+ requiresBuild: true
dev: true
optional: true
@@ -3027,6 +3053,7 @@ packages:
/mimic-response@3.1.0:
resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==}
engines: {node: '>=10'}
+ requiresBuild: true
dev: true
optional: true
@@ -3079,6 +3106,7 @@ packages:
/mkdirp-classic@0.5.3:
resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
+ requiresBuild: true
dev: true
optional: true
@@ -3126,6 +3154,7 @@ packages:
/napi-build-utils@1.0.2:
resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==}
+ requiresBuild: true
dev: true
optional: true
@@ -3140,6 +3169,7 @@ packages:
/node-abi@3.8.0:
resolution: {integrity: sha512-tzua9qWWi7iW4I42vUPKM+SfaF0vQSLAm4yO5J83mSwB7GeoWrDKC/K+8YCnYNwqP5duwazbw2X9l4m8SC2cUw==}
engines: {node: '>=10'}
+ requiresBuild: true
dependencies:
semver: 7.5.1
dev: true
@@ -3147,6 +3177,7 @@ packages:
/node-addon-api@4.3.0:
resolution: {integrity: sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==}
+ requiresBuild: true
dev: true
optional: true
@@ -3177,6 +3208,7 @@ packages:
/npmlog@4.1.2:
resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==}
+ requiresBuild: true
dependencies:
are-we-there-yet: 1.1.7
console-control-strings: 1.1.0
@@ -3194,6 +3226,7 @@ packages:
/number-is-nan@1.0.1:
resolution: {integrity: sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==}
engines: {node: '>=0.10.0'}
+ requiresBuild: true
dev: true
optional: true
@@ -3450,6 +3483,7 @@ packages:
resolution: {integrity: sha512-QBSab31WqkyxpnMWQxubYAHR5S9B2+r81ucocew34Fkl98FhvKIF50jIJnNOBmAZfyNV7vE5T6gd3hTVWgY6tg==}
engines: {node: '>=10'}
hasBin: true
+ requiresBuild: true
dependencies:
detect-libc: 2.0.1
expand-template: 2.0.3
@@ -3483,6 +3517,7 @@ packages:
/process-nextick-args@2.0.1:
resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
+ requiresBuild: true
dev: true
optional: true
@@ -3496,6 +3531,7 @@ packages:
/pump@3.0.0:
resolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==}
+ requiresBuild: true
dependencies:
end-of-stream: 1.4.4
once: 1.4.0
@@ -3529,6 +3565,7 @@ packages:
/rc@1.2.8:
resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==}
hasBin: true
+ requiresBuild: true
dependencies:
deep-extend: 0.6.0
ini: 1.3.8
@@ -3569,6 +3606,7 @@ packages:
/readable-stream@2.3.7:
resolution: {integrity: sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==}
+ requiresBuild: true
dependencies:
core-util-is: 1.0.3
inherits: 2.0.4
@@ -3583,6 +3621,7 @@ packages:
/readable-stream@3.6.0:
resolution: {integrity: sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==}
engines: {node: '>= 6'}
+ requiresBuild: true
dependencies:
inherits: 2.0.4
string_decoder: 1.3.0
@@ -3673,11 +3712,13 @@ packages:
/safe-buffer@5.1.2:
resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==}
+ requiresBuild: true
dev: true
optional: true
/safe-buffer@5.2.1:
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
+ requiresBuild: true
dev: true
optional: true
@@ -3719,6 +3760,7 @@ packages:
/set-blocking@2.0.0:
resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==}
+ requiresBuild: true
dev: true
optional: true
@@ -3757,11 +3799,13 @@ packages:
/simple-concat@1.0.1:
resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==}
+ requiresBuild: true
dev: true
optional: true
/simple-get@4.0.1:
resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==}
+ requiresBuild: true
dependencies:
decompress-response: 6.0.0
once: 1.4.0
@@ -3840,6 +3884,7 @@ packages:
/string-width@1.0.2:
resolution: {integrity: sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==}
engines: {node: '>=0.10.0'}
+ requiresBuild: true
dependencies:
code-point-at: 1.1.0
is-fullwidth-code-point: 1.0.0
@@ -3892,6 +3937,7 @@ packages:
/string_decoder@1.1.1:
resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==}
+ requiresBuild: true
dependencies:
safe-buffer: 5.1.2
dev: true
@@ -3899,6 +3945,7 @@ packages:
/string_decoder@1.3.0:
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
+ requiresBuild: true
dependencies:
safe-buffer: 5.2.1
dev: true
@@ -3907,6 +3954,7 @@ packages:
/strip-ansi@3.0.1:
resolution: {integrity: sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==}
engines: {node: '>=0.10.0'}
+ requiresBuild: true
dependencies:
ansi-regex: 2.1.1
dev: true
@@ -3946,6 +3994,7 @@ packages:
/strip-json-comments@2.0.1:
resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==}
engines: {node: '>=0.10.0'}
+ requiresBuild: true
dev: true
optional: true
@@ -3994,6 +4043,7 @@ packages:
/tar-fs@2.1.1:
resolution: {integrity: sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==}
+ requiresBuild: true
dependencies:
chownr: 1.1.4
mkdirp-classic: 0.5.3
@@ -4005,6 +4055,7 @@ packages:
/tar-stream@2.2.0:
resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==}
engines: {node: '>=6'}
+ requiresBuild: true
dependencies:
bl: 4.1.0
end-of-stream: 1.4.4
@@ -4167,6 +4218,7 @@ packages:
/tunnel-agent@0.6.0:
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
+ requiresBuild: true
dependencies:
safe-buffer: 5.2.1
dev: true
@@ -4470,6 +4522,7 @@ packages:
/wide-align@1.1.5:
resolution: {integrity: sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==}
+ requiresBuild: true
dependencies:
string-width: 4.2.3
dev: true
diff --git a/res/icon.png b/res/icon.png
new file mode 100644
index 0000000..da87972
Binary files /dev/null and b/res/icon.png differ
diff --git a/res/shot.gif b/res/shot.gif
new file mode 100644
index 0000000..ac28956
Binary files /dev/null and b/res/shot.gif differ
diff --git a/res/shot.png b/res/shot.png
new file mode 100644
index 0000000..46cef7c
Binary files /dev/null and b/res/shot.png differ
diff --git a/src/core.ts b/src/core.ts
new file mode 100644
index 0000000..8d017f7
--- /dev/null
+++ b/src/core.ts
@@ -0,0 +1,60 @@
+import * as vscode from 'vscode'
+import { getRandomEmoji } from './util'
+
+const editor = vscode.window.activeTextEditor
+
+export function addLog() {
+ if (!editor)
+ return
+
+ const textArray: string[] = []
+ const selectRanges = editor.selections
+ selectRanges.forEach((range) => {
+ let text = editor.document.getText(range)
+ let insertText = 'console.log('
+ if (text) {
+ text = text.replace(/'/g, '"')
+ const suffix = vscode.workspace.getConfiguration().get('tree-log.suffix')
+ const emoji = getRandomEmoji()
+ insertText = `console.log(' ${suffix || emoji}', '\\n', '├──', '${text}', '\\n', '└──', ${text}, '\\n')`
+ }
+ textArray.push(insertText)
+ })
+
+ vscode.commands.executeCommand('editor.action.insertLineAfter')
+ .then(() => {
+ const ranges = editor.selections
+ const positionList: vscode.Position[] = []
+ ranges.forEach((range) => {
+ const position = new vscode.Position(range.start.line, range.start.character)
+ positionList.push(position)
+ })
+ editor.edit((editBuilder) => {
+ positionList.forEach((position, index) => {
+ editBuilder.insert(position, textArray[index])
+ })
+ })
+ })
+}
+
+export function deleteLog() {
+ const logRegex = /(console.(log|debug|info|warn|error|assert|dir|dirxml|trace|group|groupEnd|time|timeEnd|profile|profileEnd|count)\((.*)\)| log\((.*)\));?/g
+ if (!editor)
+ return
+
+ const document = editor.document
+ const documentText = document.getText()
+ const Ranges: vscode.Range[] = []
+
+ let match
+ while (match = logRegex.exec(documentText)) {
+ const matchRange = new vscode.Range(document.positionAt(match.index), document.positionAt(match.index + match[0].length))
+ if (!matchRange.isEmpty)
+ Ranges.push(matchRange)
+ }
+ editor.edit((editBuilder) => {
+ Ranges.forEach((range, index) => {
+ editBuilder.delete(Ranges[index])
+ })
+ })
+}
diff --git a/src/index.ts b/src/index.ts
index 080658a..dccb175 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,7 +1,13 @@
-import { window } from 'vscode'
+import type { ExtensionContext } from 'vscode'
+import { commands } from 'vscode'
+import { addLog, deleteLog } from './core'
-export function activate() {
- window.showInformationMessage('Hello')
+export function activate(context: ExtensionContext) {
+ const addlog = commands.registerCommand('tree-log.addLog', addLog)
+ context.subscriptions.push(addlog)
+
+ const deletelog = commands.registerCommand('tree-log.deleteLog', deleteLog)
+ context.subscriptions.push(deletelog)
}
export function deactivate() {
diff --git a/src/util.ts b/src/util.ts
new file mode 100644
index 0000000..55ca44f
--- /dev/null
+++ b/src/util.ts
@@ -0,0 +1,1054 @@
+const emoji = [
+ '🤡',
+ '👹',
+ '👺',
+ '👻',
+ '👽',
+ '👾',
+ '🤖',
+ '😺',
+ '😸',
+ '😹',
+ '😻',
+ '😼',
+ '😽',
+ '🙀',
+ '😿',
+ '😾',
+ '🙈',
+ '🙉',
+ '🙊',
+ '💋',
+ '💌',
+ '💘',
+ '💝',
+ '💖',
+ '💗',
+ '💓',
+ '💞',
+ '💕',
+ '💟',
+ '❣️',
+ '💔',
+ '❤️',
+ '🧡',
+ '💛',
+ '💚',
+ '💙',
+ '💜',
+ '🤎',
+ '🖤',
+ '🤍',
+ '💯',
+ '💢',
+ '💥',
+ '💫',
+ '💦',
+ '💨',
+ '🕳️',
+ '💣',
+ '💬',
+ '👁️🗨️',
+ '🗨️',
+ '🗯️',
+ '💭',
+ '💤',
+ '👋',
+ '🤚',
+ '🖐️',
+ '🖐🏻',
+ '🖐🏼',
+ '🖐🏽',
+ '🖐🏾',
+ '🖐🏿',
+ '✋',
+ '🖖',
+ '👌',
+ '🤌',
+ '🤏',
+ '✌️',
+ '✌🏻',
+ '✌🏼',
+ '✌🏽',
+ '✌🏾',
+ '✌🏿',
+ '🤞',
+ '🤟',
+ '🤘',
+ '🤙',
+ '👈',
+ '👉',
+ '👆',
+ '🖕',
+ '👇',
+ '☝️',
+ '☝🏻',
+ '☝🏼',
+ '☝🏽',
+ '☝🏾',
+ '☝🏿',
+ '👍',
+ '👎',
+ '✊',
+ '👊',
+ '🤛',
+ '🤜',
+ '👏',
+ '🙌',
+ '👐',
+ '🤲',
+ '🤝',
+ '🙏',
+ '✍️',
+ '💅',
+ '🤳',
+ '💪',
+ '🦾',
+ '🦿',
+ '🦵',
+ '🦶',
+ '👂',
+ '🦻',
+ '🤴',
+ '👸',
+ '👳',
+ '👲',
+ '🧕',
+ '🤵',
+ '👰',
+ '🤰',
+ '🤱',
+ '👩🍼',
+ '👨🍼',
+ '🧑🍼',
+ '👼',
+ '🎅',
+ '🤶',
+ '🧑🎄',
+ '🦸',
+ '🦹',
+ '🧙',
+ '🧚',
+ '🧛',
+ '🧜',
+ '🧝',
+ '🧞',
+ '🧟',
+ '💆',
+ '💇',
+ '🚴',
+ '🚵',
+ '🤸',
+ '🤼',
+ '🤽',
+ '🤾',
+ '🤹',
+ '🧘',
+ '🛀',
+ '🐵',
+ '🐒',
+ '🦍',
+ '🦧',
+ '🐶',
+ '🐕',
+ '🦮',
+ '🐕🦺',
+ '🐩',
+ '🐺',
+ '🦊',
+ '🦝',
+ '🐱',
+ '🐈',
+ '🦁',
+ '🐯',
+ '🐅',
+ '🐆',
+ '🐴',
+ '🐎',
+ '🦄',
+ '🦓',
+ '🦌',
+ '🦬',
+ '🐮',
+ '🐂',
+ '🐃',
+ '🐄',
+ '🐷',
+ '🐖',
+ '🐗',
+ '🐽',
+ '🐏',
+ '🐑',
+ '🐐',
+ '🐪',
+ '🐫',
+ '🦙',
+ '🦒',
+ '🐘',
+ '🦣',
+ '🦏',
+ '🦛',
+ '🐭',
+ '🐁',
+ '🐀',
+ '🐹',
+ '🐰',
+ '🐇',
+ '🐿️',
+ '🦫',
+ '🦔',
+ '🦇',
+ '🐻',
+ '🐨',
+ '🐼',
+ '🦥',
+ '🦦',
+ '🦨',
+ '🦘',
+ '🦡',
+ '🐾',
+ '🦃',
+ '🐔',
+ '🐓',
+ '🐣',
+ '🐤',
+ '🐥',
+ '🐦',
+ '🐧',
+ '🕊️',
+ '🦅',
+ '🦆',
+ '🦢',
+ '🦉',
+ '🦤',
+ '🪶',
+ '🦩',
+ '🦚',
+ '🦜',
+ '🐸',
+ '🐊',
+ '🐢',
+ '🦎',
+ '🐍',
+ '🐲',
+ '🐉',
+ '🦕',
+ '🦖',
+ '🐳',
+ '🐋',
+ '🐬',
+ '🦭',
+ '🐟',
+ '🐠',
+ '🐡',
+ '🦈',
+ '🐙',
+ '🐚',
+ '🐌',
+ '🦋',
+ '🐛',
+ '🐜',
+ '🐝',
+ '🪲',
+ '🐞',
+ '🦗',
+ '🪳',
+ '🕷️',
+ '🕸️',
+ '🦂',
+ '🦟',
+ '🪰',
+ '🪱',
+ '🦠',
+ '💐',
+ '🌸',
+ '💮',
+ '🏵️',
+ '🌹',
+ '🥀',
+ '🌺',
+ '🌻',
+ '🌼',
+ '🌷',
+ '🌱',
+ '🪴',
+ '🌲',
+ '🌳',
+ '🌴',
+ '🌵',
+ '🌾',
+ '🌿',
+ '☘️',
+ '🍀',
+ '🍁',
+ '🍂',
+ '🍃',
+ '🍇',
+ '🍈',
+ '🍉',
+ '🍊',
+ '🍋',
+ '🍌',
+ '🍍',
+ '🥭',
+ '🍎',
+ '🍏',
+ '🍐',
+ '🍑',
+ '🍒',
+ '🍓',
+ '🫐',
+ '🥝',
+ '🍅',
+ '🫒',
+ '🥥',
+ '🥑',
+ '🍆',
+ '🥔',
+ '🥕',
+ '🌽',
+ '🌶️',
+ '🫑',
+ '🥒',
+ '🥬',
+ '🥦',
+ '🧄',
+ '🧅',
+ '🍄',
+ '🥜',
+ '🌰',
+ '🍞',
+ '🥐',
+ '🥖',
+ '🫓',
+ '🥨',
+ '🥯',
+ '🥞',
+ '🧇',
+ '🧀',
+ '🍖',
+ '🍗',
+ '🥩',
+ '🥓',
+ '🍔',
+ '🍟',
+ '🍕',
+ '🌭',
+ '🥪',
+ '🌮',
+ '🌯',
+ '🫔',
+ '🥙',
+ '🧆',
+ '🥚',
+ '🍳',
+ '🥘',
+ '🍲',
+ '🫕',
+ '🥣',
+ '🥗',
+ '🍿',
+ '🧈',
+ '🧂',
+ '🥫',
+ '🍱',
+ '🍘',
+ '🍙',
+ '🍚',
+ '🍛',
+ '🍜',
+ '🍝',
+ '🍠',
+ '🍢',
+ '🍣',
+ '🍤',
+ '🍥',
+ '🥮',
+ '🍡',
+ '🥟',
+ '🥠',
+ '🥡',
+ '🦀',
+ '🦞',
+ '🦐',
+ '🦑',
+ '🦪',
+ '🍦',
+ '🍧',
+ '🍨',
+ '🍩',
+ '🍪',
+ '🎂',
+ '🍰',
+ '🧁',
+ '🥧',
+ '🍫',
+ '🍬',
+ '🍭',
+ '🍮',
+ '🍯',
+ '🍼',
+ '🥛',
+ '☕',
+ '🫖',
+ '🍵',
+ '🍶',
+ '🍾',
+ '🍷',
+ '🍸',
+ '🍹',
+ '🍺',
+ '🍻',
+ '🥂',
+ '🥃',
+ '🥤',
+ '🧋',
+ '🧃',
+ '🧉',
+ '🧊',
+ '🥢',
+ '🍽️',
+ '🍴',
+ '🥄',
+ '🔪',
+ '🏺',
+ '🌍',
+ '🌎',
+ '🌏',
+ '🌐',
+ '🗺️',
+ '🗾',
+ '🧭',
+ '🏔️',
+ '⛰️',
+ '🌋',
+ '🗻',
+ '🏕️',
+ '🏖️',
+ '🏜️',
+ '🏝️',
+ '🏞️',
+ '🏟️',
+ '🏛️',
+ '🏗️',
+ '🧱',
+ '🪨',
+ '🪵',
+ '🛖',
+ '🏘️',
+ '🏚️',
+ '🏠',
+ '🏡',
+ '🏢',
+ '🏣',
+ '🏤',
+ '🏥',
+ '🏦',
+ '🏨',
+ '🏩',
+ '🏪',
+ '🏫',
+ '🏬',
+ '🏭',
+ '🏯',
+ '🏰',
+ '💒',
+ '🗼',
+ '🗽',
+ '⛪',
+ '🕌',
+ '🛕',
+ '🕍',
+ '⛩️',
+ '🕋',
+ '⛲',
+ '⛺',
+ '🌁',
+ '🌃',
+ '🏙️',
+ '🌄',
+ '🌅',
+ '🌆',
+ '🌇',
+ '🌉',
+ '♨️',
+ '🎠',
+ '🎡',
+ '🎢',
+ '💈',
+ '🎪',
+ '🚂',
+ '🚃',
+ '🚄',
+ '🚅',
+ '🚆',
+ '🚇',
+ '🚈',
+ '🚉',
+ '🚊',
+ '🚝',
+ '🚞',
+ '🚋',
+ '🚌',
+ '🚍',
+ '🚎',
+ '🚐',
+ '🚑',
+ '🚒',
+ '🚓',
+ '🚔',
+ '🚕',
+ '🚖',
+ '🚗',
+ '🚘',
+ '🚙',
+ '🛻',
+ '🚚',
+ '🚛',
+ '🚜',
+ '🏎️',
+ '🏍️',
+ '🛵',
+ '🦽',
+ '🦼',
+ '🛺',
+ '🚲',
+ '🛴',
+ '🛹',
+ '🛼',
+ '🚏',
+ '🛣️',
+ '🛤️',
+ '🛢️',
+ '⛽',
+ '🚨',
+ '🚥',
+ '🚦',
+ '🛑',
+ '🚧',
+ '⚓',
+ '⛵',
+ '🛶',
+ '🚤',
+ '🛳️',
+ '⛴️',
+ '🛥️',
+ '🚢',
+ '✈️',
+ '🛩️',
+ '🛫',
+ '🛬',
+ '🪂',
+ '💺',
+ '🚁',
+ '🚟',
+ '🚠',
+ '🚡',
+ '🛰️',
+ '🚀',
+ '🛸',
+ '🛎️',
+ '🧳',
+ '⌛',
+ '⏳',
+ '⌚',
+ '⏰',
+ '⏱️',
+ '⏲️',
+ '🕰️',
+ '🌑',
+ '🌒',
+ '🌓',
+ '🌔',
+ '🌕',
+ '🌖',
+ '🌗',
+ '🌘',
+ '🌙',
+ '🌚',
+ '🌛',
+ '🌜',
+ '🌡️',
+ '☀️',
+ '🌝',
+ '🌞',
+ '🪐',
+ '⭐',
+ '🌟',
+ '🌠',
+ '🌌',
+ '☁️',
+ '⛅',
+ '⛈️',
+ '🌤️',
+ '🌥️',
+ '🌦️',
+ '🌧️',
+ '🌨️',
+ '🌩️',
+ '🌪️',
+ '🌫️',
+ '🌬️',
+ '🌀',
+ '🌈',
+ '🌂',
+ '☂️',
+ '☔',
+ '⛱️',
+ '⚡',
+ '❄️',
+ '☃️',
+ '⛄',
+ '☄️',
+ '🔥',
+ '💧',
+ '🌊',
+ '🎃',
+ '🎄',
+ '🎆',
+ '🎇',
+ '🧨',
+ '✨',
+ '🎈',
+ '🎉',
+ '🎊',
+ '🎋',
+ '🎍',
+ '🎎',
+ '🎏',
+ '🎐',
+ '🎑',
+ '🧧',
+ '🎀',
+ '🎁',
+ '🎗️',
+ '🎟️',
+ '🎫',
+ '🎖️',
+ '🏆',
+ '🏅',
+ '🥇',
+ '🥈',
+ '🥉',
+ '⚽',
+ '⚾',
+ '🥎',
+ '🏀',
+ '🏐',
+ '🏈',
+ '🏉',
+ '🎾',
+ '🥏',
+ '🎳',
+ '🏏',
+ '🏑',
+ '🏒',
+ '🥍',
+ '🏓',
+ '🏸',
+ '🥊',
+ '🥋',
+ '🥅',
+ '⛳',
+ '⛸️',
+ '🎣',
+ '🤿',
+ '🎽',
+ '🎿',
+ '🛷',
+ '🥌',
+ '🎯',
+ '🪀',
+ '🪁',
+ '🎱',
+ '🔮',
+ '🪄',
+ '🧿',
+ '🎮',
+ '🕹️',
+ '🎰',
+ '🎲',
+ '🧩',
+ '🧸',
+ '🪅',
+ '🪆',
+ '♠️',
+ '♥️',
+ '♦️',
+ '♣️',
+ '♟️',
+ '🃏',
+ '🀄',
+ '🎴',
+ '🎭',
+ '🖼️',
+ '🎨',
+ '🧵',
+ '🪡',
+ '🧶',
+ '🪢',
+ '👓',
+ '🕶️',
+ '🥽',
+ '🥼',
+ '🦺',
+ '👔',
+ '👕',
+ '👖',
+ '🧣',
+ '🧤',
+ '🧥',
+ '🧦',
+ '👗',
+ '👘',
+ '🥻',
+ '🩱',
+ '🩲',
+ '🩳',
+ '👙',
+ '👚',
+ '👛',
+ '👜',
+ '👝',
+ '🛍️',
+ '🎒',
+ '🩴',
+ '👞',
+ '👟',
+ '🥾',
+ '🥿',
+ '👠',
+ '👡',
+ '🩰',
+ '👢',
+ '👑',
+ '👒',
+ '🎩',
+ '🎓',
+ '🧢',
+ '🪖',
+ '⛑️',
+ '📿',
+ '💄',
+ '💍',
+ '💎',
+ '🔇',
+ '🔈',
+ '🔉',
+ '🔊',
+ '📢',
+ '📣',
+ '📯',
+ '🔔',
+ '🔕',
+ '🎼',
+ '🎵',
+ '🎶',
+ '🎙️',
+ '🎚️',
+ '🎛️',
+ '🎤',
+ '🎧',
+ '📻',
+ '🎷',
+ '🪗',
+ '🎸',
+ '🎹',
+ '🎺',
+ '🎻',
+ '🪕',
+ '🥁',
+ '🪘',
+ '📱',
+ '📲',
+ '☎️',
+ '📞',
+ '📟',
+ '📠',
+ '🔋',
+ '🔌',
+ '💻',
+ '🖥️',
+ '🖨️',
+ '⌨️',
+ '🖱️',
+ '🖲️',
+ '💽',
+ '💾',
+ '💿',
+ '📀',
+ '🧮',
+ '🎥',
+ '🎞️',
+ '📽️',
+ '🎬',
+ '📺',
+ '📷',
+ '📸',
+ '📹',
+ '📼',
+ '🔍',
+ '🔎',
+ '🕯️',
+ '💡',
+ '🔦',
+ '🏮',
+ '🪔',
+ '📔',
+ '📕',
+ '📖',
+ '📗',
+ '📘',
+ '📙',
+ '📚',
+ '📓',
+ '📒',
+ '📃',
+ '📜',
+ '📄',
+ '📰',
+ '🗞️',
+ '📑',
+ '🔖',
+ '🏷️',
+ '💰',
+ '🪙',
+ '💴',
+ '💵',
+ '💶',
+ '💷',
+ '💸',
+ '💳',
+ '🧾',
+ '💹',
+ '✉️',
+ '📧',
+ '📨',
+ '📩',
+ '📤',
+ '📥',
+ '📦',
+ '📫',
+ '📪',
+ '📬',
+ '📭',
+ '📮',
+ '🗳️',
+ '✏️',
+ '✒️',
+ '🖋️',
+ '🖊️',
+ '🖌️',
+ '🖍️',
+ '📝',
+ '💼',
+ '📁',
+ '📂',
+ '🗂️',
+ '📅',
+ '📆',
+ '🗒️',
+ '🗓️',
+ '📇',
+ '📈',
+ '📉',
+ '📊',
+ '📋',
+ '📌',
+ '📍',
+ '📎',
+ '🖇️',
+ '📏',
+ '📐',
+ '✂️',
+ '🗃️',
+ '🗄️',
+ '🗑️',
+ '🔒',
+ '🔓',
+ '🔏',
+ '🔐',
+ '🔑',
+ '🗝️',
+ '🔨',
+ '🪓',
+ '⛏️',
+ '⚒️',
+ '🛠️',
+ '🗡️',
+ '⚔️',
+ '🔫',
+ '🪃',
+ '🏹',
+ '🛡️',
+ '🪚',
+ '🔧',
+ '🪛',
+ '🔩',
+ '⚙️',
+ '🗜️',
+ '⚖️',
+ '🦯',
+ '🔗',
+ '⛓️',
+ '🪝',
+ '🧰',
+ '🧲',
+ '🪜',
+ '⚗️',
+ '🧪',
+ '🧫',
+ '🧬',
+ '🔬',
+ '🔭',
+ '📡',
+ '💉',
+ '🩸',
+ '💊',
+ '🩹',
+ '🩺',
+ '🚪',
+ '🛗',
+ '🪞',
+ '🪟',
+ '🛏️',
+ '🛋️',
+ '🪑',
+ '🚽',
+ '🪠',
+ '🚿',
+ '🛁',
+ '🪤',
+ '🪒',
+ '🧴',
+ '🧷',
+ '🧹',
+ '🧺',
+ '🧻',
+ '🪣',
+ '🧼',
+ '🪥',
+ '🧽',
+ '🧯',
+ '🛒',
+ '🚬',
+ '⚰️',
+ '🪦',
+ '⚱️',
+ '🗿',
+ '🪧',
+ '🏧',
+ '🚮',
+ '🚰',
+ '🔆',
+ '😀',
+ '😃',
+ '😄',
+ '😁',
+ '😆',
+ '😅',
+ '🤣',
+ '😂',
+ '🙂',
+ '🙃',
+ '😉',
+ '😊',
+ '😇',
+ '🥰',
+ '😍',
+ '🤩',
+ '😘',
+ '😗',
+ '😚',
+ '😙',
+ '🥲',
+ '😋',
+ '😛',
+ '😜',
+ '🤪',
+ '😝',
+ '🤑',
+ '🤗',
+ '🤭',
+ '🤫',
+ '🤔',
+ '🤐',
+ '🤨',
+ '😐',
+ '😑',
+ '😶',
+ '😏',
+ '😒',
+ '🙄',
+ '😬',
+ '🤥',
+ '😌',
+ '😔',
+ '😪',
+ '🤤',
+ '😴',
+ '😷',
+ '🤒',
+ '🤕',
+ '🤢',
+ '🤮',
+ '🤧',
+ '🥵',
+ '🥶',
+ '🥴',
+ '😵',
+ '🤯',
+ '🤠',
+ '🥳',
+ '🥸',
+ '😎',
+ '🤓',
+ '🧐',
+ '😕',
+ '😟',
+ '🙁',
+ '😮',
+ '😯',
+ '😲',
+ '😳',
+ '🥺',
+ '😦',
+ '😧',
+ '😨',
+ '😰',
+ '😥',
+ '😢',
+ '😭',
+ '😱',
+ '😖',
+ '😣',
+ '😞',
+ '😓',
+ '😩',
+ '😫',
+ '🥱',
+ '😤',
+ '😡',
+ '😠',
+ '🤬',
+ '😈',
+ '💀',
+ '💩',
+]
+
+export function getRandomEmoji(): string {
+ return emoji[Math.floor((Math.random() * emoji.length))]
+}
+
+export function isBasicType(val = ''): boolean {
+ const t = Object.prototype.toString.call(val)
+ if (t === '[object String]'
+ || t === '[object Boolean]'
+ || t === '[object Number]'
+ || t === '[object Null]'
+ || t === '[object Undefined]'
+ || t === '[object Symbol]')
+ return true
+
+ return false
+}