Skip to content

Commit 3b7f41c

Browse files
authored
Merge pull request #3 from advancedcommunities/refactoring
Refactoring
2 parents b6536f6 + d264fac commit 3b7f41c

File tree

4 files changed

+51
-78
lines changed

4 files changed

+51
-78
lines changed

src/tools/apex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from "@salesforce/apex-node";
1313
import { getConnection } from "../shared/connection.js";
1414
import { permissions } from "../config/permissions.js";
15-
import { executeSfCommand, executeSfCommandRaw } from "../utils/sfCommand.js";
15+
import { executeSfCommand } from "../utils/sfCommand.js";
1616

1717
const executeAnonymousApex = async (
1818
targetOrg: string,

src/tools/code-analyzer.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,43 +89,43 @@ const listCodeAnalyzerRules = async (
8989
export const registerCodeAnalyzerTools = (server: McpServer) => {
9090
server.tool(
9191
"run_code_analyzer",
92-
'Analyze your code with a selection of rules to ensure good coding practices. You can scan your codebase with the recommended rules. Or use flags to filter the rules based on engines (such as "retire-js" or "eslint"), rule names, tags, and more. Always execute the `list_code_analyzer_rules` tool first to understnad which rules to provide into ruleSelector parameter based on the files to be scanned.',
92+
"Analyze code for quality and security issues. Run list_code_analyzer_rules first to select appropriate rules for ruleSelector parameter.",
9393
{
9494
input: z.object({
9595
workspace: z
9696
.array(z.string())
9797
.optional()
9898
.describe(
99-
"Set of files that make up your workspace. Typically, a workspace is a single project folder that contains all your files. But it can also consist of one or more folders, one or more files, and use glob patterns (wildcards). If you specify this flag multiple times, then your workspace is the sum of the files and folders. Some engines often need your entire code base to perform an analysis, even if you want to target only a subset of the files within your workspace, such as with the --target flag. If you don't specify the --workspace flag, then the current folder '.' is used as your workspace."
99+
"Files/folders to analyze. Supports glob patterns. Multiple values are summed. Defaults to current folder '.'"
100100
),
101101
target: z
102102
.array(z.string())
103103
.optional()
104104
.describe(
105-
"Subset of files within your workspace to be targeted for analysis.You can specify a target as a file, a folder, or a glob pattern. If you specify this flag multiple times, then the full list of targeted files is the sum of the files and folders. Each targeted file must live within the workspace that you specified with the `–-workspace` flag. If you don't specify the `--target` flag, then all the files within your workspace (specified by the `--workspace` flag) are targeted for analysis."
105+
"Specific files/folders to target within workspace. Supports glob patterns. Defaults to all workspace files."
106106
),
107107
ruleSelector: z
108108
.array(z.string())
109109
.describe(
110-
'Selection of rules, based on engine name, severity level, rule name, tag, or a combination of criteria separated by colons. Use the `--rule-selector` flag to select the list of rules to run based on specific criteria. For example, you can select by engine, such as the rules associated with the "retire-js" or "eslint" engine. Or select by the severity of the rules, such as high or moderate. You can also select rules using tag values or rule names. Every rule has a name, which is unique within the scope of an engine. Most rules have tags, although it\'s not required. An example of a tag is "Recommended". You can combine different criteria using colons to further filter the list; the colon works as an intersection. For example, `--rule-selector eslint:Security` runs rules associated only with the "eslint" engine that have the Security tag. The flag `--rule-selector eslint:Security:3` flag runs the "eslint" rules that have the Security tag and moderate severity (3). To add multiple rule selectors together (a union), specify the `--rule-selector` flag multiple times, such as `--rule-selector eslint:Recommended --rule-selector retire-js:3`. Run `sf code-analyzer rules --rule-selector all` to see the possible values for engine name, rule name, tags, and severity levels that you can use with this flag.'
110+
'Select rules by engine, severity, name, or tag. Use colons to combine (e.g., "eslint:Security:3"). Multiple selectors create union. Run with "all" to see available values.'
111111
),
112112
outputFile: z
113113
.string()
114114
.optional()
115115
.describe(
116-
"Specify a file to save the output to. This flag can be used with or without the --output-format flag. If you don't specify the output format, the output is formatted based on the file extension of the specified file. Specifying a file extension that doesn't match a supported output format results in a JSON file being created."
116+
"Save output to file. Format auto-detected from extension or defaults to JSON."
117117
),
118118
severity: z
119119
.enum(["High", "Medium", "Low"])
120120
.optional()
121121
.describe(
122-
"Throw a non-zero exit code when rule violations of the specified severity (or more severe) are found. Values are High, Medium, and Low. The default is --severity-threshold=Low"
122+
"Exit with error on violations at/above this severity. Default: Low"
123123
),
124124
configFile: z
125125
.string()
126126
.optional()
127127
.describe(
128-
"Path to the configuration file used to customize the engines and rules. Code Analyzer has an internal default configuration for its rule and engine properties. If you want to override these defaults, you can create a Code Analyzer configuration file. We recommend that you name your Code Analyzer configuration file `code-analyzer.yml` or `code-analyzer.yaml` and put it at the root of your workspace. You then don't need to use this flag when you run the `code-analyzer run` command from the root of your workspace, because it automatically looks for either file in the current folder, and if found, applies its rule overrides and engine settings. If you want to name the file something else, or put it in an alternative folder, then you must specify this flag. To help you get started, use the `code-analyzer config` command to create your first Code Analyzer configuration file. With it, you can change the severity of an existing rule, change a rule's tags, and so on. Then use this flag to specify the file so that the command takes your customizations into account."
128+
"Config file to customize rules/engines. Auto-detects code-analyzer.yml/yaml in current folder. Use 'code-analyzer config' to create."
129129
),
130130
}),
131131
},
@@ -193,38 +193,36 @@ export const registerCodeAnalyzerTools = (server: McpServer) => {
193193

194194
server.tool(
195195
"list_code_analyzer_rules",
196-
"List the rules that are available to analyze your code. You can also view details about the rules, such as the engine it's associated with, tags, and description. Use this command to determine the exact set of rules to analyze your code. The `code-analyzer run` command has similar flags as this command, so once you've determined the flag values for this command that list the rules you want to run, you specify the same values to the `code-analyzer run` command.",
196+
"List available code analysis rules with details. Use to determine rules for code-analyzer run command.",
197197
{
198198
input: z.object({
199199
workspace: z
200200
.array(z.string())
201201
.optional()
202202
.describe(
203-
"Set of files that make up your workspace for rule discovery."
203+
"Files/folders for rule discovery. Supports glob patterns."
204204
),
205205
target: z
206206
.array(z.string())
207207
.optional()
208208
.describe(
209-
"Subset of files within your workspace to be targeted for analysis.You can specify a target as a file, a folder, or a glob pattern. If you specify this flag multiple times, then the full list of targeted files is the sum of the files and folders. Each targeted file must live within the workspace that you specified with the `–-workspace` flag. If you don't specify the `--target` flag, then all the files within your workspace (specified by the `--workspace` flag) are targeted for analysis."
209+
"Specific files/folders to target within workspace. Supports glob patterns. Defaults to all workspace files."
210210
),
211211
configFile: z
212212
.string()
213213
.optional()
214-
.describe(
215-
"Use the specified configuration file to discover rules."
216-
),
214+
.describe("Config file for rule discovery."),
217215
ruleSelector: z
218216
.array(z.string())
219217
.optional()
220218
.describe(
221-
"Filter rules by their names, tags, categories, or engines."
219+
"Filter rules by name, tag, category, or engine."
222220
),
223221
view: z
224222
.enum(["detail", "table"])
225223
.optional()
226224
.describe(
227-
"Format to display the rules in the terminal. The format 'table' is concise and shows minimal output, the format 'detail' shows all available information. Default is 'table'."
225+
"Display format: 'table' (concise) or 'detail' (full info). Default: 'table'."
228226
),
229227
}),
230228
},

src/tools/project.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,60 +59,52 @@ const deployStart = async (
5959
export const registerProjectTools = (server: McpServer) => {
6060
server.tool(
6161
"deploy_start",
62-
"",
62+
"Deploy metadata to Salesforce org with test execution options.",
6363
{
6464
input: z.object({
65-
targetOrg: z
66-
.string()
67-
.describe(
68-
"Username or alias of the target org. Not required if the 'target-org' configuration variable is already set."
69-
),
65+
targetOrg: z.string().describe("Target org username or alias."),
7066
dryRun: z
7167
.boolean()
72-
.describe(
73-
"Validate deploy and run Apex tests but don't save to the org."
74-
),
68+
.describe("Validate only, don't save changes."),
7569
manifest: z
7670
.string()
7771
.optional()
7872
.describe(
79-
"Full file path for manifest (package.xml) of components to deploy. All child components are included. If you specify this flag, don’t specify --metadata or --source-dir."
73+
"Package.xml manifest path. Excludes --metadata and --source-dir."
8074
),
8175
metadata: z
8276
.string()
8377
.optional()
8478
.describe(
85-
"Metadata component names to deploy. Wildcards (`*` ) supported as long as you use quotes, such as `ApexClass:MyClass*`."
79+
"Component names to deploy. Supports wildcards with quotes."
8680
),
8781
metadataDirectory: z
8882
.string()
8983
.optional()
90-
.describe(
91-
"Root of directory or zip file of metadata formatted files to deploy."
92-
),
84+
.describe("Metadata directory or zip file to deploy."),
9385
singlePackage: z
9486
.boolean()
9587
.optional()
9688
.describe(
97-
"Indicates that the metadata zip file points to a directory structure for a single package."
89+
"Metadata zip contains single package structure."
9890
),
9991
sourceDirectory: z
10092
.string()
10193
.optional()
10294
.describe(
103-
"Path to the local source files to deploy. The supplied path can be to a single file (in which case the operation is applied to only one file) or to a folder (in which case the operation is applied to all metadata types in the directory and its subdirectories). If you specify this flag, don’t specify --metadata or --manifest."
95+
"Local source path to deploy. Excludes --metadata and --manifest."
10496
),
10597
tests: z
10698
.string()
10799
.optional()
108100
.describe(
109-
'Apex tests to run when --test-level is RunSpecifiedTests. If a test name contains a space, enclose it in double quotes. For multiple test names, use one of the following formats: - Repeat the flag for multiple test names: --tests Test1 --tests Test2 --tests "Test With Space" - Separate the test names with spaces: --tests Test1 Test2 "Test With Space"'
101+
"Tests for RunSpecifiedTests level. Quote names with spaces. Separate multiple with spaces or repeat flag."
110102
),
111103
testLevel: z
112104
.string()
113105
.optional()
114106
.describe(
115-
"Deployment Apex testing level. Valid values are: - NoTestRun — No tests are run. This test level applies only to deployments to development environments, such as sandbox, Developer Edition, or trial orgs. This test level is the default for development environments. - RunSpecifiedTests — Runs only the tests that you specify with the --tests flag. Code coverage requirements differ from the default coverage requirements when using this test level. Executed tests must comprise a minimum of 75% code coverage for each class and trigger in the deployment package. This coverage is computed for each class and trigger individually and is different than the overall coverage percentage. - RunLocalTests — All tests in your org are run, except the ones that originate from installed managed and unlocked packages. This test level is the default for production deployments that include Apex classes or triggers. - RunAllTestsInOrg — All tests in your org are run, including tests of managed packages.If you don’t specify a test level, the default behavior depends on the contents of your deployment package and target org."
107+
"Test level: NoTestRun (dev only), RunSpecifiedTests (75% coverage), RunLocalTests (default prod), RunAllTestsInOrg."
116108
),
117109
}),
118110
},

0 commit comments

Comments
 (0)