Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: shim reporter from gatsby #29669

Merged
merged 2 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import sysPath from "path"
import fs from "fs-extra"
import { collectionExtractQueryString } from "../collection-extract-query-string"
import reporter from "gatsby-cli/lib/reporter"
import reporter from "gatsby/reporter"

jest.mock(`gatsby-cli/lib/reporter`)
jest.mock(`gatsby/reporter`, () => {
return {
panicOnBuild: jest.fn(),
}
})

// This makes the tests work on windows properly
const createPath = (path: string): string => path.replace(/\//g, sysPath.sep)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { derivePath } from "../derive-path"
import reporter from "gatsby-cli/lib/reporter"
import reporter from "gatsby/reporter"

describe(`derive-path`, () => {
it(`has basic support`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { isValidCollectionPathImplementation } from "../is-valid-collection-path-implementation"
import reporter from "gatsby-cli/lib/reporter"
import reporter from "gatsby/reporter"
import syspath from "path"

jest.mock(`gatsby-cli/lib/reporter`)
jest.mock(`gatsby/reporter`, () => {
return {
panicOnBuild: jest.fn(),
}
})

// windows and mac have different seperators, all code is written with unix-like
// file systems, but the underlying code uses `path.sep`. So when running tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateQueryFromString } from "./extract-query"
import fs from "fs-extra"
import { Reporter } from "gatsby"
import { Reporter } from "gatsby/reporter"
import { extractModel } from "./path-utils"
import { CODES, prefixId } from "./error-utils"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { createClientOnlyPage } from "./create-client-only-page"
import { createPagesFromCollectionBuilder } from "./create-pages-from-collection-builder"
import systemPath from "path"
import { trackFeatureIsUsed } from "gatsby-telemetry"
import { Reporter } from "gatsby"
import { Reporter } from "gatsby/reporter"

function pathIsCollectionBuilder(path: string): boolean {
return path.includes(`{`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Move this to gatsby-core-utils?
import { Actions, CreatePagesArgs } from "gatsby"
import { createPath } from "gatsby-page-utils"
import { Reporter } from "gatsby"
import { Reporter } from "gatsby/reporter"
import { Options as ISlugifyOptions } from "@sindresorhus/slugify"
import { reverseLookupParams } from "./extract-query"
import { getMatchPath } from "./get-match-path"
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-page-creator/src/derive-path.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from "lodash"
import slugify, { Options as ISlugifyOptions } from "@sindresorhus/slugify"
import { Reporter } from "gatsby"
import { Reporter } from "gatsby/reporter"
import {
extractFieldWithoutUnion,
extractAllCollectionSegments,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-page-creator/src/error-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Reporter } from "gatsby"
import { Reporter } from "gatsby/reporter"

export const CODES = {
Generic: `12101`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sysPath from "path"
import { Reporter } from "gatsby"
import { Reporter } from "gatsby/reporter"
import { CODES, prefixId } from "./error-utils"
import { matchAllPolyfill } from "./path-utils"

Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-sharp/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const {
setPluginOptions,
} = require(`../plugin-options`)

jest.mock(`gatsby-cli/lib/reporter`, () => {
jest.mock(`gatsby/reporter`, () => {
return {
log: jest.fn(),
info: jest.fn(),
Expand Down
5 changes: 2 additions & 3 deletions packages/gatsby-plugin-sharp/src/__tests__/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
jest.mock(`gatsby-cli/lib/reporter`)
jest.mock(`gatsby/reporter`)
jest.mock(`progress`)
const { calculateImageSizes } = require(`../utils`)
const reporter = require(`gatsby-cli/lib/reporter`)
const progress = require(`progress`)
const reporter = require(`gatsby/reporter`)
const sharp = require(`sharp`)

const file = {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-sharp/src/image-data.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-unused-expressions */
import { IGatsbyImageData, ISharpGatsbyImageArgs } from "gatsby-plugin-image"
import { GatsbyCache, Node } from "gatsby"
import { Reporter } from "gatsby-cli/lib/reporter/reporter"
import { Reporter } from "gatsby/reporter"
import { rgbToHex, calculateImageSizes, getSrcSet, getSizes } from "./utils"
import { traceSVG, getImageSizeAsync, base64, batchQueueImageResizing } from "."
import sharp from "./safe-sharp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jest.mock(`fs`, () => {
}
})
jest.mock(`recursive-readdir`, () => jest.fn())
jest.mock(`gatsby-cli/lib/reporter`, () => {
jest.mock(`gatsby/reporter`, () => {
return {
panic: jest.fn(),
}
Expand All @@ -15,7 +15,7 @@ const fs = require(`fs`)
const nodePath = require(`path`)
const readdir = require(`recursive-readdir`)

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

const {
OPTION_DEFAULT_REPL_DIRECTORY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jest.mock(`../create-file-node`, () => {
createFileNode: jest.fn(),
}
})
const reporter = require(`gatsby-cli/lib/reporter`)
const reporter = require(`gatsby/reporter`)

const got = require(`got`)
const createRemoteFileNode = require(`../create-remote-file-node`)
Expand Down
2 changes: 0 additions & 2 deletions packages/gatsby-source-filesystem/src/__tests__/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
jest.mock(`gatsby-cli/lib/reporter`)
jest.mock(`progress`)
const { getRemoteFileExtension, getRemoteFileName } = require(`../utils`)

describe(`create remote file node`, () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-source-wordpress/src/models/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Reporter } from "gatsby"
import { Reporter } from "gatsby/reporter"
import { formatLogMessage } from "~/utils/format-log-message"
import { IPluginOptions } from "./gatsby-api"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { formatLogMessage } from "~/utils/format-log-message"
import { touchValidNodes } from "../source-nodes/update-nodes/fetch-node-updates"

import { IPluginOptions } from "~/models/gatsby-api"
import { Reporter } from "gatsby"
import { Reporter } from "gatsby/reporter"

export const inPreviewMode = (): boolean =>
!!process.env.ENABLE_GATSBY_REFRESH_ENDPOINT &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Reporter } from "gatsby"
import { Reporter } from "gatsby/reporter"
import { formatLogMessage } from "../utils/format-log-message"

let isWpSourcePluginInstalled = false

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const extendNodeType = require(`../extend-node-type`)
const { createContentDigest } = require(`gatsby-core-utils`)
const { typeDefs } = require(`../create-schema-customization`)

jest.mock(`gatsby-cli/lib/reporter`, () => {
jest.mock(`gatsby/reporter`, () => {
return {
log: jest.fn(),
info: jest.fn(),
Expand Down
2 changes: 2 additions & 0 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@
"gatsby-admin-public/",
"graphql.js",
"graphql.d.ts",
"reporter.js",
"reporter.d.ts",
"index.d.ts",
"scripts/postinstall.js",
"utils.js",
Expand Down
4 changes: 4 additions & 0 deletions packages/gatsby/reporter.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import reporter from "gatsby-cli/lib/reporter"

export default reporter
export type Reporter = typeof reporter
3 changes: 3 additions & 0 deletions packages/gatsby/reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict"

module.exports = require('gatsby-cli/lib/reporter/index.js').default;