Skip to content

Commit 11d7f41

Browse files
committed
fix(cli): Resolve the CLI CalmHub plugin relative to the CLI directory
1 parent 842eb5d commit 11d7f41

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

shared/src/consts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export const CALM_META_SCHEMA_DIRECTORY = __dirname + '/calm';
1+
export const CALM_META_SCHEMA_DIRECTORY = __dirname + '/calm';
2+
export const CALM_AUTH_PLUGIN_DIRECTORY = __dirname + '/plugins';

shared/src/document-loader/calmhub-custom-document-loader.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { SchemaDirectory } from '../schema-directory';
33
import { execFileSync } from 'child_process';
44
import { constants } from 'os';
55
import { Mock } from 'vitest';
6+
import { CALM_AUTH_PLUGIN_DIRECTORY } from '../consts';
7+
import path from 'path';
68

79
const calmHubBaseUrl = 'http://local-calmhub';
810

@@ -33,7 +35,7 @@ describe('calmhub-custom-document-loader', () => {
3335
const document = await calmHubDocumentLoader.loadMissingDocument(calmHubUrl, 'schema');
3436
expect(document).toEqual(JSON.parse(mockResponse));
3537
expect(execFileSyncMock).toHaveBeenCalledExactlyOnceWith(
36-
'my-calmhub-wrapper',
38+
path.resolve(CALM_AUTH_PLUGIN_DIRECTORY, 'my-calmhub-wrapper'),
3739
['--method', 'GET', calmHubBaseUrl + '/schemas/2025-03/meta/core.json'],
3840
{ 'stdio': 'pipe', 'shell': true, 'encoding': 'utf-8', 'timeout': 30000 });
3941
});
@@ -50,7 +52,7 @@ describe('calmhub-custom-document-loader', () => {
5052

5153
await expect(calmHubDocumentLoader.loadMissingDocument(calmHubUrl, 'schema')).rejects.toThrow();
5254
expect(execFileSyncMock).toHaveBeenCalledExactlyOnceWith(
53-
'my-calmhub-wrapper',
55+
path.resolve(CALM_AUTH_PLUGIN_DIRECTORY, 'my-calmhub-wrapper'),
5456
['--method', 'GET', calmHubBaseUrl + '/schemas/2025-03/meta/nonexistent.json'],
5557
{ 'stdio': 'pipe', 'shell': true, 'encoding': 'utf-8', 'timeout': 30000 });
5658
});

shared/src/document-loader/calmhub-custom-document-loader.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { execFileSync } from 'child_process';
22
import { SchemaDirectory } from '../schema-directory';
33
import { CalmDocumentType, DocumentLoader, CALM_HUB_PROTO } from './document-loader';
44
import { initLogger, Logger } from '../logger';
5+
import path from 'path';
6+
import { CALM_AUTH_PLUGIN_DIRECTORY } from '../consts';
57

68
export class CalmHubCustomDocumentLoader implements DocumentLoader {
79
private readonly logger: Logger;
@@ -10,9 +12,10 @@ export class CalmHubCustomDocumentLoader implements DocumentLoader {
1012

1113
constructor(private calmHubUrl: string, calmHubWrapper: string, debug: boolean) {
1214
this.baseURL = calmHubUrl;
13-
this.wrapper = calmHubWrapper;
15+
this.wrapper = path.resolve(CALM_AUTH_PLUGIN_DIRECTORY, calmHubWrapper);
1416
this.logger = initLogger(debug, 'calmhub-custom-document-loader');
1517
this.logger.info('Configuring CALMHub custom document loader with base URL: ' + calmHubUrl);
18+
this.logger.info('Configuring CALMHub custom document loader with plugin: ' + this.wrapper);
1619
}
1720

1821
async initialise(_: SchemaDirectory): Promise<void> {

0 commit comments

Comments
 (0)