Skip to content

Commit

Permalink
React 16.2 and dev cert generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoferbaxter committed Jan 11, 2018
1 parent d5a0a7a commit 4b5278b
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 37 deletions.
8 changes: 4 additions & 4 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ module.exports = function(context) {

return {
presets: [
["env", {
['@babel/env', {
targets: targets[env],
modules: isServer ? "commonjs" : false,
loose: isServer ? false : true,
// debug: true,
}]
],
plugins: [
["transform-class-properties"],
["transform-es2015-block-scoping", {
["@babel/proposal-class-properties"],
["@babel/transform-block-scoping", {
"throwIfClosureRequired": true
}],
["transform-react-jsx", {
["@babel/transform-react-jsx", {
pragma: "React.createElement",
useBuiltIns: true
}]
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ Made with _kindness_ in California. 🏄
* https://yarnpkg.com/en/docs/install
2. Install h2o Proxy (to allow for local h2 and h2 push)
* Depends on your OS. Tend to use 'brew' on MacOS -- 'brew update; brew install h2o'
* Put some self-signed certs in the 'proxy' folder (http://stackoverflow.com/questions/10175812/how-to-create-a-self-signed-certificate-with-openssl)
3. Install Brotli and Zopfli CLI
* Again, depends on your OS. Typically just use 'brew', 'brew update; brew install brotli; brew install zopfli'
* https://github.com/google/brotli
* https://github.com/google/zopfli
4. Install Yarn Dependencies
* yarn install
5. Run Locally
* yarn run start (chrome only)
* yarn run bundle:prod; yarn run start (all browsers)
* yarn start (chrome only)
* yarn bundle:prod; yarn start (all browsers)
6. Access using your favorite browser
* https://localhost:5443

Expand Down
67 changes: 37 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,72 @@
"author": "Kristofer Baxter",
"license": "MIT",
"scripts": {
"start": "node_modules/.bin/nodemon -e js,css --config nodemon.config.json --exec 'yarn' start:node:dev-after-bundle",
"start": "yarn certs; yarn nodemon -e js,css --config nodemon.config.json --exec 'yarn' start:node:dev-after-bundle",
"start:node": "node dist/server/restify.server.js | ./node_modules/.bin/bunyan",
"start:node:dev-after-bundle": "yarn run bundle:dev; yarn run start:node",
"start:node:dev-after-bundle": "yarn bundle:dev; yarn start:node",
"start:h2o": "cd dist/server && h2o -c h2o.config.yaml",
"bundle:dev": "BUNDLE_ENV=dev yarn run bundle:chrome; yarn run bundle:server",
"bundle:all": "yarn run bundle:chrome; yarn run bundle:safari; yarn run bundle:edge; yarn run bundle:firefox; yarn run bundle:fallback; yarn run bundle:server",
"bundle:dev": "BUNDLE_ENV=dev yarn bundle:chrome; yarn bundle:server",
"bundle:all": "yarn bundle:chrome; yarn bundle:safari; yarn bundle:edge; yarn bundle:firefox; yarn bundle:fallback; yarn bundle:server",
"bundle:chrome": "BABEL_ENV=chrome node_modules/.bin/webpack --config config/webpack.chrome.js --json > dist/chrome/webpack.json",
"bundle:safari": "BABEL_ENV=safari node_modules/.bin/webpack --config config/webpack.safari.js --json > dist/safari/webpack.json",
"bundle:edge": "BABEL_ENV=edge node_modules/.bin/webpack --config config/webpack.edge.js --json > dist/edge/webpack.json",
"bundle:firefox": "BABEL_ENV=firefox node_modules/.bin/webpack --config config/webpack.firefox.js --json > dist/firefox/webpack.json",
"bundle:fallback": "BABEL_ENV=fallback node_modules/.bin/webpack --config config/webpack.fallback.js --json > dist/fallback/webpack.json",
"bundle:server": "BABEL_ENV=server node_modules/.bin/webpack --config config/webpack.server.js --json > dist/server/webpack.json",
"bundle:prod": "NODE_ENV=production yarn run bundle:all;",
"test:h2o": "cd dist/server && h2o -t -c h2o.config.yaml"
"bundle:prod": "NODE_ENV=production yarn bundle:all;",
"test:h2o": "cd dist/server && h2o -t -c h2o.config.yaml",
"certs": "node scripts/dev-certs.js"
},
"dependencies": {
"bunyan": "^1.8.12",
"forever": "^0.15.3",
"history": "^4.7.2",
"iltorb": "^1.2.1",
"iltorb": "^2.0.3",
"jsonfile": "^2.4.0",
"node-fetch": "^1.7.3",
"obj-str": "^1.0.0",
"object-assign-polyfill": "^0.1.0",
"promise-polyfill": "^6.0.2",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router-dom": "^4.2.2",
"restify": "^4.3.0",
"unfetch": "^2.1.2",
"useragent": "^2.1.12",
"uuid": "^3.0.1"
"unfetch": "^3.0.0",
"useragent": "^2.2.1",
"uuid": "^3.1.0"
},
"devDependencies": {
"babel-cli": "7.0.0-alpha.18",
"babel-core": "7.0.0-alpha.18",
"babel-loader": "^7.1.2",
"babel-plugin-transform-class-properties": "v7.0.0-alpha.18",
"babel-plugin-transform-es2015-block-scoping": "v7.0.0-alpha.18",
"babel-plugin-transform-react-jsx": "7.0.0-alpha.18",
"babel-preset-env": "2.0.0-alpha.19",
"@babel/cli": "v7.0.0-beta.37",
"@babel/core": "v7.0.0-beta.37",
"@babel/plugin-proposal-class-properties": "v7.0.0-beta.37",
"@babel/plugin-syntax-dynamic-import": "v7.0.0-beta.37",
"@babel/plugin-transform-block-scoping": "v7.0.0-beta.37",
"@babel/plugin-transform-destructuring": "v7.0.0-beta.37",
"@babel/plugin-transform-react-jsx": "v7.0.0-beta.37",
"@babel/plugin-transform-regenerator": "v7.0.0-beta.37",
"@babel/preset-env": "^7.0.0-beta.37",
"babel-loader": "8.0.0-beta.0",
"babel-plugin-fast-async": "^6.1.2",
"babili": "^0.1.4",
"babili-webpack-plugin": "^0.1.2",
"brotli-webpack-plugin": "^0.4.1",
"browserslist": "^2.4.0",
"brotli-webpack-plugin": "^0.5.0",
"browserslist": "^2.11.1",
"bundle-loader": "^0.5.5",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"chalk": "^2.3.0",
"copy-webpack-plugin": "^4.3.1",
"css-loader": "^0.28.8",
"cssnano": "^3.10.0",
"extract-text-webpack-plugin": "^3.0.0",
"nodemon": "^1.11.0",
"devcert-with-localhost": "^0.3.3",
"extract-text-webpack-plugin": "^3.0.2",
"nodemon": "^1.14.11",
"object.values": "^1.0.4",
"offline-plugin": "^4.8.3",
"optimize-js-plugin": "^0.0.4",
"postcss-loader": "^2.0.6",
"postcss-modules": "^0.8.0",
"style-loader": "^0.18.2",
"url-polyfill": "^1.0.7",
"webpack": "^3.5.6",
"postcss-loader": "^2.0.10",
"postcss-modules": "^1.1.0",
"style-loader": "^0.19.1",
"url-polyfill": "^1.0.10",
"webpack": "^3.10.0",
"webpack-cleanup-plugin": "^0.5.1"
}
}
38 changes: 38 additions & 0 deletions scripts/dev-certs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const chalk = require('chalk');
const getDevelopmentCertificate = require('devcert-with-localhost').default;
const fs = require('fs');
const path = require('path');

const PRIVATE_FOLDER_PATH = path.join(__dirname, '..', 'proxy');
const CERT_KEY_PATH = path.join(PRIVATE_FOLDER_PATH, 'key.pem');
const CERT_PATH = path.join(PRIVATE_FOLDER_PATH, 'cert.pem');

if (fs.existsSync(CERT_PATH)) {
process.stdout.write(chalk.yellow('📄 Existing certificate found') + chalk.dim(' – Replacing\n'));
fs.unlinkSync(CERT_PATH);
}
if (fs.existsSync(CERT_KEY_PATH)) {
process.stdout.write(chalk.yellow('🔑 Existing private key found') + chalk.dim(' – Replacing\n'));
fs.unlinkSync(CERT_KEY_PATH);
}

process.stdout.write(chalk.yellow('🔐 Generating certificates'));
getDevelopmentCertificate('react-hn', {installCertutil: true})
.then(({key, cert}) => {
process.stdout.write(chalk.dim(' – ') + chalk.green.bold('✅ Success!\n'));

fs.writeFileSync(CERT_PATH, cert);
fs.writeFileSync(CERT_KEY_PATH, key);

fs.chmodSync(CERT_PATH, '0400');
fs.chmodSync(CERT_KEY_PATH, '0400');
process.exit(0);
})
.catch(err => {
process.stderr.write(
chalk.red(
`Issue generating certificates. Please consult the "Manually Generating Certificates" section of the README\n${err}\n`,
),
);
process.exit(1);
});

0 comments on commit 4b5278b

Please sign in to comment.