Skip to content

Commit

Permalink
feat: gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
enzonotario committed Oct 29, 2023
1 parent 6d99972 commit bc8a109
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 8 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Sample workflow for building and deploying a VitePress site to GitHub Pages
#
name: Deploy EsJS Docs

on:
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
# using the `master` branch as the default branch.
push:
branches: [main, feature/gh-pages]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
node-version: 18

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false

- name: Install dependencies
run: pnpm --filter compiler --filter sandbox --filter core --filter docs-components --filter language-tools --filter docs install

- name: Build
run: pnpm --filter docs --filter language-tools --filter docs-components --filter core --filter sandbox --filter compiler run build

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: packages/docs/src/.vitepress/dist

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
13 changes: 6 additions & 7 deletions packages/sandbox/src/utils/ejecutar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ const scriptEls: HTMLScriptElement[] = []

let theme: 'dark' | 'light' = 'dark'

let lastArgs: any = {}

export async function init(options: EjecutarOptions): Promise<void> {
_options = options

Expand All @@ -40,7 +38,7 @@ export async function init(options: EjecutarOptions): Promise<void> {
evalInitialCode()
}

export async function evalFiles({ files }) {
export async function evalFiles({ files }: { files: string[] }) {
try {
const result = prepareCodeAndTestsForPlayground(
files[MAIN_FILE] || '',
Expand Down Expand Up @@ -74,7 +72,7 @@ export async function evalFiles({ files }) {
}
}

function handleEvalError(error) {
function handleEvalError(error: any) {
const errorArgs = {
filename: error.filename,
message: error.message,
Expand Down Expand Up @@ -102,8 +100,6 @@ window.onerror(${JSON.stringify(error.message)}, null, 1, 1, ${JSON.stringify(er
}

async function evalCode(args: any) {
lastArgs = Object.assign({}, args)

if (scriptEls.length) {
scriptEls.forEach((el) => {
document.head.removeChild(el)
Expand All @@ -118,7 +114,7 @@ async function evalCode(args: any) {

resetAppElement()

const usesTerminal = scripts.some(script => script.includes('Terminal'))
const usesTerminal = scripts.some((script: string) => script.includes('Terminal'))
if (usesTerminal)
await addEsJSTerminal()

Expand All @@ -130,6 +126,8 @@ async function evalCode(args: any) {
// send ok in the module script to ensure sequential evaluation
// of multiple proxy.eval() calls
const done = new Promise((resolve) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
window.__next__ = resolve
})
scriptEl.innerHTML = `${script}\nwindow.__next__()`
Expand Down Expand Up @@ -163,6 +161,7 @@ function clearConsole() {
if (isDev)
return

// eslint-disable-next-line no-console
console.clear()
}

Expand Down
3 changes: 2 additions & 1 deletion packages/sandbox/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"declarationDir": "./types",
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true
"noImplicitReturns": true,
"allowJs": true
},
"include": ["./src"]
}

0 comments on commit bc8a109

Please sign in to comment.