-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[1.0] Change directory structure #802
Changes from 23 commits
ad3e387
9834943
e3c4245
1f999dd
f45a455
abb0351
3af80ea
240f5da
72e706f
d73cda5
871d31c
0c71ab9
2de4528
f4b80ed
186ed2b
c8ee94b
d3c99a3
5501d78
55d14b8
e85fe81
3d3ce81
7c58180
d232690
7d1f719
9886ac0
297100e
3df19af
5c87433
c913534
b3dd006
ad073ef
e43b022
46c6b0f
9aad264
04a8508
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,6 @@ | ||
// Placez vos paramètres dans ce fichier pour remplacer les paramètres par défaut et les paramètres utilisateur. | ||
{ | ||
"prettier.semi": false, | ||
"prettier.trailingComma": "es5", | ||
"editor.formatOnSave": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,7 @@ powershell console. On installing this package, it downloads and installs the | |
Visual C++ Build Tools 2015, provided free of charge by Microsoft. These tools | ||
are required to compile popular native modules. It will also install Python | ||
2.7, configuring your machine and npm appropriately. | ||
|
||
## Installing dependencies without troubles. | ||
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. Is there some pages discussing this issue that you can link to? 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. Just my personal experience for instant, but I can search ;) 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. Looks like this is what you need to do to get Hyper setup vercel/hyper#946 (comment) Perhaps just add this to the instructions instead of this section? |
||
|
||
Run `yarn` or `npm i` in **a powershell console** to have a correct build (some issues with sharp and sqlite3 with a bash console) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ClassicComponentClass } from "react"; | ||
import { LinkProps } from "react-router"; | ||
|
||
type GatsbyLink = ClassicComponentClass<LinkProps>; | ||
declare const GatsbyLink: GatsbyLink; | ||
|
||
export = GatsbyLink; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,8 @@ import _ from "lodash" | |
import slash from "slash" | ||
import createPath from "./create-path" | ||
import fs from "fs-extra" | ||
import Joi from "joi" | ||
import chalk from "chalk" | ||
import apiRunnerNode from "../utils/api-runner-node" | ||
import { graphql } from "graphql" | ||
import { layoutComponentChunkName } from "../utils/js-chunk-names" | ||
import { store } from "../redux" | ||
const { boundActionCreators } = require("../redux/actions") | ||
|
||
|
@@ -33,16 +30,20 @@ const preferDefault = m => (m && m.default) || m | |
|
||
const mkdirs = Promise.promisify(fs.mkdirs) | ||
const copy = Promise.promisify(fs.copy) | ||
const removeDir = Promise.promisify(fs.remove) | ||
const glob = Promise.promisify(globCB) | ||
|
||
// Path creator. | ||
// Auto-create pages. | ||
// algorithm is glob /pages directory for js/jsx/cjsx files *not* | ||
// underscored. Then create url w/ our path algorithm *unless* user | ||
// takes control of that page component in gatsby-node. | ||
const autoPathCreator = async (program: any) => { | ||
const pagesDirectory = path.posix.join(program.directory, `pages`) | ||
const autoPathCreator = async () => { | ||
const { config, program } = store.getState() | ||
const pagesDirectory = path.posix.join( | ||
program.directory, | ||
config.rootPath, | ||
`pages` | ||
) | ||
const exts = program.extensions.map(e => `*${e}`).join("|") | ||
// The promisified version wasn't working for some reason | ||
// so we'll use sync for now. | ||
|
@@ -90,17 +91,20 @@ module.exports = async (program: any) => { | |
|
||
// Try opening the site's gatsby-config.js file. | ||
console.time(`open and validate gatsby-config.js`) | ||
let config = {} | ||
let config = { | ||
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. Let's put defaults in Redux so data processing is centralized there. |
||
rootPath: `/`, | ||
} | ||
try { | ||
config = require(`${program.directory}/gatsby-config`) | ||
Object.assign( | ||
config, | ||
preferDefault(require(`${program.directory}/gatsby-config`)) | ||
) | ||
} catch (e) { | ||
console.log(`Couldn't open your gatsby-config.js file`) | ||
console.log(e) | ||
process.exit() | ||
} | ||
|
||
config = preferDefault(config) | ||
|
||
store.dispatch({ | ||
type: "SET_SITE_CONFIG", | ||
payload: config, | ||
|
@@ -115,7 +119,7 @@ module.exports = async (program: any) => { | |
// Also test adding to redux store. | ||
const processPlugin = plugin => { | ||
if (_.isString(plugin)) { | ||
const resolvedPath = path.dirname(require.resolve(plugin)) | ||
const resolvedPath = slash(path.dirname(require.resolve(plugin))) | ||
const packageJSON = JSON.parse( | ||
fs.readFileSync(`${resolvedPath}/package.json`, `utf-8`) | ||
) | ||
|
@@ -137,7 +141,7 @@ module.exports = async (program: any) => { | |
} | ||
plugin.options.plugins = subplugins | ||
|
||
const resolvedPath = path.dirname(require.resolve(plugin.resolve)) | ||
const resolvedPath = slash(path.dirname(require.resolve(plugin.resolve))) | ||
const packageJSON = JSON.parse( | ||
fs.readFileSync(`${resolvedPath}/package.json`, `utf-8`) | ||
) | ||
|
@@ -158,7 +162,7 @@ module.exports = async (program: any) => { | |
|
||
// Add the site's default "plugin" i.e. gatsby-x files in root of site. | ||
plugins.push({ | ||
resolve: process.cwd(), | ||
resolve: slash(process.cwd()), | ||
name: `defaultSitePlugin`, | ||
version: `n/a`, | ||
pluginOptions: { | ||
|
@@ -272,10 +276,13 @@ module.exports = async (program: any) => { | |
} | ||
|
||
// Collect resolvable extensions and attach to program. | ||
// TODO refactor this to use Redux. | ||
const extensions = [`.js`, `.jsx`] | ||
const apiResults = await apiRunnerNode("resolvableExtensions") | ||
program.extensions = apiResults.reduce((a, b) => a.concat(b), extensions) | ||
|
||
store.dispatch({ | ||
type: "SET_PROGRAM_EXTENSIONS", | ||
payload: _.flattenDeep([extensions, apiResults]), | ||
}) | ||
|
||
// Collect pages. | ||
await apiRunnerNode(`createPages`, { | ||
|
@@ -285,7 +292,7 @@ module.exports = async (program: any) => { | |
// TODO move this to own source plugin per component type | ||
// (js/cjsx/typescript, etc.). Only do after there's themes | ||
// so can cement default /pages setup in default core theme. | ||
autoPathCreator(program) | ||
autoPathCreator() | ||
|
||
// Copy /404/ to /404.html as many static site hosting companies expect | ||
// site 404 pages to be named this. | ||
|
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.
Let's stick with english here :-)
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.
Daim! It's the auto-comment of my editor ^^