From 25a48332d632dff88afb7e8011e07d1dc0c56a1c Mon Sep 17 00:00:00 2001 From: Mr Wand Date: Thu, 5 Dec 2024 11:58:03 -0500 Subject: [PATCH] remove oscal-js --- build/Makefile | 6 ++++-- build/features/step_defenitions/steps.ts | 26 +++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/build/Makefile b/build/Makefile index 6380cc1506..69d0099960 100644 --- a/build/Makefile +++ b/build/Makefile @@ -33,9 +33,11 @@ test: configure: npm install wget https://repo1.maven.org/maven2/dev/metaschema/oscal/oscal-cli-enhanced/2.4.0/oscal-cli-enhanced-2.4.0-oscal-cli.zip - unzip -j oscal-cli-enhanced-2.4.0-oscal-cli.zip -d node_modules/.bin/oscal-cli-enhanced + unzip -o oscal-cli-enhanced-2.4.0-oscal-cli.zip -d node_modules/.bin/oscal-cli-enhanced rm oscal-cli-enhanced-2.4.0-oscal-cli.zip - ln -sf $(pwd)/node_modules/.bin/oscal-cli-enhanced/bin/oscal-cli node_modules/.bin/oscal-cli + ln -sf oscal-cli-enhanced/bin/oscal-cli node_modules/.bin/oscal-cli + chmod +x node_modules/.bin/oscal-cli-enhanced/bin/oscal-cli + .PHONY: clean clean: clean-schemas clean-linkcheck clean-converters clean-archives clean-resolved-metaschemas ## Remove all generated content diff --git a/build/features/step_defenitions/steps.ts b/build/features/step_defenitions/steps.ts index 16a05d857d..98e834c594 100644 --- a/build/features/step_defenitions/steps.ts +++ b/build/features/step_defenitions/steps.ts @@ -10,7 +10,8 @@ Given('the following directories by type:', function(dataTable:any) { }); Given('the OSCAL CLI tool is installed', async function() { - const success = await execSync("which oscal-cli"); + const success=execSync(`npx oscal-cli --version`) + if (!success) throw new Error('OSCAL CLI not installed'); }); @@ -19,13 +20,28 @@ Given('the metaschema directory is {string}', function(dir) { }); When('I validate {string} content in {string}',{timeout:90000}, async function(type, path) { - - const metaschema = 'oscal_'+type+'_metaschema.xml' ; + const metaschema = 'oscal_'+type+'_metaschema.xml'; const metaschemaPath = `${this.metaschemaDir}/${metaschema}`; - await execSync('oscal-cli metaschema validate-content '+path+"-m "+metaschemaPath); + + try { + const output = execSync(`npx oscal-cli metaschema validate-content ${path} -m ${metaschemaPath}`, { + stdio: 'pipe', + encoding: 'utf-8' + }); + this.result = { isValid: true, output }; + } catch (error:any) { + this.result = { + isValid: false, + error: error.message, + stderr: error.stderr?.toString(), + stdout: error.stdout?.toString() + }; + } + }); + Then('all validations should pass without errors', function() { if (!this.result.isValid) { - throw new Error(`Validation failed:`); + throw new Error(`Validation failed:\n`+this.result.stderr); } });