Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@
}
},
"rules": {
"quotes": [
"error",
"single",
{
"allowTemplateLiterals": true
}
],
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off"
},
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/create-spectacle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: create-spectacle

on:
push:
branches:
- main
paths:
- "packages/create-spectacle/**"
pull_request:
branches:
- main
paths:
- "packages/create-spectacle/**"

jobs:
build:
name: Create, build, and install
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
create-type: ['jsx', 'tsx', 'onepage']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

# Wireit cache
- uses: google/wireit@setup-github-actions-caching/v1

- uses: pnpm/action-setup@v2.2.2
with:
version: 7

- name: Get pnpm store directory
id: pnpm-cache
run: echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('./pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- name: Build create-spectacle
run: pnpm run --filter ./packages/create-spectacle build

# Create, build, isntall a full example.
# Then, start a background dev server.
- name: Create example - ${{ matrix.create-type }}
working-directory: ./packages/create-spectacle
run: |
pnpm run examples:${{ matrix.create-type }}:create && \
pnpm run examples:${{ matrix.create-type }}:install && \
pnpm run examples:${{ matrix.create-type }}:build && \
pnpm run examples:${{ matrix.create-type }}:start &

# Wait until the dev server is full up and running and then test.
- name: Test example - ${{ matrix.create-type }}
working-directory: ./packages/create-spectacle
run: |
pnpm exec wait-on http-get://localhost:3000 && \
pnpm run examples:test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ dist
lib
es
bin
.puppeteer
.examples

# Pack-ing artifacts
packages/**/package
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ build
.nova
.vscode
.wireit
.examples
.changeset/*.md

# Allow us to manually format this.
examples/md/slides.md
examples/one-page/index.html
51 changes: 51 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,57 @@ $ yarn clean:cache:wireit # wireit task cache
$ yarn clean:cache:modules # caches in node_modules (prettier, etc.)
```

### Checking `create-spectacle`

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.

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.

```sh
# Option 1 -- Do nothing! If you have the Mac Chrome app, you can skip this step!
# Option 2 -- Install chromium
# Option 2.a -- Normal binary
$ pnpm puppeteer:install
# Option 2.b -- If you are on an M1/2 Mac, do this instead:
$ PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM=true pnpm puppeteer:install
```

After that, you'll want to either build or watch the `create-spectacle` files:

```sh
$ pnpm run --filter ./packages/create-spectacle build
$ pnpm run --filter ./packages/create-spectacle build --watch
```

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:

```sh
# JavaScript
$ pnpm run --filter ./packages/create-spectacle examples:jsx:clean && \
pnpm run --filter ./packages/create-spectacle examples:jsx:create && \
pnpm run --filter ./packages/create-spectacle examples:jsx:install && \
pnpm run --filter ./packages/create-spectacle examples:jsx:build && \
pnpm run --filter ./packages/create-spectacle examples:jsx:start

# TypeScript
$ pnpm run --filter ./packages/create-spectacle examples:tsx:clean && \
pnpm run --filter ./packages/create-spectacle examples:tsx:create && \
pnpm run --filter ./packages/create-spectacle examples:tsx:install && \
pnpm run --filter ./packages/create-spectacle examples:tsx:build && \
pnpm run --filter ./packages/create-spectacle examples:tsx:start

# One Page (HTML-only, no build step)
$ pnpm run --filter ./packages/create-spectacle examples:onepage:clean && \
pnpm run --filter ./packages/create-spectacle examples:onepage:create && \
pnpm run --filter ./packages/create-spectacle examples:onepage:start
```

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:

```sh
$ pnpm run --filter ./packages/create-spectacle examples:test
```

### Before submitting a PR

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:
Expand Down
7 changes: 5 additions & 2 deletions examples/js/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><%= htmlWebpackPlugin.options.title %></title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&display=swap" rel="stylesheet">
<link
href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&display=swap"
rel="stylesheet"
/>
</head>
<body>
<div id="root"></div>
Expand Down
8 changes: 4 additions & 4 deletions examples/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@
]
},
"prettier": {
"command": "nps prettier:pkg",
"command": "nps prettier:pkg -- -- \"*\"",
"files": [
"../../.prettierignore",
"../../.prettierrc",
"*.{js,jsx,ts,tsx}"
"*.{js,html}"
],
"output": [],
"packageLocks": [
"pnpm-lock.yaml"
]
},
"prettier:fix": {
"command": "pnpm run prettier || nps prettier:pkg:fix",
"command": "pnpm run prettier || nps prettier:pkg:fix -- -- \"*\"",
"files": [
"../../.prettierignore",
"../../.prettierrc",
"*.{js,jsx,ts,tsx}"
"*.{js,html}"
],
"output": [],
"packageLocks": [
Expand Down
7 changes: 5 additions & 2 deletions examples/md/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><%= htmlWebpackPlugin.options.title %></title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&display=swap" rel="stylesheet">
<link
href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&display=swap"
rel="stylesheet"
/>
</head>
<body>
<div id="root"></div>
Expand Down
8 changes: 4 additions & 4 deletions examples/md/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@
]
},
"prettier": {
"command": "nps prettier:pkg",
"command": "nps prettier:pkg -- -- \"*\"",
"files": [
"../../.prettierignore",
"../../.prettierrc",
"*.{js,jsx,ts,tsx}"
"*.{js,html}"
],
"output": [],
"packageLocks": [
"pnpm-lock.yaml"
]
},
"prettier:fix": {
"command": "pnpm run prettier || nps prettier:pkg:fix",
"command": "pnpm run prettier || nps prettier:pkg:fix -- -- \"*\"",
"files": [
"../../.prettierignore",
"../../.prettierrc",
"*.{js,jsx,ts,tsx}"
"*.{js,html}"
],
"output": [],
"packageLocks": [
Expand Down
6 changes: 4 additions & 2 deletions examples/one-page/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@
]
},
"prettier": {
"command": "nps prettier:pkg",
"command": "nps prettier:pkg -- -- \"*\" scripts",
"files": [
"../../.prettierignore",
"../../.prettierrc",
"*.html",
"scripts"
],
"output": [],
Expand All @@ -64,10 +65,11 @@
]
},
"prettier:fix": {
"command": "pnpm run prettier || nps prettier:pkg:fix",
"command": "pnpm run prettier || nps prettier:pkg:fix -- -- \"*\" scripts",
"files": [
"../../.prettierignore",
"../../.prettierrc",
"*.html",
"scripts"
],
"output": [],
Expand Down
7 changes: 5 additions & 2 deletions examples/typescript/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><%= htmlWebpackPlugin.options.title %></title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&display=swap" rel="stylesheet">
<link
href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&display=swap"
rel="stylesheet"
/>
</head>
<body>
<div id="root"></div>
Expand Down
8 changes: 4 additions & 4 deletions examples/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,23 @@
]
},
"prettier": {
"command": "nps prettier:pkg",
"command": "nps prettier:pkg -- -- \"*\"",
"files": [
"../../.prettierignore",
"../../.prettierrc",
"*.{js,jsx,ts,tsx}"
"*.{js,jsx,ts,tsx,html}"
],
"output": [],
"packageLocks": [
"pnpm-lock.yaml"
]
},
"prettier:fix": {
"command": "pnpm run prettier || nps prettier:pkg:fix",
"command": "pnpm run prettier || nps prettier:pkg:fix -- -- \"*\"",
"files": [
"../../.prettierignore",
"../../.prettierrc",
"*.{js,jsx,ts,tsx}"
"*.{js,jsx,ts,tsx,html}"
],
"output": [],
"packageLocks": [
Expand Down
17 changes: 9 additions & 8 deletions package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@ module.exports = {
// - Webpack
webpack: 'webpack',

// Test
jest: 'jest',

// Quality.
// - Format
'prettier:base':
'prettier --list-different "./**/*.{js,jsx,json,ts,tsx,css,md}"',
'prettier:base:fix':
'prettier --write "./**/*.{js,jsx,json,ts,tsx,css,md}"',
'prettier:base': 'prettier --list-different',
'prettier:base:fix': 'prettier --write',
'prettier:pkg':
'nps "prettier:base --config ../../.prettierrc --ignore-path ../../.prettierignore"',
'nps prettier:base -- -- --config ../../.prettierrc --ignore-path ../../.prettierignore',
'prettier:pkg:fix':
'nps "prettier:base:fix --config ../../.prettierrc --ignore-path ../../.prettierignore"',
'nps prettier:base:fix -- -- --config ../../.prettierrc --ignore-path ../../.prettierignore',

// - Lint
'lint:base': 'eslint --cache --color',
'lint:pkg': 'nps "lint:base src"',
'lint:pkg:fix': 'nps "lint:base --fix src"'
'lint:pkg': 'nps lint:base -- -- src',
'lint:pkg:fix': 'nps lint:base -- -- --fix src'
}
};
Loading