Skip to content

Commit b2edbd3

Browse files
committed
add script for deploying examples to github pages
1 parent 09ce173 commit b2edbd3

File tree

14 files changed

+48
-33
lines changed

14 files changed

+48
-33
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
build
2+
build
3+
gh-pages

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
},
1313
"scripts": {
1414
"bootstrap": "lerna bootstrap --hoist",
15-
"start": "http-server & (cd packages/uni-virtualizer-examples; npm run build-and-watch)"
15+
"start": "http-server & (cd packages/uni-virtualizer-examples; npm run build-and-watch)",
16+
"deploy-examples": "./scripts/deploy-examples.sh"
1617
},
1718
"dependencies": {}
1819
}

packages/uni-virtualizer-examples/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"repository": "PolymerLabs/uni-virtualizer",
77
"private": true,
88
"scripts": {
9+
"build": "rollup -c",
910
"build-and-watch": "rollup -c -w"
1011
},
1112
"author": "The Polymer Authors",

packages/uni-virtualizer-examples/public/basic-lit-element/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<!doctype html>
1111
<html>
1212
<head>
13-
<script src="../../shared/boot.js"></script>
13+
<script src="../shared/boot.js"></script>
1414
<style>
1515
body {
1616
display: grid;

packages/uni-virtualizer-examples/public/basic-lit-element/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ContactList extends LitElement {
5959
}
6060

6161
async firstUpdated() {
62-
const resp = await fetch('../../shared/contacts.json');
62+
const resp = await fetch('../shared/contacts.json');
6363
this.data = await resp.json();
6464
}
6565

packages/uni-virtualizer-examples/public/basic-lit-html/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<!doctype html>
1111
<html>
1212
<head>
13-
<script src="../../shared/boot.js"></script>
13+
<script src="../shared/boot.js"></script>
1414
</head>
1515
<body>
1616
</body>

packages/uni-virtualizer-examples/public/basic-lit-html/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ const example = (contacts) => html`
1313
`;
1414

1515
(async function go() {
16-
const contacts = await(await fetch('../../shared/contacts.json')).json();
16+
const contacts = await(await fetch('../shared/contacts.json')).json();
1717
render(example(contacts), document.body);
1818
})();

packages/uni-virtualizer-examples/shared/boot.js renamed to packages/uni-virtualizer-examples/public/shared/boot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ async function boot() {
55
if (unbundled) {
66
const importmap = document.createElement('script');
77
importmap.setAttribute('type', 'importmap');
8-
importmap.textContent = await (await fetch('../../shared/importmap.json')).text();
8+
importmap.textContent = await (await fetch('../shared/importmap.json')).text();
99
document.head.appendChild(importmap);
1010
}
1111
const example = document.createElement('script');

packages/uni-virtualizer-examples/public/temp/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<!doctype html>
1111
<html>
1212
<head>
13-
<script src="../../shared/boot.js"></script>
13+
<script src="../shared/boot.js"></script>
1414
</head>
1515
<body>
1616
<hey-yo></hey-yo>

packages/uni-virtualizer-examples/public/temp/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Yo extends LitElement {
7373
}
7474

7575
async firstUpdated() {
76-
const resp = await fetch('../../shared/contacts.json');
76+
const resp = await fetch('../shared/contacts.json');
7777
this.data = await resp.json();
7878
}
7979

packages/uni-virtualizer-examples/rollup.config.js

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,23 @@ export default [
1717
]
1818
},
1919
{
20-
input: [
21-
'lit-html',
22-
'lit-virtualizer/lib/scroll.js',
23-
'public/basic-lit-html/index.js'
24-
],
25-
output: {
26-
dir: 'public/basic-lit-html/build',
27-
format: 'esm'
28-
},
29-
plugins: [
30-
resolve(),
31-
]
20+
input: 'public/basic-lit-html/index.js',
21+
output: {
22+
dir: 'public/basic-lit-html/build',
23+
format: 'esm'
24+
},
25+
plugins: [
26+
resolve(),
27+
]
3228
},
3329
{
34-
input: [
35-
// 'lit-element',
36-
// 'lit-virtualizer/src/lit-virtualizer.js',
37-
'public/basic-lit-element/index.js'
38-
],
39-
output: {
40-
dir: 'public/basic-lit-element/build',
41-
format: 'esm'
42-
},
43-
plugins: [
44-
resolve(),
45-
]
30+
input: 'public/basic-lit-element/index.js',
31+
output: {
32+
dir: 'public/basic-lit-element/build',
33+
format: 'esm'
34+
},
35+
plugins: [
36+
resolve(),
37+
]
4638
},
4739
];

scripts/deploy-examples.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
# Create a new worktree at `gh-pages/`
4+
if ! git worktree add gh-pages ; then
5+
git worktree remove gh-pages
6+
git worktree add gh-pages
7+
fi
8+
9+
# Clean it out
10+
rm -rf gh-pages/*
11+
12+
# Build uni-virtualizer-examples and copy the build into the gh-pages worktree
13+
npm run build --prefix packages/uni-virtualizer-examples/
14+
cp -r packages/uni-virtualizer-examples/public/* gh-pages
15+
16+
# Commit and push to deploy
17+
cd gh-pages
18+
if ! { git add -A && git commit -m "deploy examples" && git push origin HEAD:gh-pages; } ; then
19+
echo $'\nNothing to deploy.'
20+
fi

0 commit comments

Comments
 (0)