From ba0597b4bc6f5c949675992827599feda04be438 Mon Sep 17 00:00:00 2001 From: Blaine Kasten Date: Fri, 19 Jun 2020 09:21:21 -0500 Subject: [PATCH] chore(release): Publish - gatsby-admin@0.1.70 - gatsby-react-router-scroll@3.0.4 - gatsby-theme-blog-core@1.5.45 - gatsby-theme-blog@1.6.45 - gatsby-theme-notes@1.3.71 - gatsby-theme-ui-preset@0.0.60 - gatsby@2.23.6 --- packages/gatsby-admin/CHANGELOG.md | 4 + packages/gatsby-admin/package.json | 4 +- .../gatsby-react-router-scroll/CHANGELOG.md | 6 + .../gatsby-react-router-scroll/package.json | 2 +- .../lib/catch-exit-signals.d.ts | 2 + .../gatsby-reporter/lib/catch-exit-signals.js | 54 +++ packages/gatsby-reporter/lib/constants.d.ts | 39 ++ packages/gatsby-reporter/lib/constants.js | 62 ++++ .../lib/get-error-formater.d.ts | 2 + .../gatsby-reporter/lib/get-error-formater.js | 49 +++ packages/gatsby-reporter/lib/index.d.ts | 9 + packages/gatsby-reporter/lib/index.js | 36 ++ .../gatsby-reporter/lib/loggers/ink/cli.d.ts | 18 + .../gatsby-reporter/lib/loggers/ink/cli.js | 143 ++++++++ .../lib/loggers/ink/components/develop.d.ts | 3 + .../lib/loggers/ink/components/develop.js | 92 +++++ .../lib/loggers/ink/components/error.d.ts | 6 + .../lib/loggers/ink/components/error.js | 76 ++++ .../lib/loggers/ink/components/messages.d.ts | 9 + .../lib/loggers/ink/components/messages.js | 69 ++++ .../loggers/ink/components/progress-bar.d.ts | 8 + .../loggers/ink/components/progress-bar.js | 51 +++ .../lib/loggers/ink/components/spinner.d.ts | 7 + .../lib/loggers/ink/components/spinner.js | 27 ++ .../lib/loggers/ink/components/utils.d.ts | 4 + .../lib/loggers/ink/components/utils.js | 24 ++ .../lib/loggers/ink/context.d.ts | 5 + .../lib/loggers/ink/context.js | 32 ++ .../lib/loggers/ink/index.d.ts | 1 + .../gatsby-reporter/lib/loggers/ink/index.js | 31 ++ .../lib/loggers/ipc/index.d.ts | 1 + .../gatsby-reporter/lib/loggers/ipc/index.js | 65 ++++ .../lib/loggers/json/index.d.ts | 1 + .../gatsby-reporter/lib/loggers/json/index.js | 39 ++ .../lib/loggers/yurnalist/index.d.ts | 1 + .../lib/loggers/yurnalist/index.js | 153 ++++++++ .../gatsby-reporter/lib/patch-console.d.ts | 2 + packages/gatsby-reporter/lib/patch-console.js | 33 ++ .../gatsby-reporter/lib/redux/actions.d.ts | 60 +++ packages/gatsby-reporter/lib/redux/actions.js | 44 +++ packages/gatsby-reporter/lib/redux/index.d.ts | 14 + packages/gatsby-reporter/lib/redux/index.js | 84 +++++ .../lib/redux/internal-actions.d.ts | 65 ++++ .../lib/redux/internal-actions.js | 317 ++++++++++++++++ .../gatsby-reporter/lib/redux/reducer.d.ts | 2 + packages/gatsby-reporter/lib/redux/reducer.js | 111 ++++++ packages/gatsby-reporter/lib/redux/types.d.ts | 102 ++++++ packages/gatsby-reporter/lib/redux/types.js | 1 + packages/gatsby-reporter/lib/redux/utils.d.ts | 13 + packages/gatsby-reporter/lib/redux/utils.js | 93 +++++ .../gatsby-reporter/lib/reporter-phantom.d.ts | 9 + .../gatsby-reporter/lib/reporter-phantom.js | 38 ++ .../lib/reporter-progress.d.ts | 13 + .../gatsby-reporter/lib/reporter-progress.js | 117 ++++++ .../gatsby-reporter/lib/reporter-timer.d.ts | 11 + .../gatsby-reporter/lib/reporter-timer.js | 67 ++++ packages/gatsby-reporter/lib/reporter.d.ts | 66 ++++ packages/gatsby-reporter/lib/reporter.js | 273 ++++++++++++++ .../gatsby-reporter/lib/start-logger.d.ts | 1 + packages/gatsby-reporter/lib/start-logger.js | 53 +++ .../__tests__/construct-error.d.ts | 1 + .../__tests__/error-map.d.ts | 1 + .../__tests__/error-schema.d.ts | 1 + .../structured-errors/construct-error.d.ts | 3 + .../lib/structured-errors/construct-error.js | 53 +++ .../lib/structured-errors/error-map.d.ts | 259 +++++++++++++ .../lib/structured-errors/error-map.js | 342 ++++++++++++++++++ .../lib/structured-errors/error-schema.d.ts | 5 + .../lib/structured-errors/error-schema.js | 43 +++ .../sanitize-structured-stack-trace.d.ts | 3 + .../sanitize-structured-stack-trace.js | 45 +++ .../lib/structured-errors/types.d.ts | 52 +++ .../lib/structured-errors/types.js | 23 ++ packages/gatsby-reporter/lib/types.d.ts | 39 ++ packages/gatsby-reporter/lib/types.js | 1 + packages/gatsby-theme-blog-core/CHANGELOG.md | 4 + packages/gatsby-theme-blog-core/package.json | 4 +- packages/gatsby-theme-blog/CHANGELOG.md | 4 + packages/gatsby-theme-blog/package.json | 6 +- packages/gatsby-theme-notes/CHANGELOG.md | 4 + packages/gatsby-theme-notes/package.json | 4 +- packages/gatsby-theme-ui-preset/CHANGELOG.md | 4 + packages/gatsby-theme-ui-preset/package.json | 4 +- packages/gatsby/CHANGELOG.md | 4 + packages/gatsby/package.json | 4 +- 85 files changed, 3623 insertions(+), 14 deletions(-) create mode 100644 packages/gatsby-reporter/lib/catch-exit-signals.d.ts create mode 100644 packages/gatsby-reporter/lib/catch-exit-signals.js create mode 100644 packages/gatsby-reporter/lib/constants.d.ts create mode 100644 packages/gatsby-reporter/lib/constants.js create mode 100644 packages/gatsby-reporter/lib/get-error-formater.d.ts create mode 100644 packages/gatsby-reporter/lib/get-error-formater.js create mode 100644 packages/gatsby-reporter/lib/index.d.ts create mode 100644 packages/gatsby-reporter/lib/index.js create mode 100644 packages/gatsby-reporter/lib/loggers/ink/cli.d.ts create mode 100644 packages/gatsby-reporter/lib/loggers/ink/cli.js create mode 100644 packages/gatsby-reporter/lib/loggers/ink/components/develop.d.ts create mode 100644 packages/gatsby-reporter/lib/loggers/ink/components/develop.js create mode 100644 packages/gatsby-reporter/lib/loggers/ink/components/error.d.ts create mode 100644 packages/gatsby-reporter/lib/loggers/ink/components/error.js create mode 100644 packages/gatsby-reporter/lib/loggers/ink/components/messages.d.ts create mode 100644 packages/gatsby-reporter/lib/loggers/ink/components/messages.js create mode 100644 packages/gatsby-reporter/lib/loggers/ink/components/progress-bar.d.ts create mode 100644 packages/gatsby-reporter/lib/loggers/ink/components/progress-bar.js create mode 100644 packages/gatsby-reporter/lib/loggers/ink/components/spinner.d.ts create mode 100644 packages/gatsby-reporter/lib/loggers/ink/components/spinner.js create mode 100644 packages/gatsby-reporter/lib/loggers/ink/components/utils.d.ts create mode 100644 packages/gatsby-reporter/lib/loggers/ink/components/utils.js create mode 100644 packages/gatsby-reporter/lib/loggers/ink/context.d.ts create mode 100644 packages/gatsby-reporter/lib/loggers/ink/context.js create mode 100644 packages/gatsby-reporter/lib/loggers/ink/index.d.ts create mode 100644 packages/gatsby-reporter/lib/loggers/ink/index.js create mode 100644 packages/gatsby-reporter/lib/loggers/ipc/index.d.ts create mode 100644 packages/gatsby-reporter/lib/loggers/ipc/index.js create mode 100644 packages/gatsby-reporter/lib/loggers/json/index.d.ts create mode 100644 packages/gatsby-reporter/lib/loggers/json/index.js create mode 100644 packages/gatsby-reporter/lib/loggers/yurnalist/index.d.ts create mode 100644 packages/gatsby-reporter/lib/loggers/yurnalist/index.js create mode 100644 packages/gatsby-reporter/lib/patch-console.d.ts create mode 100644 packages/gatsby-reporter/lib/patch-console.js create mode 100644 packages/gatsby-reporter/lib/redux/actions.d.ts create mode 100644 packages/gatsby-reporter/lib/redux/actions.js create mode 100644 packages/gatsby-reporter/lib/redux/index.d.ts create mode 100644 packages/gatsby-reporter/lib/redux/index.js create mode 100644 packages/gatsby-reporter/lib/redux/internal-actions.d.ts create mode 100644 packages/gatsby-reporter/lib/redux/internal-actions.js create mode 100644 packages/gatsby-reporter/lib/redux/reducer.d.ts create mode 100644 packages/gatsby-reporter/lib/redux/reducer.js create mode 100644 packages/gatsby-reporter/lib/redux/types.d.ts create mode 100644 packages/gatsby-reporter/lib/redux/types.js create mode 100644 packages/gatsby-reporter/lib/redux/utils.d.ts create mode 100644 packages/gatsby-reporter/lib/redux/utils.js create mode 100644 packages/gatsby-reporter/lib/reporter-phantom.d.ts create mode 100644 packages/gatsby-reporter/lib/reporter-phantom.js create mode 100644 packages/gatsby-reporter/lib/reporter-progress.d.ts create mode 100644 packages/gatsby-reporter/lib/reporter-progress.js create mode 100644 packages/gatsby-reporter/lib/reporter-timer.d.ts create mode 100644 packages/gatsby-reporter/lib/reporter-timer.js create mode 100644 packages/gatsby-reporter/lib/reporter.d.ts create mode 100644 packages/gatsby-reporter/lib/reporter.js create mode 100644 packages/gatsby-reporter/lib/start-logger.d.ts create mode 100644 packages/gatsby-reporter/lib/start-logger.js create mode 100644 packages/gatsby-reporter/lib/structured-errors/__tests__/construct-error.d.ts create mode 100644 packages/gatsby-reporter/lib/structured-errors/__tests__/error-map.d.ts create mode 100644 packages/gatsby-reporter/lib/structured-errors/__tests__/error-schema.d.ts create mode 100644 packages/gatsby-reporter/lib/structured-errors/construct-error.d.ts create mode 100644 packages/gatsby-reporter/lib/structured-errors/construct-error.js create mode 100644 packages/gatsby-reporter/lib/structured-errors/error-map.d.ts create mode 100644 packages/gatsby-reporter/lib/structured-errors/error-map.js create mode 100644 packages/gatsby-reporter/lib/structured-errors/error-schema.d.ts create mode 100644 packages/gatsby-reporter/lib/structured-errors/error-schema.js create mode 100644 packages/gatsby-reporter/lib/structured-errors/sanitize-structured-stack-trace.d.ts create mode 100644 packages/gatsby-reporter/lib/structured-errors/sanitize-structured-stack-trace.js create mode 100644 packages/gatsby-reporter/lib/structured-errors/types.d.ts create mode 100644 packages/gatsby-reporter/lib/structured-errors/types.js create mode 100644 packages/gatsby-reporter/lib/types.d.ts create mode 100644 packages/gatsby-reporter/lib/types.js diff --git a/packages/gatsby-admin/CHANGELOG.md b/packages/gatsby-admin/CHANGELOG.md index 237beef76fe83..c066a071b95da 100644 --- a/packages/gatsby-admin/CHANGELOG.md +++ b/packages/gatsby-admin/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.1.70](https://github.com/gatsbyjs/gatsby/compare/gatsby-admin@0.1.69...gatsby-admin@0.1.70) (2020-06-19) + +**Note:** Version bump only for package gatsby-admin + ## [0.1.69](https://github.com/gatsbyjs/gatsby/compare/gatsby-admin@0.1.68...gatsby-admin@0.1.69) (2020-06-19) ### Bug Fixes diff --git a/packages/gatsby-admin/package.json b/packages/gatsby-admin/package.json index f8fdc29845b3f..16476cbe600b8 100644 --- a/packages/gatsby-admin/package.json +++ b/packages/gatsby-admin/package.json @@ -1,6 +1,6 @@ { "name": "gatsby-admin", - "version": "0.1.69", + "version": "0.1.70", "main": "index.js", "author": "Max Stoiber", "license": "MIT", @@ -17,7 +17,7 @@ "@typescript-eslint/parser": "^2.28.0", "csstype": "^2.6.10", "formik": "^2.1.4", - "gatsby": "^2.23.5", + "gatsby": "^2.23.6", "gatsby-interface": "0.0.167", "gatsby-plugin-typescript": "^2.4.6", "gatsby-source-graphql": "^2.5.5", diff --git a/packages/gatsby-react-router-scroll/CHANGELOG.md b/packages/gatsby-react-router-scroll/CHANGELOG.md index fef579e699029..b88f3f8038cdf 100644 --- a/packages/gatsby-react-router-scroll/CHANGELOG.md +++ b/packages/gatsby-react-router-scroll/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [3.0.4](https://github.com/gatsbyjs/gatsby/compare/gatsby-react-router-scroll@3.0.3...gatsby-react-router-scroll@3.0.4) (2020-06-19) + +### Bug Fixes + +- Several Fixes for Scroll Handling and Restoration ([#24306](https://github.com/gatsbyjs/gatsby/issues/24306)) ([4c0916b](https://github.com/gatsbyjs/gatsby/commit/4c0916b)) + ## [3.0.3](https://github.com/gatsbyjs/gatsby/compare/gatsby-react-router-scroll@3.0.2...gatsby-react-router-scroll@3.0.3) (2020-06-09) **Note:** Version bump only for package gatsby-react-router-scroll diff --git a/packages/gatsby-react-router-scroll/package.json b/packages/gatsby-react-router-scroll/package.json index fc7641f25aba3..6a9c516e05571 100644 --- a/packages/gatsby-react-router-scroll/package.json +++ b/packages/gatsby-react-router-scroll/package.json @@ -1,7 +1,7 @@ { "name": "gatsby-react-router-scroll", "description": "React Router scroll management forked from https://github.com/ytase/react-router-scroll for Gatsby", - "version": "3.0.3", + "version": "3.0.4", "author": "Jimmy Jia", "bugs": { "url": "https://github.com/gatsbyjs/gatsby/issues" diff --git a/packages/gatsby-reporter/lib/catch-exit-signals.d.ts b/packages/gatsby-reporter/lib/catch-exit-signals.d.ts new file mode 100644 index 0000000000000..d6cff1927be77 --- /dev/null +++ b/packages/gatsby-reporter/lib/catch-exit-signals.d.ts @@ -0,0 +1,2 @@ +export declare const prematureEnd: () => void; +export declare const catchExitSignals: () => void; diff --git a/packages/gatsby-reporter/lib/catch-exit-signals.js b/packages/gatsby-reporter/lib/catch-exit-signals.js new file mode 100644 index 0000000000000..936f3b8c891df --- /dev/null +++ b/packages/gatsby-reporter/lib/catch-exit-signals.js @@ -0,0 +1,54 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.catchExitSignals = exports.prematureEnd = void 0; + +var _signalExit = _interopRequireDefault(require("signal-exit")); + +var _redux = require("./redux"); + +var _actions = require("./redux/actions"); + +var _constants = require("./constants"); + +var _reporter = require("./reporter"); + +/* + * This module is used to catch if the user kills the gatsby process via cmd+c + * When this happens, there is some clean up logic we need to fire offf + */ +const interruptActivities = () => { + const { + activities + } = (0, _redux.getStore)().getState().logs; + Object.keys(activities).forEach(activityId => { + const activity = activities[activityId]; + + if (activity.status === _constants.ActivityStatuses.InProgress || activity.status === _constants.ActivityStatuses.NotStarted) { + _reporter.reporter.completeActivity(activityId, _constants.ActivityStatuses.Interrupted); + } + }); +}; + +const prematureEnd = () => { + // hack so at least one activity is surely failed, so + // we are guaranteed to generate FAILED status + // if none of activity did explicitly fail + (0, _actions.createPendingActivity)({ + id: `panic`, + status: _constants.ActivityStatuses.Failed + }); + interruptActivities(); +}; + +exports.prematureEnd = prematureEnd; + +const catchExitSignals = () => { + (0, _signalExit.default)((code, signal) => { + if (code !== 0 && signal !== `SIGINT` && signal !== `SIGTERM`) prematureEnd();else interruptActivities(); + }); +}; + +exports.catchExitSignals = catchExitSignals; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/constants.d.ts b/packages/gatsby-reporter/lib/constants.d.ts new file mode 100644 index 0000000000000..5216469ee7068 --- /dev/null +++ b/packages/gatsby-reporter/lib/constants.d.ts @@ -0,0 +1,39 @@ +export declare enum Actions { + LogAction = "LOG_ACTION", + SetStatus = "SET_STATUS", + Log = "LOG", + SetLogs = "SET_LOGS", + StartActivity = "ACTIVITY_START", + EndActivity = "ACTIVITY_END", + UpdateActivity = "ACTIVITY_UPDATE", + PendingActivity = "ACTIVITY_PENDING", + CancelActivity = "ACTIVITY_CANCEL", + ActivityErrored = "ACTIVITY_ERRORED" +} +export declare enum LogLevels { + Debug = "DEBUG", + Success = "SUCCESS", + Info = "INFO", + Warning = "WARNING", + Log = "LOG", + Error = "ERROR" +} +export declare enum ActivityLogLevels { + Success = "ACTIVITY_SUCCESS", + Failed = "ACTIVITY_FAILED", + Interrupted = "ACTIVITY_INTERRUPTED" +} +export declare enum ActivityStatuses { + InProgress = "IN_PROGRESS", + NotStarted = "NOT_STARTED", + Interrupted = "INTERRUPTED", + Failed = "FAILED", + Success = "SUCCESS", + Cancelled = "CANCELLED" +} +export declare enum ActivityTypes { + Spinner = "spinner", + Hidden = "hidden", + Progress = "progress", + Pending = "pending" +} diff --git a/packages/gatsby-reporter/lib/constants.js b/packages/gatsby-reporter/lib/constants.js new file mode 100644 index 0000000000000..45a269a0c472a --- /dev/null +++ b/packages/gatsby-reporter/lib/constants.js @@ -0,0 +1,62 @@ +"use strict"; + +exports.__esModule = true; +exports.ActivityTypes = exports.ActivityStatuses = exports.ActivityLogLevels = exports.LogLevels = exports.Actions = void 0; +let Actions; +exports.Actions = Actions; + +(function (Actions) { + Actions["LogAction"] = "LOG_ACTION"; + Actions["SetStatus"] = "SET_STATUS"; + Actions["Log"] = "LOG"; + Actions["SetLogs"] = "SET_LOGS"; + Actions["StartActivity"] = "ACTIVITY_START"; + Actions["EndActivity"] = "ACTIVITY_END"; + Actions["UpdateActivity"] = "ACTIVITY_UPDATE"; + Actions["PendingActivity"] = "ACTIVITY_PENDING"; + Actions["CancelActivity"] = "ACTIVITY_CANCEL"; + Actions["ActivityErrored"] = "ACTIVITY_ERRORED"; +})(Actions || (exports.Actions = Actions = {})); + +let LogLevels; +exports.LogLevels = LogLevels; + +(function (LogLevels) { + LogLevels["Debug"] = "DEBUG"; + LogLevels["Success"] = "SUCCESS"; + LogLevels["Info"] = "INFO"; + LogLevels["Warning"] = "WARNING"; + LogLevels["Log"] = "LOG"; + LogLevels["Error"] = "ERROR"; +})(LogLevels || (exports.LogLevels = LogLevels = {})); + +let ActivityLogLevels; +exports.ActivityLogLevels = ActivityLogLevels; + +(function (ActivityLogLevels) { + ActivityLogLevels["Success"] = "ACTIVITY_SUCCESS"; + ActivityLogLevels["Failed"] = "ACTIVITY_FAILED"; + ActivityLogLevels["Interrupted"] = "ACTIVITY_INTERRUPTED"; +})(ActivityLogLevels || (exports.ActivityLogLevels = ActivityLogLevels = {})); + +let ActivityStatuses; +exports.ActivityStatuses = ActivityStatuses; + +(function (ActivityStatuses) { + ActivityStatuses["InProgress"] = "IN_PROGRESS"; + ActivityStatuses["NotStarted"] = "NOT_STARTED"; + ActivityStatuses["Interrupted"] = "INTERRUPTED"; + ActivityStatuses["Failed"] = "FAILED"; + ActivityStatuses["Success"] = "SUCCESS"; + ActivityStatuses["Cancelled"] = "CANCELLED"; +})(ActivityStatuses || (exports.ActivityStatuses = ActivityStatuses = {})); + +let ActivityTypes; +exports.ActivityTypes = ActivityTypes; + +(function (ActivityTypes) { + ActivityTypes["Spinner"] = "spinner"; + ActivityTypes["Hidden"] = "hidden"; + ActivityTypes["Progress"] = "progress"; + ActivityTypes["Pending"] = "pending"; +})(ActivityTypes || (exports.ActivityTypes = ActivityTypes = {})); \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/get-error-formater.d.ts b/packages/gatsby-reporter/lib/get-error-formater.d.ts new file mode 100644 index 0000000000000..8de727c96a591 --- /dev/null +++ b/packages/gatsby-reporter/lib/get-error-formater.d.ts @@ -0,0 +1,2 @@ +import PrettyError from "pretty-error"; +export declare function getErrorFormatter(): PrettyError; diff --git a/packages/gatsby-reporter/lib/get-error-formater.js b/packages/gatsby-reporter/lib/get-error-formater.js new file mode 100644 index 0000000000000..a55c5411a238e --- /dev/null +++ b/packages/gatsby-reporter/lib/get-error-formater.js @@ -0,0 +1,49 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.getErrorFormatter = getErrorFormatter; + +var _prettyError = _interopRequireDefault(require("pretty-error")); + +function getErrorFormatter() { + const prettyError = new _prettyError.default(); + const baseRender = prettyError.render; + prettyError.skipNodeFiles(); + prettyError.skipPackage(`regenerator-runtime`, `graphql`, `core-js` // `static-site-generator-webpack-plugin`, + // `tapable`, // webpack + ); // @ts-ignore the type defs in prettyError are wrong + + prettyError.skip(traceLine => { + if (traceLine && traceLine.file === `asyncToGenerator.js`) return true; + return false; + }); + prettyError.appendStyle({ + "pretty-error": { + marginTop: 1 + }, + "pretty-error > header": { + background: `red` + }, + "pretty-error > header > colon": { + color: `white` + } + }); + + if (process.env.FORCE_COLOR === `0`) { + prettyError.withoutColors(); + } + + prettyError.render = err => { + if (Array.isArray(err)) { + return err.map(e => prettyError.render(e)).join(`\n`); + } + + let rendered = baseRender.call(prettyError, err); + if (`codeFrame` in err) rendered = `\n${err.codeFrame}\n${rendered}`; + return rendered; + }; + + return prettyError; +} \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/index.d.ts b/packages/gatsby-reporter/lib/index.d.ts new file mode 100644 index 0000000000000..84ebe9969e52a --- /dev/null +++ b/packages/gatsby-reporter/lib/index.d.ts @@ -0,0 +1,9 @@ +import { reporter } from "./reporter"; +import { setStore } from "./redux"; +import { IGatsbyCLIState } from "./redux/types"; +import { IActivityArgs, IPhantomReporter, IProgressReporter } from "./types"; +export { reporter }; +export { setStore }; +export declare const reduxLogReducer: (state: IGatsbyCLIState | undefined, action: import("./redux/types").ActionsUnion) => IGatsbyCLIState; +export { IActivityArgs, IPhantomReporter, IProgressReporter, IGatsbyCLIState }; +export declare type IGatsbyReporter = typeof reporter; diff --git a/packages/gatsby-reporter/lib/index.js b/packages/gatsby-reporter/lib/index.js new file mode 100644 index 0000000000000..0482b3741fcf7 --- /dev/null +++ b/packages/gatsby-reporter/lib/index.js @@ -0,0 +1,36 @@ +"use strict"; + +exports.__esModule = true; +exports.reduxLogReducer = void 0; + +var _startLogger = require("./start-logger"); + +var _patchConsole = require("./patch-console"); + +var _catchExitSignals = require("./catch-exit-signals"); + +var _reporter = require("./reporter"); + +exports.reporter = _reporter.reporter; + +var _redux = require("./redux"); + +exports.setStore = _redux.setStore; + +var _reducer = require("./redux/reducer"); + +var _types = require("./redux/types"); + +exports.IGatsbyCLIState = _types.IGatsbyCLIState; + +var _types2 = require("./types"); + +exports.IActivityArgs = _types2.IActivityArgs; +exports.IPhantomReporter = _types2.IPhantomReporter; +exports.IProgressReporter = _types2.IProgressReporter; +(0, _catchExitSignals.catchExitSignals)(); +(0, _startLogger.startLogger)(); +(0, _patchConsole.patchConsole)(_reporter.reporter); +const reduxLogReducer = _reducer.reducer; // Types + +exports.reduxLogReducer = reduxLogReducer; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/loggers/ink/cli.d.ts b/packages/gatsby-reporter/lib/loggers/ink/cli.d.ts new file mode 100644 index 0000000000000..cbea1dbc5f3c6 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/cli.d.ts @@ -0,0 +1,18 @@ +import React from "react"; +import { IGatsbyCLIState } from "../../redux/types"; +interface ICLIProps { + logs: IGatsbyCLIState; + showStatusBar: boolean; +} +interface ICLIState { + hasError: boolean; + error?: Error; +} +declare class CLI extends React.Component { + readonly state: ICLIState; + memoizedReactElementsForMessages: React.ReactElement[]; + componentDidCatch(error: Error, info: React.ErrorInfo): void; + static getDerivedStateFromError(error: Error): ICLIState; + render(): React.ReactElement; +} +export default CLI; diff --git a/packages/gatsby-reporter/lib/loggers/ink/cli.js b/packages/gatsby-reporter/lib/loggers/ink/cli.js new file mode 100644 index 0000000000000..5528193cfd77c --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/cli.js @@ -0,0 +1,143 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = void 0; + +var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); + +var _react = _interopRequireDefault(require("react")); + +var _ink = require("ink"); + +var _gatsbyTelemetry = require("gatsby-telemetry"); + +var _spinner = require("./components/spinner"); + +var _progressBar = require("./components/progress-bar"); + +var _messages = require("./components/messages"); + +var _error = require("./components/error"); + +var _develop = _interopRequireDefault(require("./components/develop")); + +var _constants = require("../../constants"); + +var _gatsbyCoreUtils = require("gatsby-core-utils"); + +// Some CI pipelines incorrectly report process.stdout.isTTY status, +// which causes unwanted lines in the output. An additional check for isCI helps. +// @see https://github.com/prettier/prettier/blob/36aeb4ce4f620023c8174e826d7208c0c64f1a0b/src/utils/is-tty.js +const showProgress = process.stdout.isTTY && !(0, _gatsbyCoreUtils.isCI)(); + +class CLI extends _react.default.Component { + constructor(...args) { + super(...args); + this.state = { + hasError: false + }; + this.memoizedReactElementsForMessages = []; + } + + componentDidCatch(error, info) { + (0, _gatsbyTelemetry.trackBuildError)(`INK`, { + error: { + stack: info.componentStack, + text: error.message, + context: {} + } + }); + } + + static getDerivedStateFromError(error) { + return { + hasError: true, + error + }; + } + + render() { + const { + logs: { + messages, + activities + }, + showStatusBar + } = this.props; + const { + hasError, + error + } = this.state; + + if (hasError && error) { + // You can render any custom fallback UI + return /*#__PURE__*/_react.default.createElement(_ink.Box, { + flexDirection: "row" + }, /*#__PURE__*/_react.default.createElement(_messages.Message, { + level: _constants.ActivityLogLevels.Failed, + text: `We've encountered an error: ${error.message}` + })); + } + /* + Only operation on messages array is to push new message into it. Once + message is there it can't change. Because of that we can do single + transform from message object to react element and store it. + This will avoid calling React.createElement completely for every message + that can't change. + */ + + + if (messages.length > this.memoizedReactElementsForMessages.length) { + for (let index = this.memoizedReactElementsForMessages.length; index < messages.length; index++) { + const msg = messages[index]; + this.memoizedReactElementsForMessages.push(msg.level === `ERROR` ? /*#__PURE__*/_react.default.createElement(_error.Error, { + details: msg, + key: index + }) : /*#__PURE__*/_react.default.createElement(_messages.Message, (0, _extends2.default)({ + key: index + }, msg))); + } + } + + const spinners = []; + const progressBars = []; + + if (showProgress) { + Object.keys(activities).forEach(activityName => { + const activity = activities[activityName]; + + if (activity.status !== `IN_PROGRESS`) { + return; + } + + if (activity.type === `spinner`) { + spinners.push(activity); + } + + if (activity.type === `progress` && activity.startTime) { + progressBars.push(activity); + } + }); + } + + return /*#__PURE__*/_react.default.createElement(_ink.Box, { + flexDirection: "column" + }, /*#__PURE__*/_react.default.createElement(_ink.Box, { + flexDirection: "column" + }, /*#__PURE__*/_react.default.createElement(_ink.Static, null, this.memoizedReactElementsForMessages), spinners.map(activity => /*#__PURE__*/_react.default.createElement(_spinner.Spinner, (0, _extends2.default)({ + key: activity.id + }, activity))), progressBars.map(activity => /*#__PURE__*/_react.default.createElement(_progressBar.ProgressBar, { + key: activity.id, + message: activity.text, + total: activity.total || 0, + current: activity.current || 0, + startTime: activity.startTime || [0, 0] + }))), showStatusBar && /*#__PURE__*/_react.default.createElement(_develop.default, null)); + } + +} + +var _default = CLI; +exports.default = _default; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/loggers/ink/components/develop.d.ts b/packages/gatsby-reporter/lib/loggers/ink/components/develop.d.ts new file mode 100644 index 0000000000000..17a178402773b --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/components/develop.d.ts @@ -0,0 +1,3 @@ +import React from "react"; +declare const ConnectedDevelop: React.FC; +export default ConnectedDevelop; diff --git a/packages/gatsby-reporter/lib/loggers/ink/components/develop.js b/packages/gatsby-reporter/lib/loggers/ink/components/develop.js new file mode 100644 index 0000000000000..cc6f288cc9765 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/components/develop.js @@ -0,0 +1,92 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); + +exports.__esModule = true; +exports.default = void 0; + +var _react = _interopRequireWildcard(require("react")); + +var _ink = require("ink"); + +var _context = _interopRequireDefault(require("../context")); + +var _constants = require("../../../constants"); + +var _utils = require("./utils"); + +const getLabel = level => { + switch (level) { + case _constants.ActivityStatuses.InProgress: + return (0, _utils.createLabel)(`In Progress`, `white`); + + case _constants.ActivityStatuses.Interrupted: + return (0, _utils.createLabel)(`Interrupted`, `gray`); + + case _constants.ActivityStatuses.Failed: + return (0, _utils.createLabel)(`Failed`, `red`); + + case _constants.ActivityStatuses.Success: + return (0, _utils.createLabel)(`Success`, `green`); + + default: + return (0, _utils.createLabel)(level, `white`); + } +}; // Track the width and height of the terminal. Responsive app design baby! + + +const useTerminalResize = () => { + const { + stdout + } = (0, _react.useContext)(_ink.StdoutContext); + const [sizes, setSizes] = (0, _react.useState)([stdout.columns, stdout.rows]); + (0, _react.useEffect)(() => { + const resizeListener = () => { + setSizes([stdout.columns, stdout.rows]); + }; + + stdout.on(`resize`, resizeListener); + return () => { + stdout.off(`resize`, resizeListener); + }; + }, [stdout]); + return sizes; +}; + +const Develop = ({ + pagesCount, + appName, + status +}) => { + const [width] = useTerminalResize(); + const StatusLabel = getLabel(status); + return /*#__PURE__*/_react.default.createElement(_ink.Box, { + flexDirection: "column", + marginTop: 2 + }, /*#__PURE__*/_react.default.createElement(_ink.Box, { + textWrap: `truncate` + }, `—`.repeat(width)), /*#__PURE__*/_react.default.createElement(_ink.Box, { + height: 1, + flexDirection: "row" + }, /*#__PURE__*/_react.default.createElement(StatusLabel, null), /*#__PURE__*/_react.default.createElement(_ink.Box, { + flexGrow: 1 + }), /*#__PURE__*/_react.default.createElement(_ink.Color, null, appName), /*#__PURE__*/_react.default.createElement(_ink.Box, { + flexGrow: 1 + }), /*#__PURE__*/_react.default.createElement(_ink.Color, null, pagesCount, " pages"))); +}; + +const ConnectedDevelop = () => { + var _state$pages, _state$program, _state$logs; + + const state = (0, _react.useContext)(_context.default); + return /*#__PURE__*/_react.default.createElement(Develop, { + pagesCount: ((_state$pages = state.pages) === null || _state$pages === void 0 ? void 0 : _state$pages.size) || 0, + appName: ((_state$program = state.program) === null || _state$program === void 0 ? void 0 : _state$program.sitePackageJson.name) || ``, + status: ((_state$logs = state.logs) === null || _state$logs === void 0 ? void 0 : _state$logs.status) || `` + }); +}; + +var _default = ConnectedDevelop; +exports.default = _default; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/loggers/ink/components/error.d.ts b/packages/gatsby-reporter/lib/loggers/ink/components/error.d.ts new file mode 100644 index 0000000000000..0c940e8f388ba --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/components/error.d.ts @@ -0,0 +1,6 @@ +import { FunctionComponent } from "react"; +import { IStructuredError } from "../../../structured-errors/types"; +export interface IErrorProps { + details: IStructuredError; +} +export declare const Error: FunctionComponent; diff --git a/packages/gatsby-reporter/lib/loggers/ink/components/error.js b/packages/gatsby-reporter/lib/loggers/ink/components/error.js new file mode 100644 index 0000000000000..814c3f88b95c8 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/components/error.js @@ -0,0 +1,76 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.Error = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _path = _interopRequireDefault(require("path")); + +var _ink = require("ink"); + +const File = ({ + filePath, + location +}) => { + const lineNumber = location === null || location === void 0 ? void 0 : location.start.line; + let locString = ``; + + if (typeof lineNumber !== `undefined`) { + locString += `:${lineNumber}`; + const columnNumber = location === null || location === void 0 ? void 0 : location.start.column; + + if (typeof columnNumber !== `undefined`) { + locString += `:${columnNumber}`; + } + } + + return /*#__PURE__*/_react.default.createElement(_ink.Color, { + blue: true + }, _path.default.relative(process.cwd(), filePath), locString); +}; + +const DocsLink = ({ + docsUrl +}) => { + // TODO: when there's no specific docsUrl, add helpful message describing how + // to submit an issue + if (docsUrl === `https://gatsby.dev/issue-how-to`) return null; + return /*#__PURE__*/_react.default.createElement(_ink.Box, { + marginTop: 1 + }, "See our docs page for more info on this error: ", docsUrl); +}; + +const Error = /*#__PURE__*/_react.default.memo(({ + details +}) => +/*#__PURE__*/ +// const stackLength = get(details, `stack.length`, 0 +_react.default.createElement(_ink.Box, { + marginY: 1, + flexDirection: "column" +}, /*#__PURE__*/_react.default.createElement(_ink.Box, { + flexDirection: "column" +}, /*#__PURE__*/_react.default.createElement(_ink.Box, { + flexDirection: "column" +}, /*#__PURE__*/_react.default.createElement(_ink.Box, null, /*#__PURE__*/_react.default.createElement(_ink.Box, { + marginRight: 1 +}, /*#__PURE__*/_react.default.createElement(_ink.Color, { + black: true, + bgRed: true +}, ` ${details.level} `, details.code ? `#${details.code} ` : ``), /*#__PURE__*/_react.default.createElement(_ink.Color, { + red: true +}, details.type ? ` ` + details.type : ``))), /*#__PURE__*/_react.default.createElement(_ink.Box, { + marginTop: 1 +}, details.text), details.filePath && /*#__PURE__*/_react.default.createElement(_ink.Box, { + marginTop: 1 +}, "File:", ` `, /*#__PURE__*/_react.default.createElement(File, { + filePath: details.filePath, + location: details.location +}))), /*#__PURE__*/_react.default.createElement(DocsLink, { + docsUrl: details.docsUrl +})))); + +exports.Error = Error; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/loggers/ink/components/messages.d.ts b/packages/gatsby-reporter/lib/loggers/ink/components/messages.d.ts new file mode 100644 index 0000000000000..339e132ef4ba7 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/components/messages.d.ts @@ -0,0 +1,9 @@ +import React from "react"; +import { ActivityLogLevels, LogLevels } from "../../../constants"; +export interface IMessageProps { + level: ActivityLogLevels | LogLevels; + text: string; + duration?: number; + statusText?: string; +} +export declare const Message: React.NamedExoticComponent; diff --git a/packages/gatsby-reporter/lib/loggers/ink/components/messages.js b/packages/gatsby-reporter/lib/loggers/ink/components/messages.js new file mode 100644 index 0000000000000..1078ae67ee386 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/components/messages.js @@ -0,0 +1,69 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.Message = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _ink = require("ink"); + +var _utils = require("./utils"); + +var _constants = require("../../../constants"); + +const getLabel = level => { + switch (level) { + case _constants.ActivityLogLevels.Success: + case _constants.LogLevels.Success: + return (0, _utils.createLabel)(`success`, `green`); + + case _constants.LogLevels.Warning: + return (0, _utils.createLabel)(`warn`, `yellow`); + + case _constants.LogLevels.Debug: + return (0, _utils.createLabel)(`verbose`, `gray`); + + case _constants.LogLevels.Info: + return (0, _utils.createLabel)(`info`, `blue`); + + case _constants.ActivityLogLevels.Failed: + return (0, _utils.createLabel)(`failed`, `red`); + + case _constants.ActivityLogLevels.Interrupted: + return (0, _utils.createLabel)(`not finished`, `gray`); + + default: + return (0, _utils.createLabel)(level, `blue`); + } +}; + +const Message = /*#__PURE__*/_react.default.memo(({ + level, + text, + duration, + statusText +}) => { + let message = text; + + if (duration) { + message += ` - ${duration.toFixed(3)}s`; + } + + if (statusText) { + message += ` - ${statusText}`; + } + + if (!level || level === `LOG`) { + return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, message); + } + + const TextLabel = getLabel(level); + return /*#__PURE__*/_react.default.createElement(_ink.Box, { + textWrap: "wrap", + flexDirection: "row" + }, /*#__PURE__*/_react.default.createElement(TextLabel, null), ` `, message); +}); + +exports.Message = Message; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/loggers/ink/components/progress-bar.d.ts b/packages/gatsby-reporter/lib/loggers/ink/components/progress-bar.d.ts new file mode 100644 index 0000000000000..2d81c021e0dfb --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/components/progress-bar.d.ts @@ -0,0 +1,8 @@ +/// +export interface IProgressbarProps { + message: string; + current: number; + total: number; + startTime: [number, number]; +} +export declare function ProgressBar({ message, current, total, startTime, }: IProgressbarProps): JSX.Element; diff --git a/packages/gatsby-reporter/lib/loggers/ink/components/progress-bar.js b/packages/gatsby-reporter/lib/loggers/ink/components/progress-bar.js new file mode 100644 index 0000000000000..f23667a95cbdd --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/components/progress-bar.js @@ -0,0 +1,51 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.ProgressBar = ProgressBar; + +var _react = _interopRequireDefault(require("react")); + +var _ink = require("ink"); + +var _convertHrtime = _interopRequireDefault(require("convert-hrtime")); + +function calcElapsedTime(startTime) { + const elapsed = process.hrtime(startTime); + return (0, _convertHrtime.default)(elapsed)[`seconds`].toFixed(3); +} + +const maxWidth = 30; +const minWidth = 10; + +const getLength = prop => String(prop).length; + +function ProgressBar({ + message, + current, + total, + startTime +}) { + const percentage = total ? Math.round(current / total * 100) : 0; + const terminalWidth = process.stdout.columns || 80; + const availableWidth = terminalWidth - getLength(message) - getLength(current) - getLength(total) - getLength(percentage) - 11; // margins + extra characters + + const progressBarWidth = Math.max(minWidth, Math.min(maxWidth, availableWidth)); + return /*#__PURE__*/_react.default.createElement(_ink.Box, { + flexDirection: "row" + }, /*#__PURE__*/_react.default.createElement(_ink.Box, { + marginRight: 3, + width: progressBarWidth + }, "[", /*#__PURE__*/_react.default.createElement(_ink.Box, { + width: progressBarWidth - 2 + }, `=`.repeat((progressBarWidth - 2) * percentage / 100)), "]"), /*#__PURE__*/_react.default.createElement(_ink.Box, { + marginRight: 1 + }, calcElapsedTime(startTime), " s"), /*#__PURE__*/_react.default.createElement(_ink.Box, { + marginRight: 1 + }, current, "/", total), /*#__PURE__*/_react.default.createElement(_ink.Box, { + marginRight: 1 + }, `` + percentage, "%"), /*#__PURE__*/_react.default.createElement(_ink.Box, { + textWrap: "truncate" + }, message)); +} \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/loggers/ink/components/spinner.d.ts b/packages/gatsby-reporter/lib/loggers/ink/components/spinner.d.ts new file mode 100644 index 0000000000000..0fb6c7b111404 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/components/spinner.d.ts @@ -0,0 +1,7 @@ +/// +interface ISpinnerProps { + text: string; + statusText?: string; +} +export declare function Spinner({ text, statusText }: ISpinnerProps): JSX.Element; +export {}; diff --git a/packages/gatsby-reporter/lib/loggers/ink/components/spinner.js b/packages/gatsby-reporter/lib/loggers/ink/components/spinner.js new file mode 100644 index 0000000000000..0d9ecf7f11822 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/components/spinner.js @@ -0,0 +1,27 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.Spinner = Spinner; + +var _react = _interopRequireDefault(require("react")); + +var _ink = require("ink"); + +var _inkSpinner = _interopRequireDefault(require("ink-spinner")); + +function Spinner({ + text, + statusText +}) { + let label = text; + + if (statusText) { + label += ` — ${statusText}`; + } + + return /*#__PURE__*/_react.default.createElement(_ink.Box, null, /*#__PURE__*/_react.default.createElement(_inkSpinner.default, { + type: "dots" + }), " ", label); +} \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/loggers/ink/components/utils.d.ts b/packages/gatsby-reporter/lib/loggers/ink/components/utils.d.ts new file mode 100644 index 0000000000000..59a5e9fca02c5 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/components/utils.d.ts @@ -0,0 +1,4 @@ +import { FunctionComponent } from "react"; +import { ColorProps } from "ink"; +export declare const ColorSwitcher: FunctionComponent; +export declare const createLabel: (text: string, color: string) => FunctionComponent; diff --git a/packages/gatsby-reporter/lib/loggers/ink/components/utils.js b/packages/gatsby-reporter/lib/loggers/ink/components/utils.js new file mode 100644 index 0000000000000..92128a7f7ce13 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/components/utils.js @@ -0,0 +1,24 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.createLabel = exports.ColorSwitcher = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _ink = require("ink"); + +const ColorSwitcher = ({ + children, + ...props +}) => /*#__PURE__*/_react.default.createElement(_ink.Color, props, children); + +exports.ColorSwitcher = ColorSwitcher; + +const createLabel = (text, color) => (...props) => /*#__PURE__*/_react.default.createElement(ColorSwitcher, { + [color]: true, + ...props +}, text); + +exports.createLabel = createLabel; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/loggers/ink/context.d.ts b/packages/gatsby-reporter/lib/loggers/ink/context.d.ts new file mode 100644 index 0000000000000..86b9bef4c63a1 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/context.d.ts @@ -0,0 +1,5 @@ +import React from "react"; +import { IGatsbyState } from "gatsby/src/redux/types"; +declare const StoreStateContext: React.Context; +export declare const StoreStateProvider: React.FC; +export default StoreStateContext; diff --git a/packages/gatsby-reporter/lib/loggers/ink/context.js b/packages/gatsby-reporter/lib/loggers/ink/context.js new file mode 100644 index 0000000000000..0a643a08d86a7 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/context.js @@ -0,0 +1,32 @@ +"use strict"; + +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); + +exports.__esModule = true; +exports.default = exports.StoreStateProvider = void 0; + +var _react = _interopRequireWildcard(require("react")); + +var _redux = require("../../redux"); + +// These weird castings we are doing in this file is because the way gatsby-cli works is that it starts with it's own store +// but then quickly swaps it out with the store from the installed gatsby. This would benefit from a refactor later on +// to not use it's own store temporarily. +// By the time this is actually running, it will become an `IGatsbyState` +const StoreStateContext = (0, _react.createContext)((0, _redux.getStore)().getState()); + +const StoreStateProvider = ({ + children +}) => { + const [state, setState] = (0, _react.useState)((0, _redux.getStore)().getState()); + (0, _react.useEffect)(() => (0, _redux.onLogAction)(() => { + setState((0, _redux.getStore)().getState()); + }), []); + return /*#__PURE__*/_react.default.createElement(StoreStateContext.Provider, { + value: state + }, children); +}; + +exports.StoreStateProvider = StoreStateProvider; +var _default = StoreStateContext; +exports.default = _default; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/loggers/ink/index.d.ts b/packages/gatsby-reporter/lib/loggers/ink/index.d.ts new file mode 100644 index 0000000000000..0e5254266a499 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/index.d.ts @@ -0,0 +1 @@ +export declare function initializeINKLogger(): void; diff --git a/packages/gatsby-reporter/lib/loggers/ink/index.js b/packages/gatsby-reporter/lib/loggers/ink/index.js new file mode 100644 index 0000000000000..928f500658483 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ink/index.js @@ -0,0 +1,31 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); + +exports.__esModule = true; +exports.initializeINKLogger = initializeINKLogger; + +var _react = _interopRequireWildcard(require("react")); + +var _ink = require("ink"); + +var _context = _interopRequireWildcard(require("./context")); + +var _cli = _interopRequireDefault(require("./cli")); + +const ConnectedCLI = () => { + var _state$program, _state$program$_, _state$program2; + + const state = (0, _react.useContext)(_context.default); + const showStatusBar = ((_state$program = state.program) === null || _state$program === void 0 ? void 0 : (_state$program$_ = _state$program._) === null || _state$program$_ === void 0 ? void 0 : _state$program$_[0]) === `develop` && ((_state$program2 = state.program) === null || _state$program2 === void 0 ? void 0 : _state$program2.status) === `BOOTSTRAP_FINISHED`; + return /*#__PURE__*/_react.default.createElement(_cli.default, { + showStatusBar: Boolean(showStatusBar), + logs: state.logs + }); +}; + +function initializeINKLogger() { + (0, _ink.render)( /*#__PURE__*/_react.default.createElement(_context.StoreStateProvider, null, /*#__PURE__*/_react.default.createElement(ConnectedCLI, null))); +} \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/loggers/ipc/index.d.ts b/packages/gatsby-reporter/lib/loggers/ipc/index.d.ts new file mode 100644 index 0000000000000..6662d62898407 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ipc/index.d.ts @@ -0,0 +1 @@ +export declare const initializeIPCLogger: () => void; diff --git a/packages/gatsby-reporter/lib/loggers/ipc/index.js b/packages/gatsby-reporter/lib/loggers/ipc/index.js new file mode 100644 index 0000000000000..1a1e0013d446d --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/ipc/index.js @@ -0,0 +1,65 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.initializeIPCLogger = void 0; + +var _index = require("../../redux/index"); + +var _constants = require("../../constants"); + +var _stripAnsi = _interopRequireDefault(require("strip-ansi")); + +var _lodash = require("lodash"); + +const isStringPayload = action => typeof action.payload === `string`; +/** + * Payload can either be a String or an Object + * See more at integration-tests/structured-logging/__tests__/to-do.js + */ + + +const sanitizeAction = action => { + const copiedAction = (0, _lodash.cloneDeep)(action); + + if (isStringPayload(copiedAction)) { + return copiedAction; + } + + if (`text` in copiedAction.payload && copiedAction.payload.text) { + copiedAction.payload.text = (0, _stripAnsi.default)(copiedAction.payload.text); + } + + if (`statusText` in copiedAction.payload && copiedAction.payload.statusText) { + copiedAction.payload.statusText = (0, _stripAnsi.default)(copiedAction.payload.statusText); + } + + return copiedAction; +}; + +const initializeIPCLogger = () => { + (0, _index.onLogAction)(action => { + if (!process.send) return; + const sanitizedAction = sanitizeAction(action); // we mutate sanitizedAction but this is already deep copy of action so we should be good + + if (sanitizedAction.type === _constants.Actions.Log) { + // Don't emit Debug over IPC + if ([_constants.LogLevels.Debug].includes(sanitizedAction.payload.level)) { + return; + } // Override Success and Log types to Info over IPC + + + if ([_constants.LogLevels.Success, _constants.LogLevels.Log].includes(sanitizedAction.payload.level)) { + sanitizedAction.payload.level = _constants.LogLevels.Info; + } + } + + process.send({ + type: _constants.Actions.LogAction, + action: sanitizedAction + }); + }); +}; + +exports.initializeIPCLogger = initializeIPCLogger; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/loggers/json/index.d.ts b/packages/gatsby-reporter/lib/loggers/json/index.d.ts new file mode 100644 index 0000000000000..70a1ae461e46d --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/json/index.d.ts @@ -0,0 +1 @@ +export declare function initializeJSONLogger(): void; diff --git a/packages/gatsby-reporter/lib/loggers/json/index.js b/packages/gatsby-reporter/lib/loggers/json/index.js new file mode 100644 index 0000000000000..bcccbfed46f26 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/json/index.js @@ -0,0 +1,39 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.initializeJSONLogger = initializeJSONLogger; + +var _index = require("../../redux/index"); + +var _stripAnsi = _interopRequireDefault(require("strip-ansi")); + +var _lodash = require("lodash"); + +const isStringPayload = action => typeof action.payload === `string`; + +const sanitizeAction = action => { + const copiedAction = (0, _lodash.cloneDeep)(action); + + if (isStringPayload(copiedAction)) { + return copiedAction; + } + + if (`text` in copiedAction.payload && copiedAction.payload.text) { + copiedAction.payload.text = (0, _stripAnsi.default)(copiedAction.payload.text); + } + + if (`statusText` in copiedAction.payload && copiedAction.payload.statusText) { + copiedAction.payload.statusText = (0, _stripAnsi.default)(copiedAction.payload.statusText); + } + + return copiedAction; +}; + +function initializeJSONLogger() { + (0, _index.onLogAction)(action => { + const sanitizedAction = sanitizeAction(action); + process.stdout.write(JSON.stringify(sanitizedAction) + `\n`); + }); +} \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/loggers/yurnalist/index.d.ts b/packages/gatsby-reporter/lib/loggers/yurnalist/index.d.ts new file mode 100644 index 0000000000000..43f087adbfffb --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/yurnalist/index.d.ts @@ -0,0 +1 @@ +export declare function initializeYurnalistLogger(): void; diff --git a/packages/gatsby-reporter/lib/loggers/yurnalist/index.js b/packages/gatsby-reporter/lib/loggers/yurnalist/index.js new file mode 100644 index 0000000000000..99a6dd5aa9419 --- /dev/null +++ b/packages/gatsby-reporter/lib/loggers/yurnalist/index.js @@ -0,0 +1,153 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.initializeYurnalistLogger = initializeYurnalistLogger; + +var _redux = require("../../redux"); + +var _constants = require("../../constants"); + +var _yurnalist = require("yurnalist"); + +var _progress = _interopRequireDefault(require("progress")); + +var _chalk = _interopRequireDefault(require("chalk")); + +function initializeYurnalistLogger() { + const activities = {}; + const yurnalist = (0, _yurnalist.createReporter)({ + emoji: true, + verbose: true + }); + const levelToYurnalist = { + [_constants.LogLevels.Log]: yurnalist.log.bind(yurnalist), + [_constants.LogLevels.Warning]: yurnalist.warn.bind(yurnalist), + [_constants.LogLevels.Error]: yurnalist.error.bind(yurnalist), + [_constants.LogLevels.Info]: yurnalist.info.bind(yurnalist), + [_constants.LogLevels.Success]: yurnalist.success.bind(yurnalist), + [_constants.ActivityLogLevels.Success]: yurnalist.success.bind(yurnalist), + [_constants.ActivityLogLevels.Failed]: text => { + yurnalist.log(`${_chalk.default.red(`failed`)} ${text}`); + }, + [_constants.ActivityLogLevels.Interrupted]: text => { + yurnalist.log(`${_chalk.default.gray(`not finished`)} ${text}`); + } + }; + (0, _redux.onLogAction)(action => { + switch (action.type) { + case _constants.Actions.Log: + { + const yurnalistMethod = levelToYurnalist[action.payload.level]; + + if (!yurnalistMethod) { + process.stdout.write(`NO "${action.payload.level}" method\n`); + } else { + let message = action.payload.text; + + if (action.payload.duration) { + message += ` - ${action.payload.duration.toFixed(3)}s`; + } + + if (action.payload.statusText) { + message += ` - ${action.payload.statusText}`; + } + + yurnalistMethod(message); + } + + break; + } + + case _constants.Actions.StartActivity: + { + if (action.payload.type === _constants.ActivityTypes.Spinner) { + const spinner = yurnalist.activity(); + spinner.tick(action.payload.text); + const activity = { + text: action.payload.text, + statusText: action.payload.statusText, + + update(payload) { + // TODO: I'm not convinced that this is ever called with a text property. + // From searching the codebase it appears that we do not ever assign a text + // property during the IUpdateActivity action. + if (payload.text) { + activity.text = payload.text; + } + + if (payload.statusText) { + activity.statusText = payload.statusText; + } + + let message = activity.text; + + if (activity.statusText) { + message += ` - ${activity.statusText}`; + } + + message += ` id:"${action.payload.id}"`; + spinner.tick(message); + }, + + end() { + spinner.end(); + } + + }; + activities[action.payload.id] = activity; + } else if (action.payload.type === _constants.ActivityTypes.Progress) { + const bar = new _progress.default(` [:bar] :current/:total :elapsed s :percent ${action.payload.text}`, { + total: action.payload.total, + curr: action.payload.current, + width: 30, + clear: true + }); + activities[action.payload.id] = { + text: undefined, + statusText: undefined, + + update(payload) { + if (payload.total) { + bar.total = payload.total; + } + + if (payload.current) { + bar.curr = payload.current; + } + + bar.tick(0); + }, + + end() {} + + }; + } + + break; + } + + case _constants.Actions.UpdateActivity: + { + const activity = activities[action.payload.id]; + + if (activity) { + activity.update(action.payload); + } + + break; + } + + case _constants.Actions.EndActivity: + { + const activity = activities[action.payload.id]; + + if (activity) { + activity.end(); + delete activities[action.payload.id]; + } + } + } + }); +} \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/patch-console.d.ts b/packages/gatsby-reporter/lib/patch-console.d.ts new file mode 100644 index 0000000000000..bccc24dbf9de5 --- /dev/null +++ b/packages/gatsby-reporter/lib/patch-console.d.ts @@ -0,0 +1,2 @@ +import { reporter as gatsbyReporter } from "./reporter"; +export declare function patchConsole(reporter: typeof gatsbyReporter): void; diff --git a/packages/gatsby-reporter/lib/patch-console.js b/packages/gatsby-reporter/lib/patch-console.js new file mode 100644 index 0000000000000..025e52efefc53 --- /dev/null +++ b/packages/gatsby-reporter/lib/patch-console.js @@ -0,0 +1,33 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.patchConsole = patchConsole; + +var _util = _interopRequireDefault(require("util")); + +/* + * This module is used to patch console through our reporter so we can track + * these logs + */ +function patchConsole(reporter) { + console.log = (...args) => { + const [format, ...rest] = args; + reporter.log(_util.default.format(format === undefined ? `` : format, ...rest)); + }; + + console.warn = (...args) => { + const [format, ...rest] = args; + reporter.warn(_util.default.format(format === undefined ? `` : format, ...rest)); + }; + + console.info = (...args) => { + const [format, ...rest] = args; + reporter.info(_util.default.format(format === undefined ? `` : format, ...rest)); + }; + + console.error = (format, ...args) => { + reporter.error(_util.default.format(format === undefined ? `` : format, ...args)); + }; +} \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/redux/actions.d.ts b/packages/gatsby-reporter/lib/redux/actions.d.ts new file mode 100644 index 0000000000000..bddff0843607b --- /dev/null +++ b/packages/gatsby-reporter/lib/redux/actions.d.ts @@ -0,0 +1,60 @@ +import { Dispatch } from "redux"; +export declare const createLog: ({ level, text, statusText, duration, group, code, type, filePath, location, docsUrl, context, activity_current, activity_total, activity_type, activity_uuid, stack, }: { + level: string; + text?: string | undefined; + statusText?: string | undefined; + duration?: number | undefined; + group?: string | undefined; + code?: string | undefined; + type?: string | undefined; + filePath?: string | undefined; + location?: { + start: import("../structured-errors/types").ILocationPosition; + end?: import("../structured-errors/types").ILocationPosition | undefined; + } | undefined; + docsUrl?: string | undefined; + context?: string | undefined; + activity_current?: number | undefined; + activity_total?: number | undefined; + activity_type?: string | undefined; + activity_uuid?: string | undefined; + stack?: import("../structured-errors/types").IStructuredStackFrame[] | undefined; +}) => import("./types").ICreateLog; +export declare const createPendingActivity: ({ id, status, }: { + id: string; + status?: import("../constants").ActivityStatuses | undefined; +}) => (import("./types").IPendingActivity | ((dispatch: Dispatch) => void))[]; +export declare const setStatus: (status: "" | import("../constants").ActivityStatuses, force?: boolean) => (dispatch: Dispatch) => void; +export declare const startActivity: ({ id, text, type, status, current, total, }: { + id: string; + text: string; + type: import("../constants").ActivityTypes; + status?: import("../constants").ActivityStatuses | undefined; + current?: number | undefined; + total?: number | undefined; +}) => (import("./types").IStartActivity | ((dispatch: Dispatch) => void))[]; +export declare const endActivity: ({ id, status, }: { + id: string; + status: import("../constants").ActivityStatuses; +}) => (import("./types").ICreateLog | import("./types").IEndActivity | import("./types").ICancelActivity | ((dispatch: Dispatch) => void))[] | null; +export declare const updateActivity: ({ id, ...rest }: { + id: string; + statusText?: string | undefined; + total?: number | undefined; + current?: number | undefined; +}) => import("./types").IUpdateActivity | null; +export declare const setActivityErrored: ({ id, }: { + id: string; +}) => import("./types").IActivityErrored | null; +export declare const setActivityStatusText: ({ id, statusText, }: { + id: string; + statusText: string; +}) => import("./types").IUpdateActivity | null; +export declare const setActivityTotal: ({ id, total, }: { + id: string; + total: number; +}) => import("./types").IUpdateActivity | null; +export declare const activityTick: ({ id, increment, }: { + id: string; + increment: number; +}) => import("./types").IUpdateActivity | null; diff --git a/packages/gatsby-reporter/lib/redux/actions.js b/packages/gatsby-reporter/lib/redux/actions.js new file mode 100644 index 0000000000000..62a6302b724e5 --- /dev/null +++ b/packages/gatsby-reporter/lib/redux/actions.js @@ -0,0 +1,44 @@ +"use strict"; + +exports.__esModule = true; +exports.activityTick = exports.setActivityTotal = exports.setActivityStatusText = exports.setActivityErrored = exports.updateActivity = exports.endActivity = exports.startActivity = exports.setStatus = exports.createPendingActivity = exports.createLog = void 0; + +var _redux = require("redux"); + +var _ = require("./"); + +var _internalActions = require("./internal-actions"); + +const actions = { + createLog: _internalActions.createLog, + createPendingActivity: _internalActions.createPendingActivity, + setStatus: _internalActions.setStatus, + startActivity: _internalActions.startActivity, + endActivity: _internalActions.endActivity, + updateActivity: _internalActions.updateActivity, + setActivityErrored: _internalActions.setActivityErrored, + setActivityStatusText: _internalActions.setActivityStatusText, + setActivityTotal: _internalActions.setActivityTotal, + activityTick: _internalActions.activityTick +}; +const boundActions = (0, _redux.bindActionCreators)(actions, _.dispatch); +const createLog = boundActions.createLog; +exports.createLog = createLog; +const createPendingActivity = boundActions.createPendingActivity; +exports.createPendingActivity = createPendingActivity; +const setStatus = boundActions.setStatus; +exports.setStatus = setStatus; +const startActivity = boundActions.startActivity; +exports.startActivity = startActivity; +const endActivity = boundActions.endActivity; +exports.endActivity = endActivity; +const updateActivity = boundActions.updateActivity; +exports.updateActivity = updateActivity; +const setActivityErrored = boundActions.setActivityErrored; +exports.setActivityErrored = setActivityErrored; +const setActivityStatusText = boundActions.setActivityStatusText; +exports.setActivityStatusText = setActivityStatusText; +const setActivityTotal = boundActions.setActivityTotal; +exports.setActivityTotal = setActivityTotal; +const activityTick = boundActions.activityTick; +exports.activityTick = activityTick; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/redux/index.d.ts b/packages/gatsby-reporter/lib/redux/index.d.ts new file mode 100644 index 0000000000000..4f7e0ecbf8a58 --- /dev/null +++ b/packages/gatsby-reporter/lib/redux/index.d.ts @@ -0,0 +1,14 @@ +import { ActionsUnion } from "./types"; +declare let store: import("redux").Store, ActionsUnion>; +declare type GatsbyCLIStore = typeof store; +declare type StoreListener = (store: GatsbyCLIStore) => void; +declare type ActionLogListener = (action: ActionsUnion) => any; +declare type Thunk = (...args: any[]) => ActionsUnion; +export declare const getStore: () => typeof store; +export declare const dispatch: (action: ActionsUnion | Thunk) => void; +export declare const onStoreSwap: (fn: StoreListener) => void; +export declare const onLogAction: (fn: ActionLogListener) => (() => void); +export declare const setStore: (s: GatsbyCLIStore) => void; +export {}; diff --git a/packages/gatsby-reporter/lib/redux/index.js b/packages/gatsby-reporter/lib/redux/index.js new file mode 100644 index 0000000000000..2fca2549d4a8f --- /dev/null +++ b/packages/gatsby-reporter/lib/redux/index.js @@ -0,0 +1,84 @@ +"use strict"; + +exports.__esModule = true; +exports.setStore = exports.onLogAction = exports.onStoreSwap = exports.dispatch = exports.getStore = void 0; + +var _redux = require("redux"); + +var _reducer = require("./reducer"); + +var _utils = require("./utils"); + +var _constants = require("../constants"); + +let store = (0, _redux.createStore)((0, _redux.combineReducers)({ + logs: _reducer.reducer +}), {}); +const storeSwapListeners = []; +const onLogActionListeners = new Set(); + +const getStore = () => store; + +exports.getStore = getStore; + +const dispatch = action => { + if (!action) { + return; + } + + if (Array.isArray(action)) { + action.forEach(item => dispatch(item)); + return; + } else if (typeof action === `function`) { + action(dispatch); + return; + } + + action = { ...action, + // eslint-disable-next-line @typescript-eslint/ban-ts-ignore + // @ts-ignore this is a typescript no-no.. + // And i'm pretty sure this timestamp isn't used anywhere. + // but for now, the structured logs integration tests expect it + // so it's easier to leave it and then explore as a follow up + timestamp: new Date().toJSON() + }; + store.dispatch(action); + + if ((0, _utils.isInternalAction)(action)) { + // consumers (ipc, yurnalist, json logger) shouldn't have to + // deal with actions needed just for internal tracking of status + return; + } + + for (const fn of onLogActionListeners) { + fn(action); + } +}; + +exports.dispatch = dispatch; + +const onStoreSwap = fn => { + storeSwapListeners.push(fn); +}; + +exports.onStoreSwap = onStoreSwap; + +const onLogAction = fn => { + onLogActionListeners.add(fn); + return () => { + onLogActionListeners.delete(fn); + }; +}; + +exports.onLogAction = onLogAction; + +const setStore = s => { + s.dispatch({ + type: _constants.Actions.SetLogs, + payload: store.getState().logs + }); + store = s; + storeSwapListeners.forEach(fn => fn(store)); +}; + +exports.setStore = setStore; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/redux/internal-actions.d.ts b/packages/gatsby-reporter/lib/redux/internal-actions.d.ts new file mode 100644 index 0000000000000..5a2189297de56 --- /dev/null +++ b/packages/gatsby-reporter/lib/redux/internal-actions.d.ts @@ -0,0 +1,65 @@ +import { Dispatch } from "redux"; +import { ActivityStatuses, ActivityTypes } from "../constants"; +import { IPendingActivity, ICreateLog, ISetStatus, IStartActivity, ICancelActivity, IEndActivity, IUpdateActivity, IActivityErrored, IGatsbyCLIState, ISetLogs } from "./types"; +import { IStructuredError } from "../structured-errors/types"; +export declare const setStatus: (status: ActivityStatuses | "", force?: boolean) => (dispatch: Dispatch) => void; +export declare const createLog: ({ level, text, statusText, duration, group, code, type, filePath, location, docsUrl, context, activity_current, activity_total, activity_type, activity_uuid, stack, }: { + level: string; + text?: string | undefined; + statusText?: string | undefined; + duration?: number | undefined; + group?: string | undefined; + code?: string | undefined; + type?: string | undefined; + filePath?: string | undefined; + location?: IStructuredError["location"]; + docsUrl?: string | undefined; + context?: string | undefined; + activity_current?: number | undefined; + activity_total?: number | undefined; + activity_type?: string | undefined; + activity_uuid?: string | undefined; + stack?: import("../structured-errors/types").IStructuredStackFrame[] | undefined; +}) => ICreateLog; +declare type ActionsToEmit = Array>; +export declare const createPendingActivity: ({ id, status, }: { + id: string; + status?: ActivityStatuses | undefined; +}) => ActionsToEmit; +declare type QueuedStartActivityActions = Array>; +export declare const startActivity: ({ id, text, type, status, current, total, }: { + id: string; + text: string; + type: ActivityTypes; + status?: ActivityStatuses | undefined; + current?: number | undefined; + total?: number | undefined; +}) => QueuedStartActivityActions; +declare type QueuedEndActivity = Array>; +export declare const endActivity: ({ id, status, }: { + id: string; + status: ActivityStatuses; +}) => QueuedEndActivity | null; +export declare const updateActivity: ({ id, ...rest }: { + id: string; + statusText?: string | undefined; + total?: number | undefined; + current?: number | undefined; +}) => IUpdateActivity | null; +export declare const setActivityErrored: ({ id, }: { + id: string; +}) => IActivityErrored | null; +export declare const setActivityStatusText: ({ id, statusText, }: { + id: string; + statusText: string; +}) => IUpdateActivity | null; +export declare const setActivityTotal: ({ id, total, }: { + id: string; + total: number; +}) => IUpdateActivity | null; +export declare const activityTick: ({ id, increment, }: { + id: string; + increment: number; +}) => IUpdateActivity | null; +export declare const setLogs: (logs: IGatsbyCLIState) => ISetLogs; +export {}; diff --git a/packages/gatsby-reporter/lib/redux/internal-actions.js b/packages/gatsby-reporter/lib/redux/internal-actions.js new file mode 100644 index 0000000000000..5a98669f341e0 --- /dev/null +++ b/packages/gatsby-reporter/lib/redux/internal-actions.js @@ -0,0 +1,317 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.setLogs = exports.activityTick = exports.setActivityTotal = exports.setActivityStatusText = exports.setActivityErrored = exports.updateActivity = exports.endActivity = exports.startActivity = exports.createPendingActivity = exports.createLog = exports.setStatus = void 0; + +var _v = _interopRequireDefault(require("uuid/v4")); + +var _gatsbyTelemetry = require("gatsby-telemetry"); + +var _signalExit = _interopRequireDefault(require("signal-exit")); + +var _ = require("./"); + +var _constants = require("../constants"); + +var _utils = require("./utils"); + +/* eslint-disable @typescript-eslint/camelcase */ +const ActivityStatusToLogLevel = { + [_constants.ActivityStatuses.Interrupted]: _constants.ActivityLogLevels.Interrupted, + [_constants.ActivityStatuses.Failed]: _constants.ActivityLogLevels.Failed, + [_constants.ActivityStatuses.Success]: _constants.ActivityLogLevels.Success +}; +let weShouldExit = false; +(0, _signalExit.default)(() => { + weShouldExit = true; +}); +let cancelDelayedSetStatus; // TODO: THIS IS NOT WORKING ATM + +const setStatus = (status, force = false) => dispatch => { + const currentStatus = (0, _.getStore)().getState().logs.status; + + if (cancelDelayedSetStatus) { + cancelDelayedSetStatus(); + cancelDelayedSetStatus = null; + } + + if (status !== currentStatus) { + if (status === `IN_PROGRESS` || force || weShouldExit) { + dispatch({ + type: _constants.Actions.SetStatus, + payload: status + }); + } else { + cancelDelayedSetStatus = (0, _utils.delayedCall)(() => { + setStatus(status, true)(dispatch); + }, 1000); + } + } +}; + +exports.setStatus = setStatus; + +const createLog = ({ + level, + text, + statusText, + duration, + group, + code, + type, + filePath, + location, + docsUrl, + context, + activity_current, + activity_total, + activity_type, + activity_uuid, + stack +}) => { + return { + type: _constants.Actions.Log, + payload: { + level, + text, + statusText, + duration, + group, + code, + type, + filePath, + location, + docsUrl, + context, + activity_current, + activity_total, + activity_type, + activity_uuid, + timestamp: new Date().toJSON(), + stack + } + }; +}; + +exports.createLog = createLog; + +const createPendingActivity = ({ + id, + status = _constants.ActivityStatuses.NotStarted +}) => { + const actionsToEmit = []; + const logsState = (0, _.getStore)().getState().logs; + const globalStatus = (0, _utils.getGlobalStatus)(id, status); + + if (globalStatus !== logsState.status) { + actionsToEmit.push(setStatus(globalStatus)); + } + + actionsToEmit.push({ + type: _constants.Actions.PendingActivity, + payload: { + id, + type: _constants.ActivityTypes.Pending, + status + } + }); + return actionsToEmit; +}; + +exports.createPendingActivity = createPendingActivity; + +const startActivity = ({ + id, + text, + type, + status = _constants.ActivityStatuses.InProgress, + current, + total +}) => { + const actionsToEmit = []; + const logsState = (0, _.getStore)().getState().logs; + const globalStatus = (0, _utils.getGlobalStatus)(id, status); + + if (globalStatus !== logsState.status) { + actionsToEmit.push(setStatus(globalStatus)); + } + + actionsToEmit.push({ + type: _constants.Actions.StartActivity, + payload: { + id, + uuid: (0, _v.default)(), + text, + type, + status, + startTime: process.hrtime(), + statusText: ``, + current, + total + } + }); + return actionsToEmit; +}; + +exports.startActivity = startActivity; + +const endActivity = ({ + id, + status +}) => { + const activity = (0, _utils.getActivity)(id); + + if (!activity) { + return null; + } + + const actionsToEmit = []; + const durationMS = (0, _utils.getElapsedTimeMS)(activity); + const durationS = durationMS / 1000; + + if (activity.type === _constants.ActivityTypes.Pending) { + actionsToEmit.push({ + type: _constants.Actions.CancelActivity, + payload: { + id, + status: _constants.ActivityStatuses.Cancelled, + type: activity.type, + duration: durationS + } + }); + } else if (activity.status === _constants.ActivityStatuses.InProgress) { + (0, _gatsbyTelemetry.trackCli)(`ACTIVITY_DURATION`, { + name: activity.text, + duration: Math.round(durationMS) + }); + + if (activity.errored) { + status = _constants.ActivityStatuses.Failed; + } + + actionsToEmit.push({ + type: _constants.Actions.EndActivity, + payload: { + uuid: activity.uuid, + id, + status, + duration: durationS, + type: activity.type + } + }); + + if (activity.type !== _constants.ActivityTypes.Hidden) { + actionsToEmit.push(createLog({ + text: activity.text, + level: ActivityStatusToLogLevel[status], + duration: durationS, + statusText: activity.statusText || (status === _constants.ActivityStatuses.Success && activity.type === _constants.ActivityTypes.Progress ? `${activity.current}/${activity.total} ${((activity.total || 0) / durationS).toFixed(2)}/s` : undefined), + activity_uuid: activity.uuid, + activity_current: activity.current, + activity_total: activity.total, + activity_type: activity.type + })); + } + } + + const logsState = (0, _.getStore)().getState().logs; + const globalStatus = (0, _utils.getGlobalStatus)(id, status); + + if (globalStatus !== logsState.status) { + actionsToEmit.push(setStatus(globalStatus)); + } + + return actionsToEmit; +}; + +exports.endActivity = endActivity; + +const updateActivity = ({ + id = ``, + ...rest +}) => { + const activity = (0, _utils.getActivity)(id); + + if (!activity) { + return null; + } + + return { + type: _constants.Actions.UpdateActivity, + payload: { + uuid: activity.uuid, + id, + ...rest + } + }; +}; + +exports.updateActivity = updateActivity; + +const setActivityErrored = ({ + id +}) => { + const activity = (0, _utils.getActivity)(id); + + if (!activity) { + return null; + } + + return { + type: _constants.Actions.ActivityErrored, + payload: { + id + } + }; +}; + +exports.setActivityErrored = setActivityErrored; + +const setActivityStatusText = ({ + id, + statusText +}) => updateActivity({ + id, + statusText +}); + +exports.setActivityStatusText = setActivityStatusText; + +const setActivityTotal = ({ + id, + total +}) => updateActivity({ + id, + total +}); + +exports.setActivityTotal = setActivityTotal; + +const activityTick = ({ + id, + increment = 1 +}) => { + const activity = (0, _utils.getActivity)(id); + + if (!activity) { + return null; + } + + return updateActivity({ + id, + current: (activity.current || 0) + increment + }); +}; + +exports.activityTick = activityTick; + +const setLogs = logs => { + return { + type: _constants.Actions.SetLogs, + payload: logs + }; +}; + +exports.setLogs = setLogs; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/redux/reducer.d.ts b/packages/gatsby-reporter/lib/redux/reducer.d.ts new file mode 100644 index 0000000000000..ed534e65aa57f --- /dev/null +++ b/packages/gatsby-reporter/lib/redux/reducer.d.ts @@ -0,0 +1,2 @@ +import { ActionsUnion, IGatsbyCLIState, ISetLogs } from "./types"; +export declare const reducer: (state: IGatsbyCLIState | undefined, action: ActionsUnion | ISetLogs) => IGatsbyCLIState; diff --git a/packages/gatsby-reporter/lib/redux/reducer.js b/packages/gatsby-reporter/lib/redux/reducer.js new file mode 100644 index 0000000000000..6ebd2ec5df830 --- /dev/null +++ b/packages/gatsby-reporter/lib/redux/reducer.js @@ -0,0 +1,111 @@ +"use strict"; + +exports.__esModule = true; +exports.reducer = void 0; + +var _constants = require("../constants"); + +const reducer = (state = { + messages: [], + activities: {}, + status: `` +}, action) => { + switch (action.type) { + case _constants.Actions.SetStatus: + { + return { ...state, + status: action.payload + }; + } + + case _constants.Actions.Log: + { + if (!action.payload.text) { + // set empty character to fix ink + action.payload.text = `\u2800`; + } + + return { ...state, + messages: [...state.messages, action.payload] + }; + } + + case _constants.Actions.StartActivity: + { + const { + id + } = action.payload; + return { ...state, + activities: { ...state.activities, + [id]: action.payload + } + }; + } + + case _constants.Actions.UpdateActivity: + case _constants.Actions.PendingActivity: + { + const { + id, + ...rest + } = action.payload; + const activity = state.activities[id]; + return { ...state, + activities: { ...state.activities, + [id]: { ...activity, + ...rest + } + } + }; + } + + case _constants.Actions.ActivityErrored: + { + const { + id + } = action.payload; + const activity = state.activities[id]; + return { ...state, + activities: { ...state.activities, + [id]: { ...activity, + errored: true + } + } + }; + } + + case _constants.Actions.EndActivity: + case _constants.Actions.CancelActivity: + { + const { + id, + status, + duration + } = action.payload; + const activity = state.activities[id]; + + if (!activity) { + return state; + } + + const activities = { ...state.activities + }; + activities[id] = { ...activity, + status, + duration + }; + return { ...state, + activities + }; + } + + case _constants.Actions.SetLogs: + { + return action.payload; + } + } + + return state; +}; + +exports.reducer = reducer; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/redux/types.d.ts b/packages/gatsby-reporter/lib/redux/types.d.ts new file mode 100644 index 0000000000000..8c09a78eeac8a --- /dev/null +++ b/packages/gatsby-reporter/lib/redux/types.d.ts @@ -0,0 +1,102 @@ +import { Actions, ActivityStatuses, ActivityTypes } from "../constants"; +import { IStructuredError } from "../structured-errors/types"; +export interface IGatsbyCLIState { + messages: ILog[]; + activities: { + [id: string]: IActivity; + }; + status: ActivityStatuses | ""; +} +export declare type ActionsUnion = ICreateLog | ISetStatus | IEndActivity | IPendingActivity | IStartActivity | ICancelActivity | IUpdateActivity | IActivityErrored | ISetLogs; +export interface IActivity { + startTime?: [number, number]; + id: string; + uuid: string; + text: string; + type: ActivityTypes; + status: ActivityStatuses; + statusText: string; + current?: number; + total?: number; + duration?: number; + errored?: boolean; +} +interface ILog { + level: string; + text: string | undefined; + statusText: string | undefined; + duration: number | undefined; + group: string | undefined; + code: string | undefined; + type: string | undefined; + filePath: string | undefined; + location: IStructuredError["location"] | undefined; + docsUrl: string | undefined; + context: string | undefined; + activity_current: number | undefined; + activity_total: number | undefined; + activity_type: string | undefined; + activity_uuid: string | undefined; + timestamp: string; + stack: IStructuredError["stack"] | undefined; +} +export interface ICreateLog { + type: Actions.Log; + payload: ILog; +} +export interface ISetStatus { + type: Actions.SetStatus; + payload: ActivityStatuses | ""; +} +export interface IPendingActivity { + type: Actions.PendingActivity; + payload: { + id: string; + type: ActivityTypes; + status: ActivityStatuses; + }; +} +export interface IStartActivity { + type: Actions.StartActivity; + payload: IActivity; +} +export interface ICancelActivity { + type: Actions.CancelActivity; + payload: { + id: string; + status: ActivityStatuses.Cancelled; + duration: number; + type: ActivityTypes; + }; +} +export interface IEndActivity { + type: Actions.EndActivity; + payload: { + uuid: string; + id: string; + status: ActivityStatuses; + duration: number; + type: ActivityTypes; + }; +} +export interface IUpdateActivity { + type: Actions.UpdateActivity; + payload: { + uuid: string; + id: string; + statusText?: string; + total?: number; + current?: number; + }; +} +export interface IActivityErrored { + type: Actions.ActivityErrored; + payload: { + id: string; + }; +} +export interface ISetLogs { + type: Actions.SetLogs; + payload: IGatsbyCLIState; +} +export {}; diff --git a/packages/gatsby-reporter/lib/redux/types.js b/packages/gatsby-reporter/lib/redux/types.js new file mode 100644 index 0000000000000..9a390c31f71bc --- /dev/null +++ b/packages/gatsby-reporter/lib/redux/types.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/redux/utils.d.ts b/packages/gatsby-reporter/lib/redux/utils.d.ts new file mode 100644 index 0000000000000..4816dac5bbc14 --- /dev/null +++ b/packages/gatsby-reporter/lib/redux/utils.d.ts @@ -0,0 +1,13 @@ +import { ActivityStatuses } from "../constants"; +import { ActionsUnion, IActivity } from "./types"; +export declare const getGlobalStatus: (id: string, status: ActivityStatuses) => ActivityStatuses; +export declare const getActivity: (id: string) => IActivity | null; +/** + * @returns {Number} Milliseconds from activity start + */ +export declare const getElapsedTimeMS: (activity: IActivity) => number; +export declare const isInternalAction: (action: ActionsUnion) => boolean; +/** + * Like setTimeout, but also handle signalExit + */ +export declare const delayedCall: (fn: () => void, timeout: number) => (() => void); diff --git a/packages/gatsby-reporter/lib/redux/utils.js b/packages/gatsby-reporter/lib/redux/utils.js new file mode 100644 index 0000000000000..4b70032beee4f --- /dev/null +++ b/packages/gatsby-reporter/lib/redux/utils.js @@ -0,0 +1,93 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.delayedCall = exports.isInternalAction = exports.getElapsedTimeMS = exports.getActivity = exports.getGlobalStatus = void 0; + +var _index = require("./index"); + +var _convertHrtime = _interopRequireDefault(require("convert-hrtime")); + +var _constants = require("../constants"); + +var _signalExit = _interopRequireDefault(require("signal-exit")); + +const getGlobalStatus = (id, status) => { + const { + logs + } = (0, _index.getStore)().getState(); + const currentActivities = [id, ...Object.keys(logs.activities)]; + return currentActivities.reduce((generatedStatus, activityId) => { + const activityStatus = activityId === id ? status : logs.activities[activityId].status; + + if (activityStatus === _constants.ActivityStatuses.InProgress || activityStatus === _constants.ActivityStatuses.NotStarted) { + return _constants.ActivityStatuses.InProgress; + } else if (activityStatus === _constants.ActivityStatuses.Failed && generatedStatus !== _constants.ActivityStatuses.InProgress) { + return _constants.ActivityStatuses.Failed; + } else if (activityStatus === _constants.ActivityStatuses.Interrupted && generatedStatus !== _constants.ActivityStatuses.InProgress) { + return _constants.ActivityStatuses.Interrupted; + } + + return generatedStatus; + }, _constants.ActivityStatuses.Success); +}; + +exports.getGlobalStatus = getGlobalStatus; + +const getActivity = id => (0, _index.getStore)().getState().logs.activities[id]; +/** + * @returns {Number} Milliseconds from activity start + */ + + +exports.getActivity = getActivity; + +const getElapsedTimeMS = activity => { + const elapsed = process.hrtime(activity.startTime); + return (0, _convertHrtime.default)(elapsed).milliseconds; +}; + +exports.getElapsedTimeMS = getElapsedTimeMS; + +const isInternalAction = action => { + switch (action.type) { + case _constants.Actions.PendingActivity: + case _constants.Actions.CancelActivity: + case _constants.Actions.ActivityErrored: + return true; + + case _constants.Actions.StartActivity: + case _constants.Actions.EndActivity: + return action.payload.type === _constants.ActivityTypes.Hidden; + + default: + return false; + } +}; +/** + * Like setTimeout, but also handle signalExit + */ + + +exports.isInternalAction = isInternalAction; + +const delayedCall = (fn, timeout) => { + const fnWrap = () => { + fn(); // eslint-disable-next-line @typescript-eslint/no-use-before-define + + clear(); + }; + + const timeoutID = setTimeout(fnWrap, timeout); + const cancelSignalExit = (0, _signalExit.default)(fnWrap); + + const clear = () => { + clearTimeout(timeoutID); + cancelSignalExit(); + }; + + return clear; +}; + +exports.delayedCall = delayedCall; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/reporter-phantom.d.ts b/packages/gatsby-reporter/lib/reporter-phantom.d.ts new file mode 100644 index 0000000000000..a98a61c4968f0 --- /dev/null +++ b/packages/gatsby-reporter/lib/reporter-phantom.d.ts @@ -0,0 +1,9 @@ +import { Span } from "opentracing"; +import { IPhantomReporter } from "./types"; +interface ICreatePhantomReporterArguments { + text: string; + id: string; + span: Span; +} +export declare const createPhantomReporter: ({ text, id, span, }: ICreatePhantomReporterArguments) => IPhantomReporter; +export {}; diff --git a/packages/gatsby-reporter/lib/reporter-phantom.js b/packages/gatsby-reporter/lib/reporter-phantom.js new file mode 100644 index 0000000000000..97da120b6e095 --- /dev/null +++ b/packages/gatsby-reporter/lib/reporter-phantom.js @@ -0,0 +1,38 @@ +"use strict"; + +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); + +exports.__esModule = true; +exports.createPhantomReporter = void 0; + +var reporterActions = _interopRequireWildcard(require("./redux/actions")); + +var _constants = require("./constants"); + +const createPhantomReporter = ({ + text, + id, + span +}) => { + return { + start() { + reporterActions.startActivity({ + id, + text, + type: _constants.ActivityTypes.Hidden + }); + }, + + end() { + span.finish(); + reporterActions.endActivity({ + id, + status: _constants.ActivityStatuses.Success + }); + }, + + span + }; +}; + +exports.createPhantomReporter = createPhantomReporter; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/reporter-progress.d.ts b/packages/gatsby-reporter/lib/reporter-progress.d.ts new file mode 100644 index 0000000000000..73de921a5cb29 --- /dev/null +++ b/packages/gatsby-reporter/lib/reporter-progress.d.ts @@ -0,0 +1,13 @@ +import { Span } from "opentracing"; +import { reporter as gatsbyReporter } from "./reporter"; +import { IProgressReporter } from "./types"; +interface ICreateProgressReporterArguments { + id: string; + text: string; + start: number; + total: number; + span: Span; + reporter: typeof gatsbyReporter; +} +export declare const createProgressReporter: ({ id, text, start, total, span, reporter, }: ICreateProgressReporterArguments) => IProgressReporter; +export {}; diff --git a/packages/gatsby-reporter/lib/reporter-progress.js b/packages/gatsby-reporter/lib/reporter-progress.js new file mode 100644 index 0000000000000..27e74c734c2e4 --- /dev/null +++ b/packages/gatsby-reporter/lib/reporter-progress.js @@ -0,0 +1,117 @@ +"use strict"; + +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); + +exports.__esModule = true; +exports.createProgressReporter = void 0; + +var reporterActions = _interopRequireWildcard(require("./redux/actions")); + +var _constants = require("./constants"); + +const createProgressReporter = ({ + id, + text, + start, + total, + span, + reporter +}) => { + let lastUpdateTime = 0; + let unflushedProgress = 0; + let unflushedTotal = 0; + const progressUpdateDelay = Math.round(1000 / 10); // 10 fps *shrug* + + const updateProgress = (forced = false) => { + const t = Date.now(); + if (!forced && t - lastUpdateTime <= progressUpdateDelay) return; + + if (unflushedTotal > 0) { + reporterActions.setActivityTotal({ + id, + total: unflushedTotal + }); + unflushedTotal = 0; + } + + if (unflushedProgress > 0) { + reporterActions.activityTick({ + id, + increment: unflushedProgress + }); + unflushedProgress = 0; + } + + lastUpdateTime = t; + }; + + return { + start() { + reporterActions.startActivity({ + id, + text, + type: _constants.ActivityTypes.Progress, + current: start, + total + }); + }, + + setStatus(statusText) { + reporterActions.setActivityStatusText({ + id, + statusText + }); + }, + + tick(increment = 1) { + unflushedProgress += increment; // Have to manually track this :/ + + updateProgress(); + }, + + panicOnBuild(errorMeta, error) { + span.finish(); + reporterActions.setActivityErrored({ + id + }); + return reporter.panicOnBuild(errorMeta, error); + }, + + panic(errorMeta, error) { + span.finish(); + reporterActions.endActivity({ + id, + status: _constants.ActivityStatuses.Failed + }); + return reporter.panic(errorMeta, error); + }, + + end() { + updateProgress(true); + span.finish(); + reporterActions.endActivity({ + id, + status: _constants.ActivityStatuses.Success + }); + }, + + // @deprecated - use end() + done() { + updateProgress(true); + span.finish(); + reporterActions.endActivity({ + id, + status: _constants.ActivityStatuses.Success + }); + }, + + set total(value) { + unflushedTotal = value; + updateProgress(); + }, + + span + }; +}; + +exports.createProgressReporter = createProgressReporter; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/reporter-timer.d.ts b/packages/gatsby-reporter/lib/reporter-timer.d.ts new file mode 100644 index 0000000000000..1aa89a6670ec6 --- /dev/null +++ b/packages/gatsby-reporter/lib/reporter-timer.d.ts @@ -0,0 +1,11 @@ +import { Span } from "opentracing"; +import { reporter as gatsbyReporter } from "./reporter"; +import { ITimerReporter } from "./types"; +interface ICreateTimerReporterArguments { + text: string; + id: string; + span: Span; + reporter: typeof gatsbyReporter; +} +export declare const createTimerReporter: ({ text, id, span, reporter, }: ICreateTimerReporterArguments) => ITimerReporter; +export {}; diff --git a/packages/gatsby-reporter/lib/reporter-timer.js b/packages/gatsby-reporter/lib/reporter-timer.js new file mode 100644 index 0000000000000..153aad4d70bd5 --- /dev/null +++ b/packages/gatsby-reporter/lib/reporter-timer.js @@ -0,0 +1,67 @@ +"use strict"; + +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); + +exports.__esModule = true; +exports.createTimerReporter = void 0; + +var reporterActions = _interopRequireWildcard(require("./redux/actions")); + +var _constants = require("./constants"); + +/* + * This module is used when calling reporter. + * these logs + */ +const createTimerReporter = ({ + text, + id, + span, + reporter +}) => { + return { + start() { + reporterActions.startActivity({ + id, + text: text || `__timer__`, + type: _constants.ActivityTypes.Spinner + }); + }, + + setStatus(statusText) { + reporterActions.setActivityStatusText({ + id, + statusText + }); + }, + + panicOnBuild(errorMeta, error) { + span.finish(); + reporterActions.setActivityErrored({ + id + }); + return reporter.panicOnBuild(errorMeta, error); + }, + + panic(errorMeta, error) { + span.finish(); + reporterActions.endActivity({ + id, + status: _constants.ActivityStatuses.Failed + }); + return reporter.panic(errorMeta, error); + }, + + end() { + span.finish(); + reporterActions.endActivity({ + id, + status: _constants.ActivityStatuses.Success + }); + }, + + span + }; +}; + +exports.createTimerReporter = createTimerReporter; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/reporter.d.ts b/packages/gatsby-reporter/lib/reporter.d.ts new file mode 100644 index 0000000000000..3699b77e5e04e --- /dev/null +++ b/packages/gatsby-reporter/lib/reporter.d.ts @@ -0,0 +1,66 @@ +import { ActivityStatuses } from "./constants"; +import { IStructuredError } from "./structured-errors/types"; +import { ErrorMeta, IActivityArgs, IPhantomReporter, IProgressReporter, ITimerReporter } from "./types"; +import { ICreateLog } from "./redux/types"; +/** + * Reporter module. + * @module reporter + */ +export declare class Reporter { + /** + * Strip initial indentation template function. + */ + stripIndent: import("common-tags").TemplateTag; + format: import("chalk").Chalk & { + supportsColor: import("chalk").ColorSupport; + }; + /** + * Toggle verbosity. + */ + setVerbose: (_isVerbose?: boolean) => void; + /** + * Turn off colors in error output. + */ + setNoColor: (isNoColor?: boolean) => void; + /** + * Log arguments and exit process with status 1. + */ + panic: (errorMeta: ErrorMeta, error?: Error | Error[] | undefined) => never; + panicOnBuild: (errorMeta: ErrorMeta, error?: Error | Error[] | undefined) => IStructuredError | IStructuredError[]; + error: (errorMeta: ErrorMeta | ErrorMeta[], error?: Error | Error[] | undefined) => IStructuredError | IStructuredError[]; + /** + * Set prefix on uptime. + */ + uptime: (prefix: string) => void; + verbose: (text: string) => void; + success: (text?: string | undefined) => ICreateLog; + info: (text?: string | undefined) => ICreateLog; + warn: (text?: string | undefined) => ICreateLog; + log: (text?: string | undefined) => ICreateLog; + pendingActivity: ({ id, status, }: { + id: string; + status?: ActivityStatuses | undefined; + }) => (import("./redux/types").IPendingActivity | ((dispatch: import("redux").Dispatch) => void))[]; + completeActivity: (id: string, status?: ActivityStatuses) => void; + /** + * Time an activity. + */ + activityTimer: (text: string, activityArgs?: IActivityArgs) => ITimerReporter; + /** + * Create an Activity that is not visible to the user + * + * During the lifecycle of the Gatsby process, sometimes we need to do some + * async work and wait for it to complete. A typical example of this is a job. + * This work should set the status of the process to `in progress` while running and + * `complete` (or `failure`) when complete. Activities do just this! However, they + * are visible to the user. So this function can be used to create a _hidden_ activity + * that while not displayed in the CLI, still triggers a change in process status. + */ + phantomActivity: (text: string, activityArgs?: IActivityArgs) => IPhantomReporter; + /** + * Create a progress bar for an activity + */ + createProgress: (text: string, total?: number, start?: number, activityArgs?: IActivityArgs) => IProgressReporter; + _setStage: () => void; +} +export declare const reporter: Reporter; diff --git a/packages/gatsby-reporter/lib/reporter.js b/packages/gatsby-reporter/lib/reporter.js new file mode 100644 index 0000000000000..ac8b402ffbbbb --- /dev/null +++ b/packages/gatsby-reporter/lib/reporter.js @@ -0,0 +1,273 @@ +"use strict"; + +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.reporter = exports.Reporter = void 0; + +var _commonTags = require("common-tags"); + +var _chalk = _interopRequireDefault(require("chalk")); + +var _gatsbyTelemetry = require("gatsby-telemetry"); + +var _opentracing = require("opentracing"); + +var _getErrorFormater = require("./get-error-formater"); + +var reporterActions = _interopRequireWildcard(require("./redux/actions")); + +var _constants = require("./constants"); + +var _constructError = _interopRequireDefault(require("./structured-errors/construct-error")); + +var _catchExitSignals = require("./catch-exit-signals"); + +var _reporterTimer = require("./reporter-timer"); + +var _reporterPhantom = require("./reporter-phantom"); + +var _reporterProgress = require("./reporter-progress"); + +const errorFormatter = (0, _getErrorFormater.getErrorFormatter)(); +const tracer = (0, _opentracing.globalTracer)(); +let isVerbose = false; +/** + * Reporter module. + * @module reporter + */ + +class Reporter { + constructor() { + this.stripIndent = _commonTags.stripIndent; + this.format = _chalk.default; + + this.setVerbose = (_isVerbose = true) => { + isVerbose = _isVerbose; + }; + + this.setNoColor = (isNoColor = false) => { + if (isNoColor) { + errorFormatter.withoutColors(); + } // disables colors in popular terminal output coloring packages + // - chalk: see https://www.npmjs.com/package/chalk#chalksupportscolor + // - ansi-colors: see https://github.com/doowb/ansi-colors/blob/8024126c7115a0efb25a9a0e87bc5e29fd66831f/index.js#L5-L7 + + + if (isNoColor) { + process.env.FORCE_COLOR = `0`; // chalk determines color level at import time. Before we reach this point, + // chalk was already imported, so we need to retroactively adjust level + + _chalk.default.level = 0; + } + }; + + this.panic = (errorMeta, error) => { + const reporterError = this.error(errorMeta, error); + (0, _gatsbyTelemetry.trackError)(`GENERAL_PANIC`, { + error: reporterError + }); + (0, _catchExitSignals.prematureEnd)(); + return process.exit(1); + }; + + this.panicOnBuild = (errorMeta, error) => { + const reporterError = this.error(errorMeta, error); + (0, _gatsbyTelemetry.trackError)(`BUILD_PANIC`, { + error: reporterError + }); + + if (process.env.gatsby_executing_command === `build`) { + (0, _catchExitSignals.prematureEnd)(); + process.exit(1); + } + + return reporterError; + }; + + this.error = (errorMeta, error) => { + let details = { + context: {} + }; // Many paths to retain backcompat :scream: + // 1. + // reporter.error(any, Error); + // reporter.error(any, [Error]); + + if (error) { + if (Array.isArray(error)) { + return error.map(errorItem => this.error(errorMeta, errorItem)); + } + + details.error = error; + details.context = { + sourceMessage: errorMeta + ` ` + error.message + }; // 2. + // reporter.error(Error); + } else if (errorMeta instanceof Error) { + details.error = errorMeta; + details.context = { + sourceMessage: errorMeta.message + }; // 3. + // reporter.error([Error]); + } else if (Array.isArray(errorMeta)) { + // when we get an array of messages, call this function once for each error + return errorMeta.map(errorItem => this.error(errorItem)); // 4. + // reporter.error(errorMeta); + } else if (typeof errorMeta === `object`) { + details = { ...errorMeta + }; // 5. + // reporter.error('foo'); + } else if (typeof errorMeta === `string`) { + details.context = { + sourceMessage: errorMeta + }; + } + + const structuredError = (0, _constructError.default)({ + details + }); + + if (structuredError) { + reporterActions.createLog(structuredError); + } // TODO: remove this once Error component can render this info + // log formatted stacktrace + + + if (structuredError.error) { + this.log(errorFormatter.render(structuredError.error)); + } + + return structuredError; + }; + + this.uptime = prefix => { + this.verbose(`${prefix}: ${(process.uptime() * 1000).toFixed(3)}ms`); + }; + + this.verbose = text => { + if (isVerbose) { + reporterActions.createLog({ + level: _constants.LogLevels.Debug, + text + }); + } + }; + + this.success = text => reporterActions.createLog({ + level: _constants.LogLevels.Success, + text + }); + + this.info = text => reporterActions.createLog({ + level: _constants.LogLevels.Info, + text + }); + + this.warn = text => reporterActions.createLog({ + level: _constants.LogLevels.Warning, + text + }); + + this.log = text => reporterActions.createLog({ + level: _constants.LogLevels.Log, + text + }); + + this.pendingActivity = reporterActions.createPendingActivity; + + this.completeActivity = (id, status = _constants.ActivityStatuses.Success) => { + reporterActions.endActivity({ + id, + status + }); + }; + + this.activityTimer = (text, activityArgs = {}) => { + let { + parentSpan, + id, + tags + } = activityArgs; + const spanArgs = parentSpan ? { + childOf: parentSpan, + tags + } : { + tags + }; + + if (!id) { + id = text; + } + + const span = tracer.startSpan(text, spanArgs); + return (0, _reporterTimer.createTimerReporter)({ + text, + id, + span, + reporter: this + }); + }; + + this.phantomActivity = (text, activityArgs = {}) => { + let { + parentSpan, + id, + tags + } = activityArgs; + const spanArgs = parentSpan ? { + childOf: parentSpan, + tags + } : { + tags + }; + + if (!id) { + id = text; + } + + const span = tracer.startSpan(text, spanArgs); + return (0, _reporterPhantom.createPhantomReporter)({ + id, + text, + span + }); + }; + + this.createProgress = (text, total = 0, start = 0, activityArgs = {}) => { + let { + parentSpan, + id, + tags + } = activityArgs; + const spanArgs = parentSpan ? { + childOf: parentSpan, + tags + } : { + tags + }; + + if (!id) { + id = text; + } + + const span = tracer.startSpan(text, spanArgs); + return (0, _reporterProgress.createProgressReporter)({ + id, + text, + total, + start, + span, + reporter: this + }); + }; + + this._setStage = () => {}; + } + +} + +exports.Reporter = Reporter; +const reporter = new Reporter(); +exports.reporter = reporter; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/start-logger.d.ts b/packages/gatsby-reporter/lib/start-logger.d.ts new file mode 100644 index 0000000000000..90a4f27d28d1d --- /dev/null +++ b/packages/gatsby-reporter/lib/start-logger.d.ts @@ -0,0 +1 @@ +export declare const startLogger: () => void; diff --git a/packages/gatsby-reporter/lib/start-logger.js b/packages/gatsby-reporter/lib/start-logger.js new file mode 100644 index 0000000000000..7f8a26b0d8b50 --- /dev/null +++ b/packages/gatsby-reporter/lib/start-logger.js @@ -0,0 +1,53 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.startLogger = void 0; + +var _semver = _interopRequireDefault(require("semver")); + +var _gatsbyCoreUtils = require("gatsby-core-utils"); + +var _ipc = require("./loggers/ipc"); + +var _json = require("./loggers/json"); + +var _yurnalist = require("./loggers/yurnalist"); + +var _ink = require("./loggers/ink"); + +/* + * This module is a side-effect filled module to load in the proper logger. + */ +const startLogger = () => { + let inkExists = false; + + try { + inkExists = !!require.resolve(`ink`); // eslint-disable-next-line no-empty + } catch (err) {} + + if (!process.env.GATSBY_LOGGER) { + if (inkExists && _semver.default.satisfies(process.version, `>=8`) && !(0, _gatsbyCoreUtils.isCI)() && typeof jest === `undefined`) { + process.env.GATSBY_LOGGER = `ink`; + } else { + process.env.GATSBY_LOGGER = `yurnalist`; + } + } // if child process - use ipc logger + + + if (process.send) { + // process.env.FORCE_COLOR = `0` + (0, _ipc.initializeIPCLogger)(); + } + + if (process.env.GATSBY_LOGGER.includes(`json`)) { + (0, _json.initializeJSONLogger)(); + } else if (process.env.GATSBY_LOGGER.includes(`yurnalist`)) { + (0, _yurnalist.initializeYurnalistLogger)(); + } else { + (0, _ink.initializeINKLogger)(); + } +}; + +exports.startLogger = startLogger; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/structured-errors/__tests__/construct-error.d.ts b/packages/gatsby-reporter/lib/structured-errors/__tests__/construct-error.d.ts new file mode 100644 index 0000000000000..cb0ff5c3b541f --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/__tests__/construct-error.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/gatsby-reporter/lib/structured-errors/__tests__/error-map.d.ts b/packages/gatsby-reporter/lib/structured-errors/__tests__/error-map.d.ts new file mode 100644 index 0000000000000..cb0ff5c3b541f --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/__tests__/error-map.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/gatsby-reporter/lib/structured-errors/__tests__/error-schema.d.ts b/packages/gatsby-reporter/lib/structured-errors/__tests__/error-schema.d.ts new file mode 100644 index 0000000000000..cb0ff5c3b541f --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/__tests__/error-schema.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/gatsby-reporter/lib/structured-errors/construct-error.d.ts b/packages/gatsby-reporter/lib/structured-errors/construct-error.d.ts new file mode 100644 index 0000000000000..d25be75509876 --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/construct-error.d.ts @@ -0,0 +1,3 @@ +import { IConstructError, IStructuredError } from "./types"; +declare const constructError: ({ details: { id, ...otherDetails }, }: IConstructError) => IStructuredError; +export default constructError; diff --git a/packages/gatsby-reporter/lib/structured-errors/construct-error.js b/packages/gatsby-reporter/lib/structured-errors/construct-error.js new file mode 100644 index 0000000000000..eb8b6645ef512 --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/construct-error.js @@ -0,0 +1,53 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.default = void 0; + +var _stackTrace = _interopRequireDefault(require("stack-trace")); + +var _errorSchema = require("./error-schema"); + +var _errorMap = require("./error-map"); + +var _sanitizeStructuredStackTrace = require("./sanitize-structured-stack-trace"); + +// Merge partial error details with information from the errorMap +// Validate the constructed object against an error schema +const constructError = ({ + details: { + id, + ...otherDetails + } +}) => { + const result = id && _errorMap.errorMap[id] || _errorMap.defaultError; // merge + + const structuredError = { + context: {}, + ...otherDetails, + ...result, + text: result.text(otherDetails.context), + stack: otherDetails.error ? (0, _sanitizeStructuredStackTrace.sanitizeStructuredStackTrace)(_stackTrace.default.parse(otherDetails.error)) : [], + docsUrl: result.docsUrl || `https://gatsby.dev/issue-how-to` + }; + + if (id) { + structuredError.code = id; + } // validate + + + const { + error + } = _errorSchema.errorSchema.validate(structuredError); + + if (error !== null) { + console.log(`Failed to validate error`, error); + process.exit(1); + } + + return structuredError; +}; + +var _default = constructError; +exports.default = _default; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/structured-errors/error-map.d.ts b/packages/gatsby-reporter/lib/structured-errors/error-map.d.ts new file mode 100644 index 0000000000000..4d43e42c9dfeb --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/error-map.d.ts @@ -0,0 +1,259 @@ +import { ErrorLevel, ErrorType } from "./types"; +declare const errors: { + "": { + text: (context: any) => string; + level: ErrorLevel; + }; + 95312: { + text: (context: any) => string; + level: ErrorLevel; + docsUrl: string; + }; + 95313: { + text: (context: any) => string; + level: ErrorLevel; + docsUrl: string; + }; + 98123: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 98124: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85901: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85907: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85908: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85909: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85910: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + docsUrl: string; + }; + 85911: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85912: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85913: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85914: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85915: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85916: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85917: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85918: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85919: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85920: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85921: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85922: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85923: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85924: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85925: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85926: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 85927: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 10122: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 10123: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 10124: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 10125: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 10126: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 10226: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 11321: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 11322: { + text: (context: any) => string; + level: ErrorLevel; + }; + 11323: { + text: (context: any) => string; + level: ErrorLevel; + }; + 11324: { + text: (context: any) => string; + level: ErrorLevel; + }; + 11325: { + text: (context: any) => string; + level: ErrorLevel; + }; + 11326: { + text: (context: any) => string; + level: ErrorLevel; + }; + 11327: { + text: (context: any) => string; + level: ErrorLevel; + }; + 11328: { + text: (context: any) => string; + level: ErrorLevel; + }; + 11329: { + text: (context: any) => string; + level: ErrorLevel; + }; + 11330: { + text: (context: any) => string; + type: ErrorType; + level: ErrorLevel; + }; + 11331: { + text: (context: any) => string; + level: ErrorLevel; + }; + 11467: { + text: (context: any) => string; + level: ErrorLevel; + docsUrl: string; + }; + 11521: { + text: () => string; + level: ErrorLevel; + docsUrl: string; + }; + 11522: { + text: () => string; + level: ErrorLevel; + docsUrl: string; + }; + 11610: { + text: (context: any) => string; + level: ErrorLevel; + docsUrl: string; + }; + 11611: { + text: (context: any) => string; + level: ErrorLevel; + docsUrl: string; + }; + 11612: { + text: (context: any) => string; + level: ErrorLevel; + docsUrl: string; + }; + 11613: { + text: (context: any) => string; + level: ErrorLevel; + docsUrl: string; + }; +}; +export declare type ErrorId = keyof typeof errors; +export declare const errorMap: Record; +export declare const defaultError: IErrorMapEntry; +export interface IErrorMapEntry { + text: (context: any) => string; + level: ErrorLevel; + type?: ErrorType; + docsUrl?: string; +} +export {}; diff --git a/packages/gatsby-reporter/lib/structured-errors/error-map.js b/packages/gatsby-reporter/lib/structured-errors/error-map.js new file mode 100644 index 0000000000000..e7e5e30309330 --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/error-map.js @@ -0,0 +1,342 @@ +"use strict"; + +exports.__esModule = true; +exports.defaultError = exports.errorMap = void 0; + +var _commonTags = require("common-tags"); + +var _types = require("./types"); + +const optionalGraphQLInfo = context => `${context.codeFrame ? `\n\n${context.codeFrame}` : ``}${context.filePath ? `\n\nFile path: ${context.filePath}` : ``}${context.urlPath ? `\nUrl path: ${context.urlPath}` : ``}${context.plugin ? `\nPlugin: ${context.plugin}` : ``}`; + +const errors = { + "": { + text: context => { + const sourceMessage = context.sourceMessage ? context.sourceMessage : `There was an error`; + return sourceMessage; + }, + level: _types.ErrorLevel.ERROR + }, + "95312": { + text: context => `"${context.ref}" is not available during server side rendering.`, + level: _types.ErrorLevel.ERROR, + docsUrl: `https://gatsby.dev/debug-html` + }, + "95313": { + text: context => `Building static HTML failed${context.errorPath ? ` for path "${context.errorPath}"` : ``}`, + level: _types.ErrorLevel.ERROR, + docsUrl: `https://gatsby.dev/debug-html` + }, + "98123": { + text: context => { + var _context$sourceMessag; + + return `${context.stageLabel} failed\n\n${(_context$sourceMessag = context.sourceMessage) !== null && _context$sourceMessag !== void 0 ? _context$sourceMessag : context.message}`; + }, + type: _types.ErrorType.WEBPACK, + level: _types.ErrorLevel.ERROR + }, + "98124": { + text: context => `${context.stageLabel} failed\n\n${context.sourceMessage}\n\nIf you're trying to use a package make sure that '${context.packageName}' is installed. If you're trying to use a local file make sure that the path is correct.`, + type: _types.ErrorType.WEBPACK, + level: _types.ErrorLevel.ERROR + }, + "85901": { + text: context => (0, _commonTags.stripIndent)(` + There was an error in your GraphQL query:\n\n${context.sourceMessage}${optionalGraphQLInfo(context)}`), + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + // Deprecated + "85907": { + text: context => `There was an error in your GraphQL query:\n\n${context.message}`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85908": { + text: context => { + const closestFragment = context.closestFragment ? `\n\nDid you mean to use ` + `"${context.closestFragment}"?` : ``; + return `There was an error in your GraphQL query:\n\nThe fragment "${context.fragmentName}" does not exist.\n\n${context.codeFrame}${closestFragment}`; + }, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + // Deprecated + "85909": { + text: context => context.sourceMessage, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85910": { + text: context => (0, _commonTags.stripIndents)(` + Multiple "root" queries found: "${context.name}" and "${context.otherName}". + Only the first ("${context.otherName}") will be registered. + + Instead of: + + ${context.beforeCodeFrame} + + Do: + + ${context.afterCodeFrame} + + This can happen when you use two page/static queries in one file. Please combine those into one query. + If you're defining multiple components (each with a static query) in one file, you'll need to move each component to its own file. + `), + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR, + docsUrl: `https://www.gatsbyjs.org/docs/graphql/` + }, + "85911": { + text: context => (0, _commonTags.stripIndent)(` + There was a problem parsing "${context.filePath}"; any GraphQL + fragments or queries in this file were not processed. + + This may indicate a syntax error in the code, or it may be a file type + that Gatsby does not know how to parse. + `), + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85912": { + text: context => `Failed to parse preprocessed file ${context.filePath}`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85913": { + text: context => `There was a problem reading the file: ${context.filePath}`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85914": { + text: context => `There was a problem reading the file: ${context.filePath}`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + // default parsing error + "85915": { + text: context => `There was a problem parsing the GraphQL query in file: ${context.filePath}`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85916": { + text: context => `String interpolation is not allowed in graphql tag:\n\n${context.codeFrame}`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85917": { + text: context => `Unexpected empty graphql tag${context.codeFrame ? `\n\n${context.codeFrame}` : ``}`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85918": { + text: context => (0, _commonTags.stripIndent)(` + GraphQL syntax error in query:\n\n${context.sourceMessage}${context.codeFrame ? `\n\n${context.codeFrame}` : ``}`), + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + // Duplicate fragment + "85919": { + text: context => (0, _commonTags.stripIndent)(` + Found two different GraphQL fragments with identical name "${context.fragmentName}". Fragment names must be unique + + File: ${context.leftFragment.filePath} + ${context.leftFragment.codeFrame} + + File: ${context.rightFragment.filePath} + ${context.rightFragment.codeFrame} + `), + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + // Undefined variables in Queries + "85920": { + text: context => { + const staticQueryMessage = (0, _commonTags.stripIndents)(`Suggestion 1: + + If you're not using a page query but a useStaticQuery / StaticQuery you see this error because they currently don't support variables. To learn more about the limitations of useStaticQuery / StaticQuery, please visit these docs: + + https://www.gatsbyjs.org/docs/use-static-query/ + https://www.gatsbyjs.org/docs/static-query/`); + const generalMessage = (0, _commonTags.stripIndents)(`Suggestion 2: + + You might have a typo in the variable name "${context.variableName}" or you didn't provide the variable via context to this page query. Have a look at the docs to learn how to add data to context: + + https://www.gatsbyjs.org/docs/page-query/#how-to-add-query-variables-to-a-page-query`); + return (0, _commonTags.stripIndent)(` + There was an error in your GraphQL query:\n\n${context.sourceMessage}${optionalGraphQLInfo(context)}\n\n${staticQueryMessage}\n\n${generalMessage}`); + }, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85921": { + text: context => `There was an error in your GraphQL query:\n\n${context.sourceMessage}\n\nIf you're e.g. filtering for specific nodes make sure that you choose the correct field (that has the same type "${context.inputType}") or adjust the context variable to the type "${context.expectedType}".`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85922": { + text: context => `There was an error in your GraphQL query:\n\n${context.sourceMessage}\n\nThis can happen if you e.g. accidentally added { } to the field "${context.fieldName}". If you didn't expect "${context.fieldName}" to be of type "${context.fieldType}" make sure that your input source and/or plugin is correct.`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85923": { + text: context => `There was an error in your GraphQL query:\n\n${context.sourceMessage}\n\nIf you don't expect "${context.field}" to exist on the type "${context.type}" it is most likely a typo.\nHowever, if you expect "${context.field}" to exist there are a couple of solutions to common problems:\n\n- If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server\n- The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have\n- You want to optionally use your field "${context.field}" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add a least one entry with that field ("dummy content")\n\nIt is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "${context.type}":\nhttps://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85924": { + text: context => `There was an error in your GraphQL query:\n\n${context.sourceMessage}\n\nThis can happen when you or a plugin/theme explicitly defined the GraphQL schema for this GraphQL object type via the schema customization API and "${context.value}" doesn't match the (scalar) type of "${context.type}".${optionalGraphQLInfo(context)}`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85925": { + text: context => `There was an error in your GraphQL query:\n\n${context.sourceMessage}\n\nThe field "${context.field}" was explicitly defined as non-nullable via the schema customization API (by yourself or a plugin/theme). This means that this field is not optional and you have to define a value. If this is not your desired behavior and you defined the schema yourself, go to "createTypes" in gatsby-node.js. If you're using a plugin/theme, you can learn more here on how to fix field types:\nhttps://www.gatsbyjs.org/docs/schema-customization/#fixing-field-types${optionalGraphQLInfo(context)}`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85926": { + text: context => `There was an error in your GraphQL query:\n\n${context.sourceMessage}\n\nThis can happen when you used graphql\`{ ...yourQuery }\` instead of graphql(\`{ ...yourQuery }\`) inside gatsby-node.js\n\nYou can't use the template literal function you're used to (from page queries) and rather have to call graphql() as a normal function.`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + "85927": { + text: context => `There was an error in your GraphQL query:\n\n${context.sourceMessage}\n\nSee if ${context.variable} has a typo or ${context.operation} doesn't actually require this variable.`, + type: _types.ErrorType.GRAPHQL, + level: _types.ErrorLevel.ERROR + }, + // Config errors + "10122": { + text: context => `The site's gatsby-config.js failed validation:\n\n${context.sourceMessage}`, + type: _types.ErrorType.CONFIG, + level: _types.ErrorLevel.ERROR + }, + "10123": { + text: context => `We encountered an error while trying to load your site's ${context.configName}. Please fix the error and try again.`, + type: _types.ErrorType.CONFIG, + level: _types.ErrorLevel.ERROR + }, + "10124": { + text: context => `It looks like you were trying to add the config file? Please rename "${context.nearMatch}" to "${context.configName}.js"`, + type: _types.ErrorType.CONFIG, + level: _types.ErrorLevel.ERROR + }, + "10125": { + text: context => `Your ${context.configName} file is in the wrong place. You've placed it in the src/ directory. It must instead be at the root of your site next to your package.json file.`, + type: _types.ErrorType.CONFIG, + level: _types.ErrorLevel.ERROR + }, + "10126": { + text: context => `${context.path}/${context.configName} cannot export a function.` + `\n\nA ${context.configName} exported as a Function can only be used as a theme and not run directly.` + `\nIf you are trying to run a theme directly, use the theme in an example site or starter instead and run that site to test.` + `\nIf you are in the root gatsby-config.js for your site, change the export to be an object and not a function as functions` + `\nare not supported in the root gatsby-config.`, + type: _types.ErrorType.CONFIG, + level: _types.ErrorLevel.ERROR + }, + "10226": { + text: context => [`Couldn't find the "${context.themeName}" plugin declared in "${context.configFilePath}".`, context.pathToLocalTheme && `Tried looking for a local plugin in ${context.pathToLocalTheme}.`, `Tried looking for an installed package in the following paths:\n${context.nodeResolutionPaths.map(potentialLocationPath => ` - ${potentialLocationPath}`).join(`\n`)}`].filter(Boolean).join(`\n\n`), + type: _types.ErrorType.CONFIG, + level: _types.ErrorLevel.ERROR + }, + // Plugin errors + "11321": { + text: context => { + var _context$sourceMessag2; + + return `"${context.pluginName}" threw an error while running the ${context.api} lifecycle:\n\n${(_context$sourceMessag2 = context.sourceMessage) !== null && _context$sourceMessag2 !== void 0 ? _context$sourceMessag2 : context.message}${optionalGraphQLInfo(context)}`; + }, + type: _types.ErrorType.PLUGIN, + level: _types.ErrorLevel.ERROR + }, + "11322": { + text: context => `${context.pluginName} created a page and didn't pass the path to the component.\n\nThe page object passed to createPage:\n${JSON.stringify(context.pageObject, null, 4)}\n\nSee the documentation for the "createPage" action — https://www.gatsbyjs.org/docs/actions/#createPage`, + level: _types.ErrorLevel.ERROR + }, + "11323": { + text: context => `${context.pluginName} must set the page path when creating a page.\n\nThe page object passed to createPage:\n${JSON.stringify(context.pageObject, null, 4)}\n\nSee the documentation for the "createPage" action — https://www.gatsbyjs.org/docs/actions/#createPage`, + level: _types.ErrorLevel.ERROR + }, + "11324": { + text: context => `${context.message}\n\nSee the documentation for the "createPage" action — https://www.gatsbyjs.org/docs/actions/#createPage`, + level: _types.ErrorLevel.ERROR + }, + "11325": { + text: context => `${context.pluginName} created a page with a component that doesn't exist.\n\nThe path to the missing component is "${context.component}"\n\nThe page object passed to createPage:\n${JSON.stringify(context.pageObject, null, 4)}\n\nSee the documentation for the "createPage" action — https://www.gatsbyjs.org/docs/actions/#createPage`, + level: _types.ErrorLevel.ERROR + }, + "11326": { + text: context => `${context.pluginName} must set the absolute path to the page component when create creating a page.\n\nThe (relative) path you used for the component is "${context.component}"\n\nYou can convert a relative path to an absolute path by requiring the path module and calling path.resolve() e.g.\n\nconst path = require("path")\npath.resolve("${context.component}")\n\nThe page object passed to createPage:\n${JSON.stringify(context.pageObject, null, 4)}\n\nSee the documentation for the "createPage" action — https://www.gatsbyjs.org/docs/actions/#createPage`, + level: _types.ErrorLevel.ERROR + }, + "11327": { + text: context => `You have an empty file in the "src/pages" directory at "${context.relativePath}". Please remove it or make it a valid component`, + level: _types.ErrorLevel.ERROR + }, + "11328": { + text: context => `A page component must export a React component for it to be valid. Please make sure this file exports a React component:\n\n${context.fileName}`, + level: _types.ErrorLevel.ERROR + }, + // invalid or deprecated APIs + "11329": { + text: context => [(0, _commonTags.stripIndent)(` + Your plugins must export known APIs from their gatsby-${context.exportType}.js. + + See https://www.gatsbyjs.org/docs/${context.exportType}-apis/ for the list of Gatsby ${context.exportType} APIs. + `)].concat([``].concat(context.errors)).concat(context.fixes.length > 0 ? [``, `Some of the following may help fix the error(s):`, ``, ...context.fixes.map(fix => `- ${fix}`)] : []).join(`\n`), + level: _types.ErrorLevel.ERROR + }, + // "X" is not defined in Gatsby's node APIs + "11330": { + text: context => { + var _context$sourceMessag3; + + return `"${context.pluginName}" threw an error while running the ${context.api} lifecycle:\n\n${(_context$sourceMessag3 = context.sourceMessage) !== null && _context$sourceMessag3 !== void 0 ? _context$sourceMessag3 : context.message}\n\n${context.codeFrame}\n\nMake sure that you don't have a typo somewhere and use valid arguments in ${context.api} lifecycle.\nLearn more about ${context.api} here: https://www.gatsbyjs.org/docs/node-apis/#${context.api}`; + }, + type: _types.ErrorType.PLUGIN, + level: _types.ErrorLevel.ERROR + }, + // Directory/file name exceeds OS character limit + "11331": { + text: context => [`One or more path segments are too long - they exceed OS filename length limit.\n`, `Page path: "${context.path}"`, `Invalid segments:\n${context.invalidPathSegments.map(segment => ` - "${segment}"`).join(`\n`)}`, ...(!context.isProduction ? [`\nThis will fail production builds, please adjust your paths.`, `\nIn development mode gatsby truncated to: "${context.truncatedPath}"`] : [])].filter(Boolean).join(`\n`), + level: _types.ErrorLevel.ERROR + }, + // node object didn't pass validation + "11467": { + text: context => [`The new node didn't pass validation: ${context.validationErrorMessage}`, `Failing node:`, JSON.stringify(context.node, null, 4), `Note: there might be more nodes that failed validation. Output is limited to one node per type of validation failure to limit terminal spam.`, context.codeFrame].filter(Boolean).join(`\n\n`), + level: _types.ErrorLevel.ERROR, + docsUrl: `https://www.gatsbyjs.org/docs/actions/#createNode` + }, + // local SSL certificate errors + "11521": { + text: () => `for custom ssl --https, --cert-file, and --key-file must be used together`, + level: _types.ErrorLevel.ERROR, + docsUrl: `https://www.gatsbyjs.org/docs/local-https/#custom-key-and-certificate-files` + }, + "11522": { + text: () => `Failed to generate dev SSL certificate`, + level: _types.ErrorLevel.ERROR, + docsUrl: `https://www.gatsbyjs.org/docs/local-https/#setup` + }, + // cli new command errors + "11610": { + text: context => `It looks like you gave wrong argument orders . Try running instead "gatsby new ${context.starter} ${context.rootPath}"`, + level: _types.ErrorLevel.ERROR, + docsUrl: `https://www.gatsbyjs.org/docs/gatsby-cli/#new` + }, + "11611": { + text: context => `It looks like you passed a URL to your project name. Try running instead "gatsby new new-gatsby-project ${context.rootPath}"`, + level: _types.ErrorLevel.ERROR, + docsUrl: `https://www.gatsbyjs.org/docs/gatsby-cli/#new` + }, + "11612": { + text: context => `Could not create a project in "${context.path}" because it's not a valid path`, + level: _types.ErrorLevel.ERROR, + docsUrl: `https://www.gatsbyjs.org/docs/gatsby-cli/#new` + }, + "11613": { + text: context => `Directory ${context.rootPath} is already an npm project`, + level: _types.ErrorLevel.ERROR, + docsUrl: `https://www.gatsbyjs.org/docs/gatsby-cli/#new` + } +}; +const errorMap = errors; +exports.errorMap = errorMap; +const defaultError = errorMap[``]; +exports.defaultError = defaultError; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/structured-errors/error-schema.d.ts b/packages/gatsby-reporter/lib/structured-errors/error-schema.d.ts new file mode 100644 index 0000000000000..83fd5cc4b7b28 --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/error-schema.d.ts @@ -0,0 +1,5 @@ +/// +import Joi from "@hapi/joi"; +import { ILocationPosition, IStructuredError } from "./types"; +export declare const Position: Joi.ObjectSchema; +export declare const errorSchema: Joi.ObjectSchema; diff --git a/packages/gatsby-reporter/lib/structured-errors/error-schema.js b/packages/gatsby-reporter/lib/structured-errors/error-schema.js new file mode 100644 index 0000000000000..4a8dbfc0ba5b6 --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/error-schema.js @@ -0,0 +1,43 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); + +exports.__esModule = true; +exports.errorSchema = exports.Position = void 0; + +var _joi = _interopRequireDefault(require("@hapi/joi")); + +const Position = _joi.default.object().keys({ + line: _joi.default.number(), + column: _joi.default.number() +}); + +exports.Position = Position; + +const errorSchema = _joi.default.object().keys({ + code: _joi.default.string(), + text: _joi.default.string(), + stack: _joi.default.array().items(_joi.default.object().keys({ + fileName: _joi.default.string(), + functionName: _joi.default.string().allow(null), + lineNumber: _joi.default.number().allow(null), + columnNumber: _joi.default.number().allow(null) + })).allow(null), + level: _joi.default.string().valid([`ERROR`, `WARNING`, `INFO`, `DEBUG`]), + type: _joi.default.string().valid([`GRAPHQL`, `CONFIG`, `WEBPACK`, `PLUGIN`]), + filePath: _joi.default.string(), + location: _joi.default.object({ + start: Position.required(), + end: Position + }), + docsUrl: _joi.default.string().uri({ + allowRelative: false, + relativeOnly: false + }), + error: _joi.default.object({}).unknown(), + context: _joi.default.object({}).unknown(), + group: _joi.default.string(), + panicOnBuild: _joi.default.boolean() +}); + +exports.errorSchema = errorSchema; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/structured-errors/sanitize-structured-stack-trace.d.ts b/packages/gatsby-reporter/lib/structured-errors/sanitize-structured-stack-trace.d.ts new file mode 100644 index 0000000000000..a2a984de67ed0 --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/sanitize-structured-stack-trace.d.ts @@ -0,0 +1,3 @@ +import stackTrace from "stack-trace"; +import { IStructuredStackFrame } from "./types"; +export declare const sanitizeStructuredStackTrace: (stack: stackTrace.StackFrame[]) => IStructuredStackFrame[]; diff --git a/packages/gatsby-reporter/lib/structured-errors/sanitize-structured-stack-trace.js b/packages/gatsby-reporter/lib/structured-errors/sanitize-structured-stack-trace.js new file mode 100644 index 0000000000000..a69dca89805f2 --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/sanitize-structured-stack-trace.js @@ -0,0 +1,45 @@ +"use strict"; + +exports.__esModule = true; +exports.sanitizeStructuredStackTrace = void 0; + +var _gatsbyCoreUtils = require("gatsby-core-utils"); + +const packagesToSkip = [`core-js`, `bluebird`, `regenerator-runtime`, `graphql`]; +const packagesToSkipTest = new RegExp(`node_modules[\\/](${packagesToSkip.join(`|`)})`); // TO-DO: move this this out of this file (and probably delete this file completely) +// it's here because it re-implements similar thing as `pretty-error` already does + +const sanitizeStructuredStackTrace = stack => { + // first filter out not useful call sites + stack = stack.filter(callSite => { + if (!callSite.getFileName()) { + return false; + } + + if (packagesToSkipTest.test(callSite.getFileName())) { + return false; + } + + if (callSite.getFileName().includes(`asyncToGenerator.js`)) { + return false; + } + + if ((0, _gatsbyCoreUtils.isNodeInternalModulePath)(callSite.getFileName())) { + return false; + } + + return true; + }); // then sanitize individual call site objects to make sure we don't + // emit objects with extra fields that won't be handled by consumers + + return stack.map(callSite => { + return { + fileName: callSite.getFileName(), + functionName: callSite.getFunctionName(), + columnNumber: callSite.getColumnNumber(), + lineNumber: callSite.getLineNumber() + }; + }); +}; + +exports.sanitizeStructuredStackTrace = sanitizeStructuredStackTrace; \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/structured-errors/types.d.ts b/packages/gatsby-reporter/lib/structured-errors/types.d.ts new file mode 100644 index 0000000000000..27c4ba7e83e38 --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/types.d.ts @@ -0,0 +1,52 @@ +import { IErrorMapEntry, ErrorId } from "./error-map"; +export interface IConstructError { + details: { + id?: ErrorId; + context?: Record; + error?: Error; + [key: string]: unknown; + }; +} +export interface ILocationPosition { + line: number; + column: number; +} +export interface IStructuredStackFrame { + fileName: string; + functionName?: string; + lineNumber?: number; + columnNumber?: number; +} +export interface IStructuredError { + code?: string; + text: string; + stack: IStructuredStackFrame[]; + filePath?: string; + location?: { + start: ILocationPosition; + end?: ILocationPosition; + }; + error?: Error; + group?: string; + level: IErrorMapEntry["level"]; + type?: IErrorMapEntry["type"]; + docsUrl?: string; +} +export interface IOptionalGraphQLInfoContext { + codeFrame?: string; + filePath?: string; + urlPath?: string; + plugin?: string; +} +export declare enum ErrorLevel { + ERROR = "ERROR", + WARNING = "WARNING", + INFO = "INFO", + DEBUG = "DEBUG" +} +export declare enum ErrorType { + GRAPHQL = "GRAPHQL", + CONFIG = "CONFIG", + WEBPACK = "WEBPACK", + PLUGIN = "PLUGIN" +} diff --git a/packages/gatsby-reporter/lib/structured-errors/types.js b/packages/gatsby-reporter/lib/structured-errors/types.js new file mode 100644 index 0000000000000..7518fef00bd8c --- /dev/null +++ b/packages/gatsby-reporter/lib/structured-errors/types.js @@ -0,0 +1,23 @@ +"use strict"; + +exports.__esModule = true; +exports.ErrorType = exports.ErrorLevel = void 0; +let ErrorLevel; +exports.ErrorLevel = ErrorLevel; + +(function (ErrorLevel) { + ErrorLevel["ERROR"] = "ERROR"; + ErrorLevel["WARNING"] = "WARNING"; + ErrorLevel["INFO"] = "INFO"; + ErrorLevel["DEBUG"] = "DEBUG"; +})(ErrorLevel || (exports.ErrorLevel = ErrorLevel = {})); + +let ErrorType; +exports.ErrorType = ErrorType; + +(function (ErrorType) { + ErrorType["GRAPHQL"] = "GRAPHQL"; + ErrorType["CONFIG"] = "CONFIG"; + ErrorType["WEBPACK"] = "WEBPACK"; + ErrorType["PLUGIN"] = "PLUGIN"; +})(ErrorType || (exports.ErrorType = ErrorType = {})); \ No newline at end of file diff --git a/packages/gatsby-reporter/lib/types.d.ts b/packages/gatsby-reporter/lib/types.d.ts new file mode 100644 index 0000000000000..ea28f9a255084 --- /dev/null +++ b/packages/gatsby-reporter/lib/types.d.ts @@ -0,0 +1,39 @@ +import { Span } from "opentracing"; +import { IStructuredError } from "./structured-errors/types"; +export declare type ErrorMeta = { + id: string; + error?: Error; + context: Record; + [id: string]: any; +} | string | Error | ErrorMeta[]; +export interface IActivityArgs { + id?: string; + parentSpan?: Span; + tags?: { + [key: string]: any; + }; +} +export interface IPhantomReporter { + start(): void; + end(): void; + span: Span; +} +export interface IProgressReporter { + start(): void; + setStatus(statusText: string): void; + tick(increment?: number): void; + panicOnBuild(arg: any, ...otherArgs: any[]): IStructuredError | IStructuredError[]; + panic(arg: any, ...otherArgs: any[]): never; + end(): void; + done(): void; + total: number; + span: Span; +} +export interface ITimerReporter { + start(): void; + setStatus(statusText: string): void; + panicOnBuild(arg: any, ...otherArgs: any[]): IStructuredError | IStructuredError[]; + panic(arg: any, ...otherArgs: any[]): never; + end(): void; + span: Span; +} diff --git a/packages/gatsby-reporter/lib/types.js b/packages/gatsby-reporter/lib/types.js new file mode 100644 index 0000000000000..9a390c31f71bc --- /dev/null +++ b/packages/gatsby-reporter/lib/types.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/packages/gatsby-theme-blog-core/CHANGELOG.md b/packages/gatsby-theme-blog-core/CHANGELOG.md index c84edeca72558..35b27149b103a 100644 --- a/packages/gatsby-theme-blog-core/CHANGELOG.md +++ b/packages/gatsby-theme-blog-core/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.5.45](https://github.com/gatsbyjs/gatsby/compare/gatsby-theme-blog-core@1.5.44...gatsby-theme-blog-core@1.5.45) (2020-06-19) + +**Note:** Version bump only for package gatsby-theme-blog-core + ## [1.5.44](https://github.com/gatsbyjs/gatsby/compare/gatsby-theme-blog-core@1.5.43...gatsby-theme-blog-core@1.5.44) (2020-06-19) **Note:** Version bump only for package gatsby-theme-blog-core diff --git a/packages/gatsby-theme-blog-core/package.json b/packages/gatsby-theme-blog-core/package.json index ddec4d93caf0c..473fc64dc05a9 100644 --- a/packages/gatsby-theme-blog-core/package.json +++ b/packages/gatsby-theme-blog-core/package.json @@ -1,6 +1,6 @@ { "name": "gatsby-theme-blog-core", - "version": "1.5.44", + "version": "1.5.45", "main": "index.js", "author": "christopherbiscardi (@chrisbiscardi)", "license": "MIT", @@ -30,7 +30,7 @@ }, "devDependencies": { "@mdx-js/react": "^1.6.5", - "gatsby": "^2.23.5", + "gatsby": "^2.23.6", "prettier": "2.0.5", "react": "^16.12.0", "react-dom": "^16.12.0" diff --git a/packages/gatsby-theme-blog/CHANGELOG.md b/packages/gatsby-theme-blog/CHANGELOG.md index c1fdd74fe6610..1c8d4c4e6ac97 100644 --- a/packages/gatsby-theme-blog/CHANGELOG.md +++ b/packages/gatsby-theme-blog/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.6.45](https://github.com/gatsbyjs/gatsby/compare/gatsby-theme-blog@1.6.44...gatsby-theme-blog@1.6.45) (2020-06-19) + +**Note:** Version bump only for package gatsby-theme-blog + ## [1.6.44](https://github.com/gatsbyjs/gatsby/compare/gatsby-theme-blog@1.6.43...gatsby-theme-blog@1.6.44) (2020-06-19) **Note:** Version bump only for package gatsby-theme-blog diff --git a/packages/gatsby-theme-blog/package.json b/packages/gatsby-theme-blog/package.json index 9e6c7c47152f7..41a178e783b87 100644 --- a/packages/gatsby-theme-blog/package.json +++ b/packages/gatsby-theme-blog/package.json @@ -1,6 +1,6 @@ { "name": "gatsby-theme-blog", - "version": "1.6.44", + "version": "1.6.45", "description": "A Gatsby theme for miscellaneous blogging with a dark/light mode", "main": "index.js", "keywords": [ @@ -29,7 +29,7 @@ "gatsby-plugin-react-helmet": "^3.3.4", "gatsby-plugin-theme-ui": "^0.2.53", "gatsby-plugin-twitter": "^2.3.4", - "gatsby-theme-blog-core": "^1.5.44", + "gatsby-theme-blog-core": "^1.5.45", "mdx-utils": "0.2.0", "react-helmet": "^5.2.1", "react-switch": "^5.0.1", @@ -39,7 +39,7 @@ "typography-theme-wordpress-2016": "^0.16.19" }, "devDependencies": { - "gatsby": "^2.23.5", + "gatsby": "^2.23.6", "prettier": "2.0.5", "react": "^16.12.0", "react-dom": "^16.12.0" diff --git a/packages/gatsby-theme-notes/CHANGELOG.md b/packages/gatsby-theme-notes/CHANGELOG.md index 7afe638db7f0e..9e2d2ca61fb65 100644 --- a/packages/gatsby-theme-notes/CHANGELOG.md +++ b/packages/gatsby-theme-notes/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.3.71](https://github.com/gatsbyjs/gatsby/compare/gatsby-theme-notes@1.3.70...gatsby-theme-notes@1.3.71) (2020-06-19) + +**Note:** Version bump only for package gatsby-theme-notes + ## [1.3.70](https://github.com/gatsbyjs/gatsby/compare/gatsby-theme-notes@1.3.69...gatsby-theme-notes@1.3.70) (2020-06-19) **Note:** Version bump only for package gatsby-theme-notes diff --git a/packages/gatsby-theme-notes/package.json b/packages/gatsby-theme-notes/package.json index cc12c0dde05d5..4221ada8d00aa 100644 --- a/packages/gatsby-theme-notes/package.json +++ b/packages/gatsby-theme-notes/package.json @@ -1,7 +1,7 @@ { "name": "gatsby-theme-notes", "description": "Gatsby Theme for adding a notes section to your website", - "version": "1.3.70", + "version": "1.3.71", "author": "John Otander", "license": "MIT", "main": "index.js", @@ -20,7 +20,7 @@ }, "homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-theme-notes#readme", "devDependencies": { - "gatsby": "^2.23.5", + "gatsby": "^2.23.6", "react": "^16.12.0", "react-dom": "^16.12.0" }, diff --git a/packages/gatsby-theme-ui-preset/CHANGELOG.md b/packages/gatsby-theme-ui-preset/CHANGELOG.md index d06e116ba18a8..b5939e9ed2f51 100644 --- a/packages/gatsby-theme-ui-preset/CHANGELOG.md +++ b/packages/gatsby-theme-ui-preset/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.0.60](https://github.com/gatsbyjs/gatsby/compare/gatsby-theme-ui-preset@0.0.59...gatsby-theme-ui-preset@0.0.60) (2020-06-19) + +**Note:** Version bump only for package gatsby-theme-ui-preset + ## [0.0.59](https://github.com/gatsbyjs/gatsby/compare/gatsby-theme-ui-preset@0.0.58...gatsby-theme-ui-preset@0.0.59) (2020-06-19) **Note:** Version bump only for package gatsby-theme-ui-preset diff --git a/packages/gatsby-theme-ui-preset/package.json b/packages/gatsby-theme-ui-preset/package.json index d0522d3dad5c3..4a2e81317c8d4 100644 --- a/packages/gatsby-theme-ui-preset/package.json +++ b/packages/gatsby-theme-ui-preset/package.json @@ -1,6 +1,6 @@ { "name": "gatsby-theme-ui-preset", - "version": "0.0.59", + "version": "0.0.60", "description": "A Gatsby theme for theme-ui styles", "main": "index.js", "keywords": [ @@ -30,7 +30,7 @@ "typography-theme-wordpress-2016": "^0.16.19" }, "devDependencies": { - "gatsby": "^2.23.5", + "gatsby": "^2.23.6", "prettier": "2.0.5", "react": "^16.12.0", "react-dom": "^16.12.0" diff --git a/packages/gatsby/CHANGELOG.md b/packages/gatsby/CHANGELOG.md index a608df46aaf78..24557809a25bc 100644 --- a/packages/gatsby/CHANGELOG.md +++ b/packages/gatsby/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.23.6](https://github.com/gatsbyjs/gatsby/compare/gatsby@2.23.5...gatsby@2.23.6) (2020-06-19) + +**Note:** Version bump only for package gatsby + ## [2.23.5](https://github.com/gatsbyjs/gatsby/compare/gatsby@2.23.4...gatsby@2.23.5) (2020-06-19) ### Bug Fixes diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index 021c11df7bd37..d724083f4d32b 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -1,7 +1,7 @@ { "name": "gatsby", "description": "Blazing fast modern site generator for React", - "version": "2.23.5", + "version": "2.23.6", "author": "Kyle Mathews ", "bin": { "gatsby": "./dist/bin/gatsby.js" @@ -78,7 +78,7 @@ "gatsby-link": "^2.4.6", "gatsby-plugin-page-creator": "^2.3.10", "gatsby-plugin-typescript": "^2.4.6", - "gatsby-react-router-scroll": "^3.0.3", + "gatsby-react-router-scroll": "^3.0.4", "gatsby-telemetry": "^1.3.12", "glob": "^7.1.6", "got": "8.3.2",