Skip to content

Commit f371033

Browse files
authored
Added PSRule getting started walkthrough #771 (#832)
1 parent ce7f2a8 commit f371033

17 files changed

Lines changed: 323 additions & 12 deletions

.vscode/settings.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,23 @@
33
"node_modules/": true
44
},
55
"search.exclude": {
6-
"out": true
6+
"out/": true,
7+
"node_modules/": true
78
},
89
"files.associations": {
910
"**/.azure-pipelines/*.yaml": "azure-pipelines",
1011
"**/.azure-pipelines/jobs/*.yaml": "azure-pipelines"
1112
},
13+
"json.schemas": [
14+
{
15+
"url": ".vscode/walkthrough.schema.json",
16+
"fileMatch": [
17+
"**/media/walkthroughs/**/snippets.json"
18+
]
19+
}
20+
],
1221
"editor.insertSpaces": true,
22+
"files.insertFinalNewline": true,
1323
"editor.tabSize": 4,
1424
"[yaml]": {
1525
"editor.tabSize": 2
@@ -19,7 +29,7 @@
1929
},
2030
"[json]": {
2131
"editor.formatOnSave": true,
22-
"editor.defaultFormatter": "esbenp.prettier-vscode"
32+
"editor.defaultFormatter": "vscode.json-language-features"
2333
},
2434
"[jsonc]": {
2535
"editor.formatOnSave": true,

.vscode/walkthrough.schema.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"$schema": "https://json-schema.org/draft-07/schema#",
3+
"type": "array",
4+
"items": {
5+
"$ref": "#/definitions/snippet"
6+
},
7+
"definitions": {
8+
"snippet": {
9+
"type": "object",
10+
"properties": {
11+
"name": {
12+
"type": "string"
13+
},
14+
"snippet": {
15+
"type": "array",
16+
"items": {
17+
"type": "string"
18+
}
19+
}
20+
},
21+
"additionalProperties": false,
22+
"required": [
23+
"name",
24+
"snippet"
25+
],
26+
"defaultSnippets": [
27+
{
28+
"label": "New snippet",
29+
"body": {
30+
"name": "",
31+
"snippet": ""
32+
}
33+
}
34+
]
35+
}
36+
}
37+
}

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,26 @@ This extension is available in two release channels for Visual Studio Code from
1212
- Aligned to versioning of PSRule.
1313
Continue reading to see the changes included in the latest version.
1414

15+
**Experimental features**:
16+
17+
- CodeLens to create or edit documentation.
18+
- Link from rules allows markdown documentation to be created or edited.
19+
- When existing markdown documentation exists, file is opened in editor.
20+
- When documentation for a rule does not exist, a new file is created from a snippet.
21+
- Added settings to configure the location for storing documentation,
22+
and the snippet used to create documentation.
23+
- Get started with PSRule walkthrough.
24+
- Steps cover basic PSRule configuration and documentation.
25+
1526
## Unreleased
1627

1728
What's changed since v2.3.0:
1829

30+
- General improvements:
31+
- **Experimental:** Added a walkthrough for getting started with PSRule by @BernieWhite.
32+
[#771](https://github.com/microsoft/PSRule-vscode/issues/771)
33+
- Added steps for basic configuration and documentation.
34+
- To use try this feature, install the preview channel with experimental features enabled.
1935
- Engineering:
2036
- Updated PSRule schema files.
2137
[#812](https://github.com/microsoft/PSRule-vscode/pull/812)
@@ -62,7 +78,7 @@ What's changed since v2.1.0:
6278
What's changed since v2.0.0:
6379

6480
- New features:
65-
- **Experimental:** CodeLens provides links to open or create rule documentation.
81+
- **Experimental:** CodeLens provides links to open or create rule documentation by @BernieWhite.
6682
[#227](https://github.com/microsoft/PSRule-vscode/issues/227)
6783
- Link from rules allows markdown documentation to be created or edited.
6884
- When existing markdown documentation exists, file is opened in editor.

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,4 @@ This project is [licensed under the MIT License][license].
153153
[contribution guide]: https://github.com/Microsoft/PSRule-vscode/blob/main/CONTRIBUTING.md
154154
[change log]: https://github.com/Microsoft/PSRule-vscode/blob/main/CHANGELOG.md
155155
[license]: https://github.com/Microsoft/PSRule-vscode/blob/main/LICENSE
156-
[chat]: https://gitter.im/PSRule/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
157-
[chat-badge]: https://img.shields.io/static/v1.svg?label=chat&message=on%20gitter&color=informational&logo=gitter
158-
[ps-rule.yaml]: https://microsoft.github.io/PSRule/concepts/PSRule/en-US/about_PSRule_Options.html
156+
[ps-rule.yaml]: https://aka.ms/ps-rule/options
File renamed without changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Configure an options file
2+
3+
- First, type `requires` and press Tab or Enter to complete the suggestion.
4+
- Continue typing to replace `Module` with `PSRule` and press Tab or Enter to move to the version constraint.
5+
- Replace `'>=1.0.0'` with the minimum version of PSRule you want to use, such as `'>=2.3.2'`.
6+
7+
## Configure additional modules
8+
9+
Additional modules can be added to the options file.
10+
For example:
11+
12+
[Copy snippet](command:PSRule.walkthroughCopySnippet?%7B%22snippet%22%3A%2201_requiresModules%22%7D)
13+
14+
```yaml
15+
requires:
16+
PSRule: '>=2.3.2'
17+
PSRule.Rules.Azure: '>=1.18.1'
18+
```
19+
20+
### Configure other options
21+
22+
Rules often have additional configuration options that can be set.
23+
For example, the `PSRule.Rules.Azure` module has the following options:
24+
25+
[Copy snippet](command:PSRule.walkthroughCopySnippet?%7B%22snippet%22%3A%2201_configureAzure%22%7D)
26+
27+
```yaml
28+
configuration:
29+
AZURE_PARAMETER_FILE_EXPANSION: true
30+
AZURE_BICEP_FILE_EXPANSION: true
31+
```

media/walkthroughs/getStarted/02_configureSettings.md

Whitespace-only changes.

media/walkthroughs/getStarted/03_learnMore.md

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"name": "01_requiresModules",
4+
"snippet": [
5+
"requires:",
6+
" PSRule: '>=2.3.2'",
7+
" PSRule.Rules.Azure: '>=1.18.1'"
8+
]
9+
},
10+
{
11+
"name": "01_configureAzure",
12+
"snippet": [
13+
"configuration:",
14+
" AZURE_PARAMETER_FILE_EXPANSION: true",
15+
" AZURE_BICEP_FILE_EXPANSION: true"
16+
]
17+
}
18+
]

package.json

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"color": "#0072c6",
2626
"theme": "dark"
2727
},
28-
"icon": "images/icon256.png",
28+
"icon": "media/icon256.png",
2929
"repository": {
3030
"type": "git",
3131
"url": "https://github.com/Microsoft/PSRule-vscode.git"
@@ -38,12 +38,18 @@
3838
"activationEvents": [
3939
"onLanguage:powershell",
4040
"workspaceContains:/ps-rule.yaml",
41+
"workspaceContains:**/ps-rule.yaml",
4142
"workspaceContains:**/*.Rule.yaml",
4243
"workspaceContains:**/*.Rule.yml",
4344
"workspaceContains:**/*.Rule.json",
4445
"workspaceContains:**/*.Rule.jsonc",
4546
"workspaceContains:**/*.Rule.ps1",
46-
"onCommand:workbench.action.tasks.runTask"
47+
"onCommand:workbench.action.tasks.runTask",
48+
"onCommand:PSRule.createOrEditDocumentation",
49+
"onCommand:PSRule.openOptionsFile",
50+
"onCommand:PSRule.createOptionsFile",
51+
"onCommand:PSRule.configureSettings",
52+
"onCommand:PSRule.walkthroughCopySnippet"
4753
],
4854
"main": "./out/dist/main.js",
4955
"capabilities": {
@@ -60,10 +66,27 @@
6066
"shortTitle": "Edit documentation",
6167
"category": "PSRule"
6268
},
69+
{
70+
"command": "PSRule.openOptionsFile",
71+
"title": "Open options file",
72+
"category": "PSRule"
73+
},
6374
{
6475
"command": "PSRule.createOptionsFile",
6576
"title": "Create options file",
6677
"category": "PSRule"
78+
},
79+
{
80+
"command": "PSRule.configureSettings",
81+
"title": "Configure settings",
82+
"category": "PSRule"
83+
},
84+
{
85+
"$comment": "Only used by walkthrough.",
86+
"command": "PSRule.walkthroughCopySnippet",
87+
"title": "Copy walkthrough snippet",
88+
"enablement": "false",
89+
"category": "PSRule"
6790
}
6891
],
6992
"configuration": [
@@ -310,6 +333,47 @@
310333
}
311334
]
312335
}
336+
],
337+
"walkthroughs": [
338+
{
339+
"id": "PSRule.getStarted",
340+
"title": "Get Started with PSRule",
341+
"description": "Learn about and start using PSRule with Visual Studio Code.",
342+
"when": "config.PSRule.experimental.enabled",
343+
"steps": [
344+
{
345+
"id": "configureOptions",
346+
"title": "Configure an options file",
347+
"description": "The options file **ps-rule.yaml** is used to initialize a workspace and configure features of PSRule.\n[Open an options file](command:PSRule.openOptionsFile)\n[Create an options file](command:PSRule.createOptionsFile)\nTip: [Close the side bar for more space](command:workbench.action.closeSidebar)",
348+
"media": {
349+
"markdown": "media/walkthroughs/getStarted/01_configureOptions.md"
350+
},
351+
"completionEvents": [
352+
"onCommand:PSRule.openOptionsFile",
353+
"onCommand:PSRule.createOptionsFile"
354+
]
355+
},
356+
{
357+
"id": "configureSettings",
358+
"title": "Configure settings",
359+
"description": "In addition to **ps-rule.yaml**, some settings that affect how PSRule runs within Visual Studio Code can be configured per user or per workspace.\n[Configure settings](command:PSRule.configureSettings)\nTip: __You can sync some of these settings across devices.__",
360+
"media": {
361+
"markdown": "media/walkthroughs/getStarted/02_configureSettings.md"
362+
},
363+
"completionEvents": [
364+
"onCommand:PSRule.configureSettings"
365+
]
366+
},
367+
{
368+
"id": "learnMore",
369+
"title": "Learn more",
370+
"description": "Check out our [PSRule documentation](https://aka.ms/ps-rule) to learn more about features and customization.",
371+
"media": {
372+
"markdown": "media/walkthroughs/getStarted/03_learnMore.md"
373+
}
374+
}
375+
]
376+
}
313377
]
314378
},
315379
"scripts": {

0 commit comments

Comments
 (0)