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

Major Patch: ES6-Babel-6-Full-Dependencies-Upgrade #111

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
@@ -1,3 +1,3 @@
{
"stage": 0
"presets": ["es2015", "stage-0", "react"]
}
22 changes: 20 additions & 2 deletions .eslintrc
@@ -1,15 +1,33 @@
{
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"env": {
"browser": true,
"node": true
},
"parser": "babel-eslint",
"extends": "eslint-config-airbnb",
"rules": {
"no-loop-func": 0,
"quotes": [2, "single"],
"strict": [2, "never"],
"react/jsx-uses-react": 2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are redundant as they're already set in the airbnb eslint config https://github.com/airbnb/javascript/blob/fbf81eba3a02ef2dc4c92b0d98f93a4bad99869d/packages/eslint-config-airbnb/rules/react.js#L70

Only add rules here if we need to override eslint defaults or rules we inherit from airbnb.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I'll remove
"quotes": [2, "single"],
"strict": [2, "never"],
"react/jsx-uses-react": 2,
However, I'll keep "no-loop-func": 0, until glob-pages.js is modified to support this requirement.

"react/jsx-uses-vars": 2,
"react/react-in-jsx-scope": 2,
"indent": [2, 2, {"SwitchCase": 1}],
"no-console": [0],
"func-names": [0],
"semi": [2, "never"],
"no-extra-semi": [2],
"space-before-function-paren": [2, "always"],
"no-else-return": [0],
"no-else-return": [0]
},
"globals": {
"__PREFIX_LINKS__": true,
"__PREFIX_LINKS__": true
},
"plugins": [
"react"
]
}
7 changes: 5 additions & 2 deletions .gitignore
Expand Up @@ -24,9 +24,12 @@ build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
node_modules/
examples/biz-website/public/
examples/blog/public/
*.un~
dist
dist/
bin/published.js

# JetBrains IntelliJ IDEA-based project configuration directory
.idea/
6 changes: 6 additions & 0 deletions .jshintrc
@@ -0,0 +1,6 @@
{
"node": true,
"browser": true,
"esnext": true,
"newcap": false
}
29 changes: 0 additions & 29 deletions bin/build.coffee

This file was deleted.

27 changes: 27 additions & 0 deletions bin/build.js
@@ -0,0 +1,27 @@
import program from 'commander'
import path from 'path'

const packageJson = require('../package.json')

// Use compiled version of code when installed globally, otherwise use babel script version.
const build = require(('./published.js') ? ('../dist/utils/build') : ('../lib/utils/build'))

program
.version(packageJson.version)
.option('--prefix-links', 'Build site with links prefixed (set prefix in your config).')
.parse(process.argv)

let relativeDirectory = program.args[0]
if (!(typeof relativeDirectory !== 'undefined' && relativeDirectory !== null)) { relativeDirectory = '.' }
const directory = path.resolve(relativeDirectory)

program.directory = directory
program.relativeDirectory = relativeDirectory

build(program, function (err) {
if ((typeof err !== 'undefined' && err !== null)) {
throw err
} else {
return console.log('Done')
}
})
1 change: 0 additions & 1 deletion bin/cli.js
@@ -1,4 +1,3 @@
#!/usr/bin/env node

require('coffee-script/register')
require('./index')
26 changes: 0 additions & 26 deletions bin/develop.coffee

This file was deleted.

22 changes: 22 additions & 0 deletions bin/develop.js
@@ -0,0 +1,22 @@
import program from 'commander'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder that this code needs to be ES5/commonjs as Babel doesn't work when code is globally installed https://phabricator.babeljs.io/T1889 #54

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah indeed, I'll will adjust this to utilize requires instead along with ES5 compliant code.

import path from 'path'

import packageJson from '../package.json'

// Use compiled version of code when installed globally, otherwise use babel script version.
const develop = require(('./published.js') ? ('../dist/utils/develop') : ('../lib/utils/develop'))

program
.version(packageJson.version)
.option('-h, --host <url>', 'Set host. Defaults to 0.0.0.0', '0.0.0.0')
.option('-p, --port <port>', 'Set port. Defaults to 8000', '8000')
.parse(process.argv)

let relativeDirectory = program.args[0]
if (!(typeof relativeDirectory !== 'undefined' && relativeDirectory !== null)) { relativeDirectory = '.' }
const directory = path.resolve(relativeDirectory)

program.directory = directory
program.relativeDirectory = relativeDirectory

develop(program)
3 changes: 1 addition & 2 deletions bin/gatsby-build.js
@@ -1,5 +1,4 @@
#!/usr/bin/env node

require('babel/register')
require('coffee-script/register')
require('babel-register')
require('./build')
3 changes: 1 addition & 2 deletions bin/gatsby-develop.js
@@ -1,5 +1,4 @@
#!/usr/bin/env node
require('babel/register')

require('coffee-script/register')
require('babel-register')
require('./develop')
3 changes: 1 addition & 2 deletions bin/gatsby-new.js
@@ -1,5 +1,4 @@
#!/usr/bin/env node

require('coffee-script/register')
require('babel/register')
require('babel-register')
require('./new')
5 changes: 2 additions & 3 deletions bin/index.coffee → bin/index.js
@@ -1,7 +1,6 @@
program = require 'commander'
path = require 'path'
const program = require('commander')

packageJson = require '../package.json'
const packageJson = require('../package.json')

program
.version(packageJson.version)
Expand Down
29 changes: 0 additions & 29 deletions bin/new.coffee

This file was deleted.

23 changes: 23 additions & 0 deletions bin/new.js
@@ -0,0 +1,23 @@
const program = require('commander')
const loggy = require('loggy')

const packageJson = require('../package.json')

// Use compiled version of code when installed globally, otherwise use babelscript version.
const initStarter = require(('./published.js') ? ('../dist/utils/init-starter') : ('../lib/utils/init-starter'))

program
.version(packageJson.version)
.parse(process.argv)

const rootPath = program.args[0]
const starter = ((program.args.length === 1) ? ('gh:gatsbyjs/gatsby-starter-default') : (program.args[1]))

initStarter(starter, {
rootPath,
logger: loggy,
}, function (error) {
if (error) {
return loggy.error(error)
}
})
14 changes: 8 additions & 6 deletions lib/isomorphic/HTML.jsx → lib/isomorphic/HTML.js
@@ -1,4 +1,6 @@
import React, {PropTypes} from 'react'
'use strict'

import React, { PropTypes } from 'react'
import Typography from 'typography'

const TypographyStyle = new Typography().TypographyStyle
Expand All @@ -10,14 +12,14 @@ module.exports = React.createClass({
favicon: PropTypes.string,
},

getDefaultProps: function () {
getDefaultProps () {
return {
title: 'Default title',
body: '',
}
},

render: function () {
render () {
return (
<html lang="en">
<head>
Expand All @@ -27,12 +29,12 @@ module.exports = React.createClass({
<title>
{this.props.title}
</title>
<link rel="shortcut icon" href={this.props.favicon} />
<link rel="shortcut icon" href={ this.props.favicon } />
<TypographyStyle/>
<style dangerouslySetInnerHTML={{ __html: `body {color: rgb(66,66,66)} h1,h2,h3,h4,h5,h6 {color: rgb(44,44,44)}a {color: rgb(42,93,173)text-decoration: none}a:hover{text-decoration: underline}`}} />
<style dangerouslySetInnerHTML={{ __html: `body {color: rgb(66,66,66)} h1,h2,h3,h4,h5,h6 {color: rgb(44,44,44)}a {color: rgb(42,93,173)text-decoration: none}a:hover{text-decoration: underline}` }} />
</head>
<body className="landing-page">
<div id="react-mount" dangerouslySetInnerHTML={{__html: this.props.body}} />
<div id="react-mount" dangerouslySetInnerHTML={{ __html: this.props.body }} />
<script src="/bundle.js" />
</body>
</html>
Expand Down