Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci
- run: npm run generate
- run: git diff --exit-code -- src/generated/api.ts
- run: npm run typecheck
- run: npm run lint
- run: npm test -- --coverage
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
dist/
src/generated/
resources/
coverage/
node_modules/
test/data/
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ client is created, without repeating the value.
## Development

```bash
./sync.sh # download the current OpenAPI description
npm run generate # rebuild src/generated/api.ts from that file
npm ci
npm run typecheck
npm run lint
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { defineConfig } from 'eslint/config';
const rootDir = fileURLToPath(new URL('.', import.meta.url));

export default defineConfig(
{ ignores: ['dist/', 'coverage/', 'node_modules/'] },
{ ignores: ['dist/', 'coverage/', 'node_modules/', 'src/generated/'] },
js.configs.recommended,
{
files: ['**/*.ts'],
Expand Down
19 changes: 19 additions & 0 deletions generate.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { mkdirSync, writeFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

import openapiTS, { astToString } from 'openapi-typescript';

const root = resolve(dirname(fileURLToPath(import.meta.url)));
const outputPath = resolve(root, 'src/generated/api.ts');

const ast = await openapiTS(new URL('./resources/shieldlabs-api.yaml', import.meta.url));
const banner = `/**
* Generated from resources/shieldlabs-api.yaml. Do not edit by hand.
* Refresh with: ./sync.sh && npm run generate
*/
`;

mkdirSync(dirname(outputPath), { recursive: true });
writeFileSync(outputPath, banner + astToString(ast));
console.log(`Wrote ${outputPath}`);
Loading
Loading