fix: build issues

This commit is contained in:
2023-11-01 15:22:32 +01:00
parent c7555e1918
commit 4bdd4b20d0
15 changed files with 188 additions and 74 deletions

View File

@@ -34,7 +34,7 @@
"lint:fix": "eslint --fix --ext .ts src/",
"test": "c8 mocha --exit"
},
"dpendencies": {
"dependencies": {
"@openstapps/api": "workspace:*",
"@openstapps/core": "workspace:*",
"@openstapps/logger": "workspace:*",

View File

@@ -1,2 +0,0 @@
core.schema.json
core.schema.d.ts

View File

@@ -64,6 +64,11 @@ import {SCTicket, SCTicketMeta, SCTicketWithoutReferences} from './things/ticket
import {SCToDo, SCToDoMeta, SCToDoWithoutReferences} from './things/todo.js';
import {SCTour, SCTourMeta, SCTourWithoutReferences} from './things/tour.js';
import {SCVideo, SCVideoMeta, SCVideoWithoutReferences} from './things/video.js';
import {version} from '../package.json';
// re-export breaks .d.ts generation for some reason
// eslint-disable-next-line unicorn/prefer-export-from
export const STAPPS_CORE_VERSION = version;
/**
* A map of things, from type to meta data

View File

@@ -92,11 +92,11 @@ export interface SCPluginMetaData {
/**
* Plugin register response
* @validatable
*/
export interface SCPluginRegisterResponse {
/**
* Whether the desired action succeeded or failed (true for success, false if an error occurred)
* @validatable
*/
success: boolean;
}

View File

@@ -19,17 +19,15 @@
"dev": "tsup --watch --onSuccess \"node lib/index.js\"",
"format": "prettier . -c --ignore-path ../../.gitignore",
"format:fix": "prettier --write . --ignore-path ../../.gitignore",
"lint": "eslint --ext .ts src/ test/",
"lint:fix": "eslint --ext .ts src/ test/",
"lint": "eslint --ext .ts src/",
"lint:fix": "eslint --ext .ts src/",
"test": "c8 mocha"
},
"dependencies": {
"@elastic/elasticsearch": "8.10.0",
"@openstapps/json-schema-generator": "workspace:*",
"@openstapps/tsup-plugin": "workspace:*",
"@types/json-schema": "7.0.14",
"ajv": "8.12.0",
"better-ajv-errors": "1.2.0"
"@types/json-schema": "7.0.14"
},
"devDependencies": {
"@openstapps/eslint-config": "workspace:*",

View File

@@ -1,5 +1,4 @@
import {defineConfig} from 'tsup';
import {jsonSchemaPlugin} from '@openstapps/json-schema-generator';
export default defineConfig({
entry: ['src/index.ts'],
@@ -7,6 +6,4 @@ export default defineConfig({
clean: true,
format: 'esm',
outDir: 'lib',
external: ['./index.schema.json'],
plugins: [jsonSchemaPlugin('index.schema.json')],
});

View File

@@ -6,7 +6,21 @@ import {createGenerator} from 'ts-json-schema-generator';
export type SchemaConsumer = (this: PluginContext, schema: JSONSchema7) => Record<string, string | Buffer>;
export const jsonSchema: EsbuildPlugin = {
/**
* ESBuild Plugin for directly importing schemas
*
* Schemas will be bundled in the output, but because each schema is compiled individually,
* the resulting output can be substantially bigger and take longer to compile.
* @example
* interface Foo {}
* import {default as fooSchema} from 'schema:#Foo'
* @example
* // ./my-type.ts
* interface Bar {}
* // ./schema-consumer.ts
* import {default as barSchema} from 'schema:./my-type.js#Bar'
*/
export const esbuildJsonSchemaPlugin: EsbuildPlugin = {
name: 'json-schema',
setup(build) {
const fileRegex = /^schema:/;