Skip to content

Commit

Permalink
Merge branch 'master' into renovate/typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
LekoArts committed Jul 1, 2022
2 parents b43f49b + 245c717 commit 5019eff
Show file tree
Hide file tree
Showing 59 changed files with 270 additions and 291 deletions.
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -40,9 +40,9 @@
"eslint-plugin-filenames": "^1.3.2",
"eslint-plugin-flowtype": "^6.1.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.30.0",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.30.1",
"fs-extra": "^10.1.0",
"glob": "^7.2.3",
"husky": "3.1.0",
Expand All @@ -61,7 +61,7 @@
"npm-packlist": "^2.1.5",
"npm-run-all": "4.1.5",
"plop": "^1.9.1",
"prettier": "^2.6.2",
"prettier": "^2.7.1",
"remark": "^13.0.0",
"remark-cli": "^9.0.0",
"remark-frontmatter": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-preset-gatsby/package.json
@@ -1,6 +1,6 @@
{
"name": "babel-preset-gatsby",
"version": "2.19.0-next.0",
"version": "2.19.0-next.1",
"author": "Philipp Spiess <hello@philippspiess.com>",
"repository": {
"type": "git",
Expand All @@ -23,7 +23,7 @@
"babel-plugin-macros": "^3.1.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"gatsby-core-utils": "^3.19.0-next.0",
"gatsby-legacy-polyfills": "^2.19.0-next.0"
"gatsby-legacy-polyfills": "^2.19.0-next.1"
},
"peerDependencies": {
"@babel/core": "^7.11.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-gatsby/package.json
@@ -1,6 +1,6 @@
{
"name": "create-gatsby",
"version": "2.19.0-next.0",
"version": "2.19.0-next.1",
"main": "lib/index.js",
"bin": "cli.js",
"license": "MIT",
Expand Down Expand Up @@ -30,7 +30,7 @@
"fs-extra": "^10.1.0",
"gatsby-plugin-utils": "^3.13.0-next.0",
"joi": "^17.4.2",
"microbundle": "^0.14.2",
"microbundle": "^0.15.0",
"node-fetch": "^2.6.6",
"string-length": "^4.0.2",
"terminal-link": "^2.1.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby-cli/package.json
@@ -1,7 +1,7 @@
{
"name": "gatsby-cli",
"description": "Gatsby command-line interface for creating new sites and running Gatsby commands",
"version": "4.19.0-next.0",
"version": "4.19.0-next.2",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bin": {
"gatsby": "cli.js"
Expand All @@ -27,13 +27,13 @@
"common-tags": "^1.8.2",
"configstore": "^5.0.1",
"convert-hrtime": "^3.0.0",
"create-gatsby": "^2.19.0-next.0",
"create-gatsby": "^2.19.0-next.1",
"envinfo": "^7.8.1",
"execa": "^5.1.1",
"fs-exists-cached": "^1.0.0",
"fs-extra": "^10.1.0",
"gatsby-core-utils": "^3.19.0-next.0",
"gatsby-telemetry": "^3.19.0-next.0",
"gatsby-telemetry": "^3.19.0-next.1",
"hosted-git-info": "^3.0.8",
"is-valid-path": "^0.1.1",
"joi": "^17.4.2",
Expand Down
16 changes: 8 additions & 8 deletions packages/gatsby-codemods/README.md
@@ -1,10 +1,10 @@
## gatsby-codemods
# gatsby-codemods

A collection of codemod scripts for use with [JSCodeshift](https://github.com/facebook/jscodeshift) that help migrate to newer versions of Gatsby.

> **Note:** Codemods are designed to rewrite your project's files. Ensure you have a backup before going any further.
### Setup & Run
## Setup & Run

There are two ways to run codemods on this package.

Expand Down Expand Up @@ -49,9 +49,9 @@ Structure of a jscodeshift call:
- use the `--extensions` option if your files have different extensions than `.js` (for example, `--extensions js,jsx`)
- see all available [jscodeshift options](https://github.com/facebook/jscodeshift#usage-cli).

### Included scripts
## Included scripts

#### `global-graphql-calls`
### `global-graphql-calls`

Add a `graphql` import to modules that use the `graphql` tag function without an import. This was supported in Gatsby v1 and deprecated for Gatsby v2.

Expand Down Expand Up @@ -82,7 +82,7 @@ export const query = graphql`
`
```

#### `import-link`
### `import-link`

Import `Link` from `gatsby` instead of `gatsby-link` and remove the `gatsby-link` import.

Expand All @@ -103,7 +103,7 @@ export default props => (
)
```

#### `navigate-calls`
### `navigate-calls`

Change the deprecated `navigateTo` method from `gatsby-link` to `navigate` from the `gatsby` module.

Expand All @@ -128,7 +128,7 @@ export default props => (
)
```

#### `rename-bound-action-creators`
### `rename-bound-action-creators`

Rename `boundActionCreators` to `actions`. `boundActionCreators` has been deprecated in Gatsby v2

Expand Down Expand Up @@ -158,7 +158,7 @@ Example result:
}
```

### More scripts
## More scripts

Check out [issue 5038 in the Gatsby repo for additional codemod ideas](https://github.com/gatsbyjs/gatsby/issues/5038#issuecomment-411516865).

Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-codemods/package.json
@@ -1,6 +1,6 @@
{
"name": "gatsby-codemods",
"version": "3.19.0-next.0",
"version": "3.19.0-next.1",
"description": "A collection of codemod scripts for use with JSCodeshift that help migrate to newer versions of Gatsby.",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 0 additions & 4 deletions packages/gatsby-design-tokens/README.md
@@ -1,7 +1,3 @@
<img src="https://user-images.githubusercontent.com/21834/74070062-35b91980-4a00-11ea-93a8-b77bde7b4c37.png" width="48" height="48" alt="rebeccapurple dot" />
<br>
<br>

# gatsby-design-tokens

<a href="https://www.npmjs.org/package/gatsby-design-tokens">
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-design-tokens/package.json
@@ -1,6 +1,6 @@
{
"name": "gatsby-design-tokens",
"version": "4.19.0-next.0",
"version": "4.19.0-next.2",
"description": "Gatsby Design Tokens",
"main": "dist/index.js",
"module": "dist/index.esm.js",
Expand Down Expand Up @@ -32,7 +32,7 @@
"devDependencies": {
"agadoo": "^2.0.0",
"cross-env": "^7.0.3",
"microbundle": "^0.14.2",
"microbundle": "^0.15.0",
"preval.macro": "^5.0.0"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-legacy-polyfills/package.json
@@ -1,7 +1,7 @@
{
"name": "gatsby-legacy-polyfills",
"description": "Polyfills for legacy browsers",
"version": "2.19.0-next.0",
"version": "2.19.0-next.1",
"main": "dist/polyfills.js",
"author": "Ward Peeters <ward@gatsbyjs.com>",
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-legacy-polyfills#readme",
Expand Down Expand Up @@ -40,7 +40,7 @@
"event-target-polyfill": "^0.0.3",
"execa": "^5.1.1",
"fs-extra": "^10.1.0",
"microbundle": "^0.14.2",
"microbundle": "^0.15.0",
"npm-run-all": "^4.1.5",
"object-assign": "^4.1.1",
"url-polyfill": "^1.1.12",
Expand Down
4 changes: 1 addition & 3 deletions packages/gatsby-link/.babelrc
@@ -1,3 +1 @@
{
"presets": [["babel-preset-gatsby-package", { "browser": true, "esm": true }]]
}
{}
31 changes: 18 additions & 13 deletions packages/gatsby-link/package.json
@@ -1,23 +1,35 @@
{
"name": "gatsby-link",
"description": "An enhanced Link component for Gatsby sites with support for resource prefetching",
"version": "4.19.0-next.0",
"version": "4.19.0-next.1",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"source": "src/index.js",
"main": "dist/index.js",
"module": "dist/index.modern.mjs",
"types": "index.d.ts",
"files": [
"dist/*"
],
"sideEffects": false,
"scripts": {
"build": "microbundle -f cjs,modern --jsx React.createElement --generateTypes false",
"watch": "npm run build watch --no-compress",
"prepare": "cross-env NODE_ENV=production npm run clean && npm run build",
"clean": "del-cli dist/*"
},
"dependencies": {
"@babel/runtime": "^7.15.4",
"@types/reach__router": "^1.3.10",
"gatsby-page-utils": "^2.19.0-next.0",
"prop-types": "^15.8.1"
},
"devDependencies": {
"@babel/cli": "^7.15.4",
"@babel/core": "^7.15.5",
"@testing-library/react": "^11.2.7",
"babel-preset-gatsby-package": "^2.19.0-next.0",
"cross-env": "^7.0.3"
"cross-env": "^7.0.3",
"del-cli": "^3.0.1",
"microbundle": "^0.15.0"
},
"peerDependencies": {
"@gatsbyjs/reach-router": "^1.3.5",
Expand All @@ -29,18 +41,11 @@
"gatsby"
],
"license": "MIT",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby.git",
"directory": "packages/gatsby-link"
},
"scripts": {
"build": "babel src --out-dir . --ignore \"**/__tests__\"",
"prepare": "cross-env NODE_ENV=production npm run build",
"watch": "babel -w src --out-dir . --ignore \"**/__tests__\""
},
"types": "index.d.ts",
"engines": {
"node": ">=14.15.0"
}
Expand Down
33 changes: 2 additions & 31 deletions packages/gatsby-link/src/index.js
Expand Up @@ -4,38 +4,9 @@ import { Link, Location } from "@gatsbyjs/reach-router"
import { parsePath } from "./parse-path"
import { isLocalLink } from "./is-local-link"
import { rewriteLinkPath } from "./rewrite-link-path"
import { withPrefix, getGlobalPathPrefix } from "./prefix-helpers"

export { parsePath }

export function withPrefix(path, prefix = getGlobalBasePrefix()) {
if (!isLocalLink(path)) {
return path
}

if (path.startsWith(`./`) || path.startsWith(`../`)) {
return path
}
const base = prefix ?? getGlobalPathPrefix() ?? `/`

return `${base?.endsWith(`/`) ? base.slice(0, -1) : base}${
path.startsWith(`/`) ? path : `/${path}`
}`
}

// These global values are wrapped in typeof clauses to ensure the values exist.
// This is especially problematic in unit testing of this component.
const getGlobalPathPrefix = () =>
process.env.NODE_ENV !== `production`
? typeof __PATH_PREFIX__ !== `undefined`
? __PATH_PREFIX__
: undefined
: __PATH_PREFIX__
const getGlobalBasePrefix = () =>
process.env.NODE_ENV !== `production`
? typeof __BASE_PATH__ !== `undefined`
? __BASE_PATH__
: undefined
: __BASE_PATH__
export { parsePath, withPrefix }

export function withAssetPrefix(path) {
return withPrefix(path, getGlobalPathPrefix())
Expand Down
32 changes: 32 additions & 0 deletions packages/gatsby-link/src/prefix-helpers.js
@@ -0,0 +1,32 @@
import { isLocalLink } from "./is-local-link"

export const getGlobalBasePrefix = () =>
process.env.NODE_ENV !== `production`
? typeof __BASE_PATH__ !== `undefined`
? __BASE_PATH__
: undefined
: __BASE_PATH__

// These global values are wrapped in typeof clauses to ensure the values exist.
// This is especially problematic in unit testing of this component.
export const getGlobalPathPrefix = () =>
process.env.NODE_ENV !== `production`
? typeof __PATH_PREFIX__ !== `undefined`
? __PATH_PREFIX__
: undefined
: __PATH_PREFIX__

export function withPrefix(path, prefix = getGlobalBasePrefix()) {
if (!isLocalLink(path)) {
return path
}

if (path.startsWith(`./`) || path.startsWith(`../`)) {
return path
}
const base = prefix ?? getGlobalPathPrefix() ?? `/`

return `${base?.endsWith(`/`) ? base.slice(0, -1) : base}${
path.startsWith(`/`) ? path : `/${path}`
}`
}
2 changes: 1 addition & 1 deletion packages/gatsby-link/src/rewrite-link-path.js
Expand Up @@ -3,7 +3,7 @@ import { resolve } from "@gatsbyjs/reach-router/lib/utils"
import { applyTrailingSlashOption } from "gatsby-page-utils/apply-trailing-slash-option"
import { parsePath } from "./parse-path"
import { isLocalLink } from "./is-local-link"
import { withPrefix } from "."
import { withPrefix } from "./prefix-helpers"

const isAbsolutePath = path => path?.startsWith(`/`)

Expand Down
3 changes: 0 additions & 3 deletions packages/gatsby-link/tsconfig.json

This file was deleted.

14 changes: 8 additions & 6 deletions packages/gatsby-plugin-flow/README.md
Expand Up @@ -4,15 +4,17 @@ Provides drop-in support for Flow by adding `@babel/preset-flow`.

## Install

`npm install gatsby-plugin-flow`
```shell
npm install gatsby-plugin-flow
```

## How to use

1. Include the plugin in your `gatsby-config.js` file.
1. You're good to go.

`gatsby-config.js`
Add the plugin to your `gatsby-config.js` file:

```javascript
plugins: [`gatsby-plugin-flow`]
// In your gatsby-config.js
module.exports = {
plugins: [`gatsby-plugin-flow`],
}
```
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-flow/package.json
@@ -1,6 +1,6 @@
{
"name": "gatsby-plugin-flow",
"version": "3.19.0-next.0",
"version": "3.19.0-next.1",
"description": "Provides drop-in support for Flow by adding @babel/preset-flow.",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-gatsby-cloud/package.json
@@ -1,7 +1,7 @@
{
"name": "gatsby-plugin-gatsby-cloud",
"description": "A Gatsby plugin which optimizes working with Gatsby Cloud",
"version": "4.19.0-next.0",
"version": "4.19.0-next.1",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
Expand All @@ -10,7 +10,7 @@
"@babel/runtime": "^7.15.4",
"fs-extra": "^10.1.0",
"gatsby-core-utils": "^3.19.0-next.0",
"gatsby-telemetry": "^3.19.0-next.0",
"gatsby-telemetry": "^3.19.0-next.1",
"kebab-hash": "^0.1.2",
"lodash": "^4.17.21",
"webpack-assets-manifest": "^5.1.0"
Expand Down

0 comments on commit 5019eff

Please sign in to comment.