@snelusha/noto 1.0.6 → 1.0.7

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 +35 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -176,7 +176,7 @@ var isFirstCommit = async () => {
176
176
  };
177
177
  var getStagedDiff = async () => {
178
178
  try {
179
- return git.diff(["--cached"]);
179
+ return git.diff(["--cached", "--", ":!*.lock"]);
180
180
  } catch {
181
181
  return null;
182
182
  }
@@ -191,6 +191,14 @@ var commit = async (message) => {
191
191
  return false;
192
192
  }
193
193
  };
194
+ var push = async () => {
195
+ try {
196
+ const result = await git.push();
197
+ return result.update || result.pushed && result.pushed.length > 0;
198
+ } catch {
199
+ return false;
200
+ }
201
+ };
194
202
 
195
203
  // src/middleware/git.ts
196
204
  var withRepository = (fn, options = { enabled: true }) => {
@@ -199,20 +207,22 @@ var withRepository = (fn, options = { enabled: true }) => {
199
207
  if (!isRepo && options.enabled) {
200
208
  p2.log.error(
201
209
  dedent2`${color2.red("no git repository found in cwd.")}
202
- ${color2.dim(`run ${color2.cyan("`git init`")} to initialize a new repository.`)}`
210
+ ${color2.dim(`run ${color2.cyan("`git init`")} to initialize a new repository.`)}`
203
211
  );
204
212
  return await exit(1);
205
213
  }
206
214
  opts.isRepo = isRepo;
207
- const diff = await getStagedDiff();
208
- if (!diff && options.enabled) {
209
- p2.log.error(
210
- dedent2`${color2.red("no staged changes found.")}
211
- ${color2.dim(`run ${color2.cyan("`git add <file>`")} or ${color2.cyan("`git add .`")} to stage changes.`)}`
212
- );
213
- return await exit(1);
215
+ if (isRepo) {
216
+ const diff = await getStagedDiff();
217
+ if (!diff && options.enabled) {
218
+ p2.log.error(
219
+ dedent2`${color2.red("no staged changes found.")}
220
+ ${color2.dim(`run ${color2.cyan("`git add <file>`")} or ${color2.cyan("`git add .`")} to stage changes.`)}`
221
+ );
222
+ return await exit(1);
223
+ }
224
+ opts.diff = diff;
214
225
  }
215
- opts.diff = diff;
216
226
  return fn(opts);
217
227
  };
218
228
  };
@@ -352,6 +362,12 @@ var command = {
352
362
  alias: "-a",
353
363
  description: "commit the generated message directly"
354
364
  },
365
+ {
366
+ type: Boolean,
367
+ flag: "--push",
368
+ alias: "-p",
369
+ description: "commit and push the changes"
370
+ },
355
371
  {
356
372
  type: Boolean,
357
373
  flag: "--edit",
@@ -416,6 +432,14 @@ var command = {
416
432
  p3.log.error(color3.red("failed to commit changes"));
417
433
  }
418
434
  }
435
+ if (options["--push"]) {
436
+ const success = await push();
437
+ if (success) {
438
+ p3.log.step(color3.dim("push successful"));
439
+ } else {
440
+ p3.log.error(color3.red("failed to push changes"));
441
+ }
442
+ }
419
443
  return await exit(0);
420
444
  } catch {
421
445
  spin.stop(color3.red("failed to generate commit message"), 1);
@@ -685,7 +709,7 @@ var listCommand = () => {
685
709
  };
686
710
 
687
711
  // package.json
688
- var version = "1.0.6";
712
+ var version = "1.0.7";
689
713
 
690
714
  // src/index.ts
691
715
  var globalSpec = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snelusha/noto",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Generate clean commit messages in a snap! ✨",
5
5
  "license": "MIT",
6
6
  "type": "module",