@snelusha/noto 0.3.4 → 0.3.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.
package/README.md CHANGED
@@ -2,10 +2,6 @@
2
2
  <p align="center"><sup>(/nōto/, <em>notebook</em> in Japanese)</sup></p>
3
3
  <img src="https://github.com/snelusha/static/blob/main/noto/banner-minimal.png?raw=true" align="center"></img>
4
4
 
5
- <pre align="center">
6
- <p>npm install -g <b>@snelusha/noto</b></p>
7
- </pre>
8
-
9
5
  ## Features
10
6
 
11
7
  - **Instant Commit Messages**: Generate clear, context-aware messages based on staged changes.
package/dist/cli.cjs CHANGED
@@ -15,6 +15,7 @@ const ora = require('ora');
15
15
  const simpleGit = require('simple-git');
16
16
  const ai = require('ai');
17
17
  const zod = require('zod');
18
+ const dedent = require('dedent');
18
19
 
19
20
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
20
21
 
@@ -27,6 +28,7 @@ const os__default = /*#__PURE__*/_interopDefaultCompat(os);
27
28
  const process__default = /*#__PURE__*/_interopDefaultCompat(process$1);
28
29
  const ora__default = /*#__PURE__*/_interopDefaultCompat(ora);
29
30
  const simpleGit__default = /*#__PURE__*/_interopDefaultCompat(simpleGit);
31
+ const dedent__default = /*#__PURE__*/_interopDefaultCompat(dedent);
30
32
 
31
33
  function getDefaultExportFromCjs (x) {
32
34
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -3229,14 +3231,13 @@ async function dump() {
3229
3231
  async function isGitRepository() {
3230
3232
  try {
3231
3233
  return await simpleGit__default().checkIsRepo();
3232
- } catch (_) {
3234
+ } catch {
3233
3235
  return false;
3234
3236
  }
3235
3237
  }
3236
3238
  async function getStagedDiff() {
3237
3239
  try {
3238
- const diff = await simpleGit__default().diff(["--cached"]);
3239
- return diff;
3240
+ return await simpleGit__default().diff(["--cached"]);
3240
3241
  } catch {
3241
3242
  return null;
3242
3243
  }
@@ -5007,7 +5008,7 @@ async function generateCommitMessage(diff) {
5007
5008
  messages: [
5008
5009
  {
5009
5010
  role: "system",
5010
- content: `
5011
+ content: dedent__default`
5011
5012
  You are a state-of-the-art AI model tasked with generating a precise Git commit message based on staged changes.
5012
5013
  Adhere strictly to the following instructions, ranked by priority:
5013
5014
 
@@ -5023,15 +5024,14 @@ async function generateCommitMessage(diff) {
5023
5024
  },
5024
5025
  {
5025
5026
  role: "user",
5026
- content: `generate a commit message for the following staged changes:
5027
- ${diff}`
5027
+ content: dedent__default`generate a commit message for the following staged changes:\n${diff}`
5028
5028
  }
5029
5029
  ]
5030
5030
  });
5031
5031
  return object.message.trim();
5032
5032
  }
5033
5033
 
5034
- const version = "0.3.3";
5034
+ const version = "0.3.5";
5035
5035
 
5036
5036
  yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
5037
5037
  "config",
@@ -5057,7 +5057,7 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
5057
5057
  c__default.bold("`noto`")
5058
5058
  )} to generate your commit message!`
5059
5059
  );
5060
- return process.exit(0);
5060
+ process.exit(0);
5061
5061
  }
5062
5062
  }
5063
5063
  const response = await prompts({
@@ -5068,8 +5068,8 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
5068
5068
  });
5069
5069
  if (response.apiKey) {
5070
5070
  storage.apiKey = response.apiKey;
5071
- dump();
5072
- console.log("API key saved successfully!");
5071
+ await dump();
5072
+ console.log("API key configured successfully!");
5073
5073
  console.log(
5074
5074
  `Use ${c__default.greenBright(
5075
5075
  c__default.bold("`noto`")
@@ -5105,15 +5105,12 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
5105
5105
  process.exit(1);
5106
5106
  }
5107
5107
  const message = storage.lastGeneratedMessage;
5108
- const copy = args.copy;
5109
- const apply = args.apply;
5110
5108
  spin.success(`Previous Commit Message: ${c__default.dim(c__default.bold(message))}`);
5111
- if (copy) {
5109
+ if (args.copy) {
5112
5110
  clipboardy__default.writeSync(message);
5113
5111
  spin.success("Message copied to clipboard!");
5114
5112
  }
5115
- if (apply) {
5116
- process.cwd();
5113
+ if (args.apply) {
5117
5114
  if (!await isGitRepository()) {
5118
5115
  console.log(
5119
5116
  c__default.red("Oops! No Git repository found in the current directory.")
@@ -5169,7 +5166,6 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
5169
5166
  );
5170
5167
  process.exit(1);
5171
5168
  }
5172
- process.cwd();
5173
5169
  if (!await isGitRepository()) {
5174
5170
  console.log(
5175
5171
  c__default.red("Oops! No Git repository found in the current directory.")
@@ -5196,17 +5192,15 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
5196
5192
  const spin = spinner();
5197
5193
  try {
5198
5194
  spin.start("Generating commit message...");
5199
- const message = await generateCommitMessage(diff || "");
5195
+ const message = await generateCommitMessage(diff);
5200
5196
  storage.lastGeneratedMessage = message;
5201
5197
  await dump();
5202
- const copy = args.copy;
5203
- const apply = args.apply;
5204
5198
  spin.success(`Commit Message: ${c__default.dim(c__default.bold(message))}`);
5205
- if (copy) {
5199
+ if (args.copy) {
5206
5200
  clipboardy__default.writeSync(message);
5207
5201
  spin.success("Message copied to clipboard!");
5208
5202
  }
5209
- if (apply) {
5203
+ if (args.apply) {
5210
5204
  if (!await commit(message)) {
5211
5205
  spin.fail("Failed to commit staged changes.");
5212
5206
  process.exit(1);
package/dist/cli.mjs CHANGED
@@ -13,6 +13,7 @@ import ora from 'ora';
13
13
  import simpleGit from 'simple-git';
14
14
  import { generateObject } from 'ai';
15
15
  import { z } from 'zod';
16
+ import dedent from 'dedent';
16
17
 
17
18
  function getDefaultExportFromCjs (x) {
18
19
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -3215,14 +3216,13 @@ async function dump() {
3215
3216
  async function isGitRepository() {
3216
3217
  try {
3217
3218
  return await simpleGit().checkIsRepo();
3218
- } catch (_) {
3219
+ } catch {
3219
3220
  return false;
3220
3221
  }
3221
3222
  }
3222
3223
  async function getStagedDiff() {
3223
3224
  try {
3224
- const diff = await simpleGit().diff(["--cached"]);
3225
- return diff;
3225
+ return await simpleGit().diff(["--cached"]);
3226
3226
  } catch {
3227
3227
  return null;
3228
3228
  }
@@ -4993,7 +4993,7 @@ async function generateCommitMessage(diff) {
4993
4993
  messages: [
4994
4994
  {
4995
4995
  role: "system",
4996
- content: `
4996
+ content: dedent`
4997
4997
  You are a state-of-the-art AI model tasked with generating a precise Git commit message based on staged changes.
4998
4998
  Adhere strictly to the following instructions, ranked by priority:
4999
4999
 
@@ -5009,15 +5009,14 @@ async function generateCommitMessage(diff) {
5009
5009
  },
5010
5010
  {
5011
5011
  role: "user",
5012
- content: `generate a commit message for the following staged changes:
5013
- ${diff}`
5012
+ content: dedent`generate a commit message for the following staged changes:\n${diff}`
5014
5013
  }
5015
5014
  ]
5016
5015
  });
5017
5016
  return object.message.trim();
5018
5017
  }
5019
5018
 
5020
- const version = "0.3.3";
5019
+ const version = "0.3.5";
5021
5020
 
5022
5021
  yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
5023
5022
  "config",
@@ -5043,7 +5042,7 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
5043
5042
  c.bold("`noto`")
5044
5043
  )} to generate your commit message!`
5045
5044
  );
5046
- return process.exit(0);
5045
+ process.exit(0);
5047
5046
  }
5048
5047
  }
5049
5048
  const response = await prompts({
@@ -5054,8 +5053,8 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
5054
5053
  });
5055
5054
  if (response.apiKey) {
5056
5055
  storage.apiKey = response.apiKey;
5057
- dump();
5058
- console.log("API key saved successfully!");
5056
+ await dump();
5057
+ console.log("API key configured successfully!");
5059
5058
  console.log(
5060
5059
  `Use ${c.greenBright(
5061
5060
  c.bold("`noto`")
@@ -5091,15 +5090,12 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
5091
5090
  process.exit(1);
5092
5091
  }
5093
5092
  const message = storage.lastGeneratedMessage;
5094
- const copy = args.copy;
5095
- const apply = args.apply;
5096
5093
  spin.success(`Previous Commit Message: ${c.dim(c.bold(message))}`);
5097
- if (copy) {
5094
+ if (args.copy) {
5098
5095
  clipboardy.writeSync(message);
5099
5096
  spin.success("Message copied to clipboard!");
5100
5097
  }
5101
- if (apply) {
5102
- process.cwd();
5098
+ if (args.apply) {
5103
5099
  if (!await isGitRepository()) {
5104
5100
  console.log(
5105
5101
  c.red("Oops! No Git repository found in the current directory.")
@@ -5155,7 +5151,6 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
5155
5151
  );
5156
5152
  process.exit(1);
5157
5153
  }
5158
- process.cwd();
5159
5154
  if (!await isGitRepository()) {
5160
5155
  console.log(
5161
5156
  c.red("Oops! No Git repository found in the current directory.")
@@ -5182,17 +5177,15 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
5182
5177
  const spin = spinner();
5183
5178
  try {
5184
5179
  spin.start("Generating commit message...");
5185
- const message = await generateCommitMessage(diff || "");
5180
+ const message = await generateCommitMessage(diff);
5186
5181
  storage.lastGeneratedMessage = message;
5187
5182
  await dump();
5188
- const copy = args.copy;
5189
- const apply = args.apply;
5190
5183
  spin.success(`Commit Message: ${c.dim(c.bold(message))}`);
5191
- if (copy) {
5184
+ if (args.copy) {
5192
5185
  clipboardy.writeSync(message);
5193
5186
  spin.success("Message copied to clipboard!");
5194
5187
  }
5195
- if (apply) {
5188
+ if (args.apply) {
5196
5189
  if (!await commit(message)) {
5197
5190
  spin.fail("Failed to commit staged changes.");
5198
5191
  process.exit(1);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@snelusha/noto",
3
3
  "type": "module",
4
- "version": "0.3.4",
4
+ "version": "0.3.5",
5
5
  "description": "generate clean commit messages in a snap! ✨",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -43,12 +43,13 @@
43
43
  "dependencies": {
44
44
  "@ai-sdk/google": "^1.0.12",
45
45
  "@posva/prompts": "^2.4.4",
46
- "ai": "^4.0.22",
46
+ "ai": "^4.0.26",
47
47
  "clipboardy": "^4.0.0",
48
+ "dedent": "^1.5.3",
48
49
  "ora": "^8.1.1",
49
50
  "picocolors": "^1.1.1",
50
51
  "simple-git": "^3.27.0",
51
- "unbuild": "^3.0.1",
52
+ "unbuild": "^3.2.0",
52
53
  "which": "^5.0.0",
53
54
  "yargs": "^17.7.2",
54
55
  "zod": "^3.24.1"