Skip to content

Commit 34d0ae1

Browse files
🚀 [Feature]: Add Get-ASTCommand to get commands ++ (#15)
## Description This pull request includes several changes across multiple files, primarily focusing on adding new functionalities for AST (Abstract Syntax Tree) operations, updating linting configurations, and minor updates to documentation and metadata. The most important changes include adding new functions for AST operations, updating linting configurations, and modifying documentation. ### New AST Functions: * Added `Get-AstCommand` function to retrieve command AST elements from a PowerShell script or AST object (`src/functions/public/Core/Get-ASTCommand.ps1`). * Added `Get-AstFunction` function to retrieve function definitions from a PowerShell script or AST (`src/functions/public/Core/Get-ASTFunction.ps1`). * Added `Get-AstScript` function to parse a PowerShell script or script file and return its AST (`src/functions/public/Core/Get-ASTScript.ps1`). * Added `Get-ASTFunctionAlias` function to retrieve function aliases from a PowerShell script or file (`src/functions/public/Functions/Get-ASTFunctionAlias.ps1`). ### Linting Configuration Updates: * Added a new `.jscpd.json` configuration file for JavaScript code duplication detection (`.github/linters/.jscpd.json`). * Updated `.powershell-psscriptanalyzer.psd1` to include specific PowerShell Script Analyzer rules and settings (`.github/linters/.powershell-psscriptanalyzer.psd1`). * Modified `Linter.yml` to disable JSON Prettier validation (`.github/workflows/Linter.yml`). ### Documentation and Metadata Updates: * Updated the `LICENSE` file to reflect the year 2025 (`LICENSE`). * Updated the example function name in the `README.md` to `Get-ASTFunctionName` (`README.md`). ### Removed Deprecated Functions: * Removed `Get-FunctionAST` and `Get-ScriptAST` functions as they have been replaced by new AST functions (`src/functions/public/Core/Get-FunctionAST.ps1`, `src/functions/public/Core/Get-ScriptAST.ps1`). [[1]](diffhunk://#diff-ebd4e1ad30387639d36d84e6a48c5b48cb76c42514fa21253a16d440b7cb4021L1-L46) [[2]](diffhunk://#diff-dfd1b919296a66069c792bbb32868f85ab37b6952f7646b18ba660edfb779a28L1-L74) ### Example Removal: * Removed the general example script (`examples/General.ps1`). ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [x] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 0ee8bd6 commit 34d0ae1

26 files changed

Lines changed: 1547 additions & 499 deletions

.github/linters/.jscpd.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"threshold": 0,
3+
"reporters": [
4+
"consoleFull"
5+
],
6+
"ignore": [
7+
"**/tests/**",
8+
"**/src/functions/public/Functions/**",
9+
"**/src/functions/public/Core/Get-ASTCommand.ps1",
10+
"**/src/functions/public/Core/Get-ASTFunction.ps1"
11+
],
12+
"absolute": true
13+
}
Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,56 @@
1-
#Documentation: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/docs/Cmdlets/Invoke-ScriptAnalyzer.md#-settings
2-
@{
3-
#CustomRulePath='path\to\CustomRuleModule.psm1'
4-
#RecurseCustomRulePath='path\of\customrules'
5-
#Severity = @(
6-
# 'Error'
7-
# 'Warning'
8-
#)
9-
#IncludeDefaultRules=${true}
1+
@{
2+
Rules = @{
3+
PSAlignAssignmentStatement = @{
4+
Enable = $true
5+
CheckHashtable = $true
6+
}
7+
PSAvoidLongLines = @{
8+
Enable = $true
9+
MaximumLineLength = 150
10+
}
11+
PSAvoidSemicolonsAsLineTerminators = @{
12+
Enable = $true
13+
}
14+
PSPlaceCloseBrace = @{
15+
Enable = $true
16+
NewLineAfter = $false
17+
IgnoreOneLineBlock = $true
18+
NoEmptyLineBefore = $false
19+
}
20+
PSPlaceOpenBrace = @{
21+
Enable = $true
22+
OnSameLine = $true
23+
NewLineAfter = $true
24+
IgnoreOneLineBlock = $true
25+
}
26+
PSProvideCommentHelp = @{
27+
Enable = $true
28+
ExportedOnly = $false
29+
BlockComment = $true
30+
VSCodeSnippetCorrection = $false
31+
Placement = 'begin'
32+
}
33+
PSUseConsistentIndentation = @{
34+
Enable = $true
35+
IndentationSize = 4
36+
PipelineIndentation = 'IncreaseIndentationForFirstPipeline'
37+
Kind = 'space'
38+
}
39+
PSUseConsistentWhitespace = @{
40+
Enable = $true
41+
CheckInnerBrace = $true
42+
CheckOpenBrace = $true
43+
CheckOpenParen = $true
44+
CheckOperator = $true
45+
CheckPipe = $true
46+
CheckPipeForRedundantWhitespace = $true
47+
CheckSeparator = $true
48+
CheckParameter = $true
49+
IgnoreAssignmentOperatorInsideHashTable = $true
50+
}
51+
}
1052
ExcludeRules = @(
11-
'PSMissingModuleManifestField'
53+
'PSMissingModuleManifestField', # This rule is not applicable until the module is built.
54+
'PSUseToExportFieldsInManifest'
1255
)
13-
#IncludeRules = @(
14-
# 'PSAvoidUsingWriteHost',
15-
# 'MyCustomRuleName'
16-
#)
1756
}

0 commit comments

Comments
 (0)