Skip to content

Commit

Permalink
Merge pull request #1 from Pkcarreno/develop
Browse files Browse the repository at this point in the history
feat: first commit
  • Loading branch information
Pkcarreno authored Jun 2, 2024
2 parents db8acc5 + 1b32fd3 commit 7dbbb6d
Show file tree
Hide file tree
Showing 123 changed files with 15,134 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
16 changes: 16 additions & 0 deletions .github/actions/setup-node-pnpm-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Taken from obytes' react native template: https://github.com/obytes/react-native-template-obytes

name: 'Setup Node + PNPM + Install Dependencies'
description: 'Setup Node + PNPM + Install Dependencies'
runs:
using: 'composite'
steps:
- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
cache: 'pnpm'

- name: 📦 Install Project Dependencies
run: pnpm install --frozen-lockfile
shell: bash
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'monthly'
time: '01:00'
commit-message:
prefix: 'pnpm'
groups:
all:
patterns:
- '*'
77 changes: 77 additions & 0 deletions .github/workflows/precheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Taken from obytes' react native template: https://github.com/obytes/react-native-template-obytes

name: Precheck

on:
pull_request:
branches: [main]
workflow_call:

jobs:
install:
name: Prepare enviroment + Cache
runs-on: ubuntu-latest
steps:
- name: 📦 Checkout project repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 📦 Setup Node + PNPM + install deps
uses: ./.github/actions/setup-node-pnpm-install

lint:
name: Lint TS (eslint, prettier)
needs: [install]
runs-on: ubuntu-latest
steps:
- name: 📦 Checkout project repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 📦 Setup Node + PNPM + install deps
uses: ./.github/actions/setup-node-pnpm-install

- name: 🏃‍♂️ Run ESLint PR
if: github.event_name == 'pull_request'
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
eslint_flags: 'src --max-warnings=0'

- name: 🏃‍♂️ Run ESLint PR
if: github.event_name != 'pull_request'
run: pnpm run lint

type-check:
name: Type Check (tsc)
needs: [install]
runs-on: ubuntu-latest
steps:
- name: 📦 Checkout project repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 📦 Setup Node + PNPM + install deps
uses: ./.github/actions/setup-node-pnpm-install

- name: 📦 Install Reviewdog
if: github.event_name == 'pull_request'
uses: reviewdog/action-setup@v1

- name: 🏃‍♂️ Run TypeScript PR # Reviewdog tsc errorformat: %f:%l:%c - error TS%n: %m
# We only need to add the reviewdog step if it's a pull request
if: github.event_name == 'pull_request'
run: |
pnpm type-check | reviewdog -name="tsc" -efm="%f(%l,%c): error TS%n: %m" -reporter="github-pr-review" -filter-mode="nofilter" -fail-on-error -tee
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name:
🏃‍♂️ Run TypeScript Commit
# If it's not a Pull Request then we just need to run the type-check
if: github.event_name != 'pull_request'
run: pnpm type-check
89 changes: 89 additions & 0 deletions .github/workflows/release-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

name: 'release and deploy'

jobs:
prepare:
uses: ./.github/workflows/precheck.yml

release:
runs-on: ubuntu-latest
needs: [prepare]
permissions:
contents: write
pull-requests: write
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
release-type: node
outputs:
release-created: ${{ steps.release.outputs.release_created }}

build:
runs-on: ubuntu-latest
needs: [release]
if: ${{ needs.release.outputs.release-created }}
env:
VITE_BASE_URL: '/jsod'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 📦 Setup Node + PNPM + install deps
uses: ./.github/actions/setup-node-pnpm-install

- name: Build
run: pnpm build
shell: bash

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist

deploy:
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: read
pages: write
id-token: write
env:
VITE_BASE_URL: '/release-please-test/'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: dist
path: dist

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
dist
dist-ssr
*.local

# dependencies
/node_modules
/.pnp
.pnp.js

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/dev-dist

# local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm commitlint --edit $1
8 changes: 8 additions & 0 deletions .husky/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Workaround for Windows 10, Git Bash and Yarn
if command_exists winpty && test -t 1; then
exec </dev/tty
fi
14 changes: 14 additions & 0 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function changed {
git diff --name-only HEAD@{1} HEAD | grep "^$1" >/dev/null 2>&1
}

echo 'Checking for changes in pnpm-lock.yml...'

if changed 'pnpm-lock.yml'; then
echo "📦 pnpm-lock.yml changed. Run pnpm install to bring your dependencies up to date."
pnpm install
fi

echo 'You are up to date :)'

exit 0
19 changes: 19 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
. "$(dirname "$0")/common.sh"

echo "===\n>> Checking branch name..."

# Check branch protection
BRANCH=$(git rev-parse --abbrev-ref HEAD)
PROTECTED_BRANCHES="^(master|main)"

if [[ $BRANCH =~ $PROTECTED_BRANCHES ]]; then
echo ">> Direct commits to the $BRANCH branch are not allowed. Please choose a new branch name."
exit 1
fi

echo ">> Finish checking branch name"
echo ">> Linting your files and fixing them if needed..."

pnpm type-check
pnpm lint-staged
15 changes: 15 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
. "$(dirname "$0")/common.sh"

echo "===\n>> Checking branch name..."

# Check branch protection
BRANCH=$(git rev-parse --abbrev-ref HEAD)
PROTECTED_BRANCHES="^(master|main)"

if [[ $BRANCH =~ $PROTECTED_BRANCHES ]]; then
echo ">> Direct push to the $BRANCH branch are not allowed. Please choose a new branch name."
exit 1
fi

echo ">> Finish checking branch name"
4 changes: 4 additions & 0 deletions .knip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"entry": ["src/index.{js,ts,tsx}"]
}
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"endOfLine": "lf"
}
6 changes: 6 additions & 0 deletions .vitest/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { expect, afterEach } from 'vitest';
import { cleanup } from '@testing-library/react';
import * as matchers from '@testing-library/jest-dom/matchers';

expect.extend(matchers);
afterEach(cleanup);
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# JSOD

> [!IMPORTANT]
>
> The project is under development, so bugs or missing important features are expected.
Write, run, and share JavaScript code instantly.

It's:

- Open Source
- Run 100% on your device
- Powered by QuickJS (via [quickjs-emscripten](https://github.com/justjake/quickjs-emscripten))
- Shareable
- Installable
- Offline first

> [!CAUTION]
>
> Although JSOD aims to provide a safe environment, there may be inappropriate or malicious behavior when executing third-party code.
## Folder Structure

Follow [Bulletproof-react project structure](https://github.com/alan2207/bulletproof-react/blob/master/docs/project-structure.md).

## Development

To get a local copy of the code, clone it using git:

```bash
git clone https://github.com/Pkcarreno/jsod
cd jsod
```

Install dependencies:

```bash
pnpm i
```

Now, you can start a local web server by running:

```bash
pnpm dev
```

And then open [http://localhost:4000](http://localhost:4000) to view it in the browser.

## Thanks to

[Vite Template React](https://github.com/SafdarJamal/vite-template-react): Template used in this project.
[quickjs-emscripten](https://github.com/justjake/quickjs-emscripten) and [quickjs-emscripten-sync](https://github.com/reearth/quickjs-emscripten-sync): Quickjs wrapper, the engine of this app.
[codi.link](http://codi.link): Web editor, made in community. Great inspiration.
[borrowed.nvim](https://github.com/MyyPo/borrowed.nvim): Neovim color scheme, take the naming convention to create a color scheme under the JSOD color palette.

## License

This project is licensed under the terms of the [MIT license](https://github.com/Pkcarreno/jsod/blob/main/LICENSE).
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default { extends: ['@commitlint/config-conventional'] };
Loading

0 comments on commit 7dbbb6d

Please sign in to comment.