2.2.0 • Published 2 months ago

gatsby-plugin-utils v2.2.0

Weekly downloads
369,011
License
MIT
Repository
github
Last release
2 months ago

gatsby-plugin-utils

Usage

npm install gatsby-plugin-utils

validateOptionsSchema

The validateOptionsSchema function verifies that the proper data types of options were passed into a plugin from the gatsby-config.js file. It is called internally by Gatsby to validate each plugin's options when a site is started.

Example

import { validateOptionsSchema } from "gatsby-plugin-utils"

await validateOptionsSchema(pluginName, pluginSchema, pluginOptions)

testPluginOptionsSchema

Utility to validate and test plugin options schemas. An example of a plugin options schema implementation can be found in the gatsby-node.js file of gatsby-plugin-google-analytics.

Example

// This is an example using Jest (https://jestjs.io/)
import { testPluginOptionsSchema } from "gatsby-plugin-utils"

it(`should partially validate one value of a schema`, async () => {
  const pluginSchema = ({ Joi }) =>
    Joi.object({
      someOtherValue: Joi.string(),
      toVerify: Joi.boolean(),
    })

  // Only the "toVerify" key of the schema will be verified in this test
  const { isValid, errors } = await testPluginOptionsSchema(pluginSchema, {
    toVerify: `abcd`,
  })

  expect(isValid).toBe(false)
  expect(errors).toEqual([`"toVerify" must be a boolean`])
})

isGatsbyNodeLifecycleSupported

Utility to be used by plugins to do runtime check against gatsby core package checking wether particular gatsby-node lifecycle API is supported. Useful for plugins to be able to support multiple gatsby core versions.

Example

const { isGatsbyNodeLifecycleSupported } = require(`gatsby-plugin-utils`)

// only use createSchemaCustomization lifecycle only when it's available.
if (isGatsbyNodeLifecycleSupported(`createSchemaCustomization`)) {
  exports.createSchemaCustomization = function createSchemaCustomization({
    actions,
  }) {
    // customize schema
  }
}
2.2.0

2 months ago

2.2.0-next.2

2 months ago

2.2.0-next.1

2 months ago

2.1.1

2 months ago

2.3.0-next.0

2 months ago

2.2.0-next.0

3 months ago

2.1.0

3 months ago

2.0.0

3 months ago

2.1.0-next.0

3 months ago

2.0.0-zz-next.3

3 months ago

2.0.0-zz-next.2

4 months ago

1.14.0

4 months ago

2.0.0-zz-next.1

4 months ago

2.0.0-zz-next.8

4 months ago

2.0.0-next.0

4 months ago

2.0.0-next.1

4 months ago

1.14.0-next.2

4 months ago

1.14.0-next.1

5 months ago

1.13.0

5 months ago

1.14.0-next.0

5 months ago

1.12.0

5 months ago

1.13.0-next.0

5 months ago

1.12.0-next.3

5 months ago

1.12.0-next.1

6 months ago

1.12.0-next.2

6 months ago

1.11.0

6 months ago

1.12.0-next.0

6 months ago

1.10.0

6 months ago

1.11.0-next.0

6 months ago

1.10.0-next.1

7 months ago

1.9.0

7 months ago

1.10.0-next.0

7 months ago

1.9.0-next.1

7 months ago

1.8.0

7 months ago

1.9.0-next.0

7 months ago

1.6.0

8 months ago

1.7.0-next.1

8 months ago

1.7.1

7 months ago

1.7.0

7 months ago

1.7.0-next.2

8 months ago

1.8.0-next.0

8 months ago

1.8.0-next.1

7 months ago

1.4.0

9 months ago

1.5.0-next.0

9 months ago

1.6.0-next.0

9 months ago

1.7.0-next.0

8 months ago

1.5.0

8 months ago

1.3.0

9 months ago

1.4.0-next.0

10 months ago

1.3.0-next.1

10 months ago

1.2.0

10 months ago

1.3.0-next.0

10 months ago

1.1.0

10 months ago

1.2.0-next.0

10 months ago

1.0.0

11 months ago

1.0.0-v3rc.0

11 months ago

1.1.0-next.1

11 months ago

1.1.0-next.0

11 months ago

1.0.0-next.1

11 months ago

1.0.0-next.0

12 months ago

0.9.0

12 months ago

0.10.0-next.0

12 months ago

0.8.0

12 months ago

0.9.0-next.0

1 year ago

0.8.0-next.1

1 year ago

0.7.0

1 year ago

0.8.0-next.0

1 year ago

0.7.0-next.1

1 year ago

0.6.0

1 year ago

0.7.0-next.0

1 year ago

0.5.0

1 year ago

0.6.0-next.0

1 year ago

0.4.0

1 year ago

0.5.0-next.0

1 year ago

0.3.0

1 year ago

0.4.0-next.0

1 year ago

0.3.0-next.1

1 year ago

0.3.0-next.0

1 year ago

0.2.40

1 year ago

0.2.39

1 year ago

0.2.27-qod.21

1 year ago

0.2.27-qod.20

1 year ago

0.2.38

1 year ago

0.2.27-qod.19

1 year ago

0.2.37

1 year ago

0.2.36

1 year ago

0.2.35

1 year ago

0.2.34

1 year ago

0.2.33

1 year ago

0.2.32

1 year ago

0.2.31

1 year ago

0.2.30

1 year ago

0.2.29

1 year ago

0.2.28

1 year ago

0.2.27

1 year ago

0.2.26

1 year ago