mirror of
https://github.com/yt-dlp/ejs.git
synced 2026-06-19 19:51:19 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06d71457ef | ||
|
|
3e76dde153 | ||
|
|
4f1d91dbb1 | ||
|
|
4b4ac2b896 |
63
.github/workflows/ci.yml
vendored
63
.github/workflows/ci.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
|||||||
name: Ruff format check
|
name: Ruff format check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: astral-sh/ruff-action@v3
|
- uses: astral-sh/ruff-action@v3
|
||||||
with:
|
with:
|
||||||
args: "check --output-format github"
|
args: "check --output-format github"
|
||||||
@@ -32,7 +32,7 @@ jobs:
|
|||||||
name: Ruff linting check
|
name: Ruff linting check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: astral-sh/ruff-action@v3
|
- uses: astral-sh/ruff-action@v3
|
||||||
with:
|
with:
|
||||||
args: "format --check --diff"
|
args: "format --check --diff"
|
||||||
@@ -41,33 +41,33 @@ jobs:
|
|||||||
name: Prettier check
|
name: Prettier check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- name: Install Deno v2.x (latest)
|
- name: Install Deno v2.x (latest)
|
||||||
uses: denoland/setup-deno@v2
|
uses: denoland/setup-deno@v2
|
||||||
with:
|
with:
|
||||||
deno-version: v2.x
|
deno-version: v2.x
|
||||||
- name: Install Deno requirements
|
- name: Install requirements
|
||||||
run: |
|
run: |
|
||||||
deno install
|
python pnpm.py install --frozen-lockfile
|
||||||
- name: Run Prettier check
|
- name: Run Prettier check
|
||||||
run: |
|
run: |
|
||||||
deno task fmt:check
|
python pnpm.py fmt:check
|
||||||
|
|
||||||
eslint:
|
eslint:
|
||||||
name: ESLint check
|
name: ESLint check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- name: Install Deno v2.x (latest)
|
- name: Install Deno v2.x (latest)
|
||||||
uses: denoland/setup-deno@v2
|
uses: denoland/setup-deno@v2
|
||||||
with:
|
with:
|
||||||
deno-version: v2.x
|
deno-version: v2.x
|
||||||
- name: Install Deno requirements
|
- name: Install requirements
|
||||||
run: |
|
run: |
|
||||||
deno install
|
python pnpm.py install --frozen-lockfile
|
||||||
- name: Run ESLint check
|
- name: Run ESLint check
|
||||||
run: |
|
run: |
|
||||||
deno task lint
|
python pnpm.py lint
|
||||||
|
|
||||||
python_tests:
|
python_tests:
|
||||||
name: Python tests
|
name: Python tests
|
||||||
@@ -78,7 +78,7 @@ jobs:
|
|||||||
runner: [ubuntu-latest, windows-latest]
|
runner: [ubuntu-latest, windows-latest]
|
||||||
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', pypy-3.11]
|
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', pypy-3.11]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Install Deno v2.x (latest)
|
- name: Install Deno v2.x (latest)
|
||||||
@@ -112,17 +112,14 @@ jobs:
|
|||||||
name: Prepare JS runtime tests
|
name: Prepare JS runtime tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- name: Install Deno v2.x (latest)
|
- uses: pnpm/action-setup@v4 # respects packageManager version in package.json
|
||||||
uses: denoland/setup-deno@v2
|
- name: Install requirements
|
||||||
with:
|
|
||||||
deno-version: v2.x
|
|
||||||
- name: Install Deno requirements
|
|
||||||
run: |
|
run: |
|
||||||
deno install
|
python pnpm.py install --frozen-lockfile
|
||||||
- name: Build control bundle
|
- name: Build control bundle
|
||||||
run: |
|
run: |
|
||||||
deno task bundle
|
python pnpm.py run bundle
|
||||||
- name: Generate bundle hashes
|
- name: Generate bundle hashes
|
||||||
run: |
|
run: |
|
||||||
pushd dist
|
pushd dist
|
||||||
@@ -143,6 +140,10 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
src/yt/solver/test/players
|
src/yt/solver/test/players
|
||||||
key: test-player-js-${{ hashFiles('src/yt/solver/test/tests.ts') }}
|
key: test-player-js-${{ hashFiles('src/yt/solver/test/tests.ts') }}
|
||||||
|
- name: Install Deno v2.x (latest)
|
||||||
|
uses: denoland/setup-deno@v2
|
||||||
|
with:
|
||||||
|
deno-version: v2.x
|
||||||
- name: Download player JS files
|
- name: Download player JS files
|
||||||
run: |
|
run: |
|
||||||
deno run \
|
deno run \
|
||||||
@@ -165,7 +166,7 @@ jobs:
|
|||||||
needs: [prepare]
|
needs: [prepare]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Install Deno
|
- name: Install Deno
|
||||||
@@ -189,7 +190,7 @@ jobs:
|
|||||||
grep -q 'yt_dlp_ejs/yt/solver/lib\.min\.js' .wheel_contents
|
grep -q 'yt_dlp_ejs/yt/solver/lib\.min\.js' .wheel_contents
|
||||||
- name: Install Deno requirements
|
- name: Install Deno requirements
|
||||||
run: |
|
run: |
|
||||||
deno install
|
python pnpm.py install --frozen-lockfile
|
||||||
- name: Bundle with Deno
|
- name: Bundle with Deno
|
||||||
run: |
|
run: |
|
||||||
deno task bundle
|
deno task bundle
|
||||||
@@ -208,14 +209,14 @@ jobs:
|
|||||||
needs: [prepare]
|
needs: [prepare]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- name: Install Deno
|
- name: Install Deno
|
||||||
uses: denoland/setup-deno@v2
|
uses: denoland/setup-deno@v2
|
||||||
with:
|
with:
|
||||||
deno-version: "2.0.0" # minimum supported version
|
deno-version: "2.0.0" # minimum supported version
|
||||||
- name: Install Deno requirements
|
- name: Install Deno requirements
|
||||||
run: |
|
run: |
|
||||||
deno install
|
python pnpm.py install --frozen-lockfile
|
||||||
- name: Download player JS artifact
|
- name: Download player JS artifact
|
||||||
uses: actions/download-artifact@v5
|
uses: actions/download-artifact@v5
|
||||||
with:
|
with:
|
||||||
@@ -232,7 +233,7 @@ jobs:
|
|||||||
needs: [prepare]
|
needs: [prepare]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Install Bun
|
- name: Install Bun
|
||||||
@@ -256,7 +257,7 @@ jobs:
|
|||||||
grep -q 'yt_dlp_ejs/yt/solver/lib\.min\.js' .wheel_contents
|
grep -q 'yt_dlp_ejs/yt/solver/lib\.min\.js' .wheel_contents
|
||||||
- name: Install Bun requirements
|
- name: Install Bun requirements
|
||||||
run: |
|
run: |
|
||||||
bun install
|
python pnpm.py install --frozen-lockfile
|
||||||
- name: Bundle with Bun
|
- name: Bundle with Bun
|
||||||
run: |
|
run: |
|
||||||
bun --bun run bundle
|
bun --bun run bundle
|
||||||
@@ -275,14 +276,14 @@ jobs:
|
|||||||
needs: [prepare]
|
needs: [prepare]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- name: Install Bun
|
- name: Install Bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@v2
|
||||||
with:
|
with:
|
||||||
bun-version: "1.2.11" # XXX: We support 1.0.31, but test suite requires 1.2.11+
|
bun-version: "1.2.11" # XXX: We support 1.0.31, but test suite requires 1.2.11+
|
||||||
- name: Install Bun requirements
|
- name: Install Bun requirements
|
||||||
run: |
|
run: |
|
||||||
bun install
|
python pnpm.py install --frozen-lockfile
|
||||||
- name: Download player JS artifact
|
- name: Download player JS artifact
|
||||||
uses: actions/download-artifact@v5
|
uses: actions/download-artifact@v5
|
||||||
with:
|
with:
|
||||||
@@ -297,7 +298,7 @@ jobs:
|
|||||||
needs: [prepare]
|
needs: [prepare]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
@@ -321,7 +322,7 @@ jobs:
|
|||||||
grep -q 'yt_dlp_ejs/yt/solver/lib\.min\.js' .wheel_contents
|
grep -q 'yt_dlp_ejs/yt/solver/lib\.min\.js' .wheel_contents
|
||||||
- name: Install Node requirements
|
- name: Install Node requirements
|
||||||
run: |
|
run: |
|
||||||
npm install
|
python pnpm.py install --frozen-lockfile
|
||||||
- name: Bundle with Node
|
- name: Bundle with Node
|
||||||
run: |
|
run: |
|
||||||
npm run bundle
|
npm run bundle
|
||||||
@@ -340,14 +341,14 @@ jobs:
|
|||||||
needs: [prepare]
|
needs: [prepare]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: "22.18" # XXX: We support 20.0, but test suite requires 22.18+
|
node-version: "22.18" # XXX: We support 20.0, but test suite requires 22.18+
|
||||||
- name: Install Node requirements
|
- name: Install Node requirements
|
||||||
run: |
|
run: |
|
||||||
npm install
|
python pnpm.py install --frozen-lockfile
|
||||||
- name: Download player JS artifact
|
- name: Download player JS artifact
|
||||||
uses: actions/download-artifact@v5
|
uses: actions/download-artifact@v5
|
||||||
with:
|
with:
|
||||||
|
|||||||
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
|||||||
name: Build artifacts
|
name: Build artifacts
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: denoland/setup-deno@v2
|
- uses: denoland/setup-deno@v2
|
||||||
@@ -37,7 +37,7 @@ jobs:
|
|||||||
compression-level: 0
|
compression-level: 0
|
||||||
- name: Build JavaScript artifacts
|
- name: Build JavaScript artifacts
|
||||||
run: |
|
run: |
|
||||||
deno install --frozen
|
python pnpm.py install --frozen-lockfile
|
||||||
deno task bundle
|
deno task bundle
|
||||||
- name: Upload JavaScript artifacts
|
- name: Upload JavaScript artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
@@ -73,7 +73,7 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: actions/download-artifact@v5
|
- uses: actions/download-artifact@v5
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,6 +3,7 @@
|
|||||||
/yt_dlp_ejs/_version.py
|
/yt_dlp_ejs/_version.py
|
||||||
/node_modules
|
/node_modules
|
||||||
/bun.lock
|
/bun.lock
|
||||||
|
/deno.lock
|
||||||
/package-lock.json
|
/package-lock.json
|
||||||
/.idea
|
/.idea
|
||||||
/.venv
|
/.venv
|
||||||
|
|||||||
33
README.md
33
README.md
@@ -12,9 +12,13 @@ pip install -U yt-dlp-ejs
|
|||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
While this project does pin its dependencies,
|
The project uses [`pnpm`](<https://github.com/pnpm/pnpm>) as a package manager with
|
||||||
it only provides a lockfile for building with `deno`.
|
dependencies pinned through `pnpm-lock.yaml`.
|
||||||
You may install dependencies using any compatible package manager.
|
|
||||||
|
If you only have Python and a JS runtime you may instead invoke `./pnpm.py`,
|
||||||
|
which will transparently invoke one of the supported JS runtimes to call `pnpm`.
|
||||||
|
|
||||||
|
This pure JavaScript approach should be runtime agnostic.
|
||||||
If you notice differences between different runtimes' builds
|
If you notice differences between different runtimes' builds
|
||||||
please open an issue [here](<https://github.com/yt-dlp/ejs/issues/new>).
|
please open an issue [here](<https://github.com/yt-dlp/ejs/issues/new>).
|
||||||
|
|
||||||
@@ -26,34 +30,27 @@ The build hook will automatically invoke `deno`, `bun` or `node` as required.
|
|||||||
Alternatively, to only build the JavaScript files you can run the `bundle` script manually:
|
Alternatively, to only build the JavaScript files you can run the `bundle` script manually:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Deno:
|
python pnpm.py install --frozen-lockfile
|
||||||
deno install --frozen
|
python pnpm.py run bundle
|
||||||
deno task bundle
|
|
||||||
|
|
||||||
# Bun:
|
|
||||||
bun install
|
|
||||||
bun --bun run bundle
|
|
||||||
|
|
||||||
# Node:
|
|
||||||
npm install
|
|
||||||
npm run bundle
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This will automatically select an available runtime and invoke `pnpm` to build it.
|
||||||
|
|
||||||
### Tests
|
### Tests
|
||||||
|
|
||||||
First, make sure the project's dependencies are installed and download the player JS files:
|
First, make sure the project's dependencies are installed and download the player JS files:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Deno:
|
# Deno:
|
||||||
deno install --frozen
|
python pnpm.py install --frozen-lockfile
|
||||||
deno run src/yt/solver/test/download.ts
|
deno run src/yt/solver/test/download.ts
|
||||||
|
|
||||||
# Bun:
|
# Bun:
|
||||||
bun install
|
python pnpm.py install --frozen-lockfile
|
||||||
bun --bun run src/yt/solver/test/download.ts
|
bun --bun run src/yt/solver/test/download.ts
|
||||||
|
|
||||||
# Node 22.6+:
|
# Node 22.6+:
|
||||||
npm install
|
python pnpm.py install --frozen-lockfile
|
||||||
node --experimental-strip-types src/yt/solver/test/download.ts
|
node --experimental-strip-types src/yt/solver/test/download.ts
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -74,6 +71,6 @@ node --test
|
|||||||
|
|
||||||
This code is licensed under [Unlicense](<https://unlicense.org/>).
|
This code is licensed under [Unlicense](<https://unlicense.org/>).
|
||||||
|
|
||||||
An exception to this are the prebuilt wheels, which contain both
|
An exception to this is the prebuilt wheels, which contain both
|
||||||
[`meriyah`](<https://github.com/meriyah/meriyah>) and [`astring`](<https://github.com/davidbonnet/astring>),
|
[`meriyah`](<https://github.com/meriyah/meriyah>) and [`astring`](<https://github.com/davidbonnet/astring>),
|
||||||
licensed under [`ISC`](<https://github.com/meriyah/meriyah?tab=ISC-1-ov-file>) and [`MIT`](<https://github.com/davidbonnet/astring?tab=MIT-1-ov-file>), respectively.
|
licensed under [`ISC`](<https://github.com/meriyah/meriyah?tab=ISC-1-ov-file>) and [`MIT`](<https://github.com/davidbonnet/astring?tab=MIT-1-ov-file>), respectively.
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
import os
|
|
||||||
import shutil
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
|
||||||
|
|
||||||
|
|
||||||
class CustomBuildHook(BuildHookInterface):
|
|
||||||
def initialize(self, version, build_data):
|
|
||||||
if shutil.which("deno"):
|
|
||||||
print("Building with deno...", flush=True)
|
|
||||||
os.environ["DENO_NO_UPDATE_CHECK"] = "1"
|
|
||||||
subprocess.run(["deno", "install", "--frozen"], check=True)
|
|
||||||
subprocess.run(["deno", "task", "bundle"], check=True)
|
|
||||||
|
|
||||||
elif shutil.which("bun"):
|
|
||||||
print("Building with bun...", flush=True)
|
|
||||||
subprocess.run(["bun", "install"], check=True)
|
|
||||||
subprocess.run(["bun", "--bun", "run", "bundle"], check=True)
|
|
||||||
|
|
||||||
elif shutil.which("npm"):
|
|
||||||
print("Building with npm...", flush=True)
|
|
||||||
# npm is a batch file (`npm.cmd`) on windows, which requires `shell=True`
|
|
||||||
requires_shell = os.name == "nt"
|
|
||||||
subprocess.run(["npm", "install"], check=True, shell=requires_shell)
|
|
||||||
subprocess.run(["npm", "run", "bundle"], check=True, shell=requires_shell)
|
|
||||||
|
|
||||||
else:
|
|
||||||
raise RuntimeError(
|
|
||||||
"One of 'deno', 'bun', or 'npm' could not be found. "
|
|
||||||
"Please install one of them to proceed with the build."
|
|
||||||
)
|
|
||||||
|
|
||||||
build_data["force_include"].update(
|
|
||||||
{
|
|
||||||
"dist/yt.solver.core.min.js": "yt_dlp_ejs/yt/solver/core.min.js",
|
|
||||||
"dist/yt.solver.lib.min.js": "yt_dlp_ejs/yt/solver/lib.min.js",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
def clean(self, versions):
|
|
||||||
shutil.rmtree("node_modules", ignore_errors=True)
|
|
||||||
@@ -25,5 +25,6 @@
|
|||||||
"rollup": "4.52.5",
|
"rollup": "4.52.5",
|
||||||
"rollup-plugin-license": "3.6.0",
|
"rollup-plugin-license": "3.6.0",
|
||||||
"typescript-eslint": "8.46.2"
|
"typescript-eslint": "8.46.2"
|
||||||
}
|
},
|
||||||
|
"packageManager": "pnpm@10.24.0"
|
||||||
}
|
}
|
||||||
|
|||||||
1782
pnpm-lock.yaml
generated
Normal file
1782
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
90
pnpm.py
Executable file
90
pnpm.py
Executable file
@@ -0,0 +1,90 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
try:
|
||||||
|
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
||||||
|
except ImportError:
|
||||||
|
BuildHookInterface = object
|
||||||
|
|
||||||
|
|
||||||
|
class CustomBuildHook(BuildHookInterface):
|
||||||
|
def initialize(self, version, build_data):
|
||||||
|
name, pnpm = build_pnpm()
|
||||||
|
if pnpm is None:
|
||||||
|
raise RuntimeError(
|
||||||
|
"One of 'deno', 'bun', or 'npm' could not be found. "
|
||||||
|
"Please install one of them to proceed with the build."
|
||||||
|
)
|
||||||
|
print(f"Building with {name}...")
|
||||||
|
|
||||||
|
pnpm(["install", "--frozen-lockfile"])
|
||||||
|
pnpm(["run", "bundle"])
|
||||||
|
|
||||||
|
build_data["force_include"].update(
|
||||||
|
{
|
||||||
|
"dist/yt.solver.core.min.js": "yt_dlp_ejs/yt/solver/core.min.js",
|
||||||
|
"dist/yt.solver.lib.min.js": "yt_dlp_ejs/yt/solver/lib.min.js",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def clean(self, versions):
|
||||||
|
shutil.rmtree("node_modules", ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
|
def build_pnpm():
|
||||||
|
package_json = pathlib.Path(__file__).with_name("package.json")
|
||||||
|
with package_json.open("rb") as file:
|
||||||
|
data = json.load(file)
|
||||||
|
|
||||||
|
package_manager = data["packageManager"]
|
||||||
|
env = os.environ.copy()
|
||||||
|
|
||||||
|
if pnpm := shutil.which("pnpm"):
|
||||||
|
name = "pnpm binary"
|
||||||
|
cmd = [pnpm]
|
||||||
|
|
||||||
|
elif deno := shutil.which("deno"):
|
||||||
|
name = "deno"
|
||||||
|
env["DENO_NO_UPDATE_CHECK"] = "1"
|
||||||
|
cmd = [
|
||||||
|
deno,
|
||||||
|
"run",
|
||||||
|
"--allow-all",
|
||||||
|
"--node-modules-dir=none",
|
||||||
|
f"npm:{package_manager}",
|
||||||
|
]
|
||||||
|
|
||||||
|
elif bun := shutil.which("bun"):
|
||||||
|
name = "bun"
|
||||||
|
cmd = [bun, "x", package_manager]
|
||||||
|
|
||||||
|
elif npm := shutil.which("npm"):
|
||||||
|
name = "npm (node)"
|
||||||
|
cmd = [npm, "exec", "--", package_manager]
|
||||||
|
|
||||||
|
else:
|
||||||
|
return None, None
|
||||||
|
|
||||||
|
def run_pnpm(args: list[str]):
|
||||||
|
return subprocess.check_call([*cmd, *args], env=env)
|
||||||
|
|
||||||
|
return name, run_pnpm
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import sys
|
||||||
|
|
||||||
|
name, pnpm = build_pnpm()
|
||||||
|
if pnpm is None:
|
||||||
|
print("ERROR: No suitable JavaScript runtime found", file=sys.stderr)
|
||||||
|
sys.exit(128)
|
||||||
|
print(f"Calling {name}...", file=sys.stderr)
|
||||||
|
|
||||||
|
try:
|
||||||
|
pnpm(sys.argv[1:])
|
||||||
|
except subprocess.CalledProcessError as error:
|
||||||
|
sys.exit(error.returncode)
|
||||||
@@ -47,6 +47,7 @@ source = "vcs"
|
|||||||
exclude = [
|
exclude = [
|
||||||
"/.github/**",
|
"/.github/**",
|
||||||
"/src/yt/solver/test/players/*",
|
"/src/yt/solver/test/players/*",
|
||||||
|
"!/src/yt/solver/test/players/.gitignore",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.hatch.build.targets.wheel]
|
[tool.hatch.build.targets.wheel]
|
||||||
@@ -56,6 +57,7 @@ packages = ["yt_dlp_ejs"]
|
|||||||
version-file = "yt_dlp_ejs/_version.py"
|
version-file = "yt_dlp_ejs/_version.py"
|
||||||
|
|
||||||
[tool.hatch.build.targets.wheel.hooks.custom]
|
[tool.hatch.build.targets.wheel.hooks.custom]
|
||||||
|
path = "pnpm.py"
|
||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
select = [
|
select = [
|
||||||
|
|||||||
Reference in New Issue
Block a user