Skip to content

Commit

Permalink
chore: update and fix tests etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Feb 3, 2023
1 parent 297d3d3 commit 034c183
Show file tree
Hide file tree
Showing 23 changed files with 5,194 additions and 2,345 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
**/.coverage
**/.test
**/tests
**/bundle.*

.yarn
.pnp.*
**/node_modules
Expand Down
37 changes: 16 additions & 21 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
root: true

extends:
- 'plugin:@typescript-eslint/recommended'
- plugin:node/recommended
- plugin:github/recommended
- plugin:promise/recommended
Expand All @@ -11,10 +12,12 @@ extends:
- plugin:unicorn/recommended
- plugin:security/recommended
- plugin:sonarjs/recommended
- plugin:ava/recommended
- xo
- prettier

plugins:
- '@typescript-eslint'
- node
- github
- promise
Expand All @@ -27,33 +30,35 @@ plugins:
- security
- no-secrets
- sonarjs
- ava
- notice

parser: '@typescript-eslint/parser'

parserOptions:
ecmaVersion: 2020
project:
- '**/tsconfig*.json'
project: './**/tsconfig*.json'

overrides:
- files: '*.{m,c,}ts'
- files: '*.schema.{c,m,}ts'
rules:
sonarjs/no-duplicate-string: off
- files: '*.{c,m,}ts'
extends:
- plugin:github/typescript
- plugin:import/typescript
- xo-typescript
- prettier
parserOptions:
ecmaVersion: 2020
project:
- '**/tsconfig*.json'
project: './**/tsconfig*.json'
rules:
'@typescript-eslint/naming-convention':
[
error,
{ selector: default, format: [camelCase] },
{ selector: enumMember, format: [PascalCase] },
{ selector: objectLiteralProperty, format: null },
{ selector: enumMember, format: [PascalCase] },
{ selector: typeProperty, format: null },

{
Expand Down Expand Up @@ -89,20 +94,6 @@ overrides:
},
]
'@typescript-eslint/consistent-type-definitions': [warn, interface]
- files: '*.schema.{m,c,}ts'
extends:
- plugin:github/typescript
- plugin:import/typescript
- xo-typescript
- prettier
parserOptions:
ecmaVersion: 2020
project:
- '**/tsconfig*.json'
rules:
'sonarjs/no-duplicate-string': off
'no-secrets/no-secrets': off
'@typescript-eslint/naming-convention': off

rules:
notice/notice:
Expand All @@ -128,7 +119,7 @@ rules:
unicorn/filename-case: off
i18n-text/no-en: off
eslint-comments/no-use: off
no-secrets/no-secrets: error
no-secrets/no-secrets: [error, { tolerance: 5 }]
no-empty-label: off
no-warning-comments: off
node/no-missing-import: off
Expand All @@ -137,3 +128,7 @@ rules:
no-constructor-bind/no-constructor-bind: error
no-constructor-bind/no-constructor-state: error
sort-imports: [warn, { allowSeparatedGroups: true }]
ava/no-ignored-test-files: off
ava/no-import-test-files: off
ava/no-skip-test: warn
ava/no-skip-assert: warn
199 changes: 117 additions & 82 deletions .yarn/plugins/@ojkelly/plugin-build.cjs

Large diffs are not rendered by default.

211 changes: 103 additions & 108 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

783 changes: 0 additions & 783 deletions .yarn/releases/yarn-3.2.3.cjs

This file was deleted.

873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.4.1.cjs

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
packageExtensions:
chalk@5.0.1:
'@apidevtools/json-schema-ref-parser@10.1.0':
dependencies:
"#ansi-styles": "npm:ansi-styles@6.1.0"
"#supports-color": "npm:supports-color@9.2.2"
node-fetch: 'npm:node-fetch@^2.6.2'

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
spec: '@yarnpkg/plugin-typescript'
- path: .yarn/plugins/@ojkelly/plugin-build.cjs
spec: "https://yarn.build/latest/build"
spec: 'https://yarn.build/latest/build'
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
spec: '@yarnpkg/plugin-interactive-tools'
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
spec: '@yarnpkg/plugin-workspace-tools'

yarnPath: .yarn/releases/yarn-3.2.3.cjs
yarnPath: .yarn/releases/yarn-3.4.1.cjs
1 change: 1 addition & 0 deletions formats.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"FMIS",
"jwks",
"lcov",
"ojkelly",
"sonarjs",
"unversioned"
],
Expand Down
43 changes: 21 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,39 @@
},
"devDependencies": {
"@tsconfig/node16": "^1.0.3",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"@yarnpkg/sdks": "^3.0.0-rc.22",
"@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.50.0",
"@yarnpkg/sdks": "^3.0.0-rc.37",
"coveralls": "^3.1.1",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-xo": "^0.42.0",
"eslint-config-xo-typescript": "^0.53.0",
"eslint-formatter-pretty": "^4.1.0",
"eslint-import-resolver-node": "^0.3.6",
"eslint-plugin-array-func": "^3.1.7",
"eslint-plugin-ava": "^13.2.0",
"eslint": "^8.33.0",
"eslint-config-prettier": "^8.6.0",
"eslint-config-xo": "^0.43.1",
"eslint-config-xo-typescript": "^0.55.1",
"eslint-plugin-array-func": "^3.1.8",
"eslint-plugin-ava": "^14.0.0",
"eslint-plugin-escompat": "^3.3.4",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-filenames": "^1.3.2",
"eslint-plugin-github": "^4.3.7",
"eslint-plugin-github": "^4.6.0",
"eslint-plugin-i18n-text": "^1.0.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-no-constructor-bind": "^2.0.4",
"eslint-plugin-no-only-tests": "^3.0.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-no-secrets": "^0.8.9",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-notice": "^0.9.10",
"eslint-plugin-optimize-regex": "^1.2.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.0.1",
"eslint-plugin-regexp": "^1.9.0",
"eslint-plugin-security": "^1.5.0",
"eslint-plugin-sonarjs": "^0.15.0",
"eslint-plugin-unicorn": "^43.0.2",
"lerna": "^5.5.4",
"prettier": "^2.7.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-regexp": "^1.12.0",
"eslint-plugin-security": "^1.7.1",
"eslint-plugin-sonarjs": "^0.18.0",
"eslint-plugin-unicorn": "^45.0.2",
"lerna": "^6.4.1",
"prettier": "^2.8.3",
"typescript": "4.8.2"
},
"packageManager": "yarn@3.2.3",
"packageManager": "yarn@3.4.1",
"volta": {
"node": "16.15.1"
}
Expand Down
24 changes: 12 additions & 12 deletions packages/formats/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,28 @@
]
},
"dependencies": {
"@apidevtools/json-schema-ref-parser": "^9.0.9",
"@apidevtools/json-schema-ref-parser": "^10.1.0",
"@oada/media-types": "^3.0.0",
"ajv": "^8.11.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"ajv-formats-draft2019": "^1.6.1",
"axios": "^0.27.2",
"glob": "^8.0.3",
"glob-promise": "^5.0.0",
"tslib": "^2.4.0"
"axios": "^1.3.2",
"glob": "^8.1.0",
"glob-promise": "^5.0.1",
"tslib": "^2.5.0"
},
"devDependencies": {
"@ava/typescript": "^3.0.1",
"@types/debug": "^4.1.7",
"@types/glob": "^8.0.0",
"@types/glob": "^8.0.1",
"@types/mkdirp": "^1.0.2",
"@types/node": "^16.11.62",
"@types/yargs": "^17.0.13",
"ava": "4.3.3",
"@types/node": "^16.18.11",
"@types/yargs": "^17.0.22",
"ava": "5.1.1",
"c8": "^7.12.0",
"debug": "^4.3.4",
"jsonschema8": "^1.1.1",
"mkdirp": "^1.0.4",
"yargs": "^17.5.1"
"mkdirp": "^2.1.3",
"yargs": "^17.6.2"
}
}
13 changes: 9 additions & 4 deletions packages/formats/src/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
JSONSchema8 as Schema,
} from 'jsonschema8';
import type { default as Ajv } from 'ajv';
import mkdirp from 'mkdirp';
import { mkdirp } from 'mkdirp';

import { contentTypeToKey } from './ajv.js';

Expand Down Expand Up @@ -191,11 +191,13 @@ export async function migrate(
let path = join(outdir, key);
const json = JSON.stringify({ ...schema, examples }, null, 2);
switch (format) {
case 'json':
case 'json': {
// Create plain JSON schema
output = json;
break;
case 'ts':
}

case 'ts': {
// Create "TypeScript" schema
output = `
import { JSONSchema8 as Schema } from 'jsonschema8'
Expand All @@ -205,8 +207,11 @@ export async function migrate(
`;
path = path.replace(/\.json$/, '.ts');
break;
default:
}

default: {
throw new Error(`Unknown format ${format}`);
}
}

// Write file out
Expand Down
2 changes: 1 addition & 1 deletion packages/formats/src/schemas/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { dirname, join, resolve } from 'node:path';
import fs from 'node:fs/promises';

import log from 'debug';
import mkdirp from 'mkdirp';
import { mkdirp } from 'mkdirp';
import yargs from 'yargs';

import schemas from './index.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/media-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@
},
"dependencies": {
"@types/content-type": "^1.1.5",
"content-type": "^1.0.4"
"content-type": "^1.0.5"
},
"devDependencies": {
"@ava/typescript": "^3.0.1",
"ava": "4.3.3",
"ava": "5.1.1",
"c8": "^7.12.0"
}
}
8 changes: 4 additions & 4 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
},
"dependencies": {
"@oada/media-types": "^3.0.0",
"content-type": "^1.0.4"
"content-type": "^1.0.5"
},
"peerDependencies": {
"@oada/formats": "^1.3.0",
Expand All @@ -90,9 +90,9 @@
"devDependencies": {
"@ava/typescript": "^3.0.1",
"@types/content-type": "^1.1.5",
"@types/express": "^4.17.14",
"ava": "4.3.3",
"@types/express": "^4.17.16",
"ava": "5.1.1",
"c8": "^7.12.0",
"fastify": "^4.6.0"
"fastify": "^4.12.0"
}
}
1 change: 1 addition & 0 deletions packages/server/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function middleware(_options: Options): RequestHandler {
response.get('Link')
);
// @ts-expect-error stuff
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
response.log?.trace('Setting schema headers: %O', headers);
response.set(headers);

Expand Down
14 changes: 7 additions & 7 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,29 +134,29 @@
"tsconfig.json"
],
"dependencies": {
"ajv": "8.11.0",
"ajv": "8.12.0",
"ajv-formats": "^2.1.1",
"ajv-formats-draft2019": "^1.6.1",
"tslib": "^2.4.0"
"tslib": "^2.5.0"
},
"devDependencies": {
"@apidevtools/json-schema-ref-parser": "^9.0.9",
"@apidevtools/json-schema-ref-parser": "^10.1.0",
"@ava/typescript": "^3.0.1",
"@oada/formats": "^3.0.0",
"@types/clone-deep": "^4.0.1",
"@types/debug": "^4.1.7",
"@types/json-schema-merge-allof": "^0.6.1",
"@types/lodash.omit": "^4.5.7",
"@types/mkdirp": "^1.0.2",
"@types/node": "^16.11.62",
"ava": "4.3.3",
"@types/node": "^16.18.11",
"ava": "5.1.1",
"c8": "^7.12.0",
"clone-deep": "^4.0.1",
"debug": "^4.3.4",
"json-schema-merge-allof": "^0.8.1",
"json-schema-to-typescript": "^11.0.2",
"json-schema-to-typescript": "^11.0.3",
"jsonschema8": "^1.1.1",
"lodash.omit": "^4.5.0",
"mkdirp": "^1.0.4"
"mkdirp": "^2.1.3"
}
}
4 changes: 2 additions & 2 deletions packages/types/src/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import { createRequire } from 'node:module';
import { promises as fs } from 'node:fs';
import { setTimeout } from 'node:timers/promises';

import $RefParser from '@apidevtools/json-schema-ref-parser';
import { $RefParser } from '@apidevtools/json-schema-ref-parser';
import { default as Ajv } from 'ajv';
import { default as addFormats } from 'ajv-formats';
import addFormats2019 from 'ajv-formats-draft2019';
import clone from 'clone-deep';
import { compile } from 'json-schema-to-typescript';
import log from 'debug';
import mkdirp from 'mkdirp';
import { mkdirp } from 'mkdirp';
import { default as standaloneCode } from 'ajv/dist/standalone/index.js';
import { toSafeString } from 'json-schema-to-typescript/dist/src/utils.js';

Expand Down
Loading

0 comments on commit 034c183

Please sign in to comment.