[WIP] example / gatsby / themed-site (#120)

* add themed gatsby site as example and test target

* add specific example ignores to gitignore

* update api key reference

* theme needs the alpha version currently

* update and pin deps

* remove lock file, we want a fresh build to test every time

* add recipe theme for cheap way to add to ton of site pages

* add tauri as dev dep

* build gatsby as a smoke test

* cd on each step

* pass api key

* chore(package.json): update

* schedule renovate to tone down noisiness (#122)

Also, there is a running theory that Tuesday is a good day for upgrades.

* combine jobs and add step with conditional (#121)

* combine jobs and add step with conditional

* too many equals

* Update dependency fast-glob to v3.1.1 (#113)

* chore(yarn.lock): update

* chore(versions): bump tauri.js & tauri

* feat(gatsby): include tauri resources

* feat(build): tauri build works

* tauri prod and source scripts

* add build from source and artifact upload to action

* don't need to init, examples are already

* point to direct executable with matrix

* ignore WixTools from build

* config app name

* build and install source deps before build project on source

* odd things when tauri is defined in a script, remove

* set gatsby config to what is believed will be ~es5

* babel plugin is actually neeeded

* run subscripts with yarn

* lower timeout limit to 30 minutes, easy to swamp CI with this

* shorten job names

* install tauri-cli (rust)

* make API key optional (sort of hacky)

* install rust for prod for cargo command following

* artifact name cannot have / within it

* windows is running a tad slow
This commit is contained in:
Jacob Bolda 2019-12-02 08:20:20 -06:00 committed by nothingismagick
parent 5a34e3db93
commit 6eb1837181
32 changed files with 14186 additions and 2 deletions

94
.github/workflows/build-smoke-tests.yml vendored Normal file
View File

@ -0,0 +1,94 @@
name: build smoke tests
on: pull_request
jobs:
via-prod:
runs-on: ${{ matrix.platform }}
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
example: [gatsby/themed-site]
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 3
- name: install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: cargo install tauri-cli
- name: install via yarn
run: |
cd ./examples/${{ matrix.example }}
yarn
- name: build example
env:
EXAMPLE_GATSBY_AIRTABLE_API_KEY: ${{ secrets.EXAMPLE_GATSBY_AIRTABLE_API_KEY }}
run: |
cd ./examples/${{ matrix.example }}
yarn build
- name: yarn tauri build
run: |
cd ./examples/${{ matrix.example }}
yarn tauri:prod:build
via-source:
runs-on: ${{ matrix.platform }}
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
example:
- name : GatsbyThemedSite
folder: gatsby/themed-site
executable: GatsbyThemedSiteApp
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 3
- name: install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: install webkit2gtk (ubuntu only)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.0
- name: build rust
run: cargo build
env:
TAURI_DIST_DIR: ../../test/fixture/dist
TAURI_CONFIG_DIR: ../test/fixture/
- run: cargo install --path ./cli/tauri-cli --force
- name: install cli deps via yarn
run: |
cd ./cli/tauri.js
yarn
- name: install via yarn
run: |
cd ./examples/${{ matrix.example.folder }}
yarn
- name: build example
env:
EXAMPLE_GATSBY_AIRTABLE_API_KEY: ${{ secrets.EXAMPLE_GATSBY_AIRTABLE_API_KEY }}
run: |
cd ./examples/${{ matrix.example.folder }}
yarn build
- name: yarn tauri build
run: |
cd ./examples/${{ matrix.example.folder }}
yarn tauri:source:build
- uses: actions/upload-artifact@v1
if: success()
with:
name: tauri built ${{ matrix.example.name }} on ${{ matrix.platform }}
path: ./examples/${{ matrix.example.folder }}/src-tauri/target/release/${{ matrix.example.executable }}

6
.gitignore vendored
View File

@ -72,4 +72,8 @@ target
# doing this because of how our tests currently (naively) drop the tauri.conf.js in that folder
# todo: needs a proper fic
/cli/tauri.js/tauri.conf.js
/cli/tauri.js/tauri.conf.js
# example specific ignores
examples/**/.cache
examples/**/public

View File

@ -0,0 +1,13 @@
{
"plugins": ["@babel/plugin-proposal-optional-chaining"],
"presets": [
[
"babel-preset-gatsby",
{
"targets": {
"browsers": ["defaults", "not dead"]
}
}
]
]
}

View File

@ -0,0 +1,2 @@
.cache
public

View File

@ -0,0 +1,4 @@
# Gatsby Themed Site
This is a minimal config required gatsby site created using themes. The intention is to smoke test gatsby and provide an assortment of pages to test tauri response.
This _does_ use an API key to Airtable, but we have made it optional. (Although currently gatsby is rather aggressive in compiling things out of node_modules so `gatsby-config.js` has a hack to rename files so gatsby will ignore them. [insert heavy sigh here])

View File

@ -0,0 +1,155 @@
const fs = require("fs");
const path = require("path");
const addPluginsIfAPIKeySet = !process.env.EXAMPLE_GATSBY_AIRTABLE_API_KEY
? []
: [
{
resolve: `gatsby-source-airtable`,
options: {
apiKey: process.env.EXAMPLE_GATSBY_AIRTABLE_API_KEY,
tables: [
{
baseId: `appcL6Jdj7ZrhTg4q`,
tableName: `Recipes`,
tableView: `List`,
queryName: `Recipes`,
mapping: {
images: "fileNode",
ingredients: "text/markdown",
directions: "text/markdown"
},
separateMapTypes: true
}
]
}
},
{
resolve: `gatsby-theme-recipes`,
options: {
sources: ["Airtable"]
}
}
];
if (!process.env.EXAMPLE_GATSBY_AIRTABLE_API_KEY) {
try {
const template = require.resolve(
"gatsby-theme-recipes/src/templates/recipeTemplate.js"
);
const main = require.resolve("gatsby-theme-recipes/src/main/recipes.js");
fs.renameSync(
template,
template
.split(".")
.reduce((acc, cur) => (cur === "js" ? acc + ".nojs" : acc + cur), "")
);
fs.renameSync(
main,
main
.split(".")
.reduce((acc, cur) => (cur === "js" ? acc + ".nojs" : acc + cur), "")
);
} catch (e) {
// no-op
}
} else {
try {
const template = require.resolve(
"gatsby-theme-recipes/src/templates/recipeTemplate.nojs"
);
const main = require.resolve("gatsby-theme-recipes/src/main/recipes.nojs");
fs.renameSync(
template,
template
.split(".")
.reduce((acc, cur) => (cur === "nojs" ? acc + ".js" : acc + cur), "")
);
fs.renameSync(
main,
main
.split(".")
.reduce((acc, cur) => (cur === "nojs" ? acc + ".js" : acc + cur), "")
);
} catch (e) {
// no-op
}
}
module.exports = {
siteMetadata: {
siteTitle: `Jacob Bolda`,
siteDescription: `Structural Engineer with a knack for creative solutions using code and ingenuity.`,
siteAuthor: `Jacob Bolda`,
siteAuthorIdentity: `Structural Engineer`,
siteLanding: `
Focusing on the intersection of tech and Structural
Engineering. Masters degree in Structural Engineering
from the Milwaukee School of Engineering, undergrad in
Architectural Engineering with a minor in Management,
and a deep understanding of software and programming.
Marrying that experience with problem solving and
systematizing is powerful.
`,
siteContact: "https://twitter.com/jacobbolda",
contactLinks: [
{
url: "mailto:me@jacobbolda.com",
text: "me@jacobbolda.com",
icon: ["far", "envelope"]
},
{
url: "https://twitter.com/jacobbolda",
text: "@jacobbolda",
icon: ["fab", "twitter"]
},
{
url: "https://linkedin.com/in/bolda",
text: "linkedin.com/in/bolda",
icon: ["fab", "linkedin"]
},
{
url: "https://github.com/jbolda",
text: "github.com/jbolda",
icon: ["fab", "github"]
},
{
url: "https://keybase.io/jbolda",
text: "keybase.io/jbolda",
icon: ["fab", "keybase"]
},
{
url: "https://angel.co/jacobbolda",
text: "angel.co/jacobbolda",
icon: ["fab", "angellist"]
},
{
url: "http://www.jbolda.com/photo",
text: "My Photographs",
icon: ["fas", "camera"]
}
],
navLinks: [{ url: "/recipes/", text: "Our Recipes" }]
},
plugins: [
{
resolve: `gatsby-source-filesystem`,
options: {
name: `articles`,
path: `${__dirname}/src/articles/`
}
},
`gatsby-plugin-theme-ui`,
`gatsby-plugin-sharp`,
`gatsby-transformer-sharp`,
`@jbolda/gatsby-theme-homepage`,
`@jbolda/gatsby-theme-articles`,
...addPluginsIfAPIKeySet,
{
resolve: `gatsby-plugin-mdx`,
options: {}
},
`gatsby-plugin-react-helmet`,
`gatsby-plugin-netlify`
]
};

View File

@ -0,0 +1,53 @@
{
"name": "personal-themed-site",
"version": "0.0.0",
"author": "Jacob Bolda <me@jacobbolda.com>",
"license": "MIT",
"private": true,
"browserslist": {
"ie": "9"
},
"scripts": {
"build": "gatsby build",
"build:hard": "gatsby clean && gatsby build",
"develop": "gatsby develop",
"dev:hard": "gatsby clean && gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"tauri:prod": "tauri",
"tauri:source": "node ../../../cli/tauri.js/bin/tauri",
"tauri:source:init": "yarn tauri:source init --tauri-path ../../../tauri",
"tauri:prod:init": "yarn tauri:prod:init",
"tauri:source:dev": "yarn tauri:source dev",
"tauri:prod:dev": "yarn tauri:prod dev",
"tauri:source:build": "yarn tauri:source build",
"tauri:prod:build": "yarn tauri:prod build",
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@emotion/core": "10.0.22",
"@jbolda/gatsby-theme-articles": "0.0.2",
"@jbolda/gatsby-theme-homepage": "0.0.2",
"@jbolda/gatsby-theme-layout": "0.0.2",
"@mdx-js/mdx": "1.5.1",
"@mdx-js/react": "1.5.1",
"gatsby": "2.18.5",
"gatsby-image": "2.2.34",
"gatsby-plugin-mdx": "1.0.58",
"gatsby-plugin-netlify": "2.1.27",
"gatsby-plugin-react-helmet": "3.1.16",
"gatsby-plugin-sharp": "2.3.4",
"gatsby-plugin-theme-ui": "0.2.43",
"gatsby-source-airtable": "2.1.0-alpha.0",
"gatsby-source-filesystem": "2.1.39",
"gatsby-theme-recipes": "^0.0.9",
"gatsby-transformer-sharp": "2.3.6",
"react": "16.12.0",
"react-dom": "16.12.0",
"react-helmet": "5.2.1",
"theme-ui": "0.2.49"
},
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.7.4",
"tauri": "^0.1.3"
}
}

View File

@ -0,0 +1,16 @@
# Generated by Cargo
# will have compiled files and executables
/target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
tauri.js
config.json
bundle.json
WixTools

View File

@ -0,0 +1,41 @@
workspace = { }
[package]
name = "GatsbyThemedSiteApp"
version = "0.1.0"
description = "Gatsby themed site built by Tauri"
author = [ "you" ]
license = ""
repository = ""
default-run = "GatsbyThemedSiteApp"
edition = "2018"
[package.metadata.bundle]
identifier = "com.tauri.dev"
icon = [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
[dependencies]
serde_json = "1.0.41"
serde = "1.0"
serde_derive = "1.0"
tiny_http = "0.6"
phf = "0.7.24"
includedir = "0.5.0"
[dependencies.tauri]
version = "0.1.2"
features = [ "edge" ]
[features]
dev = [ "tauri/dev" ]
embedded-server = [ "tauri/embedded-server" ]
[[bin]]
name = "GatsbyThemedSiteApp"
path = "src/main.rs"

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -0,0 +1,13 @@
max_width = 100
hard_tabs = false
tab_spaces = 2
newline_style = "Auto"
use_small_heuristics = "Default"
reorder_imports = true
reorder_modules = true
remove_nested_parens = true
edition = "2018"
merge_derives = true
use_try_shorthand = false
use_field_init_shorthand = false
force_explicit_abi = true

View File

@ -0,0 +1,8 @@
#[derive(Deserialize)]
#[serde(tag = "cmd", rename_all = "camelCase")]
pub enum Cmd {
// your custom commands
// multiple arguments are allowed
// note that rename_all = "camelCase": you need to use "myCustomCommand" on JS
MyCustomCommand { argument: String },
}

View File

@ -0,0 +1,26 @@
mod cmd;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
fn main() {
tauri::AppBuilder::new()
.invoke_handler(|_webview, arg| {
use cmd::Cmd::*;
match serde_json::from_str(arg) {
Err(_) => {}
Ok(command) => {
match command {
// definitions for your custom commands from Cmd here
MyCustomCommand { argument } => {
// your command code
println!("{}", argument);
}
}
}
}
})
.build()
.run();
}

View File

@ -0,0 +1,31 @@
---
title: Hello World (example)
written: 2019-04-15
---
Hello, world! This is a demo post for `gatsby-theme-blog`.
Delete me, and get writing!
```js:title=gatsby-config.js
module.exports = {
plugins: [
"gatsby-theme-blog", // highlight-line
"gatsby-theme-notes"
]
};
```
This is another paragraph after the code block.
## This is a secondary heading
```jsx
import React from "react";
import { ThemeProvider } from "theme-ui";
import theme from "./theme";
export default props => (
<ThemeProvider theme={theme}>{props.children}</ThemeProvider>
);
```

View File

@ -0,0 +1,35 @@
const path = require('path')
const distDir = path.resolve(__dirname, './public')
module.exports = function () {
return {
build: {
distDir: distDir,
devPath: 'http://localhost:8000' // devServer URL or path to html file
},
ctx: {},
tauri: {
embeddedServer: {
active: true
},
bundle: {
active: true
},
whitelist: {
all: false
},
window: {
title: 'Tauri App'
},
security: {
csp: 'default-src data: filesystem: ws: http: https: \'unsafe-eval\' \'unsafe-inline\''
},
edge: {
active: true
},
automaticStart: {
active: true
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@ includedir = "0.5.0"
[dependencies.tauri]
version = "0.1.0"
features = [ "all-api" ]
features = [ "all-api", "edge" ]
[features]
dev = [ "tauri/dev" ]