@snelusha/noto 1.0.0-beta.4 → 1.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +54 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -220,7 +220,7 @@ var getModel = async () => {
220
220
  };
221
221
 
222
222
  // src/ai/index.ts
223
- var generateCommitMessage = async (diff) => {
223
+ var generateCommitMessage = async (diff, type) => {
224
224
  const model2 = await getModel();
225
225
  const { object } = await generateObject({
226
226
  model: model2,
@@ -242,7 +242,11 @@ var generateCommitMessage = async (diff) => {
242
242
  6. Avoid mentioning file names unless a file was renamed or is critical for understanding the changes.
243
243
  7. Prioritize clarity and focus on the most impactful changes for the commit.
244
244
 
245
- You are expected to generate structured outputs that align with the provided guidelines and produce a message optimized for readability and accuracy. Strictly follow all constraints to ensure high-quality results.`
245
+ You are expected to generate structured outputs that align with the provided guidelines and produce a message optimized for readability and accuracy. Strictly follow all constraints to ensure high-quality results.
246
+
247
+ ${type ? `if a type is provided (e.g., feat, fix), include it in the commit message in the format "type: message"
248
+
249
+ type: ${type}` : ""}`
246
250
  },
247
251
  {
248
252
  role: "user",
@@ -260,6 +264,12 @@ var command = {
260
264
  description: "generate commit message",
261
265
  usage: "noto [options]",
262
266
  options: [
267
+ {
268
+ type: Boolean,
269
+ flag: "--type",
270
+ alias: "-t",
271
+ description: "generate commit message based on type"
272
+ },
263
273
  {
264
274
  type: Boolean,
265
275
  flag: "--copy",
@@ -285,8 +295,48 @@ var command = {
285
295
  try {
286
296
  const { diff } = options;
287
297
  const isEditMode = options["--edit"];
298
+ if (options["--type"]) {
299
+ const type = await p3.select({
300
+ message: "select the type of commit message",
301
+ options: [
302
+ {
303
+ label: "chore",
304
+ value: "chore"
305
+ },
306
+ {
307
+ label: "feat",
308
+ value: "feat"
309
+ },
310
+ {
311
+ label: "fix",
312
+ value: "fix"
313
+ },
314
+ {
315
+ label: "docs",
316
+ value: "docs"
317
+ },
318
+ {
319
+ label: "refactor",
320
+ value: "refactor"
321
+ },
322
+ {
323
+ label: "perf",
324
+ value: "perf"
325
+ },
326
+ {
327
+ label: "test",
328
+ value: "test"
329
+ }
330
+ ]
331
+ });
332
+ if (p3.isCancel(type)) {
333
+ p3.log.error(color3.red("nothing selected!"));
334
+ return await exit(1);
335
+ }
336
+ options.type = type;
337
+ }
288
338
  spin.start("generating commit message");
289
- let message = await generateCommitMessage(diff);
339
+ let message = await generateCommitMessage(diff, options.type);
290
340
  spin.stop(isEditMode ? color3.white(message) : color3.green(message));
291
341
  if (isEditMode) {
292
342
  const editedMessage = await p3.text({
@@ -543,7 +593,7 @@ function main() {
543
593
  let commandArgs = args;
544
594
  let selectedCommand = cmd;
545
595
  if (cmd.subCommands && commandArgs.length) {
546
- const possibleCommand = commandArgs[0];
596
+ const possibleCommand = commandArgs[1];
547
597
  const subCommand = cmd.subCommands.find(
548
598
  (cmd2) => cmd2.name === possibleCommand || cmd2.aliases && cmd2.aliases.includes(possibleCommand)
549
599
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snelusha/noto",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.0-beta.5",
4
4
  "description": "Generate clean commit messages in a snap! ✨",
5
5
  "license": "MIT",
6
6
  "type": "module",