@snelusha/noto 1.0.0-beta.2 → 1.0.0-beta.3
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/dist/index.js +49 -11
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var parse = (schema, raw) => {
|
|
|
15
15
|
// src/commands/noto.ts
|
|
16
16
|
import * as p3 from "@clack/prompts";
|
|
17
17
|
import color3 from "picocolors";
|
|
18
|
+
import clipboard from "clipboardy";
|
|
18
19
|
|
|
19
20
|
// src/middleware/auth.ts
|
|
20
21
|
import * as p from "@clack/prompts";
|
|
@@ -127,6 +128,16 @@ var getStagedDiff = async () => {
|
|
|
127
128
|
return null;
|
|
128
129
|
}
|
|
129
130
|
};
|
|
131
|
+
var commit = async (message) => {
|
|
132
|
+
try {
|
|
133
|
+
const {
|
|
134
|
+
summary: { changes }
|
|
135
|
+
} = await git.commit(message);
|
|
136
|
+
return Boolean(changes);
|
|
137
|
+
} catch {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
130
141
|
|
|
131
142
|
// src/middleware/git.ts
|
|
132
143
|
var withRepository = (fn) => {
|
|
@@ -154,6 +165,14 @@ var withRepository = (fn) => {
|
|
|
154
165
|
};
|
|
155
166
|
};
|
|
156
167
|
|
|
168
|
+
// src/ai/index.ts
|
|
169
|
+
import { generateObject } from "ai";
|
|
170
|
+
import z3 from "zod";
|
|
171
|
+
import dedent3 from "dedent";
|
|
172
|
+
|
|
173
|
+
// src/ai/models.ts
|
|
174
|
+
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
175
|
+
|
|
157
176
|
// src/errors.ts
|
|
158
177
|
var NotoError = class _NotoError extends Error {
|
|
159
178
|
code;
|
|
@@ -164,13 +183,7 @@ var NotoError = class _NotoError extends Error {
|
|
|
164
183
|
}
|
|
165
184
|
};
|
|
166
185
|
|
|
167
|
-
// src/ai/index.ts
|
|
168
|
-
import { generateObject } from "ai";
|
|
169
|
-
import z3 from "zod";
|
|
170
|
-
import dedent3 from "dedent";
|
|
171
|
-
|
|
172
186
|
// src/ai/models.ts
|
|
173
|
-
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
174
187
|
var google = createGoogleGenerativeAI({
|
|
175
188
|
apiKey: (await StorageManager.get()).llm?.apiKey ?? "api-key"
|
|
176
189
|
});
|
|
@@ -240,7 +253,20 @@ var command = {
|
|
|
240
253
|
name: "noto",
|
|
241
254
|
description: "generate commit message",
|
|
242
255
|
usage: "noto [options]",
|
|
243
|
-
options: [
|
|
256
|
+
options: [
|
|
257
|
+
{
|
|
258
|
+
type: Boolean,
|
|
259
|
+
flag: "--copy",
|
|
260
|
+
alias: "-c",
|
|
261
|
+
description: "copy the generated commit message to clipboard"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
type: Boolean,
|
|
265
|
+
flag: "--apply",
|
|
266
|
+
alias: "-a",
|
|
267
|
+
description: "commit the generated message directly"
|
|
268
|
+
}
|
|
269
|
+
],
|
|
244
270
|
execute: withAuth(
|
|
245
271
|
withRepository(async (options) => {
|
|
246
272
|
const spin = p3.spinner();
|
|
@@ -249,12 +275,24 @@ var command = {
|
|
|
249
275
|
spin.start("generating commit message");
|
|
250
276
|
const message = await generateCommitMessage(diff);
|
|
251
277
|
spin.stop(color3.green(message));
|
|
278
|
+
if (options["--copy"]) {
|
|
279
|
+
clipboard.writeSync(message);
|
|
280
|
+
p3.log.step(color3.dim("copied commit message to clipboard"));
|
|
281
|
+
}
|
|
282
|
+
if (options["--apply"]) {
|
|
283
|
+
const success = await commit(message);
|
|
284
|
+
if (success) {
|
|
285
|
+
p3.log.step(color3.dim("commit successful"));
|
|
286
|
+
} else {
|
|
287
|
+
p3.log.error(color3.red("failed to commit changes"));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
252
290
|
} catch {
|
|
253
291
|
spin.stop(color3.red("failed to generate commit message"), 1);
|
|
254
|
-
console.log();
|
|
255
292
|
process.exit(1);
|
|
293
|
+
} finally {
|
|
294
|
+
process.stdout.write("\n");
|
|
256
295
|
}
|
|
257
|
-
console.log();
|
|
258
296
|
})
|
|
259
297
|
)
|
|
260
298
|
};
|
|
@@ -367,7 +405,7 @@ var getCommand = (name, cmds = commands) => {
|
|
|
367
405
|
};
|
|
368
406
|
|
|
369
407
|
// package.json
|
|
370
|
-
var version = "1.0.0-beta.
|
|
408
|
+
var version = "1.0.0-beta.3";
|
|
371
409
|
|
|
372
410
|
// src/index.ts
|
|
373
411
|
var globalSpec = {
|
|
@@ -384,7 +422,7 @@ function main() {
|
|
|
384
422
|
if (globalOptions["--version"]) return p5.outro(version);
|
|
385
423
|
const cmd = getCommand(command3) ?? getCommand("noto");
|
|
386
424
|
if (!cmd) return getCommand("noto")?.execute(globalOptions);
|
|
387
|
-
let commandArgs =
|
|
425
|
+
let commandArgs = args;
|
|
388
426
|
let selectedCommand = cmd;
|
|
389
427
|
if (cmd.subCommands && commandArgs.length) {
|
|
390
428
|
const possibleCommand = commandArgs[0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snelusha/noto",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "Generate clean commit messages in a snap! ✨",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@clack/prompts": "^0.10.0",
|
|
44
44
|
"ai": "^4.1.40",
|
|
45
45
|
"arg": "^5.0.2",
|
|
46
|
+
"clipboardy": "^4.0.0",
|
|
46
47
|
"dedent": "^1.5.3",
|
|
47
48
|
"picocolors": "^1.1.1",
|
|
48
49
|
"simple-git": "^3.27.0",
|