-
Notifications
You must be signed in to change notification settings - Fork 20
feat: add support for gatsby 5 #852
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"id": "gatsby5", | ||
"name": "Gatsby 5", | ||
"category": "static_site_generator", | ||
"detect": { | ||
"npmDependencies": [{ "name": "gatsby", "version": ">=5.0.0" }], | ||
"excludedNpmDependencies": [], | ||
"configFiles": ["gatsby-config.js"] | ||
}, | ||
"dev": { | ||
"command": "gatsby develop", | ||
"port": 8000, | ||
"pollingStrategies": [{ "name": "TCP" }, { "name": "HTTP" }] | ||
}, | ||
"build": { | ||
"command": "gatsby build", | ||
"directory": "public" | ||
}, | ||
"staticAssetsDirectory": "static", | ||
"env": { | ||
"GATSBY_LOGGER": "yurnalist", | ||
"GATSBY_PRECOMPILE_DEVELOP_FUNCTIONS": "true", | ||
"AWS_LAMBDA_JS_RUNTIME": "nodejs18.x", | ||
"NODE_VERSION": "18" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These variables seem to only be used in the CLI and I'm not even certain about this. I haven't tested this because I think what we want cannot be achieved with setting NODE_VERSION. What we want is an explicit setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a fan of needing to create a new framework for each version. It feels hacky and hard to maintain. What happens when Gatsby 6 is released? Do we create a new one, or rename it to gatsby5plus? The approach of the plugins repo of allowing an array of versions, each with their own rules, seems to be better, though would be more of a breaking change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To answer your question - I think you are right, and these are only used in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just followed the pattern that existed for other frameworks as everything else would be a big change. What I'm thinking of is something like this (simplified) {
"id": "gatsby5",
"name": "Gatsby",
"detect": {
"npmDependencies": ["gatsby"],
"excludedNpmDependencies": [],
"configFiles": ["gatsby-config.js"]
},
"overrides": [
{
"detect": {
"npmDependencies": [{name: "gatsby", version: ">99"}],
},
"dev": {
"port": 1111,
},
}
],
"dev": {
"port": 8888,
},
} So in this example it would change the dev port if a certain version of the framework is used, but inherit everything else from the initial config. The structure in the processed end result would be exactly the same, at least for the framework detection. |
||
}, | ||
"logo": { | ||
"default": "/logos/gatsby/default.svg", | ||
"light": "/logos/gatsby/light.svg", | ||
"dark": "/logos/gatsby/dark.svg" | ||
}, | ||
"plugins": [ | ||
{ | ||
"packageName": "@netlify/plugin-gatsby", | ||
"condition": { "minNodeVersion": "12.13.0" } | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,15 +7,21 @@ export const getPackageJsonContent = function ({ packageJson }) { | |
} | ||
|
||
const npmDependencies = getNpmDependencies(packageJson) | ||
const npmDependenciesVersions = getNpmDependenciesVersions(packageJson) | ||
const scripts = getScripts(packageJson) | ||
return { npmDependencies, scripts } | ||
return { npmDependencies, npmDependenciesVersions, scripts } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm exporting all the versions as It is not ideal to kinda return the same info in different formats, but I think that is the compromise here. |
||
} | ||
|
||
// Retrieve `package.json` `dependencies` and `devDependencies` names | ||
const getNpmDependencies = function ({ dependencies, devDependencies }) { | ||
return [...getObjectKeys(dependencies), ...getObjectKeys(devDependencies)] | ||
} | ||
|
||
// Retrieve `package.json` `dependencies` and `devDependencies` versions | ||
const getNpmDependenciesVersions = function ({ dependencies, devDependencies }) { | ||
return { ...devDependencies, ...dependencies } | ||
} | ||
|
||
const getObjectKeys = function (value) { | ||
if (!isPlainObj(value)) { | ||
return [] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "test", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"gatsby": "4" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "test", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"gatsby": "5" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node 12 was dropped.