Skip to content

jellydn/firebolt-grit-demo

Repository files navigation

Welcome to firebolt-grit-demo 👋

Version

This project showcases how Grit, simple web app with Firebolt, can automate tasks like code migrations with Grit CLI or Github action.

IT Man - Automate Your Codebase: #GritQL & The Future of Software Maintenance with #Grit

Pre-requisites

Install

bun install

Development

bun run dev

Build

bun run build

List all patterns

grit list

Check the current pattern

grit check

Grit Demo 1

Describe the pattern

grit patterns describe <pattern>

For example, to describe the no_console_log pattern, you can run the following command:

grit patterns describe no_console_log

# Remove console.log

Remove `console.log` statements.

- Name: no_console_log
- Language: TSX
- Tags: logging

# Body

engine marzano(0.1)
language js

`console.log($arg)` => . where {
  $arg <: not within catch_clause()
}

# Samples

## Removes a simple `console.log` statement

Input                 | Output
--------------------- | ---------------------
// Do not remove this | // Do not remove this
console.error('foo'); | console.error('foo');
console.log('foo');   |
--------------------- | ---------------------


## Removes the statement in a function

Input                 | Output
--------------------- | ---------------
function f() {        | function f() {}
  console.log('foo'); |
}                     |
--------------------- | ---------------


## Works in a list as well

Input                                                               | Output
------------------------------------------------------------------- | --------------------
server.listen(PORT, console.log(`Server started on port ${PORT}`)); | server.listen(PORT);
------------------------------------------------------------------- | --------------------


## Doesn't remove `console.log` in a catch clause

Input                 | Output
--------------------- | ---------------------
try {                 | try {
} catch (e) {         | } catch (e) {
  console.log('foo'); |   console.log('foo');
}                     | }
--------------------- | ---------------------


## Works on multiple console logs in the same file

Input                 | Output
--------------------- | ---------------------
// Do not remove this | // Do not remove this
console.error('foo'); | console.error('foo');
console.log('foo');   |
console.log('bar');   |
--------------------- | ---------------------

Apply the pattern

grit apply <pattern>

Grit Apply Demo

Edit the pattern with Grit Studio

grit pattern edit <pattern>

For example, to edit the no_alert_js pattern, you can run the following command:

grit patterns edit .grit/patterns/no_alert_js.md
Open in Grit studio: https://app.grit.io/studio?pattern_file=eJyFkLFuAjEMhl%2FFCpWOk7ijrIfo0qVTp25NdbHASg%2FlnDYxrVrEu2MCQmxsyW9%2Fn2zvzTqyEIvpTNM0lmWQQB28RsBASTRAnzt4r9ZxQ833DsMgf9UMqhC9H9hXH5YD%2FVDo4BcTWy4Wy5MbhWXnnE%2BDPokVIhgx%2FSPH6WO7qJVH9jv0BNtcmgs2fehrB6sncO5iKNoJvFEWeMZMsLgURDFdQ%2BMxe1iBNS8UQrRmafns0rxeXiV3kNJlZuYL5VPP0p4mn%2BtHKHGec%2ByLs9%2FmdtyYwxHclHC9

Docker

docker-compose up

Deploy to Fly.io

fly launch

Pre-commit

pre-commit install

Resources

Author

👤 Huynh Duc Dung

Show your support

Give a ⭐️ if this project helped you!

kofi paypal buymeacoffee

About

Quickly build high performance, efficient, full-stack apps on the web.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published