Phase 1 Partial - Colorization + share (#3679)
* add syntax files, add languages, grammars, to package.json copy over stuff to play with later got the grammars working with the other stuff commented out cleaned up, not tested remove stuff I don't think we really need to have a unique ID, we should tell people to only install our extension remove unnecessary method update our syntaxes from what we do in VS test pipeline update cgmanifest temporarly force cg test different version use .3 version update notice, it includes textmate reference manually add kitware/cmake reference to NOTICE fix trigger fix pipeline name get repo make sure we checkout the repos powershell inline reference variables correctly testing for differences, CHANGE LATER updating textmate see if we're getting the right git diff test with explicit path update dates write output try to properly access variables use embeddedbot put emails and username in variables switch when I update config orgurl add logging update auth update docs testing out PR tool remove 'description' option add console.log statements for testing map system token run index.ts for both grammars and quickinfo, put paths into variables, condition based on parameters fix trigger access variables correctly access variables correctly only run job if one of the share steps is enabled fix job name test without prefix remove difference remove snippets keyword until we actually add this remove stray miscopy remove powershell * small update * ignore tools directory when packaging * don't build the tools directory when building and testing the extension * exclude tools for webpack? * revert webpack * try webpack fix again * try another fix * revert * we need to remote the NOTICE for testing earlier so yarn doesn't fail * rename notices.txt to get around yarn issue * update changelog
This commit is contained in:
Родитель
31de14db4f
Коммит
25698e0d30
|
@ -40,9 +40,6 @@ jobs:
|
|||
configure-options: -DCMAKE_INSTALL_PREFIX:STRING=${{ github.workspace }}/test/fakebin
|
||||
install-build: true
|
||||
|
||||
- name: Delete NOTICE.txt
|
||||
run: rm ${{ github.workspace }}/NOTICE.txt
|
||||
|
||||
- name: Run backend tests
|
||||
run: yarn backendTests
|
||||
|
||||
|
|
|
@ -40,8 +40,7 @@ jobs:
|
|||
configure-options: -DCMAKE_INSTALL_PREFIX:STRING=${{ github.workspace }}/test/fakebin
|
||||
install-build: true
|
||||
|
||||
- name: Delete NOTICE.txt
|
||||
run: rm ${{ github.workspace }}/NOTICE.txt
|
||||
|
||||
|
||||
- name: Run successful-build test
|
||||
run: yarn extensionTestsSuccessfulBuild
|
||||
|
|
|
@ -42,9 +42,6 @@ jobs:
|
|||
configure-options: -DCMAKE_INSTALL_PREFIX:STRING=${{ github.workspace }}/test/fakebin
|
||||
install-build: true
|
||||
|
||||
- name: Delete NOTICE.txt
|
||||
run: del ${{ github.workspace }}/NOTICE.txt
|
||||
|
||||
- name: Run backend tests
|
||||
run: yarn backendTests
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ out/
|
|||
scripts/
|
||||
src/
|
||||
test/
|
||||
tools/
|
||||
vscode-extensions-localization-export/
|
||||
vscode-translations-import/
|
||||
**/*.map
|
||||
|
|
|
@ -5,6 +5,7 @@ Features:
|
|||
|
||||
- Add the possibility to open the current build directory in the Explorer [#1451](https://github.com/microsoft/vscode-cmake-tools/issues/1451)
|
||||
- Add support for CMakePresets V7 and V8. [#3549](https://github.com/microsoft/vscode-cmake-tools/issues/3549)
|
||||
- Add support for CMake Language Support natively in this extension. [#3559](https://github.com/microsoft/vscode-cmake-tools/issues/3559)
|
||||
|
||||
Improvements:
|
||||
|
||||
|
|
2165
NOTICE.txt
2165
NOTICE.txt
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/component-detection-manifest.json",
|
||||
"Registrations": [
|
||||
{
|
||||
"Component": {
|
||||
"Type": "git",
|
||||
"git": {
|
||||
"repositoryUrl": "https://github.com/darthwalsh/vs.language.cmake",
|
||||
"commitHash": "25a6749b2dd233233be0ab0ebb1d04d41cef6387"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Component": {
|
||||
"Type": "git",
|
||||
"git": {
|
||||
"repositoryUrl": "https://github.com/Kitware/CMake",
|
||||
"commitHash": "5e984bb35232116a54de7db39788cb162ca7c263"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -12,7 +12,7 @@ Explore the [CMake Tools documentation](README.md)
|
|||
|
||||
## What about CMake language support?
|
||||
|
||||
CMake Tools was created separately from the [CMake extension](https://marketplace.visualstudio.com/items?itemName=twxs.cmake), which provides language coloring and autocompletion support.
|
||||
We support CMake language support natively in the CMake Tools extension.
|
||||
|
||||
## How do I learn about CMake?
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
# This pipeline is designed to foster sharing our text mate grammars.
|
||||
|
||||
parameters:
|
||||
- name: shareGrammars
|
||||
type: boolean
|
||||
default: false
|
||||
values:
|
||||
- true
|
||||
- false
|
||||
- name: shareQuickInfo
|
||||
type: boolean
|
||||
default: false
|
||||
values:
|
||||
- true
|
||||
- false
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
- repository: self
|
||||
clean: true
|
||||
- repository: VS-Platform
|
||||
type: git
|
||||
name: VS-Platform
|
||||
|
||||
# Every time we merge into main, we want to check for changes to code that is shared in other repos and that is synced other places.
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- main
|
||||
pr: none
|
||||
|
||||
pool:
|
||||
name: "AzurePipelines-EO"
|
||||
demands:
|
||||
- ImageOverride -equals AzurePipelinesWindows2022compliant
|
||||
|
||||
name: $(Date:yyMMdd)$(Rev:rrr)
|
||||
|
||||
jobs:
|
||||
- job: Copy_Code_Create_PRs
|
||||
displayName: Copy shared code and create PRs if changes
|
||||
condition: or(${{ parameters.shareGrammars }}, ${{ parameters.shareQuickInfo }})
|
||||
steps:
|
||||
- checkout: self
|
||||
- checkout: VS-Platform
|
||||
- task: UseNode@1
|
||||
displayName: "Use Node 16.18"
|
||||
inputs:
|
||||
version: "16.18"
|
||||
- script: npm install
|
||||
displayName: "npm install"
|
||||
workingDirectory: $(Build.SourcesDirectory)/vscode-cmake-tools/tools/pr-creator
|
||||
- script: npm run build
|
||||
displayName: "npm run build"
|
||||
workingDirectory: $(Build.SourcesDirectory)/vscode-cmake-tools/tools/pr-creator
|
||||
- script: node $(Build.SourcesDirectory)/vscode-cmake-tools/tools/pr-creator/dist/index.js --source-file-location $(grammarSourcePath) --target-repo $(grammarTargetRepo) --target-file-location $(grammarTargetPath)
|
||||
displayName: Grammar - Copy files and Create PR
|
||||
workingDirectory: $(Build.SourcesDirectory)/$(grammarTargetRepo)
|
||||
env:
|
||||
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
|
||||
condition: ${{ parameters.shareGrammars }}
|
||||
- script: node $(Build.SourcesDirectory)/vscode-cmake-tools/tools/pr-creator/dist/index.js --source-file-location $(quickInfoSourcePath) --target-repo $(quickInfoTargetRepo) --target-file-location $(quickInfoTargetPath)
|
||||
displayName: QuickInfo - Copy files and Create PR
|
||||
workingDirectory: $(Build.SourcesDirectory)/$(quickInfoTargetRepo)
|
||||
env:
|
||||
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
|
||||
condition: ${{ parameters.shareQuickInfo }}
|
||||
|
||||
|
43
package.json
43
package.json
|
@ -18,14 +18,16 @@
|
|||
"tools",
|
||||
"build",
|
||||
"c++",
|
||||
"native"
|
||||
"native",
|
||||
"syntaxes"
|
||||
],
|
||||
"engines": {
|
||||
"vscode": "^1.63.0"
|
||||
},
|
||||
"categories": [
|
||||
"Other",
|
||||
"Debuggers"
|
||||
"Debuggers",
|
||||
"Programming Languages"
|
||||
],
|
||||
"galleryBanner": {
|
||||
"color": "#13578c",
|
||||
|
@ -59,10 +61,30 @@
|
|||
"workspaceContains:*/CMakeLists.txt",
|
||||
"workspaceContains:*/*/CMakeLists.txt",
|
||||
"workspaceContains:*/*/*/CMakeLists.txt",
|
||||
"workspaceContains:.vscode/cmake-kits.json"
|
||||
"workspaceContains:.vscode/cmake-kits.json",
|
||||
"onLanguage:cmake"
|
||||
],
|
||||
"main": "./dist/main",
|
||||
"contributes": {
|
||||
"languages": [
|
||||
{
|
||||
"id": "cmake",
|
||||
"extensions": [
|
||||
".cmake"
|
||||
],
|
||||
"filenames": ["CMakeLists.txt"],
|
||||
"aliases": [
|
||||
"CMake"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "cmake-cache",
|
||||
"filenames": ["CMakeCache.txt"],
|
||||
"aliases": [
|
||||
"CMake Cache"
|
||||
]
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
{
|
||||
"command": "cmake.openCMakePresets",
|
||||
|
@ -827,6 +849,18 @@
|
|||
"category": "CMake"
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
{
|
||||
"language": "cmake",
|
||||
"scopeName": "source.cmake",
|
||||
"path": "./syntaxes/CMake.tmLanguage"
|
||||
},
|
||||
{
|
||||
"language": "cmake-cache",
|
||||
"scopeName": "source.cmakecache",
|
||||
"path": "./syntaxes/CMakeCache.tmLanguage"
|
||||
}
|
||||
],
|
||||
"taskDefinitions": [
|
||||
{
|
||||
"type": "cmake",
|
||||
|
@ -3749,8 +3783,5 @@
|
|||
"tsconfig-paths*/json5": "^1.0.2",
|
||||
"minimatch": "^3.0.5"
|
||||
},
|
||||
"extensionPack": [
|
||||
"twxs.cmake"
|
||||
],
|
||||
"packageManager": "yarn@1.22.19"
|
||||
}
|
||||
|
|
|
@ -2324,6 +2324,41 @@ export async function activate(context: vscode.ExtensionContext): Promise<api.CM
|
|||
await vscode.window.showWarningMessage(localize('uninstall.old.cmaketools', 'Please uninstall any older versions of the CMake Tools extension. It is now published by Microsoft starting with version 1.2.0.'));
|
||||
}
|
||||
|
||||
const CMAKE_LANGUAGE = "cmake";
|
||||
|
||||
vscode.languages.setLanguageConfiguration(CMAKE_LANGUAGE, {
|
||||
indentationRules: {
|
||||
// ^(.*\*/)?\s*\}.*$
|
||||
decreaseIndentPattern: /^(.*\*\/)?\s*\}.*$/,
|
||||
// ^.*\{[^}"']*$
|
||||
increaseIndentPattern: /^.*\{[^}"']*$/
|
||||
},
|
||||
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
||||
comments: {
|
||||
lineComment: '#'
|
||||
},
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['(', ')']
|
||||
],
|
||||
|
||||
__electricCharacterSupport: {
|
||||
brackets: [
|
||||
{ tokenType: 'delimiter.curly.ts', open: '{', close: '}', isElectric: true },
|
||||
{ tokenType: 'delimiter.square.ts', open: '[', close: ']', isElectric: true },
|
||||
{ tokenType: 'delimiter.paren.ts', open: '(', close: ')', isElectric: true }
|
||||
]
|
||||
},
|
||||
|
||||
__characterPairSupport: {
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"', notIn: ['string'] }
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
if (vscode.workspace.getConfiguration('cmake').get('showOptionsMovedNotification')) {
|
||||
void vscode.window.showInformationMessage(
|
||||
localize('options.moved.notification.body', "Some status bar options in CMake Tools have now moved to the Project Status View in the CMake Tools sidebar. You can customize your view with the 'cmake.options' property in settings."),
|
||||
|
|
|
@ -0,0 +1,239 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>fileTypes</key>
|
||||
<array>
|
||||
<string>cmake</string>
|
||||
<string>CMakeLists.txt</string>
|
||||
</array>
|
||||
<key>name</key>
|
||||
<string>CMake</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Variables That Describe the System</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:APPLE|BORLAND|(CMAKE_)?(CL_64|COMPILER_2005|HOST_APPLE|HOST_SYSTEM|HOST_SYSTEM_NAME|HOST_SYSTEM_PROCESSOR|HOST_SYSTEM_VERSION|HOST_UNIX|HOST_WIN32|LIBRARY_ARCHITECTURE|LIBRARY_ARCHITECTURE_REGEX|OBJECT_PATH_MAX|SYSTEM|SYSTEM_NAME|SYSTEM_PROCESSOR|SYSTEM_VERSION)|CYGWIN|MSVC|MSVC80|MSVC_IDE|MSVC_VERSION|UNIX|WIN32|XCODE_VERSION|MSVC60|MSVC70|MSVC90|MSVC71)\b</string>
|
||||
<key>name</key>
|
||||
<string>constant.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>cmakeOperators</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:ABSOLUTE|AND|BOOL|CACHE|COMMAND|COMMENT|DEFINED|DOC|EQUAL|EXISTS|EXT|FALSE|GREATER|GREATER_EQUAL|IGNORE|INTERNAL|IN_LIST|IS_ABSOLUTE|IS_DIRECTORY|IS_NEWER_THAN|IS_SYMLINK|LESS|LESS_EQUAL|MATCHES|NAME|NAMES|NAME_WE|NO|NOT|NOTFOUND|OFF|ON|OR|PATH|PATHS|POLICY|PROGRAM|STREQUAL|STRGREATER|STRGREATER_EQUAL|STRING|STRLESS|STRLESS_EQUAL|TARGET|TEST|TRUE|VERSION_EQUAL|VERSION_GREATER|VERSION_GREATER_EQUAL|VERSION_LESS|YES)\b</string>
|
||||
<key>name</key>
|
||||
<string>keyword.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Commands</string>
|
||||
<key>match</key>
|
||||
<string>^\s*\b(?i:add_compile_definitions|add_compile_options|add_custom_command|add_custom_target|add_definitions|add_dependencies|add_executable|add_library|add_link_options|add_subdirectory|add_test|aux_source_directory|build_command|build_name|cmake_host_system_information|cmake_minimum_required|cmake_parse_arguments|cmake_policy|configure_file|create_test_sourcelist|ctest_build|ctest_configure|ctest_coverage|ctest_empty_binary_directory|ctest_memcheck|ctest_read_custom_files|ctest_run_script|ctest_sleep|ctest_start|ctest_submit|ctest_test|ctest_update|ctest_upload|define_property|enable_language|enable_testing|exec_program|execute_process|export|export_library_dependencies|file|find_file|find_library|find_package|find_path|find_program|fltk_wrap_ui|get_cmake_property|get_directory_property|get_filename_component|get_property|get_source_file_property|get_target_property|get_test_property|include|include_directories|include_external_msproject|include_guard|include_regular_expression|install|install_files|install_programs|install_targets|link_directories|link_libraries|list|load_cache|load_command|make_directory|mark_as_advanced|math|message|option|output_required_files|project|qt_wrap_cpp|qt_wrap_ui|remove|remove_definitions|return|separate_arguments|set|set_directory_properties|set_property|set_source_files_properties|set_target_properties|set_tests_properties|site_name|source_group|string|subdir_depends|subdirs|target_compile_definitions|target_compile_features|target_compile_options|target_include_directories|target_link_directories|target_link_libraries|target_link_options|target_sources|try_compile|try_run|unset|use_mangled_mesa|utility_source|variable_requires|variable_watch|write_file)\b</string>
|
||||
<key>name</key>
|
||||
<string>keyword.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Commands</string>
|
||||
<key>match</key>
|
||||
<string>^\s*\b(?i:break|continue|else|elseif|endforeach|endfunction|endif|endmacro|endwhile|foreach|function|if|macro|while)\b</string>
|
||||
<key>name</key>
|
||||
<string>keyword.cmake.control_flow</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Variables That Change Behavior</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:BUILD_SHARED_LIBS|(CMAKE_)?(ABSOLUTE_DESTINATION_FILES|AUTOMOC_RELAXED_MODE|BACKWARDS_COMPATIBILITY|BUILD_TYPE|COLOR_MAKEFILE|CONFIGURATION_TYPES|DEBUG_TARGET_PROPERTIES|DISABLE_FIND_PACKAGE_\w+|FIND_LIBRARY_PREFIXES|FIND_LIBRARY_SUFFIXES|IGNORE_PATH|INCLUDE_PATH|INSTALL_DEFAULT_COMPONENT_NAME|INSTALL_PREFIX|LIBRARY_PATH|MFC_FLAG|MODULE_PATH|NOT_USING_CONFIG_FLAGS|POLICY_DEFAULT_CMP\w+|PREFIX_PATH|PROGRAM_PATH|SKIP_INSTALL_ALL_DEPENDENCY|SYSTEM_IGNORE_PATH|SYSTEM_INCLUDE_PATH|SYSTEM_LIBRARY_PATH|SYSTEM_PREFIX_PATH|SYSTEM_PROGRAM_PATH|USER_MAKE_RULES_OVERRIDE|WARN_ON_ABSOLUTE_INSTALL_DESTINATION))\b</string>
|
||||
<key>name</key>
|
||||
<string>variable.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\$\{\w+\}</string>
|
||||
<key>name</key>
|
||||
<string>storage.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\$ENV\{\w+\}</string>
|
||||
<key>name</key>
|
||||
<string>storage.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\$CACHE\{\w+\}</string>
|
||||
<key>name</key>
|
||||
<string>storage.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Variables that Control the Build</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:(CMAKE_)?(\w+_POSTFIX|ARCHIVE_OUTPUT_DIRECTORY|AUTOMOC|AUTOMOC_MOC_OPTIONS|BUILD_WITH_INSTALL_RPATH|DEBUG_POSTFIX|EXE_LINKER_FLAGS|EXE_LINKER_FLAGS_\w+|Fortran_FORMAT|Fortran_MODULE_DIRECTORY|GNUtoMS|INCLUDE_CURRENT_DIR|INCLUDE_CURRENT_DIR_IN_INTERFACE|INSTALL_NAME_DIR|INSTALL_RPATH|INSTALL_RPATH_USE_LINK_PATH|LIBRARY_OUTPUT_DIRECTORY|LIBRARY_PATH_FLAG|LINK_DEF_FILE_FLAG|LINK_DEPENDS_NO_SHARED|LINK_INTERFACE_LIBRARIES|LINK_LIBRARY_FILE_FLAG|LINK_LIBRARY_FLAG|MACOSX_BUNDLE|NO_BUILTIN_CHRPATH|PDB_OUTPUT_DIRECTORY|POSITION_INDEPENDENT_CODE|RUNTIME_OUTPUT_DIRECTORY|SKIP_BUILD_RPATH|SKIP_INSTALL_RPATH|TRY_COMPILE_CONFIGURATION|USE_RELATIVE_PATHS|WIN32_EXECUTABLE)|EXECUTABLE_OUTPUT_PATH|LIBRARY_OUTPUT_PATH)\b</string>
|
||||
<key>name</key>
|
||||
<string>variable.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Variables that Provide Information</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:CMAKE_(AR|ARGC|ARGV0|BINARY_DIR|BUILD_TOOL|CACHEFILE_DIR|CACHE_MAJOR_VERSION|CACHE_MINOR_VERSION|CACHE_PATCH_VERSION|CFG_INTDIR|COMMAND|CROSSCOMPILING|CTEST_COMMAND|CURRENT_BINARY_DIR|CURRENT_LIST_DIR|CURRENT_LIST_FILE|CURRENT_LIST_LINE|CURRENT_SOURCE_DIR|DL_LIBS|EDIT_COMMAND|EXECUTABLE_SUFFIX|EXTRA_GENERATOR|EXTRA_SHARED_LIBRARY_SUFFIXES|GENERATOR|HOME_DIRECTORY|IMPORT_LIBRARY_PREFIX|IMPORT_LIBRARY_SUFFIX|LINK_LIBRARY_SUFFIX|MAJOR_VERSION|MAKE_PROGRAM|MINOR_VERSION|PARENT_LIST_FILE|PATCH_VERSION|PROJECT_NAME|RANLIB|ROOT|SCRIPT_MODE_FILE|SHARED_LIBRARY_PREFIX|SHARED_LIBRARY_SUFFIX|SHARED_MODULE_PREFIX|SHARED_MODULE_SUFFIX|SIZEOF_VOID_P|SKIP_RPATH|SOURCE_DIR|STANDARD_LIBRARIES|STATIC_LIBRARY_PREFIX|STATIC_LIBRARY_SUFFIX|TWEAK_VERSION|USING_VC_FREE_TOOLS|VERBOSE_MAKEFILE|VERSION)|PROJECT_BINARY_DIR|PROJECT_NAME|PROJECT_SOURCE_DIR|\w+_BINARY_DIR|\w+__SOURCE_DIR)\b</string>
|
||||
<key>name</key>
|
||||
<string>variable.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>BracketArgs</string>
|
||||
<key>begin</key>
|
||||
<string>#\[(=*)\[</string>
|
||||
<key>end</key>
|
||||
<string>\]\1\]</string>
|
||||
<key>name</key>
|
||||
<string>comment.source.cmake</string>
|
||||
</dict>
|
||||
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>BracketArgs</string>
|
||||
<key>begin</key>
|
||||
<string>\[(=*)\[</string>
|
||||
<key>end</key>
|
||||
<string>\]\1\]</string>
|
||||
<key>name</key>
|
||||
<string>argument.source.cmake</string>
|
||||
</dict>
|
||||
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>#+.*$</string>
|
||||
<key>name</key>
|
||||
<string>comment.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Properties on Cache Entries</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:ADVANCED|HELPSTRING|MODIFIED|STRINGS|TYPE|VALUE)\b</string>
|
||||
<key>name</key>
|
||||
<string>entity.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Properties on Source Files</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:ABSTRACT|COMPILE_DEFINITIONS|COMPILE_DEFINITIONS_<CONFIG>|COMPILE_FLAGS|EXTERNAL_OBJECT|Fortran_FORMAT|GENERATED|HEADER_FILE_ONLY|KEEP_EXTENSION|LABELS|LANGUAGE|LOCATION|MACOSX_PACKAGE_LOCATION|OBJECT_DEPENDS|OBJECT_OUTPUTS|SYMBOLIC|WRAP_EXCLUDE)\b</string>
|
||||
<key>name</key>
|
||||
<string>entity.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Properties on Tests</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:ATTACHED_FILES|ATTACHED_FILES_ON_FAIL|COST|DEPENDS|ENVIRONMENT|FAIL_REGULAR_EXPRESSION|LABELS|MEASUREMENT|PASS_REGULAR_EXPRESSION|PROCESSORS|REQUIRED_FILES|RESOURCE_LOCK|RUN_SERIAL|TIMEOUT|WILL_FAIL|WORKING_DIRECTORY)\b</string>
|
||||
<key>name</key>
|
||||
<string>entity.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Properties on Directories</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:ADDITIONAL_MAKE_CLEAN_FILES|CACHE_VARIABLES|CLEAN_NO_CUSTOM|COMPILE_DEFINITIONS|COMPILE_DEFINITIONS_\w+|DEFINITIONS|EXCLUDE_FROM_ALL|IMPLICIT_DEPENDS_INCLUDE_TRANSFORM|INCLUDE_DIRECTORIES|INCLUDE_REGULAR_EXPRESSION|INTERPROCEDURAL_OPTIMIZATION|INTERPROCEDURAL_OPTIMIZATION_\w+|LINK_DIRECTORIES|LISTFILE_STACK|MACROS|PARENT_DIRECTORY|RULE_LAUNCH_COMPILE|RULE_LAUNCH_CUSTOM|RULE_LAUNCH_LINK|TEST_INCLUDE_FILE|VARIABLES|VS_GLOBAL_SECTION_POST_\w+|VS_GLOBAL_SECTION_PRE_\w+)\b</string>
|
||||
<key>name</key>
|
||||
<string>entity.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Properties of Global Scope</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:ALLOW_DUPLICATE_CUSTOM_TARGETS|DEBUG_CONFIGURATIONS|DISABLED_FEATURES|ENABLED_FEATURES|ENABLED_LANGUAGES|FIND_LIBRARY_USE_LIB64_PATHS|FIND_LIBRARY_USE_OPENBSD_VERSIONING|GLOBAL_DEPENDS_DEBUG_MODE|GLOBAL_DEPENDS_NO_CYCLES|IN_TRY_COMPILE|PACKAGES_FOUND|PACKAGES_NOT_FOUND|PREDEFINED_TARGETS_FOLDER|REPORT_UNDEFINED_PROPERTIES|RULE_LAUNCH_COMPILE|RULE_LAUNCH_CUSTOM|RULE_LAUNCH_LINK|RULE_MESSAGES|TARGET_ARCHIVES_MAY_BE_SHARED_LIBS|TARGET_SUPPORTS_SHARED_LIBS|USE_FOLDERS|__CMAKE_DELETE_CACHE_CHANGE_VARS_)\b</string>
|
||||
<key>name</key>
|
||||
<string>entity.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Properties on Targets</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:\w+_(OUTPUT_NAME|POSTFIX)|ARCHIVE_OUTPUT_(DIRECTORY(_\w+)?|NAME(_\w+)?)|AUTOMOC(_MOC_OPTIONS)?|BUILD_WITH_INSTALL_RPATH|BUNDLE|BUNDLE(_EXTENSION)?|COMPATIBLE_INTERFACE_BOOL|COMPATIBLE_INTERFACE_STRING|COMPILE_(DEFINITIONS(_\w+)?|FLAGS)|DEBUG_POSTFIX|DEFINE_SYMBOL|ENABLE_EXPORTS|EXCLUDE_FROM_ALL|EchoString|FOLDER|FRAMEWORK|Fortran_(FORMAT|MODULE_DIRECTORY)|GENERATOR_FILE_NAME|GNUtoMS|HAS_CXX|IMPLICIT_DEPENDS_INCLUDE_TRANSFORM|IMPORTED|IMPORTED_(CONFIGURATIONS|IMPLIB(_\w+)?|LINK_DEPENDENT_LIBRARIES(_\w+)?|LINK_INTERFACE_LANGUAGES(_\w+)?|LINK_INTERFACE_LIBRARIES(_\w+)?|LINK_INTERFACE_MULTIPLICITY(_\w+)?|LOCATION(_\w+)?|NO_SONAME(_\w+)?|SONAME(_\w+)?)|IMPORT_PREFIX|IMPORT_SUFFIX|INSTALL_NAME_DIR|INSTALL_RPATH|INSTALL_RPATH_USE_LINK_PATH|INTERFACE|INTERFACE_COMPILE_DEFINITIONS|INTERFACE_INCLUDE_DIRECTORIES|INTERPROCEDURAL_OPTIMIZATION|INTERPROCEDURAL_OPTIMIZATION_\w+|LABELS|LIBRARY_OUTPUT_DIRECTORY(_\w+)?|LIBRARY_OUTPUT_NAME(_\w+)?|LINKER_LANGUAGE|LINK_DEPENDS|LINK_FLAGS(_\w+)?|LINK_INTERFACE_LIBRARIES(_\w+)?|LINK_INTERFACE_MULTIPLICITY(_\w+)?|LINK_LIBRARIES|LINK_SEARCH_END_STATIC|LINK_SEARCH_START_STATIC|LOCATION(_\w+)?|MACOSX_BUNDLE|MACOSX_BUNDLE_INFO_PLIST|MACOSX_FRAMEWORK_INFO_PLIST|MAP_IMPORTED_CONFIG_\w+|NO_SONAME|OSX_ARCHITECTURES(_\w+)?|OUTPUT_NAME(_\w+)?|PDB_NAME(_\w+)?|POST_INSTALL_SCRIPT|PREFIX|PRE_INSTALL_SCRIPT|PRIVATE|PRIVATE_HEADER|PROJECT_LABEL|PUBLIC|PUBLIC_HEADER|RESOURCE|RULE_LAUNCH_(COMPILE|CUSTOM|LINK)|RUNTIME_OUTPUT_(DIRECTORY(_\w+)?|NAME(_\w+)?)|SKIP_BUILD_RPATH|SOURCES|SOVERSION|STATIC_LIBRARY_FLAGS(_\w+)?|SUFFIX|TYPE|VERSION|VS_DOTNET_REFERENCES|VS_GLOBAL_(\w+|KEYWORD|PROJECT_TYPES)|VS_KEYWORD|VS_SCC_(AUXPATH|LOCALPATH|PROJECTNAME|PROVIDER)|VS_WINRT_EXTENSIONS|VS_WINRT_REFERENCES|WIN32_EXECUTABLE|XCODE_ATTRIBUTE_\w+)\b</string>
|
||||
<key>name</key>
|
||||
<string>entity.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Properties on Commands</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:ALL|APPEND|BOOL|BUILD|BYPRODUCTS|CACHE|CAPTURE_CMAKE_ERROR|CMAKE_FIND_PACKAGE_NAME|CMAKE_FIND_ROOT_PATH_BOTH|CMAKE_FLAGS|COMMAND|COMMAND_EXPAND_LISTS|COMMENT|COMPILE_DEFINITIONS|COMPILE_OUTPUT_VARIABLE|COMPONENT|CONDITION|CONFIGURATION|CONFIGURATIONS|CONTENT|COPY_FILE|COPY_FILE_ERROR|COPYONLY|DEFECT_COUNT|DEPENDS|DEPFILE|DESTINATION|DIRECTORY|DOC|ENCODING|END|ESCAPE_QUOTES|EXCLUDE|EXCLUDE_FIXTURE|EXCLUDE_FIXTURE_CLEANUP|EXCLUDE_FIXTURE_SETUP|EXCLUDE_FROM_ALL|EXCLUDE_LABEL|EXPECTED_HASH|EXPECTED_MD|EXPR|FILEPATH|FILES|FILTER|FIND|FLAGS|GET|GLOBAL|HINTS|HTTPHEADER|IMPLICIT_DEPENDS|INACTIVITY_TIMEOUT|INCLUDE|INCLUDE_LABEL|INPUT|INPUT_FILE|INSERT|INSTALL|INTERNAL|LABELS|LENGTH|LENGTH_MAXIMUM|LENGTH_MINIMUM|LIMIT_COUNT|LIMIT_INPUT|LIMIT_OUTPUT|LINK_LIBRARIES|LOG|MAIN_DEPENDENCY|MD|NAMES|NETRC|NETRC_FILE|NEWLINE_CONSUME|NEWLINE_STYLE|NO_CMAKE_FIND_ROOT_PATH|NO_HEX_CONVERSION|NUMBER_ERRORS|NUMBER_WARNINGS|ONLY_CMAKE_FIND_ROOT_PATH|OPTIONAL|OPTIONS|OUTPUT|OUTPUT_QUIET|OUTPUT_VARIABLE|PACKAGE_FIND_NAME|PACKAGE_VERSION|PARALLEL_LEVEL|PARTS|PATH|PATH_SUFFIXES|PERMISSIONS|PRE_BUILD|PREFIX|PROJECT_NAME|QUIET|REGEX|REGULAR_EXPRESSION|REMOVE_AT|REMOVE_DUPLICATES|RENAME|RESULT_VARIABLE|RESULTS_VARIABLE|RETRY_COUNT|RETRY_DELAY|RETURN_VALUE|REVERSE|RUN_OUTPUT_VARIABLE|SCHEDULE_RANDOM|SHOW_PROGRESS|SORT|SOURCE|SOURCES|START|STATIC|STATUS|STOP_TIME|STRIDE|STRING|TARGET|TEST|TEST_LOAD|TIMEOUT|TLS_CAINFO|TLS_VERIFY|TREE|TYPE|USERPWD|USES_TERMINAL|VARIABLE|VERBATIM|WORKING_DIRECTORY)\b</string>
|
||||
<key>name</key>
|
||||
<string>entity.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Normal Strings</string>
|
||||
<key>begin</key>
|
||||
<string>(?<!\\)"</string>
|
||||
<key>end</key>
|
||||
<string>"</string>
|
||||
<key>name</key>
|
||||
<string>string.source.cmake</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\\(.|$)</string>
|
||||
<key>name</key>
|
||||
<string>constant.character.escape</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\$\{\w+\}</string>
|
||||
<key>name</key>
|
||||
<string>storage.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\$ENV\{\w+\}</string>
|
||||
<key>name</key>
|
||||
<string>storage.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>\$CACHE\{\w+\}</string>
|
||||
<key>name</key>
|
||||
<string>storage.source.cmake</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
|
||||
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Derecated keyword</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:ABSTRACT_FILES|BUILD_NAME|SOURCE_FILES|SOURCE_FILES_REMOVE|VTK_MAKE_INSTANTIATOR|VTK_WRAP_JAVA|VTK_WRAP_PYTHON|VTK_WRAP_TCL|WRAP_EXCLUDE_FILES)\b</string>
|
||||
<key>name</key>
|
||||
<string>invalid.deprecated.source.cmake</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Compiler Flags</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:(CMAKE_)?(CXX_FLAGS|CMAKE_CXX_FLAGS_DEBUG|CMAKE_CXX_FLAGS_MINSIZEREL|CMAKE_CXX_FLAGS_RELEASE|CMAKE_CXX_FLAGS_RELWITHDEBINFO))\b</string>
|
||||
<key>name</key>
|
||||
<string>variable.source.cmake</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>repository</key>
|
||||
|
||||
|
||||
<dict>
|
||||
|
||||
</dict>
|
||||
<key>scopeName</key>
|
||||
<string>source.cmake</string>
|
||||
<key>uuid</key>
|
||||
<string>7aed2d59-22d9-41c8-ba9e-4f178191e380</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>fileTypes</key>
|
||||
<array>
|
||||
<string>CMakeCache.txt</string>
|
||||
</array>
|
||||
<key>name</key>
|
||||
<string>CMake</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>//+.*$|#+.*$</string>
|
||||
<key>name</key>
|
||||
<string>comment.source.cmakecache</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Properties on Cache Entries</string>
|
||||
<key>match</key>
|
||||
<string>\b-ADVANCED\b</string>
|
||||
<key>name</key>
|
||||
<string>entity.source.cmakecache</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Literal values</string>
|
||||
<key>match</key>
|
||||
<string>\b(?i:(YES|NO|ON|OFF|TRUE|FALSE|Y|N|\d+))$</string>
|
||||
<key>name</key>
|
||||
<string>constant.source.cmakecache</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Normal Strings</string>
|
||||
<key>begin</key>
|
||||
<string>=</string>
|
||||
<key>end</key>
|
||||
<string>$</string>
|
||||
<key>name</key>
|
||||
<string>string.source.cmakecache</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Cache Entry Names</string>
|
||||
<key>match</key>
|
||||
<string>^\b(?i:(\w+))\b</string>
|
||||
<key>name</key>
|
||||
<string>variable.source.cmakecache</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>comment</key>
|
||||
<string>Cache Entry Types</string>
|
||||
<key>begin</key>
|
||||
<string>:</string>
|
||||
<key>end</key>
|
||||
<string>=</string>
|
||||
<key>match</key>
|
||||
<string>(BOOL|STRING|FILEPATH|PATH|STATIC|INTERNAL)</string>
|
||||
<key>name</key>
|
||||
<string>keyword.source.cmakecache</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>repository</key>
|
||||
|
||||
|
||||
<dict>
|
||||
|
||||
</dict>
|
||||
<key>scopeName</key>
|
||||
<string>source.cmakecache</string>
|
||||
<key>uuid</key>
|
||||
<string>b545774b-6d11-4f08-bb0a-e64cccc9528c</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,159 @@
|
|||
module.exports = {
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"project": "tsconfig.json",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"@typescript-eslint/tslint",
|
||||
"eslint-plugin-jsdoc",
|
||||
"@typescript-eslint/eslint-plugin-tslint",
|
||||
"eslint-plugin-import",
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/adjacent-overload-signatures": "error",
|
||||
"@typescript-eslint/array-type": "error",
|
||||
"camelcase": "off",
|
||||
"@typescript-eslint/naming-convention": [
|
||||
"error",
|
||||
{
|
||||
"selector": "typeLike",
|
||||
"format": ["PascalCase"]
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/indent": "error",
|
||||
"@typescript-eslint/member-delimiter-style": [
|
||||
"error",
|
||||
{
|
||||
"multiline": {
|
||||
"delimiter": "semi",
|
||||
"requireLast": true
|
||||
},
|
||||
"singleline": {
|
||||
"delimiter": "semi",
|
||||
"requireLast": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-for-in-array": "error",
|
||||
"@typescript-eslint/no-misused-new": "error",
|
||||
"@typescript-eslint/no-misused-promises": "error",
|
||||
//"@typescript-eslint/no-namespace": "error",
|
||||
//"@typescript-eslint/no-non-null-assertion": "error",
|
||||
"@typescript-eslint/no-extra-non-null-assertion": "error",
|
||||
"@typescript-eslint/no-this-alias": "error",
|
||||
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
||||
"@typescript-eslint/no-unnecessary-type-arguments": "error",
|
||||
//"@typescript-eslint/no-var-requires": "error",
|
||||
"@typescript-eslint/prefer-function-type": "error",
|
||||
"@typescript-eslint/prefer-namespace-keyword": "error",
|
||||
"@typescript-eslint/semi": "error",
|
||||
"@typescript-eslint/triple-slash-reference": "error",
|
||||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
//"@typescript-eslint/unified-signatures": "error",
|
||||
"@typescript-eslint/no-floating-promises": "error",
|
||||
"@typescript-eslint/await-thenable": "error",
|
||||
"arrow-body-style": "error",
|
||||
"brace-style": "error",
|
||||
"comma-dangle": "error",
|
||||
"constructor-super": "error",
|
||||
"curly": "error",
|
||||
"eol-last": "error",
|
||||
"eqeqeq": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
//"import/no-default-export": "error",
|
||||
"import/no-unassigned-import": "error",
|
||||
"jsdoc/no-types": "error",
|
||||
"new-parens": "error",
|
||||
"no-bitwise": "error",
|
||||
"no-caller": "error",
|
||||
"no-cond-assign": "error",
|
||||
//"no-debugger": "error",
|
||||
"no-duplicate-case": "error",
|
||||
//"no-duplicate-imports": "error",
|
||||
"no-eval": "error",
|
||||
"no-fallthrough": "error",
|
||||
//"no-invalid-this": "error",
|
||||
"no-irregular-whitespace": "error",
|
||||
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1, "maxBOF": 0 }],
|
||||
"no-new-wrappers": "error",
|
||||
"no-redeclare": "error",
|
||||
"no-return-await": "error",
|
||||
"no-sequences": "error",
|
||||
"no-sparse-arrays": "error",
|
||||
"no-trailing-spaces": "error",
|
||||
"no-undef-init": "error",
|
||||
"no-unsafe-finally": "error",
|
||||
"no-unused-expressions": "off",
|
||||
"no-unused-labels": "error",
|
||||
"no-var": "error",
|
||||
"one-var": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"prefer-const": "error",
|
||||
"prefer-object-spread": "error",
|
||||
"space-in-parens": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
/*"spaced-comment": [
|
||||
"error",
|
||||
"always"
|
||||
],*/
|
||||
"use-isnan": "error",
|
||||
"valid-typeof": "error",
|
||||
"yoda": "error",
|
||||
"@typescript-eslint/tslint/config": [
|
||||
"error",
|
||||
{
|
||||
"rules": {
|
||||
"encoding": true,
|
||||
/*"file-header": [
|
||||
true,
|
||||
".*"
|
||||
],*/
|
||||
"import-spacing": true,
|
||||
"match-default-export-name": true,
|
||||
"no-boolean-literal-compare": true,
|
||||
"no-mergeable-namespace": true,
|
||||
"no-reference-import": true,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"number-literal-format": true,
|
||||
"one-line": [
|
||||
true,
|
||||
"check-catch",
|
||||
"check-finally",
|
||||
"check-else",
|
||||
"check-open-brace",
|
||||
"check-whitespace"
|
||||
],
|
||||
"prefer-method-signature": true,
|
||||
"prefer-while": true,
|
||||
/*"typedef": [
|
||||
true,
|
||||
"variable-declaration",
|
||||
"call-signature",
|
||||
"variable-declaration-ignore-function"
|
||||
],*/
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-operator",
|
||||
"check-separator",
|
||||
"check-preblock",
|
||||
"check-type"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "pr-creator",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "tsc -p ./",
|
||||
"clean": "rimraf ./dist",
|
||||
"lint": "eslint src --ext ts --max-warnings 0"
|
||||
},
|
||||
"dependencies": {
|
||||
"azure-devops-node-api": "~11.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.7",
|
||||
"eslint": "^8.25.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.8.4",
|
||||
"commander": "^12.0.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,321 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
|
||||
import { getPersonalAccessTokenHandler, WebApi } from "azure-devops-node-api";
|
||||
import { IGitApi } from "azure-devops-node-api/GitApi";
|
||||
import {
|
||||
GitPullRequest,
|
||||
GitRepository,
|
||||
PullRequestStatus
|
||||
} from "azure-devops-node-api/interfaces/GitInterfaces";
|
||||
import * as cp from "child_process";
|
||||
import { randomBytes } from "crypto";
|
||||
import * as path from "path";
|
||||
import { program } from "commander";
|
||||
|
||||
function assertNotNull<T>(
|
||||
x: T,
|
||||
msg: string = ""
|
||||
): asserts x is Exclude<T, null | undefined> {
|
||||
if (x === null || x === undefined) {
|
||||
throw new Error(`Assert failed: unexpected null. ${msg}`);
|
||||
}
|
||||
}
|
||||
|
||||
type Possibly<T> = T | undefined;
|
||||
|
||||
const repoRoot: string = path.resolve(__dirname, "..", "..", "..");
|
||||
const parentRoot: string = path.resolve(repoRoot, "..");
|
||||
const sourceRepo: string = "vscode-cmake-tools";
|
||||
|
||||
interface Settings {
|
||||
orgUrl: string;
|
||||
project: string;
|
||||
repo: string;
|
||||
sourceBranch: string;
|
||||
targetBranch: string;
|
||||
targetLocation: string;
|
||||
token: string;
|
||||
username: string;
|
||||
email: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
// Security token is automatically created for each CI run:
|
||||
// https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#systemaccesstoken
|
||||
// For local testing, set the environment variable to a PAT with write access
|
||||
// https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page#use-a-pat
|
||||
function gitAuthHeader(token: string, redact?: boolean): string {
|
||||
const encodedPat = redact
|
||||
? "**********"
|
||||
: Buffer.from(`:${token}`).toString("base64");
|
||||
return `http.extraHeader="Authorization: Basic ${encodedPat}"`;
|
||||
}
|
||||
|
||||
export function gitExtraArgs(
|
||||
username: string,
|
||||
email: string,
|
||||
token?: string,
|
||||
redact?: boolean
|
||||
): string {
|
||||
const args = [`-c user.email="${email}"`, `-c user.name="${username}"`];
|
||||
if (token) {
|
||||
args.push(`-c ${gitAuthHeader(token, redact)}`);
|
||||
}
|
||||
return args.join(" ");
|
||||
}
|
||||
|
||||
class Session {
|
||||
private api: Possibly<WebApi>;
|
||||
private git: Possibly<IGitApi>;
|
||||
private initialized: boolean = false;
|
||||
|
||||
public constructor(private readonly settings: Settings) {}
|
||||
|
||||
private async getWebApi(): Promise<WebApi> {
|
||||
const authHandler = getPersonalAccessTokenHandler(this.settings.token);
|
||||
return new WebApi(this.settings.orgUrl, authHandler);
|
||||
}
|
||||
|
||||
private async init(): Promise<void> {
|
||||
if (this.initialized) {
|
||||
console.warn("Already initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
this.initialized = true;
|
||||
this.api = await this.getWebApi();
|
||||
this.git = await this.api.getGitApi();
|
||||
}
|
||||
|
||||
private async getRepos(): Promise<GitRepository[]> {
|
||||
assertNotNull(this.git);
|
||||
return this.git.getRepositories(this.settings.project);
|
||||
}
|
||||
|
||||
private async getTargetRepo(): Promise<GitRepository> {
|
||||
const repo = (await this.getRepos()).find(
|
||||
(repo) => repo.name === this.settings.repo
|
||||
);
|
||||
assertNotNull(repo);
|
||||
return repo;
|
||||
}
|
||||
|
||||
private getRemoteUrl(): string {
|
||||
const { orgUrl, project, repo } = this.settings;
|
||||
return `${orgUrl}/${project}/_git/${repo}`;
|
||||
}
|
||||
|
||||
private runGit(command: string, withAuth: boolean = false): string {
|
||||
const redactedCliString = `git ${gitExtraArgs(
|
||||
this.settings.username,
|
||||
this.settings.email,
|
||||
withAuth ? this.settings.token : "",
|
||||
true
|
||||
)} ${command}`;
|
||||
console.log(redactedCliString);
|
||||
|
||||
const cliString = `git ${gitExtraArgs(
|
||||
this.settings.username,
|
||||
this.settings.email,
|
||||
withAuth ? this.settings.token : ""
|
||||
)} ${command}`;
|
||||
const result = cp.execSync(cliString).toString("utf8");
|
||||
console.log(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private sourceBranchAlreadyExists(): boolean {
|
||||
try {
|
||||
this.runGit(
|
||||
`show-ref --verify --quiet refs/heads/${this.settings.sourceBranch}`
|
||||
);
|
||||
} catch (error) {
|
||||
// --verify returns error code 1 when branch exists
|
||||
return (error as { status: number }).status !== 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Adapted from
|
||||
// https://github.com/microsoft/vscode-cmake-tools/blob/a057e5ceb3ce2f98c01f6eb8117d098101f5f234/translations_auto_pr.js#L56
|
||||
private hasStagedChanges(): boolean {
|
||||
console.log("Checking if any files have changed");
|
||||
const output = this.runGit("diff --staged --name-only");
|
||||
const lines = output.toString().split("\n");
|
||||
let anyChanges = false;
|
||||
lines.forEach((line) => {
|
||||
if (line !== "") {
|
||||
console.log("Change detected: " + line);
|
||||
anyChanges = true;
|
||||
}
|
||||
});
|
||||
|
||||
return anyChanges;
|
||||
}
|
||||
|
||||
private prepareSourceBranch(): void {
|
||||
if (this.sourceBranchAlreadyExists()) {
|
||||
throw new Error(
|
||||
`Source branch ${this.settings.sourceBranch} already exists`
|
||||
);
|
||||
}
|
||||
|
||||
// remember original branch
|
||||
const origBranch = this.runGit(`rev-parse --abbrev-ref HEAD`).trim();
|
||||
try {
|
||||
// create source branch
|
||||
this.runGit(`checkout -b ${this.settings.sourceBranch}`);
|
||||
|
||||
// add all modified files in target location
|
||||
this.runGit(`add ${this.settings.targetLocation}`);
|
||||
|
||||
// if no changes were detected, then there are no new updates.
|
||||
if (!this.hasStagedChanges()) {
|
||||
throw new Error("No staged changes detected");
|
||||
}
|
||||
|
||||
// commit changes
|
||||
this.runGit(`commit -m "${this.settings.title}"`);
|
||||
|
||||
// add remote (remove if it already exists)
|
||||
this.runGit(`remote add target ${this.getRemoteUrl()}`);
|
||||
|
||||
// push source branch to remote
|
||||
this.runGit(`push target ${this.settings.sourceBranch}`, true);
|
||||
} finally {
|
||||
// restore original commit ID
|
||||
this.runGit(`checkout ${origBranch}`);
|
||||
}
|
||||
}
|
||||
|
||||
private async activePullRequestExists(): Promise<boolean> {
|
||||
assertNotNull(this.git);
|
||||
const repoId = (await this.getTargetRepo()).id;
|
||||
assertNotNull(repoId);
|
||||
const pullRequests = await this.git.getPullRequests(repoId, {
|
||||
status: PullRequestStatus.Active
|
||||
});
|
||||
return pullRequests.some((pr) => pr.title?.startsWith(this.settings.title.split(" ")[0]));
|
||||
}
|
||||
|
||||
private async publishPullRequest(): Promise<void> {
|
||||
const request: GitPullRequest = {
|
||||
sourceRefName: `refs/heads/${this.settings.sourceBranch}`,
|
||||
targetRefName: `refs/heads/${this.settings.targetBranch}`,
|
||||
title: this.settings.title,
|
||||
description: "An automatic PR to share code between the CMake Tools repository and the target repo."
|
||||
};
|
||||
assertNotNull(this.git);
|
||||
const repoId = (await this.getTargetRepo()).id;
|
||||
assertNotNull(repoId);
|
||||
console.log("Creating Pull Request", request, repoId);
|
||||
const response = await this.git.createPullRequest(request, repoId);
|
||||
|
||||
// Use the createdBy field in the response as the id of the autocompleter
|
||||
// https://developercommunity.visualstudio.com/t/how-to-get-identityref-for-the-current-user-or-arb/1129979#T-N1132219
|
||||
const createdBy = response.createdBy;
|
||||
const pullRequestId = response.pullRequestId;
|
||||
assertNotNull(
|
||||
createdBy,
|
||||
"Response is missing expected property: createdBy"
|
||||
);
|
||||
assertNotNull(
|
||||
pullRequestId,
|
||||
"Response is missing expected property: pullRequestId"
|
||||
);
|
||||
await this.git.updatePullRequest(
|
||||
{ autoCompleteSetBy: createdBy },
|
||||
repoId,
|
||||
pullRequestId
|
||||
);
|
||||
}
|
||||
|
||||
private cleanup(): void {
|
||||
try {
|
||||
// remove source branch
|
||||
this.runGit(`branch -D ${this.settings.sourceBranch}`);
|
||||
} catch (error) {
|
||||
// ok if the branch doesn't exist
|
||||
}
|
||||
try {
|
||||
// remove remote
|
||||
this.runGit(`remote remove target`);
|
||||
} catch (error) {
|
||||
// ok if the remote doesn't exist
|
||||
}
|
||||
}
|
||||
|
||||
public async run(): Promise<void> {
|
||||
try {
|
||||
await this.init();
|
||||
if (await this.activePullRequestExists()) {
|
||||
console.warn(
|
||||
"An active pull request already exists, exiting."
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.prepareSourceBranch();
|
||||
await this.publishPullRequest();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
this.cleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function createPullRequest(settings: Settings): void {
|
||||
void new Session(settings).run();
|
||||
}
|
||||
|
||||
export function copyFiles(sourceLocation: string, targetRepo: string, targetLocation: string): void {
|
||||
// Copy files from source to target location
|
||||
const absoluteSourceLocation = path.resolve(parentRoot, `${sourceRepo}/${sourceLocation}/*`);
|
||||
const absoluteTargetLocation = path.resolve(parentRoot, `${targetRepo}/${targetLocation}`);
|
||||
console.log(absoluteSourceLocation);
|
||||
console.log(absoluteTargetLocation);
|
||||
cp.execSync(`copy ${absoluteSourceLocation} ${absoluteTargetLocation}`);
|
||||
console.log(`Copying files from ${absoluteSourceLocation} to ${absoluteTargetLocation}`);
|
||||
}
|
||||
|
||||
program.description("Create a pull request in the desired location.");
|
||||
|
||||
program.requiredOption("--source-file-location <source-file-location>", "The source file location. Relative path from the root of the repository.")
|
||||
.requiredOption("--target-repo <target-repo>", "The target repository.")
|
||||
.requiredOption("--target-file-location <target-file-location>", "The target file location. Relative path from the root of the repository.")
|
||||
.parse(process.argv);
|
||||
|
||||
const options = program.opts();
|
||||
|
||||
if (options.sourceFileLocation && options.targetRepo && options.targetFileLocation) {
|
||||
copyFiles(options.sourceFileLocation, options.targetRepo, options.targetFileLocation);
|
||||
|
||||
assertNotNull(process.env.SYSTEM_ACCESSTOKEN);
|
||||
assertNotNull(process.env.USERNAME);
|
||||
assertNotNull(process.env.EMAIL);
|
||||
assertNotNull(process.env.ORGURL);
|
||||
assertNotNull(process.env.SYSTEM_TEAMPROJECT);
|
||||
|
||||
const buildIdentifier: string = process.env.BUILD_BUILDNUMBER
|
||||
? // For CI, we use the build number
|
||||
process.env.BUILD_BUILDNUMBER
|
||||
: // For local testing, we use "localtest-<4 bytes of random hex>"
|
||||
`localtest-${randomBytes(4).toString("hex")}`;
|
||||
|
||||
const prTitlePrefix: string = "[Updating code from vscode-cmake-tools]";
|
||||
|
||||
const settings: Settings = {
|
||||
orgUrl: process.env.ORGURL,
|
||||
project: process.env.SYSTEM_TEAMPROJECT,
|
||||
repo: options.targetRepo,
|
||||
sourceBranch: `create-pr/${buildIdentifier}`,
|
||||
targetBranch: "main",
|
||||
targetLocation: options.targetFileLocation,
|
||||
token: process.env.SYSTEM_ACCESSTOKEN || "",
|
||||
username: process.env.USERNAME,
|
||||
email: process.env.EMAIL,
|
||||
title: `${prTitlePrefix} ${buildIdentifier}`
|
||||
};
|
||||
|
||||
createPullRequest(settings);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@
|
|||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"tools",
|
||||
".vscode-test",
|
||||
]
|
||||
}
|
Загрузка…
Ссылка в новой задаче