diff --git a/apps/demo/project.json b/apps/demo/project.json index 34085d8..4b2493e 100644 --- a/apps/demo/project.json +++ b/apps/demo/project.json @@ -30,7 +30,7 @@ "generate-api-with-core": { "executor": "@nx-plugin-openapi/core:generate-api", "options": { - "generator": "hey-openapi", + "generator": "hey-api", "inputSpec": "apps/demo/swagger.json", "outputPath": "apps/demo/src/app/api-core", "generatorOptions": { diff --git a/packages/core/src/lib/plugin-loader.spec.ts b/packages/core/src/lib/plugin-loader.spec.ts index c6cd2aa..2521249 100644 --- a/packages/core/src/lib/plugin-loader.spec.ts +++ b/packages/core/src/lib/plugin-loader.spec.ts @@ -406,14 +406,14 @@ describe('plugin-loader', () => { it('should use built-in mapping for auto-installation', async () => { const mockPlugin = { - name: 'hey-openapi', + name: 'hey-api', generate: jest.fn(), }; // The module mock will throw on first import, then succeed after "installation" let isInstalled = false; jest.doMock( - '@nx-plugin-openapi/plugin-hey-openapi', + '@nx-plugin-openapi/plugin-hey-api', () => { if (!isInstalled) { const error = new Error('Cannot find module'); @@ -430,10 +430,10 @@ describe('plugin-loader', () => { isInstalled = true; }); - const result = await loadPlugin('hey-openapi'); + const result = await loadPlugin('hey-api'); expect(autoInstaller.installPackages).toHaveBeenCalledWith( - ['@nx-plugin-openapi/plugin-hey-openapi'], + ['@nx-plugin-openapi/plugin-hey-api'], { dev: true } ); expect(result).toBe(mockPlugin); diff --git a/packages/core/src/lib/plugin-loader.ts b/packages/core/src/lib/plugin-loader.ts index 4258cb3..b1390cc 100644 --- a/packages/core/src/lib/plugin-loader.ts +++ b/packages/core/src/lib/plugin-loader.ts @@ -8,7 +8,7 @@ import { isLocalDev } from './utils/is-local-dev'; const BUILTIN_PLUGIN_MAP: Record = { 'openapi-tools': '@nx-plugin-openapi/plugin-openapi', - 'hey-openapi': '@nx-plugin-openapi/plugin-hey-openapi', + 'hey-api': '@nx-plugin-openapi/plugin-hey-api', }; const cache = new Map(); @@ -143,7 +143,7 @@ export async function loadPlugin( if ( isLocal && (pkg === '@nx-plugin-openapi/plugin-openapi' || - pkg === '@nx-plugin-openapi/plugin-hey-openapi') + pkg === '@nx-plugin-openapi/plugin-hey-api') ) { const pkgName = pkg.split('/').pop() ?? ''; const fallbackPaths = [ diff --git a/packages/plugin-hey-openapi/README.md b/packages/plugin-hey-api/README.md similarity index 52% rename from packages/plugin-hey-openapi/README.md rename to packages/plugin-hey-api/README.md index 35a66e3..58b2ea1 100644 --- a/packages/plugin-hey-openapi/README.md +++ b/packages/plugin-hey-api/README.md @@ -1,11 +1,11 @@ -# plugin-hey-openapi +# plugin-hey-api This library provides a generator plugin that uses `@hey-api/openapi-ts` to generate TypeScript clients from OpenAPI specs. ## Building -Run `nx build plugin-hey-openapi` to build the library. +Run `nx build plugin-hey-api` to build the library. ## Running unit tests -Run `nx test plugin-hey-openapi` to execute the unit tests via Jest. +Run `nx test plugin-hey-api` to execute the unit tests via Jest. diff --git a/packages/plugin-hey-openapi/eslint.config.js b/packages/plugin-hey-api/eslint.config.js similarity index 100% rename from packages/plugin-hey-openapi/eslint.config.js rename to packages/plugin-hey-api/eslint.config.js diff --git a/packages/plugin-hey-openapi/jest.config.ts b/packages/plugin-hey-api/jest.config.ts similarity index 68% rename from packages/plugin-hey-openapi/jest.config.ts rename to packages/plugin-hey-api/jest.config.ts index 13248a6..4370e57 100644 --- a/packages/plugin-hey-openapi/jest.config.ts +++ b/packages/plugin-hey-api/jest.config.ts @@ -1,10 +1,10 @@ export default { - displayName: 'plugin-hey-openapi', + displayName: 'plugin-hey-api', preset: '../../jest.preset.js', testEnvironment: 'node', transform: { '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], }, moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/packages/plugin-hey-openapi', + coverageDirectory: '../../coverage/packages/plugin-hey-api', }; diff --git a/packages/plugin-hey-openapi/package.json b/packages/plugin-hey-api/package.json similarity index 86% rename from packages/plugin-hey-openapi/package.json rename to packages/plugin-hey-api/package.json index e5939e1..043d780 100644 --- a/packages/plugin-hey-openapi/package.json +++ b/packages/plugin-hey-api/package.json @@ -1,5 +1,5 @@ { - "name": "@nx-plugin-openapi/plugin-hey-openapi", + "name": "@nx-plugin-openapi/plugin-hey-api", "version": "0.0.1", "dependencies": { "@nx-plugin-openapi/core": "0.0.1", diff --git a/packages/plugin-hey-openapi/project.json b/packages/plugin-hey-api/project.json similarity index 65% rename from packages/plugin-hey-openapi/project.json rename to packages/plugin-hey-api/project.json index 3b43fed..e304e98 100644 --- a/packages/plugin-hey-openapi/project.json +++ b/packages/plugin-hey-api/project.json @@ -1,7 +1,7 @@ { - "name": "plugin-hey-openapi", + "name": "plugin-hey-api", "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/plugin-hey-openapi/src", + "sourceRoot": "packages/plugin-hey-api/src", "projectType": "library", "release": { "version": { @@ -17,10 +17,10 @@ "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/packages/plugin-hey-openapi", - "main": "packages/plugin-hey-openapi/src/index.ts", - "tsConfig": "packages/plugin-hey-openapi/tsconfig.lib.json", - "assets": ["packages/plugin-hey-openapi/*.md"] + "outputPath": "dist/packages/plugin-hey-api", + "main": "packages/plugin-hey-api/src/index.ts", + "tsConfig": "packages/plugin-hey-api/tsconfig.lib.json", + "assets": ["packages/plugin-hey-api/*.md"] } }, "nx-release-publish": { @@ -35,7 +35,7 @@ "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "packages/plugin-hey-openapi/jest.config.ts" + "jestConfig": "packages/plugin-hey-api/jest.config.ts" } } } diff --git a/packages/plugin-hey-api/src/index.ts b/packages/plugin-hey-api/src/index.ts new file mode 100644 index 0000000..8256a85 --- /dev/null +++ b/packages/plugin-hey-api/src/index.ts @@ -0,0 +1,3 @@ +export { default as HeyApiPlugin } from './lib/hey-api-generator'; +export { default } from './lib/hey-api-generator'; +export { HeyApiGenerator } from './lib/hey-api-generator'; diff --git a/packages/plugin-hey-openapi/src/lib/hey-openapi-generator.spec.ts b/packages/plugin-hey-api/src/lib/hey-api-generator.spec.ts similarity index 84% rename from packages/plugin-hey-openapi/src/lib/hey-openapi-generator.spec.ts rename to packages/plugin-hey-api/src/lib/hey-api-generator.spec.ts index 1308764..1b40f11 100644 --- a/packages/plugin-hey-openapi/src/lib/hey-openapi-generator.spec.ts +++ b/packages/plugin-hey-api/src/lib/hey-api-generator.spec.ts @@ -1,4 +1,4 @@ -import { HeyOpenApiGenerator } from './hey-openapi-generator'; +import { HeyApiGenerator } from './hey-api-generator'; import { GeneratorContext } from '@nx-plugin-openapi/core'; jest.mock( @@ -9,14 +9,14 @@ jest.mock( { virtual: true } ); -describe('HeyOpenApiGenerator', () => { - let generator: HeyOpenApiGenerator; +describe('HeyApiGenerator', () => { + let generator: HeyApiGenerator; let mockContext: GeneratorContext; let cleanOutputSpy: jest.SpyInstance; beforeEach(() => { jest.clearAllMocks(); - generator = new HeyOpenApiGenerator(); + generator = new HeyApiGenerator(); mockContext = { root: '/workspace', workspaceName: 'test' }; // Spy on cleanOutput inherited from BaseGenerator cleanOutputSpy = jest @@ -28,7 +28,7 @@ describe('HeyOpenApiGenerator', () => { }); it('should have correct plugin name', () => { - expect(generator.name).toBe('hey-openapi'); + expect(generator.name).toBe('hey-api'); }); it('should call openapi-ts generate for single spec', async () => { @@ -41,7 +41,7 @@ describe('HeyOpenApiGenerator', () => { inputSpec: 'api.yaml', outputPath: 'src/generated', generatorOptions: { client: 'fetch' }, - } as unknown as Parameters[0], + } as unknown as Parameters[0], mockContext ); @@ -64,7 +64,7 @@ describe('HeyOpenApiGenerator', () => { { inputSpec: { users: 'users.yaml', products: 'products.yaml' }, outputPath: 'src/api', - } as unknown as Parameters[0], + } as unknown as Parameters[0], mockContext ); diff --git a/packages/plugin-hey-openapi/src/lib/hey-openapi-generator.ts b/packages/plugin-hey-api/src/lib/hey-api-generator.ts similarity index 86% rename from packages/plugin-hey-openapi/src/lib/hey-openapi-generator.ts rename to packages/plugin-hey-api/src/lib/hey-api-generator.ts index 04ff3d0..3d2bf10 100644 --- a/packages/plugin-hey-openapi/src/lib/hey-openapi-generator.ts +++ b/packages/plugin-hey-api/src/lib/hey-api-generator.ts @@ -7,25 +7,25 @@ import { GenerateOptionsBase, } from '@nx-plugin-openapi/core'; -export interface HeyOpenApiOptions { +export interface HeyApiOptions { [key: string]: unknown; } -export class HeyOpenApiGenerator +export class HeyApiGenerator extends BaseGenerator - implements GeneratorPlugin + implements GeneratorPlugin { - readonly name = 'hey-openapi'; + readonly name = 'hey-api'; async generate( - options: HeyOpenApiOptions & GenerateOptionsBase, + options: HeyApiOptions & GenerateOptionsBase, ctx: GeneratorContext ): Promise { const { inputSpec, outputPath } = options; const generatorOptions = (options.generatorOptions || - {}) as Partial; + {}) as Partial; - logger.info(`Starting hey-openapi code generation`); + logger.info(`Starting hey-api code generation`); logger.debug(`Input spec: ${JSON.stringify(inputSpec)}`); logger.debug(`Output path: ${outputPath}`); @@ -56,7 +56,7 @@ export class HeyOpenApiGenerator } } - logger.info(`hey-openapi code generation completed successfully`); + logger.info(`hey-api code generation completed successfully`); } private async invokeOpenApiTs( @@ -97,4 +97,4 @@ export class HeyOpenApiGenerator } } -export default new HeyOpenApiGenerator(); +export default new HeyApiGenerator(); diff --git a/packages/plugin-hey-openapi/src/types/openapi-ts.d.ts b/packages/plugin-hey-api/src/types/openapi-ts.d.ts similarity index 100% rename from packages/plugin-hey-openapi/src/types/openapi-ts.d.ts rename to packages/plugin-hey-api/src/types/openapi-ts.d.ts diff --git a/packages/plugin-hey-openapi/tsconfig.json b/packages/plugin-hey-api/tsconfig.json similarity index 100% rename from packages/plugin-hey-openapi/tsconfig.json rename to packages/plugin-hey-api/tsconfig.json diff --git a/packages/plugin-hey-openapi/tsconfig.lib.json b/packages/plugin-hey-api/tsconfig.lib.json similarity index 100% rename from packages/plugin-hey-openapi/tsconfig.lib.json rename to packages/plugin-hey-api/tsconfig.lib.json diff --git a/packages/plugin-hey-openapi/tsconfig.spec.json b/packages/plugin-hey-api/tsconfig.spec.json similarity index 100% rename from packages/plugin-hey-openapi/tsconfig.spec.json rename to packages/plugin-hey-api/tsconfig.spec.json diff --git a/packages/plugin-hey-openapi/src/index.ts b/packages/plugin-hey-openapi/src/index.ts deleted file mode 100644 index ddc8c87..0000000 --- a/packages/plugin-hey-openapi/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { default as HeyOpenApiPlugin } from './lib/hey-openapi-generator'; -export { default } from './lib/hey-openapi-generator'; -export { HeyOpenApiGenerator } from './lib/hey-openapi-generator'; diff --git a/tsconfig.base.json b/tsconfig.base.json index 031676c..1353b55 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -21,6 +21,9 @@ "@nx-plugin-openapi/core": ["packages/core/src/index.ts"], "@nx-plugin-openapi/plugin-openapi": [ "packages/plugin-openapi/src/index.ts" + ], + "@nx-plugin-openapi/plugin-hey-api": [ + "packages/plugin-hey-api/src/index.ts" ] } },