Skip to content

Commit

Permalink
finos#446 - Upgrade CLI to 2024-10. (finos#696)
Browse files Browse the repository at this point in the history
* finos#446 - Upgrade CLI to 2024-10.

For now this is only ensuring that the draft version is updated - not that the examples/functionality exposed by the upgraded CALM version would provide - these are covered by other issues.

* PR review fixes.
  • Loading branch information
Thels authored Dec 20, 2024
1 parent c0fa2d7 commit 7e2a717
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 23 deletions.
22 changes: 11 additions & 11 deletions calm/pattern/api-gateway.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/calm.json",
"$schema": "https://calm.finos.org/draft/2024-10/meta/calm.json",
"$id": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/pattern/api-gateway",
"title": "API Gateway Pattern",
"type": "object",
Expand All @@ -9,7 +9,7 @@
"minItems": 4,
"prefixItems": [
{
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/core.json#/defs/node",
"$ref": "https://calm.finos.org/draft/2024-10/meta/core.json#/defs/node",
"properties": {
"well-known-endpoint": {
"type": "string"
Expand All @@ -31,7 +31,7 @@
"minItems": 1,
"prefixItems": [
{
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/interface.json#/defs/host-port-interface",
"$ref": "https://calm.finos.org/draft/2024-10/meta/interface.json#/defs/host-port-interface",
"properties": {
"unique-id": {
"const": "api-gateway-ingress"
Expand All @@ -47,7 +47,7 @@
]
},
{
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/core.json#/defs/node",
"$ref": "https://calm.finos.org/draft/2024-10/meta/core.json#/defs/node",
"properties": {
"description": {
"const": "The API Consumer making an authenticated and authorized request"
Expand All @@ -64,7 +64,7 @@
}
},
{
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/core.json#/defs/node",
"$ref": "https://calm.finos.org/draft/2024-10/meta/core.json#/defs/node",
"properties": {
"description": {
"const": "The API Producer serving content"
Expand All @@ -83,7 +83,7 @@
"minItems": 1,
"prefixItems": [
{
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/interface.json#/defs/host-port-interface",
"$ref": "https://calm.finos.org/draft/2024-10/meta/interface.json#/defs/host-port-interface",
"properties": {
"unique-id": {
"const": "producer-ingress"
Expand All @@ -98,7 +98,7 @@
]
},
{
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/core.json#/defs/node",
"$ref": "https://calm.finos.org/draft/2024-10/meta/core.json#/defs/node",
"properties": {
"description": {
"const": "The Identity Provider used to verify the bearer token"
Expand All @@ -121,7 +121,7 @@
"minItems": 4,
"prefixItems": [
{
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/core.json#/defs/relationship",
"$ref": "https://calm.finos.org/draft/2024-10/meta/core.json#/defs/relationship",
"properties": {
"unique-id": {
"const": "api-consumer-api-gateway"
Expand Down Expand Up @@ -154,7 +154,7 @@
}
},
{
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/core.json#/defs/relationship",
"$ref": "https://calm.finos.org/draft/2024-10/meta/core.json#/defs/relationship",
"properties": {
"unique-id": {
"const": "api-gateway-idp"
Expand All @@ -180,7 +180,7 @@
}
},
{
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/core.json#/defs/relationship",
"$ref": "https://calm.finos.org/draft/2024-10/meta/core.json#/defs/relationship",
"properties": {
"unique-id": {
"const": "api-gateway-api-producer"
Expand Down Expand Up @@ -209,7 +209,7 @@
}
},
{
"$ref": "https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/core.json#/defs/relationship",
"$ref": "https://calm.finos.org/draft/2024-10/meta/core.json#/defs/relationship",
"properties": {
"unique-id": {
"const": "api-consumer-idp"
Expand Down
4 changes: 2 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@finos/calm-cli",
"version": "0.2.7",
"version": "0.3.0",
"description": "A set of tools for interacting with the Common Architecture Language Model (CALM)",
"main": "dist/index.js",
"files": [
Expand All @@ -12,7 +12,7 @@
"scripts": {
"build": "tsup && npm run copy-calm-schema",
"watch": "node watch.mjs",
"copy-calm-schema": "copyfiles \"../calm/draft/2024-04/meta/*\" dist/calm/",
"copy-calm-schema": "copyfiles \"../calm/draft/2024-10/meta/*\" dist/calm/",
"test": "jest",
"lint": "eslint src",
"lint-fix": "eslint src --fix",
Expand Down
3 changes: 2 additions & 1 deletion cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Option, program } from 'commander';
import path from 'path';
import { mkdirp } from 'mkdirp';
import { writeFileSync } from 'fs';
import { version } from '../package.json';

const FORMAT_OPTION = '-f, --format <format>';
const ARCHITECTURE_OPTION = '-a, --architecture <file>';
Expand All @@ -17,7 +18,7 @@ const VERBOSE_OPTION = '-v, --verbose';

program
.name('calm')
.version('0.2.5')
.version(version)
.description('A set of tools for interacting with the Common Architecture Language Model (CALM)');

program
Expand Down
4 changes: 3 additions & 1 deletion cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"target": "ES6",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"moduleResolution": "node",
"types": [
Expand All @@ -23,6 +24,7 @@
}
],
"include": [
"src/**/*"
"src/**/*",
"package.json"
]
}
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion shared/src/commands/generate/generate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jest.mock('../helper', () => {
jest.mock('./schema-directory');

jest.mock('../../consts', () => ({
get CALM_META_SCHEMA_DIRECTORY() { return '../calm/draft/2024-04/meta'; }
get CALM_META_SCHEMA_DIRECTORY() { return '../calm/draft/2024-10/meta'; }
}));


Expand Down
25 changes: 25 additions & 0 deletions shared/src/commands/generate/schema-directory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,29 @@ describe('SchemaDirectory', () => {
expect(schemaDir.getLoadedSchemas().length).toBe(2);
});

it('loads all specs from given directory including subdirectories - 2024-10 schema', async () => {
const schemaDir = new SchemaDirectory();

await schemaDir.loadSchemas('../calm/draft/2024-10');
expect(schemaDir.getLoadedSchemas().length).toBe(8);

const loadedSchemas = schemaDir.getLoadedSchemas();
const expectedFileNames = [
'https://calm.finos.org/draft/2024-10/meta/calm.json',
'https://calm.finos.org/draft/2024-10/meta/control-requirement.json',
'https://calm.finos.org/draft/2024-10/meta/control.json',
'https://calm.finos.org/draft/2024-10/meta/core.json',
'https://calm.finos.org/draft/2024-10/meta/evidence.json',
'https://calm.finos.org/draft/2024-10/meta/flow.json',
'https://calm.finos.org/draft/2024-10/meta/interface.json',
'https://calm.finos.org/draft/2024-10/meta/units.json'
];

expectedFileNames.forEach((fileName, index) => {
expect(loadedSchemas[index]).toBe(fileName);
});
});

it('resolves a reference from a loaded schema', async () => {
const schemaDir = new SchemaDirectory();

Expand Down Expand Up @@ -67,6 +90,8 @@ describe('SchemaDirectory', () => {
expect(interfaceDef.properties['missing-value']).toEqual('MISSING OBJECT, ref: ' + interfaceRef + ' could not be resolved');
});



it('terminate early in the case of a circular reference', async () => {
const schemaDir = new SchemaDirectory();

Expand Down
3 changes: 3 additions & 0 deletions shared/src/commands/generate/schema-directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export class SchemaDirectory {

map.forEach((val, key) => this.schemas.set(key, val));
this.logger.info(`Loaded ${this.schemas.size} schemas.`);
this.schemas.forEach((_schema, id) => {
this.logger.debug(`Schema ID: ${id}`);
});
} catch (err) {
if (err.code === 'ENOENT') {
this.logger.error('Schema Path not found: ', dir, ', error: ', err);
Expand Down
4 changes: 2 additions & 2 deletions shared/src/commands/validate/validate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ describe('validate-all', () => {
const given: ErrorObject[] = [
{
'instancePath': '/nodes/0/interfaces/0/port',
'schemaPath': 'https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/interface.json#/defs/host-port-interface/properties/port/type',
'schemaPath': 'https://calm.finos.org/draft/2024-10/meta/interface.json#/defs/host-port-interface/properties/port/type',
'keyword': 'type',
'params': {
'type': 'integer'
Expand All @@ -369,7 +369,7 @@ describe('validate-all', () => {
'error',
'must be integer',
'/nodes/0/interfaces/0/port',
'https://raw.githubusercontent.com/finos/architecture-as-code/main/calm/draft/2024-04/meta/interface.json#/defs/host-port-interface/properties/port/type'
'https://calm.finos.org/draft/2024-10/meta/interface.json#/defs/host-port-interface/properties/port/type'
)
];

Expand Down
2 changes: 1 addition & 1 deletion shared/src/commands/visualize/visualize.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jest.mock('../helper.js', () => {
jest.mock('../generate/generate');

jest.mock('../../consts', () => ({
get CALM_META_SCHEMA_DIRECTORY() { return '../calm/draft/2024-04/meta'; }
get CALM_META_SCHEMA_DIRECTORY() { return '../calm/draft/2024-10/meta'; }
}));

describe('visualizer', () => {
Expand Down

0 comments on commit 7e2a717

Please sign in to comment.