Skip to content

Commit

Permalink
Merge pull request #23 from versatica/modernize
Browse files Browse the repository at this point in the history
Modernize
  • Loading branch information
ibc authored Sep 15, 2023
2 parents 8c28003 + 18af7c3 commit 0bc25ef
Show file tree
Hide file tree
Showing 48 changed files with 12,195 additions and 2,734 deletions.
90 changes: 45 additions & 45 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
const os = require('os');

const isWindows = os.platform() === 'win32';

const eslintConfig =
{
env :
{
es6 : true,
node : true
browser : true,
es6 : true,
node : true
},
plugins : [],
settings : {},
parserOptions :
{
ecmaVersion : 2018,
ecmaVersion : 2022,
sourceType : 'module',
ecmaFeatures :
{
impliedStrict : true
},
lib : [ 'es2018', 'dom' ]
lib : [ 'es2022', 'dom' ],
project : 'tsconfig.json'
},
rules :
{
Expand All @@ -35,6 +41,7 @@ const eslintConfig =
'comma-style' : 2,
'computed-property-spacing' : 2,
'constructor-super' : 2,
'curly' : [ 2, 'all' ],
'func-call-spacing' : 2,
'generator-star-spacing' : 2,
'guard-for-in' : 2,
Expand All @@ -50,12 +57,13 @@ const eslintConfig =
{
beforeColon : true,
afterColon : true,
mode : 'minimum',
align : 'colon'
}
}
],
'keyword-spacing' : 2,
'linebreak-style' : [ 2, 'unix' ],
'linebreak-style' : [ 2, isWindows ? 'windows' : 'unix' ],
'lines-around-comment' : [ 2,
{
allowBlockStart : true,
Expand Down Expand Up @@ -171,70 +179,62 @@ const eslintConfig =
'strict' : 2,
'valid-typeof' : 2,
'yoda' : 2
}
},
overrides : []
};

switch (process.env.MEDIASOUP_NODE_LANGUAGE)
{
case 'typescript':
eslintConfig.overrides.push(
{
eslintConfig.parser = '@typescript-eslint/parser';
eslintConfig.plugins =
[
files : [ '*.ts' ],
parser : '@typescript-eslint/parser',
plugins : [
...eslintConfig.plugins,
'@typescript-eslint'
];
eslintConfig.extends =
[
],
extends : [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended'
];
eslintConfig.rules =
{
],
rules : {
...eslintConfig.rules,
'camelcase' : 0,
'no-unused-vars' : 0,
'@typescript-eslint/ban-ts-comment' : 0,
'@typescript-eslint/ban-ts-ignore' : 0,
'@typescript-eslint/member-delimiter-style' : [ 2,
'no-unused-vars' : 0,
'@typescript-eslint/ban-types' : 0,
'@typescript-eslint/ban-ts-comment' : 0,
'@typescript-eslint/ban-ts-ignore' : 0,
'@typescript-eslint/explicit-module-boundary-types' : 0,
'@typescript-eslint/semi' : 2,
'@typescript-eslint/member-delimiter-style' : [ 2,
{
multiline : { delimiter: 'semi', requireLast: true },
singleline : { delimiter: 'semi', requireLast: false }
}
],
'@typescript-eslint/no-empty-function' : 0,
'@typescript-eslint/no-explicit-any' : 0,
'@typescript-eslint/no-unused-vars' : [ 2,
'@typescript-eslint/no-explicit-any' : 0,
'@typescript-eslint/no-unused-vars' : [ 2,
{
vars : 'all',
args : 'after-used',
ignoreRestSiblings : false
}
],
'@typescript-eslint/no-use-before-define' : 0,
'@typescript-eslint/no-use-before-define' : [ 2, { functions: false } ],
'@typescript-eslint/no-empty-function' : 0,
'@typescript-eslint/no-non-null-assertion' : 0
};

break;
}
}
});

case 'javascript':
eslintConfig.overrides.push(
{
eslintConfig.env['jest/globals'] = true;
eslintConfig.plugins =
[
files : [ '*.ts' ],
env : {
...eslintConfig.env,
'jest/globals' : true
},
plugins : [
...eslintConfig.plugins,
'jest'
];

break;
}

default:
{
throw new TypeError('wrong/missing MEDIASOUP_NODE_LANGUAGE env');
}
}
]
});

module.exports = eslintConfig;
45 changes: 45 additions & 0 deletions .github/workflows/mediasoup-client-aiortc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: mediasoup-client-aiortc

on: [push, pull_request]

concurrency:
# Cancel a currently running workflow from the same PR, branch or tag when a
# new workflow is triggered.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
ci:
strategy:
matrix:
# Different Node versions on Ubuntu, the latest Node on other platforms.
ci:
- os: ubuntu-22.04
node: 16
- os: macos-12
node: 18
runs-on: ${{ matrix.ci.os }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.ci.node }}

- name: Configure cache
uses: actions/cache@v3
with:
path: |
~/.npm
key: ${{ matrix.ci.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ matrix.ci.os }}-node-
- run: npm ci
- run: npm run install-python-dev-deps
# NOTE: Avoid lint:python due to
# https://github.com/versatica/mediasoup-client-aiortc/issues/25
- run: npm run lint:node
- run: npm run test
18 changes: 11 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules/
/coverage/
/node_modules
/lib
/coverage

# Vim temporal files.
*.swp
Expand All @@ -9,9 +10,12 @@
.DS_Store

# Vistual Studio Code stuff.
/.vscode/
/.vscode

# Python cache
/.mypy_cache/
/worker/__pycache__/
/worker/.mypy_cache/
# Cache.
.mypy_cache
/.cache
/.mypy_cache
/worker/__pycache__
/worker/build
/worker/mediasoup_client_aiortc.egg-info
5 changes: 4 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
package-lock=false
# Generate package-lock.json.
package-lock=true
# For bad node/npm version to throw actual error.
engine-strict=true
36 changes: 29 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ Once the requirements above are satisfied, install **mediasoup-client-aiortc** w
$ npm install --save mediasoup-client-aiortc
```

The "postinstall" script in `package.json` will install the Python libraries (including **aiortc**) by using `pip3` command. If such a command is not in the `PATH` or has a different name in your system, you can override its location by setting the `PIP3` environment variable:
The "postinstall" script in `package.json` will install the Python libraries (including **aiortc**) by using `pip3` command. If such a command is not in the `PATH` or has a different name in your system, you can override its location by setting the `PIP` environment variable:

```bash
$ PIP3=/home/me/bin/pip npm install --save mediasoup-client-aiortc
$ PIP=/home/me/bin/pip npm install --save mediasoup-client-aiortc
```

Once you run your Node.js application, **mediasoup-client-aiortc** will eventually spawn Python processes and communicate with them via `UnixSocket`. This module assumes that there is a `python3` executable in your `PATH` to spawn the Python executable. If not, you can override its location by setting the `PYTHON3` environment variable:
Once you run your Node.js application, **mediasoup-client-aiortc** will eventually spawn Python processes and communicate with them via `UnixSocket`. This module assumes that there is a `python3` executable in your `PATH` to spawn the Python executable. If not, you can override its location by setting the `PYTHON` environment variable:

```bash
$ PYTHON3=/home/me/bin/python-3.7 node my_app.js
$ PYTHON=/home/me/bin/python-3.7 node my_app.js
```


Expand Down Expand Up @@ -261,12 +261,34 @@ In order to run `npm run lint` task, the following Python dependencies are requi
- `flake8` >= 5.0.4
- `mypy` >= 0.982
Install them with `pip` command:
```bash
$ pip3 install flake8==5.0.4 mypy==0.982
$ npm run install-python-dev-deps
```
### Issue with Python >= 3.11
See https://github.com/versatica/mediasoup-client-aiortc/issues/22.
As a workaround:
1. Install `python@3.10`.
2. Make `PYTHON` environment variable point to it:
```bash
export PYTHON=python3.10
```
3. Make `PIP` environment variable point to `[email protected]`:
```bash
export PIP=pip3.10
```
4. Install deps:
```bash
npm ci
```
5. Run tests:
```bash
npm test
```


## Caveats

Expand Down
25 changes: 0 additions & 25 deletions lib/AiortcMediaStream.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion lib/AiortcMediaStream.d.ts.map

This file was deleted.

73 changes: 0 additions & 73 deletions lib/AiortcMediaStream.js

This file was deleted.

Loading

0 comments on commit 0bc25ef

Please sign in to comment.