Skip to content

Commit

Permalink
new export in heta init
Browse files Browse the repository at this point in the history
  • Loading branch information
metelkin committed Sep 7, 2024
1 parent 550f157 commit 0581be0
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 40 deletions.
48 changes: 43 additions & 5 deletions bin/heta-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,19 @@ const defaultPlatform = {
importModule: {
type: 'heta',
source: 'src/index.heta'
}
},
export: [
'{ format: JSON, filepath: output.json }',
'#{ format: YAML }',
'#{ format: XLSX, omitRows: 3, splitByClass: true }',
'#{ format: SBML, version: L2V4 }',
'#{ format: SLV, eventsOff: false }',
'#{ format: DBSolve }',
'#{ format: Simbio }',
'#{ format: Mrgsolve }',
'#{ format: Matlab }',
'#{ format: Julia }'
]
};

program
Expand All @@ -51,7 +63,7 @@ let opts = program.opts();

// initialize file paths
let targetDir = path.resolve(args[0] || '.');
let filePath = path.join(targetDir, 'platform.json');
let filePath = path.join(targetDir, 'platform.yml');
console.log('Creating a template platform in directory: "' + targetDir + '"...');

// directory does not exist
Expand All @@ -69,11 +81,10 @@ if(!opts.force && fs.existsSync(filePath)){
}

// silent mode
if(opts.silent){
if (opts.silent) {
let platform = defaultPlatform;

// saving files
fs.outputJsonSync(filePath, platform, {spaces: 2});
// saving .gitignore
fs.copySync(
path.join(__dirname, './init/template.gitignore'),
Expand All @@ -84,6 +95,27 @@ if(opts.silent){
path.join(__dirname, './init/template.gitattributes'),
path.join(targetDir, '.gitattributes')
);
// create files in src
let hetaIndexFile = path.join(targetDir, 'src', 'index.heta');
fs.copySync(
path.join(__dirname, './init/index0.heta'),
hetaIndexFile
);

// saving qsp-units.heta and qsp-functions.heta
fs.copySync(
path.join(__dirname, './init/qsp-units.heta'),
path.join(targetDir, 'src/qsp-units.heta')
);
fs.copySync(
path.join(__dirname, './init/qsp-functions.heta'),
path.join(targetDir, 'src/qsp-functions.heta')
);

//fs.outputJsonSync(filePath, platform, {spaces: 2});
let json = JSON.stringify(platform, null, 2);
let yaml = json.replace(/"/g, '');
fs.writeFileSync(filePath, yaml);

console.log('Platform template is created in silent mode.');
console.log('DONE.');
Expand Down Expand Up @@ -203,6 +235,9 @@ prompt(questions)
}
}

// add export formats
platform.export = defaultPlatform.export;

// saving qsp-units.heta and qsp-functions.heta
fs.copySync(
path.join(__dirname, './init/qsp-units.heta'),
Expand All @@ -213,7 +248,10 @@ prompt(questions)
path.join(targetDir, 'src/qsp-functions.heta')
);
// saving platform file
fs.outputJsonSync(filePath, platform, {spaces: 2});
//fs.outputJsonSync(filePath, platform, {spaces: 2});
let json = JSON.stringify(platform, null, 2);
let yaml = json.replace(/"/g, '');
fs.writeFileSync(filePath, yaml);
// saving .gitignore
fs.copySync(
path.join(__dirname, './init/template.gitignore'),
Expand Down
6 changes: 0 additions & 6 deletions bin/init/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,5 @@
"assignments": {
"start_": "1"
}
},
{
"action": "export",
"format": "SBML",
"filepath": "output_sbml",
"version": "L2V4"
}
]
6 changes: 1 addition & 5 deletions bin/init/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@
id: p1
assignments:
start_: 1
-
action: export
format: SBML
filepath: output_sbml
version: L2V4

12 changes: 0 additions & 12 deletions bin/init/index0.heta
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,3 @@ include ./qsp-units.heta;
// include addon.yml type yaml;

p1 @Record .= 1;

// exports
#export { format: JSON, filepath: output };
//#export { format: YAML };
//#export { format: XLSX, omitRows: 3, splitByClass: true };
//#export { format: SBML, version: L2V4 };
//#export { format: SLV, eventsOff: false };
//#export { format: DBSolve };
//#export { format: Simbio };
//#export { format: Mrgsolve };
//#export { format: Matlab };
//#export { format: Julia };
12 changes: 0 additions & 12 deletions bin/init/index1.heta
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,3 @@ include ./table.xlsx type table with { sheet: 4, omitRows: 3 };
// include addon.yml type yaml;

p1 @Record .= 1;

// exports
#export { format: JSON, filepath: output };
//#export { format: YAML };
//#export { format: XLSX, omitRows: 3, splitByClass: true };
//#export { format: SBML, version: L2V4 };
//#export { format: SLV, eventsOff: false };
//#export { format: DBSolve };
//#export { format: Simbio };
//#export { format: Mrgsolve };
//#export { format: Matlab };
//#export { format: Julia };

0 comments on commit 0581be0

Please sign in to comment.