Fixing netlify build (#888)
This commit is contained in:
parent
43958025e7
commit
b136a032ff
|
@ -0,0 +1 @@
|
||||||
|
lts/erbium
|
|
@ -30,7 +30,15 @@ module.exports = {
|
||||||
display: `minimal-ui`,
|
display: `minimal-ui`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
`gatsby-transformer-json`,
|
{
|
||||||
|
resolve: `gatsby-transformer-json`,
|
||||||
|
options: {
|
||||||
|
// NOTE: Without this setting, the JSON types are named based on the
|
||||||
|
// folder name. In the case of `content.json`, that depends on what the
|
||||||
|
// directory name of the repo is. In netlify's case, that's `repo`.
|
||||||
|
typeName: `jsonFile`,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
resolve: `gatsby-source-filesystem`,
|
resolve: `gatsby-source-filesystem`,
|
||||||
options: {
|
options: {
|
||||||
|
|
|
@ -2,11 +2,14 @@
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
const Bluebird = require('bluebird')
|
const Bluebird = require('bluebird')
|
||||||
|
const util = require('util')
|
||||||
|
|
||||||
// Set this to true to enable more logging in this file
|
// Set this to true to enable more logging in this file
|
||||||
const DEBUG = false
|
const DEBUG = false
|
||||||
const isDev = process.env.NODE_ENV === 'development'
|
const isDev = process.env.NODE_ENV === 'development'
|
||||||
|
|
||||||
|
const jsonTypeName = `jsonFile`
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement Gatsby's Node APIs in this file.
|
* Implement Gatsby's Node APIs in this file.
|
||||||
*
|
*
|
||||||
|
@ -17,10 +20,16 @@ const isDev = process.env.NODE_ENV === 'development'
|
||||||
|
|
||||||
exports.onCreateNode = async ({ node, actions }) => {
|
exports.onCreateNode = async ({ node, actions }) => {
|
||||||
const { createNode } = actions
|
const { createNode } = actions
|
||||||
if (node.internal.type === 'OpenSourceIosAppsJson') {
|
|
||||||
|
if (node.internal.type === jsonTypeName) {
|
||||||
const { categories, projects } = node
|
const { categories, projects } = node
|
||||||
|
|
||||||
categories.forEach(category => {
|
if (DEBUG) console.error('Found the json node #QE5PnL')
|
||||||
|
|
||||||
|
let createdCategoryCount = 0
|
||||||
|
let createdProjectCount = 0
|
||||||
|
|
||||||
|
await Bluebird.each(categories, async category => {
|
||||||
if (typeof category.id !== 'string' || category.id.length < 1) {
|
if (typeof category.id !== 'string' || category.id.length < 1) {
|
||||||
console.error('Invalid category #veJYyW', category)
|
console.error('Invalid category #veJYyW', category)
|
||||||
return
|
return
|
||||||
|
@ -32,7 +41,7 @@ exports.onCreateNode = async ({ node, actions }) => {
|
||||||
project['category-ids'].includes(category.id),
|
project['category-ids'].includes(category.id),
|
||||||
).length
|
).length
|
||||||
|
|
||||||
createNode({
|
await createNode({
|
||||||
...category,
|
...category,
|
||||||
slug: category.id,
|
slug: category.id,
|
||||||
parentSlug: category.parent,
|
parentSlug: category.parent,
|
||||||
|
@ -48,6 +57,8 @@ exports.onCreateNode = async ({ node, actions }) => {
|
||||||
content: JSON.stringify(category),
|
content: JSON.stringify(category),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
createdCategoryCount++
|
||||||
})
|
})
|
||||||
|
|
||||||
await Bluebird.each(projects, async project => {
|
await Bluebird.each(projects, async project => {
|
||||||
|
@ -67,14 +78,60 @@ exports.onCreateNode = async ({ node, actions }) => {
|
||||||
content: JSON.stringify(project),
|
content: JSON.stringify(project),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
await createNode(projectNode)
|
await createNode(projectNode)
|
||||||
|
|
||||||
|
createdProjectCount++
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.error(
|
||||||
|
'Created counts #WVIeFH',
|
||||||
|
createdCategoryCount,
|
||||||
|
createdProjectCount,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.createPages = async ({ actions, graphql }) => {
|
exports.createPages = async ({ actions, graphql, getNodesByType }) => {
|
||||||
const { createPage } = actions
|
const { createPage } = actions
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
const jsonNodes = getNodesByType(jsonTypeName)
|
||||||
|
const fileNodes = getNodesByType(`File`)
|
||||||
|
console.error(
|
||||||
|
'START createPages() #IMKm8p',
|
||||||
|
jsonNodes.length,
|
||||||
|
fileNodes.length,
|
||||||
|
)
|
||||||
|
|
||||||
|
const debugResult = await graphql(`
|
||||||
|
query Debugging {
|
||||||
|
allFile {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
id
|
||||||
|
internal {
|
||||||
|
type
|
||||||
|
}
|
||||||
|
relativePath
|
||||||
|
children {
|
||||||
|
id
|
||||||
|
internal {
|
||||||
|
type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
console.error(
|
||||||
|
'File nodes #bIMtXP',
|
||||||
|
util.inspect(debugResult.data, { depth: null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const categoryTemplate = path.resolve('src/templates/category.tsx')
|
const categoryTemplate = path.resolve('src/templates/category.tsx')
|
||||||
const tagTemplate = path.resolve('src/templates/tag.tsx')
|
const tagTemplate = path.resolve('src/templates/tag.tsx')
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
[[plugins]]
|
[[plugins]]
|
||||||
package = "netlify-plugin-gatsby-cache"
|
package = "netlify-plugin-gatsby-cache"
|
||||||
|
|
||||||
[build.environment]
|
|
||||||
SHARP_IGNORE_GLOBAL_LIBVIPS="true"
|
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
publish = "public/"
|
publish = "public/"
|
||||||
command = "yarn run build"
|
command = "head -n 2 ../contents.json && yarn run build"
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
"@material-ui/icons": "^4.9.1",
|
"@material-ui/icons": "^4.9.1",
|
||||||
"@material-ui/styles": "^4.10.0",
|
"@material-ui/styles": "^4.10.0",
|
||||||
"@reduxjs/toolkit": "^1.4.0",
|
"@reduxjs/toolkit": "^1.4.0",
|
||||||
|
"bluebird": "^3.7.2",
|
||||||
"deepmerge": "^4.2.2",
|
"deepmerge": "^4.2.2",
|
||||||
"gatsby": "^2.24.56",
|
"gatsby": "^2.24.56",
|
||||||
"gatsby-plugin-manifest": "^2.4.28",
|
"gatsby-plugin-manifest": "^2.4.28",
|
||||||
|
@ -55,7 +56,6 @@
|
||||||
"@types/redux": "^3.6.0",
|
"@types/redux": "^3.6.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.1.0",
|
"@typescript-eslint/eslint-plugin": "^4.1.0",
|
||||||
"@typescript-eslint/parser": "^4.1.0",
|
"@typescript-eslint/parser": "^4.1.0",
|
||||||
"bluebird": "^3.7.2",
|
|
||||||
"eslint": "^7.8.1",
|
"eslint": "^7.8.1",
|
||||||
"eslint-config-prettier": "^6.11.0",
|
"eslint-config-prettier": "^6.11.0",
|
||||||
"eslint-plugin-prettier": "^3.1.4",
|
"eslint-plugin-prettier": "^3.1.4",
|
||||||
|
|
Loading…
Reference in New Issue