introhow it workscase studieslanguagesissuesblog

reverse file content

JavaScript files are expected to be ordered so that calls of a function are after the definition of that function. This is the reverse direction of how Eunice works, but seems to be most popular approach for JavaScript developers. This reversing of file content can be disabled:

npx eunice --reverseFileContent=false

stack file content

JavaScript files aren't assumed to be ordered and so all of the contents are put in the same level of a single level stack. The infer stacks functionality will then try and split this into multiple levels based on the dependencies. If your files have, or you would like them to have, a consistent order (e.g. top down or bottom up, see reverse files content) a multiple levels can be created based on the order within the file (instead of inferring):

npx eunice --stack-file-content=true

ignore paths

Files and sub-directories with names that start with a "." or are named node_modules are ignored by default.

A regular expression can be specified to override the default:

npx eunice --ignore-path-pattern="(^|/)(\..*|node_modules)$"

The forward slash character is converted to an escaped backslash when backslash is the path segment separator.

Babel parser plugins

All non-conflicting Babel parser plugins and the TypeScript plugin (conflicts with Flow) are enabled by default. To override the default plugins:

npx eunice --babel-parser-plugins=flow --babel-parser-plugins=jsx

source directories

Only the current directory is included in analysis by default. Multiple sources of analysis can be specified:

npx eunice --directories=directory1 --directories=directory2

file extensions

By default files with the .js extension are analysed. The default can be replaced or amended (extensions must be prefixed with .):

npx eunice --file-extensions=.ts

infer stacks

Eunice will infer stacks when none are implied or defined. By default this is enabled, but can be disable with:

npx eunice --infer-stacks=false

stack from directory

When multiple sources of analysis are specified (see source directories), a directory of stack files (.eunice-stack.yaml) can be applied to the combined sources:

npx eunice --directories=directory1 --directories=directory2 --directory-to-create-or-add-to-stacks-from=stacks-directory

modify stacks

A stack file can be specified that will be used to modify the structure of all stacks. It only modifies and does not add new items.

npx eunice --modify-stacks-file=stacks.yaml

Optionally a key and regular expression pattern can also be specified to restrict which items have their stacks modified. For example to only modify items that are in files:

npx eunice --modify-stacks-file=stacks.yaml --modify-stacks-key=type --modify-stacks-pattern=^file$

dependency permeable

Item identifiers can be specified so dependencies resolve to their children even though the items weren't specified in the dependency. For example, sub-directories such as, node_modules or src in a mono-repository.

npx eunice --dependency-permeable-identifiers=node_modules

root item

Identifiers for a parent root items can also be specified for each source directory (see source directories):

npx eunice --directories=directory1 --root-item-identifiers=prefixForDirectory1 --directories=directory2 --root-item-identifiers=prefixForDirectory2

output files

For additional output files of SVG or YAML:

npx eunice --output-svg --output-yaml

To name the output files differently or in a different directory:

npx eunice --output-base-file-name=eunice-file --output-directory-path=eunice-directory

To disable the default output file of HTML:

npx eunice --output-html=false

NPM packages

Packages installed in the node_modules directory are not analysed by default (see ignore paths). They can included using the "directories" option above or with:

npx eunice --package-names=package1 --package-names=package2

To aid readability a package prefix and scope can also be specified that will not be included in the output:

// e.g. @scope/prefix-package npx eunice --package-names=package --package-prefix=prefix- --package-scope=scope