diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 00000000..a76f46c8 --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -0,0 +1,51 @@ +name: Build and Deploy + +on: + push: + branches: + - 'preview' + - 'versions/3.0-complete' + +jobs: + build: + runs-on: ubuntu-latest + env: + BASE_URL: https://dev.nightwatchjs.org + REMOTE_SERVER: ${{ secrets.REMOTE_SERVER }} + REMOTE_USER: ${{ secrets.REMOTE_USER }} + API_DOCS_FOLDER: ${{ github.workspace }}/nightwatch/lib/api + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Checkout Nightwatch source code + uses: actions/checkout@v2 + with: + repository: nightwatchjs/nightwatch + path: nightwatch + + - name: Use Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' + + - name: Install dependencies + run: npm install + + - name: Build the website + run: npm run build + + - name: Creating symlinks to old version + run: | + ln -s ../nightwatchjs.org out/v17 + ln -s ../v09.nightwatchjs.org out/v09 + ln -s ../nightwatch-v26 out/v26 + + - name: Deploy to server + run: | + mkdir -p ~/.ssh + echo "${{ secrets.PROD_DEPLOY_SECRET }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan ${{ env.REMOTE_SERVER }} >> ~/.ssh/known_hosts + rsync -azP --delete ./out/ ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:${{ secrets.REMOTE_PREVIEW_DIRECTORY }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 338e3d73..50250fd1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,23 @@ node_modules .idea *.plist +.idea/ +.vscode/ -api/**/*.ejs \ No newline at end of file +# Dependency directories +node_modules/ +logs + +# Postdoc output directory +out/ +output/ + +# dotenv environment variables file +.env +.env.local + +# Nightwatch output directory +tests_output +/public/__examples/ +package-lock.json +.pd* \ No newline at end of file diff --git a/README.md b/README.md index 41950ae4..758c4aac 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Nightwatch Documentation +# Nightwatch.js Documentation Documentation sources for [nightwatchjs.org](http://nightwatchjs.org) website. @@ -10,12 +10,73 @@ Documentation sources for [nightwatchjs.org](http://nightwatchjs.org) website. [![Twitter Follow](https://img.shields.io/twitter/follow/nightwatchjs.svg?style=social)](https://twitter.com/nightwatchjs)

- Nightwatch.js Schematic Logo + Nightwatch.js Logo

-#### [Homepage](https://nightwatchjs.org) • [Getting Started](https://nightwatchjs.org/gettingstarted) • [Developer Guide](https://nightwatchjs.org/guide) • [API Reference](https://nightwatchjs.org/api) • [About](https://nightwatchjs.org/about) +#### [Homepage](https://nightwatchjs.org) • [Developer Guide](https://nightwatchjs.org/guide) • [API Reference](https://nightwatchjs.org/api) • [About](https://nightwatchjs.org/about) • [Blog](https://nightwatchjs.org/blog) *** +## Development + +The docs content is written in Markdown and it is located in the `docs` folder. The individual API command pages are generated from the Nightwatch source code. based on the JSDoc comments. + +### Run the website locally + +The website is built with **PostDoc** (a static site generator built with Vite and EJS). It supports Markdown, EJS, and front matter. +It comes with a dev server with Hot module replacement (HMR). + +### Configuration + +The website configuration is located in the `postdoc.config.js` file. In order to run the website locally, you need to have the Nightwatch source code repo clones and then specify the path to it in the `postdoc.config.js` file. + +You can also set the `API_DOCS_FOLDER` environment variable to specify the path. You can also disable the API docs generation by setting the `apidocs` property to `false` in the `postdoc.config.js` file, e.g.: + +```js +export default { + apidocs: false +} +``` + +### Installation + +```bash +npm install +npm start +``` + +### PostDoc CLI + +To view the available options, run: + +```bash +npx postdoc --help +``` + +#### Automatically open the website in the browser + +```bash +npm start -- --open [chrome|firefox|edge|safari] +``` + +## Build + +To build the website, run: + +```bash +npm run build +``` + +The generated files will be in the `out` folder. + +Quickly serve the generated files with: + +```bash +npx postdoc preview +``` + +## License +MIT + [discord-badge]: https://img.shields.io/discord/618399631038218240.svg?color=7389D8&labelColor=6A7EC2&logo=discord&logoColor=ffffff&style=flat-square [discord]: https://discord.gg/SN8Da2X diff --git a/build/optimize.js b/build/optimize.js new file mode 100644 index 00000000..d5c28dae --- /dev/null +++ b/build/optimize.js @@ -0,0 +1,54 @@ +import {generate} from 'critical'; +import {minify} from 'html-minifier'; +import {readFileSync, writeFileSync} from 'fs'; +import path from 'path'; + +// Inline critical CSS +generate({ + inline: true, + base: 'out/', + src: 'index.html', + target: { + html: 'index.html', + uncritical: 'css/landing/style.css' + }, + dimensions: [ + { + height: 200, + width: 500 + }, + { + height: 900, + width: 1024 + }, + { + height: 900, + width: 1400 + } + ], + // ignore CSS rules + ignoreInlinedStyles: true +}).then(({css, html, uncritical}) => { + console.log('Critical CSS generated', css.length); + console.log('Uncritical CSS generated', uncritical.length); +}).catch(err => { + console.error('Critical CSS generation failed', err); +}).then(() => { + // Minify HTML + const htmlPath = path.resolve('out/index.html'); + const htmlContent = readFileSync(htmlPath, 'utf8'); + const minifiedHTMLContent = minify(htmlContent, { + collapseWhitespace: true, + collapseInlineTagWhitespace: true, + conservativeCollapse: true, + minifyCSS: true, + minifyJS: true, + removeComments: true, + useShortDoctype: true, + html5: true + }); + + writeFileSync(htmlPath, minifiedHTMLContent, 'utf8'); + console.log('Wrote minified HTML to', htmlPath, minifiedHTMLContent.length); +}); + diff --git a/about/community/index.md b/docs/about/community/index.md similarity index 100% rename from about/community/index.md rename to docs/about/community/index.md diff --git a/about/contribute/index.md b/docs/about/contribute/index.md similarity index 100% rename from about/contribute/index.md rename to docs/about/contribute/index.md diff --git a/about/highlights/beyond-e2e.md b/docs/about/highlights/beyond-e2e.md similarity index 100% rename from about/highlights/beyond-e2e.md rename to docs/about/highlights/beyond-e2e.md diff --git a/about/highlights/developer-experience.md b/docs/about/highlights/developer-experience.md similarity index 100% rename from about/highlights/developer-experience.md rename to docs/about/highlights/developer-experience.md diff --git a/about/highlights/index.md b/docs/about/highlights/index.md similarity index 100% rename from about/highlights/index.md rename to docs/about/highlights/index.md diff --git a/about/highlights/types-of-testing.md b/docs/about/highlights/types-of-testing.md similarity index 100% rename from about/highlights/types-of-testing.md rename to docs/about/highlights/types-of-testing.md diff --git a/about/index.md b/docs/about/index.md similarity index 100% rename from about/index.md rename to docs/about/index.md diff --git a/api/alerts/index.md b/docs/api/alerts/index.md similarity index 100% rename from api/alerts/index.md rename to docs/api/alerts/index.md diff --git a/api/appium/index.md b/docs/api/appium/index.md similarity index 100% rename from api/appium/index.md rename to docs/api/appium/index.md diff --git a/api/assert/index.md b/docs/api/assert/index.md similarity index 100% rename from api/assert/index.md rename to docs/api/assert/index.md diff --git a/api/assertions.md b/docs/api/assertions.md similarity index 100% rename from api/assertions.md rename to docs/api/assertions.md diff --git a/api/chrome/index.md b/docs/api/chrome/index.md similarity index 100% rename from api/chrome/index.md rename to docs/api/chrome/index.md diff --git a/api/commands.md b/docs/api/commands.md similarity index 100% rename from api/commands.md rename to docs/api/commands.md diff --git a/api/commands/index.md b/docs/api/commands/index.md similarity index 100% rename from api/commands/index.md rename to docs/api/commands/index.md diff --git a/api/cookies/index.md b/docs/api/cookies/index.md similarity index 100% rename from api/cookies/index.md rename to docs/api/cookies/index.md diff --git a/api/document/index.md b/docs/api/document/index.md similarity index 100% rename from api/document/index.md rename to docs/api/document/index.md diff --git a/api/element.md b/docs/api/element.md similarity index 100% rename from api/element.md rename to docs/api/element.md diff --git a/api/element/index.md b/docs/api/element/index.md similarity index 100% rename from api/element/index.md rename to docs/api/element/index.md diff --git a/api/ensure.md b/docs/api/ensure.md similarity index 100% rename from api/ensure.md rename to docs/api/ensure.md diff --git a/api/ensure/index.md b/docs/api/ensure/index.md similarity index 100% rename from api/ensure/index.md rename to docs/api/ensure/index.md diff --git a/api/expect.md b/docs/api/expect.md similarity index 100% rename from api/expect.md rename to docs/api/expect.md diff --git a/api/expect/_cookie.md b/docs/api/expect/_cookie.md similarity index 100% rename from api/expect/_cookie.md rename to docs/api/expect/_cookie.md diff --git a/api/expect/_element.md b/docs/api/expect/_element.md similarity index 100% rename from api/expect/_element.md rename to docs/api/expect/_element.md diff --git a/api/expect/_elements.md b/docs/api/expect/_elements.md similarity index 100% rename from api/expect/_elements.md rename to docs/api/expect/_elements.md diff --git a/api/expect/_title.md b/docs/api/expect/_title.md similarity index 100% rename from api/expect/_title.md rename to docs/api/expect/_title.md diff --git a/api/expect/_url.md b/docs/api/expect/_url.md similarity index 100% rename from api/expect/_url.md rename to docs/api/expect/_url.md diff --git a/api/expect/element/index.md b/docs/api/expect/element/index.md similarity index 100% rename from api/expect/element/index.md rename to docs/api/expect/element/index.md diff --git a/api/expect/elements/index.md b/docs/api/expect/elements/index.md similarity index 100% rename from api/expect/elements/index.md rename to docs/api/expect/elements/index.md diff --git a/api/expect/index.md b/docs/api/expect/index.md similarity index 100% rename from api/expect/index.md rename to docs/api/expect/index.md diff --git a/api/firefox/index.md b/docs/api/firefox/index.md similarity index 100% rename from api/firefox/index.md rename to docs/api/firefox/index.md diff --git a/api/index.md b/docs/api/index.md similarity index 100% rename from api/index.md rename to docs/api/index.md diff --git a/api/method/clearValue.md b/docs/api/method/clearValue.md similarity index 100% rename from api/method/clearValue.md rename to docs/api/method/clearValue.md diff --git a/api/method/click.md b/docs/api/method/click.md similarity index 100% rename from api/method/click.md rename to docs/api/method/click.md diff --git a/api/method/end.md b/docs/api/method/end.md similarity index 100% rename from api/method/end.md rename to docs/api/method/end.md diff --git a/api/method/executeAsync.md b/docs/api/method/executeAsync.md similarity index 100% rename from api/method/executeAsync.md rename to docs/api/method/executeAsync.md diff --git a/api/page.md b/docs/api/page.md similarity index 100% rename from api/page.md rename to docs/api/page.md diff --git a/api/pageobject/index.md b/docs/api/pageobject/index.md similarity index 100% rename from api/pageobject/index.md rename to docs/api/pageobject/index.md diff --git a/api/programmatic.md b/docs/api/programmatic.md similarity index 100% rename from api/programmatic.md rename to docs/api/programmatic.md diff --git a/api/programmatic/index.md b/docs/api/programmatic/index.md similarity index 100% rename from api/programmatic/index.md rename to docs/api/programmatic/index.md diff --git a/api/useractions.md b/docs/api/useractions.md similarity index 100% rename from api/useractions.md rename to docs/api/useractions.md diff --git a/api/useractions/index.md b/docs/api/useractions/index.md similarity index 100% rename from api/useractions/index.md rename to docs/api/useractions/index.md diff --git a/api/window/index.md b/docs/api/window/index.md similarity index 100% rename from api/window/index.md rename to docs/api/window/index.md diff --git a/guide/browser-drivers/chromedriver.md b/docs/guide/browser-drivers/chromedriver.md similarity index 100% rename from guide/browser-drivers/chromedriver.md rename to docs/guide/browser-drivers/chromedriver.md diff --git a/guide/browser-drivers/edgedriver.md b/docs/guide/browser-drivers/edgedriver.md similarity index 100% rename from guide/browser-drivers/edgedriver.md rename to docs/guide/browser-drivers/edgedriver.md diff --git a/guide/browser-drivers/gecko-driver-firefox.md b/docs/guide/browser-drivers/gecko-driver-firefox.md similarity index 100% rename from guide/browser-drivers/gecko-driver-firefox.md rename to docs/guide/browser-drivers/gecko-driver-firefox.md diff --git a/guide/browser-drivers/geckodriver.md b/docs/guide/browser-drivers/geckodriver.md similarity index 100% rename from guide/browser-drivers/geckodriver.md rename to docs/guide/browser-drivers/geckodriver.md diff --git a/guide/browser-drivers/safaridriver.md b/docs/guide/browser-drivers/safaridriver.md similarity index 100% rename from guide/browser-drivers/safaridriver.md rename to docs/guide/browser-drivers/safaridriver.md diff --git a/guide/ci-integrations/run-nightwatch-on-azure-pipelines.md b/docs/guide/ci-integrations/run-nightwatch-on-azure-pipelines.md similarity index 100% rename from guide/ci-integrations/run-nightwatch-on-azure-pipelines.md rename to docs/guide/ci-integrations/run-nightwatch-on-azure-pipelines.md diff --git a/guide/ci-integrations/run-nightwatch-on-bamboo.md b/docs/guide/ci-integrations/run-nightwatch-on-bamboo.md similarity index 100% rename from guide/ci-integrations/run-nightwatch-on-bamboo.md rename to docs/guide/ci-integrations/run-nightwatch-on-bamboo.md diff --git a/guide/ci-integrations/run-nightwatch-on-circleci.md b/docs/guide/ci-integrations/run-nightwatch-on-circleci.md similarity index 100% rename from guide/ci-integrations/run-nightwatch-on-circleci.md rename to docs/guide/ci-integrations/run-nightwatch-on-circleci.md diff --git a/guide/ci-integrations/run-nightwatch-on-github-actions.md b/docs/guide/ci-integrations/run-nightwatch-on-github-actions.md similarity index 100% rename from guide/ci-integrations/run-nightwatch-on-github-actions.md rename to docs/guide/ci-integrations/run-nightwatch-on-github-actions.md diff --git a/guide/ci-integrations/run-nightwatch-on-gitlab.md b/docs/guide/ci-integrations/run-nightwatch-on-gitlab.md similarity index 100% rename from guide/ci-integrations/run-nightwatch-on-gitlab.md rename to docs/guide/ci-integrations/run-nightwatch-on-gitlab.md diff --git a/guide/ci-integrations/run-nightwatch-on-jenkins.md b/docs/guide/ci-integrations/run-nightwatch-on-jenkins.md similarity index 100% rename from guide/ci-integrations/run-nightwatch-on-jenkins.md rename to docs/guide/ci-integrations/run-nightwatch-on-jenkins.md diff --git a/guide/comparison-with-leading-frameworks.md b/docs/guide/comparison-with-leading-frameworks.md similarity index 100% rename from guide/comparison-with-leading-frameworks.md rename to docs/guide/comparison-with-leading-frameworks.md diff --git a/guide/component-testing/debugging.md b/docs/guide/component-testing/debugging.md similarity index 100% rename from guide/component-testing/debugging.md rename to docs/guide/component-testing/debugging.md diff --git a/guide/component-testing/introduction.md b/docs/guide/component-testing/introduction.md similarity index 100% rename from guide/component-testing/introduction.md rename to docs/guide/component-testing/introduction.md diff --git a/guide/component-testing/storybook-component-testing.md b/docs/guide/component-testing/storybook-component-testing.md similarity index 100% rename from guide/component-testing/storybook-component-testing.md rename to docs/guide/component-testing/storybook-component-testing.md diff --git a/guide/component-testing/testing-angular-components.md b/docs/guide/component-testing/testing-angular-components.md similarity index 100% rename from guide/component-testing/testing-angular-components.md rename to docs/guide/component-testing/testing-angular-components.md diff --git a/guide/component-testing/testing-react-components.md b/docs/guide/component-testing/testing-react-components.md similarity index 100% rename from guide/component-testing/testing-react-components.md rename to docs/guide/component-testing/testing-react-components.md diff --git a/guide/component-testing/testing-vue-components.md b/docs/guide/component-testing/testing-vue-components.md similarity index 100% rename from guide/component-testing/testing-vue-components.md rename to docs/guide/component-testing/testing-vue-components.md diff --git a/guide/component-testing/vite-plugin.md b/docs/guide/component-testing/vite-plugin.md similarity index 100% rename from guide/component-testing/vite-plugin.md rename to docs/guide/component-testing/vite-plugin.md diff --git a/guide/component-testing/write-jsx-react-tests.md b/docs/guide/component-testing/write-jsx-react-tests.md similarity index 100% rename from guide/component-testing/write-jsx-react-tests.md rename to docs/guide/component-testing/write-jsx-react-tests.md diff --git a/guide/concepts/component-testing.md b/docs/guide/concepts/component-testing.md similarity index 100% rename from guide/concepts/component-testing.md rename to docs/guide/concepts/component-testing.md diff --git a/guide/concepts/introduction-to-selenium-and-webdriver.md b/docs/guide/concepts/introduction-to-selenium-and-webdriver.md similarity index 100% rename from guide/concepts/introduction-to-selenium-and-webdriver.md rename to docs/guide/concepts/introduction-to-selenium-and-webdriver.md diff --git a/guide/concepts/page-object-model.md b/docs/guide/concepts/page-object-model.md similarity index 94% rename from guide/concepts/page-object-model.md rename to docs/guide/concepts/page-object-model.md index bfd45b4b..52b255c7 100644 --- a/guide/concepts/page-object-model.md +++ b/docs/guide/concepts/page-object-model.md @@ -89,9 +89,9 @@ Nightwatch will call the command on the context of the page or section. Client c From Nightwatch 2 it is also possible to export the page commands as an ES6 class. ### Recommended content -- [Define page elements](https://nightwatchjs.org/guide/using-page-objects/defining-elements.html) -- [Define sections](https://nightwatchjs.org/guide/using-page-objects/defining-sections.html) -- [Add page-specific commands](https://nightwatchjs.org/guide/using-page-objects/writing-page-specific-commands.html) +- [Define page elements](/guide/using-page-objects/defining-elements.html) +- [Define sections](/guide/using-page-objects/defining-sections.html) +- [Add page-specific commands](/guide/using-page-objects/writing-page-specific-commands.html)