Skip to content

Commit

Permalink
only relative paths in export
Browse files Browse the repository at this point in the history
  • Loading branch information
metelkin committed Jan 13, 2025
1 parent 1e2d3f4 commit 660aa41
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
26 changes: 4 additions & 22 deletions cli-references.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ List of `heta build` options:
| --type | \<string\> | heta | Type of source file. This option allows to select type of module which will be applied for parsing. Available values: heta/xlsx/json/yaml/sbml. |
| --debug | | | Working in debugging mode. All parsed files will be saved in JSON files in **meta** directory. |
| --units-check | | | If set all records will be checked for units consistency. |
| --dist-dir | \<string\> | | Set export directory path, where to store exported files. |
| --meta-dir | \<string\> | | Set meta directory path. |
| --log-mode | string | error | The rule in which case the log file should be created. Possible values are: never/error/always |
| --dist-dir | \<string\> | | Set export directory path, where to store exported files. Path can be absolute or relative to the project directory. |
| --meta-dir | \<string\> | | Set meta directory path. Path can be absolute or relative to the project directory.|
| --log-mode | string | error | The rule in which case the log file should be created. Possible values are: never/error/always. Path can be absolute or relative to the project directory. |
| -d, --declaration | string | platform | The filepath to declaration file (see below) without extension. The command will search the declaration file based on option trying a set of extensions: .json/.yml. |
| --log-level | string | error | The level of log information to display. Possible values are: error/warn/info/debug. |
| --skip-updates | | | Do not check available new version in npm. |
Expand Down Expand Up @@ -157,24 +157,6 @@ If we check the content of the created "test" directory we will see the followin

**.gitattributes, .gitignore** : templates to help working with [Git](https://git-scm.com/)

## "heta update" command

*Experimental*

`heta update` installs the latest version of heta-compiler available on NPM.

If the additional argument `[version]` is set then it will install the selected version.

The command is equivalen to `npm install --global heta-compiler`.

#### Example

To install the selected version.

```bash
heta update 0.7.1
```

## "heta help" command

To obtain a list of options and command description one can use command help.
Expand Down Expand Up @@ -218,7 +200,7 @@ There are properties in declaration file which do not change compilation process
| options.metaDir | string | --meta-dir | meta | If `options.debug` is set as `true` this option changes the target directory for meta files. |
| export | object[] | -e, --export | `[]` | List of export formats to run divided by colon. Each component includes `format` option and optional settings. see more details in [export-formats](./export-formats.md). |

Using neither declaration file nor CLI options is equivalent to the following declaration:
Using neither declaration file nor CLI options is equivalent to the following declaration file:
```json
{
"builderVersion": "<current buider version>",
Expand Down
18 changes: 17 additions & 1 deletion export-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ See [migrate to v0.9](./migrate-to-v0.9.md) and [CLI references](./cli-reference

There are two recommended ways to export models in Heta compiler: using [`export` property](./cli-references.md#declaration-file-format) in declaration file or using CLI [`--export` property](./cli-references.md#running-build-with CLI-options). If no --export option is set, the compiler will use the `export` property from the declaration file.

The `export` property is an array of objects with `format` property and other format-specific properties.
The `export` property is an array of objects with the `format` and `filepath` properties and other format-specific properties.

- `format` is a case-sensitive string with the name of the format. The list of supported formats is below.
- `filepath` is an *optional* property, which is a string with the path to the output directory. The path is relative to the output (`dist`) directory.

**Example**

```yaml
{
Expand All @@ -61,11 +66,22 @@ The `export` property is an array of objects with `format` property and other fo
format: SBML,
version: L2V4,
filepath: model
},
{
format: Table
}
]
}
```

Instead of `export` property in the declaration file, one can use CLI `--export` option. The option is an comma-separated list of format names. The list ai also supports structures in JSON format. If the `--export` option is set, the compiler will ignore the `export` property in the declaration file.

**Example**

```bash
heta build --export '{format: JSON, filepath: output, omit: ["aux.wiki"], spaceFilter: "nameless|another"}, {format: SBML, version: L2V4, filepath: model}, Table'
```

## JSON

Export to [JSON structure](https://www.json.org/) (array) storing the content of whole platform or selected namespaces (see spaceFilter option).
Expand Down
6 changes: 6 additions & 0 deletions src/builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ class Builder {
this.exportArray = [];
// create "export" instances
declaration.export.forEach((exportItem) => {
// check the filepath
if (!!exportItem.filepath && path.isAbsolute(exportItem.filepath)) {
logger.error(`Export item property "filepath" must be relative, got ${JSON.stringify(exportItem)}.`, {type: 'BuilderError'});
}

// check if format is supported
let ExportClass = this.exportClasses.hasOwnProperty(exportItem.format)
&& this.exportClasses[exportItem.format];
if (ExportClass) {
Expand Down

0 comments on commit 660aa41

Please sign in to comment.