Skip to content

Commit 4bd5adf

Browse files
authored
Infra: build create-spectacle examples (#1185)
Core work: - Add create/install/build/start helpers for create-spectacle - Add CI support Work along the way: - Extract `jest` dependencies to monorepo root - Lots of wireit configuration cleanup
1 parent db9c794 commit 4bd5adf

File tree

23 files changed

+1694
-540
lines changed

23 files changed

+1694
-540
lines changed

.eslintrc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@
3636
}
3737
},
3838
"rules": {
39-
"quotes": [
40-
"error",
41-
"single",
42-
{
43-
"allowTemplateLiterals": true
44-
}
45-
],
4639
"react/jsx-uses-react": "off",
4740
"react/react-in-jsx-scope": "off"
4841
},
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: create-spectacle
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "packages/create-spectacle/**"
9+
pull_request:
10+
branches:
11+
- main
12+
paths:
13+
- "packages/create-spectacle/**"
14+
15+
jobs:
16+
build:
17+
name: Create, build, and install
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
node-version: [18.x]
22+
create-type: ['jsx', 'tsx', 'onepage']
23+
steps:
24+
- uses: actions/checkout@v2
25+
- uses: actions/setup-node@v2
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
29+
# Wireit cache
30+
- uses: google/wireit@setup-github-actions-caching/v1
31+
32+
- uses: pnpm/[email protected]
33+
with:
34+
version: 7
35+
36+
- name: Get pnpm store directory
37+
id: pnpm-cache
38+
run: echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
39+
40+
- name: Setup pnpm cache
41+
uses: actions/cache@v3
42+
with:
43+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
44+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('./pnpm-lock.yaml') }}
45+
restore-keys: |
46+
${{ runner.os }}-pnpm-store-
47+
48+
- name: Install dependencies
49+
run: pnpm install
50+
51+
- name: Build create-spectacle
52+
run: pnpm run --filter ./packages/create-spectacle build
53+
54+
# Create, build, isntall a full example.
55+
# Then, start a background dev server.
56+
- name: Create example - ${{ matrix.create-type }}
57+
working-directory: ./packages/create-spectacle
58+
run: |
59+
pnpm run examples:${{ matrix.create-type }}:create && \
60+
pnpm run examples:${{ matrix.create-type }}:install && \
61+
pnpm run examples:${{ matrix.create-type }}:build && \
62+
pnpm run examples:${{ matrix.create-type }}:start &
63+
64+
# Wait until the dev server is full up and running and then test.
65+
- name: Test example - ${{ matrix.create-type }}
66+
working-directory: ./packages/create-spectacle
67+
run: |
68+
pnpm exec wait-on http-get://localhost:3000 && \
69+
pnpm run examples:test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ dist
3838
lib
3939
es
4040
bin
41+
.puppeteer
42+
.examples
4143

4244
# Pack-ing artifacts
4345
packages/**/package

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ build
1111
.nova
1212
.vscode
1313
.wireit
14+
.examples
15+
.changeset/*.md
1416

1517
# Allow us to manually format this.
1618
examples/md/slides.md
19+
examples/one-page/index.html

CONTRIBUTING.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,57 @@ $ yarn clean:cache:wireit # wireit task cache
121121
$ yarn clean:cache:modules # caches in node_modules (prettier, etc.)
122122
```
123123

124+
### Checking `create-spectacle`
125+
126+
We have slower checks for the outputs created by our `create-spectacle` package that are run in CI, but you generally won't need to run unless you are developing that package.
127+
128+
First, you can install Chromium to use in `puppeteer` or use a local Chrome instance. We only presently have Mac instructions and will get to Windows/Linux support when we get demand. You only need to do the following step once.
129+
130+
```sh
131+
# Option 1 -- Do nothing! If you have the Mac Chrome app, you can skip this step!
132+
# Option 2 -- Install chromium
133+
# Option 2.a -- Normal binary
134+
$ pnpm puppeteer:install
135+
# Option 2.b -- If you are on an M1/2 Mac, do this instead:
136+
$ PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM=true pnpm puppeteer:install
137+
```
138+
139+
After that, you'll want to either build or watch the `create-spectacle` files:
140+
141+
```sh
142+
$ pnpm run --filter ./packages/create-spectacle build
143+
$ pnpm run --filter ./packages/create-spectacle build --watch
144+
```
145+
146+
From there, here are sample collections of commands to create new example applications from scratch with full installation and ending with firing up a dev server:
147+
148+
```sh
149+
# JavaScript
150+
$ pnpm run --filter ./packages/create-spectacle examples:jsx:clean && \
151+
pnpm run --filter ./packages/create-spectacle examples:jsx:create && \
152+
pnpm run --filter ./packages/create-spectacle examples:jsx:install && \
153+
pnpm run --filter ./packages/create-spectacle examples:jsx:build && \
154+
pnpm run --filter ./packages/create-spectacle examples:jsx:start
155+
156+
# TypeScript
157+
$ pnpm run --filter ./packages/create-spectacle examples:tsx:clean && \
158+
pnpm run --filter ./packages/create-spectacle examples:tsx:create && \
159+
pnpm run --filter ./packages/create-spectacle examples:tsx:install && \
160+
pnpm run --filter ./packages/create-spectacle examples:tsx:build && \
161+
pnpm run --filter ./packages/create-spectacle examples:tsx:start
162+
163+
# One Page (HTML-only, no build step)
164+
$ pnpm run --filter ./packages/create-spectacle examples:onepage:clean && \
165+
pnpm run --filter ./packages/create-spectacle examples:onepage:create && \
166+
pnpm run --filter ./packages/create-spectacle examples:onepage:start
167+
```
168+
169+
The dev server in each of these examples runs on port 3000 by default, and you can run a simple Puppeteer test against that port with the following:
170+
171+
```sh
172+
$ pnpm run --filter ./packages/create-spectacle examples:test
173+
```
174+
124175
### Before submitting a PR
125176

126177
Thanks for taking the time to help us make Spectacle even better! Before you go ahead and submit a PR, make sure that you have done the following:

examples/js/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta charset="utf-8">
4+
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title><%= htmlWebpackPlugin.options.title %></title>
7-
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&display=swap" rel="stylesheet">
7+
<link
8+
href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&display=swap"
9+
rel="stylesheet"
10+
/>
811
</head>
912
<body>
1013
<div id="root"></div>

examples/js/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,23 @@
5656
]
5757
},
5858
"prettier": {
59-
"command": "nps prettier:pkg",
59+
"command": "nps prettier:pkg -- -- \"*\"",
6060
"files": [
6161
"../../.prettierignore",
6262
"../../.prettierrc",
63-
"*.{js,jsx,ts,tsx}"
63+
"*.{js,html}"
6464
],
6565
"output": [],
6666
"packageLocks": [
6767
"pnpm-lock.yaml"
6868
]
6969
},
7070
"prettier:fix": {
71-
"command": "pnpm run prettier || nps prettier:pkg:fix",
71+
"command": "pnpm run prettier || nps prettier:pkg:fix -- -- \"*\"",
7272
"files": [
7373
"../../.prettierignore",
7474
"../../.prettierrc",
75-
"*.{js,jsx,ts,tsx}"
75+
"*.{js,html}"
7676
],
7777
"output": [],
7878
"packageLocks": [

examples/md/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta charset="utf-8">
4+
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title><%= htmlWebpackPlugin.options.title %></title>
7-
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&display=swap" rel="stylesheet">
7+
<link
8+
href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&display=swap"
9+
rel="stylesheet"
10+
/>
811
</head>
912
<body>
1013
<div id="root"></div>

examples/md/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,23 @@
5656
]
5757
},
5858
"prettier": {
59-
"command": "nps prettier:pkg",
59+
"command": "nps prettier:pkg -- -- \"*\"",
6060
"files": [
6161
"../../.prettierignore",
6262
"../../.prettierrc",
63-
"*.{js,jsx,ts,tsx}"
63+
"*.{js,html}"
6464
],
6565
"output": [],
6666
"packageLocks": [
6767
"pnpm-lock.yaml"
6868
]
6969
},
7070
"prettier:fix": {
71-
"command": "pnpm run prettier || nps prettier:pkg:fix",
71+
"command": "pnpm run prettier || nps prettier:pkg:fix -- -- \"*\"",
7272
"files": [
7373
"../../.prettierignore",
7474
"../../.prettierrc",
75-
"*.{js,jsx,ts,tsx}"
75+
"*.{js,html}"
7676
],
7777
"output": [],
7878
"packageLocks": [

examples/one-page/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@
5252
]
5353
},
5454
"prettier": {
55-
"command": "nps prettier:pkg",
55+
"command": "nps prettier:pkg -- -- \"*\" scripts",
5656
"files": [
5757
"../../.prettierignore",
5858
"../../.prettierrc",
59+
"*.html",
5960
"scripts"
6061
],
6162
"output": [],
@@ -64,10 +65,11 @@
6465
]
6566
},
6667
"prettier:fix": {
67-
"command": "pnpm run prettier || nps prettier:pkg:fix",
68+
"command": "pnpm run prettier || nps prettier:pkg:fix -- -- \"*\" scripts",
6869
"files": [
6970
"../../.prettierignore",
7071
"../../.prettierrc",
72+
"*.html",
7173
"scripts"
7274
],
7375
"output": [],

0 commit comments

Comments
 (0)