Skip to content

Commit

Permalink
Merge branch 'feature/esm-and-nx' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobozzz committed Aug 17, 2023
2 parents a8ca619 + 3a49926 commit c380e39
Show file tree
Hide file tree
Showing 2,711 changed files with 93,135 additions and 92,019 deletions.
23 changes: 13 additions & 10 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extends": "standard-with-typescript",
"root": true,
"rules": {
"eol-last": [
"error",
Expand Down Expand Up @@ -126,18 +127,20 @@
]
},
"ignorePatterns": [
"node_modules/",
"server/tests/fixtures"
"node_modules",
"packages/tests/fixtures",
"apps/**/dist",
"packages/**/dist",
"server/dist",
"packages/types-generator/tests",
"*.js",
"/client",
"/dist"
],
"parserOptions": {
"EXPERIMENTAL_useSourceOfProjectReferenceRedirect": true,
"project": [
"./tsconfig.json",
"./shared/tsconfig.json",
"./scripts/tsconfig.json",
"./server/tsconfig.json",
"./server/tools/tsconfig.json",
"./packages/peertube-runner/tsconfig.json"
]
"./tsconfig.eslint.json"
],
"EXPERIMENTAL_useSourceOfProjectReferenceRedirect": true
}
}
31 changes: 17 additions & 14 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,25 @@ interested in, user interface, design, decentralized architecture...
You can help to write the documentation of the REST API, code, architecture,
demonstrations.

For the REST API you can see the documentation in [/support/doc/api](https://github.com/Chocobozzz/PeerTube/tree/develop/support/doc/api) directory.
Then, you can just open the `openapi.yaml` file in a special editor like [http://editor.swagger.io/](http://editor.swagger.io/) to easily see and edit the documentation. You can also use [redoc-cli](https://github.com/Redocly/redoc/blob/master/cli/README.md) and run `redoc-cli serve --watch support/doc/api/openapi.yaml` to see the final result.
### User documentation

The official user documentation is available on https://docs.joinpeertube.org/

You can update it by writing markdown files in the following repository: https://framagit.org/framasoft/peertube/documentation/

### REST API documentation

The [REST API documentation](https://docs.joinpeertube.org/api-rest-reference.html) is generated from `support/doc/api/openapi.yaml` file.
To quickly get a preview of your changes, you can generate the documentation *on the fly* using the following command:

```
npx @redocly/cli preview-docs ./support/doc/api/openapi.yaml
```

Some hints:
* Routes are defined in [/server/controllers/](https://github.com/Chocobozzz/PeerTube/tree/develop/server/controllers) directory
* Parameters validators are defined in [/server/middlewares/validators](https://github.com/Chocobozzz/PeerTube/tree/develop/server/middlewares/validators) directory
* Models sent/received by the controllers are defined in [/shared/models](https://github.com/Chocobozzz/PeerTube/tree/develop/shared/models) directory
* Routes are defined in [/server/server/controllers/](https://github.com/Chocobozzz/PeerTube/tree/develop/server/server/controllers) directory
* Parameters validators are defined in [/server/server/middlewares/validators](https://github.com/Chocobozzz/PeerTube/tree/develop/server/server/middlewares/validators) directory
* Models sent/received by the controllers are defined in [/packages/models](https://github.com/Chocobozzz/PeerTube/tree/develop/packages/models) directory


## Improve the website
Expand Down Expand Up @@ -242,15 +254,6 @@ To test emails with PeerTube:
* Run [mailslurper](http://mailslurper.com/)
* Run PeerTube using mailslurper SMTP port: `NODE_CONFIG='{ "smtp": { "hostname": "localhost", "port": 2500, "tls": false } }' NODE_ENV=dev node dist/server`

### OpenAPI documentation

The [REST API documentation](https://docs.joinpeertube.org/api-rest-reference.html) is generated from `support/doc/api/openapi.yaml` file.
To quickly get a preview of your changes, you can generate the documentation *on the fly* using the following command:

```
npx @redocly/cli preview-docs ./support/doc/api/openapi.yaml
```

### Environment variables

PeerTube can be configured using environment variables.
Expand Down
10 changes: 9 additions & 1 deletion .github/actions/reusable-prepare-peertube-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@ runs:

- name: Install peertube runner dependencies
shell: bash
run: cd packages/peertube-runner && yarn install --frozen-lockfile
run: cd apps/peertube-runner && yarn install --frozen-lockfile

- name: Install peertube CLI dependencies
shell: bash
run: cd apps/peertube-cli && yarn install --frozen-lockfile

- name: Display PeerTube dependencies
shell: bash
run: ls -l node_modules/@peertube
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Run benchmark
run: |
node dist/scripts/benchmark.js -o benchmark.json
npm run benchmark-server -- -o benchmark.json
- name: Display result
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "PeerTube CodeQL config"

paths-ignore:
- server/tests
- packages/tests
4 changes: 2 additions & 2 deletions .github/workflows/stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ jobs:
run: |
wget "https://github.com/boyter/scc/releases/download/v3.0.0/scc-3.0.0-x86_64-unknown-linux.zip"
unzip "scc-3.0.0-x86_64-unknown-linux.zip"
./scc --format=json --exclude-dir .git,node_modules,client/node_modules,client/dist,dist,yarn.lock,client/yarn.lock,client/src/locale,test1,test2,test3,client/src/assets/images,config,storage,server/tests/fixtures,support/openapi,.idea,.vscode,docker-volume,ffmpeg-3,ffmpeg-4 > ./scc.json
./scc --format=json --exclude-dir .git,node_modules,client/node_modules,client/dist,dist,yarn.lock,client/yarn.lock,client/src/locale,test1,test2,test3,client/src/assets/images,config,storage,packages/tests/fixtures,support/openapi,.idea,.vscode,docker-volume,ffmpeg-3,ffmpeg-4 > ./scc.json
- name: PeerTube client stats
if: github.event_name != 'pull_request'
run: |
node dist/scripts/client-build-stats.js > client-build-stats.json
npm run client:build-stats > client-build-stats.json
- name: PeerTube client lighthouse report
if: github.event_name != 'pull_request'
Expand Down
16 changes: 9 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# NPM instalation
/node_modules/
/server/tools/node_modules
node_modules
*npm-debug.log
yarn-error.log
.yarn

# Testing
/test1/
Expand All @@ -11,8 +11,8 @@ yarn-error.log
/test4/
/test5/
/test6/
/server/tests/fixtures/video_high_bitrate_1080p.mp4
/server/tests/fixtures/video_59fps.mp4
/packages/tests/fixtures/video_high_bitrate_1080p.mp4
/packages/tests/fixtures/video_59fps.mp4

# Production
/storage
Expand Down Expand Up @@ -49,12 +49,14 @@ yarn-error.log
/*.tar.xz
/*.asc
*.DS_Store
/server/tools/import-mediacore.ts
/docker-volume/
/init.mp4

# TypeScript
*.tsbuildinfo

# Packages
/packages/types/dist/
# EsLint
.eslintcache

# Compiled output
dist
10 changes: 10 additions & 0 deletions .mocharc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
process.env.ESBK_TSCONFIG_PATH = './packages/tests/tsconfig.json'

module.exports = {
"node-option": [
"loader=tsx",
"no-warnings",
"conditions=peertube:tsx"
],
"timeout": 30000
}
4 changes: 4 additions & 0 deletions apps/peertube-cli/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src
meta.json
tsconfig.json
scripts
43 changes: 43 additions & 0 deletions apps/peertube-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# PeerTube CLI

## Usage

See https://docs.joinpeertube.org/maintain/tools#remote-tools

## Dev

## Install dependencies

```bash
cd peertube-root
yarn install --pure-lockfile
cd apps/peertube-cli && yarn install --pure-lockfile
```

## Develop

```bash
cd peertube-root
npm run dev:peertube-cli
```

## Build

```bash
cd peertube-root
npm run build:peertube-cli
```

## Run

```bash
cd peertube-root
node apps/peertube-cli/dist/peertube-cli.js --help
```

## Publish on NPM

```bash
cd peertube-root
(cd apps/peertube-cli && npm version patch) && npm run build:peertube-cli && (cd apps/peertube-cli && npm publish --access=public)
```
19 changes: 19 additions & 0 deletions apps/peertube-cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@peertube/peertube-cli",
"version": "1.0.1",
"type": "module",
"main": "dist/peertube.js",
"bin": "dist/peertube.js",
"engines": {
"node": ">=16.x"
},
"scripts": {},
"license": "AGPL-3.0",
"private": false,
"devDependencies": {
"application-config": "^2.0.0",
"cli-table3": "^0.6.0",
"netrc-parser": "^3.1.6"
},
"dependencies": {}
}
27 changes: 27 additions & 0 deletions apps/peertube-cli/scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as esbuild from 'esbuild'
import { readFileSync } from 'fs'

const packageJSON = JSON.parse(readFileSync(new URL('../package.json', import.meta.url)))

export const esbuildOptions = {
entryPoints: [ './src/peertube.ts' ],
bundle: true,
platform: 'node',
format: 'esm',
target: 'node16',
external: [
'./lib-cov/fluent-ffmpeg',
'pg-hstore'
],
outfile: './dist/peertube.js',
banner: {
js: `const require = (await import("node:module")).createRequire(import.meta.url);` +
`const __filename = (await import("node:url")).fileURLToPath(import.meta.url);` +
`const __dirname = (await import("node:path")).dirname(__filename);`
},
define: {
'process.env.PACKAGE_VERSION': `'${packageJSON.version}'`
}
}

await esbuild.build(esbuildOptions)
7 changes: 7 additions & 0 deletions apps/peertube-cli/scripts/watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as esbuild from 'esbuild'
import { esbuildOptions } from './build.js'

const context = await esbuild.context(esbuildOptions)

// Enable watch mode
await context.watch()
Loading

0 comments on commit c380e39

Please sign in to comment.