Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sample .env file:
PARSER_PATH='@accordproject/concerto-cto'
MODELFILE_PATH='@accordproject/concerto-core'
MODELMANAGER_PATH='@accordproject/concerto-core'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
package-lock.json
package-lock.json
.env
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@accordproject/concerto-core": "^3.21.0",
"@accordproject/concerto-cto": "^3.22.0",
"child_process": "^1.0.2",
"dotenv": "^17.0.1",
"fs": "^0.0.1-security",
"inquirer": "^12.6.3",
"path": "^0.12.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("Semantic.Support.CSharp")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+069d3994476d298ecb67f9eee824952d7af16260")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3a565f9047bb3b3eb26525cedffd7946ff5b481c")]
[assembly: System.Reflection.AssemblyProductAttribute("Semantic.Support.CSharp")]
[assembly: System.Reflection.AssemblyTitleAttribute("Semantic.Support.CSharp")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
728d0b1b0d333a3b88a57dc69ea86f43dc0b627052d6c700db51c82470e30ee7
0bfa4995d66ed028f4cae65820b76d35749d7a869837ab73a1460169f77b1736
15 changes: 12 additions & 3 deletions semantic/features/support/Javascript/steps.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { Given, When, Then } from '@cucumber/cucumber';
import { Given, When, Then, Before } from '@cucumber/cucumber';
import { loadCTO } from './utils/loadCTO.ts';
import { Parser } from '@accordproject/concerto-cto';
import { ModelFile } from '@accordproject/concerto-core';
import { loadDependencies } from './utils/dynamicLoader.ts';
import assert from 'assert';

let Parser: any;
let ModelFile: any;

Before(async function () {
await this.initialize();
const deps = await loadDependencies();
Parser = deps.Parser;
ModelFile = deps.ModelFile;
});

Given('I load the following models:', function (dataTable) {
for (const row of dataTable.hashes()) {
const modelContent = loadCTO(row.model_file);
Expand Down
27 changes: 27 additions & 0 deletions semantic/features/support/Javascript/utils/dynamicLoader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as dotenv from 'dotenv';
dotenv.config();

export async function loadDependencies() {
const parserPath = process.env.PARSER_PATH || '@accordproject/concerto-cto';
const modelFilePath = process.env.MODELFILE_PATH || '@accordproject/concerto-core';
const modelManagerPath = process.env.MODELMANAGER_PATH || '@accordproject/concerto-core';

try {
const parserModule = await import(parserPath);
const modelFileModule = await import(modelFilePath);
const modelManagerModule = await import(modelManagerPath);

if (!parserModule.Parser || !modelFileModule.ModelFile || !modelManagerModule.ModelManager) {
throw new Error('Failed to load Parser, ModelFile, or ModelManager. Check paths or exports.');
}

return {
Parser: parserModule.Parser,
ModelFile: modelFileModule.ModelFile,
ModelManager: modelManagerModule.ModelManager
};
} catch (err) {
console.error('Failed to dynamically load dependencies:', err);
process.exit(1);
}
}
12 changes: 8 additions & 4 deletions semantic/features/support/Javascript/world.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { ModelManager } from '@accordproject/concerto-core';

import { setWorldConstructor, IWorldOptions } from '@cucumber/cucumber';
import { loadDependencies } from './utils/dynamicLoader.ts';

export class CustomWorld {
public modelManager: ModelManager;
public modelManager: any;
public error: Error | null;

constructor(options: IWorldOptions) {
this.modelManager = new ModelManager({ enableMapType: true });
this.error = null;
}

async initialize() {
const deps = await loadDependencies();
const ModelManager = deps.ModelManager;
this.modelManager = new ModelManager({ enableMapType: true });
}
}

setWorldConstructor(CustomWorld);