diff --git a/.circleci/config.yml b/.circleci/config.yml index c35d0f972..d851dabdf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,7 +64,7 @@ jobs: git config --global user.email "thymikee@users.noreply.github.com" git config --global user.name "Michał Pierzchała" echo "machine github.com login thymikee password $GITHUB_TOKEN" > ~/.netrc - cd website && yarn install && GIT_USER=thymikee yarn run publish-gh-pages + cd website && yarn install && GIT_USER=thymikee yarn deploy workflows: version: 2 diff --git a/.eslintrc b/.eslintrc index a25c4677d..dee438153 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,6 +4,11 @@ "flowtype/no-weak-types": 0, "react-native/no-raw-text": 0, "no-console": 1, - "react/no-multi-comp": 0 + "react/no-multi-comp": 0, + // Ignore certain webpack alias because it can't be resolved + "import/no-unresolved": [ + 2, + { "ignore": ["^@theme", "^@docusaurus", "^@generated"] } + ] } } diff --git a/.gitignore b/.gitignore index c77dbf4ce..13a6c4cc7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build # Ignore lock files in examples for now examples/**/yarn.lock +.docusaurus diff --git a/website/.gitignore b/website/.gitignore index 5395ea795..b2d6de306 100644 --- a/website/.gitignore +++ b/website/.gitignore @@ -1,12 +1,20 @@ -.DS_Store +# Dependencies +/node_modules + +# Production +/build -node_modules +# Generated files +.docusaurus +.cache-loader -lib/core/metadata.js -lib/core/MetadataBlog.js +# Misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local -website/translated_docs -website/build/ -website/yarn.lock -website/node_modules -website/i18n/* +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/website/README.md b/website/README.md index f3da77ff3..ee0ccc9d1 100644 --- a/website/README.md +++ b/website/README.md @@ -1,193 +1,33 @@ -This website was created with [Docusaurus](https://docusaurus.io/). +# Website -# What's In This Document +This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator. -* [Get Started in 5 Minutes](#get-started-in-5-minutes) -* [Directory Structure](#directory-structure) -* [Editing Content](#editing-content) -* [Adding Content](#adding-content) -* [Full Documentation](#full-documentation) +### Installation -# Get Started in 5 Minutes - -1. Make sure all the dependencies for the website are installed: - -```sh -# Install dependencies -$ yarn -``` -2. Run your dev server: - -```sh -# Start the site -$ yarn start -``` - -## Directory Structure - -Your project file structure should look something like this - -``` -my-docusaurus/ - docs/ - doc-1.md - doc-2.md - doc-3.md - website/ - blog/ - 2016-3-11-oldest-post.md - 2017-10-24-newest-post.md - core/ - node_modules/ - pages/ - static/ - css/ - img/ - package.json - sidebar.json - siteConfig.js ``` - -# Editing Content - -## Editing an existing docs page - -Edit docs by navigating to `docs/` and editing the corresponding document: - -`docs/doc-to-be-edited.md` - -```markdown ---- -id: page-needs-edit -title: This Doc Needs To Be Edited ---- - -Edit me... -``` - -For more information about docs, click [here](https://docusaurus.io/docs/en/navigation) - -## Editing an existing blog post - -Edit blog posts by navigating to `website/blog` and editing the corresponding post: - -`website/blog/post-to-be-edited.md` -```markdown ---- -id: post-needs-edit -title: This Blog Post Needs To Be Edited ---- - -Edit me... +$ yarn ``` -For more information about blog posts, click [here](https://docusaurus.io/docs/en/adding-blog) - -# Adding Content - -## Adding a new docs page to an existing sidebar - -1. Create the doc as a new markdown file in `/docs`, example `docs/newly-created-doc.md`: - -```md ---- -id: newly-created-doc -title: This Doc Needs To Be Edited ---- +### Local Development -My new content here.. ``` - -1. Refer to that doc's ID in an existing sidebar in `website/sidebar.json`: - -```javascript -// Add newly-created-doc to the Getting Started category of docs -{ - "docs": { - "Getting Started": [ - "quick-start", - "newly-created-doc" // new doc here - ], - ... - }, - ... -} +$ yarn start ``` -For more information about adding new docs, click [here](https://docusaurus.io/docs/en/navigation) +This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server. -## Adding a new blog post +### Build -1. Make sure there is a header link to your blog in `website/siteConfig.js`: - -`website/siteConfig.js` -```javascript -headerLinks: [ - ... - { blog: true, label: 'Blog' }, - ... -] ``` - -2. Create the blog post with the format `YYYY-MM-DD-My-Blog-Post-Title.md` in `website/blog`: - -`website/blog/2018-05-21-New-Blog-Post.md` - -```markdown ---- -author: Frank Li -authorURL: https://twitter.com/foobarbaz -authorFBID: 503283835 -title: New Blog Post ---- - -Lorem Ipsum... +$ yarn build ``` -For more information about blog posts, click [here](https://docusaurus.io/docs/en/adding-blog) +This command generates static content into the `build` directory and can be served using any static contents hosting service. -## Adding items to your site's top navigation bar +### Deployment -1. Add links to docs, custom pages or external links by editing the headerLinks field of `website/siteConfig.js`: - -`website/siteConfig.js` -```javascript -{ - headerLinks: [ - ... - /* you can add docs */ - { doc: 'my-examples', label: 'Examples' }, - /* you can add custom pages */ - { page: 'help', label: 'Help' }, - /* you can add external links */ - { href: 'https://github.com/facebook/Docusaurus', label: 'GitHub' }, - ... - ], - ... -} ``` - -For more information about the navigation bar, click [here](https://docusaurus.io/docs/en/navigation) - -## Adding custom pages - -1. Docusaurus uses React components to build pages. The components are saved as .js files in `website/pages/en`: -1. If you want your page to show up in your navigation header, you will need to update `website/siteConfig.js` to add to the `headerLinks` element: - -`website/siteConfig.js` -```javascript -{ - headerLinks: [ - ... - { page: 'my-new-custom-page', label: 'My New Custom Page' }, - ... - ], - ... -} +$ GIT_USER= USE_SSH=true yarn deploy ``` -For more information about custom pages, click [here](https://docusaurus.io/docs/en/custom-pages). - -# Full Documentation - -Full documentation can be found on the [website](https://docusaurus.io/). +If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. diff --git a/website/core/Footer.js b/website/core/Footer.js deleted file mode 100644 index f58e5298a..000000000 --- a/website/core/Footer.js +++ /dev/null @@ -1,79 +0,0 @@ -/** - * 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; - return `${baseUrl}docs/${language ? `${language}/` : ''}${doc}`; - } - - pageUrl(doc, language) { - const { baseUrl } = this.props.config; - return baseUrl + (language ? `${language}/` : '') + doc; - } - - render() { - return ( - - ); - } -} - -module.exports = Footer; diff --git a/website/docker/.dockerignore b/website/docker/.dockerignore index 27d2dae2b..1a9e78bd4 100644 --- a/website/docker/.dockerignore +++ b/website/docker/.dockerignore @@ -1,2 +1,3 @@ */node_modules *.log +.docusaurus diff --git a/website/docker/Dockerfile b/website/docker/Dockerfile index d369844d5..010fec3d4 100644 --- a/website/docker/Dockerfile +++ b/website/docker/Dockerfile @@ -3,7 +3,6 @@ FROM node:8.11.4 WORKDIR /app/website EXPOSE 3000 35729 -COPY ./docs /app/docs COPY ./website /app/website RUN yarn install diff --git a/website/docker/docker-compose.yml b/website/docker/docker-compose.yml index 6711192ae..9555ba040 100644 --- a/website/docker/docker-compose.yml +++ b/website/docker/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3" +version: '3' services: docusaurus: @@ -7,12 +7,5 @@ services: - 3000:3000 - 35729:35729 volumes: - - ./docs:/app/docs - - ./website/blog:/app/website/blog - - ./website/core:/app/website/core - - ./website/i18n:/app/website/i18n - - ./website/pages:/app/website/pages - - ./website/static:/app/website/static - - ./website/sidebars.json:/app/website/sidebars.json - - ./website/siteConfig.js:/app/website/siteConfig.js + - ./website:/app/website working_dir: /app/website diff --git a/docs/API.md b/website/docs/API.md similarity index 100% rename from docs/API.md rename to website/docs/API.md diff --git a/docs/GettingStarted.md b/website/docs/GettingStarted.md similarity index 100% rename from docs/GettingStarted.md rename to website/docs/GettingStarted.md diff --git a/docs/Queries.md b/website/docs/Queries.md similarity index 100% rename from docs/Queries.md rename to website/docs/Queries.md diff --git a/docs/ReactNavigation.md b/website/docs/ReactNavigation.md similarity index 100% rename from docs/ReactNavigation.md rename to website/docs/ReactNavigation.md diff --git a/docs/ReduxIntegration.md b/website/docs/ReduxIntegration.md similarity index 100% rename from docs/ReduxIntegration.md rename to website/docs/ReduxIntegration.md diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js new file mode 100644 index 000000000..e828c01f8 --- /dev/null +++ b/website/docusaurus.config.js @@ -0,0 +1,113 @@ +const repoUrl = 'https://github.com/callstack/react-native-testing-library'; +const title = 'React Native Testing Library'; + +const siteConfig = { + title, // Title for your website. + tagline: 'Helps you to write better tests with less effort.', + url: 'https://callstack.github.io', // Your website URL + baseUrl: '/react-native-testing-library/', // Base URL for your project + // Used for publishing and more + projectName: 'react-native-testing-library', + organizationName: 'callstack', + favicon: 'img/owl.png', + + themeConfig: { + sidebarCollapsible: false, + navbar: { + title, + logo: { + alt: title, + src: 'img/owl.png', + }, + links: [ + { to: 'docs/getting-started', label: 'Docs', position: 'right' }, + { href: repoUrl, label: 'GitHub', position: 'right' }, + ], + }, + footer: { + style: 'dark', + links: [ + { + title: 'Docs', + items: [ + { + key: 1, + label: 'Getting started', + to: 'docs/getting-started', + }, + { + key: 2, + label: 'API', + to: 'docs/api', + }, + ], + }, + { + title: 'Community', + items: [ + { + key: 3, + label: 'Stack Overflow', + href: + 'http://stackoverflow.com/questions/tagged/react-native-testing-library', + }, + { + key: 4, + label: 'Discord Channel', + href: 'https://discord.gg/QbGezWe', + }, + ], + }, + { + title: 'More', + items: [ + { + key: 5, + label: 'GitHub', + href: '/callstack/react-native-testing-library', + }, + { + key: 6, + label: 'Star', + href: '/callstack/react-native-testing-library', + }, + ], + }, + ], + copyright: `Copyright © ${new Date().getFullYear()} Callstack Open Source`, + }, + image: 'img/owl.png', + prism: { + theme: require('prism-react-renderer/themes/github'), + darkTheme: require('prism-react-renderer/themes/dracula'), + defaultLanguage: 'jsx', + }, + algolia: { + apiKey: 'cd9b8b73f97b64ed04570e41c507683f', + indexName: 'react-native-testing-library', + }, + }, + + presets: [ + [ + '@docusaurus/preset-classic', + { + docs: { + sidebarPath: require.resolve('./sidebars.js'), + // Please change this to your repo. + editUrl: `${repoUrl}/blob/master`, + }, + blog: { + showReadingTime: true, + // Please change this to your repo. + editUrl: `${repoUrl}/blob/master/blog`, + }, + theme: { + customCss: require.resolve('./src/css/custom.css'), + }, + }, + ], + ], +}; + +module.exports = siteConfig; diff --git a/website/i18n/en.json b/website/i18n/en.json deleted file mode 100644 index 592bc7e0f..000000000 --- a/website/i18n/en.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "_comment": "This file is auto-generated by write-translations.js", - "localized-strings": { - "next": "Next", - "previous": "Previous", - "tagline": "Helps you to write better tests with less effort.", - "docs": { - "api": { - "title": "API" - }, - "getting-started": { - "title": "Getting Started" - }, - "api-queries": { - "title": "Queries" - }, - "react-navigation": { - "title": "React Navigation" - }, - "redux-integration": { - "title": "Redux Integration" - } - }, - "links": { - "Docs": "Docs", - "GitHub": "GitHub" - }, - "categories": { - "Introduction": "Introduction", - "API Reference": "API Reference", - "Examples": "Examples" - } - }, - "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" - } -} diff --git a/website/package.json b/website/package.json index 6c6c2a605..c710ed7e0 100644 --- a/website/package.json +++ b/website/package.json @@ -3,17 +3,28 @@ "version": "0.0.0", "private": true, "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" + "start": "docusaurus start", + "build": "docusaurus build", + "swizzle": "docusaurus swizzle", + "deploy": "docusaurus deploy" }, "dependencies": { - "docusaurus": "^1.5.1", - "react": "^16.8.1", - "react-dom": "^16.8.1" + "@docusaurus/core": "^2.0.0-alpha.54", + "@docusaurus/preset-classic": "^2.0.0-alpha.54", + "classnames": "^2.2.6", + "react": "^16.8.4", + "react-dom": "^16.8.4" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] } } diff --git a/website/pages/en/index.js b/website/pages/en/index.js deleted file mode 100644 index e86e59ffc..000000000 --- a/website/pages/en/index.js +++ /dev/null @@ -1,100 +0,0 @@ -/** - * 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'); -const CompLibrary = require('../../core/CompLibrary.js'); - -const siteConfig = require(`${process.cwd()}/siteConfig.js`); - -function docUrl(doc, language) { - return `${siteConfig.baseUrl}docs/${language ? `${language}/` : ''}${doc}`; -} - -class Button extends React.Component { - render() { - return ( -
- - {this.props.children} - -
- ); - } -} - -Button.defaultProps = { - target: '_self', -}; - -const SplashContainer = props => ( -
-
-
{props.children}
-
-
-); - -const ProjectTitle = () => ( - -

- {siteConfig.title} - {siteConfig.tagline} -

- -
-); - -class HomeSplash extends React.Component { - render() { - return ( - -
- - -
- - - -
- ); - } -} - -class Index extends React.Component { - render() { - const language = this.props.language || ''; - - return ; - } -} - -module.exports = Index; diff --git a/website/sidebars.js b/website/sidebars.js new file mode 100644 index 000000000..67b9b5d86 --- /dev/null +++ b/website/sidebars.js @@ -0,0 +1,7 @@ +module.exports = { + docs: { + Introduction: ['getting-started'], + 'API Reference': ['api', 'api-queries'], + Examples: ['react-navigation', 'redux-integration'], + }, +}; diff --git a/website/sidebars.json b/website/sidebars.json deleted file mode 100644 index 60552cd6a..000000000 --- a/website/sidebars.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "docs": { - "Introduction": ["getting-started"], - "API Reference": ["api", "api-queries"], - "Examples": ["react-navigation", "redux-integration"] - } -} diff --git a/website/siteConfig.js b/website/siteConfig.js deleted file mode 100644 index 2c4ea5065..000000000 --- a/website/siteConfig.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * 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. - */ - -// See https://docusaurus.io/docs/site-config for all the possible -// site configuration options. - -const repoUrl = 'https://github.com/callstack/react-native-testing-library'; - -const siteConfig = { - title: 'React Native Testing Library', // Title for your website. - tagline: 'Helps you to write better tests with less effort.', - url: 'https://callstack.github.io', // Your website URL - baseUrl: '/react-native-testing-library/', // Base URL for your project - - // Used for publishing and more - projectName: 'react-native-testing-library', - organizationName: 'callstack', - // For top-level user or org sites, the organization is still the same. - // e.g., for the https://JoelMarcey.github.io site, it would be set like... - // organizationName: 'JoelMarcey' - - // For no header links in the top nav bar -> headerLinks: [], - headerLinks: [ - { doc: 'getting-started', label: 'Docs' }, - { href: repoUrl, label: 'GitHub' }, - ], - - /* path to images for header/footer */ - headerIcon: 'img/owl.png', - footerIcon: 'img/owl.png', - favicon: 'img/owl.png', - - /* Colors for website */ - colors: { - primaryColor: '#262626', - secondaryColor: '#bf8a65', - }, - - /* Custom fonts for website */ - /* - fonts: { - myFont: [ - "Times New Roman", - "Serif" - ], - myOtherFont: [ - "-apple-system", - "system-ui" - ] - }, - */ - - // This copyright info is used in /core/Footer.js and blog RSS/Atom feeds. - copyright: `Copyright © ${new Date().getFullYear()} Callstack Open Source`, - - highlight: { - // Highlight.js theme to use for syntax highlighting in code blocks. - theme: 'default', - }, - - // Add custom scripts here that would be placed in