diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 00000000000..2e178927525 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,65 @@ +name: Bug Report +description: Create a report to help us improve +labels: ["type: bug", "needs-triage"] +body: + - type: markdown + attributes: + value: | + Thanks for helping PyScript! 🐍 + + Going through bugs and issues takes up a lot of time, so please be so kind and take a few minutes to fill out all the areas to the best of your ability. + + There will always be more issues than there is time to do them, and so we will need to selectively close issues that don't provide enough information, so we can focus our time on helping people like you who fill out the issue form completely. Thank you for your collaboration! + + There are also already a lot of open issues, so please take 2 minutes and search through existing ones to see if what you are experiencing already exists. + + Finally, if you are opening **a bug report related to PyScript.com** please [use this repository instead](https://github.com/anaconda/pyscript-dot-com-issues/issues/new/choose). + + Thanks for helping PyScript be amazing. We are nothing without people like you helping build a better community 💐! + - type: checkboxes + id: checks + attributes: + label: Checklist + description: Please confirm and check all the following options. + options: + - label: I added a descriptive title + required: true + - label: I searched for other issues and couldn't find a solution or duplication + required: true + - label: I already searched in Google and didn't find any good information or help + required: true + - type: textarea + id: what-happened + attributes: + label: What happened? + description: And what should have happened instead? This really helps everyone review quicker and greatly increases the chance that someone can get around to solve your issue + placeholder: Tell us what you see! + validations: + required: true + - type: dropdown + id: browsers + attributes: + label: What browsers are you seeing the problem on? (if applicable) + multiple: true + options: + - Firefox + - Chrome + - Safari + - Microsoft Edge + - Other + validations: + required: false + - type: textarea + id: list + attributes: + label: Console info + description: | + If there are errors in your browser console then its helpful to be able to troubleshoot. + - Chrome , Firefox, and Edge: Right-click on the page and select *Inspect*. Alternatively you can press F12 on your keyboard. + - Safari: Find instructions [here](https://support.apple.com/guide/safari/use-the-developer-tools-in-the-develop-menu-sfri20948/mac). + render: shell + - type: textarea + id: context + attributes: + label: Additional Context + description: Add any additional context information or screenshots you think are useful. diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 9efbb15e378..00000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: "[BUG]" -labels: needs-triage -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: either a code snippet or a link to an HTML page which shows the bug. - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000000..cbd90d4bb82 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: true +contact_links: + - name: Feature Proposals + url: https://github.com/pyscript/pyscript/discussions/new?category=proposals + about: Create a feature request to make PyScript even better + - name: Questions + url: https://github.com/pyscript/pyscript/discussions/new?category=q-a + about: For questions or discussions about pyscript diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index fcc64193853..00000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: "[FEATURE]" -labels: needs-triage -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. As a user, I'd like to [...] - -**Describe the solution you'd like** -A clear and concise description of what you expect to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000000..591e81853a0 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,12 @@ +## Description + + + +## Changes + + + +## Checklist + +- [ ] I have checked `make build` works locally. +- [ ] I have created / updated documentation for this change (if applicable). diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000000..e29bff2bead --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# Keep GitHub Actions up to date with GitHub's Dependabot... +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + groups: + github-actions: + patterns: + - "*" # Group all Actions updates into a single larger pull request + schedule: + interval: weekly diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 00000000000..0bc80808634 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,5 @@ +changelog: + categories: + - title: New Features + - title: Breaking Changes + - title: Known Issues diff --git a/.github/workflows/build-alpha.yml b/.github/workflows/build-alpha.yml deleted file mode 100644 index aa9113a664d..00000000000 --- a/.github/workflows/build-alpha.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: '[CI] Build Alpha' - -on: - push: - tags: - - '**' # Currently any tag, need to slim down - paths: - - pyscriptjs/** - - .github/workflows/build-alpha.yml # Test that workflow works when changed - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - id-token: write - defaults: - run: - working-directory: ./pyscriptjs - - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install node - uses: actions/setup-node@v3 - with: - node-version: 18.x - - name: Cache node modules - uses: actions/cache@v3 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: Install dependencies - run: | - npm install - - name: Build pyscript - run: | - npm run build - # Deploy to S3 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1.6.1 - with: - aws-region: ${{secrets.AWS_REGION}} - role-to-assume: ${{ secrets.AWS_OIDC_RUNNER_ROLE }} - - name: Sync to S3 - run: aws s3 sync . s3://pyscript-static/alpha/ # What artifacts exactly need to be copied? diff --git a/.github/workflows/build-latest.yml b/.github/workflows/build-latest.yml deleted file mode 100644 index fb19705d44c..00000000000 --- a/.github/workflows/build-latest.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: '[CI] Build Latest' - -on: - push: # Only run on merges into main that modify files under pyscriptjs/ - branches: - - main - paths: - - pyscriptjs/** - - .github/workflows/build-latest.yml # Test that workflow works when changed - - pull_request: # Run on any PR that modifies files in pyscriptjs/ - paths: - - pyscriptjs/** - - .github/workflows/** - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - id-token: write - defaults: - run: - working-directory: ./pyscriptjs - - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install node - uses: actions/setup-node@v3 - with: - node-version: 18.x - - name: Cache node modules - uses: actions/cache@v3 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: Install dependencies - run: | - npm install - - name: Build pyscript - run: | - npm run build - # Deploy to S3 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1.6.1 - with: - aws-region: ${{secrets.AWS_REGION}} - role-to-assume: ${{ secrets.AWS_OIDC_RUNNER_ROLE }} - - name: Sync to S3 - run: aws s3 sync . s3://pyscript-static/unstable/ # What artifacts exactly need to be copied? diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 00000000000..43fe719dbf1 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,71 @@ +name: "Prepare Release" + +on: + push: + tags: + - "[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9]+" # YYYY.MM.MICRO + +defaults: + run: + working-directory: ./core + +jobs: + prepare-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Python venv + run: python -m venv env + + - name: Activate Python + run: source env/bin/activate + + - name: Update pip + run: pip install --upgrade pip + + - name: Install PyMinifier + run: pip install --ignore-requires-python python-minifier + + - name: Install Setuptools + run: pip install setuptools + + - name: Cache node modules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: NPM Install + run: npm install && npx playwright install chromium + + - name: Build + run: npm run build + + - name: Generate index.html + working-directory: . + run: sed -e 's#_PATH_#./#' -e 's#_DOC_VERSION_#latest#' -e 's#_TAG_VERSION_##' -e 's#_VERSION_#latest#' ./public/index.html > ./core/dist/index.html + + - name: Zip dist folder + run: zip -r -q ./build.zip ./dist + + - name: Prepare Release + uses: softprops/action-gh-release@v2 + with: + draft: true + prerelease: true + generate_release_notes: true + files: ./build.zip diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 00000000000..5c605299dbc --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,78 @@ +name: "Publish Release" + +on: + release: + types: [published] + +defaults: + run: + working-directory: ./core + +jobs: + publish-release: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Python venv + run: python -m venv env + + - name: Activate Python + run: source env/bin/activate + + - name: Update pip + run: pip install --upgrade pip + + - name: Install PyMinifier + run: pip install --ignore-requires-python python-minifier + + - name: Install Setuptools + run: pip install setuptools + + - name: Cache node modules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: npm install + run: npm install && npx playwright install chromium + + - name: build + run: npm run build + + - name: Generate index.html in snapshot + working-directory: . + run: sed -e 's#_PATH_#https://pyscript.net/releases/${{ github.ref_name }}/#' -e 's#_DOC_VERSION_#${{ github.ref_name }}#' -e 's#_TAG_VERSION_#/tag/${{ github.ref_name }}#' -e 's#_VERSION_#${{ github.ref_name }}#' ./public/index.html > ./core/dist/index.html + + - name: Generate release.tar from snapshot and put it in dist/ + working-directory: . + run: tar -cvf ../release.tar * && mv ../release.tar . + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: ${{ secrets.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_OIDC_RUNNER_ROLE }} + + - name: Sync to S3 + run: + | # Update /latest and create an explicitly versioned directory under releases/YYYY.MM.MICRO/ + aws s3 sync --quiet ./dist/ s3://pyscript.net/latest/ + aws s3 sync --quiet ./dist/ s3://pyscript.net/releases/${{ github.ref_name }}/ diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 00000000000..b7f51d52ae7 --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,76 @@ +name: "Publish Snapshot" + +on: + workflow_dispatch: + inputs: + snapshot_version: + description: "The calver version of this snapshot: 2022.09.1 or 2022.09.1.RC1" + type: string + required: true + +defaults: + run: + working-directory: ./core + +jobs: + publish-snapshot: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Python venv + run: python -m venv env + + - name: Activate Python + run: source env/bin/activate + + - name: Update pip + run: pip install --upgrade pip + + - name: Install PyMinifier + run: pip install --ignore-requires-python python-minifier + + - name: Install Setuptools + run: pip install setuptools + + - name: Cache node modules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install Dependencies + run: npm install && npx playwright install chromium + + - name: Build Pyscript.core + run: npm run build + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: ${{ secrets.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_OIDC_RUNNER_ROLE }} + + - name: Generate index.html in snapshot + working-directory: . + run: sed -e 's#_PATH_#https://pyscript.net/snapshots/${{ inputs.snapshot_version }}/#' -e 's#_DOC_VERSION_#${{ inputs.snapshot_version }}#' -e 's#_TAG_VERSION_#/tag/${{ inputs.snapshot_version }}#' -e 's#_VERSION_#${{ inputs.snapshot_version }}#' ./public/index.html > ./core/dist/index.html + + - name: Copy to Snapshot + run: > + aws s3 sync ./dist/ s3://pyscript.net/snapshots/${{ inputs.snapshot_version }}/ diff --git a/.github/workflows/publish-unstable.yml b/.github/workflows/publish-unstable.yml new file mode 100644 index 00000000000..89a0e2b8902 --- /dev/null +++ b/.github/workflows/publish-unstable.yml @@ -0,0 +1,76 @@ +name: "Publish Unstable" + +on: + push: # Only run on merges into main that modify files under core/ and examples/ + branches: + - main + paths: + - core/** + - examples/** + + workflow_dispatch: + +jobs: + publish-unstable: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + defaults: + run: + working-directory: ./core + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Python venv + run: python -m venv env + + - name: Activate Python + run: source env/bin/activate + + - name: Update pip + run: pip install --upgrade pip + + - name: Install PyMinifier + run: pip install --ignore-requires-python python-minifier + + - name: Install Setuptools + run: pip install setuptools + + - name: Cache node modules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: NPM Install + run: npm install && npx playwright install chromium + + - name: Build + run: npm run build + + - name: Generate index.html in snapshot + working-directory: . + run: sed -e 's#_PATH_#./#' -e 's#_DOC_VERSION_#latest#' -e 's#_TAG_VERSION_##' -e 's#_VERSION_#latest#' ./public/index.html > ./core/dist/index.html + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: ${{ secrets.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_OIDC_RUNNER_ROLE }} + + - name: Sync to S3 + run: aws s3 sync --quiet ./dist/ s3://pyscript.net/unstable/ diff --git a/.github/workflows/sync-examples.yml b/.github/workflows/sync-examples.yml deleted file mode 100644 index 980f0b606e1..00000000000 --- a/.github/workflows/sync-examples.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: '[CI] Sync Examples' - -on: - push: # Only run on merges into main that modify files under pyscriptjs/examples/ - branches: - - main - paths: - - pyscriptjs/examples/** - - .github/workflows/sync-examples.yml # Test that workflow works when changed - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - id-token: write - defaults: - run: - working-directory: ./pyscriptjs/examples - - steps: - # Deploy to S3 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1.6.1 - with: - aws-region: ${{secrets.AWS_REGION}} - role-to-assume: ${{ secrets.AWS_OIDC_RUNNER_ROLE }} - - name: Sync to S3 - run: aws s3 sync . s3://pyscript-static/examples/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000000..785b7cbbf3f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,80 @@ +name: "[CI] Test" + +on: + push: # Only run on merges into main that modify certain files + branches: + - main + paths: + - core/** + - .github/workflows/test.yml + + pull_request: # Only run on merges into main that modify certain files + branches: + - main + paths: + - core/** + - .github/workflows/test.yml + workflow_dispatch: + +jobs: + BuildAndTest: + runs-on: ubuntu-latest + env: + MINICONDA_PYTHON_VERSION: py38 + MINICONDA_VERSION: 4.11.0 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 3 + + # display a git log: when you run CI on PRs, github automatically + # merges the PR into main and run the CI on that commit. The idea + # here is to show enough of git log to understand what is the + # actual commit (in the PR) that we are using. See also + # 'fetch-depth: 3' above. + - name: git log + run: git log --graph -3 + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Cache node modules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: setup Miniconda + uses: conda-incubator/setup-miniconda@v3 + + - name: Create and activate virtual environment + run: | + python3 -m venv test_venv + source test_venv/bin/activate + echo PATH=$PATH >> $GITHUB_ENV + echo VIRTUAL_ENV=$VIRTUAL_ENV >> $GITHUB_ENV + + - name: Setup dependencies in virtual environment + run: | + make setup + + - name: Build + run: make build # Integration tests run in the build step. + + - uses: actions/upload-artifact@v4 + with: + name: pyscript + path: | + core/dist/ + if-no-files-found: error + retention-days: 7 diff --git a/.gitignore b/.gitignore index 86b04373c8b..6ccef40cf9e 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ instance/ # Sphinx documentation docs/_build/ +docs/_env/ # PyBuilder target/ @@ -134,3 +135,18 @@ dmypy.json .pyre/ node_modules/ + +coverage/ + +# junit xml for test results +test_results + +# @pyscript/core npm artifacts +core/test-results/* +core/core.* +core/dist +core/dist.zip +core/src/plugins.js +core/src/stdlib/pyscript.js +core/src/3rd-party/* +!core/src/3rd-party/READMEmd diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e583aa1b135..b18b22ee168 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,77 +1,53 @@ # This is the configuration for pre-commit, a local framework for managing pre-commit hooks # Check out the docs at: https://pre-commit.com/ +ci: + #skip: [eslint] + autoupdate_schedule: monthly -default_stages: [commit] +default_stages: [pre-commit] repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 - hooks: - - id: check-builtin-literals - - id: check-case-conflict - - id: check-docstring-first - - id: check-executables-have-shebangs - - id: check-json - exclude: tsconfig.json - - id: check-toml - - id: check-xml - - id: check-yaml - - id: detect-private-key - - id: end-of-file-fixer - exclude: \.min\.js$ - - id: trailing-whitespace - -- repo: https://github.com/PyCQA/bandit - rev: 1.7.4 - hooks: - - id: bandit - args: - - --skip=B201 - -- repo: https://github.com/psf/black - rev: 22.3.0 - hooks: - - id: black - -- repo: https://github.com/codespell-project/codespell - rev: v2.1.0 - hooks: - - id: codespell # See 'setup.cfg' for args - -- repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 - hooks: - - id: flake8 # See 'setup.cfg' for args - additional_dependencies: [flake8-bugbear, flake8-comprehensions] - -- repo: https://github.com/pycqa/isort - rev: 5.10.1 - hooks: - - id: isort - name: isort (python) - args: [--profile, black] - -- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.3.0 - hooks: - - id: pretty-format-yaml - args: [--autofix, --indent, '4'] - -- repo: https://github.com/asottile/pyupgrade - rev: v2.32.1 - hooks: - - id: pyupgrade - args: - - --py310-plus - -- repo: https://github.com/pre-commit/mirrors-eslint - rev: v8.15.0 - hooks: - - id: eslint - files: pyscriptjs/src/.*\.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx - types: [file] - additional_dependencies: - - eslint - - eslint-plugin-svelte3 - - typescript - - '@typescript-eslint/eslint-plugin' - - '@typescript-eslint/parser' + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-builtin-literals + - id: check-case-conflict + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-json + exclude: tsconfig\.json + - id: check-toml + exclude: bad\.toml + - id: check-xml + - id: check-yaml + - id: detect-private-key + - id: end-of-file-fixer + exclude: core/dist|\.min\.js$ + - id: trailing-whitespace + + - repo: https://github.com/psf/black + rev: 25.1.0 + hooks: + - id: black + exclude: core/tests + args: ["-l", "88", "--skip-string-normalization"] + + - repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + hooks: + - id: codespell # See 'pyproject.toml' for args + exclude: fs\.py|\.js\.map$ + additional_dependencies: + - tomli + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.11.8 + hooks: + - id: ruff + exclude: core/tests + + - repo: https://github.com/hoodmane/pyscript-prettier-precommit + rev: "v3.0.0-alpha.6" + hooks: + - id: prettier + exclude: core/tests|core/dist|core/types|core/src/stdlib/pyscript.js|pyscript\.sw/|core/src/3rd-party + args: [--tab-width, "4"] diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000000..8251e101bf7 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +ISSUE_TEMPLATE +*.min.* +package-lock.json +bridge/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 14e7620f6e2..66e416d3162 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,4 +1,4 @@ # Code of Conduct -The Code of Conduct is available in the pyscript Governance repo. +The Code of Conduct is available in the PyScript Governance repo. See https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 32d32d36677..8ce2c517a45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,97 +1,4 @@ # Contributing to PyScript -Thank you for wanting to contribute to the PyScript project! - -## Table of contents - -* [Code of Conduct](#code-of-conduct) -* [Contributing](#contributing) - * [Reporting bugs](#reporting-bugs) - * [Reporting security issues](#reporting-security-issues) - * [Asking questions](#asking-questions) - * [Setting up your environment](#setting-up-your-environment) - * [Places to start](#places-to-start) - * [Submitting a change](#submitting-a-change) -* [License terms for contributions](#license-terms-for-contributions) -* [Becoming a maintainer](#becoming-a-maintainer) -* [Trademarks](#trademarks) - -## Code of Conduct - -The [PyScript Code of Conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md) governs the project and everyone participating in it. By participating, you are expected to uphold this code. Please report unacceptable behavior to the maintainers or administrators as described in that document. - -## Contributing - -### Reporting bugs - -Bugs are tracked on the [project issues page](https://github.com/pyscript/pyscript/issues). Please check if your issue has already been filed by someone else by searching the existing issues before filing a new one. Once your issue is filed, it will be triaged by another contributor or maintainer. If there are questions raised about your issue, please respond promptly. - -#### Creating useful issues - -* Use a clear and descriptive title. -* Describe the specific steps that reproduce the problem with as many details as possible so that someone can verify the issue. -* Describe the behavior you observed, and the behavior you had expected. -* Include screenshots if they help make the issue clear. - -### Reporting security issues - -If you aren't confident that it is appropriate to submit a security issue using the above process, you can e-mail it to security@pyscript.net - -### Asking questions - -If you have questions about the project, using PyScript, or anything else, please ask in the [PyScript forum](https://community.anaconda.cloud/c/tech-topics/pyscript). - -### Setting up your environment - -* clone the repo -``` - git clone https://github.com/pyscript/pyscript -``` -* cd into the main project folder -``` - cd pyscript/pyscriptjs -``` -* install the dependencies with npm install - make sure to use nodejs version >= 16 -``` - npm install -``` -* run npm run dev to build and run the dev server. This will also watch for changes and rebuild when a file is saved. -``` - npm run dev -``` - -### Places to start - -If you would like to contribute to PyScript, but you aren't sure where to begin, here are some suggestions. - -* **Read over the existing documentation.** Are there things missing, or could they be clearer? Make some changes/additions to those documents. -* **Review the open issues.** Are they clear? Can you reproduce them? You can add comments, clarifications, or additions to those issues. If you think you have an idea of how to address the issue, submit a fix! -* **Look over the open pull requests.** Do you have comments or suggestions for the proposed changes? Add them. -* **Check out the examples.** Is there a use case that would be good to have sample code for? Create an example for it. - -### Submitting a change - -All contributions must be licensed Apache 2.0, and all files must have a copy of the boilerplate license comment (can be copied from an existing file). - -To create a change for PyScript, you can follow the process described [here](https://docs.github.com/en/get-started/quickstart/contributing-to-projects). - -* Fork a personal copy of the PyScript project. -* Make the changes you would like (don't forget to test them!) -* Please squash all commits for a change into a single commit (this can be done using "git rebase -i"). Do your best to have a well-formed commit message for the change. -* Open a pull request back to the PyScript project and address any comments/questions from the maintainers and other contributors. - -## License terms for contributions - -This Project welcomes contributions, suggestions, and feedback. All contributions, suggestions, and feedback you submitted are accepted under the [Apache 2.0](./LICENSE) license. You represent that if you do not own copyright in the code that you have the authority to submit it under the [Apache 2.0](./LICENSE) license. All feedback, suggestions, or contributions are not confidential. - -## Becoming a maintainer - -Contributors are invited to be maintainers to the project by demonstrating good decision making in their contributions, a commitment to the goals of the project, and consistent adherence to the [code of conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md). New maintainers are invited by a 3/4 vote of the existing maintainers. - -## Trademarks - -The Project abides by the Organization's [trademark policy](https://github.com/pyscript/governance/blob/main/TRADEMARKS.md). - ---- -Part of MVG-0.1-beta. -Made with love by GitHub. Licensed under the [CC-BY 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/). +Please see our guide to contributing to PyScript +[in our documentation](https://docs.pyscript.net/latest/contributing/). diff --git a/GETTING-STARTED.md b/GETTING-STARTED.md deleted file mode 100644 index bb1e17220a0..00000000000 --- a/GETTING-STARTED.md +++ /dev/null @@ -1,210 +0,0 @@ -# Getting started with PyScript - -This page will guide you through getting started with PyScript. - -## Development setup - -PyScript does not require any development environment other -than a web browser. We recommend using [Chrome](https://www.google.com/chrome/). - -If you're using [VSCode](https://code.visualstudio.com/), the -[Live Server extension](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) -can be used to reload the page as you edit the HTML file. - -## Installation - -There is no installation required. In this document we'll use -the PyScript assets served on https://pyscript.net. - -If you want to download the source and build it yourself, follow -the instructions in the README.md file. - -## Your first PyScript HTML file - -Here's a "Hello, world!" example using PyScript. - -Using your favorite editor create a new file called `hello.html` in -the same directory as your PyScript, JavaScript, and CSS files with the -following content, and open the file in your web browser. You can typically -open an HTML by double clicking it in your file explorer. - -```html - -
- - - -Today is
-