@snelusha/noto 0.3.3 → 0.3.4

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
@@ -1,6 +1,6 @@
1
1
  <h1 align="center">noto ✨</h1>
2
2
  <p align="center"><sup>(/nōto/, <em>notebook</em> in Japanese)</sup></p>
3
- <img src="https://github.com/snelusha/static/blob/main/noto/banner.png?raw=true" align="center"></img>
3
+ <img src="https://github.com/snelusha/static/blob/main/noto/banner-minimal.png?raw=true" align="center"></img>
4
4
 
5
5
  <pre align="center">
6
6
  <p>npm install -g <b>@snelusha/noto</b></p>
package/dist/cli.cjs CHANGED
@@ -12,7 +12,7 @@ const os = require('node:os');
12
12
  const process$1 = require('node:process');
13
13
  require('which');
14
14
  const ora = require('ora');
15
- const tinyexec = require('tinyexec');
15
+ const simpleGit = require('simple-git');
16
16
  const ai = require('ai');
17
17
  const zod = require('zod');
18
18
 
@@ -26,6 +26,7 @@ const clipboardy__default = /*#__PURE__*/_interopDefaultCompat(clipboardy);
26
26
  const os__default = /*#__PURE__*/_interopDefaultCompat(os);
27
27
  const process__default = /*#__PURE__*/_interopDefaultCompat(process$1);
28
28
  const ora__default = /*#__PURE__*/_interopDefaultCompat(ora);
29
+ const simpleGit__default = /*#__PURE__*/_interopDefaultCompat(simpleGit);
29
30
 
30
31
  function getDefaultExportFromCjs (x) {
31
32
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -3225,12 +3226,16 @@ async function dump() {
3225
3226
  }
3226
3227
  }
3227
3228
 
3228
- function isGitRepository(path) {
3229
- return node_fs.existsSync(node_path.join(path, ".git"));
3229
+ async function isGitRepository() {
3230
+ try {
3231
+ return await simpleGit__default().checkIsRepo();
3232
+ } catch (_) {
3233
+ return false;
3234
+ }
3230
3235
  }
3231
3236
  async function getStagedDiff() {
3232
3237
  try {
3233
- const diff = (await tinyexec.x("git", ["diff", "--cached"])).stdout.toString();
3238
+ const diff = await simpleGit__default().diff(["--cached"]);
3234
3239
  return diff;
3235
3240
  } catch {
3236
3241
  return null;
@@ -3238,8 +3243,8 @@ async function getStagedDiff() {
3238
3243
  }
3239
3244
  async function commit(message) {
3240
3245
  try {
3241
- const result = await tinyexec.x("git", ["commit", "-m", message]);
3242
- return /file(s)? changed/i.test(result.stdout.toString());
3246
+ const result = await simpleGit__default().commit(message);
3247
+ return result.summary.changes > 0;
3243
3248
  } catch {
3244
3249
  return false;
3245
3250
  }
@@ -5108,8 +5113,8 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
5108
5113
  spin.success("Message copied to clipboard!");
5109
5114
  }
5110
5115
  if (apply) {
5111
- const cwd = process.cwd();
5112
- if (!isGitRepository(cwd)) {
5116
+ process.cwd();
5117
+ if (!await isGitRepository()) {
5113
5118
  console.log(
5114
5119
  c__default.red("Oops! No Git repository found in the current directory.")
5115
5120
  );
@@ -5164,8 +5169,8 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
5164
5169
  );
5165
5170
  process.exit(1);
5166
5171
  }
5167
- const cwd = process.cwd();
5168
- if (!isGitRepository(cwd)) {
5172
+ process.cwd();
5173
+ if (!await isGitRepository()) {
5169
5174
  console.log(
5170
5175
  c__default.red("Oops! No Git repository found in the current directory.")
5171
5176
  );
@@ -5191,7 +5196,7 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
5191
5196
  const spin = spinner();
5192
5197
  try {
5193
5198
  spin.start("Generating commit message...");
5194
- const message = await generateCommitMessage(diff);
5199
+ const message = await generateCommitMessage(diff || "");
5195
5200
  storage.lastGeneratedMessage = message;
5196
5201
  await dump();
5197
5202
  const copy = args.copy;
package/dist/cli.mjs CHANGED
@@ -10,7 +10,7 @@ import os from 'node:os';
10
10
  import process$1 from 'node:process';
11
11
  import 'which';
12
12
  import ora from 'ora';
13
- import { x } from 'tinyexec';
13
+ import simpleGit from 'simple-git';
14
14
  import { generateObject } from 'ai';
15
15
  import { z } from 'zod';
16
16
 
@@ -3212,12 +3212,16 @@ async function dump() {
3212
3212
  }
3213
3213
  }
3214
3214
 
3215
- function isGitRepository(path) {
3216
- return existsSync(join(path, ".git"));
3215
+ async function isGitRepository() {
3216
+ try {
3217
+ return await simpleGit().checkIsRepo();
3218
+ } catch (_) {
3219
+ return false;
3220
+ }
3217
3221
  }
3218
3222
  async function getStagedDiff() {
3219
3223
  try {
3220
- const diff = (await x("git", ["diff", "--cached"])).stdout.toString();
3224
+ const diff = await simpleGit().diff(["--cached"]);
3221
3225
  return diff;
3222
3226
  } catch {
3223
3227
  return null;
@@ -3225,8 +3229,8 @@ async function getStagedDiff() {
3225
3229
  }
3226
3230
  async function commit(message) {
3227
3231
  try {
3228
- const result = await x("git", ["commit", "-m", message]);
3229
- return /file(s)? changed/i.test(result.stdout.toString());
3232
+ const result = await simpleGit().commit(message);
3233
+ return result.summary.changes > 0;
3230
3234
  } catch {
3231
3235
  return false;
3232
3236
  }
@@ -5095,8 +5099,8 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
5095
5099
  spin.success("Message copied to clipboard!");
5096
5100
  }
5097
5101
  if (apply) {
5098
- const cwd = process.cwd();
5099
- if (!isGitRepository(cwd)) {
5102
+ process.cwd();
5103
+ if (!await isGitRepository()) {
5100
5104
  console.log(
5101
5105
  c.red("Oops! No Git repository found in the current directory.")
5102
5106
  );
@@ -5151,8 +5155,8 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
5151
5155
  );
5152
5156
  process.exit(1);
5153
5157
  }
5154
- const cwd = process.cwd();
5155
- if (!isGitRepository(cwd)) {
5158
+ process.cwd();
5159
+ if (!await isGitRepository()) {
5156
5160
  console.log(
5157
5161
  c.red("Oops! No Git repository found in the current directory.")
5158
5162
  );
@@ -5178,7 +5182,7 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
5178
5182
  const spin = spinner();
5179
5183
  try {
5180
5184
  spin.start("Generating commit message...");
5181
- const message = await generateCommitMessage(diff);
5185
+ const message = await generateCommitMessage(diff || "");
5182
5186
  storage.lastGeneratedMessage = message;
5183
5187
  await dump();
5184
5188
  const copy = args.copy;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@snelusha/noto",
3
3
  "type": "module",
4
- "version": "0.3.3",
4
+ "version": "0.3.4",
5
5
  "description": "generate clean commit messages in a snap! ✨",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -47,7 +47,7 @@
47
47
  "clipboardy": "^4.0.0",
48
48
  "ora": "^8.1.1",
49
49
  "picocolors": "^1.1.1",
50
- "tinyexec": "^0.3.1",
50
+ "simple-git": "^3.27.0",
51
51
  "unbuild": "^3.0.1",
52
52
  "which": "^5.0.0",
53
53
  "yargs": "^17.7.2",