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

Migrate gatsby from v1 to v2 #75

Merged
merged 23 commits into from
Jan 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1e334c3
static-site: Update gatsby dependencies
kairstenfay Jan 9, 2020
ee64e10
Install react
kairstenfay Jan 9, 2020
642e401
static-site: Install plugins' peer dependencies
kairstenfay Jan 9, 2020
6006108
Install missing dependency
kairstenfay Jan 10, 2020
9b8d770
Lock npm dependencies
kairstenfay Jan 10, 2020
bf730e9
Change modifyWebpackConfig to onCreateWebpackConfig
kairstenfay Jan 13, 2020
6697dce
Remove gatsby-link package
jameshadfield Jan 14, 2020
8cce59f
Import `graphql` from gatsby
jameshadfield Jan 14, 2020
1b5bd8d
Add `babel-preset-gatsby`to babelrc
jameshadfield Jan 14, 2020
ded9755
fix styled component errors. Site now builds.
jameshadfield Jan 14, 2020
40c8daf
Rename boundActionCreators to actions
jameshadfield Jan 14, 2020
0738429
upgrade nodejs & npm
jameshadfield Jan 14, 2020
6670128
Fix (main) styling issues
jameshadfield Jan 14, 2020
99e3fa8
fix HTML nesting error
jameshadfield Jan 14, 2020
0a9393c
minor style fix
jameshadfield Jan 14, 2020
0d3dce5
debug (should be squashed)
jameshadfield Jan 14, 2020
6818b81
disable `gatsby-plugin-catch-links`
jameshadfield Jan 15, 2020
8f78689
user page styling fix
jameshadfield Jan 15, 2020
2fdb343
minor syntax fix
jameshadfield Jan 15, 2020
55b1676
Fix relative links which should go to server
jameshadfield Jan 15, 2020
bbbd3b9
[gatsby upgrade] fix `matchPath` in page creation
jameshadfield Jan 15, 2020
431b191
Move users page to sections
jameshadfield Jan 15, 2020
d80405f
Remove Python2 from stated dependencies
trvrb Jan 21, 2020
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
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ This repository provides the tools you need to [build nextstrain.org locally](#b
## Build nextstrain.org locally

### Install prerequisites

We recommend using a conda environment to manade the dependencies as both node version 10 and python v2 are needed.
These can be installed into a new environment via:
```
conda create -n nextstrain.org nodejs=10 python=2.7
```
Next we need to install the node dependencies by running
Install the node dependencies by running
```
npm install
```
Expand All @@ -40,7 +34,6 @@ If you add a new profile to `~/.aws/credentials`, you can then tell the local ne

---
## Splash & documentation pages

These are found in `./static-site/`.
See [static-site/README.md](./static-site/README.md) for instructions on how to add content (e.g. docs) and develop this portion of the site in isolation.
In production, this is built using Gatsby (`npm run build`) and served via the nextstrain.org server (`npm run server`).
Expand All @@ -56,7 +49,6 @@ The auspice customisations specific to nextstrain.org are found in `./auspice/cl
Please see [the auspice documentation](https://nextstrain.github.io/auspice/customisations/introduction) for more information on customising auspice.

### Testing locally

Make sure you've installed dependencies with `npm install` first (and activated your conda environment if using one).
Then run:

Expand All @@ -82,7 +74,6 @@ npx auspice develop --verbose --extend ./client/config.json --handlers ./server/


### Using a different version of Auspice

Sometimes it is useful to change the version of Auspice that is used.
Perhaps you're upgrading the version nextstrain.org uses or you want to test changes in a local copy of Auspice against nextstrain.org.

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"repository": "github:nextstrain/nextstrain.org",
"homepage": "https://nextstrain.org",
"engines": {
"node": "10.8.x",
"npm": "6.2.x"
"node": "13.6.x",
"npm": "6.13.x"
},
"scripts": {
"build": "./build.sh",
Expand Down
10 changes: 9 additions & 1 deletion static-site/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"plugins": ["lodash"]
"plugins": [
"lodash",
"babel-plugin-styled-components"
],
"presets": [
[
"babel-preset-gatsby"
]
]
}
6 changes: 3 additions & 3 deletions static-site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ For general `nextstrain.org` documentation including the nextstrain server (incl

## Installing

See [the readme](../README.md#build-nextstrainorg-locally) in the parent directory for instructions on how to install prerequisites and install nextstrain.org locally.
See [the readme](../README.md#build-nextstrainorg-locally) in the parent directory for instructions on how to install prerequisites and install nextstrain.org locally.

### Developing locally

To develop just the static-site part of nextstrain.org, you may run:

```
npm install # this needs python 2
npm install
npm run develop
```

Expand All @@ -26,7 +26,7 @@ npm run develop
If you wish to test the production build of just the static-site portion of nextstrain.org, you may run:

```
npm install # this needs python 2
npm install
npm run build
npm run serve
```
Expand Down
2 changes: 1 addition & 1 deletion static-site/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ module.exports = {
}
},
"gatsby-plugin-sharp",
"gatsby-plugin-catch-links" // See https://github.com/nextstrain/nextstrain.org/issues/34
// "gatsby-plugin-catch-links" // See https://github.com/nextstrain/nextstrain.org/issues/34
]
};
27 changes: 14 additions & 13 deletions static-site/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Here we predominantly use it to set the slug (the URL)
and the order ([chaper, page])
NOTE that for static pages, the slug is set in createPages (below)
NOTE this should probably be moved into createPages */
exports.onCreateNode = ({node, boundActionCreators, getNode}) => {
exports.onCreateNode = ({node, actions, getNode}) => {
/* for markdown files, turn (e.g.)
* /content/reports/01-flu-vaccine-selection/2015-september into
* /content/reports/flu-vaccine-selection/2015-september
Expand Down Expand Up @@ -43,31 +43,31 @@ exports.onCreateNode = ({node, boundActionCreators, getNode}) => {
}
/* step two: modify the node data */
if (chapter.name) {
boundActionCreators.createNodeField({
actions.createNodeField({
node,
name: "slug",
value: `/${section}/${chapter.name}/${post.name}`
});
// console.log(`${parsedFilePath.dir}/${parsedFilePath.name} (CHAPTERS)-> /${section}/${chapter.name}/${post.name}. Chapter order: ${chapter.order}. Post Order: ${post.order}`)
boundActionCreators.createNodeField({
actions.createNodeField({
node,
name: "chapterOrder",
value: chapter.order
});
} else {
boundActionCreators.createNodeField({
actions.createNodeField({
node,
name: "slug",
value: `/${section}/${post.name}`
});
// console.log(`${parsedFilePath.dir}/${parsedFilePath.name} -> /${section}/${post.name}. Post Order: ${post.order}`)
boundActionCreators.createNodeField({
actions.createNodeField({
node,
name: "chapterOrder",
value: "00" // this means we don't have chapters! */
});
}
boundActionCreators.createNodeField({
actions.createNodeField({
node,
name: "postOrder",
value: post.order
Expand All @@ -77,8 +77,8 @@ exports.onCreateNode = ({node, boundActionCreators, getNode}) => {
};

/* createPages essentially defines all the URLs and which component gets called to display them */
exports.createPages = ({graphql, boundActionCreators}) => {
const {createPage, createRedirect} = boundActionCreators;
exports.createPages = ({graphql, actions}) => {
const {createPage, createRedirect} = actions;

/* statically defined pages (i.e. not generated from GraphQL & markdown) */
/* The context is passed as props to the component as well as into the component's GraphQL query. */
Expand Down Expand Up @@ -180,20 +180,21 @@ exports.createPages = ({graphql, boundActionCreators}) => {
});
}
});

// Create users page
createPage({
path: "/users",
matchPath: "/users/:username",
component: path.resolve("src/pages/users.jsx")
matchPath: "/users/*",
component: path.resolve("src/sections/users.jsx")
});
})
);
});
};

exports.modifyWebpackConfig = ({config, stage}) => {
exports.onCreateWebpackConfig = ({stage, actions}) => {
if (stage === "build-javascript") {
config.plugin("Lodash", webpackLodashPlugin, null);
actions.setWebpackConfig({
plugins: [webpackLodashPlugin],
});
}
};
Loading