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

[pull] master from gatsbyjs:master #198

Merged
merged 2 commits into from
Oct 14, 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
1 change: 1 addition & 0 deletions docs/docs/how-to/sourcing-data/headless-cms.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ The following CMSs have high popularity among Gatsby users and support key funct
| [Cockpit](https://getcockpit.com/) | | [docs](/plugins/gatsby-plugin-cockpit) | |
| [CraftCMS](https://craftcms.com/) | | [docs](/plugins/gatsby-source-craftcms) | |
| [Agility CMS](https://agilitycms.com/) | [guide](/docs/sourcing-from-agilitycms/) | [docs](/plugins/@agility/gatsby-source-agilitycms/) | [starter](/starters/agility/agility-gatsby-starter/) |
| [Prepr CMS](https://prepr.io/) | [guide](https://docs.prepr.io/docs/frontend-integrations/v1/gatsby) | | |
| [Forestry](https://forestry.io/) | [guide](/docs/sourcing-from-forestry/) | | |
| [Gentics Mesh](https://getmesh.io) | [guide](/docs/sourcing-from-gentics-mesh) | | |
| [Seams-CMS](https://seams-cms.com/) | [guide](/docs/sourcing-from-seams-cms) | | |
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/query/__tests__/data-tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jest.mock(`gatsby-cli/lib/reporter`, () => {
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
verbose: jest.fn(),
panicOnBuild: console.log,
activityTimer: () => {
return {
Expand Down
8 changes: 4 additions & 4 deletions packages/gatsby/src/redux/actions/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const { getPageMode } = require(`../../utils/page-mode`)
const normalizePath = require(`../../utils/normalize-path`).default
import { createJobV2FromInternalJob } from "./internal"
import { maybeSendJobToMainProcess } from "../../utils/jobs/worker-messaging"
import { warnOnce } from "../../utils/warn-once"
import { reportOnce } from "../../utils/report-once"
import fs from "fs-extra"

const isNotTestEnv = process.env.NODE_ENV !== `test`
Expand Down Expand Up @@ -1198,7 +1198,7 @@ actions.createJob = (job: Job, plugin?: ?Plugin = null) => {
if (plugin?.name) {
msg = msg + ` (called by ${plugin.name})`
}
warnOnce(msg)
reportOnce(msg)

return {
type: `CREATE_JOB`,
Expand Down Expand Up @@ -1252,7 +1252,7 @@ actions.setJob = (job: Job, plugin?: ?Plugin = null) => {
if (plugin?.name) {
msg = msg + ` (called by ${plugin.name})`
}
warnOnce(msg)
reportOnce(msg)

return {
type: `SET_JOB`,
Expand All @@ -1279,7 +1279,7 @@ actions.endJob = (job: Job, plugin?: ?Plugin = null) => {
if (plugin?.name) {
msg = msg + ` (called by ${plugin.name})`
}
warnOnce(msg)
reportOnce(msg)

return {
type: `END_JOB`,
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/schema/__tests__/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jest.mock(`gatsby-cli/lib/reporter`, () => {
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
verbose: jest.fn(),
activityTimer: () => {
return {
start: jest.fn(),
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/schema/__tests__/rebuild-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jest.mock(`gatsby-cli/lib/reporter`, () => {
log: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
verbose: jest.fn(),
activityTimer: () => {
return {
start: jest.fn(),
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/schema/infer/__tests__/infer-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jest.mock(`gatsby-cli/lib/reporter`, () => {
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
verbose: jest.fn(),
activityTimer: () => {
return {
start: jest.fn(),
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/schema/infer/__tests__/infer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jest.mock(`gatsby-cli/lib/reporter`, () => {
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
verbose: jest.fn(),
activityTimer: () => {
return {
start: jest.fn(),
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/schema/infer/__tests__/merge-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jest.mock(`gatsby-cli/lib/reporter`, () => {
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
verbose: jest.fn(),
activityTimer: () => {
return {
start: jest.fn(),
Expand Down
7 changes: 4 additions & 3 deletions packages/gatsby/src/schema/infer/add-inferred-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const report = require(`gatsby-cli/lib/reporter`)
import { isFile } from "./is-file"
import { isDate } from "../types/date"
import { addDerivedType } from "../types/derived-types"
import { warnOnce } from "../../utils/warn-once"
import { reportOnce } from "../../utils/report-once"
import { is32BitInteger } from "../../utils/is-32-bit-integer"
const { getDataStore } = require(`../../datastore`)

Expand Down Expand Up @@ -35,10 +35,11 @@ const addInferredFields = ({
})

if (deprecatedNodeKeys.size > 0) {
warnOnce(
reportOnce(
`The ___NODE convention is deprecated. Please use the @link directive instead.\nType: ${typeComposer.getTypeName()}, Keys: ${Array.from(
deprecatedNodeKeys
).join(`, `)}\nMigration: https://gatsby.dev/node-convention-deprecation`
).join(`, `)}\nMigration: https://gatsby.dev/node-convention-deprecation`,
`verbose`
)
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/schema/types/__tests__/filter-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jest.mock(`gatsby-cli/lib/reporter`, () => {
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
verbose: jest.fn(),
activityTimer: () => {
return {
start: jest.fn(),
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/src/utils/page-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
IMaterializePageMode,
PageMode,
} from "../redux/types"
import { warnOnce } from "./warn-once"
import { reportOnce } from "./report-once"

/**
* In develop IGatsbyPage["mode"] can change at any time, so as a general rule we need to resolve it
Expand Down Expand Up @@ -48,7 +48,7 @@ function resolvePageMode(
pageMode !== `SSG` &&
(page.path === `/404.html` || page.path === `/500.html`)
) {
warnOnce(
reportOnce(
`Status page "${page.path}" ignores page mode ("${pageMode}") and force sets it to SSG (this page can't be lazily rendered).`
)
pageMode = `SSG`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { isWorker } from "gatsby-worker"

const displayedWarnings = new Set<string>()

export const warnOnce = (message: string, key?: string): void => {
export const reportOnce = (
message: string,
method: "log" | "warn" | "info" | "success" | "verbose" | "error" = `warn`,
key?: string
): void => {
const messageId = key ?? message
if (!displayedWarnings.has(messageId) && !isWorker) {
displayedWarnings.add(messageId)
reporter.warn(message)
reporter[method](message)
}
}