Skip to content

Commit

Permalink
feat(): Upgrade to gatsby v2 APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessestuart committed Apr 17, 2019
1 parent 8b55b68 commit 6e3c828
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 48 deletions.
22 changes: 11 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
module.exports = {
extends: [
'prettier',
'plugin:@typescript-eslint/recommended',
],
extends: ['prettier', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
env: {
browser: true,
Expand All @@ -24,13 +21,16 @@ module.exports = {
},
rules: {
'@typescript-eslint/indent': ['error', 2],
'@typescript-eslint/member-delimiter-style': ['error', {
multiline: {
delimiter: 'none',
requireLast: true,
}
}],
'@typescript-eslint/member-delimiter-style': [
'error',
{
multiline: {
delimiter: 'none',
requireLast: true,
},
},
],
'@typescript-eslint/no-use-before-define': ['off'],
'@typescript-eslint/camelcase': ['off'],
}
},
}
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// noop
58 changes: 27 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-source-s3-image",
"description": "GatsbyJS plugin to source images from S3-compliant APIs, with EXIF-extracting superpowers.",
"version": "0.2.133",
"version": "0.3.0",
"author": "Jesse Stuart <hi@jessestuart.com>",
"homepage": "https://github.com/jessestuart/gatsby-source-s3-image#readme",
"main": "index.js",
Expand All @@ -10,40 +10,36 @@
"url": "git+https://github.com/jessestuart/gatsby-source-s3-image"
},
"dependencies": {
"aws-sdk": "2.438.0",
"bluebird": "3.5.4",
"aws-sdk": "2.411.0",
"bluebird": "3.5.3",
"exif-parser": "0.1.12",
"gatsby": "2.1.4",
"gatsby-source-filesystem": "2.0.20",
"lodash": "4.17.11",
"luxon": "1.12.1"
"luxon": "1.11.2"
},
"devDependencies": {
"@babel/cli": "7.4.3",
"@babel/core": "7.4.3",
"@babel/plugin-proposal-object-rest-spread": "7.4.3",
"@babel/plugin-transform-async-to-generator": "7.4.0",
"@babel/plugin-transform-flow-strip-types": "7.4.0",
"@babel/plugin-transform-runtime": "7.4.3",
"@babel/polyfill": "7.4.3",
"@babel/preset-env": "7.4.3",
"@babel/preset-flow": "7.0.0",
"@babel/preset-react": "7.0.0",
"@babel/cli": "7.2.3",
"@babel/core": "7.3.3",
"@babel/preset-typescript": "7.3.3",
"@semantic-release/git": "7.0.8",
"babel-eslint": "10.0.1",
"babel-jest": "23.6.0",
"@types/graphql": "14.0.7",
"@types/lodash": "4.14.121",
"@types/node": "11.9.4",
"@typescript-eslint/eslint-plugin": "1.3.0",
"@typescript-eslint/parser": "1.3.0",
"babel-jest": "24.1.0",
"babel-plugin-add-module-exports": "1.0.0",
"babel-plugin-lodash": "3.3.4",
"eslint-config-prettier": "3.6.0",
"eslint-config-standard": "12.0.0",
"eslint-friendly-formatter": "4.0.1",
"eslint-loader": "2.1.2",
"eslint-plugin-import": "2.17.2",
"eslint-plugin-node": "8.0.1",
"eslint-plugin-prettier": "3.0.1",
"eslint-plugin-promise": "4.1.1",
"eslint-plugin-react": "7.12.4",
"eslint-plugin-standard": "4.0.0",
"prettier": "1.17.0",
"prettier-eslint": "8.8.2",
"semantic-release": "15.13.3"
"babel-preset-gatsby-package": "0.1.3",
"eslint": "5.14.0",
"eslint-config-prettier": "4.0.0",
"prettier": "1.16.4",
"semantic-release": "15.13.3",
"tslint": "5.12.1",
"tslint-config-prettier": "1.18.0",
"tslint-config-standard": "8.0.1",
"typescript": "3.3.3"
},
"keywords": [
"exif",
Expand All @@ -55,8 +51,8 @@
],
"license": "MIT",
"scripts": {
"build": "babel src --out-dir . --ignore __tests__",
"lint": "eslint --format 'node_modules/eslint-friendly-formatter' --quiet --ext .js ./src",
"build": "tsc",
"lint": "eslint src/** --ext ts,tsx",
"prepublishOnly": "yarn build",
"semantic-release": "yarn build && semantic-release",
"update": "ncu -ua && yarn -s",
Expand Down
7 changes: 4 additions & 3 deletions src/extend-node-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
GraphQLInt,
GraphQLObjectType,
GraphQLString,
} from 'graphql'
} from 'gatsby/graphql'
import _ from 'lodash'
import { DateTime } from 'luxon'

import { ExifData } from './types/exif-data'
import { S3ImageAssetNode } from './types/s3-image-asset-node'
import ExifData from './types/exif-data'
import S3ImageAssetNode from './types/s3-image-asset-node'

export const resolveExifData = (image: S3ImageAssetNode): ExifData => {
const file = fs.readFileSync(image.absolutePath)
Expand Down Expand Up @@ -46,6 +46,7 @@ export const extendNodeType = ({
return {}
}

console.log('extend node type', { type })
return Promise.resolve({
ETag: { type: GraphQLString },
EXIF: {
Expand Down
7 changes: 5 additions & 2 deletions src/source-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const constructS3UrlForAsset = ({
return null
}

const isImage = (entity: any): boolean => {
function isImage(entity): boolean {
// S3 API doesn't expose Content-Type, and we don't want to make unnecessary
// HTTP requests for non-images... so we'll just infer based on the suffix
// of the Key.
Expand All @@ -55,7 +55,7 @@ const isImage = (entity: any): boolean => {
}

export const sourceNodes = async (
{ actions, store, cache },
{ actions, store, cache, createNodeId },
{ bucketName, domain, protocol = 'https' }: SourceS3Options,
done
): Promise<void> => {
Expand Down Expand Up @@ -93,6 +93,7 @@ export const sourceNodes = async (
bucketName,
cache,
createNode,
createNodeId,
domain,
entity,
localFile___NODE: null,
Expand Down Expand Up @@ -121,11 +122,13 @@ const createS3RemoteFileNode = async ({
createNode,
store,
s3Url,
createNodeId,
}): Promise<any | void> => {
try {
return await createRemoteFileNode({
cache,
createNode,
createNodeId,
store,
url: s3Url,
})
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"declaration": true,
"esModuleInterop": true,
"inlineSources": true,
"lib": ["esnext"],
"lib": ["esnext", "es2015"],
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": false,
Expand Down

0 comments on commit 6e3c828

Please sign in to comment.