This commit is contained in:
Vic Perdana 2021-10-01 20:31:17 +10:00
Родитель 530b4d25af
Коммит c24b197551
36 изменённых файлов: 3029 добавлений и 372 удалений

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

@ -0,0 +1,133 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Azure DevOps
# CI pipeline for PSDocs-vscode
variables:
version: '1'
# Use build number format, i.e. 2021.5.10
name: $(Year:yyyy).$(Month).$(rev:r)
trigger:
branches:
include:
- 'main'
- 'release/*'
tags:
include:
- 'v1.*'
pr:
branches:
include:
- 'main'
- 'release/*'
stages:
# Build pipeline
- stage: Build
displayName: Build
dependsOn: []
jobs:
- template: jobs/build-channel.yaml
parameters:
channel: preview
- template: jobs/build-channel.yaml
parameters:
channel: stable
# Test pipeline
- stage: Test
dependsOn: [ 'Build' ]
jobs:
- template: jobs/test.yaml
parameters:
name: macOS_10_15
displayName: 'PowerShell 7.1 - macOS-10.15'
imageName: 'macOS-10.15'
channel: preview
- template: jobs/test.yaml
parameters:
name: windows
displayName: 'PowerShell 5.1 - win2016'
imageName: 'vs2017-win2016'
channel: preview
- template: jobs/test.yaml
parameters:
name: windows_2019
displayName: 'PowerShell 7.1 - Windows 2019'
imageName: 'windows-2019'
channel: preview
- template: jobs/test.yaml
parameters:
name: ubuntu_20_04
displayName: 'PowerShell 7.1 - ubuntu-20.04'
imageName: 'ubuntu-20.04'
channel: preview
# Analysis pipeline
- stage: Analysis
displayName: Analysis
dependsOn: []
variables:
# Already done in build
skipComponentGovernanceDetection: true
jobs:
- job: Secret_Scan
pool: 'Hosted VS2017'
displayName: Secret scan
steps:
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
displayName: 'Scan for secrets'
inputs:
debugMode: false
toolMajorVersion: V2
- task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2
displayName: 'Publish scan logs'
continueOnError: true
- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@1
displayName: 'Check for failures'
inputs:
CredScan: true
ToolLogsNotFoundAction: Error
# Release pipeline
- stage: Preview
displayName: Preview
dependsOn: [ 'Build', 'Analysis', 'Test' ]
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
jobs:
- template: jobs/publish-channel.yaml
parameters:
channel: preview
- job: update_github_release
displayName: Update GitHub release
pool:
vmImage: 'ubuntu-20.04'
steps:
# Update GitHub release
- task: GitHubRelease@0
displayName: 'GitHub release'
inputs:
gitHubConnection: 'AzureDevOps-PSDocs-vscode'
repositoryName: '$(Build.Repository.Name)'
action: edit
tag: '$(Build.SourceBranchName)'
releaseNotesSource: input
releaseNotes: 'See [change log](https://github.com/Microsoft/PSDocs-vscode/blob/main/CHANGELOG.md)'
assetUploadMode: replace
addChangeLog: false
isPreRelease: false

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

@ -0,0 +1,37 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Notes:
# Builds Visual Studio Code extension for a release channel.
parameters:
- name: channel
type: string
- name: buildConfiguration
type: string
default: 'Release'
- name: vmImage
type: string
default: 'ubuntu-20.04'
jobs:
- job: 'build_${{ parameters.channel }}'
displayName: 'Build ${{ parameters.channel }}'
pool:
vmImage: '${{ parameters.vmImage }}'
steps:
# Install pipeline dependencies
- powershell: ./.azure-pipelines/pipeline-deps.ps1
displayName: 'Install dependencies'
# Build extension
- powershell: Invoke-Build -Configuration '${{ parameters.buildConfiguration }}' -Build $(Build.BuildNumber) -Channel '${{ parameters.channel }}'
displayName: 'Build extension'
# Generate artifacts
- task: PublishPipelineArtifact@0
displayName: 'Publish extension'
inputs:
artifactName: 'extension-${{ parameters.channel }}'
targetPath: out/package

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

@ -0,0 +1,37 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Notes:
# Publish Visual Studio Code extension for a release channel.
parameters:
- name: channel
type: string
- name: buildConfiguration
type: string
default: 'Release'
- name: vmImage
type: string
default: 'ubuntu-20.04'
jobs:
- job: 'publish_${{ parameters.channel }}'
displayName: 'Publish ${{ parameters.channel }}'
pool:
vmImage: '${{ parameters.vmImage }}'
steps:
# Download extension
- task: DownloadPipelineArtifact@1
displayName: 'Download extension'
inputs:
artifactName: 'extension-${{ parameters.channel }}'
downloadPath: $(Build.SourcesDirectory)/out/package
# Install pipeline dependencies
- powershell: ./.azure-pipelines/pipeline-deps.ps1
displayName: 'Install dependencies'
# Install pipeline dependencies and build module
- powershell: Invoke-Build Release -ApiKey $(apiKey) -Channel ${{ parameters.channel }}
displayName: 'Publish extension'

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

@ -0,0 +1,52 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Notes:
# Test Visual Studio Code extension.
parameters:
- name: name
type: string
- name: displayName
type: string
- name: channel
type: string
- name: buildConfiguration
type: string
default: 'Release'
- name: imageName
type: string
jobs:
- job: '${{ parameters.name }}'
displayName: '${{ parameters.displayName }}'
pool:
vmImage: '${{ parameters.imageName }}'
variables:
skipComponentGovernanceDetection: true
steps:
- bash: |
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
echo ">>> Started xvfb"
displayName: Start xvfb
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
# Install pipeline dependencies
- powershell: ./.azure-pipelines/pipeline-deps.ps1
displayName: 'Install dependencies'
# Download module
- task: DownloadPipelineArtifact@2
displayName: 'Download extension'
inputs:
artifact: 'extension-${{ parameters.channel }}'
path: $(Build.SourcesDirectory)/out/package
# Run tests
- powershell: |-
npm install
npm test
displayName: 'Test extension'
env:
DISPLAY: ':99.0'

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

@ -0,0 +1,59 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Notes:
# Test Visual Studio Code extension.
parameters:
- name: name
type: string
- name: displayName
type: string
- name: channel
type: string
- name: buildConfiguration
type: string
default: 'Release'
- name: vmImage
type: string
default: 'ubuntu-20.04'
- name: imageName
type: string
- name: imageTag
type: string
jobs:
- job: ${{ parameters.name }}
displayName: ${{ parameters.displayName }}
pool:
vmImage: ${{ parameters.vmImage }}
container:
image: '${{ parameters.imageName }}:${{ parameters.imageTag }}'
variables:
skipComponentGovernanceDetection: true
steps:
- bash: |
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
echo ">>> Started xvfb"
displayName: Start xvfb
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
# Install pipeline dependencies
- powershell: ./.azure-pipelines/pipeline-deps.ps1
displayName: 'Install dependencies'
# Download module
- task: DownloadPipelineArtifact@2
displayName: 'Download extension'
inputs:
artifact: 'extension-${{ parameters.channel }}'
path: $(Build.SourcesDirectory)/out/package
# Run tests
- powershell: |-
npm install
npm test
displayName: 'Test extension'
env:
DISPLAY: ':99.0'

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

@ -0,0 +1,22 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# Install dependencies for integration with Azure DevOps
#
if ($Env:SYSTEM_DEBUG -eq 'true') {
$VerbosePreference = 'Continue';
}
if ($Null -eq (Get-PackageProvider -Name NuGet -ErrorAction Ignore)) {
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser;
}
if ($Null -eq (Get-InstalledModule -Name PowerShellGet -MinimumVersion 2.1.2 -ErrorAction Ignore)) {
Install-Module PowerShellGet -MinimumVersion 2.1.2 -Scope CurrentUser -Force -AllowClobber;
}
if ($Null -eq (Get-InstalledModule -Name InvokeBuild -MinimumVersion 5.4.0 -ErrorAction Ignore)) {
Install-Module InvokeBuild -MinimumVersion 5.4.0 -Scope CurrentUser -Force;
}

24
.eslintrc.json Normal file
Просмотреть файл

@ -0,0 +1,24 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
},
"ignorePatterns": [
"out",
"dist",
"**/*.d.ts"
]
}

44
.github/ISSUE_TEMPLATE/bug_report.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,44 @@
---
name: Bug report
about: Report errors or an unexpected issue
---
**Description of the issue**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the issue:
```powershell
```
**Expected behaviour**
A clear and concise description of what you expected to happen.
**Error output**
Capture any error messages and or terminal output.
```text
```
**Extension version:**
- Version: **[e.g. 1.0.0]**
**PSRule module version:**
Captured output from `Get-InstalledModule PSRule | Format-List Name,Version`:
```text
```
**Additional context**
Add any other context about the problem here.

20
.github/ISSUE_TEMPLATE/feature_request.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

355
.gitignore поставляемый
Просмотреть файл

@ -1,350 +1,5 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
out
dist
node_modules
.vscode-test/
*.vsix

8
.vscode/extensions.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,8 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"ms-vscode.vscode-typescript-tslint-plugin",
"esbenp.prettier-vscode"
]
}

35
.vscode/launch.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,35 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}

40
.vscode/settings.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,40 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
//"powershell.integratedConsole.suppressStartupBanner": true,
//"terminal.integrated.automationShell.windows": "cmd.exe"
"files.associations": {
"**/.azure-pipelines/*.yaml": "azure-pipelines",
"**/.azure-pipelines/jobs/*.yaml": "azure-pipelines"
},
"editor.insertSpaces": true,
"editor.tabSize": 4,
"[yaml]": {
"editor.tabSize": 2
},
"[markdown]": {
"editor.tabSize": 2
},
"[json]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"cSpell.words": [
"pwsh"
]
}

31
.vscode/tasks.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,31 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Compile",
"type": "npm",
"script": "compile",
"presentation": {
"focus": false,
"panel": "dedicated",
"clear": true
},
"problemMatcher": ["$tsc"]
}
]
}

12
.vscodeignore Normal file
Просмотреть файл

@ -0,0 +1,12 @@
.vscode/**
.vscode-test/**
out/test/**
src/**
.gitignore
.yarnrc
vsc-extension-quickstart.md
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts

15
CHANGELOG.md Normal file
Просмотреть файл

@ -0,0 +1,15 @@
# Change log
All notable changes to this extension will be documented in this file.
This extension is available in two release channels for Visual Studio Code from the Visual Studio Marketplace.
- Uses [semantic versioning](http://semver.org/) to declare changes.
Continue reading to see the changes included in the latest version.
## Unreleased
## v0.0.1
- Initial preview release.
https://marketplace.visualstudio.com/items?itemName=viperdan.psdocs-vscode

103
CONTRIBUTING.md Normal file
Просмотреть файл

@ -0,0 +1,103 @@
# Contributing to PSDocs.Azure VSCode Extension
Welcome, and thank you for your interest in contributing to PSDocs!
There are many ways in which you can contribute, beyond writing code.
The goal of this document is to provide a high-level overview of how you can get involved.
- [Reporting issues](#reporting-issues)
- Fix bugs or add features
## Contributor License Agreement (CLA)
This project welcomes contributions and suggestions. Most contributions require you to
agree to a Contributor License Agreement (CLA) declaring that you have the right to,
and actually do, grant us the rights to use your contribution. For details, visit
https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need
to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the
instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
## Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
## Reporting issues
Have you identified a reproducible problem?
Have a feature request?
We want to hear about it!
Here's how you can make reporting your issue as effective as possible.
### Look for an existing issue
Before you create a new issue, please do a search in [open issues][issues] to see if the issue or feature request has already been filed.
If you find your issue already exists,
make relevant comments and add your [reaction](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments).
Use a reaction in place of a "+1" comment:
* 👍 - upvote
## Contributing to code
- Before writing a fix or feature enhancement, ensure that an issue is logged.
- Be prepared to discuss a feature and take feedback.
- Include unit tests and updates documentation to complement the change.
When you are ready to contribute a fix or feature:
- Start by [forking the PSDocs-vscode][github-fork].
- Create a new branch from main in your fork.
- Add commits in your branch.
- If you have updated module code or rules also update `CHANGELOG.md`.
- You don't need to update the `CHANGELOG.md` for changes to unit tests or documentation.
- Try building your changes locally. See [building from source][build] for instructions.
- [Create a pull request][github-pr-create] to merge changes into the PSDocs `main` branch.
- If you are _ready_ for your changes to be reviewed create a _pull request_.
- If you are _not ready_ for your changes to be reviewed, create a _draft pull request_.
- An continuous integration (CI) process will automatically build your changes.
- You changes must build successfully to be merged.
- If you have any build errors, push new commits to your branch.
- Avoid using forced pushes or squashing changes while in review, as this makes reviewing your changes harder.
### Intro to Git and GitHub
When contributing to documentation or code changes, you'll need to have a GitHub account and a basic understanding of Git.
Check out the links below to get started.
- Make sure you have a [GitHub account][github-signup].
- GitHub Help:
- [Git and GitHub learning resources][learn-git].
- [GitHub Flow Guide][github-flow].
- [Fork a repo][github-fork].
- [About Pull Requests][github-pr].
### Code editor
You should use the multi-platform [Visual Studio Code][vscode] (VS Code).
The project contains a number of workspace specific settings that make it easier to author consistently.
### Building and testing
When creating a pull request to merge your changes, a continuous integration (CI) pipeline is run.
The CI pipeline will build then test your changes across MacOS, Linux and Windows configurations.
Before opening a pull request try building your changes locally.
## Thank You!
Your contributions to open source, large or small, make great projects like this possible.
Thank you for taking the time to contribute.
[learn-git]: https://help.github.com/en/articles/git-and-github-learning-resources
[github-flow]: https://guides.github.com/introduction/flow/
[github-signup]: https://github.com/signup/free
[github-fork]: https://help.github.com/en/github/getting-started-with-github/fork-a-repo
[github-pr]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests
[github-pr-create]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork
[vscode]: https://code.visualstudio.com/
[issues]: https://github.com/Microsoft/PSDocs-vscode/issues

105
README.md
Просмотреть файл

@ -1,33 +1,94 @@
# Project
# PSDocs.Azure
> This repo has been populated by an initial template to help get you started. Please
> make sure to update the content to build a great experience for community-building.
Generate documentation from Infrastructure as Code (IaC). PSDocs for Azure automatically generates documentation for Azure infrastructure as code (IaC) artifacts.
As the maintainer of this project, please make a few updates:
Please review the [Requirements](#Requirements) to ensure you can use this extension successfully.
- Improving this README.MD file to provide a great experience
- Updating SUPPORT.MD with content about this project's support experience
- Understanding the security reporting process in SECURITY.MD
- Remove this section from the README
Note: this extension is in preview release.
## Features
### Command Palette
You can generate markdown files directly from an ARM template through the Command Pallette. Simply press `Ctrl+Shift+P` and type in `PSDocs.Azure: Generate Markdown`
![Generate Markdown](images/cmd-a.png)
You will first be asked to provide a full path to the ARM template. The prompt auto-populates with the full path of the currently opened file.
![Provide full path to the ARM template file](images/cmd-b.png)
Additionally, you will be asked to provide a relative path (from the ARM template) to store the generated markdown.
![Provide destination relative path where markdown will be created](images/cmd-c.png)
The markdown will be created in the folder relative to the the ARM template file.
### Snippets
Adds snippets for adding metadata tag within ARM templates.
* `psdocs-arm` can be used to add metadata at the template root schema
* `psdocs-arm-short` can be used to add metadata anywhere else e.g. parameters or variables
![PSDocs.Azure Template](images/snippet-arm.gif)
![PSDocs.Azure Template](images/snippet-arm-short.gif)
## Requirements
PSDocs.Azure is required for this extension to work.
To install the module use the following command from a PowerShell prompt.
```powershell
Install-Module -Name PSDocs.Azure -Scope CurrentUser;
```
## Known Issues and Limitations
* The extension is in preview and therefore has not undergone extended testing scenarios.
* Only one markdown can be generated at one time.
* A separate directory should be used to avoid overriding the Generated Markdown --> README.md file.
* Additional PSDocs.Azure [configuration](https://github.com/Azure/PSDocs.Azure/blob/main/docs/concepts/en-US/about_PSDocs_Azure_Configuration.md) is not supported at this time.
## Release Notes
Refer to [CHANGELOG](CHANGELOG.md)
## Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
This project welcomes contributions and suggestions.
If you are ready to contribute, please visit the [contribution guide].
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
## Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
## Maintainers
- [Vic Perdana](https://github.com/VicPerdana)
- [Bernie White](https://github.com/BernieWhite)
## License
This project is [licensed under the MIT License][license].
[issue]: https://github.com/Microsoft/PSDocs-vscode/issues
[discussion]: https://github.com/microsoft/PSDocs-vscode/discussions
[ci-badge]: https://dev.azure.com/viperdan/PSDocs-vscode/_apis/build/status/PSDocs-vscode-CI?branchName=main
[vscode-ext-gallery]: https://code.visualstudio.com/docs/editor/extension-gallery
[ext-preview]: https://marketplace.visualstudio.com/items?itemName=viperdan.PSDocs-vscode-preview
[ext-preview-version-badge]: https://vsmarketplacebadge.apphb.com/version/viperdan.PSDocs-vscode-preview.svg
[ext-preview-installs-badge]: https://vsmarketplacebadge.apphb.com/installs-short/viperdan.PSDocs-vscode-preview.svg
[ext-stable]: https://marketplace.visualstudio.com/items?itemName=viperdan.PSDocs-vscode
[ext-stable-version-badge]: https://vsmarketplacebadge.apphb.com/version/viperdan.PSDocs-vscode.svg
[ext-stable-installs-badge]: https://vsmarketplacebadge.apphb.com/installs-short/viperdan.PSDocs-vscode.svg
[module-version-badge]: https://img.shields.io/powershellgallery/v/PSDocs.svg?label=PowerShell%20Gallery&color=brightgreen
[contribution guide]: https://github.com/Microsoft/PSDocs-vscode/blob/main/CONTRIBUTING.md
[change log]: https://github.com/Microsoft/PSDocs-vscode/blob/main/CHANGELOG.md
[license]: https://github.com/Microsoft/PSDocs-vscode/blob/main/LICENSE
[ps-rule.yaml]: https://microsoft.github.io/PSDocs/concepts/PSDocs/en-US/about_PSDocs_Options.html
## Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.

Двоичные данные
images/cmd-a.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.1 KiB

Двоичные данные
images/cmd-b.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.5 KiB

Двоичные данные
images/cmd-c.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.7 KiB

Двоичные данные
images/psdocs-icon.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичные данные
images/snippet-arm-a.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.2 KiB

Двоичные данные
images/snippet-arm-b.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 8.2 KiB

Двоичные данные
images/snippet-arm-short-a.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.4 KiB

Двоичные данные
images/snippet-arm-short-b.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 11 KiB

Двоичные данные
images/snippet-arm-short.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 22 KiB

Двоичные данные
images/snippet-arm.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 29 KiB

2018
package-lock.json сгенерированный Normal file

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

76
package.json Normal file
Просмотреть файл

@ -0,0 +1,76 @@
{
"name": "psdocs-vscode",
"displayName": "PSDocs (Preview)",
"publisher": "viperdan",
"description": "Generate Markdown from ARM templates using PSDocs.Azure",
"author": {
"name": "Vic Perdana"
},
"version": "0.0.1",
"engines": {
"vscode": "^1.58.0"
},
"license": "SEE LICENSE IN LICENSE",
"categories": [
"Programming Languages",
"Snippets"
],
"keywords": [
"Azure Template",
"Azure",
"ARM",
"Resource Manager",
"PSDocs.Azure"
],
"galleryBanner": {
"color": "#0072c6",
"theme": "dark"
},
"icon": "images/psdocs-icon.png",
"activationEvents": [
"onCommand:viperdan.psdocs-vscode"
],
"private": true,
"preview": true,
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "viperdan.psdocs-vscode",
"title": "PSDocs.Azure: Generate Markdown"
}
],
"snippets": [
{
"language": "arm-template",
"path": "./snippets/arm.json"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "npm run compile && npm run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js"
},
"extensionDependencies": [
"vscode.powershell",
"ms-vscode.powershell",
"msazurermtools.azurerm-vscode-tools"
],
"devDependencies": {
"@types/vscode": "^1.58.0",
"@types/glob": "^7.1.3",
"@types/mocha": "^8.2.2",
"@types/node": "14.x",
"eslint": "^7.27.0",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"glob": "^7.1.7",
"mocha": "^8.4.0",
"typescript": "^4.3.2",
"vscode-test": "^1.5.2"
}
}

21
snippets/arm.json Normal file
Просмотреть файл

@ -0,0 +1,21 @@
{
"psdocs-arm": {
"prefix": "psdocs-arm",
"description": "Add metadata to an existing ARM template",
"body": [
"\"metadata\": {",
"\t\"name\": \"${1:Name of the template}\",",
"\t\"description\": \"${2:Description of the template}\"",
"}"
]
},
"psdocs-arm-parameter": {
"prefix": "psdocs-arm-short",
"description": "Add metadata to an existing parameter or variable in an ARM template",
"body": [
"\"metadata\": {",
"\t\"description\": \"${1:Description of the parameter or variable}\"",
"}"
]
}
}

56
src/extension.ts Normal file
Просмотреть файл

@ -0,0 +1,56 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import path = require("path");
import * as vscode from "vscode";
export function activate(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand(
"viperdan.psdocs-vscode",
function () {
var currentlyOpenFilePath =
vscode.window.activeTextEditor?.document.uri.fsPath;
var templatePath = "";
var outputPath = "";
var templateFolderPath = "";
let options: vscode.InputBoxOptions = {
prompt: "Full path to the ARM template: ",
value: `${currentlyOpenFilePath}`,
};
vscode.window.showInputBox(options).then((value) => {
if (!value) return;
templatePath = value;
templateFolderPath = path.dirname(templatePath);
let options: vscode.InputBoxOptions = {
prompt:
"Output Path of the Markdown (relative path from the ARM template file): ",
value: "out\\docs\\",
};
vscode.window.showInputBox(options).then((value) => {
if (!value) return;
outputPath = value;
const { exec } = require("child_process");
var message = "";
exec(
`Import-Module PSDocs.Azure; Invoke-PSDocument -Module PSDocs.Azure -InputObject ${templatePath} -OutputPath ${templateFolderPath}/${outputPath};`,
{ shell: "pwsh" },
(error: any, stdout: any, stderr: any) => {
message = stderr;
if (message !== "") {
vscode.window.showErrorMessage(message);
} else {
vscode.window.showInformationMessage(
`Markdown generated in ${templateFolderPath}/${outputPath}`
);
}
}
);
});
});
}
);
}
export function deactivate() {}

23
src/test/runTest.ts Normal file
Просмотреть файл

@ -0,0 +1,23 @@
import * as path from 'path';
import { runTests } from 'vscode-test';
async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');
// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath });
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}
main();

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

@ -0,0 +1,15 @@
import * as assert from 'assert';
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
// import * as myExtension from '../../extension';
suite('Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.');
test('Sample test', () => {
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
});
});

38
src/test/suite/index.ts Normal file
Просмотреть файл

@ -0,0 +1,38 @@
import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';
export function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
color: true
});
const testsRoot = path.resolve(__dirname, '..');
return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}
// Add files to the test suite
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
try {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
console.error(err);
e(err);
}
});
});
}

22
tsconfig.json Normal file
Просмотреть файл

@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "out",
"lib": [
"es6"
],
"watch": true,
"sourceMap": true,
"rootDir": "src",
"strict": true /* enable all strict type-checking options */
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
},
"exclude": [
"node_modules",
".vscode-test"
]
}