Skip to content

Commit

Permalink
feat(recipes): Export providers (#27724)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic committed Oct 30, 2020
1 parent f8cf904 commit 023daf2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 38 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-recipes/src/create-types.js
Expand Up @@ -4,7 +4,7 @@ import { GraphQLString, GraphQLObjectType, GraphQLList } from "graphql"
import _ from "lodash"
import { ObjectTypeComposer, schemaComposer } from "graphql-compose"

import resources from "./resources"
import * as resources from "./resources"

const typeNameToHumanName = name => {
if (name.endsWith(`Connection`)) {
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-recipes/src/index.js
Expand Up @@ -4,4 +4,5 @@ import startGraphQLServer from "./graphql-server"
// data = { recipe?: string, graphqlPort: number, projectRoot: string }
const recipesHandler = async data => cli(data)

export * from "./resources"
export { startGraphQLServer, recipesHandler }
2 changes: 1 addition & 1 deletion packages/gatsby-recipes/src/renderer/render.js
Expand Up @@ -3,7 +3,7 @@ import Queue from "better-queue"
import lodash from "lodash"
import mitt from "mitt"

import resources from "../resources"
import * as resources from "../resources"

import RecipesReconciler from "./reconciler"
import ErrorBoundary from "./error-boundary"
Expand Down
@@ -1,6 +1,6 @@
import React, { Suspense } from "react"

import resources from "../resources"
import * as resources from "../resources"

import { ResourceComponent } from "./render"

Expand Down
@@ -1,4 +1,4 @@
import providedResources from "../resources"
import * as providedResources from "../resources"
const isResource = type => type && (type === `Input` || providedResources[type])

const extractPlan = (node, type) => {
Expand Down
47 changes: 14 additions & 33 deletions packages/gatsby-recipes/src/resources.js
@@ -1,33 +1,14 @@
import * as fileResource from "./providers/fs/file"
import * as directoryResource from "./providers/fs/directory"
import * as gatsbyPageResource from "./providers/gatsby/page"
import * as gatsbyPluginResource from "./providers/gatsby/plugin"
import * as gatsbyShadowFileResource from "./providers/gatsby/shadow-file"
import * as gatsbySiteMetadataResource from "./providers/gatsby/site-metadata"
import * as npmPackageResource from "./providers/npm/package"
import * as npmPackageScriptResource from "./providers/npm/script"
import * as npmPackageJsonResource from "./providers/npm/package-json"
import * as gitIgnoreResource from "./providers/git/ignore"
import * as contentfulSpace from "./providers/contentful/space"
import * as contentfulEnvironment from "./providers/contentful/environment"
import * as contentfulType from "./providers/contentful/type"
import * as contentfulEntry from "./providers/contentful/entry"

const componentResourceMapping = {
File: fileResource,
Directory: directoryResource,
GatsbyPage: gatsbyPageResource,
GatsbyPlugin: gatsbyPluginResource,
GatsbyShadowFile: gatsbyShadowFileResource,
GatsbySiteMetadata: gatsbySiteMetadataResource,
NPMPackage: npmPackageResource,
NPMScript: npmPackageScriptResource,
NPMPackageJson: npmPackageJsonResource,
GitIgnore: gitIgnoreResource,
ContentfulSpace: contentfulSpace,
ContentfulEnvironment: contentfulEnvironment,
ContentfulType: contentfulType,
ContentfulEntry: contentfulEntry,
}

export default componentResourceMapping
export * as File from "./providers/fs/file"
export * as Directory from "./providers/fs/directory"
export * as GatsbyPage from "./providers/gatsby/page"
export * as GatsbyPlugin from "./providers/gatsby/plugin"
export * as GatsbyShadowFile from "./providers/gatsby/shadow-file"
export * as GatsbySiteMetadata from "./providers/gatsby/site-metadata"
export * as NPMPackage from "./providers/npm/package"
export * as NPMScript from "./providers/npm/script"
export * as NPMPackageJson from "./providers/npm/package-json"
export * as GitIgnore from "./providers/git/ignore"
export * as ContentfulSpace from "./providers/contentful/space"
export * as ContentfulEnvironment from "./providers/contentful/environment"
export * as ContentfulType from "./providers/contentful/type"
export * as ContentfulEntry from "./providers/contentful/entry"
2 changes: 1 addition & 1 deletion packages/gatsby-recipes/src/validate-recipe.js
@@ -1,4 +1,4 @@
import resources from "./resources"
import * as resources from "./resources"
import _ from "lodash"

export default function validateRecipe(plan) {
Expand Down

0 comments on commit 023daf2

Please sign in to comment.