Skip to content

Commit

Permalink
create list of heta
Browse files Browse the repository at this point in the history
  • Loading branch information
metelkin committed Jun 12, 2024
1 parent 15276aa commit 57b0304
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/convert-to-heta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ jobs:
- name: Create collection of heta files
run: |
bash ./bash/make-heta.sh
mkdir -p result/heta
rm -rf result/heta/*
BASE_DIR=./result/heta node ./js/convert-to-heta.js
- name: copy static
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

/result

/draft
/draft
/node_modules
7 changes: 0 additions & 7 deletions bash/make-heta.sh

This file was deleted.

35 changes: 35 additions & 0 deletions js/convert-to-heta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const BASE_DIR = process.env.BASE_DIR || './';
const path = require('path');
const fse = require('fs-extra');
const summaryPath = path.resolve(BASE_DIR, '../sbml/summary');
const summary = require(summaryPath);


let html = ''
html += '<html><head><style></style></head><body><ul>'
summary.cases.forEach((item) => {
if (!item.l3v2RetCode) {
var hetaPath = path.resolve(BASE_DIR, '../sbml', item.id, 'l3v2/heta-code/output.heta');
} else if (!item.l2v5RetCode) {
hetaPath = path.resolve(BASE_DIR, '../sbml', item.id, 'l2v5/heta-code/output.heta');
} else {
return; // skip if no heta files
}

// copy heta files
let heta = fse.readFileSync(hetaPath, 'utf8');

// input description as comment
let synop = fse.readFileSync(path.resolve(BASE_DIR, '../sbml', item.id, 'synopsis.txt'), 'utf8');

// write heta file
let fullContent = `/*${synop}*/\n\n${heta}`;
fse.writeFileSync(path.resolve(BASE_DIR, item.id, 'output.heta'), fullContent);

// update html page
html += `<li><a href="${item.id}/output.heta">${item.id}</a></li>`;
});

html += '</ul></body></html>';

fse.writeFileSync(path.resolve(BASE_DIR, 'index.html'), html);
80 changes: 80 additions & 0 deletions package-lock.json

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

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"fs-extra": "^11.2.0"
}
}

0 comments on commit 57b0304

Please sign in to comment.