tool to convert README metadata to json. (#1332)

* tool to convert README metadata to json. Includes python tool to do so (https://github.com/github/codespaces/issues/6384 , https://github.com/github/codespaces/issues/6265)

* remove path
This commit is contained in:
Josh Spicer 2022-03-02 15:09:24 -05:00 коммит произвёл GitHub
Родитель 5c91b9c0e4
Коммит c0dcc9e14f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 1469 добавлений и 405 удалений

Просмотреть файл

@ -1,5 +1,7 @@
# Azure Terraform (Community)
_build, change, and version Azure infrastructure with terraform_
## Summary
[Terraform](https://www.terraform.io/) is an open-source tool that provides the ability to build, change, and version infrastructure as code using declarative configuration files with HashiCorp Configuration Language (HCL).

Просмотреть файл

@ -7,7 +7,8 @@ _Everything you need to get started using Chef products._
| Metadata | Value |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| _Contributors_ | [Eammon Hanlon](https://gitlab.com/ehanlon) |
| _Definition type_ | Image |
| _Definition type_ | Image
| _Category_ | Community | |
| _Works in Codespaces_ | Yes |
| _Container host OS support_ | Linux, macOS, Windows |
| _Languages, platforms_ | Chef Infra Client, Chef InSpec, Chef Command Line Tool, Test Kitchen, and Various Test Kitchen and Knife plugins for clouds |

Просмотреть файл

@ -1,10 +1,11 @@
# Haskell (Community)
_This definition will hopefully get you going quickly with Haskell running as a remote container in vscode_
## Summary
[Haskell](https://www.haskell.org/) is an advanced, purely functional programming language
This definition will hopefully get you going quickly with Haskell running as a remote container in vscode.
| Metadata | Value |
|---------------------------- | -----------------------------------------------------------------------------|

Просмотреть файл

@ -2,7 +2,7 @@
## Summary
Salesforce Extension for VS Code supports remote development and allows you to use a docker container as a full-featured development environment.
_Salesforce Extension for VS Code supports remote development and allows you to use a docker container as a full-featured development environment._
| Metadata | Value |
|----------|-------|
@ -12,7 +12,7 @@ Salesforce Extension for VS Code supports remote development and allows you to u
| *Works in Codespaces* | Yes |
| *Container host OS support* | Linux, macOS, Windows |
| *Container OS* | Ubuntu |
| *Languages, Platforms* | Salesforce CLI, Lightning Web Components, Apex, Aura, Java, Node.js, JavaScript, HTML, CSS, Git |
| *Languages, platforms* | Salesforce CLI, Lightning Web Components, Apex, Aura, Java, Node.js, JavaScript, HTML, CSS, Git |
## Description

Разница между файлами не показана из-за своего большого размера Загрузить разницу

238
migrations/options.json Normal file
Просмотреть файл

@ -0,0 +1,238 @@
[
{
"id": "ubuntu",
"options": {
"VARIANT": {
"type": "string",
"proposals": ["hirsute", "bionic", "focal"],
"default": "focal"
}
}
},
{
"id": "debian",
"options": {
"VARIANT": {
"type": "string",
"proposals": ["bullseye", "buster"],
"default": "bullseye"
}
}
},
{
"id": "alpine",
"options": {
"VARIANT": {
"type": "string",
"proposals": ["3.14", "3.13", "3.12", "3.11"],
"default": "3.13"
},
"INSTALL_ZSH": {
"type": "boolean",
"default": false,
"description": "Install zsh"
}
}
},
{
"id": "javascript-node",
"options": {
"VARIANT": {
"type": "string",
"proposals": [
"16-bullseye",
"14-bullseye",
"12-bullseye",
"16-buster",
"14-buster",
"12-buster"
],
"default": "16-bullseye"
}
}
},
{
"id": "typescript-node",
"options": {
"VARIANT": {
"type": "string",
"proposals": [
"16-bullseye",
"14-bullseye",
"12-bullseye",
"16-buster",
"14-buster",
"12-buster"
],
"default": "16-bullseye"
}
}
},
{
"id": "python-3",
"options": {
"VARIANT": {
"type": "string",
"proposals": [
"3",
"3.10",
"3.9",
"3.8",
"3.7",
"3.6",
"3-bullseye",
"3.10-bullseye",
"3.9-bullseye",
"3.8-bullseye",
"3.7-bullseye",
"3.6-bullseye",
"3-buster",
"3.10-buster",
"3.9-buster",
"3.8-buster",
"3.7-buster",
"3.6-buster"
],
"default": "3-bullseye"
}
}
},
{
"id": "cpp",
"options": {
"VARIANT": {
"type": "string",
"proposals": [
"debian-11",
"debian-10",
"ubuntu-21.04",
"ubuntu-20.04",
"ubuntu-18.04"
],
"default": "debian-10"
}
}
},
{
"id": "php",
"options": {
"VARIANT": {
"type": "string",
"proposals": [
"8-apache-bullseye",
"8.1-apache-bullseye",
"8.0-apache-bullseye",
"7-apache-bullseye",
"7.4-apache-bullseye",
"8-apache-buster",
"8.1-apache-buster",
"8.0-apache-buster",
"7-apache-buster",
"7.4-apache-buster"
],
"default": "7-apache-bullseye"
}
}
},
{
"id": "rust",
"options": {
"VARIANT": {
"type": "string",
"proposals": ["buster", "bullseye"],
"default": "bullseye"
}
}
},
{
"id": "ruby",
"options": {
"VARIANT": {
"type": "string",
"enum": ["3", "2.7", "3-bullseye", "2.7-bullseye"],
"default": "3",
"description": "Select variant of the vscode/devcontainers/ruby image to be set as the base image of this Dockerfile."
},
"NODE_VERSION": {
"type": "string",
"proposals": ["lts", "16", "14", "10", "none"],
"default": "16",
"description": "Specify version of node, or 'none' to skip node installation."
}
}
},
{
"id": "go",
"options": {
"VARIANT": {
"type": "string",
"proposals": [
"1",
"1.16",
"1.17",
"1-bullseye",
"1.16-bullseye",
"1.17-bullseye",
"1-buster",
"1.16-buster",
"1.17-buster"
],
"default": "1-bullseye"
}
}
},
{
"id": "java",
"options": {
"VARIANT": {
"type": "string",
"proposals": [
"11",
"17",
"11-bullseye",
"17-bullseye",
"11-buster",
"17-buster"
],
"default": "11-bullseye"
}
}
},
{
"id": "dotnet",
"options": {
"VARIANT": {
"type": "string",
"proposals": [
"6.0-bullseye",
"5.0-bullseye",
"3.1-bullseye",
"6.0-focal",
"5.0-focal",
"3.1-focal"
],
"default": "6.0-bullseye-slim"
}
}
},
{
"id": "javascript-node-mongo",
"options": {
"VARIANT": {
"type": "string",
"proposals": [
"16-bullseye",
"14-bullseye",
"12-bullseye",
"16-buster",
"14-buster",
"12-buster",
"16",
"14",
"12"
],
"default": "14"
}
}
}
]

Просмотреть файл

@ -0,0 +1,178 @@
import subprocess
# Eg. /Users/jospicer/dev/vscode-dev-containers/containers
ABS_PATH_TO_CONTAINERS_FOLDER = ''
# Eg. /Users/jospicer/dev/vscode-dev-containers/migrations/options.json
OPTIONS_FILE = ''
containers = [
'alpine',
'azure-ansible',
'azure-bicep',
'azure-cli',
'azure-functions-dotnet-6-inprocess',
'azure-functions-dotnet-6-isolated',
'azure-functions-dotnetcore-3.1',
'azure-functions-java-11',
'azure-functions-java-8',
'azure-functions-node',
'azure-functions-pwsh',
'azure-functions-python-3',
'azure-machine-learning-python-3',
'azure-static-web-apps',
'azure-terraform',
'bash',
'bazel',
'chef-workstation',
'codespaces-linux',
'cpp',
'cpp-mariadb',
'dapr-dotnet',
'dapr-javascript-node',
'dart',
'debian',
'deno',
'docker-existing-docker-compose',
'docker-existing-dockerfile',
'docker-from-docker',
'docker-from-docker-compose',
'docker-in-docker',
'dotnet',
'dotnet-fsharp',
'dotnet-mssql',
'dotnet-postgres',
'elixir',
'elixir-phoenix-postgres',
'elm',
'go',
'go-postgres',
'haskell',
'hugo',
'java',
'java-8',
'java-postgres',
'javascript-node',
'javascript-node-azurite',
'javascript-node-mongo',
'javascript-node-postgres',
'jekyll',
'julia',
'jupyter-datascience-notebooks',
'kubernetes-helm',
'kubernetes-helm-minikube',
'markdown',
'mit-scheme',
'perl',
'php',
'php-mariadb',
'powershell',
'puppet',
'python-3',
'python-3-anaconda',
'python-3-anaconda-postgres',
'python-3-device-simulator-express',
'python-3-miniconda',
'python-3-miniconda-postgres',
'python-3-postgres',
'python-3-pypy',
'r',
'reasonml',
'ruby',
'ruby-rails',
'ruby-rails-postgres',
'ruby-sinatra',
'rust',
'rust-postgres',
'sfdx-project',
'swift',
'typescript-node',
'ubuntu',
'vue'
]
def template(defId, displayName, description, categories, defType, platforms, options):
categories = '", "'.join(categories)
platforms = '", "'.join(platforms)
if defType == 'Dockerfile' or defType == 'Image':
defType = 'singleContainer'
elif defType == 'Docker Compose':
defType = 'dockerCompose'
else:
raise Exception('Unknown type: ' + defType)
if options == '':
options = 'lc rc'
subst = '''
lc
"id": "{}",
"displayName": "{}",
"description": "{}",
"categories": [ "{}" ],
"platforms": [ "{}" ],
"type": "{}",
"options": {}
rc,'''.format(defId, displayName, description, categories, platforms, defType, options)
return subst.replace('lc', '{').replace('rc', '}')
exceptions = 0
failedDetails = []
for c in containers:
readme = f'{ABS_PATH_TO_CONTAINERS_FOLDER}/{c}/README.md'
# print(readme)
try:
displayName = subprocess.check_output(
f"/usr/bin/egrep -m 1 '^# ().*' {readme}", shell=True)
displayName = str(displayName, 'utf-8').strip().replace('# ',
'').replace('\\n', '')
description = subprocess.check_output(
f"/usr/bin/egrep -m 1 '(\*|_)(.*)(\*|_)$' {readme}", shell=True)
description = str(description, 'utf-8').strip().replace(
'*', '').replace('\\n', '')
categories = subprocess.check_output(
f"/usr/bin/egrep -m 1 '(\*|_)(Categories|Category)(\*|_)' {readme}", shell=True)
categories = str(categories, 'utf-8').split(
'|')[2].replace('*', '').split(',')
categories = map(str.strip, categories)
defType = subprocess.check_output(
f"/usr/bin/egrep -m 1 '(\*|_)Definition type(\*|_)' {readme}", shell=True)
defType = str(defType, 'utf-8').split(
'|')[2].replace('*', '').strip()
platforms = subprocess.check_output(
f"/usr/bin/egrep -m 1 '(\*|_)Languages, platforms(\*|_)' {readme}", shell=True)
platforms = str(platforms, 'utf-8').split(
'|')[2].replace('*', '').split(',')
platforms = map(str.strip, platforms)
options = ''
try:
options = subprocess.check_output(
f"cat {OPTIONS_FILE}| jq -r '.[] | select(.id == \"{c}\") | .options'", shell=True)
options = str(options, 'utf-8').strip()
except:
options = ''
pass
print(template(c, displayName, description,
categories, defType, platforms, options))
except Exception as e:
failedDetails.append(f'{c}: {e}')
exceptions += 1
continue
print()
print('==============================')
print(f'{exceptions} exceptions')
for f in failedDetails:
print(f)
print('---')