Skip to content

Commit

Permalink
Update dependencies, add GitHub Pull Requests extension, and enhance …
Browse files Browse the repository at this point in the history
…error messaging (#686)

* run prettier

* Update various dependencies, remove zx package, and enhance error messaging with URL in run script

* Add GitHub Pull Requests extension to devcontainer and vscode configs

* Add mustache template engine usage example to parsers documentation

* Update mustache template functions and documentation in parsers and types

* add husky

* Added commit message automation script using GenAI in the project's husky hook configuration

* Update commit-msg hook to run only if commit message is not empty

* Add condition to skip message generator if a commit message is provided

* Modify husky commit-msg hook to always run message generator

* better user message filter
  • Loading branch information
pelikhan authored Sep 4, 2024
1 parent 927306d commit ec62305
Show file tree
Hide file tree
Showing 55 changed files with 1,422 additions and 1,611 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"astro-build.astro-vscode",
"unifiedjs.vscode-mdx",
"streetsidesoftware.code-spell-checker",
"file-icons.file-icons"
"file-icons.file-icons",
"GitHub.vscode-pull-request-github"
]
}
},
Expand Down
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node packages/cli/built/genaiscript.cjs run commit-msg "$1"
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
prettier $(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') --write --ignore-unknown
git update-index --again
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"astro-build.astro-vscode",
"github.copilot-chat",
"tldraw-org.tldraw-vscode",
"bierner.emojisense"
"bierner.emojisense",
"github.vscode-pull-request-github"
]
}
828 changes: 40 additions & 788 deletions THIRD_PARTY_LICENSES.md

Large diffs are not rendered by default.

107 changes: 67 additions & 40 deletions demo/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 66 additions & 33 deletions docs/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions docs/src/content/docs/reference/scripts/parsers.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,11 @@ The `parsers.validateJSON` function validates a JSON string against a schema.
```js
const validation = parsers.validateJSON(schema, json)
```

## mustache

Runs the [mustache](https://mustache.github.io/) template engine in the string and arguments.

```js
const rendered = parsers.mustache("Today is {{date}}.", { date: new Date() })
```
28 changes: 14 additions & 14 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1004,9 +1004,9 @@
"@types/unist" "*"

"@types/node@*", "@types/node@>=20":
version "22.5.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.2.tgz#e42344429702e69e28c839a7e16a8262a8086793"
integrity sha512-acJsPTEqYqulZS/Yp/S3GgeE6GZ0qYODUR8aVr/DkhHQ8l9nd4j5x1/ZJy9/gHrRlFMqkO6i0I3E27Alu4jjPg==
version "22.5.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.3.tgz#91a374e42c6e7ccb5893a87f1775f36ce1671d65"
integrity sha512-njripolh85IA9SQGTAqbmnNZTdxv7X/4OYGPz8tgy5JDr8MP+uDBa921GpYEoDDnwm0Hmn5ZPeJgiiSTPoOzkQ==
dependencies:
undici-types "~6.19.2"

Expand Down Expand Up @@ -3262,10 +3262,10 @@ postcss-selector-parser@^6.1.1:
cssesc "^3.0.0"
util-deprecate "^1.0.2"

postcss@^8.4.38, postcss@^8.4.41:
version "8.4.44"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.44.tgz#d56834ef6508610ba224bb22b2457b2169ed0480"
integrity sha512-Aweb9unOEpQ3ezu4Q00DPvvM2ZTUitJdNKeP/+uQgr1IBIqu574IaZoURId7BKtWMREwzKa9OgzPzezWGPWFQw==
postcss@^8.4.38, postcss@^8.4.43:
version "8.4.45"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.45.tgz#538d13d89a16ef71edbf75d895284ae06b79e603"
integrity sha512-7KTLTdzdZZYscUc65XmjFiB73vBhBfbPztCYdUNvlaso9PrzjzcmjqBPR0lNGkcVlcO4BjiO5rK/qNz+XAen1Q==
dependencies:
nanoid "^3.3.7"
picocolors "^1.0.1"
Expand Down Expand Up @@ -3972,12 +3972,12 @@ vfile@^6.0.0, vfile@^6.0.2, vfile@^6.0.3:
vfile-message "^4.0.0"

vite@^5.4.2:
version "5.4.2"
resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.2.tgz#8acb6ec4bfab823cdfc1cb2d6c53ed311bc4e47e"
integrity sha512-dDrQTRHp5C1fTFzcSaMxjk6vdpKvT+2/mIdE07Gw2ykehT49O0z/VHS3zZ8iV/Gh8BJJKHWOe5RjaNrW5xf/GA==
version "5.4.3"
resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.3.tgz#771c470e808cb6732f204e1ee96c2ed65b97a0eb"
integrity sha512-IH+nl64eq9lJjFqU+/yrRnrHPVTlgy42/+IzbOdaFDVlyLgI/wDlf+FCobXLX1cT0X5+7LMyH1mIy2xJdLfo8Q==
dependencies:
esbuild "^0.21.3"
postcss "^8.4.41"
postcss "^8.4.43"
rollup "^4.20.0"
optionalDependencies:
fsevents "~2.3.3"
Expand Down Expand Up @@ -4231,9 +4231,9 @@ [email protected]:
integrity sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==

yaml@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.5.0.tgz#c6165a721cf8000e91c36490a41d7be25176cf5d"
integrity sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==
version "2.5.1"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.5.1.tgz#c9772aacf62cb7494a95b0c4f1fb065b563db130"
integrity sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==

yargs-parser@^21.1.1:
version "21.1.1"
Expand Down
28 changes: 28 additions & 0 deletions genaisrc/commit-msg.genai.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const msg = env.files[0]
const msgContent = msg.content
?.split(/\n/g)
.filter((l) => l && !/^#/.test(l))
.join("\n")
if (msgContent) cancel("commit message already exists")

// Check for staged changes and stage all changes if none are staged
let diff = await host.exec("git", ["diff", "--cached"])
if (!diff.stdout) cancel("no staged changes")
// Generate commit message
const res = await runPrompt(
(_) => {
_.def("GIT_DIFF", diff, { maxTokens: 20000 })
_.$`GIT_DIFF is a diff of all staged changes, coming from the command:
\`\`\`
git diff --cached
\`\`\`
Please generate a concise, one-line commit message for these changes.
- do NOT add quotes`
},
{ cache: false, temperature: 0.8 }
)

if (res.error) throw res.error
const message = res.text
if (!message) cancel("no message generated")
await workspace.writeText(msg.filename, message)
Loading

0 comments on commit ec62305

Please sign in to comment.