@snelusha/noto 1.0.0-beta.1 → 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 -12
- package/package.json +2 -2
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
|
});
|
|
@@ -202,7 +215,6 @@ var getModel = async () => {
|
|
|
202
215
|
|
|
203
216
|
// src/ai/index.ts
|
|
204
217
|
var generateCommitMessage = async (diff) => {
|
|
205
|
-
throw new Error("something");
|
|
206
218
|
const model2 = await getModel();
|
|
207
219
|
const { object } = await generateObject({
|
|
208
220
|
model: model2,
|
|
@@ -241,7 +253,20 @@ var command = {
|
|
|
241
253
|
name: "noto",
|
|
242
254
|
description: "generate commit message",
|
|
243
255
|
usage: "noto [options]",
|
|
244
|
-
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
|
+
],
|
|
245
270
|
execute: withAuth(
|
|
246
271
|
withRepository(async (options) => {
|
|
247
272
|
const spin = p3.spinner();
|
|
@@ -250,11 +275,23 @@ var command = {
|
|
|
250
275
|
spin.start("generating commit message");
|
|
251
276
|
const message = await generateCommitMessage(diff);
|
|
252
277
|
spin.stop(color3.green(message));
|
|
253
|
-
|
|
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
|
+
}
|
|
254
290
|
} catch {
|
|
255
291
|
spin.stop(color3.red("failed to generate commit message"), 1);
|
|
256
|
-
console.log();
|
|
257
292
|
process.exit(1);
|
|
293
|
+
} finally {
|
|
294
|
+
process.stdout.write("\n");
|
|
258
295
|
}
|
|
259
296
|
})
|
|
260
297
|
)
|
|
@@ -368,7 +405,7 @@ var getCommand = (name, cmds = commands) => {
|
|
|
368
405
|
};
|
|
369
406
|
|
|
370
407
|
// package.json
|
|
371
|
-
var version = "1.0.0-beta
|
|
408
|
+
var version = "1.0.0-beta.3";
|
|
372
409
|
|
|
373
410
|
// src/index.ts
|
|
374
411
|
var globalSpec = {
|
|
@@ -385,7 +422,7 @@ function main() {
|
|
|
385
422
|
if (globalOptions["--version"]) return p5.outro(version);
|
|
386
423
|
const cmd = getCommand(command3) ?? getCommand("noto");
|
|
387
424
|
if (!cmd) return getCommand("noto")?.execute(globalOptions);
|
|
388
|
-
let commandArgs =
|
|
425
|
+
let commandArgs = args;
|
|
389
426
|
let selectedCommand = cmd;
|
|
390
427
|
if (cmd.subCommands && commandArgs.length) {
|
|
391
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",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@ai-sdk/google": "^1.1.14",
|
|
43
43
|
"@clack/prompts": "^0.10.0",
|
|
44
|
-
"@snelusha/noto": "link:@snelusha/noto",
|
|
45
44
|
"ai": "^4.1.40",
|
|
46
45
|
"arg": "^5.0.2",
|
|
46
|
+
"clipboardy": "^4.0.0",
|
|
47
47
|
"dedent": "^1.5.3",
|
|
48
48
|
"picocolors": "^1.1.1",
|
|
49
49
|
"simple-git": "^3.27.0",
|