mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-04-20 03:02:51 -04:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3705a66ada | ||
|
|
bdb8da49b7 | ||
|
|
6e896ec428 | ||
|
|
9ce961ccc0 | ||
|
|
1a2f6416cc | ||
|
|
4fa438ab17 | ||
|
|
4ad7a5f779 | ||
|
|
5c0b31600f | ||
|
|
d785b821ea | ||
|
|
c50c416dfc | ||
|
|
f8720ff089 | ||
|
|
afa5949c06 | ||
|
|
b1ec69e4dd | ||
|
|
0061816b6a | ||
|
|
352b81c6c6 | ||
|
|
430776af29 | ||
|
|
c573edea97 | ||
|
|
5282734583 |
@@ -83,7 +83,7 @@ To remove description:
|
|||||||
opencommit config set description=false
|
opencommit config set description=false
|
||||||
```
|
```
|
||||||
|
|
||||||
## Git hook
|
<!-- ## Git hook
|
||||||
|
|
||||||
You can set opencommit as Git [`prepare-commit-msg`](https://git-scm.com/docs/githooks#_prepare_commit_msg) hook. Hook integrates with you IDE Source Control and allows you edit the message before commit.
|
You can set opencommit as Git [`prepare-commit-msg`](https://git-scm.com/docs/githooks#_prepare_commit_msg) hook. Hook integrates with you IDE Source Control and allows you edit the message before commit.
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ To use the hook:
|
|||||||
git commit
|
git commit
|
||||||
```
|
```
|
||||||
|
|
||||||
Or follow the process of your IDE Source Control feature, when it calls `git commit` command — OpenCommit will integrate into the flow.
|
Or follow the process of your IDE Source Control feature, when it calls `git commit` command — OpenCommit will integrate into the flow. -->
|
||||||
|
|
||||||
## Payments
|
## Payments
|
||||||
|
|
||||||
|
|||||||
6
TODO.md
6
TODO.md
@@ -1,4 +1,8 @@
|
|||||||
# TODOs
|
# TODOs
|
||||||
|
|
||||||
- [] [build for both mjs and cjs](https://snyk.io/blog/best-practices-create-modern-npm-package/)
|
- [] [build for both mjs and cjs](https://snyk.io/blog/best-practices-create-modern-npm-package/)
|
||||||
- []
|
- [] make bundle smaller by properly configuring esbuild
|
||||||
|
- [] do // TODOs in the code
|
||||||
|
- [] batch small files in one request
|
||||||
|
- [] add tests
|
||||||
|
- [] make hook work
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "open-commit",
|
"name": "open-commit",
|
||||||
"version": "0.0.6",
|
"version": "0.0.14",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "open-commit",
|
"name": "open-commit",
|
||||||
"version": "0.0.6",
|
"version": "0.0.14",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@clack/prompts": "^0.6.1",
|
"@clack/prompts": "^0.6.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "opencommit",
|
"name": "opencommit",
|
||||||
"version": "0.0.6",
|
"version": "0.0.14",
|
||||||
"description": "AI generates conventional commits with mind-blowing accuracy.",
|
"description": "AI generates conventional commits with mind-blowing accuracy.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"git",
|
"git",
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"start": "node ./out/cli.cjs",
|
"start": "node ./out/cli.cjs",
|
||||||
"dev": "ts-node ./src/cli.ts",
|
"dev": "ts-node ./src/cli.ts",
|
||||||
"build": "rimraf out && esbuild ./src/cli.ts --bundle --outfile=out/cli.cjs --format=cjs --platform=node",
|
"build": "rimraf out && esbuild ./src/cli.ts --bundle --outfile=out/cli.cjs --format=cjs --platform=node",
|
||||||
"publish": "npm version patch && npm publish",
|
"patch": "npm version patch",
|
||||||
"lint": "eslint src --ext ts && tsc --noEmit"
|
"lint": "eslint src --ext ts && tsc --noEmit"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
0
src/cli.ts
Normal file → Executable file
0
src/cli.ts
Normal file → Executable file
@@ -19,59 +19,71 @@ export const hookCommand = command(
|
|||||||
name: 'hook',
|
name: 'hook',
|
||||||
parameters: ['<set/unset>']
|
parameters: ['<set/unset>']
|
||||||
},
|
},
|
||||||
async (argv) => {
|
(argv) => {
|
||||||
const HOOK_PATH = fileURLToPath(new URL('cli.mjs', import.meta.url));
|
const HOOK_PATH = fileURLToPath(new URL('cli.cjs', import.meta.url));
|
||||||
|
|
||||||
try {
|
(async () => {
|
||||||
await assertGitRepo();
|
try {
|
||||||
|
await assertGitRepo();
|
||||||
|
|
||||||
const { setUnset: mode } = argv._;
|
const { setUnset: mode } = argv._;
|
||||||
|
|
||||||
if (mode === 'set') {
|
if (mode === 'set') {
|
||||||
intro(`setting opencommit as '${HOOK_NAME}' hook`);
|
intro(`setting opencommit as '${HOOK_NAME}' hook`);
|
||||||
if (isHookExists) {
|
|
||||||
const realPath = await fs.realpath(SYMLINK_URL);
|
|
||||||
|
|
||||||
if (realPath === HOOK_PATH)
|
if (isHookExists) {
|
||||||
return outro(`opencommit is already set as '${HOOK_NAME}'`);
|
let realPath;
|
||||||
|
try {
|
||||||
|
realPath = await fs.realpath(SYMLINK_URL);
|
||||||
|
console.log(123, { realPath });
|
||||||
|
} catch (error) {
|
||||||
|
console.log(321, { realPath });
|
||||||
|
outro(error as string);
|
||||||
|
realPath = null;
|
||||||
|
}
|
||||||
|
|
||||||
throw new Error(
|
if (realPath === HOOK_PATH)
|
||||||
`Different ${HOOK_NAME} is already set. Remove it before setting opencommit as '${HOOK_NAME}' hook.`
|
return outro(`opencommit is already set as '${HOOK_NAME}'`);
|
||||||
);
|
|
||||||
|
throw new Error(
|
||||||
|
`Different ${HOOK_NAME} is already set. Remove it before setting opencommit as '${HOOK_NAME}' hook.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await fs.mkdir(path.dirname(SYMLINK_URL), { recursive: true });
|
||||||
|
await fs.symlink(HOOK_PATH, SYMLINK_URL, 'file');
|
||||||
|
await fs.chmod(SYMLINK_URL, 0o755);
|
||||||
|
|
||||||
|
return outro(`${chalk.green('✔')} Hook set`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await fs.mkdir(path.dirname(SYMLINK_URL), { recursive: true });
|
if (mode === 'unset') {
|
||||||
await fs.symlink(HOOK_PATH, SYMLINK_URL, 'file');
|
intro(`unsetting opencommit as '${HOOK_NAME}' hook`);
|
||||||
await fs.chmod(SYMLINK_URL, 0o755);
|
|
||||||
|
|
||||||
return outro(`${chalk.green('✔')} Hook set`);
|
if (!isHookExists) {
|
||||||
|
return outro(
|
||||||
|
`opencommit wasn't previously set as '${HOOK_NAME}' hook, nothing to remove`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const realpath = await fs.realpath(SYMLINK_URL);
|
||||||
|
if (realpath !== HOOK_PATH) {
|
||||||
|
return outro(
|
||||||
|
`opencommit wasn't previously set as '${HOOK_NAME}' hook, but different hook was, if you want to remove it — do it manually`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await fs.rm(SYMLINK_URL);
|
||||||
|
return outro(`${chalk.green('✔')} Hook is removed`);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(
|
||||||
|
`unsupported mode: ${mode}. Supported modes are: 'set' or 'unset'`
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
outro(`${chalk.red('✖')} ${error}`);
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
})();
|
||||||
if (mode === 'unset') {
|
|
||||||
intro(`unsetting opencommit as '${HOOK_NAME}' hook`);
|
|
||||||
if (!isHookExists) {
|
|
||||||
return outro(
|
|
||||||
`opencommit wasn't previously set as '${HOOK_NAME}' hook, nothing to remove`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const realpath = await fs.realpath(SYMLINK_URL);
|
|
||||||
if (realpath !== HOOK_PATH) {
|
|
||||||
return outro(
|
|
||||||
`opencommit wasn't previously set as '${HOOK_NAME}' hook, but different hook was, if you want to remove it — do it manually`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await fs.rm(SYMLINK_URL);
|
|
||||||
return outro(`${chalk.green('✔')} Hook is removed`);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error(
|
|
||||||
`unsupported mode: ${mode}. Supported modes are: 'set' or 'unset'`
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
outro(`${chalk.red('✖')} ${error}`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user