<commit_before>#  (C) Datadog, Inc. 2022-present
#  All rights reserved
#  Licensed under a 3-clause BSD style license (see LICENSE)

import json
import uuid

from ....fs import write_file
from ...commands.console import abort
from ...datastructures import JSONDict
from ...utils import get_manifest_file, load_manifest

# This means the value is either not present in the old manifest, or there's logic needed to compute it
SKIP_IF_FOUND = "SKIP"

# Static text to let users know these values need updating by hand
TODO_FILL_IN = "TODO Please Fill In"

# Validate what manifest versions we can support and what we can upgrade from->to
SUPPORTED_MANIFEST_VERSIONS = ["1.0.0", "2.0.0"]
SUPPORTED_VERSION_UPGRADE_PATHS = {"1.0.0": ["2.0.0"]}

# JSONDict map all v2 fields to their v1 counterparts
# Skipping any fields that need manual intervention of custom logic
V2_TO_V1_MAP = JSONDict(
    {
        "/manifest_version": SKIP_IF_FOUND,
        "/app_id": "/integration_id",
        "/display_on_public_website": "/is_public",
        "/tile": {},
        "/tile/overview": "README.md#Overview",
        "/tile/configuration": "README.md#Setup",
        "/tile/support": "README.md#Support",
        "/tile/changelog": "CHANGELOG.md",
        "/tile/description": "/short_description",
        "/tile/title": "/public_title",
        "/tile/media": [],
        "/tile/classifier_tags": [],
        "/author": {},
        "/author/homepage": "/author/homepage",
        "/author/name": "/author/name",
        "/author/support_email": "/maintainer",
        "/oauth": {},
        "/assets": {},
        "/assets/integration": {},
        "/assets/integration/source_type_name": "/display_name",
        "/assets/integration/configuration": {},
        "/assets/integration/configuration/spec": "/assets/configuration/spec",
        "/assets/integration/events": {},
        "/assets/integration/events/creates_events": "/creates_events",
        "/assets/integration/metrics": {},
        "/assets/integration/metrics/prefix": "/metric_prefix",
        "/assets/integration/metrics/check": "/metric_to_check",
        "/assets/integration/metrics/metadata_path": "/assets/metrics_metadata",
        "/assets/integration/service_checks": {},
        "/assets/integration/service_checks/metadata_path": "/assets/service_checks",
        "/assets/dashboards": "/assets/dashboards",
        "/assets/monitors": "/assets/monitors",
        "/assets/saved_views": "/assets/saved_views",
        "/assets/logs": "/assets/logs",
    }
)

OS_TO_CLASSIFIER_TAGS = {
    "linux": "Supported OS::Linux",
    "mac_os": "Supported OS::macOS",
    "windows": "Supported OS::Windows",
}

CATEGORIES_TO_CLASSIFIER_TAGS = {
    "alerting": "Category::Alerting",
    "autodiscovery": "Category::Autodiscovery",
    "automation": "Category::Automation",
    "aws": "Category::AWS",
    "azure": "Category::Azure",
    "caching": "Category::Caching",
    "cloud": "Category::Cloud",
    "collaboration": "Category::Collaboration",
    "compliance": "Category::Compliance",
    "configuration & deployment": "Category::Configuration Deployment",
    "containers": "Category::Containers",
    "cost management": "Category::Cost Management",
    "data store": "Category::Data Store",
    "developer tools": "Category::Developer Tools",
    "event management": "Category::Event Management",
    "exceptions": "Category::Exceptions",
    "google cloud": "Category::Google Cloud",
    "incidents": "Category::Incidents",
    "iot": "Category::IOT",
    "isp": "Category::ISP",
    "issue tracking": "Category::Issue Tracking",
    "languages": "Category::Languages",
    "log collection": "Category::Log Collection",
    "marketplace": "Category::Marketplace",
    "messaging": "Category::Messaging",
    "metrics": "Category::Metrics",
    "monitoring": "Category::Monitoring",
    "network": "Category::Network",
    "notification": "Category::Notification",
    "oracle": "Category::Oracle",
    "orchestration": "Category::Orchestration",
    "os & system": "Category::OS System",
    "processing": "Category::Processing",
    "profiling": "Category::Profiling",
    "provisioning": "Category::Provisioning",
    "security": "Category::Security",
    "snmp": "Category::SNMP",
    "source control": "Category::Source Control",<commit_msg>Fix `Configuration & Deployment` tag for v2 manifest migration (#12348)<commit_after>#  (C) Datadog, Inc. 2022-present
#  All rights reserved
#  Licensed under a 3-clause BSD style license (see LICENSE)

import json
import uuid

from ....fs import write_file
from ...commands.console import abort
from ...datastructures import JSONDict
from ...utils import get_manifest_file, load_manifest

# This means the value is either not present in the old manifest, or there's logic needed to compute it
SKIP_IF_FOUND = "SKIP"

# Static text to let users know these values need updating by hand
TODO_FILL_IN = "TODO Please Fill In"

# Validate what manifest versions we can support and what we can upgrade from->to
SUPPORTED_MANIFEST_VERSIONS = ["1.0.0", "2.0.0"]
SUPPORTED_VERSION_UPGRADE_PATHS = {"1.0.0": ["2.0.0"]}

# JSONDict map all v2 fields to their v1 counterparts
# Skipping any fields that need manual intervention of custom logic
V2_TO_V1_MAP = JSONDict(
    {
        "/manifest_version": SKIP_IF_FOUND,
        "/app_id": "/integration_id",
        "/display_on_public_website": "/is_public",
        "/tile": {},
        "/tile/overview": "README.md#Overview",
        "/tile/configuration": "README.md#Setup",
        "/tile/support": "README.md#Support",
        "/tile/changelog": "CHANGELOG.md",
        "/tile/description": "/short_description",
        "/tile/title": "/public_title",
        "/tile/media": [],
        "/tile/classifier_tags": [],
        "/author": {},
        "/author/homepage": "/author/homepage",
        "/author/name": "/author/name",
        "/author/support_email": "/maintainer",
        "/oauth": {},
        "/assets": {},
        "/assets/integration": {},
        "/assets/integration/source_type_name": "/display_name",
        "/assets/integration/configuration": {},
        "/assets/integration/configuration/spec": "/assets/configuration/spec",
        "/assets/integration/events": {},
        "/assets/integration/events/creates_events": "/creates_events",
        "/assets/integration/metrics": {},
        "/assets/integration/metrics/prefix": "/metric_prefix",
        "/assets/integration/metrics/check": "/metric_to_check",
        "/assets/integration/metrics/metadata_path": "/assets/metrics_metadata",
        "/assets/integration/service_checks": {},
        "/assets/integration/service_checks/metadata_path": "/assets/service_checks",
        "/assets/dashboards": "/assets/dashboards",
        "/assets/monitors": "/assets/monitors",
        "/assets/saved_views": "/assets/saved_views",
        "/assets/logs": "/assets/logs",
    }
)

OS_TO_CLASSIFIER_TAGS = {
    "linux": "Supported OS::Linux",
    "mac_os": "Supported OS::macOS",
    "windows": "Supported OS::Windows",
}

CATEGORIES_TO_CLASSIFIER_TAGS = {
    "alerting": "Category::Alerting",
    "autodiscovery": "Category::Autodiscovery",
    "automation": "Category::Automation",
    "aws": "Category::AWS",
    "azure": "Category::Azure",
    "caching": "Category::Caching",
    "cloud": "Category::Cloud",
    "collaboration": "Category::Collaboration",
    "compliance": "Category::Compliance",
    "configuration & deployment": "Category::Configuration & Deployment",
    "containers": "Category::Containers",
    "cost management": "Category::Cost Management",
    "data store": "Category::Data Store",
    "developer tools": "Category::Developer Tools",
    "event management": "Category::Event Management",
    "exceptions": "Category::Exceptions",
    "google cloud": "Category::Google Cloud",
    "incidents": "Category::Incidents",
    "iot": "Category::IOT",
    "isp": "Category::ISP",
    "issue tracking": "Category::Issue Tracking",
    "languages": "Category::Languages",
    "log collection": "Category::Log Collection",
    "marketplace": "Category::Marketplace",
    "messaging": "Category::Messaging",
    "metrics": "Category::Metrics",
    "monitoring": "Category::Monitoring",
    "network": "Category::Network",
    "notification": "Category::Notification",
    "oracle": "Category::Oracle",
    "orchestration": "Category::Orchestration",
    "os & system": "Category::OS System",
    "processing": "Category::Processing",
    "profiling": "Category::Profiling",
    "provisioning": "Category::Provisioning",
    "security": "Category::Security",
    "snmp": "Category::SNMP",
    "source control": "Category::Source Control",
{'fraction_non_alphanumeric': 0.16766398158803222, 'fraction_numerical': 0.005523590333716916, 'mean_word_length': 3.7831590533847, 'pattern_counts': {'":': 152, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6819545', 'n_tokens_mistral': 2620, 'n_tokens_neox': 2530, 'n_words': 567}