diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-31 14:34:36 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-08-11 15:02:33 +0200 |
commit | 3a4992633ee62d5edfbb484d9c6bcb3cf158489d (patch) | |
tree | e4510b39bdac9c318fdb4b47018d08f15368b8f0 /.github | |
parent | 04d1da5621d25d59bd5fa1543b725c497bf5d9a8 (diff) | |
download | PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.gz PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.zst PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.zip |
Migrate server to ESM
Sorry for the very big commit that may lead to git log issues and merge
conflicts, but it's a major step forward:
* Server can be faster at startup because imports() are async and we can
easily lazy import big modules
* Angular doesn't seem to support ES import (with .js extension), so we
had to correctly organize peertube into a monorepo:
* Use yarn workspace feature
* Use typescript reference projects for dependencies
* Shared projects have been moved into "packages", each one is now a
node module (with a dedicated package.json/tsconfig.json)
* server/tools have been moved into apps/ and is now a dedicated app
bundled and published on NPM so users don't have to build peertube
cli tools manually
* server/tests have been moved into packages/ so we don't compile
them every time we want to run the server
* Use isolatedModule option:
* Had to move from const enum to const
(https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums)
* Had to explictely specify "type" imports when used in decorators
* Prefer tsx (that uses esbuild under the hood) instead of ts-node to
load typescript files (tests with mocha or scripts):
* To reduce test complexity as esbuild doesn't support decorator
metadata, we only test server files that do not import server
models
* We still build tests files into js files for a faster CI
* Remove unmaintained peertube CLI import script
* Removed some barrels to speed up execution (less imports)
Diffstat (limited to '.github')
-rw-r--r-- | .github/CONTRIBUTING.md | 31 | ||||
-rw-r--r-- | .github/actions/reusable-prepare-peertube-build/action.yml | 10 | ||||
-rw-r--r-- | .github/workflows/benchmark.yml | 2 | ||||
-rw-r--r-- | .github/workflows/codeql/codeql-config.yml | 2 | ||||
-rw-r--r-- | .github/workflows/stats.yml | 4 |
5 files changed, 30 insertions, 19 deletions
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 80b7cba3c..16863eceb 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md | |||
@@ -53,13 +53,25 @@ interested in, user interface, design, decentralized architecture... | |||
53 | You can help to write the documentation of the REST API, code, architecture, | 53 | You can help to write the documentation of the REST API, code, architecture, |
54 | demonstrations. | 54 | demonstrations. |
55 | 55 | ||
56 | For the REST API you can see the documentation in [/support/doc/api](https://github.com/Chocobozzz/PeerTube/tree/develop/support/doc/api) directory. | 56 | ### User documentation |
57 | 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. | 57 | |
58 | The official user documentation is available on https://docs.joinpeertube.org/ | ||
59 | |||
60 | You can update it by writing markdown files in the following repository: https://framagit.org/framasoft/peertube/documentation/ | ||
61 | |||
62 | ### REST API documentation | ||
63 | |||
64 | The [REST API documentation](https://docs.joinpeertube.org/api-rest-reference.html) is generated from `support/doc/api/openapi.yaml` file. | ||
65 | To quickly get a preview of your changes, you can generate the documentation *on the fly* using the following command: | ||
66 | |||
67 | ``` | ||
68 | npx @redocly/cli preview-docs ./support/doc/api/openapi.yaml | ||
69 | ``` | ||
58 | 70 | ||
59 | Some hints: | 71 | Some hints: |
60 | * Routes are defined in [/server/controllers/](https://github.com/Chocobozzz/PeerTube/tree/develop/server/controllers) directory | 72 | * Routes are defined in [/server/server/controllers/](https://github.com/Chocobozzz/PeerTube/tree/develop/server/server/controllers) directory |
61 | * Parameters validators are defined in [/server/middlewares/validators](https://github.com/Chocobozzz/PeerTube/tree/develop/server/middlewares/validators) directory | 73 | * Parameters validators are defined in [/server/server/middlewares/validators](https://github.com/Chocobozzz/PeerTube/tree/develop/server/server/middlewares/validators) directory |
62 | * Models sent/received by the controllers are defined in [/shared/models](https://github.com/Chocobozzz/PeerTube/tree/develop/shared/models) directory | 74 | * Models sent/received by the controllers are defined in [/packages/models](https://github.com/Chocobozzz/PeerTube/tree/develop/packages/models) directory |
63 | 75 | ||
64 | 76 | ||
65 | ## Improve the website | 77 | ## Improve the website |
@@ -242,15 +254,6 @@ To test emails with PeerTube: | |||
242 | * Run [mailslurper](http://mailslurper.com/) | 254 | * Run [mailslurper](http://mailslurper.com/) |
243 | * Run PeerTube using mailslurper SMTP port: `NODE_CONFIG='{ "smtp": { "hostname": "localhost", "port": 2500, "tls": false } }' NODE_ENV=dev node dist/server` | 255 | * Run PeerTube using mailslurper SMTP port: `NODE_CONFIG='{ "smtp": { "hostname": "localhost", "port": 2500, "tls": false } }' NODE_ENV=dev node dist/server` |
244 | 256 | ||
245 | ### OpenAPI documentation | ||
246 | |||
247 | The [REST API documentation](https://docs.joinpeertube.org/api-rest-reference.html) is generated from `support/doc/api/openapi.yaml` file. | ||
248 | To quickly get a preview of your changes, you can generate the documentation *on the fly* using the following command: | ||
249 | |||
250 | ``` | ||
251 | npx @redocly/cli preview-docs ./support/doc/api/openapi.yaml | ||
252 | ``` | ||
253 | |||
254 | ### Environment variables | 257 | ### Environment variables |
255 | 258 | ||
256 | PeerTube can be configured using environment variables. | 259 | PeerTube can be configured using environment variables. |
diff --git a/.github/actions/reusable-prepare-peertube-build/action.yml b/.github/actions/reusable-prepare-peertube-build/action.yml index 03034f6cc..13e22ceb4 100644 --- a/.github/actions/reusable-prepare-peertube-build/action.yml +++ b/.github/actions/reusable-prepare-peertube-build/action.yml | |||
@@ -32,4 +32,12 @@ runs: | |||
32 | 32 | ||
33 | - name: Install peertube runner dependencies | 33 | - name: Install peertube runner dependencies |
34 | shell: bash | 34 | shell: bash |
35 | run: cd packages/peertube-runner && yarn install --frozen-lockfile | 35 | run: cd apps/peertube-runner && yarn install --frozen-lockfile |
36 | |||
37 | - name: Install peertube CLI dependencies | ||
38 | shell: bash | ||
39 | run: cd apps/peertube-cli && yarn install --frozen-lockfile | ||
40 | |||
41 | - name: Display PeerTube dependencies | ||
42 | shell: bash | ||
43 | run: ls -l node_modules/@peertube | ||
diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index ab1780c74..5f56db3ad 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml | |||
@@ -71,7 +71,7 @@ jobs: | |||
71 | 71 | ||
72 | - name: Run benchmark | 72 | - name: Run benchmark |
73 | run: | | 73 | run: | |
74 | node dist/scripts/benchmark.js -o benchmark.json | 74 | npm run benchmark-server -- -o benchmark.json |
75 | 75 | ||
76 | - name: Display result | 76 | - name: Display result |
77 | run: | | 77 | run: | |
diff --git a/.github/workflows/codeql/codeql-config.yml b/.github/workflows/codeql/codeql-config.yml index 8b771ae99..c96a4693e 100644 --- a/.github/workflows/codeql/codeql-config.yml +++ b/.github/workflows/codeql/codeql-config.yml | |||
@@ -1,4 +1,4 @@ | |||
1 | name: "PeerTube CodeQL config" | 1 | name: "PeerTube CodeQL config" |
2 | 2 | ||
3 | paths-ignore: | 3 | paths-ignore: |
4 | - server/tests | 4 | - packages/tests |
diff --git a/.github/workflows/stats.yml b/.github/workflows/stats.yml index e772fdb81..573b42975 100644 --- a/.github/workflows/stats.yml +++ b/.github/workflows/stats.yml | |||
@@ -36,12 +36,12 @@ jobs: | |||
36 | run: | | 36 | run: | |
37 | wget "https://github.com/boyter/scc/releases/download/v3.0.0/scc-3.0.0-x86_64-unknown-linux.zip" | 37 | wget "https://github.com/boyter/scc/releases/download/v3.0.0/scc-3.0.0-x86_64-unknown-linux.zip" |
38 | unzip "scc-3.0.0-x86_64-unknown-linux.zip" | 38 | unzip "scc-3.0.0-x86_64-unknown-linux.zip" |
39 | ./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 | 39 | ./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 |
40 | 40 | ||
41 | - name: PeerTube client stats | 41 | - name: PeerTube client stats |
42 | if: github.event_name != 'pull_request' | 42 | if: github.event_name != 'pull_request' |
43 | run: | | 43 | run: | |
44 | node dist/scripts/client-build-stats.js > client-build-stats.json | 44 | npm run client:build-stats > client-build-stats.json |
45 | 45 | ||
46 | - name: PeerTube client lighthouse report | 46 | - name: PeerTube client lighthouse report |
47 | if: github.event_name != 'pull_request' | 47 | if: github.event_name != 'pull_request' |