Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@gasket/plugin-metadata
Advanced tools
Metadata is the information about the registered plugins and presets, available to plugin lifecycle hooks. This data can be used in various was for plugins, most notably the @gasket/plugin-docs which uses it to collate docs for an app.
This is a default plugin in newly create Gasket apps.
Get all the metadata for the configured plugins and modules.
const metadata = await gasket.actions.getMetadata();
Describe metadata for a plugin and optionally its supporting modules.
This plugin implements the metadata
lifecycle, which plugins can use to modify
its own metadata at runtime. Whatever is returned will replace the existing
metadata.
// gasket-plugin-example.js
export default {
name: 'example',
hooks: {
/**
* @param {Gasket} gasket - The Gasket API
* @param {PluginData} data - This plugin's initial metadata
* @returns {Object}
*/
async metadata(gasket, data) {
return {
...data,
// adding extra data to this plugin's metadata
extra: 'information',
// add metadata for details of this plugin
lifecycles: [{
name: 'some-data',
description: 'Allows plugins to do something with data',
method: 'exec',
parent: 'start'
}],
// Metadata for these modules will be loaded
// Declare as strings or objects with additional data
modules: [
{
name: 'module-name',
version: '7.0.0',
description: 'module-name despcrition',
link: 'README.md'
}
]
}
},
/**
* An example lifecycle hook which utilizes metadata
*
* @param {Gasket} gasket - The Gasket API
*/
async example(gasket) {
const { metadata } = gasket;
if (metadata.plugins.find(pluginData => pluginData.name === 'gasket-plugin-something')) {
// only perform some action if a certain plugin is also registered
}
}
}
}
Beside the lifecycles available to plugins, metadata can also be described for modules.
Lastly, modules can describe metadata by defining a gasket.metadata
property
in the package.json which will get expanded to the ModuleData:
{
"name": "example",
"version": "1.2.3",
"gasket": {
"metadata": {
"guides": [
{
"name": "Example Guide",
"description": "How to do something",
"link": "docs/example.md"
}
]
}
}
}
This is especially useful to surface guides with Gasket docs for supporting packages that are intended to be used with Gasket, but are not plugins.
Plugins and apps can read from the metadata object by using
the getMetadata
Gasket action.
Back to our example plugin, let's see how we can access details about an installed module, and put is some conditional logic.
// gasket-plugin-example.js
import semver from 'semver';
export default {
name: 'example',
hooks: {
// We need access to metadata during build
async build(gasket) {
const metadata = await gasket.actions.getMetadata()
// ... use metadata
}
}
};
FAQs
Adds metadata to gasket lifecycles
The npm package @gasket/plugin-metadata receives a total of 82 weekly downloads. As such, @gasket/plugin-metadata popularity was classified as not popular.
We found that @gasket/plugin-metadata demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.