Skip to content

Commit

Permalink
refactor!: cleanup platform support (#306)
Browse files Browse the repository at this point in the history
* refactor!: cleanup platform support

* chore: lint

* fix: web platform

* feat: provide UniversalCache

Provide UniversalCache as a wrapper around Platform.shim.Cache.

* fix: invalid import

* refactor: remove isolated-vm support

* fix: type info

* refactor: cleanup exports

* fix: mark jintr as external dependency

In the bundled CJS node build, mark jintr as external.

* chore: add additional exports

web exports provide a way to select web implementation manually without
relying on the bundler to select it correctly from the "exports" field

web points to src/platform/web.js
web.bundle points to bundle/browser.js
web.bundle.browser points to bundle/browser.min.js

agnostic exports provide users of the library to provide their own
platform implementation without first importing the default one.

agnostic points to src/platform/lib.ts

* fix: toDash on web

* revert: eval is synchronous

* fix: use serializeDOM in FormatUtils

* ci: automate releases with `release-please`

* chore: clean up workflow files

* ci: fix NPM publish action

---------

Co-authored-by: LuanRT <[email protected]>
  • Loading branch information
Wykerd and LuanRT authored Feb 12, 2023
1 parent a69e43b commit 2ccbe2c
Show file tree
Hide file tree
Showing 504 changed files with 11,293 additions and 6,388 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ cache/
src/proto/youtube.ts
coverage/
node_modules/
dist/
dist/
src/proto/generated/
8 changes: 1 addition & 7 deletions .github/labeler_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ version: 1
labels:
- label: "breaking-change"
title: "^refactor!:.*"

- label: "enhancement"
title: "^feat:.*"

- label: "bug"
title: "^fix:.*"


- label: "github"
files:
- ".github/.*"
Expand Down
20 changes: 0 additions & 20 deletions .github/release.yml

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: srvaroa/labeler@master
with:
Expand Down
25 changes: 13 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: Lint
name: lint

on: [push, pull_request]
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
eslint:
name: Lint
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3

- name: npm install and lint
run: |
npm install
npm run lint
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm ci
- run: npm run lint
26 changes: 0 additions & 26 deletions .github/workflows/node.js.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: release-please

on:
push:
branches:
- main

jobs:
release-please:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
package-name: youtubei.js
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "16.x"
- name: Build for Deno
run: |
npm ci
npm run build:deno
if: ${{ steps.release.outputs.release_created }}
- name: Move Deno files
run: |
mkdir build
mv deno build/deno
cp deno.ts build/deno.ts
cp {LICENSE,README.md} build
if: ${{ steps.release.outputs.release_created }}
- name: Push to the Deno branch
uses: s0/git-publish-subdir-action@develop
env:
REPO: self
BRANCH: deno
FOLDER: ./build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SKIP_EMPTY_COMMITS: true
MESSAGE: "chore: ${{ steps.release.outputs.tag_name }} release"
TAG: ${{ steps.release.outputs.tag_name }}-deno
if: ${{ steps.release.outputs.release_created }}
- name: Remove Deno folder
run: rm -rf build
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@v3
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
if: ${{ steps.release.outputs.release_created }}
- name: Publish package to npmjs
run: |
npm ci
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ steps.release.outputs.release_created }}
4 changes: 1 addition & 3 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ jobs:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.'
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
stale-pr-message: 'This PR has been automatically marked as stale because it has not had recent activity. Remove the stale label or comment or this will be closed in 2 days'
days-before-stale: 60
days-before-close: 4
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm ci
- run: npm run test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ tmp/
dist/
bundle/*.js.*
bundle/*.js
bundle/*.cjs
bundle/*.cjs.*
deno/

# MacOS
.DS_Store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ yarn add youtubei.js@latest
npm install github:LuanRT/YouTube.js
```

**TODO:** Deno install instructions (esm.sh possibly?)
**TODO:** Deno install instructions (deno.land)

## Usage
Create an InnerTube instance:
Expand Down
11 changes: 0 additions & 11 deletions browser.ts

This file was deleted.

2 changes: 1 addition & 1 deletion bundle/browser.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from '../dist/browser';
export * from '../dist/src/platform/lib.js';
1 change: 1 addition & 0 deletions bundle/node.d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../dist/src/platform/lib.js';
3 changes: 3 additions & 0 deletions deno.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './deno/src/platform/deno.ts';
import Innertube from './deno/src/platform/deno.ts';
export default Innertube;
28 changes: 0 additions & 28 deletions index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


module.exports = {
export default {
projects: [
{
displayName: 'node',
Expand Down
Loading

0 comments on commit 2ccbe2c

Please sign in to comment.