tis-vscode-config icon

VSCode Configuration

Silent install package for VSCode Configuration

0.2.5-12
Development
Development

  • package: tis-vscode-config
  • name: VSCode Configuration
  • version: 0.2.5-12
  • categories: Development
  • maintainer: WAPT Team,Tranquil IT,Jimmy PELÉ
  • locale: all
  • target_os: all
  • architecture: all
  • signature_date:
  • size: 7.39 Ko
  • depends:
  • conflicts :

package           : tis-vscode-config
version           : 0.2.5-12
architecture      : all
section           : base
priority          : optional
name              : VSCode Configuration
categories        : Development
maintainer        : WAPT Team,Tranquil IT,Jimmy PELÉ
description       : Configure Visual Studio Code
depends           : tis-vscode-pylance
conflicts         : tis-config-vscode
maturity          : PROD
locale            : all
target_os         : all
min_wapt_version  : 2.3
sources           : https://code.visualstudio.com/Download
installed_size    : 
impacted_process  : 
description_fr    : Configuration de Visual Studio Code
description_pl    : 
description_de    : 
description_es    : 
description_pt    : 
description_it    : 
description_nl    : 
description_ru    : 
audit_schedule    : 
editor            : 
keywords          : 
licence           : 
homepage          : 
package_uuid      : 6caa4c76-dae3-46af-aae3-88feabb33b54
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
min_os_version    : 
max_os_version    : 
icon_sha256sum    : 7891f1ca19ac8a9e41cb2963c0833bb3424a1dcc3f89e6ae484b1841a67063b2
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature_date    : 2024-09-12T11:34:50.000000
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes
signature         : MoUubb3EiHAh5zUyfatXhZyTZGtMiW5HLyxAcArkxIFx8t/nKsu/f53UUCdIi/oj6+mM8QOZ7OgUNFqtbzx/IJI8t90+X+4e/2RY8Na1of0oxuyXhgupOxu3hBS9tQjby0VqYfffb7mFUodJXX/7xAQRWMUHCKpSq4R45kRFnzf4M7Rp2r+Q72fvPuP9j6Yw3QBq7c+u42ekg2HRnyK9MhUTvQiRUR0QXgk1pl9GBwA5kN++2PimhXVkv65xBpVgPaFBjNZ88YmVfthE59AvjNfpvwzwZ8RKcBGEoM0qyMNPG80RI6xuFIsZXicefiRtELjc4i6e/Z6Vn9oklvzrUQ==

# -*- coding: utf-8 -*-
from setuphelpers import *
import json
import re
import os
import sys

r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()

Configuration procedure: https://supunkavinda.blog/vscode-editing-settings-json

File -> Preferences -> Settings -> Extensions -> Scroll down and find "Edit in settings.json"

Or in these paths in your OS :
Windows : %APPDATA%\Code\User\settings.json
macOS   : $HOME/Library/Application Support/Code/User/settings.json
Linux   : $HOME/.config/Code/User/settings.json

https://code.visualstudio.com/docs/editor/extension-marketplace#_workspace-recommended-extensions

"""


def install():
    pass


def session_setup():
    print("Applying: VSCode configuration")

    # Initializing variables
    if get_os_name() == "Windows":
        user_conf_dir = makepath(user_appdata, "Code", "User")
    elif get_os_name() == "Linux":
        user_conf_dir = makepath(user_home_directory(), ".config", "Code", "User")
    elif get_os_name() == "Darwin":
        user_conf_dir = makepath(user_home_directory(), "Library", "Application Support", "Code", "User")

    user_conf_file = makepath(user_conf_dir, "settings.json")
    user_conf_content = r"""{

    "update.mode": "none",
    "update.enableWindowsBackgroundUpdates": false,
    "update.showReleaseNotes": false,
    "powershell.promptToUpdatePowerShell": false,
    "extensions.autoCheckUpdates": false,
    "extensions.autoUpdate": false,
    "extensions.ignoreRecommendations": true,

    "telemetry.telemetryLevel": "off",
    "redhat.telemetry.enabled": false,
    "npm.fetchOnlinePackageInfo": false,
    "json.schemaDownload.enable": false,

    "editor.wordWrap": "on",
    "editor.minimap.enabled": false,
    "workbench.activityBar.visible": true,
    "workbench.startupEditor": "none",
    "restructuredtext.preview.scrollEditorWithPreview": false,
    "restructuredtext.preview.scrollPreviewWithEditor": false,
    "markdown.preview.scrollEditorWithPreview": false,
    "markdown.preview.scrollPreviewWithEditor": false,

    "python.formatting.provider": "black",
    "python.formatting.blackArgs": [
        "--line-length",
        "150"
    ],
    "python.formatting.blackPath": "{black_path}",
    "python.languageServer": "Jedi",

    "git.openRepositoryInParentFolders": "always",
    "git.autofetch": true,

    "files.associations": {
        "control": "yaml"
    }

}"""
    black_path = makepath(sys.executable.rsplit(os.path.sep, 2)[0], "libdev", "site-packages", "bin", "black")
    # user_conf_content = user_conf_content.replace("{black_path}", black_path.replace("\\", "\\\\"))
    user_conf_content = user_conf_content.replace("{black_path}", black_path.replace("\\", "/"))
    # For now black stay in lib and not libdev
    user_conf_data = json.loads(user_conf_content)
    del user_conf_data["python.formatting.blackPath"]

    if not isdir(user_conf_dir):
        mkdirs(user_conf_dir)
    if not isfile(user_conf_file):
        print("Creating: %s" % user_conf_file)
        json_write_file(user_conf_file, user_conf_data)
    else:
        new_user_conf_data = json_load_file(user_conf_file)
        new_user_conf_data.update(user_conf_data)
        if new_user_conf_data.get("python.formatting.blackPath"):
            del new_user_conf_data["python.formatting.blackPath"]
        print("Updating: %s" % user_conf_file)
        json_write_file(user_conf_file, new_user_conf_data)


def json_load_file(json_file, encoding="utf-8"):
    r"""Get content of a json file

    Args:
        path (str): path to the file

    Returns:
        dictionary (dict)

    """
    with open(json_file, encoding=encoding) as read_file:
        return json.load(read_file, cls=TrailingCommaJSONDecoder)


class TrailingCommaJSONDecoder(json.JSONDecoder):
    def decode(self, s, *args, **kwargs):
        # Remove trailing commas before decoding
        s = self._remove_trailing_commas(s)
        return super().decode(s, *args, **kwargs)

    def _remove_trailing_commas(self, s):
        # A simple implementation to remove trailing commas
        # This might not handle all edge cases, but it works for most common cases
        return s.replace(",}", "}").replace(",]", "]")

38d056ab130f7bf7c481c12636a4e9959de36561d3dfcbe54c6e3571bc0c1dc3 : WAPT/certificate.crt
763499011c813be9ea4fa9f860e94d53ed8b4786a336bbfff0aabdc4d1b05625 : WAPT/changelog.txt
10a24d0cac3e59fe4c4a0e7759d0c0a3da5cf5c1ac50e2fa038d73bb13be2136 : WAPT/control
7891f1ca19ac8a9e41cb2963c0833bb3424a1dcc3f89e6ae484b1841a67063b2 : WAPT/icon.png
16fb93c35db99e3226adfba0bedf582ffb51c83220a9d8d772315860018be84c : luti.json
6ab1791dc7dc5d5c062f9c5b6ca98f8ac2cf8db30cbdfb5c583c0a39879ad5e2 : setup.py

0.2.5-11
===
tis-waptpython-black is now a tis-waptdev-package-tools dependency
Using TrailingCommaJSONDecoder to make sure config will be applied
Fix "del"


0.2.4-8
===
No longer use PyLance as it uses too much memory (https://github.com/microsoft/pylance-release/issues/4121#issuecomment-1534371617)
Re-adding telemetry and update disabling
Adding some git options
Handle dirty JSON
Define control as YAML file since it makes it more readable