8000 GitHub - tdurieux/Dinghy: A library to parse and manipulate Dockerfiles
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

tdurieux/Dinghy

Repository files navigation

Dinghy: Versatile AST Generator for Shell Scripts and Dockerfiles

CI NPM Version

Dinghy is a robust library designed to generate Abstract Syntax Trees (ASTs) for both shell scripts and Dockerfiles. It offers developers a solution for parsing and analyzing these files, facilitating advanced automation and analysis tasks.

For detailed documentation, please visit https://durieux.me/Dinghy/.

Features

  • AST Generation: Effortlessly generate ASTs for shell scripts and Dockerfiles.
  • Parsing: Accurately parse complex Dockerfiles, capturing their structure and directives.
  • Traversal: Traverse the AST to perform various analysis tasks such as linting or modification.
  • Querying: Extract specific information about commands, arguments, and more with ease.
  • Modular Design: Built with modularity in mind, enabling easy extension and customization.
  • TypeScript Support: Fully compatible with TypeScript for type-safe development.

Installation

npm install @tdurieux/dinghy

Usage

import dinghy from "@tdurieux/dinghy";

// Parse Dockerfile
const dockerAST = dinghy.parseDocker(/* file path or file content */);
dockerAST.traverse((node) => {
  if (node instanceof dinghy.AbstractValueNode) {
    console.log(node.value);
  }
});

// Parse Shell Script
const shellAST = dinghy.parseShell(/* file path or file content */);
shellAST.traverse((node) => {
  if (node instanceof dinghy.AbstractValueNode) {
    console.log(node.value);
  }
});

Additional examples are available in the library's test suite.

Contributing

Contributions to Dinghy are welcome! Whether it's bug fixes, new features, or documentation improvements, feel free to submit pull requests on our GitHub repository.

License

Dinghy is licensed under the MIT License. See the LICENSE file for details.

Happy Coding with Dinghy!

About

A library to parse and manipulate Dockerfiles

Topics

Resources

Stars

Watchers

Forks

Languages

0