Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tdurieux/dinghy
A library to parse and manipulate Dockerfiles
https://github.com/tdurieux/dinghy
ast dockerfile parser
Last synced: 2 months ago
JSON representation
A library to parse and manipulate Dockerfiles
- Host: GitHub
- URL: https://github.com/tdurieux/dinghy
- Owner: tdurieux
- Created: 2022-12-21T06:49:51.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-15T12:30:45.000Z (7 months ago)
- Last Synced: 2024-05-16T01:25:12.185Z (7 months ago)
- Topics: ast, dockerfile, parser
- Language: TypeScript
- Homepage: https://durieux.me/Dinghy/
- Size: 3.14 MB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# **Dinghy: Versatile AST Generator for Shell Scripts and Dockerfiles**
[![CI](https://github.com/tdurieux/Dinghy/actions/workflows/build-test.yml/badge.svg)](https://github.com/tdurieux/Dinghy/actions/workflows/build-test.yml) ![NPM Version](https://img.shields.io/npm/v/%40tdurieux%2Fdinghy)
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/](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
```bash
npm install @tdurieux/dinghy
```## Usage
```typescript
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!**