From b969539c838ae3012d7a7040c5e310bb9c834e95 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 24 Dec 2021 13:16:55 +0100 Subject: Fix types dist paths --- types/generate-package.ts | 5 +---- types/src/client/tsconfig.json | 3 +++ types/src/index.ts | 2 ++ types/tests/test.ts | 32 ++++++++++++++++++++++++++++++++ types/tsconfig.dist.json | 2 +- types/tsconfig.json | 6 +++--- 6 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 types/tests/test.ts (limited to 'types') diff --git a/types/generate-package.ts b/types/generate-package.ts index a4f049a31..ae061f9b0 100644 --- a/types/generate-package.ts +++ b/types/generate-package.ts @@ -23,6 +23,7 @@ async function run () { await remove(typesDistPath) execSync('npm run tsc -- -b --verbose types', { stdio: 'inherit' }) + execSync(`npm run resolve-tspaths -- --project ${distTsConfigPath} --src ${typesDistPath} --out ${typesDistPath}`, { stdio: 'inherit' }) const allDependencies = Object.assign( mainPackageJson.dependencies, @@ -69,9 +70,5 @@ async function run () { console.log(`Writing git ignore to ${typesDistGitIgnorePath}`) await writeFile(typesDistGitIgnorePath, '*.tsbuildinfo') - console.log('Copying tsconfig files') - await copyFile(distTsConfigPath, resolve(typesDistPath, './tsconfig.json')) - await copyFile(resolve(cwd(), './tsconfig.base.json'), resolve(typesDistPath, './tsconfig.base.json')) - await copyFile(resolve(typesPath, './README.md'), resolve(typesDistPath, './README.md')) } diff --git a/types/src/client/tsconfig.json b/types/src/client/tsconfig.json index 199273538..dea4c131c 100644 --- a/types/src/client/tsconfig.json +++ b/types/src/client/tsconfig.json @@ -1,6 +1,9 @@ { "extends": "../../../tsconfig.base.json", "compilerOptions": { + "stripInternal": true, + "removeComments": false, + "emitDeclarationOnly": true, "outDir": "../../dist/client/", "rootDir": "./", "tsBuildInfoFile": "../../dist/tsconfig.client.types.tsbuildinfo" diff --git a/types/src/index.ts b/types/src/index.ts index f1325777f..a8adca287 100644 --- a/types/src/index.ts +++ b/types/src/index.ts @@ -1 +1,3 @@ export * from '@server/types' +export * from '@server/types/models' +export * from '@shared/models' diff --git a/types/tests/test.ts b/types/tests/test.ts new file mode 100644 index 000000000..8c53320a1 --- /dev/null +++ b/types/tests/test.ts @@ -0,0 +1,32 @@ +import { RegisterServerOptions, Video } from '../dist' +import { RegisterClientOptions } from '../dist/client' + +function register1 ({ registerHook }: RegisterServerOptions) { + registerHook({ + target: 'action:application.listening', + handler: () => console.log('hello') + }) +} + +function register2 ({ registerHook, peertubeHelpers }: RegisterClientOptions) { + registerHook({ + target: 'action:admin-plugin-settings.init', + handler: ({ npmName }: { npmName: string }) => { + if ('peertube-plugin-transcription' !== npmName) { + return + } + }, + }) + + registerHook({ + target: 'action:video-watch.video.loaded', + handler: ({ video }: { video: Video }) => { + fetch(`${peertubeHelpers.getBaseRouterRoute()}/videos/${video.uuid}/captions`, { + method: 'PUT', + headers: peertubeHelpers.getAuthHeader(), + }) + .then((res) => res.json()) + .then((data) => console.log('Hi %s.', data)) + }, + }) +} diff --git a/types/tsconfig.dist.json b/types/tsconfig.dist.json index fc2dbe45b..fbc92712b 100644 --- a/types/tsconfig.dist.json +++ b/types/tsconfig.dist.json @@ -5,7 +5,7 @@ "node_modules/@types", "client/node_modules/@types" ], - "baseUrl": "./", + "baseUrl": "./dist", "paths": { "@server/*": [ "server/*" ], "@shared/*": [ "shared/*" ], diff --git a/types/tsconfig.json b/types/tsconfig.json index 8f09c4a83..514683886 100644 --- a/types/tsconfig.json +++ b/types/tsconfig.json @@ -7,10 +7,11 @@ "outDir": "./dist/", "baseUrl": "./src/", "rootDir": "./src/", + "tsBuildInfoFile": "./dist/tsconfig.server.types.tsbuildinfo", "paths": { "@server/*": [ "../../server/*" ], "@shared/*": [ "../../shared/*" ], - "@client/*": [ "../../client/src/*" ], + "@client/*": [ "../../client/src/*" ] } }, "references": [ @@ -18,6 +19,5 @@ { "path": "../server/tsconfig.types.json" }, { "path": "./src/client/tsconfig.json" } ], - "files": ["./src/index.ts"], + "files": ["./src/index.ts"] } - -- cgit v1.2.3