diff --git a/package.json b/package.json index 42167945..ce3f06a9 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "semver": "^7.8.1" }, "devDependencies": { - "@oclif/plugin-command-snapshot": "^5.3.30", + "@oclif/plugin-command-snapshot": "^5.3.31", "@salesforce/cli-plugins-testkit": "^5.3.62", "@salesforce/dev-scripts": "^11.0.4", "@salesforce/plugin-command-reference": "^3.1.120", diff --git a/schemas/doctor.json b/schemas/doctor.json new file mode 100644 index 00000000..cdeb1560 --- /dev/null +++ b/schemas/doctor.json @@ -0,0 +1,204 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$ref": "#/definitions/SfDoctorDiagnosis", + "definitions": { + "SfDoctorDiagnosis": { + "type": "object", + "properties": { + "versionDetail": { + "type": "object", + "additionalProperties": false, + "properties": { + "pluginVersions": { + "type": "array", + "items": { + "type": "string" + } + }, + "architecture": { + "type": "string" + }, + "cliVersion": { + "type": "string" + }, + "nodeVersion": { + "type": "string" + }, + "osVersion": { + "type": "string" + }, + "rootPath": { + "type": "string" + }, + "shell": { + "type": "string" + } + }, + "required": ["architecture", "cliVersion", "nodeVersion", "pluginVersions"] + }, + "sfdxEnvVars": { + "type": "array", + "items": { + "$ref": "#/definitions/KeyValue%3Cstring%3E" + } + }, + "sfEnvVars": { + "type": "array", + "items": { + "$ref": "#/definitions/KeyValue%3Cstring%3E" + } + }, + "proxyEnvVars": { + "type": "array", + "items": { + "$ref": "#/definitions/KeyValue%3Cstring%3E" + } + }, + "cliConfig": { + "type": "object", + "properties": { + "bin": { + "type": "string" + }, + "nodeEngine": { + "type": "string" + }, + "windows": { + "type": "boolean" + }, + "userAgent": { + "type": "string" + }, + "shell": { + "type": "string" + }, + "channel": { + "type": "string" + } + }, + "required": ["bin", "channel", "nodeEngine", "shell", "userAgent", "windows"] + }, + "pluginSpecificData": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "$ref": "#/definitions/AnyJson" + } + } + }, + "diagnosticResults": { + "type": "array", + "items": { + "$ref": "#/definitions/DiagnosticStatus" + } + }, + "suggestions": { + "type": "array", + "items": { + "type": "string" + } + }, + "commandName": { + "type": "string" + }, + "commandExitCode": { + "type": ["string", "number"] + }, + "logFilePaths": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "versionDetail", + "sfdxEnvVars", + "sfEnvVars", + "proxyEnvVars", + "cliConfig", + "pluginSpecificData", + "diagnosticResults", + "suggestions", + "logFilePaths" + ], + "additionalProperties": false + }, + "KeyValue": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 2, + "maxItems": 2, + "description": "An alias for a tuple of type `[string, T]' for a given generic type `T`. `T` defaults to `unknown` if not otherwise defined." + }, + "AnyJson": { + "anyOf": [ + { + "$ref": "#/definitions/JsonPrimitive" + }, + { + "$ref": "#/definitions/JsonCollection" + } + ], + "description": "Any valid JSON value." + }, + "JsonPrimitive": { + "type": ["null", "boolean", "number", "string"], + "description": "Any valid JSON primitive value." + }, + "JsonCollection": { + "anyOf": [ + { + "$ref": "#/definitions/JsonMap" + }, + { + "$ref": "#/definitions/JsonArray" + } + ], + "description": "Any valid JSON collection value." + }, + "JsonMap": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Optional%3CAnyJson%3E" + }, + "properties": {}, + "description": "Any JSON-compatible object." + }, + "Optional": { + "anyOf": [ + { + "$ref": "#/definitions/AnyJson" + }, + { + "not": {} + } + ], + "description": "A union type for either the parameterized type `T` or `undefined` -- the opposite of {@link NonOptional } ." + }, + "JsonArray": { + "type": "array", + "items": { + "$ref": "#/definitions/AnyJson" + }, + "description": "Any JSON-compatible array." + }, + "DiagnosticStatus": { + "type": "object", + "properties": { + "testName": { + "type": "string" + }, + "status": { + "type": "string", + "enum": ["pass", "fail", "warn", "unknown"] + } + }, + "required": ["testName", "status"], + "additionalProperties": false + } + } +} diff --git a/schemas/info-releasenotes-display.json b/schemas/info-releasenotes-display.json new file mode 100644 index 00000000..092e8daa --- /dev/null +++ b/schemas/info-releasenotes-display.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$ref": "#/definitions/DisplayOutput", + "definitions": { + "DisplayOutput": { + "anyOf": [ + { + "type": "object", + "properties": { + "body": { + "type": "string" + }, + "url": { + "type": "string" + } + }, + "required": ["body", "url"], + "additionalProperties": false + }, + { + "not": {} + } + ] + } + } +} diff --git a/src/commands/info/releasenotes/display.ts b/src/commands/info/releasenotes/display.ts index c7e226c0..1c85dd53 100644 --- a/src/commands/info/releasenotes/display.ts +++ b/src/commands/info/releasenotes/display.ts @@ -33,7 +33,7 @@ const helpers = ['stable', 'stable-rc', 'latest', 'latest-rc', 'rc']; // or any library that is using the messages framework can also be loaded this way. const messages = Messages.loadMessages('@salesforce/plugin-info', 'display'); -export default class Display extends SfCommand { +export default class Display extends SfCommand { public static readonly summary = messages.getMessage('summary'); public static readonly description = messages.getMessage('description'); @@ -53,7 +53,7 @@ export default class Display extends SfCommand { loglevel, }; - public async run(): Promise { + public async run(): Promise { const HIDE_NOTES = this.config.bin === 'sf' ? 'SF_HIDE_RELEASE_NOTES' : 'SFDX_HIDE_RELEASE_NOTES'; const HIDE_FOOTER = this.config.bin === 'sf' ? 'SF_HIDE_RELEASE_NOTES_FOOTER' : 'SFDX_HIDE_RELEASE_NOTES_FOOTER'; @@ -142,7 +142,9 @@ export default class Display extends SfCommand { } } -export type DisplayOutput = { - body: string; - url: string; -}; +export type DisplayOutput = + | { + body: string; + url: string; + } + | undefined; diff --git a/src/doctor.ts b/src/doctor.ts index ea57742e..2d3f37da 100644 --- a/src/doctor.ts +++ b/src/doctor.ts @@ -20,7 +20,7 @@ import { join, dirname, basename } from 'node:path'; import { Messages, SfError } from '@salesforce/core'; import { Env, omit } from '@salesforce/kit'; import type { AnyJson, KeyValue } from '@salesforce/ts-types'; -import Interfaces from '@oclif/core/interfaces'; +import { Interfaces } from '@oclif/core'; import { Diagnostics, DiagnosticStatus } from './diagnostics.js'; export type SfDoctor = { @@ -42,10 +42,14 @@ export type SfDoctor = { }; // oclif has some properties marked as optional in the Interface, but they will be present after Load() is called -type CliConfig = Partial & { nodeEngine: string } & Pick< - Required, - 'windows' | 'userAgent' | 'shell' | 'channel' - >; +type CliConfig = Record & { + bin: string; + nodeEngine: string; + windows: boolean; + userAgent: string; + shell: string; + channel: string; +}; export type SfDoctorDiagnosis = { versionDetail: Omit & { pluginVersions: string[] }; diff --git a/yarn.lock b/yarn.lock index 64677582..3175b48e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1387,10 +1387,10 @@ wordwrap "^1.0.0" wrap-ansi "^7.0.0" -"@oclif/plugin-command-snapshot@^5.3.30": - version "5.3.30" - resolved "https://registry.yarnpkg.com/@oclif/plugin-command-snapshot/-/plugin-command-snapshot-5.3.30.tgz#0353f303d7bbfd8461833693f160288868c4bbb3" - integrity sha512-DyRRsNNlCs15vxoGQ1CcyP9Kkt+JGMg+Axovyd4Eutkg6Z/Q55HrIvxAT6shjIkWoFH44cqcDrhCGCA/7EFsLQ== +"@oclif/plugin-command-snapshot@^5.3.31": + version "5.3.31" + resolved "https://registry.yarnpkg.com/@oclif/plugin-command-snapshot/-/plugin-command-snapshot-5.3.31.tgz#1064f54273cead813d90c07604c16c3e99f07850" + integrity sha512-jDfwOlgIK+p8Q/YZcBsExZPGeFArtFZ5tqWV+tkW/fKLMMAIbKcrW/NPFFTGsaS3tL8nJfeqyT0f4e5ODd+vDA== dependencies: "@oclif/core" "^4" ansis "^3.17.0" @@ -1400,7 +1400,7 @@ lodash.get "^4.4.2" lodash.sortby "^4.7.0" semver "^7.8.5" - ts-json-schema-generator "^1.5.1" + ts-json-schema-generator "^2.9.0" "@oclif/plugin-help@^6.2.50": version "6.2.50" @@ -2873,10 +2873,10 @@ combined-stream@^1.0.8: dependencies: delayed-stream "~1.0.0" -commander@^12.0.0: - version "12.0.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-12.0.0.tgz#b929db6df8546080adfd004ab215ed48cf6f2592" - integrity sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA== +commander@^14.0.3: + version "14.0.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-14.0.3.tgz#425d79b48f9af82fcd9e4fc1ea8af6c5ec07bbc2" + integrity sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw== comment-parser@1.4.1: version "1.4.1" @@ -4135,6 +4135,15 @@ glob@^10.3.10: minipass "^5.0.0 || ^6.0.2 || ^7.0.0" path-scurry "^1.10.1" +glob@^13.0.6: + version "13.0.6" + resolved "https://registry.yarnpkg.com/glob/-/glob-13.0.6.tgz#078666566a425147ccacfbd2e332deb66a2be71d" + integrity sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw== + dependencies: + minimatch "^10.2.2" + minipass "^7.1.3" + path-scurry "^2.0.2" + glob@^7.0.0, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" @@ -4147,7 +4156,7 @@ glob@^7.0.0, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^8.0.3, glob@^8.1.0: +glob@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/glob/-/glob-8.1.0.tgz#d388f656593ef708ee3e34640fdfb99a9fd1c33e" integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== @@ -5303,6 +5312,11 @@ lru-cache@^10.0.1, "lru-cache@^9.1.1 || ^10.0.0": resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.2.tgz#48206bc114c1252940c41b25b41af5b545aca878" integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ== +lru-cache@^11.0.0: + version "11.5.2" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-11.5.2.tgz#00e16665c90c620fba14a3c368732a976493f760" + integrity sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g== + lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -5496,7 +5510,7 @@ minimatch@9.0.3: dependencies: brace-expansion "^2.0.1" -minimatch@^10.2.5: +minimatch@^10.2.2, minimatch@^10.2.5: version "10.2.5" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.2.5.tgz#bd48687a0be38ed2961399105600f832095861d1" integrity sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg== @@ -5543,6 +5557,11 @@ minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6: resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.3.tgz#05ea638da44e475037ed94d1c7efcc76a25e1974" integrity sha512-LhbbwCfz3vsb12j/WkWQPZfKTsgqIe1Nf/ti1pKjYESGLHIVjWU96G9/ljLH4F9mWNVhlQOm0VySdAWzf05dpg== +minipass@^7.1.2, minipass@^7.1.3: + version "7.1.3" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.3.tgz#79389b4eb1bb2d003a9bba87d492f2bd37bdc65b" + integrity sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A== + mocha@^10.7.0: version "10.7.0" resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.7.0.tgz#9e5cbed8fa9b37537a25bd1f7fb4f6fc45458b9a" @@ -6065,6 +6084,14 @@ path-scurry@^1.10.1: lru-cache "^9.1.1 || ^10.0.0" minipass "^5.0.0 || ^6.0.2 || ^7.0.0" +path-scurry@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-2.0.2.tgz#6be0d0ee02a10d9e0de7a98bae65e182c9061f85" + integrity sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg== + dependencies: + lru-cache "^11.0.0" + minipass "^7.1.2" + path-to-regexp@^1.7.0: version "1.8.0" resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a" @@ -6584,11 +6611,16 @@ safe-regex-test@^1.0.0: get-intrinsic "^1.1.3" is-regex "^1.1.4" -safe-stable-stringify@^2.3.1, safe-stable-stringify@^2.4.3: +safe-stable-stringify@^2.3.1: version "2.4.3" resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-2.4.3.tgz#138c84b6f6edb3db5f8ef3ef7115b8f55ccbf886" integrity sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g== +safe-stable-stringify@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz#4ca2f8e385f2831c432a719b108a3bf7af42a1dd" + integrity sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA== + "safer-buffer@>= 2.1.2 < 3.0.0": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -7227,18 +7259,19 @@ ts-api-utils@^1.0.1, ts-api-utils@^1.3.0: resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.3.0.tgz#4b490e27129f1e8e686b45cc4ab63714dc60eea1" integrity sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ== -ts-json-schema-generator@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/ts-json-schema-generator/-/ts-json-schema-generator-1.5.1.tgz#7759c421240be86d393a884ad186f926b22332db" - integrity sha512-apX5qG2+NA66j7b4AJm8q/DpdTeOsjfh7A3LpKsUiil0FepkNwtN28zYgjrsiiya2/OPhsr/PSjX5FUYg79rCg== +ts-json-schema-generator@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/ts-json-schema-generator/-/ts-json-schema-generator-2.9.0.tgz#cc2b99db0e64ee9ee6898c8c74905337536ef9fc" + integrity sha512-NR5ZE108uiPtBHBJNGnhwoUaUx5vWTDJzDFG9YlRoqxPU76n+5FClRh92dcGgysbe1smRmYalM9Saj97GW1J4Q== dependencies: "@types/json-schema" "^7.0.15" - commander "^12.0.0" - glob "^8.0.3" + commander "^14.0.3" + glob "^13.0.6" json5 "^2.2.3" normalize-path "^3.0.0" - safe-stable-stringify "^2.4.3" - typescript "~5.4.2" + safe-stable-stringify "^2.5.0" + tslib "^2.8.1" + typescript "^5.9.3" ts-node@^10.8.1, ts-node@^10.9.2: version "10.9.2" @@ -7400,10 +7433,10 @@ typedoc@^0.26.5: resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== -typescript@~5.4.2: - version "5.4.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611" - integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ== +typescript@^5.9.3: + version "5.9.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" + integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== uc.micro@^2.0.0, uc.micro@^2.1.0: version "2.1.0"