-
-
Save drmikecrowe/b18ef8ad67a267d619cebcf01e50b97e to your computer and use it in GitHub Desktop.
Revisions
-
drmikecrowe revised this gist
Aug 11, 2024 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,13 +9,14 @@ python VSCode_CSV.py ``` * Edit `vscode-extensions-with-desc.txt` and remove all extensions that are no longer needed * Now, removing all extensions from vscode: ```sh cat installed.txt | xargs -n 1 code --uninstall-extension rm -rf ~/.vscode/extensions/ ``` * Next, start VSCode and ensure the settings sync * Now install the right extensions ```sh -
drmikecrowe revised this gist
Aug 11, 2024 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,4 +20,6 @@ rm -rf ~/.vscode/extensions/ ```sh cat vscode-extensions-with-desc.txt | awk '{ print $1 }' | xargs -n 1 code --install-extension ``` * Now, open up your settings and find any greyed out entries and remove the (or reinstall if it's one you realize you missed) -
drmikecrowe revised this gist
Aug 11, 2024 . 2 changed files with 24 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ This snippet takes your exported vscode extension list and adds the description and last updated date. Here's how I use it: * Export my existings to a list * Review that list and decide what extensions I need to clean up (delete those lines from this list) ```py code --list-extensions > installed.txt python VSCode_CSV.py ``` * Edit `vscode-extensions-with-desc.txt` and remove all extensions that are no longer needed * Removing all extensions: ```sh cat installed.txt | xargs -n 1 code --uninstall-extension rm -rf ~/.vscode/extensions/ ``` * Now install the right extensions ```sh cat vscode-extensions-with-desc.txt | awk '{ print $1 }' | xargs -n 1 code --install-extension ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -155,7 +155,7 @@ def main(): str(round(extensions_statistics.get("install", 0))), extension_description, ) info = f"{id.strip():50} {last_update:10} {str(round(extensions_statistics.get("install", 0))):>12} {extension_description}" for cat in extension_categories: if info in used: -
drmikecrowe revised this gist
Aug 11, 2024 . 1 changed file with 99 additions and 29 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,38 @@ import requests from requests.adapters import HTTPAdapter, Retry from datetime import datetime, timedelta from rich.table import Table from rich.console import Console console = Console() table = Table(title="VSCode Extensions") def get_vscode_extensions( id, max_page=10000, page_size=100, include_versions=True, include_files=True, include_category_and_tags=True, include_shared_accounts=True, include_version_properties=True, exclude_non_validated=False, include_installation_targets=True, include_asset_uri=True, include_statistics=True, include_latest_version_only=False, unpublished=False, include_name_conflict_info=True, api_version="7.2-preview.1", session=None, ): if not session: session = requests.session() headers = {"Accept": f"application/json; charset=utf-8; api-version={api_version}"} flags = 0 if include_versions: @@ -55,27 +78,26 @@ def get_vscode_extensions(max_page=10000, page_size=100, body = { "filters": [ { "criteria": [{"filterType": 7, "value": id}], "pageNumber": page, "pageSize": page_size, "sortBy": 0, "sortOrder": 0, } ], "assetTypes": [], "flags": flags, } r = session.post( "https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery", json=body, headers=headers, ) r.raise_for_status() response = r.json() extensions = response["results"][0]["extensions"] for extension in extensions: yield extension @@ -88,25 +110,73 @@ def main(): total=3, backoff_factor=1, status_forcelist=[429, 500, 502, 503, 504], allowed_methods=["HEAD", "GET", "OPTIONS"], ) adapter = HTTPAdapter(max_retries=retry_strategy) session = requests.Session() session.mount("https://", adapter) session.mount("http://", adapter) details = [] categories = {} used = set() table.add_column("Name", style="cyan", no_wrap=True) table.add_column("Version") table.add_column("Last Update") table.add_column("Install Count", justify="right") table.add_column("Description") for id in open("vscode-extensions.txt").readlines(): for extension in get_vscode_extensions(id.strip(), session=session): extension_name = extension["extensionName"] extension_description = extension.get("shortDescription", "") extensions_versions = extension["versions"] extension_last_update = extension["lastUpdated"] last_update_dt = datetime.strptime( extension_last_update, "%Y-%m-%dT%H:%M:%S.%fZ" ) last_update = last_update_dt.strftime("%Y-%m-%d") extension_categories = extension["categories"] extensions_statistics = dict( { (item["statisticName"], item["value"]) for item in extension["statistics"] } ) extension_version_info = extensions_versions.pop(0) extension_version = extension_version_info["version"] table.add_row( extension_name, extension_version, last_update, str(round(extensions_statistics.get("install", 0))), extension_description, ) info = f"{extension_name:50} {last_update:10} {str(round(extensions_statistics.get("install", 0))):>12} {extension_description}" for cat in extension_categories: if info in used: continue used.add(cat) categories.setdefault(cat, []).append(info) details.append(info) break console.print(table) with open("vscode-extensions-with-desc.txt", "w") as f: f.write("\n".join(details)) with open("vscode-extensions-categories.txt", "w") as f: for cat, extensions in sorted(categories.items()): f.write(f"{cat}\n") f.write("\n".join(extensions)) f.write("\n\n---\n\n") if __name__ == "__main__": main() -
jossef revised this gist
Aug 28, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -95,7 +95,7 @@ def main(): session.mount("https://", adapter) session.mount("http://", adapter) for extension in get_vscode_extensions(session=session): extension_name = extension['extensionName'] extension_description = extension['extensionName'] extensions_versions = extension['versions'] -
jossef created this gist
Aug 28, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,112 @@ import requests from requests.adapters import HTTPAdapter, Retry def get_vscode_extensions(max_page=10000, page_size=100, include_versions=True, include_files=True, include_category_and_tags=True, include_shared_accounts=True, include_version_properties=True, exclude_non_validated=False, include_installation_targets=True, include_asset_uri=True, include_statistics=True, include_latest_version_only=False, unpublished=False, include_name_conflict_info=True, api_version='7.2-preview.1', session=None): if not session: session = requests.session() headers = {'Accept': f'application/json; charset=utf-8; api-version={api_version}'} flags = 0 if include_versions: flags |= 0x1 if include_files: flags |= 0x2 if include_category_and_tags: flags |= 0x4 if include_shared_accounts: flags |= 0x8 if include_shared_accounts: flags |= 0x8 if include_version_properties: flags |= 0x10 if exclude_non_validated: flags |= 0x20 if include_installation_targets: flags |= 0x40 if include_asset_uri: flags |= 0x80 if include_statistics: flags |= 0x100 if include_latest_version_only: flags |= 0x200 if unpublished: flags |= 0x1000 if include_name_conflict_info: flags |= 0x8000 for page in range(1, max_page + 1): body = { "filters": [ { "criteria": [ { "filterType": 8, "value": "Microsoft.VisualStudio.Code" } ], "pageNumber": page, "pageSize": page_size, "sortBy": 0, "sortOrder": 0 } ], "assetTypes": [], "flags": flags } r = session.post('https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery', json=body, headers=headers) r.raise_for_status() response = r.json() extensions = response['results'][0]['extensions'] for extension in extensions: yield extension if len(extensions) != page_size: break def main(): retry_strategy = Retry( total=3, backoff_factor=1, status_forcelist=[429, 500, 502, 503, 504], allowed_methods=["HEAD", "GET", "OPTIONS"] ) adapter = HTTPAdapter(max_retries=retry_strategy) session = requests.Session() session.mount("https://", adapter) session.mount("http://", adapter) for extension in get_vscode_extensions(session=session, page_size=10): extension_name = extension['extensionName'] extension_description = extension['extensionName'] extensions_versions = extension['versions'] extensions_statistics = dict({(item['statisticName'], item['value']) for item in extension['statistics']}) extension_publisher_username = extension['publisher']['publisherName'] for extension_version_info in extensions_versions: extension_version = extension_version_info['version'] extension_artifact_download_url = f'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/{extension_publisher_username}/vsextensions/{extension_name}/{extension_version}/vspackage' print(extension_name, extension_description, extension_version, extension_artifact_download_url, extensions_statistics['install']) if __name__ == '__main__': main()