Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Gatsby 4 Support, EXIF Dates & UserComments #418

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: upgrade to gatsby v4
Easen committed Nov 9, 2021
commit 2bcc4d1281648c5d651283b5d41073e5b7c74195
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v12
v16
96 changes: 48 additions & 48 deletions package.json
Original file line number Diff line number Diff line change
@@ -4,65 +4,65 @@
"version": "1.6.221",
"author": "Jesse Stuart <[email protected]>",
"dependencies": {
"aws-sdk": "2.684.0",
"aws-sdk": "2.1024.0",
"fracty": "1.0.9",
"invariant": "2.2.4",
"lodash": "4.17.15",
"luxon": "1.24.1",
"mime-types": "2.1.27",
"ts-exif-parser": "0.1.6"
"lodash": "4.17.21",
"luxon": "2.1.1",
"mime-types": "2.1.34",
"ts-exif-parser": "0.2.2"
},
"devDependencies": {
"@babel/cli": "7.10.0",
"@babel/core": "7.10.0",
"@babel/plugin-transform-runtime": "7.10.0",
"@babel/preset-typescript": "7.9.0",
"@semantic-release/git": "9.0.0",
"@types/invariant": "2.2.33",
"@types/jest": "25.2.3",
"@types/lodash": "4.14.153",
"@types/luxon": "1.24.0",
"@types/mime-types": "2.1.0",
"@types/mitm": "1.3.3",
"@types/node": "13.13.9",
"@types/redux-mock-store": "1.0.2",
"@typescript-eslint/eslint-plugin": "2.34.0",
"@typescript-eslint/parser": "2.34.0",
"babel-jest": "25.5.1",
"babel-plugin-add-module-exports": "1.0.2",
"@babel/cli": "7.16.0",
"@babel/core": "7.16.0",
"@babel/plugin-transform-runtime": "7.16.0",
"@babel/preset-typescript": "7.16.0",
"@semantic-release/git": "10.0.1",
"@types/invariant": "2.2.35",
"@types/jest": "27.0.2",
"@types/lodash": "4.14.176",
"@types/luxon": "2.0.7",
"@types/mime-types": "2.1.1",
"@types/mitm": "1.3.4",
"@types/node": "16.11.7",
"@types/redux-mock-store": "1.0.3",
"@typescript-eslint/eslint-plugin": "5.3.1",
"@typescript-eslint/parser": "5.3.1",
"babel-jest": "27.3.1",
"babel-plugin-add-module-exports": "1.0.4",
"babel-plugin-lodash": "3.3.4",
"babel-preset-gatsby-package": "0.3.1",
"babel-preset-gatsby-package": "2.1.0",
"babel-preset-minify": "0.5.1",
"codacy-coverage": "3.4.0",
"codecov": "3.7.0",
"concurrently": "5.2.0",
"eslint": "6.8.0",
"eslint-config-prettier": "6.11.0",
"eslint-config-standard": "14.1.1",
"codecov": "3.8.2",
"concurrently": "6.3.0",
"eslint": "8.2.0",
"eslint-config-prettier": "8.3.0",
"eslint-config-standard": "16.0.3",
"eslint-friendly-formatter": "4.0.1",
"eslint-loader": "3.0.4",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-import": "2.25.2",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "3.1.3",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-react": "7.20.0",
"eslint-plugin-standard": "4.0.1",
"factory.ts": "0.5.1",
"gatsby": "2.20.16",
"gatsby-source-filesystem": "2.2.2",
"jest": "25.5.4",
"jest-junit": "10.0.0",
"json-stringify-pretty-compact": "2.0.0",
"mitm": "1.7.0",
"nodemon": "2.0.4",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-promise": "5.1.1",
"eslint-plugin-react": "7.26.1",
"eslint-plugin-standard": "4.1.0",
"factory.ts": "0.5.2",
"gatsby": "4.1.2",
"gatsby-source-filesystem": "4.1.0",
"jest": "27.3.1",
"jest-junit": "13.0.0",
"json-stringify-pretty-compact": "3.0.0",
"mitm": "1.7.2",
"nodemon": "2.0.14",
"npm-check-updates": "^12.0.2",
"prettier": "1.19.1",
"prettier-eslint": "9.0.2",
"redux": "4.0.5",
"prettier": "2.4.1",
"prettier-eslint": "13.0.0",
"redux": "4.1.2",
"redux-mock-store": "1.5.4",
"semantic-release": "17.0.8",
"ts-jest": "25.5.1",
"typescript": "3.9.3"
"semantic-release": "18.0.0",
"ts-jest": "27.0.7",
"typescript": "4.4.4"
},
"files": [
"*.js",
@@ -95,7 +95,7 @@
"test": "concurrently 'yarn check-types' 'yarn jest --coverage'",
"test:watch": "concurrently 'yarn tsc --watch' 'yarn jest --watch'",
"ts:defs": "tsc --declaration --emitDeclarationOnly",
"update": "ncu -ua && yarn -s",
"update": "ncu -u && yarn -s",
"watch": "yarn build -w"
},
"types": "./types/index.d.ts"
54 changes: 54 additions & 0 deletions src/create-resolvers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { DateTime } from 'luxon'
import { ExifParserFactory } from 'ts-exif-parser'
import _ from 'lodash'
import fracty from 'fracty'

import fs from 'fs'

import ExifData from './types/ExifData'
import S3ImageAssetNode from './types/S3ImageAssetNode'

const resolveExifData = _.memoize((
image: S3ImageAssetNode // eslint-disable
): ExifData | undefined => {
const file = fs.readFileSync(image.absolutePath)
const tags = ExifParserFactory.create(file).parse().tags
const timestamp: number | undefined = _.get(tags, 'DateTimeOriginal')
if (!timestamp) {
return
}
const DateCreatedISO = DateTime.fromMillis(timestamp * 1000).toISODate()

const ExposureTime = _.get(tags, 'ExposureTime')
const ShutterSpeedFraction = fracty(ExposureTime)

return {
DateCreatedISO,
ShutterSpeedFraction,
..._.pick(tags, [
'DateTimeOriginal',
'Exposure',
'ExposureTime',
'FNumber',
'FocalLength',
'ISO',
'LensModel',
'Model',
'ShutterSpeedValue',
]),
}
})


export default ({ createResolvers }) => {
const resolvers = {
S3ImageAsset: {
EXIF: {
resolve: (image: S3ImageAssetNode) => ({
...resolveExifData(image),
}),
},
},
}
createResolvers(resolvers)
};
33 changes: 33 additions & 0 deletions src/create-schema-customization.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export default ({ actions }) => {
const { createTypes } = actions
const typeDefs = `
type S3ImageAsset implements Node {
id: String!
absolutePath: String!
ETag: String!
Key: String!
EXIF: ExifData
internal: S3ImageAssetNodeInternal!
}

type S3ImageAssetInternal {
content: String!
contentDigest: String!
mediaType: String!
type: String!
}

type ExifData {
DateCreatedISO: String
DateTimeOriginal: Int
ExposureTime: Int
FNumber: Int
FocalLength: Int
ISO: Int
LensModel: String
Model: String
ShutterSpeedValue: Int
}
`
createTypes(typeDefs)
}
5 changes: 3 additions & 2 deletions src/gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import onCreateNode from './on-create-node'
import setFieldsOnGraphQLNodeType from './set-fields-on-graphql-node-type'
import createResolvers from './create-resolvers'
import createSchemaCustomization from './create-schema-customization'
import sourceNodes from './source-nodes'

export { onCreateNode, setFieldsOnGraphQLNodeType, sourceNodes }
export { onCreateNode, createSchemaCustomization, createResolvers, sourceNodes }
85 changes: 0 additions & 85 deletions src/set-fields-on-graphql-node-type.ts

This file was deleted.

Loading