mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-01-13 07:38:01 -05:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cad179953a | ||
|
|
8979841010 | ||
|
|
1e974086d3 | ||
|
|
792ab67ef1 | ||
|
|
a7af55df37 | ||
|
|
5c540abae9 | ||
|
|
f69e716dcc | ||
|
|
1d8d8e57c2 | ||
|
|
fdc638cd86 |
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none"
|
||||
"trailingComma": "none",
|
||||
"singleQuote": true
|
||||
}
|
||||
|
||||
100
out/cli.cjs
100
out/cli.cjs
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "opencommit",
|
||||
"version": "2.2.7",
|
||||
"version": "2.2.10",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "opencommit",
|
||||
"version": "2.2.7",
|
||||
"version": "2.2.10",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "opencommit",
|
||||
"version": "2.2.7",
|
||||
"version": "2.2.10",
|
||||
"description": "Auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
|
||||
"keywords": [
|
||||
"git",
|
||||
|
||||
25
src/api.ts
25
src/api.ts
@@ -7,9 +7,14 @@ import {
|
||||
OpenAIApi
|
||||
} from 'openai';
|
||||
|
||||
import {CONFIG_MODES, DEFAULT_MODEL_TOKEN_LIMIT, getConfig} from './commands/config';
|
||||
import {tokenCount} from './utils/tokenCount';
|
||||
import {GenerateCommitMessageErrorEnum} from './generateCommitMessageFromGitDiff';
|
||||
import {
|
||||
CONFIG_MODES,
|
||||
DEFAULT_MODEL_TOKEN_LIMIT,
|
||||
getConfig
|
||||
} from './commands/config';
|
||||
import { tokenCount } from './utils/tokenCount';
|
||||
import { GenerateCommitMessageErrorEnum } from './generateCommitMessageFromGitDiff';
|
||||
import { execa } from 'execa';
|
||||
|
||||
const config = getConfig();
|
||||
|
||||
@@ -58,11 +63,11 @@ class OpenAi {
|
||||
max_tokens: maxTokens || 500
|
||||
};
|
||||
try {
|
||||
const REQUEST_TOKENS = messages.map(
|
||||
(msg) => tokenCount(msg.content) + 4
|
||||
).reduce((a, b) => a + b, 0);
|
||||
const REQUEST_TOKENS = messages
|
||||
.map((msg) => tokenCount(msg.content) + 4)
|
||||
.reduce((a, b) => a + b, 0);
|
||||
|
||||
if (REQUEST_TOKENS > (DEFAULT_MODEL_TOKEN_LIMIT - maxTokens)) {
|
||||
if (REQUEST_TOKENS > DEFAULT_MODEL_TOKEN_LIMIT - maxTokens) {
|
||||
throw new Error(GenerateCommitMessageErrorEnum.tooMuchTokens);
|
||||
}
|
||||
|
||||
@@ -98,10 +103,8 @@ export const getOpenCommitLatestVersion = async (): Promise<
|
||||
string | undefined
|
||||
> => {
|
||||
try {
|
||||
const { data } = await axios.get(
|
||||
'https://unpkg.com/opencommit/package.json'
|
||||
);
|
||||
return data.version;
|
||||
const { stdout } = await execa('npm', ['view', 'opencommit', 'version']);
|
||||
return stdout;
|
||||
} catch (_) {
|
||||
outro('Error while getting the latest version of opencommit');
|
||||
return undefined;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { getOpenCommitLatestVersion } from '../api';
|
||||
import currentPackage from '../../package.json' assert { type: 'json' };
|
||||
import chalk from 'chalk';
|
||||
import { outro } from '@clack/prompts';
|
||||
|
||||
export const checkIsLatestVersion = async () => {
|
||||
const latestVersion = await getOpenCommitLatestVersion();
|
||||
@@ -9,7 +10,7 @@ export const checkIsLatestVersion = async () => {
|
||||
const currentVersion = currentPackage.version;
|
||||
|
||||
if (currentVersion !== latestVersion) {
|
||||
console.warn(
|
||||
outro(
|
||||
chalk.yellow(
|
||||
`
|
||||
You are not using the latest stable version of OpenCommit with new features and bug fixes.
|
||||
|
||||
Reference in New Issue
Block a user