Skip to content

Commit e2c0024

Browse files
committed
init
0 parents  commit e2c0024

34 files changed

Lines changed: 18524 additions & 0 deletions

.github/workflows/validate.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: deploy
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
branches:
10+
- 'main'
11+
pull_request: {}
12+
13+
jobs:
14+
setup:
15+
name: 🔧 Setup
16+
timeout-minutes: 10
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest, windows-latest, macos-latest]
20+
runs-on: ${{ matrix.os }}
21+
steps:
22+
- name: ⬇️ Checkout repo
23+
uses: actions/checkout@v4
24+
25+
- name: ⎔ Setup node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 24
29+
30+
- name: ▶️ Run setup script
31+
run: npm run setup
32+
33+
- name: ʦ TypeScript
34+
run: npm run typecheck
35+
36+
- name: ⬣ ESLint
37+
run: npm run lint
38+
39+
tests:
40+
name: 🧪 Test
41+
timeout-minutes: 10
42+
runs-on: ubuntu-latest
43+
# Use continue-on-error to ensure this job doesn't fail the workflow
44+
continue-on-error: true
45+
46+
steps:
47+
- name: ⬇️ Checkout repo
48+
uses: actions/checkout@v4
49+
50+
- name: ⎔ Setup node
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version: 24
54+
55+
- name: 📦 Install dependencies
56+
run: npm ci
57+
58+
- name: 🧪 Run tests
59+
id: run_tests
60+
run: node ./epicshop/test.js ..s
61+
62+
deploy:
63+
name: 🚀 Deploy
64+
timeout-minutes: 10
65+
runs-on: ubuntu-latest
66+
# only deploy main branch on pushes on non-forks
67+
if:
68+
${{ github.ref == 'refs/heads/main' && github.event_name == 'push' &&
69+
github.repository_owner == 'epicweb-dev' }}
70+
71+
steps:
72+
- name: ⬇️ Checkout repo
73+
uses: actions/checkout@v4
74+
75+
- name: 🎈 Setup Fly
76+
uses: superfly/flyctl-actions/setup-flyctl@1.5
77+
78+
- name: 🚀 Deploy
79+
run:
80+
flyctl deploy --remote-only --build-arg
81+
EPICSHOP_GITHUB_REPO=https://github.com/${{ github.repository }}
82+
--build-arg EPICSHOP_COMMIT_SHA=${{ github.sha }}
83+
working-directory: ./epicshop
84+
env:
85+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
node_modules
2+
3+
workspace/
4+
**/.cache/
5+
**/build/
6+
**/public/build
7+
**/playwright-report
8+
data.db
9+
/playground
10+
**/tsconfig.tsbuildinfo
11+
**/dist
12+
13+
# in a real app you'd want to not commit the .env
14+
# file as well, but since this is for a workshop
15+
# we're going to keep them around.
16+
# .env

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
legacy-peer-deps=true
2+
registry=https://registry.npmjs.org/

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**/node_modules/**
2+
**/.cache/**
3+
**/build/**
4+
**/dist/**
5+
**/public/build/**
6+
**/package-lock.json
7+
**/playwright-report/**

LICENSE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This material is available for private, non-commercial use under the
2+
[GPL version 3](http://www.gnu.org/licenses/gpl-3.0-standalone.html). If you
3+
would like to use this material to conduct your own workshop, please contact us
4+
at team@epicweb.dev

README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<div>
2+
<h1 align="center"><a href="https://www.epicweb.dev/workshops">Epic Workshop App Tutorial 👨‍🏫</a></h1>
3+
<strong>
4+
Maximize your learning experience by learning how to use the Epic Workshop App
5+
</strong>
6+
<p>
7+
The Epic Workshop App is a powerful tool for learning and it takes some time to get used to. In this tutorial, we'll walk through the features of the app to make sure you're set up for success.
8+
</p>
9+
</div>
10+
11+
<hr />
12+
13+
<div align="center">
14+
<a
15+
alt="Epic Web logo with the words Deployed Version"
16+
href="https://epicweb-dev-epicshop-tutorial.fly.dev/"
17+
>
18+
<img
19+
width="300px"
20+
src="https://github-production-user-asset-6210df.s3.amazonaws.com/1500684/254000390-447a3559-e7b9-4918-947a-1b326d239771.png"
21+
/>
22+
</a>
23+
</div>
24+
25+
<hr />
26+
27+
<!-- prettier-ignore-start -->
28+
[![Build Status][build-badge]][build]
29+
[![GPL 3.0 License][license-badge]][license]
30+
[![Code of Conduct][coc-badge]][coc]
31+
<!-- prettier-ignore-end -->
32+
33+
## Prerequisites
34+
35+
- None for this tutorial, but each workshop will have its own prerequisites you'll need to meet.
36+
37+
## Pre-workshop Resources
38+
39+
Here are some resources you can read before taking the workshop to get you up to
40+
speed on some of the tools and concepts we'll be covering:
41+
42+
- None for this tutorial, but each workshop will have its own pre-workshop resources you'll want to read/watch/listen to.
43+
44+
## System Requirements
45+
46+
- [git][git] v2.18 or greater
47+
- [NodeJS][node] v18 or greater
48+
- [npm][npm] v8 or greater
49+
50+
All of these must be available in your `PATH`. To verify things are set up
51+
properly, you can run this:
52+
53+
```shell
54+
git --version
55+
node --version
56+
npm --version
57+
```
58+
59+
If you have trouble with any of these, learn more about the PATH environment
60+
variable and how to fix it here for [windows][win-path] or
61+
[mac/linux][mac-path].
62+
63+
## Setup
64+
65+
This is a pretty large project (it's actually many apps in one) so it can take
66+
several minutes to get everything set up the first time. Please have a strong
67+
network connection before running the setup and grab a snack.
68+
69+
> **Warning**: This repo is _very_ large. Make sure you have a good internet
70+
> connection before you start the setup process. The instructions below use
71+
> `--depth` to limit the amount you download, but if you have a slow connection,
72+
> or you pay for bandwidth, you may want to find a place with a better
73+
> connection.
74+
75+
Follow these steps to get this set up:
76+
77+
```sh nonumber
78+
git clone --depth 1 https://github.com/epicweb-dev/epicshop-tutorial.git
79+
cd epicshop-tutorial
80+
npm run setup
81+
```
82+
83+
If you experience errors here, please open [an issue][issue] with as many
84+
details as you can offer.
85+
86+
## The Workshop App
87+
88+
Learn all about the workshop app on the
89+
[Epic Web Getting Started Guide](https://www.epicweb.dev/get-started).
90+
91+
[![Kent with the workshop app in the background](https://github-production-user-asset-6210df.s3.amazonaws.com/1500684/280407082-0e012138-e01d-45d5-abf2-86ffe5d03c69.png)](https://www.epicweb.dev/get-started)
92+
93+
<!-- prettier-ignore-start -->
94+
[npm]: https://www.npmjs.com/
95+
[node]: https://nodejs.org
96+
[git]: https://git-scm.com/
97+
[build-badge]: https://img.shields.io/github/actions/workflow/status/epicweb-dev/epicshop-tutorial/validate.yml?branch=main&logo=github&style=flat-square
98+
[build]: https://github.com/epicweb-dev/epicshop-tutorial/actions?query=workflow%3Avalidate
99+
[license-badge]: https://img.shields.io/badge/license-GPL%203.0%20License-blue.svg?style=flat-square
100+
[license]: https://github.com/epicweb-dev/epicshop-tutorial/blob/main/LICENSE
101+
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
102+
[coc]: https://kentcdodds.com/conduct
103+
[win-path]: https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/
104+
[mac-path]: http://stackoverflow.com/a/24322978/971592
105+
[issue]: https://github.com/epicweb-dev/epicshop-tutorial/issues/new
106+
<!-- prettier-ignore-end -->

epicshop/.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
legacy-peer-deps=true
2+
registry=https://registry.npmjs.org/

epicshop/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM node:24-bookworm-slim as base
2+
3+
RUN apt-get update && apt-get install -y git
4+
5+
# Build argument for GitHub repo URL
6+
ARG EPICSHOP_GITHUB_REPO
7+
ENV EPICSHOP_GITHUB_REPO=${EPICSHOP_GITHUB_REPO}
8+
9+
ENV EPICSHOP_CONTEXT_CWD="/myapp/workshop-content"
10+
ENV EPICSHOP_HOME_DIR="/myapp/.epicshop"
11+
ENV EPICSHOP_DEPLOYED="true"
12+
ENV EPICSHOP_DISABLE_WATCHER="true"
13+
ENV FLY="true"
14+
ENV PORT="8080"
15+
ENV NODE_ENV="production"
16+
17+
# Build argument for commit SHA to bust cache when repo changes
18+
ARG EPICSHOP_COMMIT_SHA
19+
ENV EPICSHOP_COMMIT_SHA=${EPICSHOP_COMMIT_SHA}
20+
21+
WORKDIR /myapp
22+
23+
# Clone the workshop repo during build time, excluding database files
24+
# Clone specific commit to keep image small while ensuring cache busting
25+
RUN git init ${EPICSHOP_CONTEXT_CWD} && \
26+
cd ${EPICSHOP_CONTEXT_CWD} && \
27+
git remote add origin ${EPICSHOP_GITHUB_REPO} && \
28+
git fetch --depth 1 origin ${EPICSHOP_COMMIT_SHA} && \
29+
git checkout ${EPICSHOP_COMMIT_SHA}
30+
31+
ADD . .
32+
33+
RUN npm install --omit=dev
34+
35+
RUN cd ${EPICSHOP_CONTEXT_CWD} && \
36+
npx epicshop warm
37+
38+
CMD cd ${EPICSHOP_CONTEXT_CWD} && \
39+
npx epicshop start

epicshop/fix-watch.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import path from 'node:path'
2+
import { fileURLToPath } from 'node:url'
3+
import chokidar from 'chokidar'
4+
import { $ } from 'execa'
5+
6+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
7+
const here = (...p) => path.join(__dirname, ...p)
8+
9+
const workshopRoot = here('..')
10+
11+
// Watch the exercises directory
12+
const watcher = chokidar.watch(path.join(workshopRoot, 'exercises'), {
13+
ignored: [
14+
/(^|[\/\\])\../, // ignore dotfiles
15+
(path) => {
16+
// Only watch directories up to depth 2
17+
const relativePath = path.slice(workshopRoot.length + 1)
18+
return relativePath.split('/').length > 4
19+
},
20+
],
21+
persistent: true,
22+
ignoreInitial: true,
23+
})
24+
25+
const debouncedRun = debounce(run, 200)
26+
27+
// Add event listeners.
28+
watcher
29+
.on('addDir', (path) => {
30+
debouncedRun()
31+
})
32+
.on('unlinkDir', (path) => {
33+
debouncedRun()
34+
})
35+
.on('error', (error) => console.log(`Watcher error: ${error}`))
36+
37+
/**
38+
* Simple debounce implementation
39+
*/
40+
function debounce(fn, delay) {
41+
let timer = null
42+
return (...args) => {
43+
if (timer) clearTimeout(timer)
44+
timer = setTimeout(() => {
45+
fn(...args)
46+
}, delay)
47+
}
48+
}
49+
50+
let running = false
51+
52+
async function run() {
53+
if (running) {
54+
console.log('still running...')
55+
return
56+
}
57+
running = true
58+
try {
59+
await $({
60+
stdio: 'inherit',
61+
cwd: workshopRoot,
62+
})`node ./epicshop/fix.js`
63+
} catch (error) {
64+
throw error
65+
} finally {
66+
running = false
67+
}
68+
}
69+
70+
console.log('Watching exercises directory for changes...')
71+
console.log('running fix to start...')
72+
run()

0 commit comments

Comments
 (0)