mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 23:09:34 +00:00
refactor(vsix): centralize package JSON report defaults (#17251)
This commit is contained in:
1 parent
263cca55d7
commit
bde90e237b
1 file changed
+6
-29
@@ -595,16 +595,15 @@ const parseVsixManifestDocument = (
|
||||
};
|
||||
|
||||
interface ParsedPackageJson {
|
||||
readonly identity: VsixPackage["package_identity"];
|
||||
readonly identity: NonNullable<VsixPackage["package_identity"]>;
|
||||
readonly engine: string | null;
|
||||
readonly main: PackageJsonEntry | null;
|
||||
readonly mainDirectoryOnly: boolean;
|
||||
readonly browser: PackageJsonEntry | null;
|
||||
readonly activationEvents: string[];
|
||||
readonly contributes: VsixPackage["contributes"];
|
||||
// null when the document could not be parsed, so its ids are unknown.
|
||||
readonly extensionDependencies: string[] | null;
|
||||
readonly extensionPack: string[] | null;
|
||||
readonly extensionDependencies: string[];
|
||||
readonly extensionPack: string[];
|
||||
readonly extensionKind: string[];
|
||||
readonly capabilities: VsixPackage["capabilities"];
|
||||
readonly enabledApiProposals: string[];
|
||||
@@ -613,39 +612,17 @@ interface ParsedPackageJson {
|
||||
const parsePackageJsonDocument = (
|
||||
text: string,
|
||||
limitations: string[],
|
||||
): ParsedPackageJson => {
|
||||
const empty: ParsedPackageJson = {
|
||||
identity: null,
|
||||
engine: null,
|
||||
main: null,
|
||||
mainDirectoryOnly: false,
|
||||
browser: null,
|
||||
activationEvents: [],
|
||||
contributes: {
|
||||
keys: [],
|
||||
commands: [],
|
||||
commands_total: 0,
|
||||
commands_omitted: 0,
|
||||
},
|
||||
extensionDependencies: null,
|
||||
extensionPack: null,
|
||||
extensionKind: [],
|
||||
capabilities: {
|
||||
untrusted_workspaces: null,
|
||||
virtual_workspaces: null,
|
||||
},
|
||||
enabledApiProposals: [],
|
||||
};
|
||||
): ParsedPackageJson | undefined => {
|
||||
let record: unknown;
|
||||
try {
|
||||
record = JSON.parse(text) as unknown;
|
||||
} catch {
|
||||
limitations.push(VSIX_LIMITATIONS.malformedPackageJson);
|
||||
return empty;
|
||||
return undefined;
|
||||
}
|
||||
if (!isRecord(record)) {
|
||||
limitations.push(VSIX_LIMITATIONS.malformedPackageJson);
|
||||
return empty;
|
||||
return undefined;
|
||||
}
|
||||
const engines = isRecord(record.engines) ? record.engines : undefined;
|
||||
const engine = nonempty(engines?.vscode);
|
||||
|
||||
Reference in new issue
Block a user