mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-18 15:42:54 +00:00
feat: improve monorepo dev experience
This commit is contained in:
@@ -38,7 +38,6 @@
|
||||
"commander": "10.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openstapps/core-tools": "workspace:*",
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
"dependencies": {
|
||||
"@openstapps/api": "workspace:*",
|
||||
"@openstapps/api-plugin": "workspace:*",
|
||||
"@openstapps/json-schema-generator": "workspace:*",
|
||||
"@openstapps/core": "workspace:*",
|
||||
"@openstapps/core-tools": "workspace:*",
|
||||
"@openstapps/logger": "workspace:*",
|
||||
"commander": "10.0.0",
|
||||
"express": "4.18.2",
|
||||
@@ -46,15 +46,6 @@
|
||||
"tsup": "6.7.0",
|
||||
"typescript": "5.1.6"
|
||||
},
|
||||
"tsup": {
|
||||
"entry": [
|
||||
"src/app.ts"
|
||||
],
|
||||
"sourcemap": true,
|
||||
"clean": true,
|
||||
"format": "esm",
|
||||
"outDir": "lib"
|
||||
},
|
||||
"prettier": "@openstapps/prettier-config",
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
import {HttpClient} from '@openstapps/api';
|
||||
import {PluginClient} from '@openstapps/api-plugin';
|
||||
import {Converter} from '@openstapps/core-tools';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {Command, Option} from 'commander';
|
||||
import {readFileSync} from 'fs';
|
||||
@@ -52,18 +51,11 @@ const pluginClient = new PluginClient(new HttpClient(), options.backendUrl);
|
||||
|
||||
// create an instance of your plugin
|
||||
const plugin = new MinimalPlugin(
|
||||
// tslint:disable-next-line:no-magic-numbers
|
||||
Number.parseInt(options.port, 10),
|
||||
options.pluginName,
|
||||
options.url,
|
||||
`/${options.routeName}`,
|
||||
options.backendUrl,
|
||||
new Converter(path.resolve(__dirname, '..', 'src', 'plugin', 'protocol')), // an instance of the converter. Required
|
||||
// because your requests and response schemas are defined in the plugin. The path should lead to your request and
|
||||
// response interfaces
|
||||
'SCMinimalRequest', // TODO: adjust name of the request interface
|
||||
'SCMinimalResponse', // TODO: adjust name of the response interface
|
||||
JSON.parse(readFileSync(path.resolve(__dirname, '..', 'package.json')).toString()).version, // get the version of the plugin from the package.json
|
||||
);
|
||||
|
||||
pluginClient
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
import {Plugin} from '@openstapps/api-plugin';
|
||||
import * as express from 'express';
|
||||
import schema from '../../lib/schema.json';
|
||||
import {SCMinimalRequest} from './protocol/request.js';
|
||||
import {SCMinimalResponse} from './protocol/response.js';
|
||||
|
||||
@@ -24,6 +25,10 @@ import {SCMinimalResponse} from './protocol/response.js';
|
||||
* TODO: rename the class
|
||||
*/
|
||||
export class MinimalPlugin extends Plugin {
|
||||
requestSchema = schema.SCMinimalRequest;
|
||||
|
||||
responseSchema = schema.SCMinimalResponse;
|
||||
|
||||
/**
|
||||
* Calculates the sum of a list of numbers
|
||||
*
|
||||
|
||||
@@ -27,3 +27,5 @@ export interface SCMinimalRequest {
|
||||
*/
|
||||
numbers: number[];
|
||||
}
|
||||
|
||||
export {default as requestSchema} from 'schema:#SCMinimalRequest';
|
||||
|
||||
@@ -27,3 +27,5 @@ export interface SCMinimalResponse {
|
||||
*/
|
||||
sum: number;
|
||||
}
|
||||
|
||||
export {default as requestSchema} from 'schema:#SCMinimalResponse';
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "@openstapps/tsconfig"
|
||||
}
|
||||
12
examples/minimal-plugin/tsup.config.ts
Normal file
12
examples/minimal-plugin/tsup.config.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import {defineConfig} from 'tsup';
|
||||
import {jsonSchemaPlugin} from '@openstapps/json-schema-generator';
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/app.ts'],
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
format: 'esm',
|
||||
outDir: 'lib',
|
||||
noExternal: [/.*:schema#.*/],
|
||||
plugins: [jsonSchemaPlugin('schema.json')],
|
||||
});
|
||||
Reference in New Issue
Block a user