Skip to content

Commit

Permalink
Add basic tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed Sep 24, 2023
1 parent 61ab33d commit a77ad2a
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
.DS_Store
node_modules

# Builds
dist

# Capacitor
ios
android

# Tests
coverage

# Docs
.vitepress

# Version Control
*.lock
*-lock.json

Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

A complete example of a COMMONERS application that connects to peripheral devices using Bluetooth and Serial across multiple platforms is available at our [commoners-starter-kit](https://github.com/garrettmflynn/commoners-starter-kit) repository.

## Why Commoners?
- 🖥️ 📲 Publish for web, mobile, and desktop from a single repository
- 📜 Only native web technologies (i.e. HTML, CSS, and JavaScript) required
- ⚡️ Built on Vite for lightning-fast development speeds
Read the [documentation](https://commoners.dev) to learn more.

## Getting started
- `commoners start` - Start your project in an Electron application.
Expand Down
49 changes: 49 additions & 0 deletions docs/api-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
outline: deep
---

# Runtime API Examples

This page demonstrates usage of some of the runtime APIs provided by VitePress.

The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files:

```md
<script setup>
import { useData } from 'vitepress'

const { theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>
```

<script setup>
import { useData } from 'vitepress'

const { site, theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>

## More

Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).
31 changes: 31 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
# https://vitepress.dev/reference/default-theme-home-page
layout: home

hero:
name: "Commoners"
text: "Building Solidarity across Platforms"
tagline: Write your application for web, desktop, and mobile—without the fuss.
image:
src: /logo.png
alt: Commoners
actions:
- theme: brand
text: Markdown Examples
link: /markdown-examples
- theme: alt
text: API Examples
link: /api-examples

features:
- icon: 🌐
title: Simple Cross-Platform Builds
details: Publish for web, mobile, and desktop from a single repository.
- icon: 📜
title: Web Native
details: Only native web technologies (i.e. HTML, CSS, and JavaScript) required.
- icon: ⚡️
title: Built on Vite
details: Lightning-fast development speeds based on reliable tooling.
---

Binary file added docs/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 85 additions & 0 deletions docs/markdown-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Markdown Extension Examples

This page demonstrates some of the built-in markdown extensions provided by VitePress.

## Syntax Highlighting

VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting:

**Input**

````
```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```
````

**Output**

```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```

## Custom Containers

**Input**

```md
::: info
This is an info box.
:::

::: tip
This is a tip.
:::

::: warning
This is a warning.
:::

::: danger
This is a dangerous warning.
:::

::: details
This is a details block.
:::
```

**Output**

::: info
This is an info box.
:::

::: tip
This is a tip.
:::

::: warning
This is a warning.
:::

::: danger
This is a dangerous warning.
:::

::: details
This is a details block.
:::

## More

Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown).
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
"build:library": "vite build --config ./packages/core/vite.config.ts",
"watch": "vite build --watch",
"watch:library": "vite build --watch --config ./packages/core/vite.library.config.ts",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "vitest",
"coverage": "vitest run --coverage",
"docs": "vitepress dev docs",
"docs:build": "vitepress build docs"
},
"dependencies": {
"@electron-toolkit/tsconfig": "^1.0.1",
Expand Down Expand Up @@ -48,7 +51,10 @@
"devDependencies": {
"@electron/remote": "^2.0.11",
"@types/node": "16.18.21",
"@vitest/coverage-v8": "^0.34.5",
"typescript": "^4.9.5",
"vite-plugin-static-copy": "^0.16.0"
"vite-plugin-static-copy": "^0.16.0",
"vitepress": "^1.0.0-rc.20",
"vitest": "^0.34.5"
}
}
9 changes: 9 additions & 0 deletions packages/core/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// sum.test.js
import { expect, test } from 'vitest'

function sum(a, b) {
return a + b
}
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3)
})
5 changes: 5 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="vitest" />

import { defineConfig, normalizePath } from "vite";
import { viteStaticCopy } from 'vite-plugin-static-copy'

Expand Down Expand Up @@ -26,6 +28,9 @@ const toCopy = [
]

export default defineConfig({
test: {

},
plugins: [
{
name: 'add-bin-shebang',
Expand Down

0 comments on commit a77ad2a

Please sign in to comment.