New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@gasket/plugin-dynamic-plugins

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gasket/plugin-dynamic-plugins - npm Package Compare versions

Comparing version 7.1.5 to 7.2.0

lib/prepare.js

25

lib/index.js
/// <reference types="@gasket/plugin-metadata" />
import prepare from './prepare.js';
import { createRequire } from 'module';

@@ -12,25 +13,3 @@ const require = createRequire(import.meta.url);

hooks: {
async prepare(gasket, config) {
if (!config.dynamicPlugins?.length) return config;
const load = await Promise.all(config.dynamicPlugins.map(plugin => import(plugin)));
load.forEach(mod => {
config.plugins.push(mod.default);
});
gasket.engine.registerPlugins(config.plugins);
// eslint-disable-next-line no-sync
gasket.execApplySync('init', function (plugin, handler) {
if (config.dynamicPlugins.includes(plugin.name)) {
handler();
}
});
// eslint-disable-next-line no-sync
gasket.execApplySync('configure', async function (plugin, handler) {
if (config.dynamicPlugins.includes(plugin.name)) {
config = handler(config);
}
});
return config;
},
prepare,
metadata(gasket, meta) {

@@ -37,0 +16,0 @@ return {

{
"name": "@gasket/plugin-dynamic-plugins",
"version": "7.1.5",
"version": "7.2.0",
"description": "Gasket plugin for dynamically adding plugins to Gasket",

@@ -40,4 +40,7 @@ "type": "module",

"homepage": "https://github.com/godaddy/gasket/tree/main/packages/gasket-plugin-dynamic-plugins",
"dependencies": {
"chalk": "^5.4.1"
},
"devDependencies": {
"@gasket/core": "^7.1.4",
"@gasket/core": "^7.2.0",
"eslint": "^8.56.0",

@@ -68,3 +71,3 @@ "eslint-config-godaddy": "^7.1.1",

},
"gitHead": "c776477bc2dd4f3392472ac240084935cdeb0b63"
"gitHead": "8790fd065f4bcb853fc9a2deecf0833999f41443"
}

@@ -52,3 +52,4 @@ # @gasket/plugin-dynamic-plugins

+ '@gasket/plugin-foo',
+ '@gasket/plugin-bar'
+ '@gasket/plugin-bar',
+ './custom-plugin.js'
+ ]

@@ -58,22 +59,26 @@ });

### Environments
### Conditional configuration
This plugin can utilize [sub-environments] to determine which plugins to load dynamically. To specify which sub-environment to use, set the `GASKET_ENV` environment variable to the desired sub-environment and then add the sub-environment configuration to the `gasket` file.
You can use sub-configurations by [environments] or [commands] to determine
which plugins to load dynamically.
For example if you wanted to load the `@gasket/plugin-docs` and `@gasket/plugin-docusaurus` plugins only when running the `docs` script, you could set the `GASKET_ENV` variable to `local.docs` in your `package.json` file.
For example, if you wanted to load docs-related plugins only when using the
docs commands, with a package script like:
```json
"docs": "GASKET_ENV=local.docs node gasket.js docs"
"docs": "node gasket.js docs"
```
In your `gasket` file, you would then specify the plugins to load for the `local.docs` sub-environment.
In your `gasket` file, you would then configure the plugins to load dynamically
when the `docs` command is used.
```js
makeGasket({
environments: {
local: { ... },
'local.docs': {
// ...
commands: {
'docs': {
dynamicPlugins: [
'@gasket/plugin-docs',
'@gasket/plugin-docusaurus'
'@gasket/plugin-docusaurus',
'@gasket/plugin-metadata'
]

@@ -89,3 +94,6 @@ }

In the `prepare` hook, plugins specified in the `dynamicPlugins` configuration are registered to the Gasket instance. The `init` and `configure` lifecycles are then executed exclusively for the newly added dynamic plugins.
In the `prepare` hook, plugins specified in the `dynamicPlugins` configuration
are registered with the Gasket instance.
The `init`, `configure`, and `prepare` lifecycles are then executed exclusively
for the newly added dynamic plugins.

@@ -96,3 +104,4 @@ ## License

[sub-environments]: ../../docs/configuration.md#environments
[environments]: ../../docs/configuration.md#environments
[commands]: ../../docs/configuration.md#commands
[prepare]: ../gasket-core/README.md#prepare
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc