Skip to content

Commit 249905a

Browse files
authored
feat: shim reporter from gatsby (#29669)
1 parent 06e9337 commit 249905a

File tree

22 files changed

+40
-25
lines changed

22 files changed

+40
-25
lines changed

packages/gatsby-plugin-page-creator/src/__tests__/collection-extract-query-string.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import sysPath from "path"
22
import fs from "fs-extra"
33
import { collectionExtractQueryString } from "../collection-extract-query-string"
4-
import reporter from "gatsby-cli/lib/reporter"
4+
import reporter from "gatsby/reporter"
55

6-
jest.mock(`gatsby-cli/lib/reporter`)
6+
jest.mock(`gatsby/reporter`, () => {
7+
return {
8+
panicOnBuild: jest.fn(),
9+
}
10+
})
711

812
// This makes the tests work on windows properly
913
const createPath = (path: string): string => path.replace(/\//g, sysPath.sep)

packages/gatsby-plugin-page-creator/src/__tests__/derive-path.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { derivePath } from "../derive-path"
2-
import reporter from "gatsby-cli/lib/reporter"
2+
import reporter from "gatsby/reporter"
33

44
describe(`derive-path`, () => {
55
it(`has basic support`, () => {

packages/gatsby-plugin-page-creator/src/__tests__/is-valid-collection-path-implementation.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { isValidCollectionPathImplementation } from "../is-valid-collection-path-implementation"
2-
import reporter from "gatsby-cli/lib/reporter"
2+
import reporter from "gatsby/reporter"
33
import syspath from "path"
44

5-
jest.mock(`gatsby-cli/lib/reporter`)
5+
jest.mock(`gatsby/reporter`, () => {
6+
return {
7+
panicOnBuild: jest.fn(),
8+
}
9+
})
610

711
// windows and mac have different seperators, all code is written with unix-like
812
// file systems, but the underlying code uses `path.sep`. So when running tests

packages/gatsby-plugin-page-creator/src/collection-extract-query-string.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { generateQueryFromString } from "./extract-query"
22
import fs from "fs-extra"
3-
import { Reporter } from "gatsby"
3+
import { Reporter } from "gatsby/reporter"
44
import { extractModel } from "./path-utils"
55
import { CODES, prefixId } from "./error-utils"
66

packages/gatsby-plugin-page-creator/src/create-page-wrapper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { createClientOnlyPage } from "./create-client-only-page"
1010
import { createPagesFromCollectionBuilder } from "./create-pages-from-collection-builder"
1111
import systemPath from "path"
1212
import { trackFeatureIsUsed } from "gatsby-telemetry"
13-
import { Reporter } from "gatsby"
13+
import { Reporter } from "gatsby/reporter"
1414

1515
function pathIsCollectionBuilder(path: string): boolean {
1616
return path.includes(`{`)

packages/gatsby-plugin-page-creator/src/create-pages-from-collection-builder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Move this to gatsby-core-utils?
22
import { Actions, CreatePagesArgs } from "gatsby"
33
import { createPath } from "gatsby-page-utils"
4-
import { Reporter } from "gatsby"
4+
import { Reporter } from "gatsby/reporter"
55
import { Options as ISlugifyOptions } from "@sindresorhus/slugify"
66
import { reverseLookupParams } from "./extract-query"
77
import { getMatchPath } from "./get-match-path"

packages/gatsby-plugin-page-creator/src/derive-path.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from "lodash"
22
import slugify, { Options as ISlugifyOptions } from "@sindresorhus/slugify"
3-
import { Reporter } from "gatsby"
3+
import { Reporter } from "gatsby/reporter"
44
import {
55
extractFieldWithoutUnion,
66
extractAllCollectionSegments,

packages/gatsby-plugin-page-creator/src/error-utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Reporter } from "gatsby"
1+
import { Reporter } from "gatsby/reporter"
22

33
export const CODES = {
44
Generic: `12101`,

packages/gatsby-plugin-page-creator/src/is-valid-collection-path-implementation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sysPath from "path"
2-
import { Reporter } from "gatsby"
2+
import { Reporter } from "gatsby/reporter"
33
import { CODES, prefixId } from "./error-utils"
44
import { matchAllPolyfill } from "./path-utils"
55

packages/gatsby-plugin-sharp/src/__tests__/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const {
3838
setPluginOptions,
3939
} = require(`../plugin-options`)
4040

41-
jest.mock(`gatsby-cli/lib/reporter`, () => {
41+
jest.mock(`gatsby/reporter`, () => {
4242
return {
4343
log: jest.fn(),
4444
info: jest.fn(),

packages/gatsby-plugin-sharp/src/__tests__/utils.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
jest.mock(`gatsby-cli/lib/reporter`)
1+
jest.mock(`gatsby/reporter`)
22
jest.mock(`progress`)
33
const { calculateImageSizes } = require(`../utils`)
4-
const reporter = require(`gatsby-cli/lib/reporter`)
5-
const progress = require(`progress`)
4+
const reporter = require(`gatsby/reporter`)
65
const sharp = require(`sharp`)
76

87
const file = {

packages/gatsby-plugin-sharp/src/image-data.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-unused-expressions */
22
import { IGatsbyImageData, ISharpGatsbyImageArgs } from "gatsby-plugin-image"
33
import { GatsbyCache, Node } from "gatsby"
4-
import { Reporter } from "gatsby-cli/lib/reporter/reporter"
4+
import { Reporter } from "gatsby/reporter"
55
import { rgbToHex, calculateImageSizes, getSrcSet, getSizes } from "./utils"
66
import { traceSVG, getImageSizeAsync, base64, batchQueueImageResizing } from "."
77
import sharp from "./safe-sharp"

packages/gatsby-remark-code-repls/src/__tests__/gatsby-node.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jest.mock(`fs`, () => {
55
}
66
})
77
jest.mock(`recursive-readdir`, () => jest.fn())
8-
jest.mock(`gatsby-cli/lib/reporter`, () => {
8+
jest.mock(`gatsby/reporter`, () => {
99
return {
1010
panic: jest.fn(),
1111
}
@@ -15,7 +15,7 @@ const fs = require(`fs`)
1515
const nodePath = require(`path`)
1616
const readdir = require(`recursive-readdir`)
1717

18-
const reporter = require(`gatsby-cli/lib/reporter`)
18+
const reporter = require(`gatsby/reporter`)
1919

2020
const {
2121
OPTION_DEFAULT_REPL_DIRECTORY,

packages/gatsby-source-filesystem/src/__tests__/create-remote-file-node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jest.mock(`../create-file-node`, () => {
2727
createFileNode: jest.fn(),
2828
}
2929
})
30-
const reporter = require(`gatsby-cli/lib/reporter`)
30+
const reporter = require(`gatsby/reporter`)
3131

3232
const got = require(`got`)
3333
const createRemoteFileNode = require(`../create-remote-file-node`)

packages/gatsby-source-filesystem/src/__tests__/utils.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
jest.mock(`gatsby-cli/lib/reporter`)
2-
jest.mock(`progress`)
31
const { getRemoteFileExtension, getRemoteFileName } = require(`../utils`)
42

53
describe(`create remote file node`, () => {

packages/gatsby-source-wordpress/src/models/logger.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Reporter } from "gatsby"
1+
import { Reporter } from "gatsby/reporter"
22
import { formatLogMessage } from "~/utils/format-log-message"
33
import { IPluginOptions } from "./gatsby-api"
44

packages/gatsby-source-wordpress/src/steps/preview/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { formatLogMessage } from "~/utils/format-log-message"
1717
import { touchValidNodes } from "../source-nodes/update-nodes/fetch-node-updates"
1818

1919
import { IPluginOptions } from "~/models/gatsby-api"
20-
import { Reporter } from "gatsby"
20+
import { Reporter } from "gatsby/reporter"
2121

2222
export const inPreviewMode = (): boolean =>
2323
!!process.env.ENABLE_GATSBY_REFRESH_ENDPOINT &&

packages/gatsby-source-wordpress/src/steps/temp-prevent-multiple-instances.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { Reporter } from "gatsby"
1+
import { Reporter } from "gatsby/reporter"
22
import { formatLogMessage } from "../utils/format-log-message"
3+
34
let isWpSourcePluginInstalled = false
45

56
/**

packages/gatsby-transformer-remark/src/__tests__/extend-node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const extendNodeType = require(`../extend-node-type`)
44
const { createContentDigest } = require(`gatsby-core-utils`)
55
const { typeDefs } = require(`../create-schema-customization`)
66

7-
jest.mock(`gatsby-cli/lib/reporter`, () => {
7+
jest.mock(`gatsby/reporter`, () => {
88
return {
99
log: jest.fn(),
1010
info: jest.fn(),

packages/gatsby/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@
205205
"gatsby-admin-public/",
206206
"graphql.js",
207207
"graphql.d.ts",
208+
"reporter.js",
209+
"reporter.d.ts",
208210
"index.d.ts",
209211
"scripts/postinstall.js",
210212
"utils.js",

packages/gatsby/reporter.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import reporter from "gatsby-cli/lib/reporter"
2+
3+
export default reporter
4+
export type Reporter = typeof reporter

packages/gatsby/reporter.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use strict"
2+
3+
module.exports = require('gatsby-cli/lib/reporter/index.js').default;

0 commit comments

Comments
 (0)