Skip to content

Commit dfe1502

Browse files
committed
to es and beyond
1 parent 2b477ca commit dfe1502

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+427
-566
lines changed

packages/gatsby-recipes/src/__tests__/find-dependency-match.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const findDependencyMatch = require(`../find-dependency-match`)
1+
import findDependencyMatch from "../find-dependency-match"
22

33
describe(`findDependencyMatch`, () => {
44
test(`basic matching`, () => {
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const render = require(`./renderer`)
1+
import render from "./renderer"
22

3-
module.exports = (context, cb) =>
4-
render(context.recipe, cb, context, true, true, true)
3+
export default function ApplyPlan(context, cb) {
4+
return render(context.recipe, cb, context, true, true, true)
5+
}

packages/gatsby-recipes/src/cli/index.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
1-
const React = require(`react`)
2-
const { useState, useEffect } = require(`react`)
1+
import React, { useState, useEffect } from "react"
32
import SelectInput from "ink-select-input"
43
import { render, Box, Text, useInput, useApp, Transform } from "ink"
54
import Spinner from "ink-spinner"
65
import StepRenderer from "../components/step-renderer"
7-
const hicat = require(`hicat`)
8-
const { trackCli } = require(`gatsby-telemetry`)
6+
import hicat from "hicat"
7+
import { trackCli } from "gatsby-telemetry"
98
import {
109
useResource,
1110
useResourceByUUID,
1211
ResourceProvider,
1312
} from "../renderer/resource-provider"
1413
import terminalLink from "terminal-link"
1514
import PropTypes from "prop-types"
16-
const {
15+
import {
1716
createClient,
1817
useMutation,
1918
useSubscription,
2019
Provider,
2120
defaultExchanges,
2221
subscriptionExchange,
23-
} = require(`urql`)
24-
const { SubscriptionClient } = require(`subscriptions-transport-ws`)
25-
const fetch = require(`node-fetch`)
26-
const ws = require(`ws`)
27-
const semver = require(`semver`)
28-
const remove = require(`unist-util-remove`)
29-
const recipesList = require(`./recipes-list`).default
22+
} from "urql"
23+
import { SubscriptionClient } from "subscriptions-transport-ws"
24+
import fetch from "node-fetch"
25+
import ws from "ws"
26+
import semver from "semver"
27+
import remove from "unist-util-remove"
28+
import recipesList from "../recipes-list"
3029

3130
const removeJsx = () => tree => {
3231
remove(tree, `export`, () => true)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* This is entry point for `gatsby-recipes/components`
3+
*/
4+
5+
import StepRenderer from "./components/step-renderer"
6+
7+
console.log(StepRenderer)
8+
9+
export { StepRenderer }

packages/gatsby-recipes/src/create-plan.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const render = require(`./renderer`)
1+
import render from "./renderer"
22

3-
module.exports = async (context, cb) => {
3+
export default async function createPlan(context, cb) {
44
try {
55
const result = await render(context.recipe, cb, context)
66
return result

packages/gatsby-recipes/src/create-types.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const Joi2GQL = require(`./joi-to-graphql`)
2-
const Joi = require(`@hapi/joi`)
3-
const { GraphQLString, GraphQLObjectType, GraphQLList } = require(`graphql`)
4-
const _ = require(`lodash`)
5-
const { ObjectTypeComposer, schemaComposer } = require(`graphql-compose`)
1+
import * as Joi2GQL from "./joi-to-graphql"
2+
import * as Joi from "@hapi/joi"
3+
import { GraphQLString, GraphQLObjectType, GraphQLList } from "graphql"
4+
import _ from "lodash"
5+
import { ObjectTypeComposer, schemaComposer } from "graphql-compose"
66

7-
const resources = require(`./resources`)
7+
import resources from "./resources"
88

99
const typeNameToHumanName = name => {
1010
if (name.endsWith(`Connection`)) {
@@ -14,7 +14,7 @@ const typeNameToHumanName = name => {
1414
}
1515
}
1616

17-
module.exports = () => {
17+
export default function createTypes() {
1818
const resourceTypes = Object.entries(resources).map(
1919
([resourceName, resource]) => {
2020
if (!resource.schema) {

packages/gatsby-recipes/src/create-types.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const createTypes = require(`./create-types`)
1+
import createTypes from "./create-types"
22

33
test(`create-types`, () => {
44
const result = createTypes()

packages/gatsby-recipes/src/find-dependency-match.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Match a resource's defined dependencies against all resources
22
// defined in the recipe.
3-
module.exports = (resources, resourceWithDependencies) => {
3+
export default function findDependencyMatch(
4+
resources,
5+
resourceWithDependencies
6+
) {
47
// Resource doesn't have a dependsOn key so we return
58
if (!resourceWithDependencies.dependsOn) {
69
return []

packages/gatsby-recipes/src/graphql-server/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const execa = require(`execa`)
2-
const path = require(`path`)
3-
const fs = require(`fs`)
4-
const detectPort = require(`detect-port`)
5-
const { getService, createServiceLock } = require(`gatsby-core-utils`)
1+
import execa from "execa"
2+
import path from "path"
3+
import fs from "fs"
4+
import detectPort from "detect-port"
5+
import { getService, createServiceLock } from "gatsby-core-utils"
66

77
// NOTE(@mxstbr): The forceStart boolean enforces us to start the recipes graphql server
88
// even if another instance might already be running. This is necessary to ensure the gatsby
99
// develop command does not _not_ run the server if the user is running gatsby recipes at the same time.
10-
export default async (programPath, forceStart) => {
10+
export default async function startGraphQLServer(programPath, forceStart) {
1111
// If this env variable is set, we're in dev mode & assume the recipes API was already started
1212
// manually.
1313
if (process.env.RECIPES_DEV_MODE) {

packages/gatsby-recipes/src/graphql-server/server.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
require(`dotenv`).config()
1+
import dotenv from "dotenv"
22

3-
const express = require(`express`)
4-
const chokidar = require(`chokidar`)
5-
const graphqlHTTP = require(`express-graphql`)
6-
const { v4: uuidv4 } = require(`uuid`)
7-
const {
3+
import express from "express"
4+
import chokidar from "chokidar"
5+
import graphqlHTTP from "express-graphql"
6+
7+
import { v4 as uuidv4 } from "uuid"
8+
import {
89
GraphQLSchema,
910
GraphQLObjectType,
1011
GraphQLString,
1112
GraphQLBoolean,
1213
execute,
1314
subscribe,
14-
} = require(`graphql`)
15-
const { PubSub } = require(`graphql-subscriptions`)
16-
const { SubscriptionServer } = require(`subscriptions-transport-ws`)
17-
const { createServer } = require(`http`)
18-
const { interpret } = require(`xstate`)
19-
const pkgDir = require(`pkg-dir`)
20-
const cors = require(`cors`)
21-
const lodash = require(`lodash`)
22-
15+
} from "graphql"
16+
import { PubSub } from "graphql-subscriptions"
17+
import { SubscriptionServer } from "subscriptions-transport-ws"
18+
import { createServer } from "http"
19+
import { interpret } from "xstate"
20+
import pkgDir from "pkg-dir"
21+
import cors from "cors"
22+
import lodash from "lodash"
23+
24+
import recipeMachine from "../recipe-machine"
25+
import createTypes from "../create-types"
26+
27+
dotenv.config()
2328
// Create a session id — mostly useful to tell the client when the server
2429
// has restarted
2530
const sessionId = uuidv4()
2631

27-
const recipeMachine = require(`../recipe-machine`)
28-
const createTypes = require(`../create-types`)
29-
3032
const SITE_ROOT = pkgDir.sync(process.cwd())
3133

3234
const pubsub = new PubSub()

0 commit comments

Comments
 (0)