Compare commits

..

6 Commits

Author SHA1 Message Date
di-sukharev
757faba0c4 0.0.18 2023-03-06 21:42:05 +08:00
di-sukharev
422d38d51e * 🐛 fix(githook.ts): update HOOK_PATH to point to the correct file path
The HOOK_PATH variable was pointing to the wrong file path, which caused the hook to fail. The file path has been updated to point to the correct file path.
2023-03-06 21:41:58 +08:00
di-sukharev
ee02be56b2 0.0.17 2023-03-06 21:40:49 +08:00
di-sukharev
1c762a6e8c * 🚀 feat(package.json): add deploy script
The deploy script builds the application, increments the patch version, and publishes the package to the registry. This makes it easier to deploy new versions of the application.
2023-03-06 21:40:39 +08:00
di-sukharev
6126fad25c 0.0.16 2023-03-06 21:38:26 +08:00
di-sukharev
01cdd2f58d removed async iife 2023-03-06 21:36:37 +08:00
3 changed files with 55 additions and 59 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "open-commit",
"version": "0.0.15",
"version": "0.0.18",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "open-commit",
"version": "0.0.15",
"version": "0.0.18",
"license": "ISC",
"dependencies": {
"@clack/prompts": "^0.6.1",

View File

@@ -1,6 +1,6 @@
{
"name": "opencommit",
"version": "0.0.15",
"version": "0.0.18",
"description": "AI generates conventional commits with mind-blowing accuracy.",
"keywords": [
"git",
@@ -37,7 +37,7 @@
"start": "node ./out/cli.cjs",
"dev": "ts-node ./src/cli.ts",
"build": "rimraf out && esbuild ./src/cli.ts --bundle --outfile=out/cli.cjs --format=cjs --platform=node",
"patch": "npm version patch",
"deploy": "npm run build && npm version patch && npm publish",
"lint": "eslint src --ext ts && tsc --noEmit"
},
"devDependencies": {

View File

@@ -19,71 +19,67 @@ export const hookCommand = command(
name: 'hook',
parameters: ['<set/unset>']
},
(argv) => {
const HOOK_PATH = fileURLToPath(new URL('cli.cjs', import.meta.url));
async (argv) => {
const HOOK_PATH = fileURLToPath(new URL('out/cli.cjs', import.meta.url));
(async () => {
try {
await assertGitRepo();
try {
await assertGitRepo();
const { setUnset: mode } = argv._;
const { setUnset: mode } = argv._;
if (mode === 'set') {
intro(`setting opencommit as '${HOOK_NAME}' hook`);
if (mode === 'set') {
intro(`setting opencommit as '${HOOK_NAME}' hook`);
if (isHookExists) {
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;
}
if (realPath === HOOK_PATH)
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.`
);
if (isHookExists) {
let realPath;
try {
realPath = await fs.realpath(SYMLINK_URL);
} catch (error) {
outro(error as string);
realPath = null;
}
await fs.mkdir(path.dirname(SYMLINK_URL), { recursive: true });
await fs.symlink(HOOK_PATH, SYMLINK_URL, 'file');
await fs.chmod(SYMLINK_URL, 0o755);
if (realPath === HOOK_PATH)
return outro(`opencommit is already set as '${HOOK_NAME}'`);
return outro(`${chalk.green('✔')} Hook set`);
throw new Error(
`Different ${HOOK_NAME} is already set. Remove it before setting opencommit as '${HOOK_NAME}' hook.`
);
}
if (mode === 'unset') {
intro(`unsetting 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);
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);
return outro(`${chalk.green('✔')} Hook set`);
}
})();
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);
}
}
);