Skip to content

Commit

Permalink
Initial vitepress migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
reynoldsalec committed Feb 2, 2024
1 parent fccb1b7 commit 06c4c45
Show file tree
Hide file tree
Showing 26 changed files with 1,544 additions and 3,439 deletions.
5 changes: 3 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.temp
.cache
temp
cache
dist
_site
!.vitepress
4 changes: 2 additions & 2 deletions .github/workflows/pr-docs-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:

jobs:
unit-tests:
docs-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -26,6 +26,6 @@ jobs:

# Run tests
- name: Run linter
run: npm run docs:lint
run: npm run lint
- name: Test build
run: npm run docs:build
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ dist
.nyc_output
coverage/

# Vuepress
# docs
.temp
.cache
_site
docs/.vuepress/.cache
docs/.vuepress/.temp
docs/.vuepress/distyarn.lock
dist
cache
temp
config.*.timestamp-*-*.*

# YARN
yarn.lock
9 changes: 9 additions & 0 deletions docs/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
"max-len": ["error", {
"code": 12000,
"ignoreComments": true
}],
"require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": false,
"MethodDefinition": false,
"ClassDeclaration": false,
"ArrowFunctionExpression": false,
"FunctionExpression": false
}
}]
}
}
56 changes: 56 additions & 0 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {createRequire} from 'module';

import {defineConfig} from '@lando/vitepress-theme-default-plus/config';

const require = createRequire(import.meta.url);

const {name, version} = require('../../package.json');
const landoPlugin = name.replace('@lando/', '');

export default defineConfig({
title: 'Lando Varnish Plugin',
description: 'The offical Lando plugin for Varnish.',
landoDocs: 3,
landoPlugin,
version,
head: [
['meta', {name: 'viewport', content: 'width=device-width, initial-scale=1'}],
['link', {rel: 'icon', href: '/varnish/favicon.ico', size: 'any'}],
['link', {rel: 'icon', href: '/varnish/favicon.svg', type: 'image/svg+xml'}],
],
themeConfig: {
sidebar: sidebar(),
},
});

function sidebar() {
return [
{
text: 'Introduction',
collapsed: false,
items: [
{text: 'Overview', link: '/'},
{text: 'Installation', link: '/install'},
{text: 'Usage', link: '/config'},
],
},
{
text: 'Contribution',
collapsed: false,
items: [
{text: 'Development', link: '/development'},
{text: 'Team', link: '/team'},
],
},
{
text: 'Help & Support',
collapsed: false,
items: [
{text: 'GitHub', link: 'https://github.com/lando/varnish/issues/new/choose'},
{text: 'Slack', link: 'https://www.launchpass.com/devwithlando'},
{text: 'Contact Us', link: '/support'},
],
},
{text: 'Examples', link: 'https://github.com/lando/varnish/tree/main/examples'},
];
};
3 changes: 3 additions & 0 deletions docs/.vitepress/theme/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import VPLTheme from '@lando/vitepress-theme-default-plus';

export default VPLTheme;
40 changes: 0 additions & 40 deletions docs/.vuepress/config.js

This file was deleted.

6 changes: 3 additions & 3 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ description: Learn how to configure the Lando Varnish service.

# Configuration

Here are the configuration options, set to the default values, for this service. If you are unsure about where this goes or what this means, we *highly recommend* scanning the [services documentation](https://docs.lando.dev/config/services.html) to get a good handle on how the magicks work.
Here are the configuration options, set to the default values, for this service. If you are unsure about where this goes or what this means, we *highly recommend* scanning the [services documentation](https://docs.lando.dev/core/v3/lando-service.html) to get a good handle on how the magicks work.

Also note that options, in addition to the [build steps](https://docs.lando.dev/config/services.html#build-steps) and [overrides](https://docs.lando.dev/config/services.html#overrides) that are available to every service, are shown below:
Also note that options, in addition to the [build steps](https://docs.lando.dev/core/v3/lando-service.html#build-steps) and [overrides](https://docs.lando.dev/core/v3/lando-service.html#overrides) that are available to every service, are shown below:

```yaml
services:
Expand Down Expand Up @@ -83,7 +83,7 @@ services:

There are also [several various envvars](https://github.com/wodby/varnish#environment-variables) exposed by the underlying image we use that you can set to further customize how your Varnish works. **These are not officially supported** so we *highly recommend* you do not alter them unless you know what you are doing. Even then, YMMV.

That said, you will need to use a [service override](https://docs.lando.dev/config/services.html#overrides) to take advantage of them as shown below:
That said, you will need to use a [service override](https://docs.lando.dev/core/v3/lando-service.html#overrides) to take advantage of them as shown below:

```yaml
myservice:
Expand Down
48 changes: 20 additions & 28 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,23 @@ description: Learn how to develop and contribute to the Lando Varnish service

# Development

This guide contains information to help onboard developers to work on the [Varnish Cache](https://varnish-cache.org/intro/index.html#intro) integration, hereafter referred to as "the plugin".
This guide contains information to help onboard developers to work on the [varnish](https://varnish.microsoft.com/en-us/) integration, hereafter referred to as *the plugin*.

## Requirements

At the very least you will need to have the following installed:

* [Lando 3.5.0+](https://docs.lando.dev/basics/installation.html), preferably installed [from source](https://docs.lando.dev/basics/installation.html#from-source).
* [Lando 3.21.0+](https://docs.lando.dev/getting-started/installation.html) preferably installed [from source](https://docs.lando.dev/getting-started/installation.html#from-source).
* [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)

While not a hard requirement it's also probably a good idea to install `node` 18
* [Node 18](https://nodejs.org/dist/latest-v18.x/)

## Installation

```bash
```sh
# Clone this repo
git clone https://github.com/lando/varnish.git && cd varnish

# Install dependencies with lando
lando start

# Or install them with npm
# Install deps
npm install
```

Expand All @@ -38,7 +33,7 @@ Note that each one of these examples contains the following section in its Lando

```yaml
plugins:
"@lando/varnish": ./../../
"@lando/varnish": ../..
```
This tells Lando that _this_ app should use the source version of the `@lando/varnish` plugin you cloned down in the installation. This is useful because it allows you to isolate development within this repo without interferring with any other apps using the stable and global version of the plugin.
Expand All @@ -62,21 +57,24 @@ npm run docs:dev
# build docs locally
npm run docs:build
# preview built docs locally
npm run docs:build
```

If you are more interested in the internals of the docs they use [VuePress2](https://v2.vuepress.vuejs.org/) and our [Special theme](https://vuepress-theme-default-plus.lando.dev).
If you are more interested in the internals of the docs they use [VitePress](https://vitepress.dev/) and our [SPECIAL THEME](https://vitepress-theme-default-plus.lando.dev).

## Testing

It's best to familiarize yourself with how Lando [does testing](https://docs.lando.dev/contrib/contrib-testing.html) in general before proceeding.
It's best to familiarize yourself with how Lando [does testing](https://docs.lando.dev/contrib/coder.html) in general before proceeding.

### Unit Tests

Generally, unit testable code should be placed in `lib` and then the associated test in `tests` in the form `FILE-BEING-TESTED.spec.js`. Here is an example:
Generally, unit testable code should be placed in `utils` and then the associated test in `tests` in the form `FILE-BEING-TESTED.spec.js`. Here is an example:

```bash
./
|-- lib
|-- utils
|-- stuff.js
|-- test
|-- stuff.spec.js
Expand Down Expand Up @@ -113,21 +111,18 @@ Destroy tests
lando destroy -y
```

Note that the headers here are important and are defined in our `npm run generate:tests` script. The _Start up tests_ header specifies things that should run before the main series of tests. _Verification commands_ is the main body of tests and is required. _Destroy tests_ specifies any needed clean up commands to run.
Note that the headers here are important. The _Start up tests_ header specifies things that should run before the main series of tests. _Verification commands_ is the main body of tests and is required. _Destroy tests_ specifies any needed clean up commands to run.

If you check out the various READMEs in our [examples](https://github.com/lando/varnish/tree/main/examples) you will notice that they are all Leia tests.

Before running all or some of the tests you will need to generate them.

```bash
# Generate tests
npm run generate:tests
# Run ALL the tests, this will likely take a long time
npm run test:leia
# Run the tests for a single example
npm run leia examples/mariadb-10.2/README.md -c 'Destroy tests'
npx leia examples/mariadb-10.2/README.md -c 'Destroy tests'
```

If you've created new testable examples then you will also need to let GitHub Actions know so they can run on pull requests.
Expand All @@ -140,15 +135,12 @@ To add the new tests to the workflow just modify `jobs.leia-tests.strategy.matri
jobs:
leia-tests:
strategy:
fail-fast: false
matrix:
leia-tests:
# This should be the filename, without .leia.js extension in the test directory
# NOTE that you will need to run npm run generate:tests to see these
- test: platform-sh-maria-db-10-1-example
# This should be the directory that the test was generated from
source: examples/mariadb-10.2
- test: platform-sh-maria-db-10-2-example
source: examples/mariadb-10.2
leia-test:
- examples/2.1
- examples/2.2
```

Now open a pull request and the new tests should run!
Expand All @@ -170,4 +162,4 @@ npm install @lando/varnish@edge

## Contribution

If you want to contribute code then just follow [this flow](https://guides.github.com/introduction/flow/).
If you want to contribute code then just follow [this flow](https://docs.github.com/en/get-started/using-github/github-flow).
47 changes: 3 additions & 44 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ next: ./config.html

[Varnish Cache](https://varnish-cache.org/intro/index.html#intro) is a web application accelerator also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents.

You can easily add it to your Lando app by adding an entry to the [services](https://docs.lando.dev/config/services.html) top-level config in your [Landofile](https://docs.lando.dev/config/lando.html).
You can easily add it to your Lando app by adding an entry to the [services](https://docs.lando.dev/core/v3/lando-service.html) top-level config in your [Landofile](https://docs.lando.dev/core/v3).

```yaml
services:
Expand All @@ -25,50 +25,9 @@ services:
* [6](https://hub.docker.com/r/wodby/varnish)
* **[4.1](https://hub.docker.com/r/wodby/varnish)** **(default)**
* [4](https://hub.docker.com/r/wodby/varnish)
* [custom](https://docs.lando.dev/config/services.html#advanced)
* [custom](https://docs.lando.dev/core/v3/lando-service.html#overrides)
## Patch versions
This service does not support patch versions but if you **really** need something like that, you could consider using either a [custom compose service](https://docs.lando.dev/compose) or a service [overrides](https://docs.lando.dev/config/services.html#overrides).
This service does not support patch versions but if you **really** need something like that, you could consider using either a [custom compose service](https://docs.lando.dev/compose) or a service [overrides](https://docs.lando.dev/core/v3/lando-service.html#overrides).
## Custom Installation
This plugin is included with Lando by default. That means if you have Lando version `3.0.8` or higher then this plugin is already installed!

However if you would like to manually install the plugin, update it to the bleeding edge or install a particular version then use the below. Note that this installation method requires Lando `3.5.0+`.

:::: code-group
::: code-group-item LANDO 3.21+
```bash:no-line-numbers
lando plugin-add @lando/varnish
```
:::
::: code-group-item HYPERDRIVE
```bash:no-line-numbers
# @TODO
# @NOTE: This doesn't actaully work yet
hyperdrive install @lando/varnish
```
:::
::: code-group-item DOCKER
```bash:no-line-numbers
# Ensure you have a global plugins directory
mkdir -p ~/.lando/plugins
# Install plugin
# NOTE: Modify the "npm install @lando/varnish" line to install a particular version eg
# npm install @lando/[email protected]
docker run --rm -it -v ${HOME}/.lando/plugins:/plugins -w /tmp node:14-alpine sh -c \
"npm init -y \
&& npm install @lando/varnish --production --flat --no-default-rc --no-lockfile --link-duplicates \
&& npm install --production --cwd /tmp/node_modules/@lando/varnish \
&& mkdir -p /plugins/@lando \
&& mv --force /tmp/node_modules/@lando/varnish /plugins/@lando/varnish"
# Rebuild the plugin cache
lando --clear
```
:::
::::

You should be able to verify the plugin is installed by running `lando config --path plugins` and checking for `@lando/varnish`. This command will also show you _where_ the plugin is being loaded from.
Loading

0 comments on commit 06c4c45

Please sign in to comment.