mirror of
https://github.com/immich-app/immich.git
synced 2024-12-28 06:31:58 +00:00
parent
a5e8b451b2
commit
e7aa50425c
9 changed files with 45 additions and 16 deletions
15
.github/workflows/test.yml
vendored
15
.github/workflows/test.yml
vendored
|
@ -260,9 +260,18 @@ jobs:
|
|||
name: OpenAPI Clients
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install server dependencies
|
||||
run: npm --prefix=server ci
|
||||
|
||||
- name: Build the app
|
||||
run: npm --prefix=server run build
|
||||
|
||||
- name: Run API generation
|
||||
run: make open-api
|
||||
|
||||
- name: Find file changes
|
||||
uses: tj-actions/verify-changed-files@v20
|
||||
id: verify-changed-files
|
||||
|
@ -270,6 +279,8 @@ jobs:
|
|||
files: |
|
||||
mobile/openapi
|
||||
open-api/typescript-sdk
|
||||
open-api/immich-openapi-specs.json
|
||||
|
||||
- name: Verify files have not changed
|
||||
if: steps.verify-changed-files.outputs.files_changed == 'true'
|
||||
run: |
|
||||
|
@ -332,7 +343,7 @@ jobs:
|
|||
exit 1
|
||||
|
||||
- name: Run SQL generation
|
||||
run: npm run sql:generate
|
||||
run: npm run sync:sql
|
||||
env:
|
||||
DB_URL: postgres://postgres:postgres@localhost:5432/immich
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -37,7 +37,7 @@ open-api-typescript:
|
|||
cd ./open-api && bash ./bin/generate-open-api.sh typescript
|
||||
|
||||
sql:
|
||||
npm --prefix server run sql:generate
|
||||
npm --prefix server run sync:sql
|
||||
|
||||
attach-server:
|
||||
docker exec -it docker_immich-server_1 sh
|
||||
|
|
|
@ -62,6 +62,8 @@ fi
|
|||
if [ "$CURRENT_SERVER" != "$NEXT_SERVER" ]; then
|
||||
echo "Pumping Server: $CURRENT_SERVER => $NEXT_SERVER"
|
||||
npm --prefix server version "$SERVER_PUMP"
|
||||
npm --prefix server ci
|
||||
npm --prefix server run build
|
||||
make open-api
|
||||
npm --prefix open-api/typescript-sdk version "$SERVER_PUMP"
|
||||
npm --prefix web version "$SERVER_PUMP"
|
||||
|
|
|
@ -24,7 +24,8 @@ function typescript {
|
|||
npm --prefix typescript-sdk ci && npm --prefix typescript-sdk run build
|
||||
}
|
||||
|
||||
node ./bin/sync-spec-version.js
|
||||
# requires server to be built
|
||||
npm run sync:open-api --prefix=../server
|
||||
|
||||
if [[ $1 == 'dart' ]]; then
|
||||
dart
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
const spec = require('../immich-openapi-specs.json');
|
||||
const pkg = require('../../server/package.json');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
spec.info.version = pkg.version;
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, '../immich-openapi-specs.json'),
|
||||
JSON.stringify(spec, null, 2)
|
||||
);
|
|
@ -30,7 +30,8 @@
|
|||
"typeorm:migrations:revert": "typeorm migration:revert -d ./dist/database.config.js",
|
||||
"typeorm:schema:drop": "typeorm query -d ./dist/database.config.js 'DROP schema public cascade; CREATE schema public;'",
|
||||
"typeorm:schema:reset": "npm run typeorm:schema:drop && npm run typeorm:migrations:run",
|
||||
"sql:generate": "node ./dist/utils/sql.js",
|
||||
"sync:open-api": "node ./dist/bin/sync-open-api.js",
|
||||
"sync:sql": "node ./dist/bin/sync-sql.js",
|
||||
"email:dev": "email dev -p 3050 --dir src/emails"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
23
server/src/bin/sync-open-api.ts
Normal file
23
server/src/bin/sync-open-api.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env node
|
||||
process.env.DB_URL = 'postgres://postgres:postgres@localhost:5432/immich';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||
import { ApiModule } from 'src/app.module';
|
||||
import { useSwagger } from 'src/utils/misc';
|
||||
|
||||
const sync = async () => {
|
||||
const app = await NestFactory.create<NestExpressApplication>(ApiModule, { preview: true });
|
||||
useSwagger(app, true);
|
||||
await app.close();
|
||||
};
|
||||
|
||||
sync()
|
||||
.then(() => {
|
||||
console.log('Done');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
console.log('Something went wrong');
|
||||
process.exit(1);
|
||||
});
|
|
@ -174,7 +174,7 @@ const patchOpenAPI = (document: OpenAPIObject) => {
|
|||
return document;
|
||||
};
|
||||
|
||||
export const useSwagger = (app: INestApplication) => {
|
||||
export const useSwagger = (app: INestApplication, force = false) => {
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Immich')
|
||||
.setDescription('Immich API')
|
||||
|
@ -211,7 +211,7 @@ export const useSwagger = (app: INestApplication) => {
|
|||
|
||||
SwaggerModule.setup('doc', app, specification, customOptions);
|
||||
|
||||
if (isDev()) {
|
||||
if (isDev() || force) {
|
||||
// Generate API Documentation only in development mode
|
||||
const outputPath = path.resolve(process.cwd(), '../open-api/immich-openapi-specs.json');
|
||||
writeFileSync(outputPath, JSON.stringify(patchOpenAPI(specification), null, 2), { encoding: 'utf8' });
|
||||
|
|
Loading…
Reference in a new issue