You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: retrieval of extension data into a new ExtensionData class.
Changed:
- Moved `getExtensionPackageJsonData`, `setExtensionData`, `getExtensionData` methods into a new `ExtensionData` class for simplicity and better organisation.
- Simplified the `getExtensionPackageJsonData` method to get all package.json data not just a select few.
By using the new type `IPackageJson`, we can properly type the data as package.json instead of a generic `object` or `any`.
- Changed the `name` variable to `namespace`, simplied it's code and added it to the `contributes.configuration` object of the packageJson data, since it's the namespace of the settings
- Changed the `name` variable to `namespace`, simplied it's code and added it to the `contributes.configuration` object of the packageJson data, since it's the namespace of the configuration settings.
- Split `setExtensionData` into 2 methods: `setExtensionData` and `createExtensionData`; and simplified the code.
- `createExtensionData` to create the extension data object, defining the keys and values for the Map. The keys as defined here will also be used for type inference for VScode intellisense in the new `get` method.
- `setExtensionData` to set the data as defined in `createExtensionData` method into the `extensionData` Map.
- Changed all references to the old `getExtensionData` method to use the `get` method of the new `ExtensionData` class.
- Renamed the `Configuration` property `extensionDetails` to `extensionData`; and instantiate the `ExtensionData` class as it's value.
Added:
- Added new `get` method to get the extension's data by a specified key.
VScode intellisense auto-suggests the keys by using type inference from the keys set in `createExtensionData` method. This is important so remembering or looking up the keys isn't a pain.
- Added `getAll` method to get all extension data as readonly so it can only be logged in the Output Channel.
- Added a new dependency `package-json-type` to allow package.json typings as `IPackageJson`.
0 commit comments