Skip to content

Commit

Permalink
Base website setup with Docusaurus (#374)
Browse files Browse the repository at this point in the history
* initial stab at docusarus website

* switch colors to brown, do some TODOs

* kill webpack svg

* delete duplicate hmr files

* fix(eslint): addressed all eslint issues
  • Loading branch information
FLGMwt authored and thymikee committed Apr 24, 2018
1 parent b8ba6e2 commit 95ade60
Show file tree
Hide file tree
Showing 30 changed files with 2,315 additions and 20 deletions.
5 changes: 4 additions & 1 deletion docs/CLI Commands.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# CLI Commands
---
id: cli
title: CLI Commands
---

## `haul init`

Expand Down
6 changes: 4 additions & 2 deletions docs/Code Push.md → docs/CodePush.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Integrating Haul with CodePush

---
id: codepush
title: Integrating Haul with CodePush
---

## What is CodePush?

Expand Down
5 changes: 4 additions & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Configuration
---
id: configuration
title: Configuration
---

> You can use Haul also without any configuration. If you don't have in you project file named `haul.config.js` and you don't specify custom one it will be used the default Haul configuration with entry point from you `package.json`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Configuring your project
---
id: configuring_your_project
title: Configuring Your Project
---

## Integrating with Xcode

Expand Down
43 changes: 43 additions & 0 deletions docs/Getting_Started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
id: getting_started
title: Getting Started
sidebar_label: Add Haul to your project
---

Start by adding Haul as a dependency to your React Native project (use `react-native init MyProject` to create one if you don't have a project):

```bash
yarn add --dev haul
```

If you're on a React Native version >= 0.43, add the following in `android/app/build.gradle` somewhere before the `apply from: "../../node_modules/react-native/react.gradle"` statement:

```
project.ext.react = [
cliPath: "node_modules/haul/bin/cli.js"
]
```

To configure your project to use haul, run the following:

```bash
yarn haul init
```

This will automatically add the configuration needed to make Haul work with your app, e.g. add `webpack.haul.js` to your project, which you can customise to add more functionality.

Next, you're ready to start the development server:

```bash
yarn haul start -- --platform ios
```

Finally, reload your app to update the bundle or run your app just like you normally would:

```bash
react-native run-ios
```

<p align="center">
<img width="635" src="https://cloud.githubusercontent.com/assets/2464966/24395888/8957aba8-13a1-11e7-96a3-70d34d4b5069.png" />
</p>
7 changes: 5 additions & 2 deletions docs/hmr/API.md → docs/HMR_API.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Haul HMR API
---
id: hmr_api
title: Haul HMR API
---

## Module `haul/hot/patch.js`

Expand All @@ -16,7 +19,7 @@ require('haul/hot/patch');
does nothing.

* In development (`NODE_ENV !== 'production'`):

Patches React's `createElement` and `createFactory`, so that they use `react-proxy` and return a proxied component. Those components behave like the normal ones, but have their state persisted between updates.

This file __must be imported/required in the root file / entry file before anything else__, since the code must be executed at the very beginning.
Expand Down
5 changes: 4 additions & 1 deletion docs/hmr/Setup.md → docs/HMR_Setup.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Hot Module Replacement setup
---
id: hmr_setup
title: Hot Module Replacement setup
---

For projects created before version 0.49.0, use [this guide](https://github.com/callstack/haul/blob/740b6c3cfb51d3919c69e37935d69a4c96dec94e/docs/hmr/Setup.md).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# HMR setup with `react-native-navigation`

> Navigate to: [API docs](../API.md)
---
id: hmr_react_native_navigation
title: HMR setup with `react-native-navigation`
---

Since we don't know how your project looks like, we will use one of the possible setups. If your project is structured differently, please __tweak this guide according to your needs__.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# HMR setup with `react-navigation`

> Navigate to: [API docs](../API.md)
---
id: hmr_react_navigation
title: HMR setup with `react-navigation`
---

Since we don't know how your project looks like, we will use one of the possible setups. If your project is structured differently, please __tweak this guide according to your needs__.

Expand Down
15 changes: 9 additions & 6 deletions docs/Recipes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Recipes
---
id: recipes
title: Recipes
---

## Typescript
You will need to install `ts-loader` for Haul to work with TypeScript.
Expand Down Expand Up @@ -97,10 +100,10 @@ module.exports = ({ platform }, { module, resolve }) => ({
```

## Mock files when running detox tests
[Detox](https://github.com/wix/detox) is a "grey box" e2e framework developed by wix.
It provides the ability to mock files during tests using [react-native-repackager](https://github.com/wix/react-native-repackager)
[Detox](https://github.com/wix/detox) is a "grey box" e2e framework developed by wix.
It provides the ability to mock files during tests using [react-native-repackager](https://github.com/wix/react-native-repackager)

react-native-repackager is built for the standard react-native packager, so your mocks won't work with haul out-of-the-box. Luckily, it's easy to congiure haul (webpack, actually) to resolve the mocked files instead of the original ones during tests:
react-native-repackager is built for the standard react-native packager, so your mocks won't work with haul out-of-the-box. Luckily, it's easy to congiure haul (webpack, actually) to resolve the mocked files instead of the original ones during tests:


```javascript
Expand All @@ -109,15 +112,15 @@ react-native-repackager is built for the standard react-native packager, so your

resolve: {
...defaults.resolve,
extensions: process.env.APP_ENV === 'detox_tests'
extensions: process.env.APP_ENV === 'detox_tests'
? ['.mock.behaviour.js', ...defaults.resolve.extensions]
: defaults.resolve.extensions
},


```

Set the environment variable `APP_ENV` to
Set the environment variable `APP_ENV` to
`detox_tests` when running Haul:

```sh
Expand Down
11 changes: 11 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
.DS_Store
lib/core/metadata.js
lib/core/MetadataBlog.js
website/translated_docs
website/build/
website/yarn.lock
website/node_modules

website/i18n/*
!website/i18n/en.json
80 changes: 80 additions & 0 deletions website/core/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const React = require('react');

class Footer extends React.Component<*> {
docUrl(doc, language) {
const baseUrl = this.props.config.baseUrl;
return `${baseUrl}docs/${language ? `${language}/` : ''}${doc}`;
}

pageUrl(doc, language) {
const baseUrl = this.props.config.baseUrl;
return baseUrl + (language ? `${language}/` : '') + doc;
}

render() {
return (
<footer className="nav-footer" id="footer">
<section className="sitemap">
<a href={this.props.config.baseUrl} className="nav-home">
{this.props.config.footerIcon && (
<img
src={this.props.config.baseUrl + this.props.config.footerIcon}
alt={this.props.config.title}
width="66"
height="58"
/>
)}
</a>
<div>
<h5>Docs</h5>
<a href={this.docUrl('getting_started.html', this.props.language)}>
Getting Started
</a>
<a href={this.docUrl('cli.html', this.props.language)}>Guides</a>
</div>
<div>
<h5>Community</h5>
<a href={this.pageUrl('users.html', this.props.language)}>
User Showcase
</a>
<a
href="http://stackoverflow.com/questions/tagged/haul"
rel="noopener noreferrer"
target="_blank"
>
Stack Overflow
</a>
<a
href="https://slack.callstack.com/"
rel="noopener noreferrer"
target="_blank"
>
Project Chat
</a>
<a
href="https://twitter.com/callstackio"
rel="noopener noreferrer"
target="_blank"
>
Twitter
</a>
</div>
<div>
<h5>More</h5>
<a href={this.props.config.repoUrl}>GitHub</a>
</div>
</section>
<section className="copyright">{this.props.config.copyright}</section>
</footer>
);
}
}

module.exports = Footer;
34 changes: 34 additions & 0 deletions website/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"_comment": "This file is auto-generated by write-translations.js",
"localized-strings": {
"next": "Next",
"previous": "Previous",
"tagline": "A command line tool for developing React Native apps",
"cli": "CLI Commands",
"codepush": "Integrating Haul with CodePush",
"configuration": "Configuration",
"configuring_your_project": "Configuring Your Project",
"getting_started": "Getting Started",
"Add Haul to your project": "Add Haul to your project",
"hmr_api": "Haul HMR API",
"hmr_react_native_navigation": "HMR setup with `react-native-navigation`",
"hmr_react_navigation": "HMR setup with `react-navigation`",
"hmr_setup": "Hot Module Replacement setup",
"API": "API",
"react-native-navigation": "react-native-navigation",
"react-navigation": "react-navigation",
"Setup": "Setup",
"recipes": "Recipes",
"Docs": "Docs",
"CLI": "CLI",
"GitHub": "GitHub",
"Getting Started": "Getting Started",
"Guides": "Guides",
"Hot Module Reloading": "Hot Module Reloading"
},
"pages-strings": {
"Help Translate|recruit community translators for your project": "Help Translate",
"Edit this Doc|recruitment message asking to edit the doc source": "Edit",
"Translate this Doc|recruitment message asking to translate the docs": "Translate"
}
}
21 changes: 21 additions & 0 deletions website/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"scripts": {
"examples": "docusaurus-examples",
"start": "docusaurus-start",
"build": "docusaurus-build",
"publish-gh-pages": "docusaurus-publish",
"write-translations": "docusaurus-write-translations",
"version": "docusaurus-version",
"rename-version": "docusaurus-rename-version"
},
"devDependencies": {
"docusaurus": "^1.0.5"
},
"eslintConfig": {
"rules": {
"react/no-multi-comp": 0,
"import/no-unresolved": 0,
"import/no-extraneous-dependencies": 0
}
}
}
Loading

0 comments on commit 95ade60

Please sign in to comment.