Skip to content

Commit b88a9fb

Browse files
authored
Merge pull request #1082 from LeighFinegold/esm_integration_docify_endpoint
Remediate issue with calm docify on 0.6.0 release
2 parents f6722d8 + 6765b0a commit b88a9fb

29 files changed

Lines changed: 202 additions & 196 deletions

cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@finos/calm-cli",
3-
"version": "0.6.1",
3+
"version": "0.6.2",
44
"description": "A set of tools for interacting with the Common Architecture Language Model (CALM)",
55
"main": "dist/index.js",
66
"files": [
@@ -13,7 +13,7 @@
1313
"build": "tsup && npm run copy-calm-schema && npm run copy-docify-templates",
1414
"watch": "node watch.mjs",
1515
"copy-calm-schema": "copyfiles \"../calm/draft/2024-10/meta/*\" dist/calm/",
16-
"copy-docify-templates": "copyfiles \"../shared/src/docify/template-bundles/**/*\" dist --up 4",
16+
"copy-docify-templates": "copyfiles \"../shared/dist/template-bundles/**/*\" dist --up 3",
1717
"test": "vitest run",
1818
"lint": "eslint src",
1919
"lint-fix": "eslint src --fix",

cli/src/cli.e2e.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as os from 'os';
55
import { parseStringPromise } from 'xml2js';
66
import util from 'util';
77
import axios from 'axios';
8-
8+
import { Mock } from 'vitest';
99
// Mock axios
1010
vi.mock('axios');
1111

@@ -189,7 +189,7 @@ describe('CLI Integration Tests', () => {
189189

190190

191191
test('server command starts and responds to /health', async () => {
192-
(axios.get as vi.Mock).mockResolvedValue({ status: 200, data: { status: 'ok' } });
192+
(axios.get as Mock).mockResolvedValue({ status: 200, data: { status: 'ok' } });
193193
const serverCmd = calm('server -p 3002 --schemaDirectory ../../dist/calm/');
194194
const serverProcess = exec(serverCmd);
195195

@@ -222,8 +222,7 @@ describe('CLI Integration Tests', () => {
222222
expect(actualContent).toEqual(expectedContent);
223223
});
224224

225-
//TODO: This simulates Issue 2 of https://github.com/finos/architecture-as-code/issues/1043. Remove skip once fixed.
226-
test.skip('docify command generates expected files', async () => {
225+
test('docify command generates expected files', async () => {
227226
const fixtureDir = path.resolve(__dirname, '../test_fixtures/template');
228227
const testModelPath = path.join(fixtureDir, 'model/document-system.json');
229228
const localDirectory = path.join(fixtureDir, 'model/url-to-file-directory.json');

cli/src/command-helpers/validate.spec.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import { getFormattedOutput, validate, exitBasedOffOfValidationOutcome } from '@finos/calm-shared';
2-
import { initLogger } from '@finos/calm-shared/logger';
2+
import { initLogger } from '@finos/calm-shared';
33
import { mkdirp } from 'mkdirp';
44
import { writeFileSync } from 'fs';
55
import path from 'path';
66
import {runValidate, writeOutputFile, checkValidateOptions} from './validate';
77
import { Command } from 'commander';
8+
import { Mock } from 'vitest';
89

910
vi.mock('@finos/calm-shared', async () => ({
1011
...vi.importActual('@finos/calm-shared'),
1112
validate: vi.fn(),
1213
getFormattedOutput: vi.fn(),
1314
exitBasedOffOfValidationOutcome: vi.fn(),
14-
}));
15-
16-
vi.mock('@finos/calm-shared/logger', () => ({
17-
initLogger: vi.fn(),
15+
initLogger: vi.fn()
1816
}));
1917

2018
vi.mock('mkdirp', () => ({
@@ -43,8 +41,8 @@ describe('runValidate', () => {
4341
};
4442

4543
const fakeOutcome = { valid: true };
46-
(validate as vi.Mock).mockResolvedValue(fakeOutcome);
47-
(getFormattedOutput as vi.Mock).mockReturnValue('formatted output');
44+
(validate as Mock).mockResolvedValue(fakeOutcome);
45+
(getFormattedOutput as Mock).mockReturnValue('formatted output');
4846

4947
await runValidate(options);
5048

@@ -69,9 +67,9 @@ describe('runValidate', () => {
6967
};
7068

7169
const error = new Error('Validation failed');
72-
(validate as vi.Mock).mockRejectedValue(error);
70+
(validate as Mock).mockRejectedValue(error);
7371
const loggerMock = { error: vi.fn(), debug: vi.fn() };
74-
(initLogger as vi.Mock).mockReturnValue(loggerMock);
72+
(initLogger as Mock).mockReturnValue(loggerMock);
7573
const exitSpy = vi.spyOn(process, 'exit').mockImplementation((code?: number) => {
7674
throw new Error(`process.exit called with ${code}`);
7775
});

cli/src/command-helpers/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import { getFormattedOutput, validate, exitBasedOffOfValidationOutcome } from '@finos/calm-shared';
3-
import { initLogger } from '@finos/calm-shared/logger';
3+
import { initLogger } from '@finos/calm-shared';
44
import path from 'path';
55
import { mkdirp } from 'mkdirp';
66
import { writeFileSync } from 'fs';

cli/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#! /usr/bin/env node
21
import { program } from 'commander';
32
import { setupCLI } from './cli';
43

cli/src/server/routes/validation-route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from 'path';
55
import os from 'os';
66
import { v4 as uuidv4 } from 'uuid';
77
import winston from 'winston';
8-
import { ValidationOutcome } from '@finos/calm-shared/commands/validate/validation.output';
8+
import { ValidationOutcome } from '@finos/calm-shared';
99
import rateLimit from 'express-rate-limit';
1010

1111
export class ValidationRouter {

cli/tsconfig.build.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"exclude": ["**/*.spec.ts"]
4+
}

cli/tsconfig.json

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,13 @@
11
{
2-
"extends": "../tsconfig.json",
2+
"extends": "../tsconfig.base.json",
3+
"module": "Preserve",
4+
"moduleResolution": "bundler",
35
"compilerOptions": {
4-
"outDir": "./dist",
5-
"module": "CommonJS",
6-
"target": "ES6",
7-
"esModuleInterop": true,
8-
"forceConsistentCasingInFileNames": true,
9-
"resolveJsonModule": true,
10-
"skipLibCheck": true,
11-
"sourceMap": true,
12-
"moduleResolution": "node",
13-
"types": [
14-
"node",
15-
"jest",
16-
"../vitest/globals"
17-
],
18-
"typeRoots": [
19-
"node_modules/@types",
20-
"../node_modules/@types"
21-
]
6+
"outDir": "dist",
227
},
23-
"references": [
24-
{
25-
"path": "../shared"
26-
}
27-
],
28-
"include": [
29-
"src/**/*",
30-
"package.json"
8+
"include": ["src", "../vitest-globals.d.ts"],
9+
"lib": [
10+
"esnext"
3111
]
32-
}
12+
13+
}

cli/tsup.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@ export default defineConfig({
1515
shims: true,
1616
target: 'es2021',
1717
treeshake: true,
18+
banner: ({ format }) => {
19+
if (format === 'cjs') {
20+
return {
21+
js: '#! /usr/bin/env node'
22+
};
23+
}
24+
}
1825
});

cli/vitest.config.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {defineConfig} from 'vitest/config';
2-
import path from 'path';
32
import {CoverageV8Options} from "vitest/node";
43

54
const v8CoverageSettings: CoverageV8Options = {
@@ -14,13 +13,9 @@ const v8CoverageSettings: CoverageV8Options = {
1413
}
1514

1615
export default defineConfig({
17-
resolve: {
18-
alias: {
19-
'@finos/calm-shared': path.resolve(__dirname, '../shared/src'),
20-
}
21-
},
2216
test: {
2317
globals: true,
18+
environment: 'node',
2419
coverage: {
2520
provider: 'v8',
2621
...v8CoverageSettings,

0 commit comments

Comments
 (0)