diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 4422914..519038b 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -11,4 +11,4 @@ jobs: with: options: "--check --verbose" src: "./src" - version: "23.9.1" \ No newline at end of file + version: "23.9.1" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5c78db7..38f409d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -4,7 +4,7 @@ on: # Trigger the workflow every time you push to the `main` branch # Using a different branch name? Replace `main` with your branch’s name push: - branches: [ main ] + branches: [main] # Allows you to run this workflow manually from the Actions tab on GitHub. workflow_dispatch: @@ -37,4 +37,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v1 \ No newline at end of file + uses: actions/deploy-pages@v1 diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 9c978b3..fd28855 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -18,4 +18,4 @@ jobs: uses: stefanzweifel/git-auto-commit-action@v4 with: commit_message: Apply formatting changes - branch: ${{ github.head_ref }} \ No newline at end of file + branch: ${{ github.head_ref }} diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 9d25af1..4e64d53 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,29 +1,29 @@ name: Playwright Tests on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: test: timeout-minutes: 60 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Install dependencies - run: yarn install - - name: Build pysandbox - run: yarn build - - name: Install chromium - run: yarn playwright install chromium - - name: Run Playwright tests - run: yarn test - - uses: actions/upload-artifact@v3 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 \ No newline at end of file + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: yarn install + - name: Build pysandbox + run: yarn build + - name: Install chromium + run: yarn playwright install chromium + - name: Run Playwright tests + run: yarn test + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d0a75c0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,25 @@ +name: Release & Publish to NPM +on: workflow_dispatch +jobs: + release: + runs-on: ubuntu-20.04 + steps: + - name: Checkout source code + uses: actions/checkout@v2 + - name: Install the dependancies + run: npm ci + - name: Initialise the NPM config + run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Initialize Git user + run: | + git config --global user.email "david@kodaps.com" + git config --global user.name "Release Workflow" + - name: Log git status + run: git status + - name: Run release + run: npm run release --ci + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 62e5f02..f5eb299 100644 --- a/README.md +++ b/README.md @@ -4,20 +4,20 @@ For installation and usage instructions see [user docs](https://bugzpodder.githu ## Introduction -PySandbox is a library that helps developers create client-side Python-powered web applications. It is inspired by [PyScript](https://github.com/pyscript/pyscript) and built on top of [Pyodide](https://github.com/pyodide/pyodide) and [Polyscript](https://github.com/pyscript/polyscript). +PySandbox is a library that helps developers create client-side Python-powered web applications. It is inspired by [PyScript](https://github.com/pyscript/pyscript) and built on top of [Pyodide](https://github.com/pyodide/pyodide) and [Polyscript](https://github.com/pyscript/polyscript). The main features of PySandbox are: - - Exports simple JS classes that can be used in any JS framework or html page. - - Web Worker ready. If your site is cross origin isolated, Web Workers can be used to execute python code. - - Restricted mode. Enabling this mode will disallow python scripts access to js.document. - - Custom modules support. You can define your own modules that are accessible in the codeblock. - - Input/Output support. You can easily pass data in and out of the python code blocks and display images and/or adding 3rd party JS integration. - - Helper methods for formatting code, find imports and installing modules in Pyodide. +- Exports simple JS classes that can be used in any JS framework or html page. +- Web Worker ready. If your site is cross origin isolated, Web Workers can be used to execute python code. +- Restricted mode. Enabling this mode will disallow python scripts access to js.document. +- Custom modules support. You can define your own modules that are accessible in the codeblock. +- Input/Output support. You can easily pass data in and out of the python code blocks and display images and/or adding 3rd party JS integration. +- Helper methods for formatting code, find imports and installing modules in Pyodide. ## Contributing -Project bootstraped with `tsup` and `esbuild`. `Node.js 16.x/18.x` is recommended for development. +Project bootstraped with `tsup` and `esbuild`. `Node.js 16.x/18.x` is recommended for development. `yarn dev` to make changes and make development build @@ -25,4 +25,4 @@ Project bootstraped with `tsup` and `esbuild`. `Node.js 16.x/18.x` is recommend `yarn format` & `yarn format:py` to run code formatting -`/docs` contains documentation. Run `yarn format` in docs to format changes. +`/docs` contains documentation. Run `yarn format` in docs to format changes. diff --git a/docs/package.json b/docs/package.json index 989424d..920b68e 100644 --- a/docs/package.json +++ b/docs/package.json @@ -11,7 +11,7 @@ "build": "astro build", "preview": "astro preview", "astro": "astro", - "format": "prettier -w src src/**/*.astro" + "format": "prettier -w src src/**/*.astro *.mjs *.js *.json" }, "dependencies": { "@astrojs/starlight": "^0.10.0", diff --git a/docs/prettier.config.js b/docs/prettier.config.js index 299c31e..7e61930 100644 --- a/docs/prettier.config.js +++ b/docs/prettier.config.js @@ -1,11 +1,11 @@ /** @type {import("prettier").Config} */ export default { - plugins: ['prettier-plugin-astro'], + plugins: ["prettier-plugin-astro"], overrides: [ { - files: '*.astro', + files: "*.astro", options: { - parser: 'astro', + parser: "astro", }, }, ], diff --git a/docs/src/content/docs/guides/comparison.md b/docs/src/content/docs/guides/comparison.md index 2b53ba3..01b79fe 100644 --- a/docs/src/content/docs/guides/comparison.md +++ b/docs/src/content/docs/guides/comparison.md @@ -11,4 +11,4 @@ Pyodide does not setup web workers out of the box. If you site is [crossOriginIs ## PyScript -[PyScript](https://pyscript.net/) is great for configuring a single html page to run python code as well as providing acess to DOM through its `pyweb` API. `PyScript` adopts a RPC pattern by letting Python code manipulate the DOM and react to events, while `PySandbox` is intended to be a traditional REST backend. If you are using a JS web-framework (e.g. a React-based framework) to build your web application, you may find `PySandbox` easier to use with its pure JS invocation without needing to rely on `